Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4335a0f authored by Riley Jones's avatar Riley Jones Committed by Android (Google) Code Review
Browse files

Merge "Fix to further ensure floating menu is refreshed on user change" into main

parents 683fa70e 8243697d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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);
                    });
        }
    }
}
+19 −0
Original line number Diff line number Diff line
@@ -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 =