Remove split pair according to last visible task
Sometimes a split pair may exit in the background. At this time, the stage has no visible tasks and cause missing to reomve the split pair. This is to get the last visible task id to remove the split pair. Bug: 267245649 Test: atest WMShellUnitTests Change-Id: I995518f4f3171f545ef78f9c6c40b34310a041ac
This commit is contained in:
@@ -1148,8 +1148,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
|
||||
// Notify recents if we are exiting in a way that breaks the pair, and disable further
|
||||
// updates to splits in the recents until we enter split again
|
||||
if (shouldBreakPairedTaskInRecents(exitReason) && mShouldUpdateRecents) {
|
||||
recentTasks.removeSplitPair(mMainStage.getTopVisibleChildTaskId());
|
||||
recentTasks.removeSplitPair(mSideStage.getTopVisibleChildTaskId());
|
||||
recentTasks.removeSplitPair(mMainStage.getLastVisibleTaskId());
|
||||
recentTasks.removeSplitPair(mSideStage.getLastVisibleTaskId());
|
||||
}
|
||||
});
|
||||
mShouldUpdateRecents = false;
|
||||
|
||||
@@ -92,6 +92,7 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
|
||||
protected SurfaceControl mDimLayer;
|
||||
protected SparseArray<ActivityManager.RunningTaskInfo> mChildrenTaskInfo = new SparseArray<>();
|
||||
private final SparseArray<SurfaceControl> mChildrenLeashes = new SparseArray<>();
|
||||
private int mLastVisibleTaskId = INVALID_TASK_ID;
|
||||
// TODO(b/204308910): Extracts SplitDecorManager related code to common package.
|
||||
private SplitDecorManager mSplitDecorManager;
|
||||
|
||||
@@ -122,6 +123,13 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
|
||||
return contains(t -> t.token.asBinder() == binder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last visible task's id.
|
||||
*/
|
||||
int getLastVisibleTaskId() {
|
||||
return mLastVisibleTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the top visible child task's id.
|
||||
*/
|
||||
@@ -221,6 +229,9 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
|
||||
return;
|
||||
}
|
||||
mChildrenTaskInfo.put(taskInfo.taskId, taskInfo);
|
||||
if (taskInfo.isVisible && taskInfo.taskId != mLastVisibleTaskId) {
|
||||
mLastVisibleTaskId = taskInfo.taskId;
|
||||
}
|
||||
mCallbacks.onChildTaskStatusChanged(taskInfo.taskId, true /* present */,
|
||||
taskInfo.isVisible);
|
||||
if (!ENABLE_SHELL_TRANSITIONS) {
|
||||
@@ -253,6 +264,9 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
|
||||
} else if (mChildrenTaskInfo.contains(taskId)) {
|
||||
mChildrenTaskInfo.remove(taskId);
|
||||
mChildrenLeashes.remove(taskId);
|
||||
if (taskId == mLastVisibleTaskId) {
|
||||
mLastVisibleTaskId = INVALID_TASK_ID;
|
||||
}
|
||||
mCallbacks.onChildTaskStatusChanged(taskId, false /* present */, taskInfo.isVisible);
|
||||
if (ENABLE_SHELL_TRANSITIONS) {
|
||||
// Status is managed/synchronized by the transition lifecycle.
|
||||
|
||||
Reference in New Issue
Block a user