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

Commit ecdc2bac authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix obvious logic error with forceFinishCurrentTransition." into main

parents e29e7271 6cbd2fd1
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()