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

Commit 6cbd2fd1 authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Fix obvious logic error with forceFinishCurrentTransition.

(and add a test that will time out and cause an error if this is regressed in the future)

Test: atest KeyguardTransitionRepositoryTest
Bug: 378566698
Flag: com.android.systemui.keyguard_transition_force_finish_on_screen_off
Change-Id: Iab55a6b818e84189f2f189dcd7bffdee49393cca
parent 1168ab8c
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -527,6 +527,29 @@ class KeyguardTransitionRepositoryTest : SysuiTestCase() {
            assertEquals(0, steps.size)
        }

    @Test
    fun testForceFinishCurrentTransition_noTransitionRunning_unlocksMutex() =
        testScope.runTest {
            val steps by collectValues(underTest.transitions.dropWhile { step -> step.from == OFF })
            underTest.forceFinishCurrentTransition()

            assertThat(steps.isEmpty())

            underTest.forceFinishCurrentTransition()
            runCurrent()

            assertThat(steps.isEmpty())
            runner.startTransition(
                this,
                TransitionInfo(OWNER_NAME, AOD, LOCKSCREEN, getAnimator()),
                maxFrames = 100,
            )

            advanceTimeBy(5000L)

            assertThat(steps.isNotEmpty())
        }

    private fun listWithStep(
        step: BigDecimal,
        start: BigDecimal = BigDecimal.ZERO,
+2 −2
Original line number Diff line number Diff line
@@ -305,12 +305,12 @@ constructor(@Main val mainDispatcher: CoroutineDispatcher) : KeyguardTransitionR
    }

    override suspend fun forceFinishCurrentTransition() {
        withContextMutex.lock()

        if (lastAnimator?.isRunning != true) {
            return
        }

        withContextMutex.lock()

        return withContext("$TAG#forceFinishCurrentTransition", mainDispatcher) {
            withContextMutex.unlock()