Merge changes Ifd7bc217,I337d0189 into tm-qpr-dev am: 27df631c6f am: 1265a30c1d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21299267

Change-Id: I2cd73bb6aaa83db3e714adf6befdaf998dd79748
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Matt Pietal
2023-02-08 14:12:24 +00:00
committed by Automerger Merge Worker
3 changed files with 61 additions and 5 deletions

View File

@@ -944,7 +944,7 @@
android:showWhenLocked="true"
android:showForAllUsers="true"
android:finishOnTaskLaunch="true"
android:launchMode="singleInstance"
android:lockTaskMode="if_whitelisted"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
android:visibleToInstantApps="true">
</activity>

View File

@@ -34,6 +34,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
@@ -56,9 +57,14 @@ constructor(
private fun listenForDreamingToLockscreen() {
scope.launch {
// Using isDreamingWithOverlay provides an optimized path to LOCKSCREEN state, which
// otherwise would have gone through OCCLUDED first
keyguardInteractor.isAbleToDream
// Dependending on the dream, either dream state or occluded change will change first,
// so listen for both
combine(keyguardInteractor.isAbleToDream, keyguardInteractor.isKeyguardOccluded) {
isAbleToDream,
isKeyguardOccluded ->
isAbleToDream && isKeyguardOccluded
}
.distinctUntilChanged()
.sample(
combine(
keyguardInteractor.dozeTransitionModel,

View File

@@ -158,7 +158,7 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() {
}
@Test
fun `DREAMING to LOCKSCREEN`() =
fun `DREAMING to LOCKSCREEN - dreaming state changes first`() =
testScope.runTest {
// GIVEN a device is dreaming and occluded
keyguardRepository.setDreamingWithOverlay(true)
@@ -188,9 +188,59 @@ class KeyguardTransitionScenariosTest : SysuiTestCase() {
)
// AND dreaming has stopped
keyguardRepository.setDreamingWithOverlay(false)
advanceUntilIdle()
// AND then occluded has stopped
keyguardRepository.setKeyguardOccluded(false)
advanceUntilIdle()
val info =
withArgCaptor<TransitionInfo> {
verify(mockTransitionRepository).startTransition(capture())
}
// THEN a transition to BOUNCER should occur
assertThat(info.ownerName).isEqualTo("FromDreamingTransitionInteractor")
assertThat(info.from).isEqualTo(KeyguardState.DREAMING)
assertThat(info.to).isEqualTo(KeyguardState.LOCKSCREEN)
assertThat(info.animator).isNotNull()
coroutineContext.cancelChildren()
}
@Test
fun `DREAMING to LOCKSCREEN - occluded state changes first`() =
testScope.runTest {
// GIVEN a device is dreaming and occluded
keyguardRepository.setDreamingWithOverlay(true)
keyguardRepository.setKeyguardOccluded(true)
runCurrent()
// GIVEN a prior transition has run to DREAMING
runner.startTransition(
testScope,
TransitionInfo(
ownerName = "",
from = KeyguardState.LOCKSCREEN,
to = KeyguardState.DREAMING,
animator =
ValueAnimator().apply {
duration = 10
interpolator = Interpolators.LINEAR
},
)
)
runCurrent()
reset(mockTransitionRepository)
// WHEN doze is complete
keyguardRepository.setDozeTransitionModel(
DozeTransitionModel(from = DozeStateModel.DOZE, to = DozeStateModel.FINISH)
)
// AND occluded has stopped
keyguardRepository.setKeyguardOccluded(false)
advanceUntilIdle()
// AND then dreaming has stopped
keyguardRepository.setDreamingWithOverlay(false)
advanceUntilIdle()
val info =
withArgCaptor<TransitionInfo> {