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

Commit 5cc807be authored by Merissa Mitchell's avatar Merissa Mitchell
Browse files

[PiP on Desktop] Reorder parent to back for multi-activity PiP.

Recall: http://recall/clips/ee10466e-2115-4deb-8d1e-2a2d658435ef

For multi-activity PiP in Desktop, the parent activity is brought to
front and shown when the child activity breaks off into PiP (if we are
remaining in Desktop session).
This CL explicitly reorders the parent to the back to prevent it being
shown during PiP. Also adds a collect call for the parent before
bringing it to front when expanding from PiP, so that it is not shown
before the animation.

Bug: 409480429
Test: atest DesktopTasksControllerTest
Test: Manual - launch Netflix in Desktop with another task open, then
enter PiP. Verify that Home activity does not reappear
Test: Manual - verify that direct-enter PiP from fullscreen for
single-activity and multi-activity are WAI
Test: Manual - verify other multi-activity PiP expand cases e.g.
pip-to-split are WAI
Flag: com.android.window.flags.enable_desktop_windowing_pip

Change-Id: I1be190619dfa909591999cb61d0cbdfbe4ea72b6
parent 8007ae53
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1046,6 +1046,12 @@ class DesktopTasksController(
                transitions.dispatchRequest(SYNTHETIC_TRANSITION, requestInfo, /* skip= */ null)
            wct.merge(requestRes.second, true)

            // In multi-activity case, we explicitly reorder the parent task to the back so that it
            // is not brought to the front and shown when the child task breaks off into PiP.
            if (taskInfo.numActivities > 1) {
                wct.reorder(taskInfo.token, /* onTop= */ false)
            }

            // If the task minimizing to PiP is the last task, modify wct to perform Desktop cleanup
            var desktopExitRunnable: RunOnTransitStart? = null
            if (isLastTask) {
+8 −0
Original line number Diff line number Diff line
@@ -549,6 +549,14 @@ public class PipTransition extends PipTransitionController implements
        if (pipActivityChange == null) {
            return false;
        }

        // In multi-activity case, set the parent's leash to invisible while we're animating to PiP
        TransitionInfo.Change parentBeforePip = pipActivityChange.getLastParent() != null
                ? getChangeByToken(info, pipActivityChange.getLastParent()) : null;
        if (parentBeforePip != null && TransitionUtil.isClosingMode(parentBeforePip.getMode())) {
            startTransaction.setAlpha(parentBeforePip.getLeash(), 0);
        }

        mFinishCallback = finishCallback;

        final SurfaceControl pipLeash = getLeash(pipChange);
+15 −0
Original line number Diff line number Diff line
@@ -3939,6 +3939,21 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase()
        arg.lastValue.assertPendingIntent(launchHomeIntent(DEFAULT_DISPLAY))
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_PIP)
    fun onPipTaskMinimize_multiActivity_reordersParentToBack() {
        val task = setUpPipTask(autoEnterEnabled = true).apply { numActivities = 2 }
        // Add a second task so that entering PiP does not trigger Desktop cleanup
        setUpFreeformTask(deskId = DEFAULT_DISPLAY)

        minimizePipTask(task)

        val arg = argumentCaptor<WindowContainerTransaction>()
        verify(freeformTaskTransitionStarter).startPipTransition(arg.capture())
        assertThat(arg.lastValue.hierarchyOps.size).isEqualTo(1)
        arg.lastValue.assertReorderAt(index = 0, task, toTop = false)
    }

    @Test
    fun onDesktopWindowMinimize_singleActiveTask_noWallpaperActivityToken_doesntRemoveWallpaper() {
        val task = setUpFreeformTask(active = true)
+6 −0
Original line number Diff line number Diff line
@@ -4775,6 +4775,12 @@ class Task extends TaskFragment {
                    mTransitionController.collect(topActivity);

                    final Task lastParentBeforePip = topActivity.getLastParentBeforePip();
                    // Collect the last parent before moving it to front to make sure we have the
                    // latest view hierarchy information
                    if (isPip2ExperimentEnabled) {
                        mTransitionController.collect(lastParentBeforePip);
                    }

                    // Reset the activity windowing mode to match the parent.
                    topActivity.getRequestedOverrideConfiguration()
                            .windowConfiguration.setWindowingMode(WINDOWING_MODE_UNDEFINED);