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
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index bd52968..4a7e297 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2802,6 +2802,26 @@
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;