Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 514a576b authored by Tony Huang's avatar Tony Huang
Browse files

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
parent 9cb05eaa
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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*/);
    }

+5 −0
Original line number Diff line number Diff line
@@ -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) {
+9 −0
Original line number Diff line number Diff line
@@ -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) {