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

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

[PiP2] Handle open intent and PiP transition

Whenever an open intent transition comes in
with a remote transition in its request,
that transition is being handled by DefaultMixedHandler.

We need to make sure if the current task is PiP-ing,
the enter-PiP animation is being delegated to the pip handler
along the way as well.

We also need to make sure that the config-at-end activity change
is removed from the leftover handler's TransitionInfo and sent into
PipTransition.

Bug: 382715281
Flag: com.android.wm.shell.enable_pip2
Test: start a PiP activity, then adb shell am start
<non-launcher-activity>
Test: tap a notification from another app, while in PiP app

Change-Id: I5ba59fe722dc69aba9d61b17c1373e594e305be3
parent 27d12132
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -123,7 +123,6 @@ public class PipTransition extends PipTransitionController implements
    // Internal state and relevant cached info
    //

    @Nullable
    private Transitions.TransitionFinishCallback mFinishCallback;

    private ValueAnimator mTransitionAnimator;
@@ -234,7 +233,6 @@ public class PipTransition extends PipTransitionController implements
            @NonNull SurfaceControl.Transaction startTransaction,
            @NonNull SurfaceControl.Transaction finishTransaction,
            @NonNull Transitions.TransitionFinishCallback finishCallback) {
        mFinishCallback = finishCallback;
        if (transition == mEnterTransition || info.getType() == TRANSIT_PIP) {
            mEnterTransition = null;
            // If we are in swipe PiP to Home transition we are ENTERING_PIP as a jumpcut transition
@@ -280,7 +278,6 @@ public class PipTransition extends PipTransitionController implements
        if (isRemovePipTransition(info)) {
            return removePipImmediately(info, startTransaction, finishTransaction, finishCallback);
        }
        mFinishCallback = null;
        return false;
    }

@@ -329,6 +326,7 @@ public class PipTransition extends PipTransitionController implements
        if (pipChange == null) {
            return false;
        }
        mFinishCallback = finishCallback;
        // We expect the PiP activity as a separate change in a config-at-end transition;
        // only flings are not using config-at-end for resize bounds changes
        TransitionInfo.Change pipActivityChange = getDeferConfigActivityChange(info,
@@ -376,6 +374,7 @@ public class PipTransition extends PipTransitionController implements
        if (pipActivityChange == null) {
            return false;
        }
        mFinishCallback = finishCallback;

        final SurfaceControl pipLeash = getLeash(pipChange);
        final Rect destinationBounds = pipChange.getEndAbsBounds();
@@ -444,6 +443,7 @@ public class PipTransition extends PipTransitionController implements
        if (pipActivityChange == null) {
            return false;
        }
        mFinishCallback = finishCallback;

        final SurfaceControl pipLeash = getLeash(pipChange);
        final Rect startBounds = pipChange.getStartAbsBounds();
@@ -570,6 +570,7 @@ public class PipTransition extends PipTransitionController implements
        if (pipChange == null) {
            return false;
        }
        mFinishCallback = finishCallback;

        Rect destinationBounds = pipChange.getEndAbsBounds();
        SurfaceControl pipLeash = mPipTransitionState.getPinnedTaskLeash();
@@ -612,6 +613,7 @@ public class PipTransition extends PipTransitionController implements
                return false;
            }
        }
        mFinishCallback = finishCallback;

        // The parent change if we were in a multi-activity PiP; null if single activity PiP.
        final TransitionInfo.Change parentBeforePip = pipChange.getTaskInfo() == null
+17 −2
Original line number Diff line number Diff line
@@ -204,6 +204,7 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS,
                "tryAnimateOpenIntentWithRemoteAndPipOrDesktop");
        TransitionInfo.Change pipChange = null;
        TransitionInfo.Change pipActivityChange = null;
        for (int i = info.getChanges().size() - 1; i >= 0; --i) {
            TransitionInfo.Change change = info.getChanges().get(i);
            if (mPipHandler.isEnteringPip(change, info.getType())) {
@@ -213,6 +214,12 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
                }
                pipChange = change;
                info.getChanges().remove(i);
            } else if (change.getTaskInfo() == null && change.getParent() != null
                    && pipChange != null && change.getParent().equals(pipChange.getContainer())) {
                // Cache the PiP activity if it's a target and cached pip task change is its parent;
                // note that we are bottom-to-top, so if such activity has a task
                // that is also a target, then it must have been cached already as pipChange.
                pipActivityChange = change;
            }
        }
        TransitionInfo.Change desktopChange = null;
@@ -257,8 +264,16 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
            // make a new startTransaction because pip's startEnterAnimation "consumes" it so
            // we need a separate one to send over to launcher.
            SurfaceControl.Transaction otherStartT = new SurfaceControl.Transaction();

            mPipHandler.startEnterAnimation(pipChange, otherStartT, finishTransaction, finishCB);
            if (pipActivityChange == null) {
                mPipHandler.startEnterAnimation(pipChange, otherStartT, finishTransaction,
                        finishCB);
            } else {
                info.getChanges().remove(pipActivityChange);
                TransitionInfo pipInfo = subCopy(info, TRANSIT_PIP, false /* withChanges */);
                pipInfo.getChanges().addAll(List.of(pipChange, pipActivityChange));
                mPipHandler.startAnimation(mTransition, pipInfo, startTransaction,
                        finishTransaction, finishCB);
            }

            // Dispatch the rest of the transition normally.
            if (mLeftoversHandler != null