From 8cb1ae879becf449cc8a63a1ada484a96955943f Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Fri, 11 Apr 2025 18:31:24 +0100 Subject: [PATCH] Use SysUi focus display ID as the source of truth For key gesture events received in SysUi & Launcher, we will use the SysUi tracked display Id as the source of truth. The KeyGestureHandler mechanism will be kept because it has less redirection compare to the existing pipeline. Bug: 406452076 Test: atest NexusLauncherTests:QuickstepKeyGestureEventsHandlerTest Test: atest NexusLauncherTests:AllAppsActionManagerTest Test: atest NexusLauncherOutOfProcTests:com.google.android.apps.nexuslauncher.TaplTestsNexus Test: Verfiy manually that meta key event triggered all apps if the display focused is the default display. Flag: com.android.window.flags.enable_key_gesture_handler_for_recents Change-Id: I032a44b903e4e49e85c2a40a1e0bdc49ef8d86b0 --- .../launcher3/taskbar/TaskbarManager.java | 28 ++----------------- .../input/QuickstepKeyGestureEventsManager.kt | 10 ++----- .../QuickstepKeyGestureEventsHandlerTest.kt | 9 ++---- 3 files changed, 7 insertions(+), 40 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java index e19fd5764b..484c60037a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java @@ -121,12 +121,6 @@ public class TaskbarManager implements DisplayDecorationListener { // TODO: b/397738606 - Remove all logs with this tag after the growth framework is integrated. public static final String GROWTH_FRAMEWORK_TAG = "Growth Framework"; - /** - * An integer extra specifying the ID of the display on which the All Apps UI should be shown - * or hidden. - */ - public static final String EXTRA_KEY_ALL_APPS_ACTION_DISPLAY_ID = - "com.android.quickstep.allapps.display_id"; /** * All the configurations which do not initiate taskbar recreation. @@ -590,15 +584,7 @@ public class TaskbarManager implements DisplayDecorationListener { * visibility on the System UI tracked focused display. */ public void toggleAllAppsSearch() { - toggleAllAppsSearchForDisplay(getFocusedDisplayId()); - } - - /** - * Shows or hides the All Apps view in the Taskbar or Launcher, based on its current - * visibility on the given display, with ID {@code displayId}. - */ - public void toggleAllAppsSearchForDisplay(int displayId) { - TaskbarActivityContext taskbar = getTaskbarForDisplay(displayId); + TaskbarActivityContext taskbar = getTaskbarForDisplay(getFocusedDisplayId()); if (taskbar == null) { // Home All Apps should be toggled from this class, because the controllers are not // initialized when Taskbar is disabled (i.e. TaskbarActivityContext is null). @@ -1740,17 +1726,7 @@ public class TaskbarManager implements DisplayDecorationListener { public void send(int code, Intent intent, String resolvedType, IBinder allowlistToken, IIntentReceiver finishedReceiver, String requiredPermission, Bundle options) { - MAIN_EXECUTOR.execute(() -> { - int displayId = -1; - if (options != null) { - displayId = options.getInt(EXTRA_KEY_ALL_APPS_ACTION_DISPLAY_ID, -1); - } - if (displayId == -1) { - toggleAllAppsSearch(); - } else { - toggleAllAppsSearchForDisplay(displayId); - } - }); + MAIN_EXECUTOR.execute(TaskbarManager.this::toggleAllAppsSearch); } }); } diff --git a/quickstep/src/com/android/quickstep/input/QuickstepKeyGestureEventsManager.kt b/quickstep/src/com/android/quickstep/input/QuickstepKeyGestureEventsManager.kt index d6355e9a91..d5120985ee 100644 --- a/quickstep/src/com/android/quickstep/input/QuickstepKeyGestureEventsManager.kt +++ b/quickstep/src/com/android/quickstep/input/QuickstepKeyGestureEventsManager.kt @@ -21,11 +21,9 @@ import android.content.Context import android.hardware.input.InputManager import android.hardware.input.InputManager.KeyGestureEventHandler import android.hardware.input.KeyGestureEvent -import android.os.Bundle import android.os.IBinder import android.util.Log import androidx.annotation.VisibleForTesting -import com.android.launcher3.taskbar.TaskbarManager import com.android.window.flags.Flags /** @@ -47,11 +45,9 @@ class QuickstepKeyGestureEventsManager(context: Context) { return } - allAppsPendingIntent?.send( - Bundle().apply { - putInt(TaskbarManager.EXTRA_KEY_ALL_APPS_ACTION_DISPLAY_ID, event.displayId) - } - ) + // Ignore the display ID from the KeyGestureEvent as we will use the focus display + // from the SysUi proxy as the source of truth. + allAppsPendingIntent?.send() } } diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/input/QuickstepKeyGestureEventsHandlerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/input/QuickstepKeyGestureEventsHandlerTest.kt index e5b517ede9..b7622a0759 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/input/QuickstepKeyGestureEventsHandlerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/input/QuickstepKeyGestureEventsHandlerTest.kt @@ -20,13 +20,11 @@ import android.app.PendingIntent import android.hardware.input.InputManager import android.hardware.input.KeyGestureEvent import android.hardware.input.KeyGestureEvent.KEY_GESTURE_TYPE_ALL_APPS -import android.os.Bundle import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import android.platform.test.flag.junit.SetFlagsRule import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest -import com.android.launcher3.taskbar.TaskbarManager.EXTRA_KEY_ALL_APPS_ACTION_DISPLAY_ID import com.android.launcher3.util.SandboxApplication import com.android.window.flags.Flags import com.google.common.truth.Truth.assertThat @@ -55,7 +53,6 @@ class QuickstepKeyGestureEventsHandlerTest { private val keyGestureEventsManager = QuickstepKeyGestureEventsManager(context) private val allAppsPendingIntent: PendingIntent = mock() private val keyGestureEventsCaptor: KArgumentCaptor> = argumentCaptor() - private val bundleCaptor: KArgumentCaptor = argumentCaptor() @Before fun setup() { @@ -105,7 +102,7 @@ class QuickstepKeyGestureEventsHandlerTest { @Test @EnableFlags(Flags.FLAG_ENABLE_KEY_GESTURE_HANDLER_FOR_RECENTS) - fun handleEvent_flagEnabled_allApps_toggleAllAppsSearchWithDisplayId() { + fun handleEvent_flagEnabled_allApps_toggleAllAppsSearch() { keyGestureEventsManager.registerAllAppsKeyGestureEvent(allAppsPendingIntent) keyGestureEventsManager.allAppsKeyGestureEventHandler.handleKeyGestureEvent( @@ -116,9 +113,7 @@ class QuickstepKeyGestureEventsHandlerTest { /* focusedToken= */ null, ) - verify(allAppsPendingIntent).send(bundleCaptor.capture()) - assertThat(bundleCaptor.firstValue.getInt(EXTRA_KEY_ALL_APPS_ACTION_DISPLAY_ID)) - .isEqualTo(TEST_DISPLAY_ID) + verify(allAppsPendingIntent).send() } @Test