diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java index 01d8967c7d600..8468aacffc693 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java @@ -2441,6 +2441,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, mSplitLayout.setFreezeDividerWindow(false); final StageChangeRecord record = new StageChangeRecord(); + final int transitType = info.getType(); + boolean hasEnteringPip = false; for (int iC = 0; iC < info.getChanges().size(); ++iC) { final TransitionInfo.Change change = info.getChanges().get(iC); if (change.getMode() == TRANSIT_CHANGE @@ -2448,6 +2450,10 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, mSplitLayout.update(startTransaction); } + if (mMixedHandler.isEnteringPip(change, transitType)) { + hasEnteringPip = true; + } + final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo(); if (taskInfo == null) continue; if (taskInfo.token.equals(mRootTaskInfo.token)) { @@ -2496,6 +2502,13 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler, } } } + + if (hasEnteringPip) { + mMixedHandler.animatePendingEnterPipFromSplit(transition, info, + startTransaction, finishTransaction, finishCallback); + return true; + } + final ArraySet dismissStages = record.getShouldDismissedStage(); if (mMainStage.getChildCount() == 0 || mSideStage.getChildCount() == 0 || dismissStages.size() == 1) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java index e83780a6fc772..49185d1a6ed74 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedHandler.java @@ -447,7 +447,8 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, } finishCallback.onTransitionFinished(mixed.mFinishWCT, wctCB); }; - if (isGoingHome) { + if (isGoingHome || mSplitHandler.getSplitItemPosition(pipChange.getLastParent()) + != SPLIT_POSITION_UNDEFINED) { ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Animation is actually mixed " + "since entering-PiP caused us to leave split and return home."); // We need to split the transition into 2 parts: the pip part (animated by pip) @@ -515,11 +516,28 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, return false; } + /** + * This is intended to be called by SplitCoordinator as a helper to mix a split handling + * transition with an entering-pip change. The use-case for this is when an auto-pip change + * gets collected into the transition which has already claimed by + * StageCoordinator.handleRequest. This happens when launching a fullscreen app while having an + * auto-pip activity in the foreground split pair. + */ + // TODO(b/287704263): Remove when split/mixed are reversed. + public boolean animatePendingEnterPipFromSplit(IBinder transition, TransitionInfo info, + SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT, + Transitions.TransitionFinishCallback finishCallback) { + final MixedTransition mixed = new MixedTransition( + MixedTransition.TYPE_ENTER_PIP_FROM_SPLIT, transition); + mActiveTransitions.add(mixed); + return animateEnterPipFromSplit(mixed, info, startT, finishT, finishCallback); + } + /** * This is intended to be called by SplitCoordinator as a helper to mix an already-pending * split transition with a display-change. The use-case for this is when a display * change/rotation gets collected into a split-screen enter/exit transition which has already - * been claimed by StageCoordinator.handleRequest . This happens during launcher tests. + * been claimed by StageCoordinator.handleRequest. This happens during launcher tests. */ public boolean animatePendingSplitWithDisplayChange(@NonNull IBinder transition, @NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startT, @@ -657,6 +675,13 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler, return mPipHandler.requestHasPipEnter(request); } + /** Whether a particular change is a window that is entering pip. */ + // TODO(b/287704263): Remove when split/mixed are reversed. + public boolean isEnteringPip(TransitionInfo.Change change, + @WindowManager.TransitionType int transitType) { + return mPipHandler.isEnteringPip(change, transitType); + } + @Override public void mergeAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction t, @NonNull IBinder mergeTarget, diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java index 3b05651f884b9..44c76de945b03 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/splitscreen/SplitTransitionTests.java @@ -75,6 +75,7 @@ import com.android.wm.shell.common.SyncTransactionQueue; import com.android.wm.shell.common.TransactionPool; import com.android.wm.shell.common.split.SplitDecorManager; import com.android.wm.shell.common.split.SplitLayout; +import com.android.wm.shell.transition.DefaultMixedHandler; import com.android.wm.shell.transition.Transitions; import org.junit.Before; @@ -101,6 +102,7 @@ public class SplitTransitionTests extends ShellTestCase { @Mock private SurfaceSession mSurfaceSession; @Mock private IconProvider mIconProvider; @Mock private ShellExecutor mMainExecutor; + @Mock private DefaultMixedHandler mMixedHandler; private SplitLayout mSplitLayout; private MainStage mMainStage; private SideStage mSideStage; @@ -131,6 +133,7 @@ public class SplitTransitionTests extends ShellTestCase { mSyncQueue, mTaskOrganizer, mMainStage, mSideStage, mDisplayController, mDisplayImeController, mDisplayInsetsController, mSplitLayout, mTransitions, mTransactionPool, mMainExecutor, Optional.empty()); + mStageCoordinator.setMixedHandler(mMixedHandler); mSplitScreenTransitions = mStageCoordinator.getSplitTransitions(); doAnswer((Answer) invocation -> mock(IBinder.class)) .when(mTransitions).startTransition(anyInt(), any(), any());