diff options
| author | 2024-12-06 17:53:21 -0800 | |
|---|---|---|
| committer | 2024-12-09 15:24:42 -0800 | |
| commit | bfea8348c0d67fdc661dc02a19a3b22e955b35e4 (patch) | |
| tree | 62f89ea004f62a01d6a512176faa51b65e6aad3a | |
| parent | 27d12132f097274645fc1e0ae997ccf92e9028c6 (diff) | |
[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
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java | 8 | ||||
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedTransition.java | 19 |
2 files changed, 22 insertions, 5 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java index 1a012e075be5..9894b91a32c2 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java @@ -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 diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedTransition.java index 03ded730865e..b0547a2a47b1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedTransition.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedTransition.java @@ -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 |