Merge "Allowing having only SysUI views before pressHome()" into sc-v2-dev
diff --git a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
index 416c193..8d489e3 100644
--- a/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
+++ b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
@@ -216,7 +216,7 @@
 
     private static void assertTrue(LauncherInstrumentation launcher, String message,
             boolean condition, Description description) {
-        launcher.checkForAnomaly(true);
+        launcher.checkForAnomaly(true, true);
         if (!condition) {
             final AssertionError assertionError = new AssertionError(message);
             if (description != null) {
diff --git a/tests/src/com/android/launcher3/util/Wait.java b/tests/src/com/android/launcher3/util/Wait.java
index 8b5e197..50bc32e 100644
--- a/tests/src/com/android/launcher3/util/Wait.java
+++ b/tests/src/com/android/launcher3/util/Wait.java
@@ -52,7 +52,7 @@
             throw new RuntimeException(t);
         }
         Log.d("Wait", "atMost: timed out: " + SystemClock.uptimeMillis());
-        launcher.checkForAnomaly(false);
+        launcher.checkForAnomaly(false, false);
         Assert.fail(message.get());
     }
 
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index ea8a295..f7c6044 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -392,7 +392,8 @@
         }
     }
 
-    private String getSystemAnomalyMessage(boolean ignoreNavmodeChangeStates) {
+    private String getSystemAnomalyMessage(
+            boolean ignoreNavmodeChangeStates, boolean ignoreOnlySystemUiViews) {
         try {
             {
                 final StringBuilder sb = new StringBuilder();
@@ -415,7 +416,7 @@
 
             if (hasSystemUiObject("keyguard_status_view")) return "Phone is locked";
 
-            if (!ignoreNavmodeChangeStates) {
+            if (!ignoreOnlySystemUiViews) {
                 final String visibleApps = mDevice.findObjects(getAnyObjectSelector())
                         .stream()
                         .map(LauncherInstrumentation::getApplicationPackageSafe)
@@ -423,7 +424,8 @@
                         .filter(pkg -> pkg != null)
                         .collect(Collectors.joining(","));
                 if (SYSTEMUI_PACKAGE.equals(visibleApps)) return "Only System UI views are visible";
-
+            }
+            if (!ignoreNavmodeChangeStates) {
                 if (!mDevice.wait(Until.hasObject(getAnyObjectSelector()), WAIT_TIME_MS)) {
                     return "Screen is empty";
                 }
@@ -439,11 +441,13 @@
     }
 
     private void checkForAnomaly() {
-        checkForAnomaly(false);
+        checkForAnomaly(false, false);
     }
 
-    public void checkForAnomaly(boolean ignoreNavmodeChangeStates) {
-        final String systemAnomalyMessage = getSystemAnomalyMessage(ignoreNavmodeChangeStates);
+    public void checkForAnomaly(
+            boolean ignoreNavmodeChangeStates, boolean ignoreOnlySystemUiViews) {
+        final String systemAnomalyMessage =
+                getSystemAnomalyMessage(ignoreNavmodeChangeStates, ignoreOnlySystemUiViews);
         if (systemAnomalyMessage != null) {
             Assert.fail(formatSystemHealthMessage(formatErrorWithEvents(
                     "http://go/tapl : Tests are broken by a non-Launcher system error: "
@@ -765,7 +769,7 @@
             // pause in accessibility events prior to pressing Home.
             final String action;
             if (getNavigationModel() == NavigationModel.ZERO_BUTTON) {
-                checkForAnomaly();
+                checkForAnomaly(false, true);
                 setForcePauseTimeout(FORCE_PAUSE_TIMEOUT_MS);
 
                 final Point displaySize = getRealDisplaySize();