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

Commit 7654565a authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

Allow open intent to enter PiP w/o config-at-end

Up until now we had been using a config-at-end activity
change to figure out if notification tap to enter PiP
is happening in PiP2, but that's not a really reliable way
of filtering this; sometimes the visibility of activity might
lead to the activity not being marked as config-at-end.

That being said, even when we don't have access to config-at-end
change in Shell, we can still run a legacy cross-fade animation
for enter-PiP.

So this CL does the following 2 things:
 1. Use a flag check instead of pipActivityChange to check for
enter PiP and open-intent mixed transition
 2. Allow OPEN, TO_FRONT and CHANGE modes for PiP task to trigger
legacy animation if there is no activity amongst the changes.

Bug: 439761337
Flag: EXEMPT bugfix
Test: repro the steps in BR manually
Change-Id: I6b14d608b4976b35765d20ad280f9dfa3f272113
parent e3f2406b
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -961,11 +961,12 @@ public class PipTransition extends PipTransitionController implements

            // #getEnterPipTransaction() always attempts to mark PiP activity as config-at-end one.
            // However, the activity will only actually be marked config-at-end by Core if it is
            // both isVisible and isVisibleRequested, which is when we can't run bounds animation.
            // both isVisible and isVisibleRequested, which is when we can run bounds animation.
            //
            // So we can use the absence of a config-at-end activity as a signal that we should run
            // a legacy-enter PiP animation instead.
            return TransitionUtil.isOpeningMode(pipChange.getMode())
            return (TransitionUtil.isOpeningMode(pipChange.getMode())
                    || pipChange.getMode() == TRANSIT_CHANGE)
                    && PipTransitionUtils.getDeferConfigActivityChange(
                            info, pipChange.getContainer()) == null;
        }
+9 −9
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.wm.shell.pip.PipTransitionController;
import com.android.wm.shell.pip2.phone.transition.PipTransitionUtils;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.shared.TransitionUtil;
import com.android.wm.shell.shared.pip.PipFlags;
import com.android.wm.shell.splitscreen.SplitScreen;
import com.android.wm.shell.splitscreen.SplitScreenController;
import com.android.wm.shell.splitscreen.StageCoordinator;
@@ -235,7 +236,7 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
        }

        TransitionInfo.Change pipChange = null;
        TransitionInfo.Change pipActivityChange = null;
        final TransitionInfo pipInfo = subCopy(info, TRANSIT_PIP, false /* withChanges */);
        for (int i = info.getChanges().size() - 1; i >= 0; --i) {
            TransitionInfo.Change change = info.getChanges().get(i);
            if (mPipHandler.isEnteringPip(change, info.getType())) {
@@ -245,12 +246,14 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
                }
                pipChange = change;
                info.getChanges().remove(i);
                pipInfo.addChange(pipChange);
            } 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 pipActivityChange = info.getChanges().remove(i);
                pipInfo.getChanges().addFirst(pipActivityChange);
            }
        }
        TransitionInfo.Change desktopChange = null;
@@ -295,15 +298,12 @@ 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();
            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));
            if (PipFlags.isPip2ExperimentEnabled()) {
                mPipHandler.startAnimation(mTransition, pipInfo, startTransaction,
                        finishTransaction, finishCB);
            } else {
                mPipHandler.startEnterAnimation(pipChange, otherStartT, finishTransaction,
                        finishCB);
            }

            // Dispatch the rest of the transition normally.