Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerWindowViewModel.kt +4 −4 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ constructor( alternateBouncerInteractor: AlternateBouncerInteractor, keyguardTransitionInteractor: KeyguardTransitionInteractor, ) { val canShowAlternateBouncer: Flow<Boolean> = alternateBouncerInteractor.canShowAlternateBouncer private val deviceSupportsAlternateBouncer: Flow<Boolean> = alternateBouncerInteractor.alternateBouncerSupported private val isTransitioningToOrFromOrShowingAlternateBouncer: Flow<Boolean> = keyguardTransitionInteractor .transitionValue(KeyguardState.ALTERNATE_BOUNCER) Loading @@ -43,8 +43,8 @@ constructor( .distinctUntilChanged() val alternateBouncerWindowRequired: Flow<Boolean> = canShowAlternateBouncer.flatMapLatest { canShowAlternateBouncer -> if (canShowAlternateBouncer) { deviceSupportsAlternateBouncer.flatMapLatest { deviceSupportsAlternateBouncer -> if (deviceSupportsAlternateBouncer) { isTransitioningToOrFromOrShowingAlternateBouncer } else { flowOf(false) Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerWindowViewModelTest.kt +11 −111 Original line number Diff line number Diff line Loading @@ -19,26 +19,22 @@ package com.android.systemui.keyguard.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.keyguard.keyguardUpdateMonitor import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.data.repository.fakeFingerprintPropertyRepository import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository 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.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.policy.keyguardStateController import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.whenever import org.junit.runners.JUnit4 @ExperimentalCoroutinesApi @RunWith(AndroidJUnit4::class) Loading @@ -54,35 +50,13 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { fun alternateBouncerTransition_alternateBouncerWindowRequiredTrue() = testScope.runTest { mSetFlagsRule.enableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) val canShowAlternateBouncer by collectLastValue(underTest.canShowAlternateBouncer) val alternateBouncerWindowRequired by collectLastValue(underTest.alternateBouncerWindowRequired) givenCanShowAlternateBouncer() fingerprintPropertyRepository.supportsUdfps() transitionRepository.sendTransitionSteps( listOf( stepToLockscreen(0f, TransitionState.STARTED), stepToLockscreen(.4f), stepToLockscreen(1f, TransitionState.FINISHED), ), testScope, ) assertThat(canShowAlternateBouncer).isTrue() transitionRepository.sendTransitionSteps( listOf( stepFromLockscreenToAlternateBouncer(0f, TransitionState.STARTED), stepFromLockscreenToAlternateBouncer(.4f), stepFromLockscreenToAlternateBouncer(.6f), ), testScope, ) assertThat(canShowAlternateBouncer).isTrue() assertThat(alternateBouncerWindowRequired).isTrue() transitionRepository.sendTransitionSteps( listOf( stepFromAlternateBouncer(0f, TransitionState.STARTED), stepFromAlternateBouncer(.2f), stepFromAlternateBouncer(.4f), stepFromAlternateBouncer(.6f), ), testScope, Loading @@ -104,21 +78,13 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { mSetFlagsRule.disableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) val alternateBouncerWindowRequired by collectLastValue(underTest.alternateBouncerWindowRequired) givenCanShowAlternateBouncer() fingerprintPropertyRepository.supportsUdfps() transitionRepository.sendTransitionSteps( listOf( stepToLockscreen(0f, TransitionState.STARTED), stepToLockscreen(.4f), stepToLockscreen(1f, TransitionState.FINISHED), ), testScope, ) transitionRepository.sendTransitionSteps( listOf( stepFromLockscreenToAlternateBouncer(0f, TransitionState.STARTED), stepFromLockscreenToAlternateBouncer(.4f), stepFromLockscreenToAlternateBouncer(.6f), stepFromAlternateBouncer(0f, TransitionState.STARTED), stepFromAlternateBouncer(.4f), stepFromAlternateBouncer(.6f), stepFromAlternateBouncer(1f), ), testScope, ) Loading @@ -131,23 +97,13 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { mSetFlagsRule.enableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) val alternateBouncerWindowRequired by collectLastValue(underTest.alternateBouncerWindowRequired) givenCanShowAlternateBouncer() fingerprintPropertyRepository.supportsUdfps() transitionRepository.sendTransitionSteps( listOf( stepFromLockscreenToDozing(0f, TransitionState.STARTED), stepFromLockscreenToDozing(.4f), stepFromLockscreenToDozing(.6f), stepFromLockscreenToDozing(1f, TransitionState.FINISHED), ), testScope, ) assertThat(alternateBouncerWindowRequired).isFalse() transitionRepository.sendTransitionSteps( listOf( stepFromDozingToLockscreen(0f, TransitionState.STARTED), stepFromDozingToLockscreen(.4f), stepFromDozingToLockscreen(.6f), stepFromDozingToLockscreen(1f), ), testScope, ) Loading @@ -160,39 +116,19 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { mSetFlagsRule.enableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) val alternateBouncerWindowRequired by collectLastValue(underTest.alternateBouncerWindowRequired) givenCanShowAlternateBouncer() fingerprintPropertyRepository.supportsRearFps() transitionRepository.sendTransitionSteps( listOf( stepToLockscreen(0f, TransitionState.STARTED), stepToLockscreen(.4f), stepToLockscreen(1f, TransitionState.FINISHED), ), testScope, ) transitionRepository.sendTransitionSteps( listOf( stepFromLockscreenToAlternateBouncer(0f, TransitionState.STARTED), stepFromLockscreenToAlternateBouncer(.4f), stepFromLockscreenToAlternateBouncer(.6f), stepFromAlternateBouncer(0f, TransitionState.STARTED), stepFromAlternateBouncer(.4f), stepFromAlternateBouncer(.6f), stepFromAlternateBouncer(1f), ), testScope, ) assertThat(alternateBouncerWindowRequired).isFalse() } private fun stepToLockscreen( value: Float, state: TransitionState = TransitionState.RUNNING ): TransitionStep { return step( from = KeyguardState.GONE, to = KeyguardState.LOCKSCREEN, value = value, transitionState = state, ) } private fun stepFromAlternateBouncer( value: Float, state: TransitionState = TransitionState.RUNNING Loading @@ -205,18 +141,6 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { ) } private fun stepFromLockscreenToAlternateBouncer( value: Float, state: TransitionState = TransitionState.RUNNING ): TransitionStep { return step( from = KeyguardState.LOCKSCREEN, to = KeyguardState.ALTERNATE_BOUNCER, value = value, transitionState = state, ) } private fun stepFromDozingToLockscreen( value: Float, state: TransitionState = TransitionState.RUNNING Loading @@ -229,18 +153,6 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { ) } private fun stepFromLockscreenToDozing( value: Float, state: TransitionState = TransitionState.RUNNING ): TransitionStep { return step( from = KeyguardState.LOCKSCREEN, to = KeyguardState.DOZING, value = value, transitionState = state, ) } private fun step( from: KeyguardState, to: KeyguardState, Loading @@ -255,16 +167,4 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { ownerName = "AlternateBouncerViewModelTest" ) } /** * Given the alternate bouncer parameters are set so that the alternate bouncer can show, aside * from the fingerprint modality. */ private fun givenCanShowAlternateBouncer() { kosmos.fakeKeyguardBouncerRepository.setPrimaryShow(false) kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true) kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthCurrentlyAllowed(true) whenever(kosmos.keyguardUpdateMonitor.isFingerprintLockedOut).thenReturn(false) whenever(kosmos.keyguardStateController.isUnlocked).thenReturn(false) } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerWindowViewModel.kt +4 −4 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ constructor( alternateBouncerInteractor: AlternateBouncerInteractor, keyguardTransitionInteractor: KeyguardTransitionInteractor, ) { val canShowAlternateBouncer: Flow<Boolean> = alternateBouncerInteractor.canShowAlternateBouncer private val deviceSupportsAlternateBouncer: Flow<Boolean> = alternateBouncerInteractor.alternateBouncerSupported private val isTransitioningToOrFromOrShowingAlternateBouncer: Flow<Boolean> = keyguardTransitionInteractor .transitionValue(KeyguardState.ALTERNATE_BOUNCER) Loading @@ -43,8 +43,8 @@ constructor( .distinctUntilChanged() val alternateBouncerWindowRequired: Flow<Boolean> = canShowAlternateBouncer.flatMapLatest { canShowAlternateBouncer -> if (canShowAlternateBouncer) { deviceSupportsAlternateBouncer.flatMapLatest { deviceSupportsAlternateBouncer -> if (deviceSupportsAlternateBouncer) { isTransitioningToOrFromOrShowingAlternateBouncer } else { flowOf(false) Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/AlternateBouncerWindowViewModelTest.kt +11 −111 Original line number Diff line number Diff line Loading @@ -19,26 +19,22 @@ package com.android.systemui.keyguard.ui.viewmodel import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.keyguard.keyguardUpdateMonitor import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.data.repository.fakeFingerprintPropertyRepository import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository 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.keyguard.shared.model.TransitionStep import com.android.systemui.kosmos.testScope import com.android.systemui.statusbar.policy.keyguardStateController import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith import org.mockito.kotlin.whenever import org.junit.runners.JUnit4 @ExperimentalCoroutinesApi @RunWith(AndroidJUnit4::class) Loading @@ -54,35 +50,13 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { fun alternateBouncerTransition_alternateBouncerWindowRequiredTrue() = testScope.runTest { mSetFlagsRule.enableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) val canShowAlternateBouncer by collectLastValue(underTest.canShowAlternateBouncer) val alternateBouncerWindowRequired by collectLastValue(underTest.alternateBouncerWindowRequired) givenCanShowAlternateBouncer() fingerprintPropertyRepository.supportsUdfps() transitionRepository.sendTransitionSteps( listOf( stepToLockscreen(0f, TransitionState.STARTED), stepToLockscreen(.4f), stepToLockscreen(1f, TransitionState.FINISHED), ), testScope, ) assertThat(canShowAlternateBouncer).isTrue() transitionRepository.sendTransitionSteps( listOf( stepFromLockscreenToAlternateBouncer(0f, TransitionState.STARTED), stepFromLockscreenToAlternateBouncer(.4f), stepFromLockscreenToAlternateBouncer(.6f), ), testScope, ) assertThat(canShowAlternateBouncer).isTrue() assertThat(alternateBouncerWindowRequired).isTrue() transitionRepository.sendTransitionSteps( listOf( stepFromAlternateBouncer(0f, TransitionState.STARTED), stepFromAlternateBouncer(.2f), stepFromAlternateBouncer(.4f), stepFromAlternateBouncer(.6f), ), testScope, Loading @@ -104,21 +78,13 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { mSetFlagsRule.disableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) val alternateBouncerWindowRequired by collectLastValue(underTest.alternateBouncerWindowRequired) givenCanShowAlternateBouncer() fingerprintPropertyRepository.supportsUdfps() transitionRepository.sendTransitionSteps( listOf( stepToLockscreen(0f, TransitionState.STARTED), stepToLockscreen(.4f), stepToLockscreen(1f, TransitionState.FINISHED), ), testScope, ) transitionRepository.sendTransitionSteps( listOf( stepFromLockscreenToAlternateBouncer(0f, TransitionState.STARTED), stepFromLockscreenToAlternateBouncer(.4f), stepFromLockscreenToAlternateBouncer(.6f), stepFromAlternateBouncer(0f, TransitionState.STARTED), stepFromAlternateBouncer(.4f), stepFromAlternateBouncer(.6f), stepFromAlternateBouncer(1f), ), testScope, ) Loading @@ -131,23 +97,13 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { mSetFlagsRule.enableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) val alternateBouncerWindowRequired by collectLastValue(underTest.alternateBouncerWindowRequired) givenCanShowAlternateBouncer() fingerprintPropertyRepository.supportsUdfps() transitionRepository.sendTransitionSteps( listOf( stepFromLockscreenToDozing(0f, TransitionState.STARTED), stepFromLockscreenToDozing(.4f), stepFromLockscreenToDozing(.6f), stepFromLockscreenToDozing(1f, TransitionState.FINISHED), ), testScope, ) assertThat(alternateBouncerWindowRequired).isFalse() transitionRepository.sendTransitionSteps( listOf( stepFromDozingToLockscreen(0f, TransitionState.STARTED), stepFromDozingToLockscreen(.4f), stepFromDozingToLockscreen(.6f), stepFromDozingToLockscreen(1f), ), testScope, ) Loading @@ -160,39 +116,19 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { mSetFlagsRule.enableFlags(Flags.FLAG_DEVICE_ENTRY_UDFPS_REFACTOR) val alternateBouncerWindowRequired by collectLastValue(underTest.alternateBouncerWindowRequired) givenCanShowAlternateBouncer() fingerprintPropertyRepository.supportsRearFps() transitionRepository.sendTransitionSteps( listOf( stepToLockscreen(0f, TransitionState.STARTED), stepToLockscreen(.4f), stepToLockscreen(1f, TransitionState.FINISHED), ), testScope, ) transitionRepository.sendTransitionSteps( listOf( stepFromLockscreenToAlternateBouncer(0f, TransitionState.STARTED), stepFromLockscreenToAlternateBouncer(.4f), stepFromLockscreenToAlternateBouncer(.6f), stepFromAlternateBouncer(0f, TransitionState.STARTED), stepFromAlternateBouncer(.4f), stepFromAlternateBouncer(.6f), stepFromAlternateBouncer(1f), ), testScope, ) assertThat(alternateBouncerWindowRequired).isFalse() } private fun stepToLockscreen( value: Float, state: TransitionState = TransitionState.RUNNING ): TransitionStep { return step( from = KeyguardState.GONE, to = KeyguardState.LOCKSCREEN, value = value, transitionState = state, ) } private fun stepFromAlternateBouncer( value: Float, state: TransitionState = TransitionState.RUNNING Loading @@ -205,18 +141,6 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { ) } private fun stepFromLockscreenToAlternateBouncer( value: Float, state: TransitionState = TransitionState.RUNNING ): TransitionStep { return step( from = KeyguardState.LOCKSCREEN, to = KeyguardState.ALTERNATE_BOUNCER, value = value, transitionState = state, ) } private fun stepFromDozingToLockscreen( value: Float, state: TransitionState = TransitionState.RUNNING Loading @@ -229,18 +153,6 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { ) } private fun stepFromLockscreenToDozing( value: Float, state: TransitionState = TransitionState.RUNNING ): TransitionStep { return step( from = KeyguardState.LOCKSCREEN, to = KeyguardState.DOZING, value = value, transitionState = state, ) } private fun step( from: KeyguardState, to: KeyguardState, Loading @@ -255,16 +167,4 @@ class AlternateBouncerWindowViewModelTest : SysuiTestCase() { ownerName = "AlternateBouncerViewModelTest" ) } /** * Given the alternate bouncer parameters are set so that the alternate bouncer can show, aside * from the fingerprint modality. */ private fun givenCanShowAlternateBouncer() { kosmos.fakeKeyguardBouncerRepository.setPrimaryShow(false) kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true) kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthCurrentlyAllowed(true) whenever(kosmos.keyguardUpdateMonitor.isFingerprintLockedOut).thenReturn(false) whenever(kosmos.keyguardStateController.isUnlocked).thenReturn(false) } }