Quick patch for PredictionUiStateManager.applyState interrupting allapps
Constructor of PredictionUiStateManager posts an action in 5 sec, which
may interfere with the process of opening all apps.
Waiting until the posted action happens.
Hopefully this will fix massive flakes.
Bug: 131854153
Change-Id: I6544eae1a3b063c03e78185826c05a76add1f71b
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java
index 6dad9af..28ecce0 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java
@@ -197,7 +197,10 @@
}
}
+ public boolean mDebugHadStateUpdate;
+
private void updatePredictionStateAfterCallback() {
+ mDebugHadStateUpdate = true;
boolean validResults = false;
for (List l : mPredictionServicePredictions) {
validResults |= l != null && !l.isEmpty();
diff --git a/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java b/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
index 5e20e56..c6f7544 100644
--- a/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
+++ b/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
@@ -70,6 +70,9 @@
AppLaunchTracker.INSTANCE.initializeForTesting(new AppLaunchTracker());
PredictionUiStateManager.INSTANCE.initializeForTesting(null);
+ waitForLauncherCondition("Prediction never had state update",
+ launcher -> PredictionUiStateManager.INSTANCE.get(
+ mTargetContext).mDebugHadStateUpdate);
mCallback = PredictionUiStateManager.INSTANCE.get(mTargetContext).appPredictorCallback(
Client.HOME);
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index a59189b..35113d2 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2553,4 +2553,8 @@
void onLauncherResume();
}
+
+ public boolean debugIsPredictionInitialized() {
+ return true;
+ }
}
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index d4cfe3a..d0ea142 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -64,6 +64,8 @@
test.mDevice.pressHome();
}
test.waitForLauncherCondition("Launcher didn't start", launcher -> launcher != null);
+ test.waitForLauncherCondition("Prediction never had state update",
+ launcher -> launcher.debugIsPredictionInitialized());
test.waitForState("Launcher internal state didn't switch to Home", LauncherState.NORMAL);
test.waitForResumed("Launcher internal state is still Background");
// Check that we switched to home.