Merge "[flexiglass] Lock screen -> Lockscreen." into udc-dev

This commit is contained in:
Ale Nijamkin
2023-05-15 16:05:54 +00:00
committed by Android (Google) Code Review
17 changed files with 91 additions and 91 deletions

View File

@@ -62,7 +62,7 @@ constructor(
override fun destinationScenes(): StateFlow<Map<UserAction, SceneModel>> = override fun destinationScenes(): StateFlow<Map<UserAction, SceneModel>> =
MutableStateFlow<Map<UserAction, SceneModel>>( MutableStateFlow<Map<UserAction, SceneModel>>(
mapOf( mapOf(
UserAction.Back to SceneModel(SceneKey.LockScreen), UserAction.Back to SceneModel(SceneKey.Lockscreen),
) )
) )
.asStateFlow() .asStateFlow()

View File

@@ -33,7 +33,7 @@ import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.ui.compose.Icon import com.android.systemui.common.ui.compose.Icon
import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.ui.viewmodel.LockScreenSceneViewModel import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneViewModel
import com.android.systemui.scene.shared.model.Direction import com.android.systemui.scene.shared.model.Direction
import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.shared.model.SceneModel import com.android.systemui.scene.shared.model.SceneModel
@@ -48,13 +48,13 @@ import kotlinx.coroutines.flow.stateIn
/** The lock screen scene shows when the device is locked. */ /** The lock screen scene shows when the device is locked. */
@SysUISingleton @SysUISingleton
class LockScreenScene class LockscreenScene
@Inject @Inject
constructor( constructor(
@Application private val applicationScope: CoroutineScope, @Application private val applicationScope: CoroutineScope,
private val viewModel: LockScreenSceneViewModel, private val viewModel: LockscreenSceneViewModel,
) : ComposableScene { ) : ComposableScene {
override val key = SceneKey.LockScreen override val key = SceneKey.Lockscreen
override fun destinationScenes(): StateFlow<Map<UserAction, SceneModel>> = override fun destinationScenes(): StateFlow<Map<UserAction, SceneModel>> =
viewModel.upDestinationSceneKey viewModel.upDestinationSceneKey
@@ -69,7 +69,7 @@ constructor(
override fun Content( override fun Content(
modifier: Modifier, modifier: Modifier,
) { ) {
LockScreenScene( LockscreenScene(
viewModel = viewModel, viewModel = viewModel,
modifier = modifier, modifier = modifier,
) )
@@ -86,8 +86,8 @@ constructor(
} }
@Composable @Composable
private fun LockScreenScene( private fun LockscreenScene(
viewModel: LockScreenSceneViewModel, viewModel: LockscreenSceneViewModel,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
) { ) {
// TODO(b/280879610): implement the real UI. // TODO(b/280879610): implement the real UI.
@@ -99,7 +99,7 @@ private fun LockScreenScene(
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.align(Alignment.Center) modifier = Modifier.align(Alignment.Center)
) { ) {
Text("Lock screen", style = MaterialTheme.typography.headlineMedium) Text("Lockscreen", style = MaterialTheme.typography.headlineMedium)
Row( Row(
horizontalArrangement = Arrangement.spacedBy(8.dp), horizontalArrangement = Arrangement.spacedBy(8.dp),
) { ) {

View File

@@ -33,7 +33,7 @@ interface AuthenticationRepository {
* A device that is not yet unlocked requires unlocking by completing an authentication * A device that is not yet unlocked requires unlocking by completing an authentication
* challenge according to the current authentication method. * challenge according to the current authentication method.
* *
* Note that this state has no real bearing on whether the lock screen is showing or dismissed. * Note that this state has no real bearing on whether the lockscreen is showing or dismissed.
*/ */
val isUnlocked: StateFlow<Boolean> val isUnlocked: StateFlow<Boolean>

View File

@@ -73,7 +73,7 @@ constructor(
is AuthenticationMethodModel.Swipe -> is AuthenticationMethodModel.Swipe ->
sceneInteractor.setCurrentScene( sceneInteractor.setCurrentScene(
containerName, containerName,
SceneModel(SceneKey.LockScreen), SceneModel(SceneKey.Lockscreen),
) )
else -> Unit else -> Unit
} }

View File

@@ -36,8 +36,8 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
/** Hosts business and application state accessing logic for the lock screen scene. */ /** Hosts business and application state accessing logic for the lockscreen scene. */
class LockScreenSceneInteractor class LockscreenSceneInteractor
@AssistedInject @AssistedInject
constructor( constructor(
@Application applicationScope: CoroutineScope, @Application applicationScope: CoroutineScope,
@@ -59,7 +59,7 @@ constructor(
initialValue = !authenticationInteractor.isUnlocked.value, initialValue = !authenticationInteractor.isUnlocked.value,
) )
/** Whether it's currently possible to swipe up to dismiss the lock screen. */ /** Whether it's currently possible to swipe up to dismiss the lockscreen. */
val isSwipeToDismissEnabled: StateFlow<Boolean> = val isSwipeToDismissEnabled: StateFlow<Boolean> =
combine( combine(
authenticationInteractor.isUnlocked, authenticationInteractor.isUnlocked,
@@ -81,9 +81,9 @@ constructor(
) )
init { init {
// LOCKING SHOWS LOCK SCREEN. // LOCKING SHOWS Lockscreen.
// //
// Move to the lock screen scene if the device becomes locked while in any scene. // Move to the lockscreen scene if the device becomes locked while in any scene.
applicationScope.launch { applicationScope.launch {
authenticationInteractor.isUnlocked authenticationInteractor.isUnlocked
.map { !it } .map { !it }
@@ -92,7 +92,7 @@ constructor(
if (isLocked) { if (isLocked) {
sceneInteractor.setCurrentScene( sceneInteractor.setCurrentScene(
containerName = containerName, containerName = containerName,
scene = SceneModel(SceneKey.LockScreen), scene = SceneModel(SceneKey.Lockscreen),
) )
} }
} }
@@ -101,7 +101,7 @@ constructor(
// BYPASS UNLOCK. // BYPASS UNLOCK.
// //
// Moves to the gone scene if bypass is enabled and the device becomes unlocked while in the // Moves to the gone scene if bypass is enabled and the device becomes unlocked while in the
// lock screen scene. // lockscreen scene.
applicationScope.launch { applicationScope.launch {
combine( combine(
authenticationInteractor.isBypassEnabled, authenticationInteractor.isBypassEnabled,
@@ -110,7 +110,7 @@ constructor(
::Triple, ::Triple,
) )
.collect { (isBypassEnabled, isUnlocked, currentScene) -> .collect { (isBypassEnabled, isUnlocked, currentScene) ->
if (isBypassEnabled && isUnlocked && currentScene.key == SceneKey.LockScreen) { if (isBypassEnabled && isUnlocked && currentScene.key == SceneKey.Lockscreen) {
sceneInteractor.setCurrentScene( sceneInteractor.setCurrentScene(
containerName = containerName, containerName = containerName,
scene = SceneModel(SceneKey.Gone), scene = SceneModel(SceneKey.Gone),
@@ -119,9 +119,9 @@ constructor(
} }
} }
// SWIPE TO DISMISS LOCK SCREEN. // SWIPE TO DISMISS Lockscreen.
// //
// If switched from the lock screen to the gone scene and the auth method was a swipe, // If switched from the lockscreen to the gone scene and the auth method was a swipe,
// unlocks the device. // unlocks the device.
applicationScope.launch { applicationScope.launch {
combine( combine(
@@ -133,7 +133,7 @@ constructor(
val (previousScene, currentScene) = scenes val (previousScene, currentScene) = scenes
if ( if (
authMethod is AuthenticationMethodModel.Swipe && authMethod is AuthenticationMethodModel.Swipe &&
previousScene.key == SceneKey.LockScreen && previousScene.key == SceneKey.Lockscreen &&
currentScene.key == SceneKey.Gone currentScene.key == SceneKey.Gone
) { ) {
authenticationInteractor.unlockDevice() authenticationInteractor.unlockDevice()
@@ -141,9 +141,9 @@ constructor(
} }
} }
// DISMISS LOCK SCREEN IF AUTH METHOD IS REMOVED. // DISMISS Lockscreen IF AUTH METHOD IS REMOVED.
// //
// If the auth method becomes None while on the lock screen scene, dismisses the lock // If the auth method becomes None while on the lockscreen scene, dismisses the lock
// screen. // screen.
applicationScope.launch { applicationScope.launch {
combine( combine(
@@ -153,7 +153,7 @@ constructor(
) )
.collect { (authMethod, scene) -> .collect { (authMethod, scene) ->
if ( if (
scene.key == SceneKey.LockScreen && scene.key == SceneKey.Lockscreen &&
authMethod == AuthenticationMethodModel.None authMethod == AuthenticationMethodModel.None
) { ) {
sceneInteractor.setCurrentScene( sceneInteractor.setCurrentScene(
@@ -165,8 +165,8 @@ constructor(
} }
} }
/** Attempts to dismiss the lock screen. This will cause the bouncer to show, if needed. */ /** Attempts to dismiss the lockscreen. This will cause the bouncer to show, if needed. */
fun dismissLockScreen() { fun dismissLockscreen() {
bouncerInteractor.showOrUnlockDevice(containerName = containerName) bouncerInteractor.showOrUnlockDevice(containerName = containerName)
} }
@@ -181,6 +181,6 @@ constructor(
interface Factory { interface Factory {
fun create( fun create(
containerName: String, containerName: String,
): LockScreenSceneInteractor ): LockscreenSceneInteractor
} }
} }

View File

@@ -20,7 +20,7 @@ import com.android.systemui.R
import com.android.systemui.common.shared.model.ContentDescription import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Icon
import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.domain.interactor.LockScreenSceneInteractor import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.SceneKey
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
@@ -31,17 +31,17 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.flow.stateIn
/** Models UI state and handles user input for the lock screen scene. */ /** Models UI state and handles user input for the lockscreen scene. */
class LockScreenSceneViewModel class LockscreenSceneViewModel
@AssistedInject @AssistedInject
constructor( constructor(
@Application applicationScope: CoroutineScope, @Application applicationScope: CoroutineScope,
interactorFactory: LockScreenSceneInteractor.Factory, interactorFactory: LockscreenSceneInteractor.Factory,
@Assisted containerName: String, @Assisted containerName: String,
) { ) {
private val interactor: LockScreenSceneInteractor = interactorFactory.create(containerName) private val interactor: LockscreenSceneInteractor = interactorFactory.create(containerName)
/** The icon for the "lock" button on the lock screen. */ /** The icon for the "lock" button on the lockscreen. */
val lockButtonIcon: StateFlow<Icon> = val lockButtonIcon: StateFlow<Icon> =
interactor.isDeviceLocked interactor.isDeviceLocked
.map { isLocked -> lockIcon(isLocked = isLocked) } .map { isLocked -> lockIcon(isLocked = isLocked) }
@@ -63,12 +63,12 @@ constructor(
/** Notifies that the lock button on the lock screen was clicked. */ /** Notifies that the lock button on the lock screen was clicked. */
fun onLockButtonClicked() { fun onLockButtonClicked() {
interactor.dismissLockScreen() interactor.dismissLockscreen()
} }
/** Notifies that some content on the lock screen was clicked. */ /** Notifies that some content on the lock screen was clicked. */
fun onContentClicked() { fun onContentClicked() {
interactor.dismissLockScreen() interactor.dismissLockscreen()
} }
private fun upDestinationSceneKey( private fun upDestinationSceneKey(
@@ -103,6 +103,6 @@ constructor(
interface Factory { interface Factory {
fun create( fun create(
containerName: String, containerName: String,
): LockScreenSceneViewModel ): LockscreenSceneViewModel
} }
} }

View File

@@ -16,7 +16,7 @@
package com.android.systemui.qs.ui.viewmodel package com.android.systemui.qs.ui.viewmodel
import com.android.systemui.keyguard.domain.interactor.LockScreenSceneInteractor import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
@@ -25,15 +25,15 @@ import dagger.assisted.AssistedInject
class QuickSettingsSceneViewModel class QuickSettingsSceneViewModel
@AssistedInject @AssistedInject
constructor( constructor(
lockScreenSceneInteractorFactory: LockScreenSceneInteractor.Factory, lockscreenSceneInteractorFactory: LockscreenSceneInteractor.Factory,
@Assisted containerName: String, @Assisted containerName: String,
) { ) {
private val lockScreenSceneInteractor: LockScreenSceneInteractor = private val lockscreenSceneInteractor: LockscreenSceneInteractor =
lockScreenSceneInteractorFactory.create(containerName) lockscreenSceneInteractorFactory.create(containerName)
/** Notifies that some content in quick settings was clicked. */ /** Notifies that some content in quick settings was clicked. */
fun onContentClicked() { fun onContentClicked() {
lockScreenSceneInteractor.dismissLockScreen() lockscreenSceneInteractor.dismissLockscreen()
} }
@AssistedFactory @AssistedFactory

View File

@@ -32,8 +32,8 @@ sealed class SceneKey(
*/ */
object Gone : SceneKey("gone") object Gone : SceneKey("gone")
/** The lock screen is the scene that shows when the device is locked. */ /** The lockscreen is the scene that shows when the device is locked. */
object LockScreen : SceneKey("lockscreen") object Lockscreen : SceneKey("lockscreen")
/** /**
* The shade is the scene whose primary purpose is to show a scrollable list of notifications. * The shade is the scene whose primary purpose is to show a scrollable list of notifications.

View File

@@ -17,7 +17,7 @@
package com.android.systemui.shade.ui.viewmodel package com.android.systemui.shade.ui.viewmodel
import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.domain.interactor.LockScreenSceneInteractor import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.SceneKey
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
@@ -33,11 +33,11 @@ class ShadeSceneViewModel
@AssistedInject @AssistedInject
constructor( constructor(
@Application private val applicationScope: CoroutineScope, @Application private val applicationScope: CoroutineScope,
lockScreenSceneInteractorFactory: LockScreenSceneInteractor.Factory, lockscreenSceneInteractorFactory: LockscreenSceneInteractor.Factory,
@Assisted private val containerName: String, @Assisted private val containerName: String,
) { ) {
private val lockScreenInteractor: LockScreenSceneInteractor = private val lockScreenInteractor: LockscreenSceneInteractor =
lockScreenSceneInteractorFactory.create(containerName) lockscreenSceneInteractorFactory.create(containerName)
/** The key of the scene we should switch to when swiping up. */ /** The key of the scene we should switch to when swiping up. */
val upDestinationSceneKey: StateFlow<SceneKey> = val upDestinationSceneKey: StateFlow<SceneKey> =
@@ -54,13 +54,13 @@ constructor(
/** Notifies that some content in the shade was clicked. */ /** Notifies that some content in the shade was clicked. */
fun onContentClicked() { fun onContentClicked() {
lockScreenInteractor.dismissLockScreen() lockScreenInteractor.dismissLockscreen()
} }
private fun upDestinationSceneKey( private fun upDestinationSceneKey(
isLocked: Boolean, isLocked: Boolean,
): SceneKey { ): SceneKey {
return if (isLocked) SceneKey.LockScreen else SceneKey.Gone return if (isLocked) SceneKey.Lockscreen else SceneKey.Gone
} }
@AssistedFactory @AssistedFactory

View File

@@ -36,7 +36,7 @@ import org.junit.runners.JUnit4
@OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class)
@SmallTest @SmallTest
@RunWith(JUnit4::class) @RunWith(JUnit4::class)
class LockScreenSceneInteractorTest : SysuiTestCase() { class LockscreenSceneInteractorTest : SysuiTestCase() {
private val testScope = TestScope() private val testScope = TestScope()
private val utils = SceneTestUtils(this, testScope) private val utils = SceneTestUtils(this, testScope)
@@ -96,9 +96,9 @@ class LockScreenSceneInteractorTest : SysuiTestCase() {
val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1)) val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
authenticationInteractor.lockDevice() authenticationInteractor.lockDevice()
authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.PIN(1234)) authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.PIN(1234))
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.LockScreen)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
underTest.dismissLockScreen() underTest.dismissLockscreen()
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
} }
@@ -109,9 +109,9 @@ class LockScreenSceneInteractorTest : SysuiTestCase() {
val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1)) val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
authenticationInteractor.unlockDevice() authenticationInteractor.unlockDevice()
authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.PIN(1234)) authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.PIN(1234))
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.LockScreen)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
underTest.dismissLockScreen() underTest.dismissLockscreen()
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
} }
@@ -122,9 +122,9 @@ class LockScreenSceneInteractorTest : SysuiTestCase() {
val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1)) val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
authenticationInteractor.lockDevice() authenticationInteractor.lockDevice()
authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.Swipe) authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.Swipe)
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.LockScreen)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
underTest.dismissLockScreen() underTest.dismissLockscreen()
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
} }
@@ -142,7 +142,7 @@ class LockScreenSceneInteractorTest : SysuiTestCase() {
authenticationInteractor.lockDevice() authenticationInteractor.lockDevice()
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.LockScreen)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
} }
@Test @Test
@@ -150,11 +150,11 @@ class LockScreenSceneInteractorTest : SysuiTestCase() {
testScope.runTest { testScope.runTest {
val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1)) val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
authenticationInteractor.lockDevice() authenticationInteractor.lockDevice()
sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.LockScreen)) sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.Lockscreen))
if (!authenticationInteractor.isBypassEnabled.value) { if (!authenticationInteractor.isBypassEnabled.value) {
authenticationInteractor.toggleBypassEnabled() authenticationInteractor.toggleBypassEnabled()
} }
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.LockScreen)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
authenticationInteractor.biometricUnlock() authenticationInteractor.biometricUnlock()
@@ -166,22 +166,22 @@ class LockScreenSceneInteractorTest : SysuiTestCase() {
testScope.runTest { testScope.runTest {
val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1)) val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
authenticationInteractor.lockDevice() authenticationInteractor.lockDevice()
sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.LockScreen)) sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.Lockscreen))
if (authenticationInteractor.isBypassEnabled.value) { if (authenticationInteractor.isBypassEnabled.value) {
authenticationInteractor.toggleBypassEnabled() authenticationInteractor.toggleBypassEnabled()
} }
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.LockScreen)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
authenticationInteractor.biometricUnlock() authenticationInteractor.biometricUnlock()
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.LockScreen)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
} }
@Test @Test
fun switchFromLockScreenToGone_authMethodSwipe_unlocksDevice() = fun switchFromLockScreenToGone_authMethodSwipe_unlocksDevice() =
testScope.runTest { testScope.runTest {
val isUnlocked by collectLastValue(authenticationInteractor.isUnlocked) val isUnlocked by collectLastValue(authenticationInteractor.isUnlocked)
sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.LockScreen)) sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.Lockscreen))
authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.Swipe) authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.Swipe)
assertThat(isUnlocked).isFalse() assertThat(isUnlocked).isFalse()
@@ -194,7 +194,7 @@ class LockScreenSceneInteractorTest : SysuiTestCase() {
fun switchFromLockScreenToGone_authMethodNotSwipe_doesNotUnlockDevice() = fun switchFromLockScreenToGone_authMethodNotSwipe_doesNotUnlockDevice() =
testScope.runTest { testScope.runTest {
val isUnlocked by collectLastValue(authenticationInteractor.isUnlocked) val isUnlocked by collectLastValue(authenticationInteractor.isUnlocked)
sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.LockScreen)) sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.Lockscreen))
authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.PIN(1234)) authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.PIN(1234))
assertThat(isUnlocked).isFalse() assertThat(isUnlocked).isFalse()
@@ -223,9 +223,9 @@ class LockScreenSceneInteractorTest : SysuiTestCase() {
fun authMethodChangedToNone_onLockScreenScene_dismissesLockScreen() = fun authMethodChangedToNone_onLockScreenScene_dismissesLockScreen() =
testScope.runTest { testScope.runTest {
val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1)) val currentScene by collectLastValue(sceneInteractor.currentScene(CONTAINER_1))
sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.LockScreen)) sceneInteractor.setCurrentScene(CONTAINER_1, SceneModel(SceneKey.Lockscreen))
authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.Swipe) authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.Swipe)
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.LockScreen)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.None) authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.None)

