diff options
| author | 2024-11-13 12:38:21 +0000 | |
|---|---|---|
| committer | 2024-11-13 12:38:21 +0000 | |
| commit | ecdc2bacbfd59ecb95086d378802efadfd56ebfe (patch) | |
| tree | 212e94c63a565c908a0356b7961577fdf521f723 | |
| parent | e29e72715feb3aa2fecfd150f0385153935d8b98 (diff) | |
| parent | 6cbd2fd149d87e9bd0ff614cd06f52555303b765 (diff) | |
Merge "Fix obvious logic error with forceFinishCurrentTransition." into main
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() |