From dcd7ac401159b3aa775353b410b5f976f9e295aa Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Wed, 15 Dec 2021 13:05:06 -0800 Subject: [PATCH] Save multiple RunningTaskInfo in GestureState * With new split screen running two active tasks for a given gesture, we need to get all running task infos instead of the single most recent used one * TODO(b/210903248) for proper refactoring for GestureState Fixes: 205675364 Test: Swiping up on overview no longer crashes Change-Id: Iea1f193149657182311a97f46007b4d43e8ad549 --- .../android/quickstep/AbsSwipeUpHandler.java | 11 ++++++++--- .../com/android/quickstep/GestureState.java | 18 ++++++++++++++++++ .../quickstep/TouchInteractionService.java | 4 ++-- 3 files changed, 28 insertions(+), 5 deletions(-) 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; }