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

Commit aceec04c authored by Merissa Mitchell's avatar Merissa Mitchell
Browse files

[PiP on Desktop] Don't reparent PiP task to Desk if mid-Recents

As a temporary workaround for Desktop PiP mid-Recents, we previously
made it so that PiP will always expand to fullscreen mid-Recents in
Ibcdc47054aea52092341e55e2ee435543db58d5d.

This CL expands on the workaround to also bypass reparenting the task to
the Desk when multiple_desktops_backend flag is enabled. Note that this
fix is temporary to avoid getting into a bad state -- a more
comprehensive fix for PiP in Recents will be in a future fix.

Bug: 419875246
Test: atest DesktopPipTransitionControllerTest
Test: Manual - enter PiP on Desktop, swipe up to Recents and expand PiP.
Verify PiP expands to fullscreen
Flag: com.android.window.flags.enable_desktop_windowing_pip

Change-Id: Iba7161139ac44c3225344a3c3a2a22fd0a09f892
parent 392c5dfc
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -119,12 +119,16 @@ class PipDesktopState(
    fun isDisplayDesktopFirst(displayId: Int) =
        rootTaskDisplayAreaOrganizer.isDisplayDesktopFirst(displayId)

    /** Returns whether Recents is in the middle of animating. */
    fun isRecentsAnimating(): Boolean =
        RecentsTransitionStateListener.isAnimating(recentsTransitionState)

    /** Returns the windowing mode to restore to when resizing out of PIP direction. */
    fun getOutPipWindowingMode(): Int {
        val isInDesktop = isPipInDesktopMode()
        // Temporary workaround for b/409201669: Always expand to fullscreen if we're exiting PiP
        // in the middle of Recents animation from Desktop session.
        if (RecentsTransitionStateListener.isAnimating(recentsTransitionState) && isInDesktop) {
        if (isRecentsAnimating() && isInDesktop) {
            return WINDOWING_MODE_FULLSCREEN
        }

+3 −0
Original line number Diff line number Diff line
@@ -91,8 +91,11 @@ class DesktopPipTransitionController(
     * @param taskId of the task that is exiting PiP
     */
    fun maybeReparentTaskToDesk(wct: WindowContainerTransaction, taskId: Int) {
        // Temporary workaround for b/409201669: We always expand to fullscreen if we're exiting PiP
        // in the middle of Recents animation from Desktop session, so don't reparent to the Desk.
        if (
            !pipDesktopState.isDesktopWindowingPipEnabled() ||
                pipDesktopState.isRecentsAnimating() ||
                !DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue
        ) {
            return
+12 −0
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ class DesktopPipTransitionControllerTest(flags: FlagsParameterization) : ShellTe
        whenever(mockPipDesktopState.isDesktopWindowingPipEnabled()).thenReturn(true)
        whenever(mockPipDesktopState.isDisplayDesktopFirst(any())).thenReturn(false)
        whenever(mockPipDesktopState.isPipInDesktopMode()).thenReturn(true)
        whenever(mockPipDesktopState.isRecentsAnimating()).thenReturn(false)
        whenever(mockDesktopUserRepositories.getProfile(any())).thenReturn(mockDesktopRepository)
        whenever(mockDesktopRepository.getActiveDeskId(any())).thenReturn(DESK_ID)
        whenever(mockShellTaskOrganizer.getRunningTaskInfo(taskInfo.taskId)).thenReturn(taskInfo)
@@ -165,6 +166,17 @@ class DesktopPipTransitionControllerTest(flags: FlagsParameterization) : ShellTe
        assertThat(wct.changes.isEmpty()).isTrue()
    }

    @EnableFlags(FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND)
    @Test
    fun maybeReparentTaskToDesk_recentsAnimating_noAddMoveToDeskTaskChanges() {
        whenever(mockPipDesktopState.isRecentsAnimating()).thenReturn(true)

        controller.maybeReparentTaskToDesk(wct, taskInfo.taskId)

        verify(mockDesktopTasksController, never())
            .addMoveToDeskTaskChanges(wct = wct, task = taskInfo, deskId = DESK_ID)
    }

    @EnableFlags(FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND)
    @Test
    fun maybeReparentTaskToDesk_multiActivity_addMoveTaskToFrontChanges() {