Merge "Support AOD => occluded and Dozing => occluded transitions" into udc-qpr-dev
This commit is contained in:
@@ -24,9 +24,11 @@ import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepositor
|
||||
import com.android.systemui.keyguard.shared.model.BiometricUnlockModel.Companion.isWakeAndUnlock
|
||||
import com.android.systemui.keyguard.shared.model.DozeStateModel
|
||||
import com.android.systemui.keyguard.shared.model.KeyguardState
|
||||
import com.android.systemui.util.kotlin.Utils.Companion.toTriple
|
||||
import com.android.systemui.util.kotlin.sample
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@SysUISingleton
|
||||
@@ -43,19 +45,27 @@ constructor(
|
||||
) {
|
||||
|
||||
override fun start() {
|
||||
listenForAodToLockscreen()
|
||||
listenForAodToLockscreenOrOccluded()
|
||||
listenForAodToGone()
|
||||
}
|
||||
|
||||
private fun listenForAodToLockscreen() {
|
||||
private fun listenForAodToLockscreenOrOccluded() {
|
||||
scope.launch {
|
||||
keyguardInteractor
|
||||
.dozeTransitionTo(DozeStateModel.FINISH)
|
||||
.sample(transitionInteractor.startedKeyguardTransitionStep, ::Pair)
|
||||
.collect { pair ->
|
||||
val (dozeToAod, lastStartedStep) = pair
|
||||
.sample(
|
||||
combine(
|
||||
transitionInteractor.startedKeyguardTransitionStep,
|
||||
keyguardInteractor.isKeyguardOccluded,
|
||||
::Pair
|
||||
),
|
||||
::toTriple
|
||||
)
|
||||
.collect { (_, lastStartedStep, occluded) ->
|
||||
if (lastStartedStep.to == KeyguardState.AOD) {
|
||||
startTransitionTo(KeyguardState.LOCKSCREEN)
|
||||
startTransitionTo(
|
||||
if (occluded) KeyguardState.OCCLUDED else KeyguardState.LOCKSCREEN
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,12 @@ import com.android.systemui.dagger.qualifiers.Application
|
||||
import com.android.systemui.keyguard.data.repository.KeyguardTransitionRepository
|
||||
import com.android.systemui.keyguard.shared.model.BiometricUnlockModel.Companion.isWakeAndUnlock
|
||||
import com.android.systemui.keyguard.shared.model.KeyguardState
|
||||
import com.android.systemui.util.kotlin.Utils.Companion.toTriple
|
||||
import com.android.systemui.util.kotlin.sample
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@SysUISingleton
|
||||
@@ -43,20 +45,29 @@ constructor(
|
||||
) {
|
||||
|
||||
override fun start() {
|
||||
listenForDozingToLockscreen()
|
||||
listenForDozingToLockscreenOrOccluded()
|
||||
listenForDozingToGone()
|
||||
}
|
||||
|
||||
private fun listenForDozingToLockscreen() {
|
||||
private fun listenForDozingToLockscreenOrOccluded() {
|
||||
scope.launch {
|
||||
keyguardInteractor.wakefulnessModel
|
||||
.sample(transitionInteractor.startedKeyguardTransitionStep, ::Pair)
|
||||
.collect { (wakefulnessModel, lastStartedTransition) ->
|
||||
.sample(
|
||||
combine(
|
||||
transitionInteractor.startedKeyguardTransitionStep,
|
||||
keyguardInteractor.isKeyguardOccluded,
|
||||
::Pair
|
||||
),
|
||||
::toTriple
|
||||
)
|
||||
.collect { (wakefulnessModel, lastStartedTransition, occluded) ->
|
||||
if (
|
||||
wakefulnessModel.isStartingToWakeOrAwake() &&
|
||||
lastStartedTransition.to == KeyguardState.DOZING
|
||||
) {
|
||||
startTransitionTo(KeyguardState.LOCKSCREEN)
|
||||
startTransitionTo(
|
||||
if (occluded) KeyguardState.OCCLUDED else KeyguardState.LOCKSCREEN
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1077,7 +1077,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() {
|
||||
withArgCaptor<TransitionInfo> {
|
||||
verify(transitionRepository).startTransition(capture(), anyBoolean())
|
||||
}
|
||||
// THEN a transition to AlternateBouncer should occur
|
||||
// THEN a transition to OCCLUDED should occur
|
||||
assertThat(info.ownerName).isEqualTo("FromPrimaryBouncerTransitionInteractor")
|
||||
assertThat(info.from).isEqualTo(KeyguardState.PRIMARY_BOUNCER)
|
||||
assertThat(info.to).isEqualTo(KeyguardState.OCCLUDED)
|
||||
@@ -1086,6 +1086,61 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() {
|
||||
coroutineContext.cancelChildren()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun dozingToOccluded() =
|
||||
testScope.runTest {
|
||||
// GIVEN a prior transition has run to DOZING
|
||||
runTransition(KeyguardState.LOCKSCREEN, KeyguardState.DOZING)
|
||||
runCurrent()
|
||||
|
||||
// WHEN the keyguard is occluded and device wakes up
|
||||
keyguardRepository.setKeyguardOccluded(true)
|
||||
keyguardRepository.setWakefulnessModel(startingToWake())
|
||||
runCurrent()
|
||||
|
||||
val info =
|
||||
withArgCaptor<TransitionInfo> {
|
||||
verify(transitionRepository).startTransition(capture(), anyBoolean())
|
||||
}
|
||||
// THEN a transition to OCCLUDED should occur
|
||||
assertThat(info.ownerName).isEqualTo("FromDozingTransitionInteractor")
|
||||
assertThat(info.from).isEqualTo(KeyguardState.DOZING)
|
||||
assertThat(info.to).isEqualTo(KeyguardState.OCCLUDED)
|
||||
assertThat(info.animator).isNotNull()
|
||||
|
||||
coroutineContext.cancelChildren()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aodToOccluded() =
|
||||
testScope.runTest {
|
||||
// GIVEN a prior transition has run to AOD
|
||||
runTransition(KeyguardState.LOCKSCREEN, KeyguardState.AOD)
|
||||
runCurrent()
|
||||
|
||||
// WHEN the keyguard is occluded and aod ends
|
||||
keyguardRepository.setKeyguardOccluded(true)
|
||||
keyguardRepository.setDozeTransitionModel(
|
||||
DozeTransitionModel(
|
||||
from = DozeStateModel.DOZE_AOD,
|
||||
to = DozeStateModel.FINISH,
|
||||
)
|
||||
)
|
||||
runCurrent()
|
||||
|
||||
val info =
|
||||
withArgCaptor<TransitionInfo> {
|
||||
verify(transitionRepository).startTransition(capture(), anyBoolean())
|
||||
}
|
||||
// THEN a transition to OCCLUDED should occur
|
||||
assertThat(info.ownerName).isEqualTo("FromAodTransitionInteractor")
|
||||
assertThat(info.from).isEqualTo(KeyguardState.AOD)
|
||||
assertThat(info.to).isEqualTo(KeyguardState.OCCLUDED)
|
||||
assertThat(info.animator).isNotNull()
|
||||
|
||||
coroutineContext.cancelChildren()
|
||||
}
|
||||
|
||||
private fun startingToWake() =
|
||||
WakefulnessModel(
|
||||
WakefulnessState.STARTING_TO_WAKE,
|
||||
|
||||
Reference in New Issue
Block a user