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

Commit b670ad2c authored by Chris Li's avatar Chris Li
Browse files

Collect dismissPip change before start transition

Followup to ag/16568759.

Bug: 213300721
Test: pass existing
Change-Id: I1afbdbcaf6d108276325a1dc2b9855fb636fb97c
parent 2ffcd6dc
Loading
Loading
Loading
Loading
+21 −17
Original line number Diff line number Diff line
@@ -2052,24 +2052,29 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        try {
            final Task task = r.getTask();

            // If the activity in current PIP task needs to be moved back to the parent Task of next
            // PIP activity, we can't use that parent Task as the next PIP Task.
            // Because we need to start the Shell transition from the root Task, we delay to dismiss
            // the current PIP task until root Task is ready.
            boolean origPipWillBeMovedToTask = false;
            // Create a transition now to collect the current pinned Task dismiss. Only do the
            // create here as the Task (trigger) to enter PIP is not ready yet.
            final TransitionController transitionController = task.mTransitionController;
            Transition newTransition = null;
            if (transitionController.isCollecting()) {
                transitionController.setReady(task, false /* ready */);
            } else if (transitionController.getTransitionPlayer() != null) {
                newTransition = transitionController.createTransition(TRANSIT_PIP);
            }

            // This will change the root pinned task's windowing mode to its original mode, ensuring
            // we only have one root task that is in pinned mode.
            final Task rootPinnedTask = taskDisplayArea.getRootPinnedTask();
            if (rootPinnedTask != null) {
                final ActivityRecord topPipActivity = rootPinnedTask.getTopMostActivity();
                if (topPipActivity != null && topPipActivity.getLastParentBeforePip() == task) {
                    origPipWillBeMovedToTask = true;
                }
                transitionController.collect(rootPinnedTask);
                rootPinnedTask.dismissPip();
            }

            // Set a transition to ensure that we don't immediately try and update the visibility
            // of the activity entering PIP
            r.getDisplayContent().prepareAppTransition(TRANSIT_NONE);

            final boolean singleActivity = task.getChildCount() == 1 && !origPipWillBeMovedToTask;
            final boolean singleActivity = task.getChildCount() == 1;
            final Task rootTask;
            if (singleActivity) {
                rootTask = task;
@@ -2123,7 +2128,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                final ActivityRecord oldTopActivity = task.getTopMostActivity();
                if (oldTopActivity != null && oldTopActivity.isState(STOPPED)
                        && task.getDisplayContent().mAppTransition.containsTransitRequest(
                        TRANSIT_TO_BACK) && !origPipWillBeMovedToTask) {
                        TRANSIT_TO_BACK)) {
                    task.getDisplayContent().mClosingApps.add(oldTopActivity);
                    oldTopActivity.mRequestForceTransition = true;
                }
@@ -2137,14 +2142,13 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                // display area, so reparent.
                rootTask.reparent(taskDisplayArea, true /* onTop */);
            }
            rootTask.mTransitionController.requestTransitionIfNeeded(TRANSIT_PIP, rootTask);

            // This will change the root pinned task's windowing mode to its original mode, ensuring
            // we only have one root task that is in pinned mode.
            if (rootPinnedTask != null) {
                rootTask.mTransitionController.collect(rootPinnedTask);
                rootPinnedTask.dismissPip();
            // The new PIP Task is ready, start the transition before updating the windowing mode.
            if (newTransition != null) {
                transitionController.requestStartTransition(newTransition, rootTask,
                        null /* remoteTransition */, null /* displayChange */);
            }
            transitionController.collect(rootTask);

            // Defer the windowing mode change until after the transition to prevent the activity
            // from doing work and changing the activity visuals while animating