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

Commit cd59bb7a authored by Vania Desmonda's avatar Vania Desmonda Committed by Android (Google) Code Review
Browse files

Merge "Remove drag mirrors on EXITED_PIP." into main

parents 198ab243 1c449914
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;
        }
    }

@@ -239,7 +242,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(