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
This commit is contained in:
Vinit Nayak 2021-12-15 13:05:06 -08:00
parent 9b3b2b9c7e
commit dcd7ac4011
3 changed files with 28 additions and 5 deletions

View File

@ -557,9 +557,14 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
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()};

View File

@ -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<Integer> 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.
*/

View File

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