Fix switching a background task into split screen unexpectedly

If a task in split starts a new task or an adjacent task, it will
put the current splitting task behine it in the split. But when
users switch to the backgrond task, we would like to launch it in
fullscreen since it's shoiwng as a fullscreen tile in overview.

To fix this, the patch evicts any non-visible tasks in split when
detecting it's going to recent. So background tasks won't be launched
into split screen from overview anymore.

Fix: 232497373
Test: manual
Test: pass existing tests
Change-Id: I577aeeabda76fab88cd734af32ea8a69083ad3d3
This commit is contained in:
Tony Huang
2022-05-17 17:49:28 +08:00
parent 9cb05eaa75
commit 514a576b9e
3 changed files with 21 additions and 0 deletions

View File

@@ -414,6 +414,13 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
}
RemoteAnimationTarget[] onGoingToRecentsLegacy(RemoteAnimationTarget[] apps) {
if (isSplitScreenVisible()) {
// Evict child tasks except the top visible one under split root to ensure it could be
// launched as full screen when switching to it on recents.
final WindowContainerTransaction wct = new WindowContainerTransaction();
mStageCoordinator.prepareEvictInvisibleChildTasks(wct);
mSyncQueue.queue(wct);
}
return reparentSplitTasksForAnimation(apps, true /*splitExpectedToBeVisible*/);
}

View File

@@ -533,6 +533,11 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
}
}
void prepareEvictInvisibleChildTasks(WindowContainerTransaction wct) {
mMainStage.evictInvisibleChildren(wct);
mSideStage.evictInvisibleChildren(wct);
}
Bundle resolveStartStage(@StageType int stage,
@SplitPosition int position, @androidx.annotation.Nullable Bundle options,
@androidx.annotation.Nullable WindowContainerTransaction wct) {

View File

@@ -343,6 +343,15 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
}
}
void evictInvisibleChildren(WindowContainerTransaction wct) {
for (int i = mChildrenTaskInfo.size() - 1; i >= 0; i--) {
final ActivityManager.RunningTaskInfo taskInfo = mChildrenTaskInfo.valueAt(i);
if (!taskInfo.isVisible) {
wct.reparent(taskInfo.token, null /* parent */, false /* onTop */);
}
}
}
void onSplitScreenListenerRegistered(SplitScreen.SplitScreenListener listener,
@StageType int stage) {
for (int i = mChildrenTaskInfo.size() - 1; i >= 0; --i) {