From 3ccfdbf6c4f35a9bc1e3607df29ce34a28a10ad0 Mon Sep 17 00:00:00 2001 From: Toshiki Kikuchi Date: Tue, 15 Apr 2025 13:21:50 +0900 Subject: [PATCH] Restrict nav mode UI checks within primary display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL fixes the nav mode UI checks which currently assumes “navigation mode” takes effect on all displays although the mode is only effective on the primary display. Flag: EXEMPT - test fix Fix: 408631713 Test: atest WMShellFlickerTestsDesktopMode:com.android.wm.shell.flicker.OpenAppWithExternalDisplayConnected Change-Id: I29f33957d696e9d5afda844f69388b74a8f78b77 --- .../launcher3/taskbar/TaskbarManager.kt | 2 ++ .../launcher3/taskbar/TaskbarManagerImpl.java | 7 +++++++ .../taskbar/TaskbarManagerImplWrapper.kt | 5 +++++ .../QuickstepTestInformationHandler.java | 4 ++++ .../testing/shared/TestProtocol.java | 2 ++ .../tapl/LauncherInstrumentation.java | 21 +++++++++++++++---- 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.kt index 6506c99fa4..ecf72e3664 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.kt @@ -79,5 +79,7 @@ interface TaskbarManager : SystemDecorationChangeObserver.DisplayDecorationListe fun createAllAppsPendingIntent(): PendingIntent + fun getPrimaryDisplayId(): Int + fun debugPrimaryTaskbar(debugReason: String, verbose: Boolean) } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java index dabad1f73a..df105014f7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImpl.java @@ -1686,6 +1686,13 @@ public class TaskbarManagerImpl implements DisplayDecorationListener { return SystemUiProxy.INSTANCE.get(mBaseContext).getFocusState().getFocusedDisplayId(); } + /** + * Returns the primary display id associated with this manager. + */ + public int getPrimaryDisplayId() { + return mPrimaryDisplayId; + } + /** * Logs debug information about the TaskbarManager for primary display. * @param debugReason A string describing the reason for the debug log. diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImplWrapper.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImplWrapper.kt index ce0863f209..f695d8578e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImplWrapper.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManagerImplWrapper.kt @@ -261,6 +261,11 @@ class TaskbarManagerImplWrapper(private val impl: TaskbarManagerImpl) : TaskbarM ) } + override fun getPrimaryDisplayId(): Int { + // Thread safe + return impl.getPrimaryDisplayId() + } + override fun dumpLogs(prefix: String, pw: PrintWriter) { // Stay on caller thread because PrinterWriter is not thread safe. impl.dumpLogs(prefix, pw) diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index d80c05b99e..ab2cfbe549 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -198,6 +198,10 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { case TestProtocol.REQUEST_EJECT_FAKE_TRACKPAD: runOnTISBinder(tisBinder -> tisBinder.ejectFakeTrackpadForTesting()); return response; + case TestProtocol.REQUEST_TASKBAR_PRIMARY_DISPLAY_ID: { + return getTISBinderUIProperty(Bundle::putInt, tisBinder -> + tisBinder.getTaskbarManager().getPrimaryDisplayId()); + } } return super.call(method, arg, extras); diff --git a/shared/src/com/android/launcher3/testing/shared/TestProtocol.java b/shared/src/com/android/launcher3/testing/shared/TestProtocol.java index cdeab954fd..ce18f721c6 100644 --- a/shared/src/com/android/launcher3/testing/shared/TestProtocol.java +++ b/shared/src/com/android/launcher3/testing/shared/TestProtocol.java @@ -179,6 +179,8 @@ public final class TestProtocol { public static final String REQUEST_INJECT_FAKE_TRACKPAD = "inject-fake-trackpad"; public static final String REQUEST_EJECT_FAKE_TRACKPAD = "eject-fake-trackpad"; + public static final String REQUEST_TASKBAR_PRIMARY_DISPLAY_ID = "taskbar-primary-display-id"; + /** Logs {@link Log#d(String, String)} if {@link #sDebugTracing} is true. */ public static void testLogD(String tag, String message) { if (!sDebugTracing) { diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 6f2e8efb86..6ff957bf4c 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -461,6 +461,11 @@ public final class LauncherInstrumentation { .getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD); } + Integer getTaskbarPrimaryDisplayId() { + final Bundle testInfo = getTestInfo(TestProtocol.REQUEST_TASKBAR_PRIMARY_DISPLAY_ID); + return testInfo != null ? testInfo.getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD) : null; + } + void setActiveContainer(VisibleContainer container) { sActiveContainer = new WeakReference<>(container); } @@ -874,22 +879,30 @@ public final class LauncherInstrumentation { final int waitTime = waitForCorrectState ? WAIT_TIME_MS : 0; final NavigationModel navigationModel = getNavigationModel(); String resPackage = getNavigationButtonResPackage(); + final BySelector recentAppsSelector = By.res(resPackage, "recent_apps"); + final BySelector homeSelector = By.res(resPackage, "home"); + final Integer taskbarPrimaryDisplayId = getTaskbarPrimaryDisplayId(); + if (taskbarPrimaryDisplayId != null) { + recentAppsSelector.displayId(taskbarPrimaryDisplayId); + homeSelector.displayId(taskbarPrimaryDisplayId); + } + if (navigationModel == NavigationModel.THREE_BUTTON) { - if (!mDevice.wait(Until.hasObject(By.res(resPackage, "recent_apps")), waitTime)) { + if (!mDevice.wait(Until.hasObject(recentAppsSelector), waitTime)) { return "Recents button not present in 3-button mode"; } } else { - if (!mDevice.wait(Until.gone(By.res(resPackage, "recent_apps")), waitTime)) { + if (!mDevice.wait(Until.gone(recentAppsSelector), waitTime)) { return "Recents button is present in non-3-button mode"; } } if (navigationModel == NavigationModel.ZERO_BUTTON) { - if (!mDevice.wait(Until.gone(By.res(resPackage, "home")), waitTime)) { + if (!mDevice.wait(Until.gone(homeSelector), waitTime)) { return "Home button is present in gestural mode"; } } else { - if (!mDevice.wait(Until.hasObject(By.res(resPackage, "home")), waitTime)) { + if (!mDevice.wait(Until.hasObject(homeSelector), waitTime)) { return "Home button not present in non-gestural mode"; } }