Merge "Fix NPE when trying to construct WorkspaceItemInfo with null intent data." into ub-launcher3-qt-qpr1-dev
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java
index 742d6a2..07d0796 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java
@@ -161,9 +161,6 @@
     }
 
     public static TaskMenuView showForTask(TaskView taskView) {
-        if (TestProtocol.sDebugTracing) {
-            Log.d(TestProtocol.WELLBEING_NO_TASK_MENU, "showForTask");
-        }
         BaseDraggingActivity activity = BaseDraggingActivity.fromContext(taskView.getContext());
         final TaskMenuView taskMenuView = (TaskMenuView) activity.getLayoutInflater().inflate(
                         R.layout.task_menu, activity.getDragLayer(), false);
@@ -171,15 +168,9 @@
     }
 
     private boolean populateAndShowForTask(TaskView taskView) {
-        if (TestProtocol.sDebugTracing) {
-            Log.d(TestProtocol.WELLBEING_NO_TASK_MENU, "populateAndShowForTask1");
-        }
         if (isAttachedToWindow()) {
             return false;
         }
-        if (TestProtocol.sDebugTracing) {
-            Log.d(TestProtocol.WELLBEING_NO_TASK_MENU, "populateAndShowForTask2");
-        }
         mActivity.getDragLayer().addView(this);
         mTaskView = taskView;
         addMenuOptions(mTaskView);
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
index 3eed281..51802df 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
@@ -391,9 +391,6 @@
             mIconView.setDrawable(icon);
             mIconView.setOnClickListener(v -> showTaskMenu(Touch.TAP));
             mIconView.setOnLongClickListener(v -> {
-                if (TestProtocol.sDebugTracing) {
-                    Log.d(TestProtocol.WELLBEING_NO_TASK_MENU, "setOnLongClickListener");
-                }
                 requestDisallowInterceptTouchEvent(true);
                 return showTaskMenu(Touch.LONGPRESS);
             });
diff --git a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
index e5f949b..b8c00e4 100644
--- a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
+++ b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
@@ -42,6 +42,7 @@
 import androidx.test.uiautomator.Until;
 
 import com.android.launcher3.tapl.LauncherInstrumentation;
+import com.android.launcher3.tapl.TestHelpers;
 import com.android.launcher3.testcomponent.TestCommandReceiver;
 import com.android.launcher3.util.rule.FailureWatcher;
 import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
@@ -103,6 +104,11 @@
                 }
             }
         };
+        if (TestHelpers.isInLauncherProcess()) {
+            mLauncher.setSystemHealthSupplier(startTime -> TestCommandReceiver.callCommand(
+                    TestCommandReceiver.GET_SYSTEM_HEALTH_MESSAGE, startTime.toString()).
+                    getString("result"));
+        }
     }
 
     @NavigationModeSwitch(mode = THREE_BUTTON)
diff --git a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
index c5b560c..2111e2c 100644
--- a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
+++ b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
@@ -25,7 +25,6 @@
 import androidx.test.runner.AndroidJUnit4;
 
 import com.android.launcher3.Launcher;
-import com.android.launcher3.tapl.LauncherInstrumentation;
 import com.android.launcher3.util.RaceConditionReproducer;
 import com.android.quickstep.NavigationModeSwitchRule.Mode;
 import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
