Merge "Fix switching a background task into split screen unexpectedly" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-05-18 18:11:39 +00:00
committed by Android (Google) Code Review
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

@@ -341,6 +341,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) {