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

Commit cee4fc85 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Make sure saveReentryState works.

Make sure saveReentryState works with shell
transitions on. More specifically, make sure to use
pipBounds instead of userResizeBounds.

Bug: 271370371
Test: manually reproduced the steps in the bug
Change-Id: I2622caa305e3a352506e6c58065e3e70ca3df128
parent 0a2721fc
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -1060,13 +1060,22 @@ public class PipController implements PipTransitionController.PipTransitionCallb
    /** Save the state to restore to on re-entry. */
    public void saveReentryState(Rect pipBounds) {
        float snapFraction = mPipBoundsAlgorithm.getSnapFraction(pipBounds);
        if (mPipBoundsState.hasUserResizedPip()) {
            final Rect reentryBounds = mTouchHandler.getUserResizeBounds();
            final Size reentrySize = new Size(reentryBounds.width(), reentryBounds.height());
            mPipBoundsState.saveReentryState(reentrySize, snapFraction);
        } else {

        if (!mPipBoundsState.hasUserResizedPip()) {
            mPipBoundsState.saveReentryState(null /* bounds */, snapFraction);
            return;
        }

        Size reentrySize = new Size(pipBounds.width(), pipBounds.height());

        // TODO: b/279937014 Investigate why userResizeBounds are empty with shell transitions on
        // fallback to using the userResizeBounds if userResizeBounds are not empty
        if (!mTouchHandler.getUserResizeBounds().isEmpty()) {
            Rect userResizeBounds = mTouchHandler.getUserResizeBounds();
            reentrySize = new Size(userResizeBounds.width(), userResizeBounds.height());
        }

        mPipBoundsState.saveReentryState(reentrySize, snapFraction);
    }

    @Override
+14 −1
Original line number Diff line number Diff line
@@ -268,7 +268,7 @@ public class PipControllerTest extends ShellTestCase {
    }

    @Test
    public void saveReentryState_userHasResized_savesSize() {
    public void saveReentryState_nonEmptyUserResizeBounds_savesSize() {
        final Rect bounds = new Rect(0, 0, 10, 10);
        final Rect resizedBounds = new Rect(0, 0, 30, 30);
        when(mMockPipBoundsAlgorithm.getSnapFraction(bounds)).thenReturn(1.0f);
@@ -280,6 +280,19 @@ public class PipControllerTest extends ShellTestCase {
        verify(mMockPipBoundsState).saveReentryState(new Size(30, 30), 1.0f);
    }

    @Test
    public void saveReentryState_emptyUserResizeBounds_savesSize() {
        final Rect bounds = new Rect(0, 0, 10, 10);
        final Rect resizedBounds = new Rect(0, 0, 0, 0);
        when(mMockPipBoundsAlgorithm.getSnapFraction(bounds)).thenReturn(1.0f);
        when(mMockPipTouchHandler.getUserResizeBounds()).thenReturn(resizedBounds);
        when(mMockPipBoundsState.hasUserResizedPip()).thenReturn(true);

        mPipController.saveReentryState(bounds);

        verify(mMockPipBoundsState).saveReentryState(new Size(10, 10), 1.0f);
    }

    @Test
    public void onDisplayConfigurationChanged_inPip_movePip() {
        final int displayId = 1;