summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-11-13 12:38:21 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-11-13 12:38:21 +0000
commitecdc2bacbfd59ecb95086d378802efadfd56ebfe (patch)
tree212e94c63a565c908a0356b7961577fdf521f723
parente29e72715feb3aa2fecfd150f0385153935d8b98 (diff)
parent6cbd2fd149d87e9bd0ff614cd06f52555303b765 (diff)
Merge "Fix obvious logic error with forceFinishCurrentTransition." into main
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepositoryTest.kt23
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardTransitionRepository.kt4
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()