diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 0e5282af91..7161494c5a 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -557,9 +557,14 @@ public abstract class AbsSwipeUpHandler, runningTasks = new ActivityManager.RunningTaskInfo[splitTaskIds.length]; for (int i = 0; i < splitTaskIds.length; i++) { int taskId = splitTaskIds[i]; - ActivityManager.RunningTaskInfo rti = new ActivityManager.RunningTaskInfo(); - rti.taskId = taskId; - runningTasks[i] = rti; + // Order matters here, we want first indexed RunningTaskInfo to be leftTop task + for (ActivityManager.RunningTaskInfo rti : mGestureState.getRunningTasks()) { + if (taskId == rti.taskId) { + runningTasks[i] = rti; + break; + } + + } } } else { runningTasks = new ActivityManager.RunningTaskInfo[]{mGestureState.getRunningTask()}; diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index 9bc98d672a..01f6e23f7e 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -135,6 +135,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL private final int mGestureId; private ActivityManager.RunningTaskInfo mRunningTask; + private ActivityManager.RunningTaskInfo[] mRunningTasks; private GestureEndTarget mEndTarget; private RemoteAnimationTargetCompat mLastAppearedTaskTarget; private Set mPreviouslyAppearedTaskIds = new HashSet<>(); @@ -234,6 +235,14 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL return mRunningTask; } + /** + * This will array will contain the task returned by {@link #getRunningTask()} + * @return the running tasks for this gesture. + */ + public ActivityManager.RunningTaskInfo[] getRunningTasks() { + return mRunningTasks; + } + /** * @return the running task id for this gesture. */ @@ -248,6 +257,15 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL mRunningTask = runningTask; } + /** + * TODO(b/210903248) refactor to consolidate w/ method above + * Updates the running task for the gesture to be the given {@param runningTask}. + */ + public void updateRunningTasks(ActivityManager.RunningTaskInfo[] runningTasks) { + mRunningTasks = runningTasks; + updateRunningTask(runningTasks[0]); + } + /** * Updates the last task that appeared during this gesture. */ diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index f6f2cf953b..38d6448405 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -665,8 +665,8 @@ public class TouchInteractionService extends Service gestureState.updatePreviouslyAppearedTaskIds( previousGestureState.getPreviouslyAppearedTaskIds()); } else { - gestureState.updateRunningTask(TraceHelper.allowIpcs("getRunningTask.0", - () -> mAM.getRunningTask(false /* filterOnlyVisibleRecents */))); + gestureState.updateRunningTasks(TraceHelper.allowIpcs("getRunningTask.0", + () -> mAM.getRunningTasks(false /* filterOnlyVisibleRecents */))); } return gestureState; }