Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java +10 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.animation.Animator; import android.animation.RectEvaluator; import android.animation.ValueAnimator; import android.annotation.IntDef; import android.annotation.NonNull; import android.app.TaskInfo; import android.content.Context; import android.graphics.Rect; Loading Loading @@ -194,6 +195,15 @@ public class PipAnimationController { return animator; } /** * Quietly cancel the animator by removing the listeners first. */ static void quietCancel(@NonNull ValueAnimator animator) { animator.removeAllUpdateListeners(); animator.removeAllListeners(); animator.cancel(); } /** * Additional callback interface for PiP animation */ Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +19 −19 Original line number Diff line number Diff line Loading @@ -457,6 +457,9 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, wct.setBoundsChangeTransaction(mToken, tx); } // Cancel the existing animator if there is any. cancelCurrentAnimator(); // Set the exiting state first so if there is fixed rotation later, the running animation // won't be interrupted by alpha animation for existing PiP. mPipTransitionState.setTransitionState(PipTransitionState.EXITING_PIP); Loading Loading @@ -802,18 +805,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, return; } final PipAnimationController.PipTransitionAnimator<?> animator = mPipAnimationController.getCurrentAnimator(); if (animator != null) { if (animator.getContentOverlayLeash() != null) { removeContentOverlay(animator.getContentOverlayLeash(), animator::clearContentOverlay); } animator.removeAllUpdateListeners(); animator.removeAllListeners(); animator.cancel(); } cancelCurrentAnimator(); onExitPipFinished(info); if (Transitions.ENABLE_SHELL_TRANSITIONS) { Loading Loading @@ -1050,9 +1042,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, int direction = TRANSITION_DIRECTION_NONE; if (animator != null) { direction = animator.getTransitionDirection(); animator.removeAllUpdateListeners(); animator.removeAllListeners(); animator.cancel(); PipAnimationController.quietCancel(animator); // Do notify the listeners that this was canceled sendOnPipTransitionCancelled(direction); sendOnPipTransitionFinished(direction); Loading Loading @@ -1586,10 +1576,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, // set a start delay on this animation. ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, "%s: Task vanished, skip fadeOutAndRemoveOverlay", TAG); animation.removeAllListeners(); animation.removeAllUpdateListeners(); animation.cancel(); } else { PipAnimationController.quietCancel(animation); } else if (surface.isValid()) { final float alpha = (float) animation.getAnimatedValue(); final SurfaceControl.Transaction transaction = mSurfaceControlTransactionFactory.getTransaction(); Loading Loading @@ -1628,6 +1616,18 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, tx.apply(); } private void cancelCurrentAnimator() { final PipAnimationController.PipTransitionAnimator<?> animator = mPipAnimationController.getCurrentAnimator(); if (animator != null) { if (animator.getContentOverlayLeash() != null) { removeContentOverlay(animator.getContentOverlayLeash(), animator::clearContentOverlay); } PipAnimationController.quietCancel(animator); } } @VisibleForTesting public void setSurfaceControlTransactionFactory( PipSurfaceTransactionHelper.SurfaceControlTransactionFactory factory) { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java +10 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.animation.Animator; import android.animation.RectEvaluator; import android.animation.ValueAnimator; import android.annotation.IntDef; import android.annotation.NonNull; import android.app.TaskInfo; import android.content.Context; import android.graphics.Rect; Loading Loading @@ -194,6 +195,15 @@ public class PipAnimationController { return animator; } /** * Quietly cancel the animator by removing the listeners first. */ static void quietCancel(@NonNull ValueAnimator animator) { animator.removeAllUpdateListeners(); animator.removeAllListeners(); animator.cancel(); } /** * Additional callback interface for PiP animation */ Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +19 −19 Original line number Diff line number Diff line Loading @@ -457,6 +457,9 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, wct.setBoundsChangeTransaction(mToken, tx); } // Cancel the existing animator if there is any. cancelCurrentAnimator(); // Set the exiting state first so if there is fixed rotation later, the running animation // won't be interrupted by alpha animation for existing PiP. mPipTransitionState.setTransitionState(PipTransitionState.EXITING_PIP); Loading Loading @@ -802,18 +805,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, return; } final PipAnimationController.PipTransitionAnimator<?> animator = mPipAnimationController.getCurrentAnimator(); if (animator != null) { if (animator.getContentOverlayLeash() != null) { removeContentOverlay(animator.getContentOverlayLeash(), animator::clearContentOverlay); } animator.removeAllUpdateListeners(); animator.removeAllListeners(); animator.cancel(); } cancelCurrentAnimator(); onExitPipFinished(info); if (Transitions.ENABLE_SHELL_TRANSITIONS) { Loading Loading @@ -1050,9 +1042,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, int direction = TRANSITION_DIRECTION_NONE; if (animator != null) { direction = animator.getTransitionDirection(); animator.removeAllUpdateListeners(); animator.removeAllListeners(); animator.cancel(); PipAnimationController.quietCancel(animator); // Do notify the listeners that this was canceled sendOnPipTransitionCancelled(direction); sendOnPipTransitionFinished(direction); Loading Loading @@ -1586,10 +1576,8 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, // set a start delay on this animation. ProtoLog.d(ShellProtoLogGroup.WM_SHELL_PICTURE_IN_PICTURE, "%s: Task vanished, skip fadeOutAndRemoveOverlay", TAG); animation.removeAllListeners(); animation.removeAllUpdateListeners(); animation.cancel(); } else { PipAnimationController.quietCancel(animation); } else if (surface.isValid()) { final float alpha = (float) animation.getAnimatedValue(); final SurfaceControl.Transaction transaction = mSurfaceControlTransactionFactory.getTransaction(); Loading Loading @@ -1628,6 +1616,18 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, tx.apply(); } private void cancelCurrentAnimator() { final PipAnimationController.PipTransitionAnimator<?> animator = mPipAnimationController.getCurrentAnimator(); if (animator != null) { if (animator.getContentOverlayLeash() != null) { removeContentOverlay(animator.getContentOverlayLeash(), animator::clearContentOverlay); } PipAnimationController.quietCancel(animator); } } @VisibleForTesting public void setSurfaceControlTransactionFactory( PipSurfaceTransactionHelper.SurfaceControlTransactionFactory factory) { Loading