Loading packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt +56 −65 Original line number Diff line number Diff line Loading @@ -241,9 +241,8 @@ class KeyguardUnlockAnimationController @Inject constructor( */ @VisibleForTesting var surfaceTransactionApplier: SyncRtSurfaceTransactionApplier? = null private var surfaceBehindRemoteAnimationTarget: RemoteAnimationTarget? = null private var surfaceBehindRemoteAnimationTargets: Array<RemoteAnimationTarget>? = null private var surfaceBehindRemoteAnimationStartTime: Long = 0 private var surfaceBehindParams: SyncRtSurfaceTransactionApplier.SurfaceParams? = null /** * Alpha value applied to [surfaceBehindRemoteAnimationTarget], which is the surface of the Loading Loading @@ -458,7 +457,7 @@ class KeyguardUnlockAnimationController @Inject constructor( * (fingerprint, tap, etc.) and the keyguard is going away. */ fun notifyStartSurfaceBehindRemoteAnimation( target: RemoteAnimationTarget, targets: Array<RemoteAnimationTarget>, startTime: Long, requestedShowSurfaceBehindKeyguard: Boolean ) { Loading @@ -467,10 +466,7 @@ class KeyguardUnlockAnimationController @Inject constructor( keyguardViewController.viewRootImpl.view) } // New animation, new params. surfaceBehindParams = null surfaceBehindRemoteAnimationTarget = target surfaceBehindRemoteAnimationTargets = targets surfaceBehindRemoteAnimationStartTime = startTime // If we specifically requested that the surface behind be made visible (vs. it being made Loading Loading @@ -597,7 +593,7 @@ class KeyguardUnlockAnimationController @Inject constructor( * keyguard dismiss amount and the method of dismissal. */ private fun updateSurfaceBehindAppearAmount() { if (surfaceBehindRemoteAnimationTarget == null) { if (surfaceBehindRemoteAnimationTargets == null) { return } Loading Loading @@ -715,46 +711,42 @@ class KeyguardUnlockAnimationController @Inject constructor( * cancelled). */ fun setSurfaceBehindAppearAmount(amount: Float) { if (surfaceBehindRemoteAnimationTarget == null) { return } // Otherwise, animate in the surface's scale/transltion. val surfaceHeight: Int = surfaceBehindRemoteAnimationTarget!!.screenSpaceBounds.height() surfaceBehindRemoteAnimationTargets?.forEach { surfaceBehindRemoteAnimationTarget -> val surfaceHeight: Int = surfaceBehindRemoteAnimationTarget.screenSpaceBounds.height() var scaleFactor = (SURFACE_BEHIND_START_SCALE_FACTOR + (1f - SURFACE_BEHIND_START_SCALE_FACTOR) * MathUtils.clamp(amount, 0f, 1f)) // If we're dismissing via swipe to the Launcher, we'll play in-window scale animations, so // don't also scale the window. // If we're dismissing via swipe to the Launcher, we'll play in-window scale animations, // so don't also scale the window. if (keyguardStateController.isDismissingFromSwipe && willUnlockWithInWindowLauncherAnimations) { scaleFactor = 1f } // Translate up from the bottom. surfaceBehindMatrix.setTranslate( surfaceBehindRemoteAnimationTarget.screenSpaceBounds.left.toFloat(), surfaceHeight * SURFACE_BEHIND_START_TRANSLATION_Y * (1f - amount) ) // Scale up from a point at the center-bottom of the surface. surfaceBehindMatrix.setScale( surfaceBehindMatrix.postScale( scaleFactor, scaleFactor, surfaceBehindRemoteAnimationTarget!!.screenSpaceBounds.width() / 2f, keyguardViewController.viewRootImpl.width / 2f, surfaceHeight * SURFACE_BEHIND_SCALE_PIVOT_Y ) // Translate up from the bottom. surfaceBehindMatrix.postTranslate( 0f, surfaceHeight * SURFACE_BEHIND_START_TRANSLATION_Y * (1f - amount) ) // If we're snapping the keyguard back, immediately begin fading it out. val animationAlpha = if (keyguardStateController.isSnappingKeyguardBackAfterSwipe) amount else surfaceBehindAlpha // SyncRtSurfaceTransactionApplier cannot apply transaction when the target view is unable // to draw val sc: SurfaceControl? = surfaceBehindRemoteAnimationTarget?.leash // SyncRtSurfaceTransactionApplier cannot apply transaction when the target view is // unable to draw val sc: SurfaceControl? = surfaceBehindRemoteAnimationTarget.leash if (keyguardViewController.viewRootImpl.view?.visibility != View.VISIBLE && sc?.isValid == true) { with(SurfaceControl.Transaction()) { Loading @@ -766,7 +758,7 @@ class KeyguardUnlockAnimationController @Inject constructor( } else { applyParamsToSurface( SyncRtSurfaceTransactionApplier.SurfaceParams.Builder( surfaceBehindRemoteAnimationTarget!!.leash) surfaceBehindRemoteAnimationTarget.leash) .withMatrix(surfaceBehindMatrix) .withCornerRadius(roundedCornerRadius) .withAlpha(animationAlpha) Loading @@ -774,6 +766,7 @@ class KeyguardUnlockAnimationController @Inject constructor( ) } } } /** * Called by [KeyguardViewMediator] to let us know that the remote animation has finished, and Loading @@ -796,8 +789,7 @@ class KeyguardUnlockAnimationController @Inject constructor( launcherUnlockController?.setUnlockAmount(1f, false /* forceIfAnimating */) // That target is no longer valid since the animation finished, null it out. surfaceBehindRemoteAnimationTarget = null surfaceBehindParams = null surfaceBehindRemoteAnimationTargets = null playingCannedUnlockAnimation = false willUnlockWithInWindowLauncherAnimations = false Loading Loading @@ -829,7 +821,6 @@ class KeyguardUnlockAnimationController @Inject constructor( private fun applyParamsToSurface(params: SyncRtSurfaceTransactionApplier.SurfaceParams) { surfaceTransactionApplier!!.scheduleApply(params) surfaceBehindParams = params } private fun fadeInSurfaceBehind() { Loading packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +1 −9 Original line number Diff line number Diff line Loading @@ -2587,18 +2587,10 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, mInteractionJankMonitor.begin( createInteractionJankMonitorConf("DismissPanel")); // Apply the opening animation on root task if exists RemoteAnimationTarget aniTarget = apps[0]; for (RemoteAnimationTarget tmpTarget : apps) { if (tmpTarget.taskId != -1 && !tmpTarget.hasAnimatingParent) { aniTarget = tmpTarget; break; } } // Pass the surface and metadata to the unlock animation controller. mKeyguardUnlockAnimationControllerLazy.get() .notifyStartSurfaceBehindRemoteAnimation( aniTarget, startTime, mSurfaceBehindRemoteAnimationRequested); apps, startTime, mSurfaceBehindRemoteAnimationRequested); } else { mInteractionJankMonitor.begin( createInteractionJankMonitorConf("RemoteAnimationDisabled")); Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt +56 −13 Original line number Diff line number Diff line Loading @@ -27,11 +27,11 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor.forClass import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.Mockito.mock import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.Mockito.verifyNoMoreInteractions import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @RunWith(AndroidTestingRunner::class) Loading Loading @@ -60,7 +60,18 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { @Mock private lateinit var launcherUnlockAnimationController: ILauncherUnlockAnimationController.Stub private lateinit var remoteAnimationTarget: RemoteAnimationTarget private var surfaceControl1 = mock(SurfaceControl::class.java) private var remoteTarget1 = RemoteAnimationTarget( 0 /* taskId */, 0, surfaceControl1, false, Rect(), Rect(), 0, Point(), Rect(), Rect(), mock(WindowConfiguration::class.java), false, surfaceControl1, Rect(), mock(ActivityManager.RunningTaskInfo::class.java), false) private var surfaceControl2 = mock(SurfaceControl::class.java) private var remoteTarget2 = RemoteAnimationTarget( 1 /* taskId */, 0, surfaceControl2, false, Rect(), Rect(), 0, Point(), Rect(), Rect(), mock(WindowConfiguration::class.java), false, surfaceControl2, Rect(), mock(ActivityManager.RunningTaskInfo::class.java), false) private lateinit var remoteAnimationTargets: Array<RemoteAnimationTarget> @Before fun setUp() { Loading @@ -77,10 +88,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { // All of these fields are final, so we can't mock them, but are needed so that the surface // appear amount setter doesn't short circuit. remoteAnimationTarget = RemoteAnimationTarget( 0, 0, null, false, Rect(), Rect(), 0, Point(), Rect(), Rect(), mock(WindowConfiguration::class.java), false, mock(SurfaceControl::class.java), Rect(), mock(ActivityManager.RunningTaskInfo::class.java), false) remoteAnimationTargets = arrayOf(remoteTarget1) // Set the surface applier to our mock so that we can verify the arguments passed to it. // This applier does not have any side effects within the unlock animation controller, so Loading @@ -99,7 +107,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { `when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true) keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, false /* requestedShowSurfaceBehindKeyguard */ ) Loading Loading @@ -130,7 +138,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { `when`(biometricUnlockController.isWakeAndUnlock).thenReturn(false) keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, false /* requestedShowSurfaceBehindKeyguard */ ) Loading @@ -154,7 +162,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { `when`(keyguardStateController.isFlingingToDismissKeyguard).thenReturn(false) keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, true /* requestedShowSurfaceBehindKeyguard */ ) Loading @@ -176,7 +184,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { `when`(keyguardStateController.isFlingingToDismissKeyguard).thenReturn(true) keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, true /* requestedShowSurfaceBehindKeyguard */ ) Loading @@ -196,7 +204,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { @Test fun playCannedUnlockAnimation_ifDidNotRequestShowSurface() { keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, false /* requestedShowSurfaceBehindKeyguard */ ) Loading @@ -210,7 +218,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { `when`(notificationShadeWindowController.isLaunchingActivity).thenReturn(true) keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, true /* requestedShowSurfaceBehindKeyguard */ ) Loading @@ -225,11 +233,46 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { keyguardUnlockAnimationController.willUnlockWithInWindowLauncherAnimations = true keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, false /* requestedShowSurfaceBehindKeyguard */ ) assertTrue(keyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) } /** * If we are not wake and unlocking, we expect the unlock animation to play normally. */ @Test fun surfaceAnimation_multipleTargets() { keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( arrayOf(remoteTarget1, remoteTarget2), 0 /* startTime */, false /* requestedShowSurfaceBehindKeyguard */ ) // Set appear to 50%, we'll just verify that we're not applying the identity matrix which // means an animation is in progress. keyguardUnlockAnimationController.setSurfaceBehindAppearAmount(0.5f) val captor = forClass(SyncRtSurfaceTransactionApplier.SurfaceParams::class.java) verify(surfaceTransactionApplier, times(2)).scheduleApply(captor.capture()) val allParams = captor.allValues val remainingTargets = mutableListOf(surfaceControl1, surfaceControl2) allParams.forEach { params -> assertTrue(!params.matrix.isIdentity) remainingTargets.remove(params.surface) } // Make sure we called applyParams with each of the surface controls once. The order does // not matter, so don't explicitly check for that. assertTrue(remainingTargets.isEmpty()) // Since the animation is running, we should not have finished the remote animation. verify(keyguardViewMediator, times(0)).onKeyguardExitRemoteAnimationFinished( false /* cancelled */) } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt +56 −65 Original line number Diff line number Diff line Loading @@ -241,9 +241,8 @@ class KeyguardUnlockAnimationController @Inject constructor( */ @VisibleForTesting var surfaceTransactionApplier: SyncRtSurfaceTransactionApplier? = null private var surfaceBehindRemoteAnimationTarget: RemoteAnimationTarget? = null private var surfaceBehindRemoteAnimationTargets: Array<RemoteAnimationTarget>? = null private var surfaceBehindRemoteAnimationStartTime: Long = 0 private var surfaceBehindParams: SyncRtSurfaceTransactionApplier.SurfaceParams? = null /** * Alpha value applied to [surfaceBehindRemoteAnimationTarget], which is the surface of the Loading Loading @@ -458,7 +457,7 @@ class KeyguardUnlockAnimationController @Inject constructor( * (fingerprint, tap, etc.) and the keyguard is going away. */ fun notifyStartSurfaceBehindRemoteAnimation( target: RemoteAnimationTarget, targets: Array<RemoteAnimationTarget>, startTime: Long, requestedShowSurfaceBehindKeyguard: Boolean ) { Loading @@ -467,10 +466,7 @@ class KeyguardUnlockAnimationController @Inject constructor( keyguardViewController.viewRootImpl.view) } // New animation, new params. surfaceBehindParams = null surfaceBehindRemoteAnimationTarget = target surfaceBehindRemoteAnimationTargets = targets surfaceBehindRemoteAnimationStartTime = startTime // If we specifically requested that the surface behind be made visible (vs. it being made Loading Loading @@ -597,7 +593,7 @@ class KeyguardUnlockAnimationController @Inject constructor( * keyguard dismiss amount and the method of dismissal. */ private fun updateSurfaceBehindAppearAmount() { if (surfaceBehindRemoteAnimationTarget == null) { if (surfaceBehindRemoteAnimationTargets == null) { return } Loading Loading @@ -715,46 +711,42 @@ class KeyguardUnlockAnimationController @Inject constructor( * cancelled). */ fun setSurfaceBehindAppearAmount(amount: Float) { if (surfaceBehindRemoteAnimationTarget == null) { return } // Otherwise, animate in the surface's scale/transltion. val surfaceHeight: Int = surfaceBehindRemoteAnimationTarget!!.screenSpaceBounds.height() surfaceBehindRemoteAnimationTargets?.forEach { surfaceBehindRemoteAnimationTarget -> val surfaceHeight: Int = surfaceBehindRemoteAnimationTarget.screenSpaceBounds.height() var scaleFactor = (SURFACE_BEHIND_START_SCALE_FACTOR + (1f - SURFACE_BEHIND_START_SCALE_FACTOR) * MathUtils.clamp(amount, 0f, 1f)) // If we're dismissing via swipe to the Launcher, we'll play in-window scale animations, so // don't also scale the window. // If we're dismissing via swipe to the Launcher, we'll play in-window scale animations, // so don't also scale the window. if (keyguardStateController.isDismissingFromSwipe && willUnlockWithInWindowLauncherAnimations) { scaleFactor = 1f } // Translate up from the bottom. surfaceBehindMatrix.setTranslate( surfaceBehindRemoteAnimationTarget.screenSpaceBounds.left.toFloat(), surfaceHeight * SURFACE_BEHIND_START_TRANSLATION_Y * (1f - amount) ) // Scale up from a point at the center-bottom of the surface. surfaceBehindMatrix.setScale( surfaceBehindMatrix.postScale( scaleFactor, scaleFactor, surfaceBehindRemoteAnimationTarget!!.screenSpaceBounds.width() / 2f, keyguardViewController.viewRootImpl.width / 2f, surfaceHeight * SURFACE_BEHIND_SCALE_PIVOT_Y ) // Translate up from the bottom. surfaceBehindMatrix.postTranslate( 0f, surfaceHeight * SURFACE_BEHIND_START_TRANSLATION_Y * (1f - amount) ) // If we're snapping the keyguard back, immediately begin fading it out. val animationAlpha = if (keyguardStateController.isSnappingKeyguardBackAfterSwipe) amount else surfaceBehindAlpha // SyncRtSurfaceTransactionApplier cannot apply transaction when the target view is unable // to draw val sc: SurfaceControl? = surfaceBehindRemoteAnimationTarget?.leash // SyncRtSurfaceTransactionApplier cannot apply transaction when the target view is // unable to draw val sc: SurfaceControl? = surfaceBehindRemoteAnimationTarget.leash if (keyguardViewController.viewRootImpl.view?.visibility != View.VISIBLE && sc?.isValid == true) { with(SurfaceControl.Transaction()) { Loading @@ -766,7 +758,7 @@ class KeyguardUnlockAnimationController @Inject constructor( } else { applyParamsToSurface( SyncRtSurfaceTransactionApplier.SurfaceParams.Builder( surfaceBehindRemoteAnimationTarget!!.leash) surfaceBehindRemoteAnimationTarget.leash) .withMatrix(surfaceBehindMatrix) .withCornerRadius(roundedCornerRadius) .withAlpha(animationAlpha) Loading @@ -774,6 +766,7 @@ class KeyguardUnlockAnimationController @Inject constructor( ) } } } /** * Called by [KeyguardViewMediator] to let us know that the remote animation has finished, and Loading @@ -796,8 +789,7 @@ class KeyguardUnlockAnimationController @Inject constructor( launcherUnlockController?.setUnlockAmount(1f, false /* forceIfAnimating */) // That target is no longer valid since the animation finished, null it out. surfaceBehindRemoteAnimationTarget = null surfaceBehindParams = null surfaceBehindRemoteAnimationTargets = null playingCannedUnlockAnimation = false willUnlockWithInWindowLauncherAnimations = false Loading Loading @@ -829,7 +821,6 @@ class KeyguardUnlockAnimationController @Inject constructor( private fun applyParamsToSurface(params: SyncRtSurfaceTransactionApplier.SurfaceParams) { surfaceTransactionApplier!!.scheduleApply(params) surfaceBehindParams = params } private fun fadeInSurfaceBehind() { Loading
packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +1 −9 Original line number Diff line number Diff line Loading @@ -2587,18 +2587,10 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable, mInteractionJankMonitor.begin( createInteractionJankMonitorConf("DismissPanel")); // Apply the opening animation on root task if exists RemoteAnimationTarget aniTarget = apps[0]; for (RemoteAnimationTarget tmpTarget : apps) { if (tmpTarget.taskId != -1 && !tmpTarget.hasAnimatingParent) { aniTarget = tmpTarget; break; } } // Pass the surface and metadata to the unlock animation controller. mKeyguardUnlockAnimationControllerLazy.get() .notifyStartSurfaceBehindRemoteAnimation( aniTarget, startTime, mSurfaceBehindRemoteAnimationRequested); apps, startTime, mSurfaceBehindRemoteAnimationRequested); } else { mInteractionJankMonitor.begin( createInteractionJankMonitorConf("RemoteAnimationDisabled")); Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt +56 −13 Original line number Diff line number Diff line Loading @@ -27,11 +27,11 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor.forClass import org.mockito.Mock import org.mockito.Mockito.`when` import org.mockito.Mockito.mock import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.Mockito.verifyNoMoreInteractions import org.mockito.Mockito.`when` import org.mockito.MockitoAnnotations @RunWith(AndroidTestingRunner::class) Loading Loading @@ -60,7 +60,18 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { @Mock private lateinit var launcherUnlockAnimationController: ILauncherUnlockAnimationController.Stub private lateinit var remoteAnimationTarget: RemoteAnimationTarget private var surfaceControl1 = mock(SurfaceControl::class.java) private var remoteTarget1 = RemoteAnimationTarget( 0 /* taskId */, 0, surfaceControl1, false, Rect(), Rect(), 0, Point(), Rect(), Rect(), mock(WindowConfiguration::class.java), false, surfaceControl1, Rect(), mock(ActivityManager.RunningTaskInfo::class.java), false) private var surfaceControl2 = mock(SurfaceControl::class.java) private var remoteTarget2 = RemoteAnimationTarget( 1 /* taskId */, 0, surfaceControl2, false, Rect(), Rect(), 0, Point(), Rect(), Rect(), mock(WindowConfiguration::class.java), false, surfaceControl2, Rect(), mock(ActivityManager.RunningTaskInfo::class.java), false) private lateinit var remoteAnimationTargets: Array<RemoteAnimationTarget> @Before fun setUp() { Loading @@ -77,10 +88,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { // All of these fields are final, so we can't mock them, but are needed so that the surface // appear amount setter doesn't short circuit. remoteAnimationTarget = RemoteAnimationTarget( 0, 0, null, false, Rect(), Rect(), 0, Point(), Rect(), Rect(), mock(WindowConfiguration::class.java), false, mock(SurfaceControl::class.java), Rect(), mock(ActivityManager.RunningTaskInfo::class.java), false) remoteAnimationTargets = arrayOf(remoteTarget1) // Set the surface applier to our mock so that we can verify the arguments passed to it. // This applier does not have any side effects within the unlock animation controller, so Loading @@ -99,7 +107,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { `when`(biometricUnlockController.isWakeAndUnlock).thenReturn(true) keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, false /* requestedShowSurfaceBehindKeyguard */ ) Loading Loading @@ -130,7 +138,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { `when`(biometricUnlockController.isWakeAndUnlock).thenReturn(false) keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, false /* requestedShowSurfaceBehindKeyguard */ ) Loading @@ -154,7 +162,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { `when`(keyguardStateController.isFlingingToDismissKeyguard).thenReturn(false) keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, true /* requestedShowSurfaceBehindKeyguard */ ) Loading @@ -176,7 +184,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { `when`(keyguardStateController.isFlingingToDismissKeyguard).thenReturn(true) keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, true /* requestedShowSurfaceBehindKeyguard */ ) Loading @@ -196,7 +204,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { @Test fun playCannedUnlockAnimation_ifDidNotRequestShowSurface() { keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, false /* requestedShowSurfaceBehindKeyguard */ ) Loading @@ -210,7 +218,7 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { `when`(notificationShadeWindowController.isLaunchingActivity).thenReturn(true) keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, true /* requestedShowSurfaceBehindKeyguard */ ) Loading @@ -225,11 +233,46 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { keyguardUnlockAnimationController.willUnlockWithInWindowLauncherAnimations = true keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( remoteAnimationTarget, remoteAnimationTargets, 0 /* startTime */, false /* requestedShowSurfaceBehindKeyguard */ ) assertTrue(keyguardUnlockAnimationController.isPlayingCannedUnlockAnimation()) } /** * If we are not wake and unlocking, we expect the unlock animation to play normally. */ @Test fun surfaceAnimation_multipleTargets() { keyguardUnlockAnimationController.notifyStartSurfaceBehindRemoteAnimation( arrayOf(remoteTarget1, remoteTarget2), 0 /* startTime */, false /* requestedShowSurfaceBehindKeyguard */ ) // Set appear to 50%, we'll just verify that we're not applying the identity matrix which // means an animation is in progress. keyguardUnlockAnimationController.setSurfaceBehindAppearAmount(0.5f) val captor = forClass(SyncRtSurfaceTransactionApplier.SurfaceParams::class.java) verify(surfaceTransactionApplier, times(2)).scheduleApply(captor.capture()) val allParams = captor.allValues val remainingTargets = mutableListOf(surfaceControl1, surfaceControl2) allParams.forEach { params -> assertTrue(!params.matrix.isIdentity) remainingTargets.remove(params.surface) } // Make sure we called applyParams with each of the surface controls once. The order does // not matter, so don't explicitly check for that. assertTrue(remainingTargets.isEmpty()) // Since the animation is running, we should not have finished the remote animation. verify(keyguardViewMediator, times(0)).onKeyguardExitRemoteAnimationFinished( false /* cancelled */) } }