Restart running task if another task was started but not appeared

If we just finish the controller to resume the running task like
we normally would, the delayed task will appear on top when it's
ready. Instead, we need to start the original task in this case.

- Move mLastStartedTaskId to GestureState, shared between swipe
  handlers when continuing the gesture.
- Update logic to change LAST_TASK to NEW_TASK if a task was
  started (but not appeared) during the same gesture; likewise,
  only change NEW_TASK to LAST_TASK if no task was started.
- Finish the controller when successfully starting the task
  that already appeared, since we won't get onTaskAppeared().

Bug: 156132424
Change-Id: I1e9af297840745ab3d5e90214425f10a2616d90a
This commit is contained in:
Tony Wickham
2020-05-08 18:08:29 -05:00
parent ed31f24dbf
commit a57000c33d
4 changed files with 63 additions and 10 deletions

View File

@@ -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());
}
}