Loading packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt +30 −1 Original line number Diff line number Diff line Loading @@ -25,8 +25,12 @@ import androidx.test.filters.SmallTest import com.android.compose.animation.scene.DefaultEdgeDetector import com.android.systemui.SysuiTestCase import com.android.systemui.classifier.fakeFalsingManager import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFingerprintAuthRepository import com.android.systemui.keyguard.shared.model.SuccessFingerprintAuthenticationStatus import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.currentValue import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope Loading Loading @@ -139,7 +143,7 @@ class SceneContainerViewModelTest : SysuiTestCase() { assertThat(currentScene).isEqualTo(Scenes.Lockscreen) sceneContainerConfig.sceneKeys .filter { it != currentScene } .filter { it != currentScene && it != Scenes.Gone } .forEach { toScene -> assertWithMessage("Scene $toScene incorrectly protected when allowed") .that(underTest.canChangeScene(toScene = toScene)) Loading Loading @@ -208,6 +212,31 @@ class SceneContainerViewModelTest : SysuiTestCase() { } } @Test fun canChangeScene_toGone_whenLocked_returnsFalse() = kosmos.runTest { assertThat(currentValue(deviceUnlockedInteractor.deviceUnlockStatus).isUnlocked) .isFalse() val currentScene by collectLastValue(underTest.currentScene) assertThat(currentScene).isNotEqualTo(Scenes.Gone) assertThat(underTest.canChangeScene(toScene = Scenes.Gone)).isFalse() } @Test fun canChangeScene_toGone_whenUnlocked_returnsTrue() = kosmos.runTest { fakeDeviceEntryFingerprintAuthRepository.setAuthenticationStatus( SuccessFingerprintAuthenticationStatus(0, true) ) assertThat(currentValue(deviceUnlockedInteractor.deviceUnlockStatus).isUnlocked) .isTrue() val currentScene by collectLastValue(underTest.currentScene) assertThat(currentScene).isNotEqualTo(Scenes.Gone) assertThat(underTest.canChangeScene(toScene = Scenes.Gone)).isTrue() } @Test fun canShowOrReplaceOverlay_whenAllowed_showingWhileOnGone_returnsTrue() = kosmos.runTest { Loading packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt +34 −18 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.compose.animation.scene.UserAction import com.android.compose.animation.scene.UserActionResult import com.android.systemui.classifier.Classifier import com.android.systemui.classifier.domain.interactor.FalsingInteractor import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.ui.viewmodel.AodBurnInViewModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel Loading Loading @@ -63,6 +64,7 @@ class SceneContainerViewModel @AssistedInject constructor( private val sceneInteractor: SceneInteractor, private val deviceUnlockedInteractor: DeviceUnlockedInteractor, private val falsingInteractor: FalsingInteractor, private val powerInteractor: PowerInteractor, private val onBootTransitionInteractor: OnBootTransitionInteractor, Loading Loading @@ -222,25 +224,39 @@ constructor( * it being a false touch. */ fun canChangeScene(toScene: SceneKey): Boolean { return isInteractionAllowedByFalsing(toScene).also { sceneChangeAllowed -> if (sceneChangeAllowed) { // A scene change is guaranteed; log it. logger.logSceneChanged( if ( toScene == Scenes.Gone && !deviceUnlockedInteractor.deviceUnlockStatus.value.isUnlocked ) { logger.logSceneChangeRejection( from = currentScene.value, to = toScene, sceneState = null, reason = "user interaction", isInstant = false, originalChangeReason = null, rejectionReason = "Device not unlocked", ) } else { return false } if (!isInteractionAllowedByFalsing(toScene)) { logger.logSceneChangeRejection( from = currentScene.value, to = toScene, originalChangeReason = null, rejectionReason = "Falsing: false touch detected", ) return false } } // A scene change is guaranteed; log it. logger.logSceneChanged( from = currentScene.value, to = toScene, sceneState = null, reason = "user interaction", isInstant = false, ) return true } /** Loading packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneKosmos.kt +2 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package com.android.systemui.scene import android.view.View import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.classifier.domain.interactor.falsingInteractor import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor import com.android.systemui.haptics.msdl.msdlPlayer import com.android.systemui.keyguard.domain.interactor.keyguardInteractor import com.android.systemui.keyguard.ui.viewmodel.aodBurnInViewModel Loading Loading @@ -94,6 +95,7 @@ val Kosmos.sceneContainerViewModelFactory by Fixture { ): SceneContainerViewModel = SceneContainerViewModel( sceneInteractor = sceneInteractor, deviceUnlockedInteractor = deviceUnlockedInteractor, falsingInteractor = falsingInteractor, powerInteractor = powerInteractor, shadeModeInteractor = shadeModeInteractor, Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt +30 −1 Original line number Diff line number Diff line Loading @@ -25,8 +25,12 @@ import androidx.test.filters.SmallTest import com.android.compose.animation.scene.DefaultEdgeDetector import com.android.systemui.SysuiTestCase import com.android.systemui.classifier.fakeFalsingManager import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFingerprintAuthRepository import com.android.systemui.keyguard.shared.model.SuccessFingerprintAuthenticationStatus import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.currentValue import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope Loading Loading @@ -139,7 +143,7 @@ class SceneContainerViewModelTest : SysuiTestCase() { assertThat(currentScene).isEqualTo(Scenes.Lockscreen) sceneContainerConfig.sceneKeys .filter { it != currentScene } .filter { it != currentScene && it != Scenes.Gone } .forEach { toScene -> assertWithMessage("Scene $toScene incorrectly protected when allowed") .that(underTest.canChangeScene(toScene = toScene)) Loading Loading @@ -208,6 +212,31 @@ class SceneContainerViewModelTest : SysuiTestCase() { } } @Test fun canChangeScene_toGone_whenLocked_returnsFalse() = kosmos.runTest { assertThat(currentValue(deviceUnlockedInteractor.deviceUnlockStatus).isUnlocked) .isFalse() val currentScene by collectLastValue(underTest.currentScene) assertThat(currentScene).isNotEqualTo(Scenes.Gone) assertThat(underTest.canChangeScene(toScene = Scenes.Gone)).isFalse() } @Test fun canChangeScene_toGone_whenUnlocked_returnsTrue() = kosmos.runTest { fakeDeviceEntryFingerprintAuthRepository.setAuthenticationStatus( SuccessFingerprintAuthenticationStatus(0, true) ) assertThat(currentValue(deviceUnlockedInteractor.deviceUnlockStatus).isUnlocked) .isTrue() val currentScene by collectLastValue(underTest.currentScene) assertThat(currentScene).isNotEqualTo(Scenes.Gone) assertThat(underTest.canChangeScene(toScene = Scenes.Gone)).isTrue() } @Test fun canShowOrReplaceOverlay_whenAllowed_showingWhileOnGone_returnsTrue() = kosmos.runTest { Loading
packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt +34 −18 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.compose.animation.scene.UserAction import com.android.compose.animation.scene.UserActionResult import com.android.systemui.classifier.Classifier import com.android.systemui.classifier.domain.interactor.FalsingInteractor import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.ui.viewmodel.AodBurnInViewModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel Loading Loading @@ -63,6 +64,7 @@ class SceneContainerViewModel @AssistedInject constructor( private val sceneInteractor: SceneInteractor, private val deviceUnlockedInteractor: DeviceUnlockedInteractor, private val falsingInteractor: FalsingInteractor, private val powerInteractor: PowerInteractor, private val onBootTransitionInteractor: OnBootTransitionInteractor, Loading Loading @@ -222,25 +224,39 @@ constructor( * it being a false touch. */ fun canChangeScene(toScene: SceneKey): Boolean { return isInteractionAllowedByFalsing(toScene).also { sceneChangeAllowed -> if (sceneChangeAllowed) { // A scene change is guaranteed; log it. logger.logSceneChanged( if ( toScene == Scenes.Gone && !deviceUnlockedInteractor.deviceUnlockStatus.value.isUnlocked ) { logger.logSceneChangeRejection( from = currentScene.value, to = toScene, sceneState = null, reason = "user interaction", isInstant = false, originalChangeReason = null, rejectionReason = "Device not unlocked", ) } else { return false } if (!isInteractionAllowedByFalsing(toScene)) { logger.logSceneChangeRejection( from = currentScene.value, to = toScene, originalChangeReason = null, rejectionReason = "Falsing: false touch detected", ) return false } } // A scene change is guaranteed; log it. logger.logSceneChanged( from = currentScene.value, to = toScene, sceneState = null, reason = "user interaction", isInstant = false, ) return true } /** Loading
packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneKosmos.kt +2 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package com.android.systemui.scene import android.view.View import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.classifier.domain.interactor.falsingInteractor import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor import com.android.systemui.haptics.msdl.msdlPlayer import com.android.systemui.keyguard.domain.interactor.keyguardInteractor import com.android.systemui.keyguard.ui.viewmodel.aodBurnInViewModel Loading Loading @@ -94,6 +95,7 @@ val Kosmos.sceneContainerViewModelFactory by Fixture { ): SceneContainerViewModel = SceneContainerViewModel( sceneInteractor = sceneInteractor, deviceUnlockedInteractor = deviceUnlockedInteractor, falsingInteractor = falsingInteractor, powerInteractor = powerInteractor, shadeModeInteractor = shadeModeInteractor, Loading