Loading services/core/java/com/android/server/wm/ActivityRecord.java +3 −2 Original line number Diff line number Diff line Loading @@ -4089,11 +4089,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A @Override boolean applyAnimation(WindowManager.LayoutParams lp, int transit, boolean enter, boolean isVoiceInteraction) { boolean isVoiceInteraction, @Nullable Runnable animationFinishedCallback) { if (mUseTransferredAnimation) { return false; } return super.applyAnimation(lp, transit, enter, isVoiceInteraction); return super.applyAnimation(lp, transit, enter, isVoiceInteraction, animationFinishedCallback); } /** Loading services/core/java/com/android/server/wm/ActivityStack.java +0 −12 Original line number Diff line number Diff line Loading @@ -4946,18 +4946,6 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn } } @Override protected void onAnimationFinished() { super.onAnimationFinished(); // TODO(b/142617871): we may need to add animation type parameter on onAnimationFinished to // identify if the callback is for launch animation finish and then calling // activity#onAnimationFinished. final ActivityRecord activity = getTopMostActivity(); if (activity != null) { activity.onAnimationFinished(); } } /** * Sets the current picture-in-picture aspect ratio. */ Loading services/core/java/com/android/server/wm/AppTransitionController.java +28 −8 Original line number Diff line number Diff line Loading @@ -352,6 +352,7 @@ public class AppTransitionController { * Apply animation to the set of window containers. * * @param wcs The list of {@link WindowContainer}s to which an app transition animation applies. * @param apps The list of {@link ActivityRecord}s being transitioning. * @param transit The current transition type. * @param visible {@code true} if the apps becomes visible, {@code false} if the apps becomes * invisible. Loading @@ -359,12 +360,28 @@ public class AppTransitionController { * @param voiceInteraction {@code true} if one of the apps in this transition belongs to a voice * interaction session driving task. */ private void applyAnimations(ArraySet<WindowContainer> wcs, @TransitionType int transit, boolean visible, LayoutParams animLp, boolean voiceInteraction) { final int appsCount = wcs.size(); for (int i = 0; i < appsCount; i++) { private void applyAnimations(ArraySet<WindowContainer> wcs, ArraySet<ActivityRecord> apps, @TransitionType int transit, boolean visible, LayoutParams animLp, boolean voiceInteraction) { final int wcsCount = wcs.size(); for (int i = 0; i < wcsCount; i++) { final WindowContainer wc = wcs.valueAt(i); wc.applyAnimation(animLp, transit, visible, voiceInteraction); // If app transition animation target is promoted to higher level, SurfaceAnimator // triggers WC#onAnimationFinished only on the promoted target. So we need to take care // of triggering AR#onAnimationFinished on each ActivityRecord which is a part of the // app transition. final ArrayList<ActivityRecord> transitioningDecendants = new ArrayList<>(); for (int j = 0; j < apps.size(); ++j) { final ActivityRecord app = apps.valueAt(j); if (app.isDescendantOf(wc)) { transitioningDecendants.add(app); } } wc.applyAnimation(animLp, transit, visible, voiceInteraction, () -> { for (int j = 0; j < transitioningDecendants.size(); ++j) { transitioningDecendants.get(j).onAnimationFinished(); } }); } } Loading Loading @@ -495,8 +512,10 @@ public class AppTransitionController { openingApps, closingApps, true /* visible */); final ArraySet<WindowContainer> closingWcs = getAnimationTargets( openingApps, closingApps, false /* visible */); applyAnimations(openingWcs, transit, true /* visible */, animLp, voiceInteraction); applyAnimations(closingWcs, transit, false /* visible */, animLp, voiceInteraction); applyAnimations(openingWcs, openingApps, transit, true /* visible */, animLp, voiceInteraction); applyAnimations(closingWcs, closingApps, transit, false /* visible */, animLp, voiceInteraction); final AccessibilityController accessibilityController = mDisplayContent.mWmService.mAccessibilityController; Loading Loading @@ -575,7 +594,8 @@ public class AppTransitionController { ActivityRecord activity = apps.valueAt(i); ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, "Now changing app %s", activity); activity.cancelAnimationOnly(); activity.applyAnimation(null, transit, true, false); activity.applyAnimation(null, transit, true, false, null /* animationFinishedCallback */); activity.updateReportedVisibilityLocked(); mService.openSurfaceTransaction(); try { Loading services/core/java/com/android/server/wm/Dimmer.java +5 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.server.wm.AlphaAnimationSpecProto.FROM; import static com.android.server.wm.AlphaAnimationSpecProto.TO; import static com.android.server.wm.AnimationSpecProto.ALPHA; import android.annotation.Nullable; import android.graphics.Rect; import android.util.Log; import android.util.proto.ProtoOutputStream; Loading Loading @@ -156,7 +157,8 @@ class Dimmer { @VisibleForTesting interface SurfaceAnimatorStarter { void startAnimation(SurfaceAnimator surfaceAnimator, SurfaceControl.Transaction t, AnimationAdapter anim, boolean hidden); AnimationAdapter anim, boolean hidden, @Nullable Runnable animationFinishedCallback); } Dimmer(WindowContainer host) { Loading Loading @@ -342,7 +344,8 @@ class Dimmer { SurfaceControl.Transaction t, float startAlpha, float endAlpha) { mSurfaceAnimatorStarter.startAnimation(animator, t, new LocalAnimationAdapter( new AlphaAnimationSpec(startAlpha, endAlpha, getDimDuration(container)), mHost.mWmService.mSurfaceAnimationRunner), false /* hidden */); mHost.mWmService.mSurfaceAnimationRunner), false /* hidden */, null /* animationFinishedCallback */); } private long getDimDuration(WindowContainer container) { Loading services/core/java/com/android/server/wm/SurfaceAnimator.java +26 −5 Original line number Diff line number Diff line Loading @@ -55,7 +55,9 @@ class SurfaceAnimator { private final OnAnimationFinishedCallback mInnerAnimationFinishedCallback; @VisibleForTesting @Nullable final Runnable mAnimationFinishedCallback; final Runnable mStaticAnimationFinishedCallback; @Nullable private Runnable mAnimationFinishedCallback; private boolean mAnimationStartDelayed; /** Loading @@ -66,7 +68,7 @@ class SurfaceAnimator { WindowManagerService service) { mAnimatable = animatable; mService = service; mAnimationFinishedCallback = animationFinishedCallback; mStaticAnimationFinishedCallback = animationFinishedCallback; mInnerAnimationFinishedCallback = getFinishedCallback(animationFinishedCallback); } Loading @@ -89,10 +91,14 @@ class SurfaceAnimator { if (anim != mAnimation) { return; } final Runnable animationFinishCallback = mAnimationFinishedCallback; reset(mAnimatable.getPendingTransaction(), true /* destroyLeash */); if (animationFinishedCallback != null) { animationFinishedCallback.run(); } if (animationFinishCallback != null) { animationFinishCallback.run(); } }; if (!mAnimatable.shouldDeferAnimationFinish(resetAndInvokeFinish)) { resetAndInvokeFinish.run(); Loading @@ -111,10 +117,13 @@ class SurfaceAnimator { * @param hidden Whether the container holding the child surfaces is currently visible or not. * This is important as it will start with the leash hidden or visible before * handing it to the component that is responsible to run the animation. * @param animationFinishedCallback The callback being triggered when the animation finishes. */ void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden) { void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden, @Nullable Runnable animationFinishedCallback) { cancelAnimation(t, true /* restarting */, true /* forwardCancel */); mAnimation = anim; mAnimationFinishedCallback = animationFinishedCallback; final SurfaceControl surface = mAnimatable.getSurfaceControl(); if (surface == null) { Slog.w(TAG, "Unable to start animation, surface is null or no children."); Loading @@ -131,6 +140,10 @@ class SurfaceAnimator { mAnimation.startAnimation(mLeash, t, mInnerAnimationFinishedCallback); } void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden) { startAnimation(t, anim, hidden, null /* animationFinishedCallback */); } /** * Begins with delaying all animations to start. Any subsequent call to {@link #startAnimation} * will not start the animation until {@link #endDelayingAnimationStart} is called. When an Loading Loading @@ -232,6 +245,7 @@ class SurfaceAnimator { cancelAnimation(t, true /* restarting */, true /* forwardCancel */); mLeash = from.mLeash; mAnimation = from.mAnimation; mAnimationFinishedCallback = from.mAnimationFinishedCallback; // Cancel source animation, but don't let animation runner cancel the animation. from.cancelAnimation(t, false /* restarting */, false /* forwardCancel */); Loading @@ -258,13 +272,19 @@ class SurfaceAnimator { if (DEBUG_ANIM) Slog.i(TAG, "Cancelling animation restarting=" + restarting); final SurfaceControl leash = mLeash; final AnimationAdapter animation = mAnimation; final Runnable animationFinishedCallback = mAnimationFinishedCallback; reset(t, false); if (animation != null) { if (!mAnimationStartDelayed && forwardCancel) { animation.onAnimationCancelled(leash); } if (!restarting && mAnimationFinishedCallback != null) { mAnimationFinishedCallback.run(); if (!restarting) { if (mStaticAnimationFinishedCallback != null) { mStaticAnimationFinishedCallback.run(); } if (animationFinishedCallback != null) { animationFinishedCallback.run(); } } } Loading Loading @@ -304,6 +324,7 @@ class SurfaceAnimator { } mLeash = null; mAnimation = null; mAnimationFinishedCallback = null; if (reparent) { // Make sure to inform the animatable after the surface was reparented (or reparent Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +3 −2 Original line number Diff line number Diff line Loading @@ -4089,11 +4089,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A @Override boolean applyAnimation(WindowManager.LayoutParams lp, int transit, boolean enter, boolean isVoiceInteraction) { boolean isVoiceInteraction, @Nullable Runnable animationFinishedCallback) { if (mUseTransferredAnimation) { return false; } return super.applyAnimation(lp, transit, enter, isVoiceInteraction); return super.applyAnimation(lp, transit, enter, isVoiceInteraction, animationFinishedCallback); } /** Loading
services/core/java/com/android/server/wm/ActivityStack.java +0 −12 Original line number Diff line number Diff line Loading @@ -4946,18 +4946,6 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn } } @Override protected void onAnimationFinished() { super.onAnimationFinished(); // TODO(b/142617871): we may need to add animation type parameter on onAnimationFinished to // identify if the callback is for launch animation finish and then calling // activity#onAnimationFinished. final ActivityRecord activity = getTopMostActivity(); if (activity != null) { activity.onAnimationFinished(); } } /** * Sets the current picture-in-picture aspect ratio. */ Loading
services/core/java/com/android/server/wm/AppTransitionController.java +28 −8 Original line number Diff line number Diff line Loading @@ -352,6 +352,7 @@ public class AppTransitionController { * Apply animation to the set of window containers. * * @param wcs The list of {@link WindowContainer}s to which an app transition animation applies. * @param apps The list of {@link ActivityRecord}s being transitioning. * @param transit The current transition type. * @param visible {@code true} if the apps becomes visible, {@code false} if the apps becomes * invisible. Loading @@ -359,12 +360,28 @@ public class AppTransitionController { * @param voiceInteraction {@code true} if one of the apps in this transition belongs to a voice * interaction session driving task. */ private void applyAnimations(ArraySet<WindowContainer> wcs, @TransitionType int transit, boolean visible, LayoutParams animLp, boolean voiceInteraction) { final int appsCount = wcs.size(); for (int i = 0; i < appsCount; i++) { private void applyAnimations(ArraySet<WindowContainer> wcs, ArraySet<ActivityRecord> apps, @TransitionType int transit, boolean visible, LayoutParams animLp, boolean voiceInteraction) { final int wcsCount = wcs.size(); for (int i = 0; i < wcsCount; i++) { final WindowContainer wc = wcs.valueAt(i); wc.applyAnimation(animLp, transit, visible, voiceInteraction); // If app transition animation target is promoted to higher level, SurfaceAnimator // triggers WC#onAnimationFinished only on the promoted target. So we need to take care // of triggering AR#onAnimationFinished on each ActivityRecord which is a part of the // app transition. final ArrayList<ActivityRecord> transitioningDecendants = new ArrayList<>(); for (int j = 0; j < apps.size(); ++j) { final ActivityRecord app = apps.valueAt(j); if (app.isDescendantOf(wc)) { transitioningDecendants.add(app); } } wc.applyAnimation(animLp, transit, visible, voiceInteraction, () -> { for (int j = 0; j < transitioningDecendants.size(); ++j) { transitioningDecendants.get(j).onAnimationFinished(); } }); } } Loading Loading @@ -495,8 +512,10 @@ public class AppTransitionController { openingApps, closingApps, true /* visible */); final ArraySet<WindowContainer> closingWcs = getAnimationTargets( openingApps, closingApps, false /* visible */); applyAnimations(openingWcs, transit, true /* visible */, animLp, voiceInteraction); applyAnimations(closingWcs, transit, false /* visible */, animLp, voiceInteraction); applyAnimations(openingWcs, openingApps, transit, true /* visible */, animLp, voiceInteraction); applyAnimations(closingWcs, closingApps, transit, false /* visible */, animLp, voiceInteraction); final AccessibilityController accessibilityController = mDisplayContent.mWmService.mAccessibilityController; Loading Loading @@ -575,7 +594,8 @@ public class AppTransitionController { ActivityRecord activity = apps.valueAt(i); ProtoLog.v(WM_DEBUG_APP_TRANSITIONS, "Now changing app %s", activity); activity.cancelAnimationOnly(); activity.applyAnimation(null, transit, true, false); activity.applyAnimation(null, transit, true, false, null /* animationFinishedCallback */); activity.updateReportedVisibilityLocked(); mService.openSurfaceTransaction(); try { Loading
services/core/java/com/android/server/wm/Dimmer.java +5 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.server.wm.AlphaAnimationSpecProto.FROM; import static com.android.server.wm.AlphaAnimationSpecProto.TO; import static com.android.server.wm.AnimationSpecProto.ALPHA; import android.annotation.Nullable; import android.graphics.Rect; import android.util.Log; import android.util.proto.ProtoOutputStream; Loading Loading @@ -156,7 +157,8 @@ class Dimmer { @VisibleForTesting interface SurfaceAnimatorStarter { void startAnimation(SurfaceAnimator surfaceAnimator, SurfaceControl.Transaction t, AnimationAdapter anim, boolean hidden); AnimationAdapter anim, boolean hidden, @Nullable Runnable animationFinishedCallback); } Dimmer(WindowContainer host) { Loading Loading @@ -342,7 +344,8 @@ class Dimmer { SurfaceControl.Transaction t, float startAlpha, float endAlpha) { mSurfaceAnimatorStarter.startAnimation(animator, t, new LocalAnimationAdapter( new AlphaAnimationSpec(startAlpha, endAlpha, getDimDuration(container)), mHost.mWmService.mSurfaceAnimationRunner), false /* hidden */); mHost.mWmService.mSurfaceAnimationRunner), false /* hidden */, null /* animationFinishedCallback */); } private long getDimDuration(WindowContainer container) { Loading
services/core/java/com/android/server/wm/SurfaceAnimator.java +26 −5 Original line number Diff line number Diff line Loading @@ -55,7 +55,9 @@ class SurfaceAnimator { private final OnAnimationFinishedCallback mInnerAnimationFinishedCallback; @VisibleForTesting @Nullable final Runnable mAnimationFinishedCallback; final Runnable mStaticAnimationFinishedCallback; @Nullable private Runnable mAnimationFinishedCallback; private boolean mAnimationStartDelayed; /** Loading @@ -66,7 +68,7 @@ class SurfaceAnimator { WindowManagerService service) { mAnimatable = animatable; mService = service; mAnimationFinishedCallback = animationFinishedCallback; mStaticAnimationFinishedCallback = animationFinishedCallback; mInnerAnimationFinishedCallback = getFinishedCallback(animationFinishedCallback); } Loading @@ -89,10 +91,14 @@ class SurfaceAnimator { if (anim != mAnimation) { return; } final Runnable animationFinishCallback = mAnimationFinishedCallback; reset(mAnimatable.getPendingTransaction(), true /* destroyLeash */); if (animationFinishedCallback != null) { animationFinishedCallback.run(); } if (animationFinishCallback != null) { animationFinishCallback.run(); } }; if (!mAnimatable.shouldDeferAnimationFinish(resetAndInvokeFinish)) { resetAndInvokeFinish.run(); Loading @@ -111,10 +117,13 @@ class SurfaceAnimator { * @param hidden Whether the container holding the child surfaces is currently visible or not. * This is important as it will start with the leash hidden or visible before * handing it to the component that is responsible to run the animation. * @param animationFinishedCallback The callback being triggered when the animation finishes. */ void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden) { void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden, @Nullable Runnable animationFinishedCallback) { cancelAnimation(t, true /* restarting */, true /* forwardCancel */); mAnimation = anim; mAnimationFinishedCallback = animationFinishedCallback; final SurfaceControl surface = mAnimatable.getSurfaceControl(); if (surface == null) { Slog.w(TAG, "Unable to start animation, surface is null or no children."); Loading @@ -131,6 +140,10 @@ class SurfaceAnimator { mAnimation.startAnimation(mLeash, t, mInnerAnimationFinishedCallback); } void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden) { startAnimation(t, anim, hidden, null /* animationFinishedCallback */); } /** * Begins with delaying all animations to start. Any subsequent call to {@link #startAnimation} * will not start the animation until {@link #endDelayingAnimationStart} is called. When an Loading Loading @@ -232,6 +245,7 @@ class SurfaceAnimator { cancelAnimation(t, true /* restarting */, true /* forwardCancel */); mLeash = from.mLeash; mAnimation = from.mAnimation; mAnimationFinishedCallback = from.mAnimationFinishedCallback; // Cancel source animation, but don't let animation runner cancel the animation. from.cancelAnimation(t, false /* restarting */, false /* forwardCancel */); Loading @@ -258,13 +272,19 @@ class SurfaceAnimator { if (DEBUG_ANIM) Slog.i(TAG, "Cancelling animation restarting=" + restarting); final SurfaceControl leash = mLeash; final AnimationAdapter animation = mAnimation; final Runnable animationFinishedCallback = mAnimationFinishedCallback; reset(t, false); if (animation != null) { if (!mAnimationStartDelayed && forwardCancel) { animation.onAnimationCancelled(leash); } if (!restarting && mAnimationFinishedCallback != null) { mAnimationFinishedCallback.run(); if (!restarting) { if (mStaticAnimationFinishedCallback != null) { mStaticAnimationFinishedCallback.run(); } if (animationFinishedCallback != null) { animationFinishedCallback.run(); } } } Loading Loading @@ -304,6 +324,7 @@ class SurfaceAnimator { } mLeash = null; mAnimation = null; mAnimationFinishedCallback = null; if (reparent) { // Make sure to inform the animatable after the surface was reparented (or reparent Loading