• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.haptics.msdl
18 
19 import com.google.android.msdl.data.model.FeedbackLevel
20 import com.google.android.msdl.data.model.MSDLToken
21 import com.google.android.msdl.domain.InteractionProperties
22 import com.google.android.msdl.domain.MSDLPlayer
23 import com.google.android.msdl.logging.MSDLEvent
24 
25 class FakeMSDLPlayer : MSDLPlayer {
26     val tokensPlayed = mutableListOf<MSDLToken>()
27     val propertiesPlayed = mutableListOf<InteractionProperties?>()
28     private val history = arrayListOf<MSDLEvent>()
29 
30     var currentFeedbackLevel = FeedbackLevel.DEFAULT
31     var latestTokenPlayed: MSDLToken? = null
32         get() = tokensPlayed.lastOrNull()
33         private set
34 
35     var latestPropertiesPlayed: InteractionProperties? = null
36         get() = propertiesPlayed.lastOrNull()
37         private set
38 
getSystemFeedbackLevelnull39     override fun getSystemFeedbackLevel(): FeedbackLevel = currentFeedbackLevel
40 
41     override fun playToken(token: MSDLToken, properties: InteractionProperties?) {
42         tokensPlayed.add(token)
43         propertiesPlayed.add(properties)
44         history.add(MSDLEvent(token, properties))
45     }
46 
getHistorynull47     override fun getHistory(): List<MSDLEvent> = history
48 }
49