Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +23 −15 Original line number Diff line number Diff line Loading @@ -175,8 +175,7 @@ class UnlockedScreenOffAnimationController @Inject constructor( .setDuration(duration.toLong()) .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) .alpha(1f) .setListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator?) { .withEndAction { aodUiAnimationPlaying = false // Lock the keyguard if it was waiting for the screen off animation to end. Loading @@ -191,12 +190,21 @@ class UnlockedScreenOffAnimationController @Inject constructor( // Done going to sleep, reset this flag. decidedToAnimateGoingToSleep = null // We need to unset the listener. These are persistent for future animators keyguardView.animate().setListener(null) interactionJankMonitor.end(CUJ_SCREEN_OFF_SHOW_AOD) } .setListener(object : AnimatorListenerAdapter() { override fun onAnimationCancel(animation: Animator?) { // If we're cancelled, reset state flags/listeners. The end action above // will not be called, which is what we want since that will finish the // screen off animation and show the lockscreen, which we don't want if we // were cancelled. aodUiAnimationPlaying = false decidedToAnimateGoingToSleep = null keyguardView.animate().setListener(null) interactionJankMonitor.cancel(CUJ_SCREEN_OFF_SHOW_AOD) } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt +9 −2 Original line number Diff line number Diff line Loading @@ -117,11 +117,18 @@ class UnlockedScreenOffAnimationControllerTest : SysuiTestCase() { val keyguardSpy = spy(keyguardView) Mockito.`when`(keyguardSpy.animate()).thenReturn(animator) val listener = ArgumentCaptor.forClass(Animator.AnimatorListener::class.java) val endAction = ArgumentCaptor.forClass(Runnable::class.java) controller.animateInKeyguard(keyguardSpy, Runnable {}) Mockito.verify(animator).setListener(listener.capture()) // Verify that the listener is cleared when it ends listener.value.onAnimationEnd(null) Mockito.verify(animator).withEndAction(endAction.capture()) // Verify that the listener is cleared if we cancel it. listener.value.onAnimationCancel(null) Mockito.verify(animator).setListener(null) // Verify that the listener is also cleared if the end action is triggered. endAction.value.run() verify(animator, times(2)).setListener(null) } /** Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +23 −15 Original line number Diff line number Diff line Loading @@ -175,8 +175,7 @@ class UnlockedScreenOffAnimationController @Inject constructor( .setDuration(duration.toLong()) .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) .alpha(1f) .setListener(object : AnimatorListenerAdapter() { override fun onAnimationEnd(animation: Animator?) { .withEndAction { aodUiAnimationPlaying = false // Lock the keyguard if it was waiting for the screen off animation to end. Loading @@ -191,12 +190,21 @@ class UnlockedScreenOffAnimationController @Inject constructor( // Done going to sleep, reset this flag. decidedToAnimateGoingToSleep = null // We need to unset the listener. These are persistent for future animators keyguardView.animate().setListener(null) interactionJankMonitor.end(CUJ_SCREEN_OFF_SHOW_AOD) } .setListener(object : AnimatorListenerAdapter() { override fun onAnimationCancel(animation: Animator?) { // If we're cancelled, reset state flags/listeners. The end action above // will not be called, which is what we want since that will finish the // screen off animation and show the lockscreen, which we don't want if we // were cancelled. aodUiAnimationPlaying = false decidedToAnimateGoingToSleep = null keyguardView.animate().setListener(null) interactionJankMonitor.cancel(CUJ_SCREEN_OFF_SHOW_AOD) } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationControllerTest.kt +9 −2 Original line number Diff line number Diff line Loading @@ -117,11 +117,18 @@ class UnlockedScreenOffAnimationControllerTest : SysuiTestCase() { val keyguardSpy = spy(keyguardView) Mockito.`when`(keyguardSpy.animate()).thenReturn(animator) val listener = ArgumentCaptor.forClass(Animator.AnimatorListener::class.java) val endAction = ArgumentCaptor.forClass(Runnable::class.java) controller.animateInKeyguard(keyguardSpy, Runnable {}) Mockito.verify(animator).setListener(listener.capture()) // Verify that the listener is cleared when it ends listener.value.onAnimationEnd(null) Mockito.verify(animator).withEndAction(endAction.capture()) // Verify that the listener is cleared if we cancel it. listener.value.onAnimationCancel(null) Mockito.verify(animator).setListener(null) // Verify that the listener is also cleared if the end action is triggered. endAction.value.run() verify(animator, times(2)).setListener(null) } /** Loading