Loading packages/SystemUI/src/com/android/systemui/qs/FooterActionsController.kt +2 −1 Original line number Diff line number Diff line Loading @@ -165,6 +165,7 @@ internal class FooterActionsController @Inject constructor( powerMenuLite.visibility = View.GONE } settingsButton.setOnClickListener(onClickListener) multiUserSetting.isListening = true if (featureFlags.isEnabled(Flags.NEW_FOOTER)) { val securityFooter = securityFooterController.view as DualHeightHorizontalLinearLayout securityFootersContainer?.addView(securityFooter) Loading Loading @@ -215,6 +216,7 @@ internal class FooterActionsController @Inject constructor( override fun onViewDetached() { setListening(false) multiUserSetting.isListening = false } fun setListening(listening: Boolean) { Loading @@ -222,7 +224,6 @@ internal class FooterActionsController @Inject constructor( return } this.listening = listening multiUserSetting.isListening = listening if (this.listening) { userInfoController.addCallback(onUserInfoChangedListener) updateView() Loading packages/SystemUI/tests/src/com/android/systemui/qs/FooterActionsControllerTest.kt +24 −3 Original line number Diff line number Diff line Loading @@ -100,8 +100,10 @@ class FooterActionsControllerTest : LeakCheckedTest() { @After fun tearDown() { if (view.isAttachedToWindow) { ViewUtils.detachView(view) } } @Test fun testLogPowerMenuClick() { Loading Loading @@ -139,8 +141,7 @@ class FooterActionsControllerTest : LeakCheckedTest() { @Test fun testMultiUserSwitchUpdatedWhenSettingChanged() { // When expanded, listening is true controller.setListening(true) // Always listening to setting while View is attached testableLooper.processAllMessages() val multiUserSwitch = view.requireViewById<View>(R.id.multi_user_switch) Loading @@ -156,4 +157,24 @@ class FooterActionsControllerTest : LeakCheckedTest() { assertThat(multiUserSwitch.visibility).isEqualTo(View.VISIBLE) } @Test fun testMultiUserSettingNotListenedAfterDetach() { testableLooper.processAllMessages() val multiUserSwitch = view.requireViewById<View>(R.id.multi_user_switch) assertThat(multiUserSwitch.visibility).isNotEqualTo(View.VISIBLE) ViewUtils.detachView(view) // The setting is only used as an indicator for whether the view should refresh. The actual // value of the setting is ignored; isMultiUserEnabled is the source of truth whenever(multiUserSwitchController.isMultiUserEnabled).thenReturn(true) // Changing the value of USER_SWITCHER_ENABLED should cause the view to update fakeSettings.putIntForUser(Settings.Global.USER_SWITCHER_ENABLED, 1, userTracker.userId) testableLooper.processAllMessages() assertThat(multiUserSwitch.visibility).isNotEqualTo(View.VISIBLE) } } No newline at end of file Loading
packages/SystemUI/src/com/android/systemui/qs/FooterActionsController.kt +2 −1 Original line number Diff line number Diff line Loading @@ -165,6 +165,7 @@ internal class FooterActionsController @Inject constructor( powerMenuLite.visibility = View.GONE } settingsButton.setOnClickListener(onClickListener) multiUserSetting.isListening = true if (featureFlags.isEnabled(Flags.NEW_FOOTER)) { val securityFooter = securityFooterController.view as DualHeightHorizontalLinearLayout securityFootersContainer?.addView(securityFooter) Loading Loading @@ -215,6 +216,7 @@ internal class FooterActionsController @Inject constructor( override fun onViewDetached() { setListening(false) multiUserSetting.isListening = false } fun setListening(listening: Boolean) { Loading @@ -222,7 +224,6 @@ internal class FooterActionsController @Inject constructor( return } this.listening = listening multiUserSetting.isListening = listening if (this.listening) { userInfoController.addCallback(onUserInfoChangedListener) updateView() Loading
packages/SystemUI/tests/src/com/android/systemui/qs/FooterActionsControllerTest.kt +24 −3 Original line number Diff line number Diff line Loading @@ -100,8 +100,10 @@ class FooterActionsControllerTest : LeakCheckedTest() { @After fun tearDown() { if (view.isAttachedToWindow) { ViewUtils.detachView(view) } } @Test fun testLogPowerMenuClick() { Loading Loading @@ -139,8 +141,7 @@ class FooterActionsControllerTest : LeakCheckedTest() { @Test fun testMultiUserSwitchUpdatedWhenSettingChanged() { // When expanded, listening is true controller.setListening(true) // Always listening to setting while View is attached testableLooper.processAllMessages() val multiUserSwitch = view.requireViewById<View>(R.id.multi_user_switch) Loading @@ -156,4 +157,24 @@ class FooterActionsControllerTest : LeakCheckedTest() { assertThat(multiUserSwitch.visibility).isEqualTo(View.VISIBLE) } @Test fun testMultiUserSettingNotListenedAfterDetach() { testableLooper.processAllMessages() val multiUserSwitch = view.requireViewById<View>(R.id.multi_user_switch) assertThat(multiUserSwitch.visibility).isNotEqualTo(View.VISIBLE) ViewUtils.detachView(view) // The setting is only used as an indicator for whether the view should refresh. The actual // value of the setting is ignored; isMultiUserEnabled is the source of truth whenever(multiUserSwitchController.isMultiUserEnabled).thenReturn(true) // Changing the value of USER_SWITCHER_ENABLED should cause the view to update fakeSettings.putIntForUser(Settings.Global.USER_SWITCHER_ENABLED, 1, userTracker.userId) testableLooper.processAllMessages() assertThat(multiUserSwitch.visibility).isNotEqualTo(View.VISIBLE) } } No newline at end of file