Continue to dismiss keyguard when the remote animation is cancelled.

The keyguard going away process is consists of several steps between the
system and KeyguardService.

1. KeyguardService notifies the system that the Keyguard is going away.
2. The system prepares for the app transition, and notifies the
   KeyguardService that the app transition is ready.
3. The KeyguardService run a remote animation.
4. When the animation finishes, the KeyguardService notifies back to the
   system.

During the step 3, it's possible that the server cancels the animation
due to, for example, another app transition needs to be started. In this
case, we don't go back to the keyguard but finishes dismiss process.

Bug: 166736690
Bug: 188824028
Test: pass launcher3 MemoryTests, TaplTestsLauncher3 on test servers.
Change-Id: I3e45ca52b0006f89837365fb3f51a4372cc68060
This commit is contained in:
Issei Suzuki
2021-06-10 12:16:14 +02:00
parent 52e22aab2b
commit b061c2bec9
2 changed files with 21 additions and 15 deletions

View File

@@ -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 */)
}
}

View File

@@ -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");