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

Commit 1c449914 authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Remove drag mirrors on EXITED_PIP.

This ensures that the mirrors get removed when pip is exited, for
example, while dragging PiP, open the same app to go from PiP > full
screen.

Fixes: 408982524
Flag: com.android.window.flags.enable_dragging_pip_across_displays
Test: atest PipDisplayTransferHandlerTest
Change-Id: Ie4d2a22e52db61607056f648c7ea922e21741ee5
parent 7e47111a
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -108,8 +108,6 @@ public class PipDisplayTransferHandler implements
    @Override
    public void onPipTransitionStateChanged(@PipTransitionState.TransitionState int oldState,
            @PipTransitionState.TransitionState int newState, @Nullable Bundle extra) {
        if (extra == null) return;

        switch (newState) {
            case PipTransitionState.SCHEDULED_BOUNDS_CHANGE:
                if (!extra.containsKey(ORIGIN_DISPLAY_ID_KEY) || !extra.containsKey(
@@ -182,6 +180,11 @@ public class PipDisplayTransferHandler implements
                });
                animator.start();
                break;
            case PipTransitionState.EXITED_PIP:
                ProtoLog.v(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE,
                        "%s Exited PiP. Removing drag mirrors", TAG);
                removeMirrors();
                break;
        }
    }

@@ -237,7 +240,6 @@ public class PipDisplayTransferHandler implements
    /**
     * Remove all drag indicator mirrors from each connected display.
     */
    // TODO(b/408982524): Remove mirrors on opening app while dragging
    public void removeMirrors() {
        final Transaction transaction = mSurfaceControlTransactionFactory.getTransaction();
        for (SurfaceControl mirror : mOnDragMirrorPerDisplayId.values()) {
+20 −0
Original line number Diff line number Diff line
@@ -242,6 +242,26 @@ class PipDisplayTransferHandlerTest : ShellTestCase() {
        verify(mockPipResizeAnimator).start()
    }

    @Test
    fun onPipTransitionStateChanged_exitedPip_removesMirrors() {
        pipDisplayTransferHandler.mOnDragMirrorPerDisplayId = ArrayMap()
        pipDisplayTransferHandler.mOnDragMirrorPerDisplayId.apply {
            put(0, mockLeash)
            put(1, mockLeash)
            put(2, mockLeash)
        }

        pipDisplayTransferHandler.onPipTransitionStateChanged(
            UNDEFINED,
            EXITED_PIP,
            null
        )

        verify(mockTransaction, times(3)).remove(any())
        verify(mockTransaction, times(1)).apply()
        assertThat(pipDisplayTransferHandler.mOnDragMirrorPerDisplayId.isEmpty()).isTrue()
    }

    @Test
    fun showDragMirrorOnConnectedDisplays_hasNotLeftOriginDisplay_shouldNotCreateMirrors() {
        val globalDpBounds = MultiDisplayDragMoveBoundsCalculator.calculateGlobalDpBoundsForDrag(