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

Commit 5a3cb52f authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Allow intermittent EXITING in PiP states

There are certain special cases where we should
allow advancement to CHANGING_PIP_BOUNDS state
while not being in SCHEDULED_BOUNDS_CHANGE state.

This is because activity restart, for instance, can
trigger advancement to EXITING_PIP at the time when
exit is just scheduled (transition isn't playing yet);
this has been used to send all components a signal to finish
any animations running outside a transition (e.g. physics animator).

However, we can totally animate a PiP bounds change transition
scheduled earlier since sequentiality is guaranteed with transitions.

What this CL allows is the following:
SCHEDULED_BOUNDS_CHANGE -> EXITING_PIP -> CHANGING_PIP_BOUNDS

where the latter triggers resize animation in the relevant component.

Finally, we also setState(EXITING_PIP) when starting to play
exit-via-expand animation to avoid a an error log that we are trying to
go from _non_EXITING_PIP -> EXITED_PIP.

This should be fine to try twice since, the second time will be blocked
if redundant by PipTransitionState.

Bug: 434087237
Flag: EXEMPT bugfix
Test: atest PipTransitionState
Test: atest ActivityEmbeddingCrossUidTests
  #testUntrustedCrossUidActivityEmbeddingRestoreFromPip_succeedWhenAppOptIn
Change-Id: I3ef11f1a30f35268c8d888fc7cd7a18d0b96b8fb
parent 3e8cca45
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -481,8 +481,6 @@ public class PipTransitionState {
                // - there is no drag-to-desktop gesture in progress; otherwise the PiP resize
                //   transition will block the drag-to-desktop transitions from finishing
                return isPipStateIdle() && !mPipDesktopState.isDragToDesktopInProgress();
            case CHANGING_PIP_BOUNDS:
                return mState == SCHEDULED_BOUNDS_CHANGE;
            default:
                return true;
        }
+2 −0
Original line number Diff line number Diff line
@@ -169,6 +169,7 @@ public class PipExpandHandler implements Transitions.TransitionHandler {
                return false;
            }
        }
        mPipTransitionState.setState(PipTransitionState.EXITING_PIP);
        mFinishCallback = finishCallback;

        // The parent change if we were in a multi-activity PiP; null if single activity PiP.
@@ -316,6 +317,7 @@ public class PipExpandHandler implements Transitions.TransitionHandler {
        if (pipChange == null || pipChange.getLeash() == null) {
            return false;
        }
        mPipTransitionState.setState(PipTransitionState.EXITING_PIP);
        mFinishCallback = finishCallback;

        // Get the original parent before PiP. If original task hosting the PiP activity was
+0 −8
Original line number Diff line number Diff line
@@ -184,14 +184,6 @@ public class PipTransitionStateTest extends ShellTestCase {
                PipTransitionState.CHANGING_PIP_BOUNDS));
    }

    @Test
    public void testShouldTransitionToState_changingPipBounds_withoutScheduling_returnsFalse() {
        mPipTransitionState.setState(PipTransitionState.ENTERED_PIP);

        Assert.assertFalse(mPipTransitionState.shouldTransitionToState(
                PipTransitionState.CHANGING_PIP_BOUNDS));
    }

    @Test
    public void shouldTransitionToState_scheduledBoundsChangeWhileChangingBounds_returnsFalse() {
        Bundle extra = new Bundle();