diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt index 0ecd70eadee99..38d153e38ca96 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt @@ -162,7 +162,8 @@ class KeyguardUnlockAnimationController @Inject constructor( // If the surface alpha is 0f, it's no longer visible so we can safely be done with // the animation. if (surfaceBehindAlpha == 0f) { - keyguardViewMediator.get().finishSurfaceBehindRemoteAnimation() + keyguardViewMediator.get().finishSurfaceBehindRemoteAnimation( + false /* cancelled */) } } }) @@ -175,7 +176,8 @@ class KeyguardUnlockAnimationController @Inject constructor( } surfaceBehindEntryAnimator.addListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator) { - keyguardViewMediator.get().onKeyguardExitRemoteAnimationFinished() + keyguardViewMediator.get().onKeyguardExitRemoteAnimationFinished( + false /* cancelled */) } }) @@ -370,7 +372,7 @@ class KeyguardUnlockAnimationController @Inject constructor( } else if (keyguardViewMediator.get() .isAnimatingBetweenKeyguardAndSurfaceBehindOrWillBe && reachedHideKeyguardThreshold) { - keyguardViewMediator.get().onKeyguardExitRemoteAnimationFinished() + keyguardViewMediator.get().onKeyguardExitRemoteAnimationFinished(false /* cancelled */) } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 257c82ae6af51..f0d7d833a9fbe 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -2315,15 +2315,15 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable, } /** - * Called if the keyguard exit animation has been cancelled and we should return to the + * Called if the keyguard exit animation has been cancelled and we should dismiss to the * keyguard. * - * This can happen due to the system cancelling the RemoteAnimation (due to a timeout), or the - * user cancelling the unlock swipe gesture. + * This can happen due to the system cancelling the RemoteAnimation (due to a timeout, a new + * app transition before finishing the current RemoteAnimation). */ private void handleCancelKeyguardExitAnimation() { - hideSurfaceBehindKeyguard(); - mKeyguardUnlockAnimationControllerLazy.get().notifyCancelKeyguardExitAnimation(); + showSurfaceBehindKeyguard(); + onKeyguardExitRemoteAnimationFinished(true /* cancelled */); } /** @@ -2332,8 +2332,10 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable, * This will call {@link #mSurfaceBehindRemoteAnimationFinishedCallback} to let WM know that * we're done with the RemoteAnimation, actually hide the keyguard, and clean up state related * to the keyguard exit animation. + * + * @param cancelled {@code true} if the animation was cancelled before it finishes. */ - public void onKeyguardExitRemoteAnimationFinished() { + public void onKeyguardExitRemoteAnimationFinished(boolean cancelled) { if (!mSurfaceBehindRemoteAnimationRunning && !mSurfaceBehindRemoteAnimationRequested) { return; } @@ -2347,7 +2349,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable, mKeyguardUnlockAnimationControllerLazy.get().hideKeyguardViewAfterRemoteAnimation(); } - finishSurfaceBehindRemoteAnimation(); + finishSurfaceBehindRemoteAnimation(cancelled); mSurfaceBehindRemoteAnimationRequested = false; mKeyguardUnlockAnimationControllerLazy.get().notifyFinishedKeyguardExitAnimation(); InteractionJankMonitor.getInstance().end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION); @@ -2389,12 +2391,14 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable, } /** If it's running, finishes the RemoteAnimation on the surface behind the keyguard. */ - public void finishSurfaceBehindRemoteAnimation() { + public void finishSurfaceBehindRemoteAnimation(boolean cancelled) { mSurfaceBehindRemoteAnimationRunning = false; if (mSurfaceBehindRemoteAnimationFinishedCallback != null) { try { - mSurfaceBehindRemoteAnimationFinishedCallback.onAnimationFinished(); + if (!cancelled) { + mSurfaceBehindRemoteAnimationFinishedCallback.onAnimationFinished(); + } mSurfaceBehindRemoteAnimationFinishedCallback = null; } catch (RemoteException e) { e.printStackTrace(); @@ -2638,10 +2642,10 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable, } /** - * Cancel the keyguard exit animation, usually because we were swiping to unlock and the swipe - * gesture was cancelled. + * Cancel the keyguard exit animation, usually because we were swiping to unlock but WM starts + * a new remote animation before finishing the keyguard exit animation. * - * This will re-show the keyguard and animate out the app/launcher surface behind the keyguard. + * This will dismiss the keyguard. */ public void cancelKeyguardExitAnimation() { Trace.beginSection("KeyguardViewMediator#cancelKeyguardExitAnimation");