Merge "Save multiple RunningTaskInfo in GestureState" into sc-v2-dev

This commit is contained in:
Vinit Nayak 2021-12-16 00:03:20 +00:00 committed by Android (Google) Code Review
commit 20102c3dd7
3 changed files with 28 additions and 5 deletions

View File

@ -569,9 +569,14 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
runningTasks = new ActivityManager.RunningTaskInfo[splitTaskIds.length]; runningTasks = new ActivityManager.RunningTaskInfo[splitTaskIds.length];
for (int i = 0; i < splitTaskIds.length; i++) { for (int i = 0; i < splitTaskIds.length; i++) {
int taskId = splitTaskIds[i]; int taskId = splitTaskIds[i];
ActivityManager.RunningTaskInfo rti = new ActivityManager.RunningTaskInfo(); // Order matters here, we want first indexed RunningTaskInfo to be leftTop task
rti.taskId = taskId; for (ActivityManager.RunningTaskInfo rti : mGestureState.getRunningTasks()) {
runningTasks[i] = rti; if (taskId == rti.taskId) {
runningTasks[i] = rti;
break;
}
}
} }
} else { } else {
runningTasks = new ActivityManager.RunningTaskInfo[]{mGestureState.getRunningTask()}; runningTasks = new ActivityManager.RunningTaskInfo[]{mGestureState.getRunningTask()};

View File

@ -135,6 +135,7 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL
private final int mGestureId; private final int mGestureId;
private ActivityManager.RunningTaskInfo mRunningTask; private ActivityManager.RunningTaskInfo mRunningTask;
private ActivityManager.RunningTaskInfo[] mRunningTasks;
private GestureEndTarget mEndTarget; private GestureEndTarget mEndTarget;
private RemoteAnimationTargetCompat mLastAppearedTaskTarget; private RemoteAnimationTargetCompat mLastAppearedTaskTarget;
private Set<Integer> mPreviouslyAppearedTaskIds = new HashSet<>(); private Set<Integer> mPreviouslyAppearedTaskIds = new HashSet<>();
@ -234,6 +235,14 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL
return mRunningTask; 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. * @return the running task id for this gesture.
*/ */
@ -248,6 +257,15 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL
mRunningTask = runningTask; 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. * Updates the last task that appeared during this gesture.
*/ */

View File

@ -665,8 +665,8 @@ public class TouchInteractionService extends Service
gestureState.updatePreviouslyAppearedTaskIds( gestureState.updatePreviouslyAppearedTaskIds(
previousGestureState.getPreviouslyAppearedTaskIds()); previousGestureState.getPreviouslyAppearedTaskIds());
} else { } else {
gestureState.updateRunningTask(TraceHelper.allowIpcs("getRunningTask.0", gestureState.updateRunningTasks(TraceHelper.allowIpcs("getRunningTask.0",
() -> mAM.getRunningTask(false /* filterOnlyVisibleRecents */))); () -> mAM.getRunningTasks(false /* filterOnlyVisibleRecents */)));
} }
return gestureState; return gestureState;
} }