diff options
2 files changed, 25 insertions, 2 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt index 3d5498b61471..7a3089f33276 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt @@ -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, diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt index eaf8fa9585f6..354fc3d82342 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt @@ -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() |