Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94f3ec7a authored by Matt Pietal's avatar Matt Pietal
Browse files

Fix light reveal state

An attempt to fix jank for the light reveal disconnected the internal
state from the animation start. This lead to a race condition where
the state was set to true, and expected to be set back to false after
the animation completes but in special cases the animation was
canceled. Because of this stuck state, SysUI then entered a loop where
no touches were being registered because it believed a screen off
animation in progress.

Also fix another potential race condition with the
aodUiAnimationPlaying.

Fixes: 297306022
Test: atest UnlockedScreenOffAnimationControllerTest
Test: From launcher, get phone call, hit power off
Change-Id: I754c687039b3c20fbeb1bd424d5b5b5ed0414e2f
parent e3441274
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ class UnlockedScreenOffAnimationController @Inject constructor(

    // FrameCallback used to delay starting the light reveal animation until the next frame
    private val startLightRevealCallback = TraceUtils.namedRunnable("startLightReveal") {
        lightRevealAnimationPlaying = true
        lightRevealAnimator.start()
    }

@@ -268,7 +269,6 @@ class UnlockedScreenOffAnimationController @Inject constructor(
            decidedToAnimateGoingToSleep = true

            shouldAnimateInKeyguard = true
            lightRevealAnimationPlaying = true

            // Start the animation on the next frame. startAnimation() is called after
            // PhoneWindowManager makes a binder call to System UI on
@@ -283,7 +283,8 @@ class UnlockedScreenOffAnimationController @Inject constructor(
                // dispatched, a race condition could make it possible for this callback to be run
                // as the device is waking up. That results in the AOD UI being shown while we wake
                // up, with unpredictable consequences.
                if (!powerManager.isInteractive(Display.DEFAULT_DISPLAY)) {
                if (!powerManager.isInteractive(Display.DEFAULT_DISPLAY) &&
                        shouldAnimateInKeyguard) {
                    aodUiAnimationPlaying = true

                    // Show AOD. That'll cause the KeyguardVisibilityHelper to call
+16 −0
Original line number Diff line number Diff line
@@ -134,6 +134,22 @@ class UnlockedScreenOffAnimationControllerTest : SysuiTestCase() {
        verify(shadeViewController, times(1)).showAodUi()
    }

    @Test
    fun testAodUiShowNotInvokedIfWakingUp() {
        `when`(dozeParameters.canControlUnlockedScreenOff()).thenReturn(true)
        `when`(powerManager.isInteractive).thenReturn(false)

        val callbackCaptor = ArgumentCaptor.forClass(Runnable::class.java)
        controller.startAnimation()
        controller.onStartedWakingUp()

        verify(handler).postDelayed(callbackCaptor.capture(), anyLong())

        callbackCaptor.value.run()

        verify(shadeViewController, never()).showAodUi()
    }

    /**
     * The AOD UI is shown during the screen off animation, after a delay to allow the light reveal
     * animation to start. If the device is woken up during the screen off, we should *never* do