diff options
| author | 2023-04-11 18:38:25 +0800 | |
|---|---|---|
| committer | 2023-04-11 20:17:13 +0800 | |
| commit | 06f9bb38b382e2a9597b0db99a7ef97a976f3b5f (patch) | |
| tree | 668f7b48a467c250d1e74d215af20c44a7585f46 | |
| parent | 9338d0cce3e9e7208c92f4d97b0ead44e37f3ad9 (diff) | |
Centralize assignment of pip enter animation type
In PipTransition, the places to check enter animation type
may have different orders with different scenarios.
Assume swiping a fullscreen landscape app which can enter PiP
to portrait home:
Api request on foreground:
augmentRequest -> startEnterAnimation -> handleRotateDisplay
Api request on going to background:
startEnterAnimation -> handleRotateDisplay
Swipe to home:
Auto-pip:
augmentRequest -> handleRotateDisplay -> startEnterAnimation
No auto-pip:
handleRotateDisplay -> startEnterAnimation
To reduce the complexity of animation type management, assign
the type at entry of entering pip: PipTaskOrganizer#onTaskAppeared
Then PipTransition only needs to read it.
Note that for swiping auto-pip, the type is always ignored
because the animation is done by recents animation.
Bug: 276438425
Test: Swipe a landscape app into pip in portrait without auto-pip.
The PiP should fade in after the swipe animation.
Change-Id: I98e459fb9913d713cd3b8d44dbb691af61862c56
3 files changed, 13 insertions, 8 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java index 5670fe6eaeba..a8e5795e1e71 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java @@ -712,15 +712,16 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, return; } + final int animationType = shouldAlwaysFadeIn() + ? ANIM_TYPE_ALPHA + : mPipAnimationController.takeOneShotEnterAnimationType(); if (Transitions.ENABLE_SHELL_TRANSITIONS) { + mPipTransitionController.setEnterAnimationType(animationType); // For Shell transition, we will animate the window in PipTransition#startAnimation // instead of #onTaskAppeared. return; } - final int animationType = shouldAlwaysFadeIn() - ? ANIM_TYPE_ALPHA - : mPipAnimationController.takeOneShotEnterAnimationType(); if (mWaitForFixedRotation) { onTaskAppearedWithFixedRotation(animationType); return; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java index 91bb1abbd8c6..7fc661fa7afe 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransition.java @@ -274,9 +274,6 @@ public class PipTransition extends PipTransitionController { if (!requestHasPipEnter(request)) { throw new IllegalStateException("Called PiP augmentRequest when request has no PiP"); } - mEnterAnimationType = mPipOrganizer.shouldAlwaysFadeIn() - ? ANIM_TYPE_ALPHA - : mPipAnimationController.takeOneShotEnterAnimationType(); if (mEnterAnimationType == ANIM_TYPE_ALPHA) { mRequestedEnterTransition = transition; mRequestedEnterTask = request.getTriggerTask().token; @@ -665,6 +662,11 @@ public class PipTransition extends PipTransitionController { return false; } + @Override + public void setEnterAnimationType(@PipAnimationController.AnimationType int type) { + mEnterAnimationType = type; + } + private void startEnterAnimation(@NonNull TransitionInfo info, @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction finishTransaction, @@ -786,8 +788,6 @@ public class PipTransition extends PipTransitionController { final int enterAnimationType = mEnterAnimationType; if (enterAnimationType == ANIM_TYPE_ALPHA) { - // Restore to default type. - mEnterAnimationType = ANIM_TYPE_BOUNDS; startTransaction.setAlpha(leash, 0f); } startTransaction.apply(); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java index 7979ce7a80c1..ff7ab8ba1d97 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTransitionController.java @@ -225,6 +225,10 @@ public abstract class PipTransitionController implements Transitions.TransitionH throw new IllegalStateException("Request isn't entering PiP"); } + /** Sets the type of animation when a PiP task appears. */ + public void setEnterAnimationType(@PipAnimationController.AnimationType int type) { + } + /** Play a transition animation for entering PiP on a specific PiP change. */ public void startEnterAnimation(@NonNull final TransitionInfo.Change pipChange, @NonNull final SurfaceControl.Transaction startTransaction, |