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

Commit ce7c1b2b authored by Merissa Mitchell's avatar Merissa Mitchell Committed by Android (Google) Code Review
Browse files

Merge "[PiP on Desktop] Reorder parent to back for multi-activity PiP." into main

parents 37355870 5cc807be
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1072,6 +1072,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
@@ -552,6 +552,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
@@ -4020,6 +4020,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
@@ -4772,6 +4772,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);