diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java index eb976c7f3a..dd41d25e71 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java @@ -40,6 +40,7 @@ import android.util.Pair; import android.view.MotionEvent; import android.view.animation.Interpolator; +import androidx.annotation.CallSuper; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.UiThread; @@ -128,7 +129,6 @@ public abstract class BaseSwipeUpHandler { resultCallback.accept(success); - if (!success) { + if (success) { + if (mRecentsView.indexOfChild(nextTask) + == getLastAppearedTaskIndex()) { + onRestartLastAppearedTask(); + } + } else { mActivityInterface.onLaunchTaskFailed(); nextTask.notifyTaskLaunchFailed(TAG); mRecentsAnimationController.finish(true /* toRecents */, null); @@ -235,6 +240,19 @@ public abstract class BaseSwipeUpHandler mAM.getRunningTask(false /* filterOnlyVisibleRecents */))); diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index f06e1a6afc..9b515ae788 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -15,7 +15,6 @@ */ package com.android.quickstep; -import static com.android.quickstep.GestureState.GestureEndTarget.NEW_TASK; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; import android.app.ActivityManager; @@ -121,6 +120,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL private ActivityManager.RunningTaskInfo mRunningTask; private GestureEndTarget mEndTarget; private RemoteAnimationTargetCompat mLastAppearedTaskTarget; + private int mLastStartedTaskId = -1; public GestureState(OverviewComponentObserver componentObserver, int gestureId) { mHomeIntent = componentObserver.getHomeIntent(); @@ -139,6 +139,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL mRunningTask = other.mRunningTask; mEndTarget = other.mEndTarget; mLastAppearedTaskTarget = other.mLastAppearedTaskTarget; + mLastStartedTaskId = other.mLastStartedTaskId; } public GestureState() { @@ -234,6 +235,21 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL return mLastAppearedTaskTarget != null ? mLastAppearedTaskTarget.taskId : -1; } + /** + * Updates the last task that we started via startActivityFromRecents() during this gesture. + */ + public void updateLastStartedTaskId(int lastStartedTaskId) { + mLastStartedTaskId = lastStartedTaskId; + } + + /** + * @return The id of the task that was most recently started during this gesture, or -1 if + * no task has been started yet (i.e. we haven't settled on a new task). + */ + public int getLastStartedTaskId() { + return mLastStartedTaskId; + } + /** * @return the end target for this gesture (if known). */ @@ -300,6 +316,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL pw.println(" runningTask=" + mRunningTask); pw.println(" endTarget=" + mEndTarget); pw.println(" lastAppearedTaskTarget=" + mLastAppearedTaskTarget); + pw.println(" lastStartedTaskId=" + mLastStartedTaskId); pw.println(" isRecentsAnimationRunning=" + isRecentsAnimationRunning()); } }