Loading packages/SystemUI/src/com/android/systemui/settings/UserTracker.kt +4 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,10 @@ interface UserTracker : UserContentResolverProvider, UserContextProvider { */ @WeaklyReferencedCallback interface Callback { /** * Notifies that the current user will be changed. */ fun onBeforeUserSwitching(newUser: Int) {} /** * Same as {@link onUserChanging(Int, Context, Runnable)} but the callback will be Loading packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt +7 −0 Original line number Diff line number Diff line Loading @@ -227,6 +227,13 @@ open class UserTrackerImpl internal constructor( protected open fun handleBeforeUserSwitching(newUserId: Int) { Assert.isNotMainThread() setUserIdInternal(newUserId) val list = synchronized(callbacks) { callbacks.toList() } list.forEach { it.callback.get()?.onBeforeUserSwitching(newUserId) } } @WorkerThread Loading packages/SystemUI/tests/utils/src/com/android/systemui/settings/FakeUserTracker.kt +6 −0 Original line number Diff line number Diff line Loading @@ -69,10 +69,16 @@ class FakeUserTracker( _userId = _userInfo.id _userHandle = UserHandle.of(_userId) onBeforeUserSwitching() onUserChanging() onUserChanged() } fun onBeforeUserSwitching(userId: Int = _userId) { val copy = callbacks.toList() copy.forEach { it.onBeforeUserSwitching(userId) } } fun onUserChanging(userId: Int = _userId) { val copy = callbacks.toList() copy.forEach { it.onUserChanging(userId, userContext) {} } Loading Loading
packages/SystemUI/src/com/android/systemui/settings/UserTracker.kt +4 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,10 @@ interface UserTracker : UserContentResolverProvider, UserContextProvider { */ @WeaklyReferencedCallback interface Callback { /** * Notifies that the current user will be changed. */ fun onBeforeUserSwitching(newUser: Int) {} /** * Same as {@link onUserChanging(Int, Context, Runnable)} but the callback will be Loading
packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt +7 −0 Original line number Diff line number Diff line Loading @@ -227,6 +227,13 @@ open class UserTrackerImpl internal constructor( protected open fun handleBeforeUserSwitching(newUserId: Int) { Assert.isNotMainThread() setUserIdInternal(newUserId) val list = synchronized(callbacks) { callbacks.toList() } list.forEach { it.callback.get()?.onBeforeUserSwitching(newUserId) } } @WorkerThread Loading
packages/SystemUI/tests/utils/src/com/android/systemui/settings/FakeUserTracker.kt +6 −0 Original line number Diff line number Diff line Loading @@ -69,10 +69,16 @@ class FakeUserTracker( _userId = _userInfo.id _userHandle = UserHandle.of(_userId) onBeforeUserSwitching() onUserChanging() onUserChanged() } fun onBeforeUserSwitching(userId: Int = _userId) { val copy = callbacks.toList() copy.forEach { it.onBeforeUserSwitching(userId) } } fun onUserChanging(userId: Int = _userId) { val copy = callbacks.toList() copy.forEach { it.onUserChanging(userId, userContext) {} } Loading