Merge "Transitions - Support OCCLUDED -> GONE" into tm-qpr-dev
This commit is contained in:
@@ -47,6 +47,7 @@ constructor(
|
|||||||
listenForOccludedToLockscreen()
|
listenForOccludedToLockscreen()
|
||||||
listenForOccludedToDreaming()
|
listenForOccludedToDreaming()
|
||||||
listenForOccludedToAodOrDozing()
|
listenForOccludedToAodOrDozing()
|
||||||
|
listenForOccludedToGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun listenForOccludedToDreaming() {
|
private fun listenForOccludedToDreaming() {
|
||||||
@@ -72,11 +73,22 @@ constructor(
|
|||||||
private fun listenForOccludedToLockscreen() {
|
private fun listenForOccludedToLockscreen() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
keyguardInteractor.isKeyguardOccluded
|
keyguardInteractor.isKeyguardOccluded
|
||||||
.sample(keyguardTransitionInteractor.startedKeyguardTransitionStep, ::Pair)
|
.sample(
|
||||||
.collect { (isOccluded, lastStartedKeyguardState) ->
|
combine(
|
||||||
|
keyguardInteractor.isKeyguardShowing,
|
||||||
|
keyguardTransitionInteractor.startedKeyguardTransitionStep,
|
||||||
|
::Pair
|
||||||
|
),
|
||||||
|
::toTriple
|
||||||
|
)
|
||||||
|
.collect { (isOccluded, isShowing, lastStartedKeyguardState) ->
|
||||||
// Occlusion signals come from the framework, and should interrupt any
|
// Occlusion signals come from the framework, and should interrupt any
|
||||||
// existing transition
|
// existing transition
|
||||||
if (!isOccluded && lastStartedKeyguardState.to == KeyguardState.OCCLUDED) {
|
if (
|
||||||
|
!isOccluded &&
|
||||||
|
isShowing &&
|
||||||
|
lastStartedKeyguardState.to == KeyguardState.OCCLUDED
|
||||||
|
) {
|
||||||
keyguardTransitionRepository.startTransition(
|
keyguardTransitionRepository.startTransition(
|
||||||
TransitionInfo(
|
TransitionInfo(
|
||||||
name,
|
name,
|
||||||
@@ -90,6 +102,38 @@ constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun listenForOccludedToGone() {
|
||||||
|
scope.launch {
|
||||||
|
keyguardInteractor.isKeyguardOccluded
|
||||||
|
.sample(
|
||||||
|
combine(
|
||||||
|
keyguardInteractor.isKeyguardShowing,
|
||||||
|
keyguardTransitionInteractor.startedKeyguardTransitionStep,
|
||||||
|
::Pair
|
||||||
|
),
|
||||||
|
::toTriple
|
||||||
|
)
|
||||||
|
.collect { (isOccluded, isShowing, lastStartedKeyguardState) ->
|
||||||
|
// Occlusion signals come from the framework, and should interrupt any
|
||||||
|
// existing transition
|
||||||
|
if (
|
||||||
|
!isOccluded &&
|
||||||
|
!isShowing &&
|
||||||
|
lastStartedKeyguardState.to == KeyguardState.OCCLUDED
|
||||||
|
) {
|
||||||
|
keyguardTransitionRepository.startTransition(
|
||||||
|
TransitionInfo(
|
||||||
|
name,
|
||||||
|
KeyguardState.OCCLUDED,
|
||||||
|
KeyguardState.GONE,
|
||||||
|
getAnimator(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun listenForOccludedToAodOrDozing() {
|
private fun listenForOccludedToAodOrDozing() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
keyguardInteractor.wakefulnessModel
|
keyguardInteractor.wakefulnessModel
|
||||||
|
|||||||
@@ -967,6 +967,92 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() {
|
|||||||
coroutineContext.cancelChildren()
|
coroutineContext.cancelChildren()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `OCCLUDED to GONE`() =
|
||||||
|
testScope.runTest {
|
||||||
|
// GIVEN a device on lockscreen
|
||||||
|
keyguardRepository.setKeyguardShowing(true)
|
||||||
|
runCurrent()
|
||||||
|
|
||||||
|
// GIVEN a prior transition has run to OCCLUDED
|
||||||
|
runner.startTransition(
|
||||||
|
testScope,
|
||||||
|
TransitionInfo(
|
||||||
|
ownerName = "",
|
||||||
|
from = KeyguardState.LOCKSCREEN,
|
||||||
|
to = KeyguardState.OCCLUDED,
|
||||||
|
animator =
|
||||||
|
ValueAnimator().apply {
|
||||||
|
duration = 10
|
||||||
|
interpolator = Interpolators.LINEAR
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
keyguardRepository.setKeyguardOccluded(true)
|
||||||
|
runCurrent()
|
||||||
|
reset(mockTransitionRepository)
|
||||||
|
|
||||||
|
// WHEN keyguard goes away
|
||||||
|
keyguardRepository.setKeyguardShowing(false)
|
||||||
|
// AND occlusion ends
|
||||||
|
keyguardRepository.setKeyguardOccluded(false)
|
||||||
|
runCurrent()
|
||||||
|
|
||||||
|
val info =
|
||||||
|
withArgCaptor<TransitionInfo> {
|
||||||
|
verify(mockTransitionRepository).startTransition(capture(), anyBoolean())
|
||||||
|
}
|
||||||
|
// THEN a transition to GONE should occur
|
||||||
|
assertThat(info.ownerName).isEqualTo("FromOccludedTransitionInteractor")
|
||||||
|
assertThat(info.from).isEqualTo(KeyguardState.OCCLUDED)
|
||||||
|
assertThat(info.to).isEqualTo(KeyguardState.GONE)
|
||||||
|
assertThat(info.animator).isNotNull()
|
||||||
|
|
||||||
|
coroutineContext.cancelChildren()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `OCCLUDED to LOCKSCREEN`() =
|
||||||
|
testScope.runTest {
|
||||||
|
// GIVEN a device on lockscreen
|
||||||
|
keyguardRepository.setKeyguardShowing(true)
|
||||||
|
runCurrent()
|
||||||
|
|
||||||
|
// GIVEN a prior transition has run to OCCLUDED
|
||||||
|
runner.startTransition(
|
||||||
|
testScope,
|
||||||
|
TransitionInfo(
|
||||||
|
ownerName = "",
|
||||||
|
from = KeyguardState.LOCKSCREEN,
|
||||||
|
to = KeyguardState.OCCLUDED,
|
||||||
|
animator =
|
||||||
|
ValueAnimator().apply {
|
||||||
|
duration = 10
|
||||||
|
interpolator = Interpolators.LINEAR
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
keyguardRepository.setKeyguardOccluded(true)
|
||||||
|
runCurrent()
|
||||||
|
reset(mockTransitionRepository)
|
||||||
|
|
||||||
|
// WHEN occlusion ends
|
||||||
|
keyguardRepository.setKeyguardOccluded(false)
|
||||||
|
runCurrent()
|
||||||
|
|
||||||
|
val info =
|
||||||
|
withArgCaptor<TransitionInfo> {
|
||||||
|
verify(mockTransitionRepository).startTransition(capture(), anyBoolean())
|
||||||
|
}
|
||||||
|
// THEN a transition to LOCKSCREEN should occur
|
||||||
|
assertThat(info.ownerName).isEqualTo("FromOccludedTransitionInteractor")
|
||||||
|
assertThat(info.from).isEqualTo(KeyguardState.OCCLUDED)
|
||||||
|
assertThat(info.to).isEqualTo(KeyguardState.LOCKSCREEN)
|
||||||
|
assertThat(info.animator).isNotNull()
|
||||||
|
|
||||||
|
coroutineContext.cancelChildren()
|
||||||
|
}
|
||||||
|
|
||||||
private fun startingToWake() =
|
private fun startingToWake() =
|
||||||
WakefulnessModel(
|
WakefulnessModel(
|
||||||
WakefulnessState.STARTING_TO_WAKE,
|
WakefulnessState.STARTING_TO_WAKE,
|
||||||
|
|||||||
Reference in New Issue
Block a user