diff options
| author | 2024-06-11 16:57:27 +0000 | |
|---|---|---|
| committer | 2024-06-11 16:57:27 +0000 | |
| commit | 47eae14695158751422f87c70ba15f3d6513d14a (patch) | |
| tree | 4e81534a2a9e97db3642c8c5016fc1133b1597d7 | |
| parent | 73b4d9a98c9bc86bdd978def073632077d758c9b (diff) | |
| parent | af657c90618c24662f52728d1de32f97aa948ba7 (diff) | |
Merge "Don't use AOD device entry icon variant until dozing transition is finished" into main
2 files changed, 62 insertions, 2 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModelTest.kt index 460a1fc44e67..b0959e4eea0b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModelTest.kt @@ -25,6 +25,7 @@ import com.android.systemui.coroutines.collectLastValue import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState +import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.kosmos.testScope import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat @@ -58,6 +59,62 @@ class DeviceEntryForegroundViewModelTest : SysuiTestCase() { assertThat(viewModel?.tint).isEqualTo(Color.WHITE) } + @Test + fun startsDozing_doNotShowAodVariant() = + testScope.runTest { + val viewModel by collectLastValue(underTest.viewModel) + + givenUdfpsEnrolledAndEnabled() + kosmos.run { + fakeKeyguardTransitionRepository.sendTransitionSteps( + from = KeyguardState.LOCKSCREEN, + to = KeyguardState.DOZING, + testScope = testScope, + throughTransitionState = TransitionState.STARTED, + ) + } + + assertThat(viewModel?.useAodVariant).isEqualTo(false) + } + + @Test + fun finishedDozing_showAodVariant() = + testScope.runTest { + val viewModel by collectLastValue(underTest.viewModel) + + givenUdfpsEnrolledAndEnabled() + kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( + from = KeyguardState.LOCKSCREEN, + to = KeyguardState.AOD, + testScope = testScope, + throughTransitionState = TransitionState.FINISHED, + ) + + assertThat(viewModel?.useAodVariant).isEqualTo(true) + } + + @Test + fun startTransitionToLockscreenFromDozing_doNotShowAodVariant() = + testScope.runTest { + val viewModel by collectLastValue(underTest.viewModel) + + givenUdfpsEnrolledAndEnabled() + kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( + from = KeyguardState.LOCKSCREEN, + to = KeyguardState.DOZING, + testScope = testScope, + throughTransitionState = TransitionState.FINISHED, + ) + kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( + from = KeyguardState.DOZING, + to = KeyguardState.LOCKSCREEN, + testScope = testScope, + throughTransitionState = TransitionState.RUNNING, + ) + + assertThat(viewModel?.useAodVariant).isEqualTo(false) + } + private fun givenUdfpsEnrolledAndEnabled() { kosmos.fakeFingerprintPropertyRepository.supportsUdfps() kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModel.kt index 0f1f5c1f1cb5..06b76b3c0f37 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DeviceEntryForegroundViewModel.kt @@ -52,8 +52,11 @@ constructor( udfpsOverlayInteractor: UdfpsOverlayInteractor, ) { private val isShowingAodOrDozing: Flow<Boolean> = - transitionInteractor.startedKeyguardState.map { keyguardState -> - keyguardState == KeyguardState.AOD || keyguardState == KeyguardState.DOZING + combine( + transitionInteractor.startedKeyguardState, + transitionInteractor.transitionValue(KeyguardState.DOZING), + ) { startedKeyguardState, dozingTransitionValue -> + startedKeyguardState == KeyguardState.AOD || dozingTransitionValue == 1f } private fun getColor(usingBackgroundProtection: Boolean): Int { |