1 package com.android.systemui.statusbar.policy
2 
3 class FakeDeviceProvisionedController : DeviceProvisionedController {
4     @JvmField var deviceProvisioned = true
5     @JvmField var currentUser = 0
6 
7     private val callbacks = mutableSetOf<DeviceProvisionedController.DeviceProvisionedListener>()
8     private val usersSetup = mutableSetOf<Int>()
9 
addCallbacknull10     override fun addCallback(listener: DeviceProvisionedController.DeviceProvisionedListener) {
11         callbacks.add(listener)
12     }
13 
removeCallbacknull14     override fun removeCallback(listener: DeviceProvisionedController.DeviceProvisionedListener) {
15         callbacks.remove(listener)
16     }
17 
isDeviceProvisionednull18     override fun isDeviceProvisioned() = deviceProvisioned
19 
20     @Deprecated("Deprecated in Java")
21     override fun getCurrentUser(): Int {
22         return currentUser
23     }
24 
isUserSetupnull25     override fun isUserSetup(user: Int): Boolean {
26         return user in usersSetup
27     }
28 
isCurrentUserSetupnull29     override fun isCurrentUserSetup(): Boolean {
30         return currentUser in usersSetup
31     }
32 
setCurrentUsernull33     fun setCurrentUser(userId: Int) {
34         currentUser = userId
35         callbacks.toSet().forEach { it.onUserSwitched() }
36     }
37 
setUserSetupnull38     fun setUserSetup(userId: Int, isSetup: Boolean = true) {
39         if (isSetup) {
40             usersSetup.add(userId)
41         } else {
42             usersSetup.remove(userId)
43         }
44         callbacks.toSet().forEach { it.onUserSetupChanged() }
45     }
46 
setCurrentUserSetupnull47     fun setCurrentUserSetup(isSetup: Boolean) {
48         setUserSetup(currentUser, isSetup)
49     }
50 }
51