fadeInSurfaceBehind() when the remote animation starts.

This should never have been done earlier, it worked
thanks to null-checks in the animator. This change
consolidates all of the surface-behind animation
logic into notifyStartSurfaceBehindRemoteAnimation
where it logically belongs.

Bug: 229890190
Test: atest SystemUITests
Change-Id: Iee97d46929d6de1ad3f9e0373be584d48ced440c
This commit is contained in:
Josh Tsuji
2022-04-20 17:55:13 -04:00
parent 927a236a80
commit 19ba19d3be
2 changed files with 85 additions and 8 deletions

View File

@@ -259,7 +259,9 @@ class KeyguardUnlockAnimationController @Inject constructor(
* animation plays.
*/
private var surfaceBehindAlpha = 1f
private var surfaceBehindAlphaAnimator = ValueAnimator.ofFloat(0f, 1f)
@VisibleForTesting
var surfaceBehindAlphaAnimator = ValueAnimator.ofFloat(0f, 1f)
private var smartspaceAnimator = ValueAnimator.ofFloat(0f, 1f)
/**
@@ -422,12 +424,22 @@ class KeyguardUnlockAnimationController @Inject constructor(
surfaceBehindRemoteAnimationTarget = target
surfaceBehindRemoteAnimationStartTime = startTime
// If we specifically requested that the surface behind be made visible, it means we are
// swiping to unlock. In that case, the surface visibility is tied to the dismiss amount,
// and we'll handle that in onKeyguardDismissAmountChanged(). If we didn't request that, the
// keyguard is being dismissed for a different reason (biometric auth, etc.) and we should
// play a canned animation to make the surface fully visible.
if (!requestedShowSurfaceBehindKeyguard) {
// If we specifically requested that the surface behind be made visible (vs. it being made
// visible because we're unlocking), then we're in the middle of a swipe-to-unlock touch
// gesture and the surface behind the keyguard should be made visible.
if (requestedShowSurfaceBehindKeyguard) {
// Fade in the surface, as long as we're not now flinging. The touch gesture ending in
// a fling during the time it takes the keyguard exit animation to start is an edge
// case race condition, and we'll handle it by playing a canned animation on the
// now-visible surface to finish unlocking.
if (!keyguardStateController.isFlingingToDismissKeyguard) {
fadeInSurfaceBehind()
} else {
playCannedUnlockAnimation()
}
} else {
// The surface was made visible since we're unlocking not from a swipe (fingerprint,
// lock icon long-press, etc). Play the full unlock animation.
playCannedUnlockAnimation()
}
@@ -786,7 +798,6 @@ class KeyguardUnlockAnimationController @Inject constructor(
prepareLauncherWorkspaceForUnlockAnimation()
}
keyguardViewMediator.get().showSurfaceBehindKeyguard()
fadeInSurfaceBehind()
} else if (dismissAmount < DISMISS_AMOUNT_SHOW_SURFACE_THRESHOLD &&
keyguardViewMediator.get().requestedShowSurfaceBehindKeyguard()) {
// We're no longer past the threshold but we are showing the surface. Animate it

View File

@@ -17,6 +17,7 @@ import com.android.systemui.flags.FeatureFlags
import com.android.systemui.statusbar.phone.BiometricUnlockController
import com.android.systemui.statusbar.policy.KeyguardStateController
import junit.framework.Assert.assertEquals
import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertTrue
import org.junit.Before
import org.junit.Test
@@ -125,4 +126,69 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() {
verify(keyguardViewMediator, times(0)).onKeyguardExitRemoteAnimationFinished(
false /* cancelled */)
}
/**
* If we requested that the surface behind be made visible, and we're not flinging away the
* keyguard, it means that we're swiping to unlock and want the surface visible so it can follow
* the user's touch event as they swipe to unlock.
*
* In this case, we should verify that the surface was made visible via the alpha fade in
* animator, and verify that we did not start the canned animation to animate the surface in
* (since it's supposed to be following the touch events).
*/
@Test
fun fadeInSurfaceBehind_ifRequestedShowSurface_butNotFlinging() {
`when`(keyguardStateController.isFlingingToDismissKeyguard).thenReturn(false)
keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation(
remoteAnimationTarget,
0 /* startTime */,
true /* requestedShowSurfaceBehindKeyguard */
)
assertTrue(keyguardUnlockAnimationController.surfaceBehindAlphaAnimator.isRunning)
assertFalse(keyguardUnlockAnimationController.isPlayingCannedUnlockAnimation())
}
/**
* We requested the surface behind to be made visible, but we're now flinging to dismiss the
* keyguard. This means this was a swipe to dismiss gesture but the user flung the keyguard and
* lifted their finger while we were requesting the surface be made visible.
*
* In this case, we should verify that we are playing the canned unlock animation and not
* simply fading in the surface.
*/
@Test
fun playCannedUnlockAnimation_ifRequestedShowSurface_andFlinging() {
`when`(keyguardStateController.isFlingingToDismissKeyguard).thenReturn(true)
keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation(
remoteAnimationTarget,
0 /* startTime */,
true /* requestedShowSurfaceBehindKeyguard */
)
assertTrue(keyguardUnlockAnimationController.isPlayingCannedUnlockAnimation())
assertFalse(keyguardUnlockAnimationController.surfaceBehindAlphaAnimator.isRunning)
}
/**
* We never requested the surface behind to be made visible, which means no swiping to unlock
* ever happened and we're just playing the simple canned animation (happens via UDFPS unlock,
* long press on the lock icon, etc).
*
* In this case, we should verify that we are playing the canned unlock animation and not
* simply fading in the surface.
*/
@Test
fun playCannedUnlockAnimation_ifDidNotRequestShowSurface() {
keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation(
remoteAnimationTarget,
0 /* startTime */,
false /* requestedShowSurfaceBehindKeyguard */
)
assertTrue(keyguardUnlockAnimationController.isPlayingCannedUnlockAnimation())
assertFalse(keyguardUnlockAnimationController.surfaceBehindAlphaAnimator.isRunning)
}
}