Transitions - Add GONE->LOCKSCREEN support
Primarily used when the device goes into immediate lockdown. Also, increase the timeout to see if it reduces flakiness. Fixes: 266192407 Test: atest KeyguardTransitionScenariosTest Change-Id: I1e99ab8fa081c23943f319982c5730644680bd9c
This commit is contained in:
@@ -45,6 +45,27 @@ constructor(
|
||||
override fun start() {
|
||||
listenForGoneToAodOrDozing()
|
||||
listenForGoneToDreaming()
|
||||
listenForGoneToLockscreen()
|
||||
}
|
||||
|
||||
// Primarily for when the user chooses to lock down the device
|
||||
private fun listenForGoneToLockscreen() {
|
||||
scope.launch {
|
||||
keyguardInteractor.isKeyguardShowing
|
||||
.sample(keyguardTransitionInteractor.startedKeyguardTransitionStep, ::Pair)
|
||||
.collect { (isKeyguardShowing, lastStartedStep) ->
|
||||
if (isKeyguardShowing && lastStartedStep.to == KeyguardState.GONE) {
|
||||
keyguardTransitionRepository.startTransition(
|
||||
TransitionInfo(
|
||||
name,
|
||||
KeyguardState.GONE,
|
||||
KeyguardState.LOCKSCREEN,
|
||||
getAnimator(),
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun listenForGoneToDreaming() {
|
||||
|
||||
@@ -518,6 +518,43 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() {
|
||||
coroutineContext.cancelChildren()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GONE to LOCKSREEN`() =
|
||||
testScope.runTest {
|
||||
// GIVEN a prior transition has run to GONE
|
||||
runner.startTransition(
|
||||
testScope,
|
||||
TransitionInfo(
|
||||
ownerName = "",
|
||||
from = KeyguardState.LOCKSCREEN,
|
||||
to = KeyguardState.GONE,
|
||||
animator =
|
||||
ValueAnimator().apply {
|
||||
duration = 10
|
||||
interpolator = Interpolators.LINEAR
|
||||
},
|
||||
)
|
||||
)
|
||||
runCurrent()
|
||||
reset(mockTransitionRepository)
|
||||
|
||||
// WHEN the keyguard starts to show
|
||||
keyguardRepository.setKeyguardShowing(true)
|
||||
runCurrent()
|
||||
|
||||
val info =
|
||||
withArgCaptor<TransitionInfo> {
|
||||
verify(mockTransitionRepository).startTransition(capture())
|
||||
}
|
||||
// THEN a transition to AOD should occur
|
||||
assertThat(info.ownerName).isEqualTo("FromGoneTransitionInteractor")
|
||||
assertThat(info.from).isEqualTo(KeyguardState.GONE)
|
||||
assertThat(info.to).isEqualTo(KeyguardState.LOCKSCREEN)
|
||||
assertThat(info.animator).isNotNull()
|
||||
|
||||
coroutineContext.cancelChildren()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GONE to DREAMING`() =
|
||||
testScope.runTest {
|
||||
|
||||
@@ -71,7 +71,7 @@ class KeyguardTransitionRunner(
|
||||
waitUntilComplete(info.animator!!)
|
||||
}
|
||||
|
||||
suspend private fun waitUntilComplete(animator: ValueAnimator) {
|
||||
private suspend fun waitUntilComplete(animator: ValueAnimator) {
|
||||
withContext(Dispatchers.Main) {
|
||||
val startTime = System.currentTimeMillis()
|
||||
while (!isTerminated && animator.isRunning()) {
|
||||
@@ -96,6 +96,6 @@ class KeyguardTransitionRunner(
|
||||
override fun setFrameDelay(delay: Long) {}
|
||||
|
||||
companion object {
|
||||
private const val MAX_TEST_DURATION = 100L
|
||||
private const val MAX_TEST_DURATION = 200L
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user