summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuControllerTest.java19
2 files changed, 24 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java
index 275147e6694c..41b9d3372392 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuController.java
@@ -226,7 +226,11 @@ public class AccessibilityFloatingMenuController implements
mBtnTargets =
mAccessibilityButtonTargetsObserver.getCurrentAccessibilityButtonTargets();
mHandler.post(
- () -> handleFloatingMenuVisibility(mIsKeyguardVisible, mBtnMode, mBtnTargets));
+ () -> {
+ // Force a refresh by destroying the menu if it exists.
+ destroyFloatingMenu();
+ handleFloatingMenuVisibility(mIsKeyguardVisible, mBtnMode, mBtnTargets);
+ });
}
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuControllerTest.java
index 5e37d4cd1faf..51a7b5f6f979 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/AccessibilityFloatingMenuControllerTest.java
@@ -338,6 +338,25 @@ public class AccessibilityFloatingMenuControllerTest extends SysuiTestCase {
assertThat(mController.mFloatingMenu).isInstanceOf(MenuViewLayerController.class);
}
+ @Test
+ public void onUserInitializationComplete_destroysOldWidget() {
+ enableAccessibilityFloatingMenuConfig();
+ mController = setUpController();
+
+ captureKeyguardUpdateMonitorCallback();
+ mKeyguardCallback.onUserUnlocked();
+ mKeyguardCallback.onKeyguardVisibilityChanged(false);
+
+ IAccessibilityFloatingMenu floatingMenu = mController.mFloatingMenu;
+
+ mController.mUserInitializationCompleteCallback
+ .onUserInitializationComplete(mContext.getUserId());
+ mTestableLooper.processAllMessages();
+
+ assertThat(mController.mFloatingMenu).isNotNull();
+ assertThat(mController.mFloatingMenu).isNotSameInstanceAs(floatingMenu);
+ }
+
private AccessibilityFloatingMenuController setUpController() {
final WindowManager windowManager = mContext.getSystemService(WindowManager.class);
final ViewCaptureAwareWindowManager viewCaptureAwareWindowManager =