Restrict nav mode UI checks within primary display

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
This commit is contained in:
Toshiki Kikuchi committed 2025-04-20 19:09:38 -07:00
1 parent 4c4db8ceb5
commit 3ccfdbf6c4
6 files changed
+37 -4

No files matched your search

@@ -79,5 +79,7 @@ interface TaskbarManager : SystemDecorationChangeObserver.DisplayDecorationListe
fun createAllAppsPendingIntent(): PendingIntent
fun getPrimaryDisplayId(): Int
fun debugPrimaryTaskbar(debugReason: String, verbose: Boolean)
}
@@ -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.
@@ -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)
@@ -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);
@@ -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) {
@@ -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";
}
}