Merge "Make @QuickstepOnOff and @PortraitLandscape available to all UI tests." into ub-launcher3-master
diff --git a/quickstep/src/com/android/quickstep/QuickScrubController.java b/quickstep/src/com/android/quickstep/QuickScrubController.java
index 9432256..3420767 100644
--- a/quickstep/src/com/android/quickstep/QuickScrubController.java
+++ b/quickstep/src/com/android/quickstep/QuickScrubController.java
@@ -67,6 +67,7 @@
     private int mQuickScrubSection;
     private boolean mStartedFromHome;
     private boolean mFinishedTransitionToQuickScrub;
+    private int mLaunchingTaskId;
     private Runnable mOnFinishedTransitionToQuickScrubRunnable;
     private ActivityControlHelper mActivityControlHelper;
     private TouchInteractionLog mTouchInteractionLog;
@@ -105,6 +106,7 @@
             if (taskView != null) {
                 mWaitingForTaskLaunch = true;
                 mTouchInteractionLog.launchTaskStart();
+                mLaunchingTaskId = taskView.getTask().key.id;
                 taskView.launchTask(true, (result) -> {
                     mTouchInteractionLog.launchTaskEnd(result);
                     if (!result) {
@@ -146,6 +148,7 @@
         mActivityControlHelper = null;
         mOnFinishedTransitionToQuickScrubRunnable = null;
         mRecentsView.setNextPageSwitchRunnable(null);
+        mLaunchingTaskId = 0;
     }
 
     /**
@@ -211,6 +214,18 @@
         }
     }
 
+    public void onTaskRemoved(int taskId) {
+        if (mLaunchingTaskId == taskId) {
+            // The task has been removed mid-launch, break out of quickscrub and return the user
+            // to where they were before (and notify the launch failed)
+            TaskView taskView = mRecentsView.getTaskView(taskId);
+            if (taskView != null) {
+                taskView.notifyTaskLaunchFailed(TAG);
+            }
+            breakOutOfQuickScrub();
+        }
+    }
+
     public void snapToNextTaskIfAvailable() {
         if (mInQuickScrub && mRecentsView.getChildCount() > 0) {
             int duration = mStartedFromHome ? QUICK_SCRUB_FROM_HOME_START_DURATION
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index f3dec9a..8ad3cee 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -183,6 +183,10 @@
             if (!mHandleTaskStackChanges) {
                 return;
             }
+
+            // Notify the quick scrub controller that a particular task has been removed
+            mQuickScrubController.onTaskRemoved(taskId);
+
             BackgroundExecutor.get().submit(() -> {
                 TaskView taskView = getTaskView(taskId);
                 if (taskView == null) {