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

Commit 646a0dd3 authored by Vadim Tryshev's avatar Vadim Tryshev
Browse files

Opening options popup on KeyEvent.KEYCODE_MENU.

This fixes test LauncherJankTests#testWidgetsContainerFling which sends
this keycode as a part of opening a widget container.

Bug: 72967764
Test: atest google/perf/jank/SystemUI/UbSystemUIJankTests:android.platform.systemui.tests.jank.LauncherJankTests#testWidgetsContainerFling
Change-Id: Ia10f0306712187a526a3e9041ec67af2e3cbef77
parent 56ff06a8
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -2802,6 +2802,26 @@ public class Launcher extends BaseActivity
        return super.onKeyShortcut(keyCode, event);
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_MENU) {
            // KEYCODE_MENU is sent by some tests, for example
            // LauncherJankTests#testWidgetsContainerFling. Don't just remove its handling.
            if (!mDragController.isDragging() && !mWorkspace.isSwitchingState() &&
                    isInState(NORMAL)) {
                // Close any open floating views.
                AbstractFloatingView.closeAllOpenViews(this);

                // Setting the touch point to (-1, -1) will show the options popup in the center of
                // the screen.
                mLastDispatchTouchEvent.set(-1, -1);
                UiFactory.onWorkspaceLongPress(this, mLastDispatchTouchEvent);
            }
            return true;
        }
        return super.onKeyUp(keyCode, event);
    }

    public static Launcher getLauncher(Context context) {
        if (context instanceof Launcher) {
            return (Launcher) context;