1 package com.android.systemui.statusbar.policy
2 
3 import android.content.res.Configuration
4 import com.android.systemui.dagger.SysUISingleton
5 import dagger.Binds
6 import dagger.Module
7 import javax.inject.Inject
8 
9 /** Fake implementation of [ConfigurationController] for tests. */
10 @SysUISingleton
11 class FakeConfigurationController @Inject constructor() : ConfigurationController {
12 
13     private var listeners = mutableListOf<ConfigurationController.ConfigurationListener>()
14     private var isRtl = false
15 
addCallbacknull16     override fun addCallback(listener: ConfigurationController.ConfigurationListener) {
17         listeners += listener
18     }
19 
removeCallbacknull20     override fun removeCallback(listener: ConfigurationController.ConfigurationListener) {
21         listeners -= listener
22     }
23 
onConfigurationChangednull24     override fun onConfigurationChanged(newConfiguration: Configuration?) {
25         listeners.forEach { it.onConfigChanged(newConfiguration) }
26     }
27 
notifyThemeChangednull28     override fun notifyThemeChanged() {
29         listeners.forEach { it.onThemeChanged() }
30     }
31 
notifyDensityOrFontScaleChangednull32     fun notifyDensityOrFontScaleChanged() {
33         listeners.forEach { it.onDensityOrFontScaleChanged() }
34     }
35 
notifyConfigurationChangednull36     fun notifyConfigurationChanged() {
37         onConfigurationChanged(newConfiguration = null)
38     }
39 
notifyLayoutDirectionChangednull40     fun notifyLayoutDirectionChanged(isRtl: Boolean) {
41         this.isRtl = isRtl
42         listeners.forEach { it.onLayoutDirectionChanged(isRtl) }
43     }
44 
isLayoutRtlnull45     override fun isLayoutRtl(): Boolean = isRtl
46     override fun getNightModeName(): String = "undefined"
47 }
48 
49 @Module
50 interface FakeConfigurationControllerModule {
51     @Binds fun bindFake(fake: FakeConfigurationController): ConfigurationController
52 }
53