summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Aaron Liu <aaronjli@google.com> 2022-05-09 15:51:56 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-05-09 15:51:56 +0000
commitebf92a1acba09fd1b17748293aacc287f1699fec (patch)
tree3e5df14cdc8c89526a1de477082b0f33f1067817
parent67382ffe5c310e6099034dce801e73687256ecea (diff)
parentbd0282a0d797c5e747dffb18692702832350eab1 (diff)
Merge "[User Switcher] Remove callback in onDestroy" into tm-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/user/UserSwitcherActivity.kt12
1 files changed, 7 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/user/UserSwitcherActivity.kt b/packages/SystemUI/src/com/android/systemui/user/UserSwitcherActivity.kt
index 3329eabc80ad..ad734914170b 100644
--- a/packages/SystemUI/src/com/android/systemui/user/UserSwitcherActivity.kt
+++ b/packages/SystemUI/src/com/android/systemui/user/UserSwitcherActivity.kt
@@ -71,6 +71,11 @@ class UserSwitcherActivity @Inject constructor(
private var popupMenu: UserSwitcherPopupMenu? = null
private lateinit var addButton: View
private var addUserRecords = mutableListOf<UserRecord>()
+ private val userSwitchedCallback: UserTracker.Callback = object : UserTracker.Callback {
+ override fun onUserChanged(newUser: Int, userContext: Context) {
+ finish()
+ }
+ }
// When the add users options become available, insert another option to manage users
private val manageUserRecord = UserRecord(
null /* info */,
@@ -215,11 +220,7 @@ class UserSwitcherActivity @Inject constructor(
initBroadcastReceiver()
parent.post { buildUserViews() }
- userTracker.addCallback(object : UserTracker.Callback {
- override fun onUserChanged(newUser: Int, userContext: Context) {
- finish()
- }
- }, mainExecutor)
+ userTracker.addCallback(userSwitchedCallback, mainExecutor)
}
private fun showPopupMenu() {
@@ -340,6 +341,7 @@ class UserSwitcherActivity @Inject constructor(
super.onDestroy()
broadcastDispatcher.unregisterReceiver(broadcastReceiver)
+ userTracker.removeCallback(userSwitchedCallback)
}
private fun initBroadcastReceiver() {