@@ -80,8 +79,6 @@
     @Test
     @NavigationModeSwitch
     public void testStressPressHome() {
-        if (LauncherInstrumentation.isAvd()) return; // b/136278866
-
         for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
             // Destroy Launcher activity.
             closeLauncherActivity();
@@ -94,8 +91,6 @@
     @Test
     @NavigationModeSwitch
     public void testStressSwipeToOverview() {
-        if (LauncherInstrumentation.isAvd()) return; // b/136278866
-
         for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
             // Destroy Launcher activity.
             closeLauncherActivity();
diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java
index d286ae2..bb44d90 100644
--- a/src/com/android/launcher3/testing/TestProtocol.java
+++ b/src/com/android/launcher3/testing/TestProtocol.java
@@ -84,5 +84,4 @@
     public static final String NO_BACKGROUND_TO_OVERVIEW_TAG = "b/138251824";
     public static final String NO_DRAG_TO_WORKSPACE = "b/138729456";
     public static final String APP_NOT_DISABLED = "b/139891609";
-    public static final String WELLBEING_NO_TASK_MENU = "b/141275518";
 }
diff --git a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
index 8feadbe..d7f41bf 100644
--- a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
+++ b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java
@@ -40,8 +40,8 @@
                     + "(?<local>(BuildFromAndroidStudio|"
                     + "([0-9]+|[A-Z])-eng\\.[a-z]+\\.[0-9]+\\.[0-9]+))|"
                     + "(?<presubmit>([0-9]+|[A-Z])-P[0-9]+)|"
-                    + "(?<postsubmit>([0-9]+|[A-Z])+-[0-9]+|"
-                    + "(?<platform>([0-9]+|[A-Z])+))"
+                    + "(?<postsubmit>([0-9]+|[A-Z])-[0-9]+)|"
+                    + "(?<platform>[0-9]+|[A-Z])"
                     + ")$");
     private static final Pattern PLATFORM_BUILD =
             Pattern.compile("^("
@@ -61,70 +61,7 @@
             return new Statement() {
                 @Override
                 public void evaluate() throws Throwable {
-                    final String launcherVersion =
-                            getInstrumentation().
-                                    getContext().
-                                    getPackageManager().
-                                    getPackageInfo(
-                                            UiDevice.getInstance(getInstrumentation()).
-                                                    getLauncherPackageName(),
-                                            0).
-                                    versionName;
-
-                    final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion);
-
-                    boolean launcherLocalBuild = false;
-                    boolean launcherUnbundledPresubmit = false;
-                    boolean launcherUnbundledPostsubmit = false;
-                    boolean launcherPlatform = false;
-
-                    if (!launcherBuildMatcher.find()) {
-                        Log.e(TAG, "Match not found");
-                    } else if (launcherBuildMatcher.group("local") != null) {
-                        launcherLocalBuild = true;
-                    } else if (launcherBuildMatcher.group("presubmit") != null) {
-                        launcherUnbundledPresubmit = true;
-                    } else if (launcherBuildMatcher.group("postsubmit") != null) {
-                        launcherUnbundledPostsubmit = true;
-                    } else if (launcherBuildMatcher.group("platform") != null) {
-                        launcherPlatform = true;
-                    } else {
-                        Log.e(TAG, "ERROR1");
-                    }
-
-                    boolean platformLocalBuild = false;
-                    boolean platformPresubmit = false;
-                    boolean platformPostsubmit = false;
-
-                    final String platformVersion = Build.VERSION.INCREMENTAL;
-                    final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion);
-                    if (!platformBuildMatcher.find()) {
-                        Log.e(TAG, "Match not found");
-                    } else if (platformBuildMatcher.group("commandLine") != null) {
-                        platformLocalBuild = true;
-                    } else if (platformBuildMatcher.group("presubmit") != null) {
-                        platformPresubmit = true;
-                    } else if (platformBuildMatcher.group("postsubmit") != null) {
-                        platformPostsubmit = true;
-                    } else {
-                        Log.e(TAG, "ERROR2");
-                    }
-
-                    Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion);
-
-                    if (launcherLocalBuild && (platformLocalBuild || platformPostsubmit)) {
-                        Log.d(TAG, "LOCAL RUN");
-                    } else if (launcherUnbundledPresubmit && platformPostsubmit) {
-                        Log.d(TAG, "UNBUNDLED PRESUBMIT");
-                    } else if (launcherUnbundledPostsubmit && platformPostsubmit) {
-                        Log.d(TAG, "UNBUNDLED POSTSUBMIT");
-                    } else if (launcherPlatform && platformPresubmit) {
-                        Log.d(TAG, "PLATFORM PRESUBMIT");
-                    } else if (launcherPlatform && platformPostsubmit) {
-                        Log.d(TAG, "PLATFORM POSTSUBMIT");
-                    } else {
-                        Log.e(TAG, "ERROR3");
-                    }
+                    getRunFlavor();
 
                     base.evaluate();
                 }
@@ -133,4 +70,50 @@
             return base;
         }
     }
+
+    private static void getRunFlavor() throws Exception {
+        final String launcherVersion = getInstrumentation().
+                getContext().
+                getPackageManager().
+                getPackageInfo(
+                        UiDevice.getInstance(getInstrumentation()).
+                                getLauncherPackageName(),
+                        0).
+                versionName;
+
+        final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion);
+
+        if (!launcherBuildMatcher.find()) {
+            Log.e(TAG, "Match not found");
+        }
+
+        final String platformVersion = Build.VERSION.INCREMENTAL;
+        final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion);
+
+        if (!platformBuildMatcher.find()) {
+            Log.e(TAG, "Match not found");
+        }
+
+        Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion);
+
+        if (launcherBuildMatcher.group("local") != null && (
+                platformBuildMatcher.group("commandLine") != null ||
+                        platformBuildMatcher.group("postsubmit") != null)) {
+            Log.d(TAG, "LOCAL RUN");
+        } else if (launcherBuildMatcher.group("presubmit") != null
+                && platformBuildMatcher.group("postsubmit") != null) {
+            Log.d(TAG, "UNBUNDLED PRESUBMIT");
+        } else if (launcherBuildMatcher.group("postsubmit") != null
+                && platformBuildMatcher.group("postsubmit") != null) {
+            Log.d(TAG, "UNBUNDLED POSTSUBMIT");
+        } else if (launcherBuildMatcher.group("platform") != null
+                && platformBuildMatcher.group("presubmit") != null) {
+            Log.d(TAG, "PLATFORM PRESUBMIT");
+        } else if (launcherBuildMatcher.group("platform") != null
+                && platformBuildMatcher.group("postsubmit") != null) {
+            Log.d(TAG, "PLATFORM POSTSUBMIT");
+        } else {
+            Log.e(TAG, "ERROR3");
+        }
+    }
 }
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 65208ce..306fe48 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -37,7 +37,6 @@
 import android.graphics.Point;
 import android.graphics.Rect;
 import android.net.Uri;
-import android.os.Build;
 import android.os.Bundle;
 import android.os.Parcelable;
 import android.os.SystemClock;
@@ -239,10 +238,6 @@
         return null;
     }
 
-    public static boolean isAvd() {
-        return Build.MODEL.contains("Cuttlefish");
-    }
-
     static void log(String message) {
         Log.d(TAG, message);
     }
@@ -845,10 +840,6 @@
         mDevice.waitForIdle();
     }
 
-    float getDisplayDensity() {
-        return mInstrumentation.getTargetContext().getResources().getDisplayMetrics().density;
-    }
-
     int getTouchSlop() {
         return ViewConfiguration.get(getContext()).getScaledTouchSlop();
     }
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 510ea14..da74b66 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -38,8 +38,6 @@
  * Operations on the workspace screen.
  */
 public final class Workspace extends Home {
-    private static final float FLING_SPEED =
-            LauncherInstrumentation.isAvd() ? 1500.0F : 3500.0F;
     private static final int DRAG_DURACTION = 2000;
     private static final int FLING_STEPS = 10;
     private final UiObject2 mHotseat;