View File

@@ -22,7 +22,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Icon
import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.domain.interactor.LockScreenSceneInteractor import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
import com.android.systemui.scene.SceneTestUtils import com.android.systemui.scene.SceneTestUtils
import com.android.systemui.scene.SceneTestUtils.Companion.CONTAINER_1 import com.android.systemui.scene.SceneTestUtils.Companion.CONTAINER_1
import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.SceneKey
@@ -39,7 +39,7 @@ import org.junit.runners.JUnit4
@OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class)
@SmallTest @SmallTest
@RunWith(JUnit4::class) @RunWith(JUnit4::class)
class LockScreenSceneViewModelTest : SysuiTestCase() { class LockscreenSceneViewModelTest : SysuiTestCase() {
private val testScope = TestScope() private val testScope = TestScope()
private val utils = SceneTestUtils(this, testScope) private val utils = SceneTestUtils(this, testScope)
@@ -50,11 +50,11 @@ class LockScreenSceneViewModelTest : SysuiTestCase() {
) )
private val underTest = private val underTest =
LockScreenSceneViewModel( LockscreenSceneViewModel(
applicationScope = testScope.backgroundScope, applicationScope = testScope.backgroundScope,
interactorFactory = interactorFactory =
object : LockScreenSceneInteractor.Factory { object : LockscreenSceneInteractor.Factory {
override fun create(containerName: String): LockScreenSceneInteractor { override fun create(containerName: String): LockscreenSceneInteractor {
return utils.lockScreenSceneInteractor( return utils.lockScreenSceneInteractor(
authenticationInteractor = authenticationInteractor, authenticationInteractor = authenticationInteractor,
sceneInteractor = sceneInteractor, sceneInteractor = sceneInteractor,

View File

@@ -20,7 +20,7 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.domain.interactor.LockScreenSceneInteractor import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
import com.android.systemui.scene.SceneTestUtils import com.android.systemui.scene.SceneTestUtils
import com.android.systemui.scene.SceneTestUtils.Companion.CONTAINER_1 import com.android.systemui.scene.SceneTestUtils.Companion.CONTAINER_1
import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.SceneKey
@@ -49,9 +49,9 @@ class QuickSettingsSceneViewModelTest : SysuiTestCase() {
private val underTest = private val underTest =
QuickSettingsSceneViewModel( QuickSettingsSceneViewModel(
lockScreenSceneInteractorFactory = lockscreenSceneInteractorFactory =
object : LockScreenSceneInteractor.Factory { object : LockscreenSceneInteractor.Factory {
override fun create(containerName: String): LockScreenSceneInteractor { override fun create(containerName: String): LockscreenSceneInteractor {
return utils.lockScreenSceneInteractor( return utils.lockScreenSceneInteractor(
authenticationInteractor = authenticationInteractor, authenticationInteractor = authenticationInteractor,
sceneInteractor = sceneInteractor, sceneInteractor = sceneInteractor,

View File

@@ -45,7 +45,7 @@ class SceneContainerRepositoryTest : SysuiTestCase() {
listOf( listOf(
SceneKey.QuickSettings, SceneKey.QuickSettings,
SceneKey.Shade, SceneKey.Shade,
SceneKey.LockScreen, SceneKey.Lockscreen,
SceneKey.Bouncer, SceneKey.Bouncer,
SceneKey.Gone, SceneKey.Gone,
) )
@@ -62,7 +62,7 @@ class SceneContainerRepositoryTest : SysuiTestCase() {
fun currentScene() = runTest { fun currentScene() = runTest {
val underTest = utils.fakeSceneContainerRepository() val underTest = utils.fakeSceneContainerRepository()
val currentScene by collectLastValue(underTest.currentScene("container1")) val currentScene by collectLastValue(underTest.currentScene("container1"))
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.LockScreen)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
underTest.setCurrentScene("container1", SceneModel(SceneKey.Shade)) underTest.setCurrentScene("container1", SceneModel(SceneKey.Shade))
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Shade)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Shade))
@@ -88,7 +88,7 @@ class SceneContainerRepositoryTest : SysuiTestCase() {
utils.fakeSceneContainerConfig("container1"), utils.fakeSceneContainerConfig("container1"),
utils.fakeSceneContainerConfig( utils.fakeSceneContainerConfig(
"container2", "container2",
listOf(SceneKey.QuickSettings, SceneKey.LockScreen) listOf(SceneKey.QuickSettings, SceneKey.Lockscreen)
), ),
) )
) )

View File

@@ -46,7 +46,7 @@ class SceneInteractorTest : SysuiTestCase() {
@Test @Test
fun sceneTransitions() = runTest { fun sceneTransitions() = runTest {
val currentScene by collectLastValue(underTest.currentScene("container1")) val currentScene by collectLastValue(underTest.currentScene("container1"))
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.LockScreen)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
underTest.setCurrentScene("container1", SceneModel(SceneKey.Shade)) underTest.setCurrentScene("container1", SceneModel(SceneKey.Shade))
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Shade)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Shade))

View File

@@ -63,7 +63,7 @@ class SceneContainerViewModelTest : SysuiTestCase() {
@Test @Test
fun sceneTransition() = runTest { fun sceneTransition() = runTest {
val currentScene by collectLastValue(underTest.currentScene) val currentScene by collectLastValue(underTest.currentScene)
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.LockScreen)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
underTest.setCurrentScene(SceneModel(SceneKey.Shade)) underTest.setCurrentScene(SceneModel(SceneKey.Shade))
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Shade)) assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Shade))

View File

@@ -20,7 +20,7 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.domain.interactor.LockScreenSceneInteractor import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
import com.android.systemui.scene.SceneTestUtils import com.android.systemui.scene.SceneTestUtils
import com.android.systemui.scene.SceneTestUtils.Companion.CONTAINER_1 import com.android.systemui.scene.SceneTestUtils.Companion.CONTAINER_1
import com.android.systemui.scene.shared.model.SceneKey import com.android.systemui.scene.shared.model.SceneKey
@@ -50,9 +50,9 @@ class ShadeSceneViewModelTest : SysuiTestCase() {
private val underTest = private val underTest =
ShadeSceneViewModel( ShadeSceneViewModel(
applicationScope = testScope.backgroundScope, applicationScope = testScope.backgroundScope,
lockScreenSceneInteractorFactory = lockscreenSceneInteractorFactory =
object : LockScreenSceneInteractor.Factory { object : LockscreenSceneInteractor.Factory {
override fun create(containerName: String): LockScreenSceneInteractor { override fun create(containerName: String): LockscreenSceneInteractor {
return utils.lockScreenSceneInteractor( return utils.lockScreenSceneInteractor(
authenticationInteractor = authenticationInteractor, authenticationInteractor = authenticationInteractor,
sceneInteractor = sceneInteractor, sceneInteractor = sceneInteractor,
@@ -74,7 +74,7 @@ class ShadeSceneViewModelTest : SysuiTestCase() {
authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.PIN(1234)) authenticationInteractor.setAuthenticationMethod(AuthenticationMethodModel.PIN(1234))
authenticationInteractor.lockDevice() authenticationInteractor.lockDevice()
assertThat(upTransitionSceneKey).isEqualTo(SceneKey.LockScreen) assertThat(upTransitionSceneKey).isEqualTo(SceneKey.Lockscreen)
} }
@Test @Test

View File

@@ -23,7 +23,7 @@ import com.android.systemui.authentication.domain.interactor.AuthenticationInter
import com.android.systemui.bouncer.data.repo.BouncerRepository import com.android.systemui.bouncer.data.repo.BouncerRepository
import com.android.systemui.bouncer.domain.interactor.BouncerInteractor import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.bouncer.ui.viewmodel.BouncerViewModel import com.android.systemui.bouncer.ui.viewmodel.BouncerViewModel
import com.android.systemui.keyguard.domain.interactor.LockScreenSceneInteractor import com.android.systemui.keyguard.domain.interactor.LockscreenSceneInteractor
import com.android.systemui.scene.data.model.SceneContainerConfig import com.android.systemui.scene.data.model.SceneContainerConfig
import com.android.systemui.scene.data.repository.SceneContainerRepository import com.android.systemui.scene.data.repository.SceneContainerRepository
import com.android.systemui.scene.domain.interactor.SceneInteractor import com.android.systemui.scene.domain.interactor.SceneInteractor
@@ -58,7 +58,7 @@ class SceneTestUtils(
return listOf( return listOf(
SceneKey.QuickSettings, SceneKey.QuickSettings,
SceneKey.Shade, SceneKey.Shade,
SceneKey.LockScreen, SceneKey.Lockscreen,
SceneKey.Bouncer, SceneKey.Bouncer,
SceneKey.Gone, SceneKey.Gone,
) )
@@ -71,7 +71,7 @@ class SceneTestUtils(
return SceneContainerConfig( return SceneContainerConfig(
name = name, name = name,
sceneKeys = sceneKeys, sceneKeys = sceneKeys,
initialSceneKey = SceneKey.LockScreen, initialSceneKey = SceneKey.Lockscreen,
) )
} }
@@ -139,8 +139,8 @@ class SceneTestUtils(
authenticationInteractor: AuthenticationInteractor, authenticationInteractor: AuthenticationInteractor,
sceneInteractor: SceneInteractor, sceneInteractor: SceneInteractor,
bouncerInteractor: BouncerInteractor, bouncerInteractor: BouncerInteractor,
): LockScreenSceneInteractor { ): LockscreenSceneInteractor {
return LockScreenSceneInteractor( return LockscreenSceneInteractor(
applicationScope = applicationScope(), applicationScope = applicationScope(),
authenticationInteractor = authenticationInteractor, authenticationInteractor = authenticationInteractor,
bouncerInteractorFactory = bouncerInteractorFactory =