Merge changes from topics "device-entry-interactor", "make-bouncer-reusable" into main
* changes:
Remove sceneInteractor and deviceEntry dependencies from BouncerInteractor and AuthenticationInteractor
Move device unlock initiation to DeviceEntryInteractor
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/domain/interactor/BouncerActionButtonInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/domain/interactor/BouncerActionButtonInteractorTest.kt
index 15d4d20..67ce86b 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/domain/interactor/BouncerActionButtonInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/domain/interactor/BouncerActionButtonInteractorTest.kt
@@ -25,7 +25,7 @@
import com.android.internal.logging.testing.FakeMetricsLogger
import com.android.internal.util.EmergencyAffordanceManager
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.Flags.REFACTOR_GETCURRENTUSER
import com.android.systemui.log.table.TableLogBuffer
diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java
index f091558..07359d1 100644
--- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java
+++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java
@@ -60,10 +60,10 @@
import com.android.systemui.biometrics.AuthRippleController;
import com.android.systemui.biometrics.UdfpsController;
import com.android.systemui.biometrics.shared.model.UdfpsOverlayParams;
-import com.android.systemui.bouncer.domain.interactor.BouncerInteractor;
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
+import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
@@ -127,7 +127,7 @@
@NonNull private final KeyguardTransitionInteractor mTransitionInteractor;
@NonNull private final KeyguardInteractor mKeyguardInteractor;
@NonNull private final View.AccessibilityDelegate mAccessibilityDelegate;
- @NonNull private final Lazy<BouncerInteractor> mBouncerInteractor;
+ @NonNull private final Lazy<DeviceEntryInteractor> mDeviceEntryInteractor;
@NonNull private final SceneContainerFlags mSceneContainerFlags;
// Tracks the velocity of a touch to help filter out the touches that move too fast.
@@ -205,7 +205,7 @@
@NonNull FeatureFlags featureFlags,
PrimaryBouncerInteractor primaryBouncerInteractor,
Context context,
- Lazy<BouncerInteractor> bouncerInteractor,
+ Lazy<DeviceEntryInteractor> deviceEntryInteractor,
SceneContainerFlags sceneContainerFlags
) {
mStatusBarStateController = statusBarStateController;
@@ -232,7 +232,7 @@
dumpManager.registerDumpable(TAG, this);
mResources = resources;
mContext = context;
- mBouncerInteractor = bouncerInteractor;
+ mDeviceEntryInteractor = deviceEntryInteractor;
mSceneContainerFlags = sceneContainerFlags;
mAccessibilityDelegate = new View.AccessibilityDelegate() {
@@ -747,7 +747,7 @@
vibrateOnLongPress();
if (mSceneContainerFlags.isEnabled()) {
- mBouncerInteractor.get().showOrUnlockDevice(null);
+ mDeviceEntryInteractor.get().attemptDeviceEntry();
} else {
mKeyguardViewController.showPrimaryBouncer(/* scrim */ true);
}
diff --git a/packages/SystemUI/src/com/android/systemui/authentication/data/repository/AuthenticationRepository.kt b/packages/SystemUI/src/com/android/systemui/authentication/data/repository/AuthenticationRepository.kt
index e8b16db..ee3a55f 100644
--- a/packages/SystemUI/src/com/android/systemui/authentication/data/repository/AuthenticationRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/authentication/data/repository/AuthenticationRepository.kt
@@ -25,7 +25,7 @@
import com.android.internal.widget.LockPatternUtils
import com.android.internal.widget.LockscreenCredential
import com.android.keyguard.KeyguardSecurityModel
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.authentication.shared.model.AuthenticationResultModel
import com.android.systemui.authentication.shared.model.AuthenticationThrottlingModel
import com.android.systemui.broadcast.BroadcastDispatcher
@@ -45,7 +45,9 @@
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
@@ -68,6 +70,12 @@
val isAutoConfirmFeatureEnabled: StateFlow<Boolean>
/**
+ * Emits the result whenever a PIN/Pattern/Password security challenge is attempted by the user
+ * in order to unlock the device.
+ */
+ val authenticationChallengeResult: SharedFlow<Boolean>
+
+ /**
* The exact length a PIN should be for us to enable PIN length hinting.
*
* A PIN that's shorter or longer than this is not eligible for the UI to render hints showing
@@ -164,6 +172,7 @@
initialValue = false,
getFreshValue = lockPatternUtils::isAutoPinConfirmEnabled,
)
+ override val authenticationChallengeResult = MutableSharedFlow<Boolean>()
override val hintedPinLength: Int = 6
@@ -224,6 +233,7 @@
} else {
lockPatternUtils.reportFailedPasswordAttempt(selectedUserId)
}
+ authenticationChallengeResult.emit(isSuccessful)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractor.kt b/packages/SystemUI/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractor.kt
index 22b44d5..1ede530 100644
--- a/packages/SystemUI/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractor.kt
@@ -16,19 +16,16 @@
package com.android.systemui.authentication.domain.interactor
-import com.android.app.tracing.TraceUtils.Companion.async
import com.android.app.tracing.TraceUtils.Companion.withContext
import com.android.internal.widget.LockPatternView
import com.android.internal.widget.LockscreenCredential
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel as DataLayerAuthenticationMethodModel
import com.android.systemui.authentication.data.repository.AuthenticationRepository
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel as DomainLayerAuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.authentication.shared.model.AuthenticationPatternCoordinate
import com.android.systemui.authentication.shared.model.AuthenticationThrottlingModel
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
-import com.android.systemui.deviceentry.data.repository.DeviceEntryRepository
import com.android.systemui.user.data.repository.UserRepository
import com.android.systemui.util.time.SystemClock
import javax.inject.Inject
@@ -40,6 +37,7 @@
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
@@ -47,7 +45,6 @@
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
-import kotlinx.coroutines.withContext
/**
* Hosts application business logic related to user authentication.
@@ -64,7 +61,6 @@
private val repository: AuthenticationRepository,
@Background private val backgroundDispatcher: CoroutineDispatcher,
private val userRepository: UserRepository,
- private val deviceEntryRepository: DeviceEntryRepository,
private val clock: SystemClock,
) {
/**
@@ -85,8 +81,7 @@
* `true` even when the lockscreen is showing and still needs to be dismissed by the user to
* proceed.
*/
- val authenticationMethod: Flow<DomainLayerAuthenticationMethodModel> =
- repository.authenticationMethod.map { rawModel -> rawModel.toDomainLayer() }
+ val authenticationMethod: Flow<AuthenticationMethodModel> = repository.authenticationMethod
/** The current authentication throttling state, only meaningful if [isThrottled] is `true`. */
val throttling: StateFlow<AuthenticationThrottlingModel> = repository.throttling
@@ -143,6 +138,13 @@
/** Whether the pattern should be visible for the currently-selected user. */
val isPatternVisible: StateFlow<Boolean> = repository.isPatternVisible
+ /**
+ * Emits the outcome (successful or unsuccessful) whenever a PIN/Pattern/Password security
+ * challenge is attempted by the user in order to unlock the device.
+ */
+ val authenticationChallengeResult: SharedFlow<Boolean> =
+ repository.authenticationChallengeResult
+
private var throttlingCountdownJob: Job? = null
init {
@@ -165,17 +167,8 @@
* The flow should be used for code that wishes to stay up-to-date its logic as the
* authentication changes over time and this method should be used for simple code that only
* needs to check the current value.
- *
- * Note: this layer adds the synthetic authentication method of "swipe" which is special. When
- * the current authentication method is "swipe", the user does not need to complete any
- * authentication challenge to unlock the device; they just need to dismiss the lockscreen to
- * get past it. This also means that the value of `DeviceEntryInteractor#isUnlocked` remains
- * `true` even when the lockscreen is showing and still needs to be dismissed by the user to
- * proceed.
*/
- suspend fun getAuthenticationMethod(): DomainLayerAuthenticationMethodModel {
- return repository.getAuthenticationMethod().toDomainLayer()
- }
+ suspend fun getAuthenticationMethod() = repository.getAuthenticationMethod()
/**
* Attempts to authenticate the user and unlock the device.
@@ -205,13 +198,13 @@
// attempt.
isThrottled.value -> true
// The pattern is too short; skip the attempt.
- authMethod == DomainLayerAuthenticationMethodModel.Pattern &&
+ authMethod == AuthenticationMethodModel.Pattern &&
input.size < repository.minPatternLength -> true
// Auto-confirm attempt when the feature is not enabled; skip the attempt.
tryAutoConfirm && !isAutoConfirmEnabled.value -> true
// Auto-confirm should skip the attempt if the pin entered is too short.
tryAutoConfirm &&
- authMethod == DomainLayerAuthenticationMethodModel.Pin &&
+ authMethod == AuthenticationMethodModel.Pin &&
input.size < repository.getPinLength() -> true
else -> false
}
@@ -297,15 +290,15 @@
}
}
- private fun DomainLayerAuthenticationMethodModel.createCredential(
+ private fun AuthenticationMethodModel.createCredential(
input: List<Any>
): LockscreenCredential? {
return when (this) {
- is DomainLayerAuthenticationMethodModel.Pin ->
+ is AuthenticationMethodModel.Pin ->
LockscreenCredential.createPin(input.joinToString(""))
- is DomainLayerAuthenticationMethodModel.Password ->
+ is AuthenticationMethodModel.Password ->
LockscreenCredential.createPassword(input.joinToString(""))
- is DomainLayerAuthenticationMethodModel.Pattern ->
+ is AuthenticationMethodModel.Pattern ->
LockscreenCredential.createPattern(
input
.map { it as AuthenticationPatternCoordinate }
@@ -315,23 +308,6 @@
}
}
- private suspend fun DataLayerAuthenticationMethodModel.toDomainLayer():
- DomainLayerAuthenticationMethodModel {
- return when (this) {
- is DataLayerAuthenticationMethodModel.None ->
- if (deviceEntryRepository.isInsecureLockscreenEnabled()) {
- DomainLayerAuthenticationMethodModel.Swipe
- } else {
- DomainLayerAuthenticationMethodModel.None
- }
- is DataLayerAuthenticationMethodModel.Pin -> DomainLayerAuthenticationMethodModel.Pin
- is DataLayerAuthenticationMethodModel.Password ->
- DomainLayerAuthenticationMethodModel.Password
- is DataLayerAuthenticationMethodModel.Pattern ->
- DomainLayerAuthenticationMethodModel.Pattern
- }
- }
-
companion object {
const val TAG = "AuthenticationInteractor"
}
diff --git a/packages/SystemUI/src/com/android/systemui/authentication/domain/model/AuthenticationMethodModel.kt b/packages/SystemUI/src/com/android/systemui/authentication/domain/model/AuthenticationMethodModel.kt
deleted file mode 100644
index d7e6099..0000000
--- a/packages/SystemUI/src/com/android/systemui/authentication/domain/model/AuthenticationMethodModel.kt
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2023 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.systemui.authentication.domain.model
-
-/** Enumerates all known authentication methods. */
-sealed class AuthenticationMethodModel(
- /**
- * Whether the authentication method is considered to be "secure".
- *
- * "Secure" authentication methods require authentication to unlock the device. Non-secure auth
- * methods simply require user dismissal.
- */
- open val isSecure: Boolean,
-) {
- /** There is no authentication method on the device. We shouldn't even show the lock screen. */
- object None : AuthenticationMethodModel(isSecure = false)
-
- /** The most basic authentication method. The lock screen can be swiped away when displayed. */
- object Swipe : AuthenticationMethodModel(isSecure = false)
-
- object Pin : AuthenticationMethodModel(isSecure = true)
-
- object Password : AuthenticationMethodModel(isSecure = true)
-
- object Pattern : AuthenticationMethodModel(isSecure = true)
-}
diff --git a/packages/SystemUI/src/com/android/systemui/authentication/data/model/AuthenticationMethodModel.kt b/packages/SystemUI/src/com/android/systemui/authentication/shared/model/AuthenticationMethodModel.kt
similarity index 81%
rename from packages/SystemUI/src/com/android/systemui/authentication/data/model/AuthenticationMethodModel.kt
rename to packages/SystemUI/src/com/android/systemui/authentication/shared/model/AuthenticationMethodModel.kt
index 6d23b11..bb5b81d 100644
--- a/packages/SystemUI/src/com/android/systemui/authentication/data/model/AuthenticationMethodModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/authentication/shared/model/AuthenticationMethodModel.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2023 The Android Open Source Project
+ * Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.systemui.authentication.data.model
+package com.android.systemui.authentication.shared.model
/** Enumerates all known authentication methods. */
sealed class AuthenticationMethodModel(
@@ -26,7 +26,10 @@
*/
open val isSecure: Boolean,
) {
- /** There is no authentication method on the device. We shouldn't even show the lock screen. */
+ /**
+ * Device doesn't use a secure authentication method. Either there is no lockscreen or the lock
+ * screen can be swiped away when displayed.
+ */
object None : AuthenticationMethodModel(isSecure = false)
object Pin : AuthenticationMethodModel(isSecure = true)
diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt b/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt
index b9a913e..4e1cddc 100644
--- a/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt
@@ -19,24 +19,22 @@
import android.content.Context
import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor
import com.android.systemui.authentication.domain.interactor.AuthenticationResult
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.authentication.shared.model.AuthenticationThrottlingModel
import com.android.systemui.bouncer.data.repository.BouncerRepository
import com.android.systemui.classifier.FalsingClassifier
import com.android.systemui.classifier.domain.interactor.FalsingInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
-import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
import com.android.systemui.res.R
-import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.flag.SceneContainerFlags
-import com.android.systemui.scene.shared.model.SceneKey
-import com.android.systemui.scene.shared.model.SceneModel
import com.android.systemui.util.kotlin.pairwise
import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.async
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
@@ -51,9 +49,7 @@
@Application private val applicationScope: CoroutineScope,
@Application private val applicationContext: Context,
private val repository: BouncerRepository,
- private val deviceEntryInteractor: DeviceEntryInteractor,
private val authenticationInteractor: AuthenticationInteractor,
- private val sceneInteractor: SceneInteractor,
flags: SceneContainerFlags,
private val falsingInteractor: FalsingInteractor,
) {
@@ -100,6 +96,10 @@
val isUserSwitcherVisible: Boolean
get() = repository.isUserSwitcherVisible
+ private val _onImeHidden = MutableSharedFlow<Unit>()
+ /** Provide the onImeHidden events from the bouncer */
+ val onImeHidden: SharedFlow<Unit> = _onImeHidden
+
init {
if (flags.isEnabled()) {
// Clear the message if moved from throttling to no-longer throttling.
@@ -142,32 +142,6 @@
}
/**
- * Either shows the bouncer or unlocks the device, if the bouncer doesn't need to be shown.
- *
- * @param message An optional message to show to the user in the bouncer.
- */
- fun showOrUnlockDevice(
- message: String? = null,
- ) {
- applicationScope.launch {
- if (deviceEntryInteractor.isAuthenticationRequired()) {
- repository.setMessage(
- message ?: promptMessage(authenticationInteractor.getAuthenticationMethod())
- )
- sceneInteractor.changeScene(
- scene = SceneModel(SceneKey.Bouncer),
- loggingReason = "request to unlock device while authentication required",
- )
- } else {
- sceneInteractor.changeScene(
- scene = SceneModel(SceneKey.Gone),
- loggingReason = "request to unlock device while authentication isn't required",
- )
- }
- }
- }
-
- /**
* Resets the user-facing message back to the default according to the current authentication
* method.
*/
@@ -212,17 +186,11 @@
return applicationScope
.async {
val authResult = authenticationInteractor.authenticate(input, tryAutoConfirm)
- when (authResult) {
- // Authentication succeeded.
- AuthenticationResult.SUCCEEDED ->
- sceneInteractor.changeScene(
- scene = SceneModel(SceneKey.Gone),
- loggingReason = "successful authentication",
- )
- // Authentication failed.
- AuthenticationResult.FAILED -> showErrorMessage()
- // Authentication skipped.
- AuthenticationResult.SKIPPED -> if (!tryAutoConfirm) showErrorMessage()
+ if (
+ authResult == AuthenticationResult.FAILED ||
+ (authResult == AuthenticationResult.SKIPPED && !tryAutoConfirm)
+ ) {
+ showErrorMessage()
}
authResult
}
@@ -242,16 +210,8 @@
}
/** Notifies the interactor that the input method editor has been hidden. */
- fun onImeHidden() {
- // If the bouncer is showing, hide it and return to the lockscreen scene.
- if (sceneInteractor.desiredScene.value.key != SceneKey.Bouncer) {
- return
- }
-
- sceneInteractor.changeScene(
- scene = SceneModel(SceneKey.Lockscreen),
- loggingReason = "IME hidden",
- )
+ suspend fun onImeHidden() {
+ _onImeHidden.emit(Unit)
}
private fun promptMessage(authMethod: AuthenticationMethodModel): String {
diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/AuthMethodBouncerViewModel.kt b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/AuthMethodBouncerViewModel.kt
index 55bc653..f46574c 100644
--- a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/AuthMethodBouncerViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/AuthMethodBouncerViewModel.kt
@@ -18,7 +18,7 @@
import android.annotation.StringRes
import com.android.systemui.authentication.domain.interactor.AuthenticationResult
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.MutableStateFlow
@@ -75,7 +75,7 @@
* Notifies that the input method editor (for example, the software keyboard) has been shown or
* hidden.
*/
- fun onImeVisibilityChanged(isVisible: Boolean) {
+ suspend fun onImeVisibilityChanged(isVisible: Boolean) {
if (isImeVisible && !isVisible) {
interactor.onImeHidden()
}
diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt
index 4767e21..09c94c8 100644
--- a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt
@@ -20,7 +20,7 @@
import android.graphics.Bitmap
import androidx.core.graphics.drawable.toBitmap
import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.bouncer.domain.interactor.BouncerActionButtonInteractor
import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.bouncer.shared.model.BouncerActionButtonModel
diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModel.kt b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModel.kt
index fe77419..a15698e 100644
--- a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModel.kt
@@ -16,7 +16,7 @@
package com.android.systemui.bouncer.ui.viewmodel
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.res.R
import kotlinx.coroutines.CoroutineScope
diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModel.kt b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModel.kt
index d301085..ed6a48f 100644
--- a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModel.kt
@@ -18,7 +18,7 @@
import android.content.Context
import android.util.TypedValue
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.authentication.shared.model.AuthenticationPatternCoordinate
import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.res.R
diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModel.kt b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModel.kt
index b90e255..2ed0d5d 100644
--- a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModel.kt
@@ -18,7 +18,7 @@
import android.content.Context
import com.android.keyguard.PinShapeAdapter
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.res.R
import kotlinx.coroutines.CoroutineScope
diff --git a/packages/SystemUI/src/com/android/systemui/deviceentry/data/repository/DeviceEntryRepository.kt b/packages/SystemUI/src/com/android/systemui/deviceentry/data/repository/DeviceEntryRepository.kt
index 1e29e1f..f27bbe6 100644
--- a/packages/SystemUI/src/com/android/systemui/deviceentry/data/repository/DeviceEntryRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/deviceentry/data/repository/DeviceEntryRepository.kt
@@ -1,5 +1,6 @@
package com.android.systemui.deviceentry.data.repository
+import android.util.Log
import com.android.internal.widget.LockPatternUtils
import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
@@ -15,9 +16,12 @@
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.awaitClose
+import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.distinctUntilChanged
+import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.withContext
@@ -35,10 +39,14 @@
val isUnlocked: StateFlow<Boolean>
/**
- * Whether the lockscreen should be shown when the authentication method is not secure (e.g.
- * `None` or `Swipe`).
+ * Whether the lockscreen is enabled for the current user. This is `true` whenever the user has
+ * chosen any secure authentication method and even if they set the lockscreen to be dismissed
+ * when the user swipes on it.
*/
- suspend fun isInsecureLockscreenEnabled(): Boolean
+ suspend fun isLockscreenEnabled(): Boolean
+
+ /** Report successful authentication for device entry. */
+ fun reportSuccessfulAuthentication()
/**
* Whether lockscreen bypass is enabled. When enabled, the lockscreen will be automatically
@@ -67,7 +75,9 @@
keyguardStateController: KeyguardStateController,
) : DeviceEntryRepository {
- override val isUnlocked =
+ private val _isUnlocked = MutableStateFlow(false)
+
+ private val isUnlockedReportedByLegacyKeyguard =
conflatedCallbackFlow {
val callback =
object : KeyguardStateController.Callback {
@@ -99,19 +109,27 @@
awaitClose { keyguardStateController.removeCallback(callback) }
}
.distinctUntilChanged()
+ .onEach { _isUnlocked.value = it }
.stateIn(
applicationScope,
SharingStarted.Eagerly,
initialValue = false,
)
- override suspend fun isInsecureLockscreenEnabled(): Boolean {
+ override val isUnlocked: StateFlow<Boolean> = _isUnlocked.asStateFlow()
+
+ override suspend fun isLockscreenEnabled(): Boolean {
return withContext(backgroundDispatcher) {
val selectedUserId = userRepository.getSelectedUserInfo().id
!lockPatternUtils.isLockScreenDisabled(selectedUserId)
}
}
+ override fun reportSuccessfulAuthentication() {
+ Log.d(TAG, "Successful authentication reported.")
+ _isUnlocked.value = true
+ }
+
override val isBypassEnabled: StateFlow<Boolean> =
conflatedCallbackFlow {
val listener =
diff --git a/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractor.kt b/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractor.kt
index e872d13..c3f3529 100644
--- a/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractor.kt
@@ -17,23 +17,28 @@
package com.android.systemui.deviceentry.domain.interactor
import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.data.repository.DeviceEntryRepository
import com.android.systemui.keyguard.data.repository.DeviceEntryFaceAuthRepository
import com.android.systemui.keyguard.data.repository.TrustRepository
import com.android.systemui.scene.domain.interactor.SceneInteractor
+import com.android.systemui.scene.shared.flag.SceneContainerFlags
import com.android.systemui.scene.shared.model.SceneKey
+import com.android.systemui.scene.shared.model.SceneModel
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
+import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
+import kotlinx.coroutines.launch
/**
* Hosts application business logic related to device entry.
@@ -48,9 +53,10 @@
@Application private val applicationScope: CoroutineScope,
repository: DeviceEntryRepository,
private val authenticationInteractor: AuthenticationInteractor,
- sceneInteractor: SceneInteractor,
+ private val sceneInteractor: SceneInteractor,
deviceEntryFaceAuthRepository: DeviceEntryFaceAuthRepository,
trustRepository: TrustRepository,
+ flags: SceneContainerFlags,
) {
/**
* Whether the device is unlocked.
@@ -90,28 +96,33 @@
.map { it == SceneKey.Gone }
.stateIn(
scope = applicationScope,
- started = SharingStarted.WhileSubscribed(),
+ started = SharingStarted.Eagerly,
initialValue = false,
)
// Authenticated by a TrustAgent like trusted device, location, etc or by face auth.
private val passivelyAuthenticated =
merge(
- trustRepository.isCurrentUserTrusted,
- deviceEntryFaceAuthRepository.isAuthenticated,
- )
+ trustRepository.isCurrentUserTrusted,
+ deviceEntryFaceAuthRepository.isAuthenticated,
+ )
+ .onStart { emit(false) }
/**
* Whether it's currently possible to swipe up to enter the device without requiring
- * authentication. This returns `false` whenever the lockscreen has been dismissed.
+ * authentication or when the device is already authenticated using a passive authentication
+ * mechanism like face or trust manager. This returns `false` whenever the lockscreen has been
+ * dismissed.
*
* Note: `true` doesn't mean the lockscreen is visible. It may be occluded or covered by other
* UI.
*/
val canSwipeToEnter =
combine(
+ // This is true when the user has chosen to show the lockscreen but has not made it
+ // secure.
authenticationInteractor.authenticationMethod.map {
- it == AuthenticationMethodModel.Swipe
+ it == AuthenticationMethodModel.None && repository.isLockscreenEnabled()
},
passivelyAuthenticated,
isDeviceEntered
@@ -120,11 +131,37 @@
}
.stateIn(
scope = applicationScope,
- started = SharingStarted.WhileSubscribed(),
+ started = SharingStarted.Eagerly,
initialValue = false,
)
/**
+ * Attempt to enter the device and dismiss the lockscreen. If authentication is required to
+ * unlock the device it will transition to bouncer.
+ */
+ fun attemptDeviceEntry() {
+ // TODO (b/307768356),
+ // 1. Check if the device is already authenticated by trust agent/passive biometrics
+ // 2. show SPFS/UDFPS bouncer if it is available AlternateBouncerInteractor.show
+ // 3. For face auth only setups trigger face auth, delay transitioning to bouncer for
+ // a small amount of time.
+ // 4. Transition to bouncer scene
+ applicationScope.launch {
+ if (isAuthenticationRequired()) {
+ sceneInteractor.changeScene(
+ scene = SceneModel(SceneKey.Bouncer),
+ loggingReason = "request to unlock device while authentication required",
+ )
+ } else {
+ sceneInteractor.changeScene(
+ scene = SceneModel(SceneKey.Gone),
+ loggingReason = "request to unlock device while authentication isn't required",
+ )
+ }
+ }
+ }
+
+ /**
* Returns `true` if the device currently requires authentication before entry is granted;
* `false` if the device can be entered without authenticating first.
*/
@@ -133,10 +170,22 @@
}
/**
- * Whether lock screen bypass is enabled. When enabled, the lock screen will be automatically
+ * Whether lockscreen bypass is enabled. When enabled, the lockscreen will be automatically
* dismissed once the authentication challenge is completed. For example, completing a biometric
* authentication challenge via face unlock or fingerprint sensor can automatically bypass the
- * lock screen.
+ * lockscreen.
*/
val isBypassEnabled: StateFlow<Boolean> = repository.isBypassEnabled
+
+ init {
+ if (flags.isEnabled()) {
+ applicationScope.launch {
+ authenticationInteractor.authenticationChallengeResult.collectLatest { successful ->
+ if (successful) {
+ repository.reportSuccessfulAuthentication()
+ }
+ }
+ }
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt
index 9edd2c6..5993cf1 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModel.kt
@@ -16,8 +16,8 @@
package com.android.systemui.qs.ui.viewmodel
-import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
import com.android.systemui.shade.ui.viewmodel.ShadeHeaderViewModel
import javax.inject.Inject
@@ -26,11 +26,9 @@
class QuickSettingsSceneViewModel
@Inject
constructor(
- private val bouncerInteractor: BouncerInteractor,
+ private val deviceEntryInteractor: DeviceEntryInteractor,
val shadeHeaderViewModel: ShadeHeaderViewModel,
) {
/** Notifies that some content in quick settings was clicked. */
- fun onContentClicked() {
- bouncerInteractor.showOrUnlockDevice()
- }
+ fun onContentClicked() = deviceEntryInteractor.attemptDeviceEntry()
}
diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt
index 91b4d17..ca2828b 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/SceneContainerStartable.kt
@@ -19,8 +19,7 @@
package com.android.systemui.scene.domain.startable
import com.android.systemui.CoreStartable
-import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel
+import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.classifier.FalsingCollector
import com.android.systemui.classifier.FalsingCollectorActual
import com.android.systemui.dagger.SysUISingleton
@@ -45,6 +44,7 @@
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.distinctUntilChangedBy
import kotlinx.coroutines.flow.emptyFlow
@@ -64,7 +64,7 @@
@Application private val applicationScope: CoroutineScope,
private val sceneInteractor: SceneInteractor,
private val deviceEntryInteractor: DeviceEntryInteractor,
- private val authenticationInteractor: AuthenticationInteractor,
+ private val bouncerInteractor: BouncerInteractor,
private val keyguardInteractor: KeyguardInteractor,
private val flags: SceneContainerFlags,
private val sysUiState: SysUiState,
@@ -121,6 +121,17 @@
/** Switches between scenes based on ever-changing application state. */
private fun automaticallySwitchScenes() {
applicationScope.launch {
+ // TODO (b/308001302): Move this to a bouncer specific interactor.
+ bouncerInteractor.onImeHidden.collectLatest {
+ if (sceneInteractor.desiredScene.value.key == SceneKey.Bouncer) {
+ sceneInteractor.changeScene(
+ scene = SceneModel(SceneKey.Lockscreen),
+ loggingReason = "IME hidden",
+ )
+ }
+ }
+ }
+ applicationScope.launch {
deviceEntryInteractor.isUnlocked
.mapNotNull { isUnlocked ->
val renderedScenes =
@@ -132,41 +143,41 @@
transitionState.toScene,
)
}
+ val isOnLockscreen = renderedScenes.contains(SceneKey.Lockscreen)
+ val isOnBouncer = renderedScenes.contains(SceneKey.Bouncer)
+ if (!isUnlocked) {
+ return@mapNotNull if (isOnLockscreen || isOnBouncer) {
+ // Already on lockscreen or bouncer, no need to change scenes.
+ null
+ } else {
+ // The device locked while on a scene that's not Lockscreen or Bouncer,
+ // go to Lockscreen.
+ SceneKey.Lockscreen to
+ "device locked in non-Lockscreen and non-Bouncer scene"
+ }
+ }
+
+ val isBypassEnabled = deviceEntryInteractor.isBypassEnabled.value
+ val canSwipeToEnter = deviceEntryInteractor.canSwipeToEnter.value
when {
- isUnlocked ->
- when {
- // When the device becomes unlocked in Bouncer, go to Gone.
- renderedScenes.contains(SceneKey.Bouncer) ->
- SceneKey.Gone to "device unlocked in Bouncer scene"
-
- // When the device becomes unlocked in Lockscreen, go to Gone if
- // bypass is enabled.
- renderedScenes.contains(SceneKey.Lockscreen) ->
- if (deviceEntryInteractor.isBypassEnabled.value) {
- SceneKey.Gone to
- "device unlocked in Lockscreen scene with bypass"
- } else {
- null
- }
-
- // We got unlocked while on a scene that's not Lockscreen or
- // Bouncer, no need to change scenes.
- else -> null
- }
-
- // When the device becomes locked, to Lockscreen.
- !isUnlocked ->
- when {
- // Already on lockscreen or bouncer, no need to change scenes.
- renderedScenes.contains(SceneKey.Lockscreen) ||
- renderedScenes.contains(SceneKey.Bouncer) -> null
-
- // We got locked while on a scene that's not Lockscreen or Bouncer,
- // go to Lockscreen.
- else ->
- SceneKey.Lockscreen to
- "device locked in non-Lockscreen and non-Bouncer scene"
- }
+ isOnBouncer ->
+ // When the device becomes unlocked in Bouncer, go to Gone.
+ SceneKey.Gone to "device was unlocked in Bouncer scene"
+ isOnLockscreen ->
+ // The lockscreen should be dismissed automatically in 2 scenarios:
+ // 1. When face auth bypass is enabled and authentication happens while
+ // the user is on the lockscreen.
+ // 2. Whenever the user authenticates using an active authentication
+ // mechanism like fingerprint auth. Since canSwipeToEnter is true
+ // when the user is passively authenticated, the false value here
+ // when the unlock state changes indicates this is an active
+ // authentication attempt.
+ if (isBypassEnabled || !canSwipeToEnter)
+ SceneKey.Gone to
+ "device has been unlocked on lockscreen with either " +
+ "bypass enabled or using an active authentication mechanism"
+ else null
+ // Not on lockscreen or bouncer, so remain in the current scene.
else -> null
}
}
@@ -186,24 +197,15 @@
loggingReason = "device is starting to sleep",
)
} else {
- val authMethod = authenticationInteractor.getAuthenticationMethod()
+ val canSwipeToEnter = deviceEntryInteractor.canSwipeToEnter.value
val isUnlocked = deviceEntryInteractor.isUnlocked.value
- when {
- authMethod == AuthenticationMethodModel.None -> {
- switchToScene(
- targetSceneKey = SceneKey.Gone,
- loggingReason =
- "device is starting to wake up while auth method is" + " none",
- )
- }
- authMethod.isSecure && isUnlocked -> {
- switchToScene(
- targetSceneKey = SceneKey.Gone,
- loggingReason =
- "device is starting to wake up while unlocked with a" +
- " secure auth method",
- )
- }
+ if (isUnlocked && !canSwipeToEnter) {
+ switchToScene(
+ targetSceneKey = SceneKey.Gone,
+ loggingReason =
+ "device is waking up while unlocked without the ability" +
+ " to swipe up on lockscreen to enter.",
+ )
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
index 9c5a201..20b9ede 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
@@ -16,7 +16,6 @@
package com.android.systemui.shade.ui.viewmodel
-import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
@@ -34,8 +33,7 @@
@Inject
constructor(
@Application private val applicationScope: CoroutineScope,
- deviceEntryInteractor: DeviceEntryInteractor,
- private val bouncerInteractor: BouncerInteractor,
+ private val deviceEntryInteractor: DeviceEntryInteractor,
val shadeHeaderViewModel: ShadeHeaderViewModel,
) {
/** The key of the scene we should switch to when swiping up. */
@@ -60,9 +58,7 @@
)
/** Notifies that some content in the shade was clicked. */
- fun onContentClicked() {
- bouncerInteractor.showOrUnlockDevice()
- }
+ fun onContentClicked() = deviceEntryInteractor.attemptDeviceEntry()
private fun upDestinationSceneKey(
isUnlocked: Boolean,
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java
index 1d4f2cb..d2f45ae 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerBaseTest.java
@@ -42,8 +42,8 @@
import com.android.systemui.SysuiTestCase;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.biometrics.AuthRippleController;
-import com.android.systemui.bouncer.domain.interactor.BouncerInteractor;
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor;
+import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor;
import com.android.systemui.doze.util.BurnInHelperKt;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FakeFeatureFlags;
@@ -78,7 +78,7 @@
protected MockitoSession mStaticMockSession;
protected final SceneTestUtils mSceneTestUtils = new SceneTestUtils(this);
- protected @Mock BouncerInteractor mBouncerInteractor;
+ protected @Mock DeviceEntryInteractor mDeviceEntryInteractor;
protected @Mock LockIconView mLockIconView;
protected @Mock AnimatedStateListDrawable mIconDrawable;
protected @Mock Context mContext;
@@ -176,7 +176,7 @@
mFeatureFlags,
mPrimaryBouncerInteractor,
mContext,
- () -> mBouncerInteractor,
+ () -> mDeviceEntryInteractor,
mSceneTestUtils.getSceneContainerFlags()
);
}
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerTest.java
index adcec10..93a5393 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/LockIconViewControllerTest.java
@@ -381,7 +381,7 @@
// THEN show primary bouncer via keyguard view controller, not scene container
verify(mKeyguardViewController).showPrimaryBouncer(anyBoolean());
- verify(mBouncerInteractor, never()).showOrUnlockDevice(any());
+ verify(mDeviceEntryInteractor, never()).attemptDeviceEntry();
}
@Test
@@ -395,7 +395,7 @@
// THEN show primary bouncer
verify(mKeyguardViewController, never()).showPrimaryBouncer(anyBoolean());
- verify(mBouncerInteractor).showOrUnlockDevice(any());
+ verify(mDeviceEntryInteractor).attemptDeviceEntry();
}
@Test
@@ -408,6 +408,7 @@
mUnderTest.onLongPress();
// THEN don't show primary bouncer
- verify(mBouncerInteractor, never()).showOrUnlockDevice(any());
+ verify(mDeviceEntryInteractor, never()).attemptDeviceEntry();
+ verify(mKeyguardViewController, never()).showPrimaryBouncer(anyBoolean());
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/authentication/data/repository/AuthenticationRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/authentication/data/repository/AuthenticationRepositoryTest.kt
index 0c06808..ae2ec2c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/authentication/data/repository/AuthenticationRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/authentication/data/repository/AuthenticationRepositoryTest.kt
@@ -26,7 +26,7 @@
import com.android.internal.widget.LockPatternUtils
import com.android.keyguard.KeyguardSecurityModel
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.scene.SceneTestUtils
@@ -127,6 +127,22 @@
assertThat(values.last()).isTrue()
}
+ @Test
+ fun reportAuthenticationAttempt_emitsAuthenticationChallengeResult() =
+ testScope.runTest {
+ val authenticationChallengeResults by
+ collectValues(underTest.authenticationChallengeResult)
+
+ runCurrent()
+ underTest.reportAuthenticationAttempt(true)
+ runCurrent()
+ underTest.reportAuthenticationAttempt(false)
+ runCurrent()
+ underTest.reportAuthenticationAttempt(true)
+
+ assertThat(authenticationChallengeResults).isEqualTo(listOf(true, false, true))
+ }
+
private fun setSecurityModeAndDispatchBroadcast(
securityMode: KeyguardSecurityModel.SecurityMode,
) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractorTest.kt
index 103f2b8..7439db2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/authentication/domain/interactor/AuthenticationInteractorTest.kt
@@ -20,9 +20,8 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel as DataLayerAuthenticationMethodModel
import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel as DomainLayerAuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.authentication.shared.model.AuthenticationPatternCoordinate
import com.android.systemui.authentication.shared.model.AuthenticationThrottlingModel
import com.android.systemui.coroutines.collectLastValue
@@ -51,33 +50,16 @@
testScope.runTest {
val authMethod by collectLastValue(underTest.authenticationMethod)
runCurrent()
- assertThat(authMethod).isEqualTo(DomainLayerAuthenticationMethodModel.Pin)
- assertThat(underTest.getAuthenticationMethod())
- .isEqualTo(DomainLayerAuthenticationMethodModel.Pin)
+ assertThat(authMethod).isEqualTo(AuthenticationMethodModel.Pin)
+ assertThat(underTest.getAuthenticationMethod()).isEqualTo(AuthenticationMethodModel.Pin)
utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Password
+ AuthenticationMethodModel.Password
)
- assertThat(authMethod).isEqualTo(DomainLayerAuthenticationMethodModel.Password)
+ assertThat(authMethod).isEqualTo(AuthenticationMethodModel.Password)
assertThat(underTest.getAuthenticationMethod())
- .isEqualTo(DomainLayerAuthenticationMethodModel.Password)
- }
-
- @Test
- fun authenticationMethod_noneTreatedAsSwipe_whenLockscreenEnabled() =
- testScope.runTest {
- val authMethod by collectLastValue(underTest.authenticationMethod)
- runCurrent()
-
- utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.None
- )
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
-
- assertThat(authMethod).isEqualTo(DomainLayerAuthenticationMethodModel.Swipe)
- assertThat(underTest.getAuthenticationMethod())
- .isEqualTo(DomainLayerAuthenticationMethodModel.Swipe)
+ .isEqualTo(AuthenticationMethodModel.Password)
}
@Test
@@ -86,23 +68,18 @@
val authMethod by collectLastValue(underTest.authenticationMethod)
runCurrent()
- utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.None
- )
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(false)
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
- assertThat(authMethod).isEqualTo(DomainLayerAuthenticationMethodModel.None)
+ assertThat(authMethod).isEqualTo(AuthenticationMethodModel.None)
assertThat(underTest.getAuthenticationMethod())
- .isEqualTo(DomainLayerAuthenticationMethodModel.None)
+ .isEqualTo(AuthenticationMethodModel.None)
}
@Test
fun authenticate_withCorrectPin_returnsTrue() =
testScope.runTest {
val isThrottled by collectLastValue(underTest.isThrottled)
- utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Pin
- )
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
assertThat(underTest.authenticate(FakeAuthenticationRepository.DEFAULT_PIN))
.isEqualTo(AuthenticationResult.SUCCEEDED)
assertThat(isThrottled).isFalse()
@@ -111,9 +88,7 @@
@Test
fun authenticate_withIncorrectPin_returnsFalse() =
testScope.runTest {
- utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Pin
- )
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
assertThat(underTest.authenticate(listOf(9, 8, 7, 6, 5, 4)))
.isEqualTo(AuthenticationResult.FAILED)
}
@@ -121,9 +96,7 @@
@Test(expected = IllegalArgumentException::class)
fun authenticate_withEmptyPin_throwsException() =
testScope.runTest {
- utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Pin
- )
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
underTest.authenticate(listOf())
}
@@ -132,7 +105,7 @@
testScope.runTest {
val pin = List(16) { 9 }
utils.authenticationRepository.apply {
- setAuthenticationMethod(DataLayerAuthenticationMethodModel.Pin)
+ setAuthenticationMethod(AuthenticationMethodModel.Pin)
overrideCredential(pin)
}
@@ -148,9 +121,7 @@
// If the policy changes, there is work to do in SysUI.
assertThat(DevicePolicyManager.MAX_PASSWORD_LENGTH).isLessThan(17)
- utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Pin
- )
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
assertThat(underTest.authenticate(List(17) { 9 }))
.isEqualTo(AuthenticationResult.FAILED)
}
@@ -160,7 +131,7 @@
testScope.runTest {
val isThrottled by collectLastValue(underTest.isThrottled)
utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Password
+ AuthenticationMethodModel.Password
)
assertThat(underTest.authenticate("password".toList()))
@@ -172,7 +143,7 @@
fun authenticate_withIncorrectPassword_returnsFalse() =
testScope.runTest {
utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Password
+ AuthenticationMethodModel.Password
)
assertThat(underTest.authenticate("alohomora".toList()))
@@ -183,7 +154,7 @@
fun authenticate_withCorrectPattern_returnsTrue() =
testScope.runTest {
utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Pattern
+ AuthenticationMethodModel.Pattern
)
assertThat(underTest.authenticate(FakeAuthenticationRepository.PATTERN))
@@ -194,7 +165,7 @@
fun authenticate_withIncorrectPattern_returnsFalse() =
testScope.runTest {
utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Pattern
+ AuthenticationMethodModel.Pattern
)
assertThat(
@@ -211,12 +182,12 @@
}
@Test
- fun tryAutoConfirm_withAutoConfirmPinAndShorterPin_returnsNullAndHasNoEffect() =
+ fun tryAutoConfirm_withAutoConfirmPinAndShorterPin_returnsNull() =
testScope.runTest {
val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled)
val isThrottled by collectLastValue(underTest.isThrottled)
utils.authenticationRepository.apply {
- setAuthenticationMethod(DataLayerAuthenticationMethodModel.Pin)
+ setAuthenticationMethod(AuthenticationMethodModel.Pin)
setAutoConfirmFeatureEnabled(true)
}
assertThat(isAutoConfirmEnabled).isTrue()
@@ -234,11 +205,11 @@
}
@Test
- fun tryAutoConfirm_withAutoConfirmWrongPinCorrectLength_returnsFalseAndDoesNotUnlockDevice() =
+ fun tryAutoConfirm_withAutoConfirmWrongPinCorrectLength_returnsFalse() =
testScope.runTest {
val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled)
utils.authenticationRepository.apply {
- setAuthenticationMethod(DataLayerAuthenticationMethodModel.Pin)
+ setAuthenticationMethod(AuthenticationMethodModel.Pin)
setAutoConfirmFeatureEnabled(true)
}
assertThat(isAutoConfirmEnabled).isTrue()
@@ -250,16 +221,14 @@
)
)
.isEqualTo(AuthenticationResult.FAILED)
- val isUnlocked by collectLastValue(utils.deviceEntryRepository.isUnlocked)
- assertThat(isUnlocked).isFalse()
}
@Test
- fun tryAutoConfirm_withAutoConfirmLongerPin_returnsFalseAndDoesNotUnlockDevice() =
+ fun tryAutoConfirm_withAutoConfirmLongerPin_returnsFalse() =
testScope.runTest {
val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled)
utils.authenticationRepository.apply {
- setAuthenticationMethod(DataLayerAuthenticationMethodModel.Pin)
+ setAuthenticationMethod(AuthenticationMethodModel.Pin)
setAutoConfirmFeatureEnabled(true)
}
assertThat(isAutoConfirmEnabled).isTrue()
@@ -271,16 +240,14 @@
)
)
.isEqualTo(AuthenticationResult.FAILED)
- val isUnlocked by collectLastValue(utils.deviceEntryRepository.isUnlocked)
- assertThat(isUnlocked).isFalse()
}
@Test
- fun tryAutoConfirm_withAutoConfirmCorrectPin_returnsTrueAndUnlocksDevice() =
+ fun tryAutoConfirm_withAutoConfirmCorrectPin_returnsTrue() =
testScope.runTest {
val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled)
utils.authenticationRepository.apply {
- setAuthenticationMethod(DataLayerAuthenticationMethodModel.Pin)
+ setAuthenticationMethod(AuthenticationMethodModel.Pin)
setAutoConfirmFeatureEnabled(true)
}
assertThat(isAutoConfirmEnabled).isTrue()
@@ -292,18 +259,16 @@
)
)
.isEqualTo(AuthenticationResult.SUCCEEDED)
- val isUnlocked by collectLastValue(utils.deviceEntryRepository.isUnlocked)
- assertThat(isUnlocked).isTrue()
}
@Test
- fun tryAutoConfirm_withAutoConfirmCorrectPinButDuringThrottling_returnsNullAndHasNoEffects() =
+ fun tryAutoConfirm_withAutoConfirmCorrectPinButDuringThrottling_returnsNull() =
testScope.runTest {
val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled)
val isUnlocked by collectLastValue(utils.deviceEntryRepository.isUnlocked)
val hintedPinLength by collectLastValue(underTest.hintedPinLength)
utils.authenticationRepository.apply {
- setAuthenticationMethod(DataLayerAuthenticationMethodModel.Pin)
+ setAuthenticationMethod(AuthenticationMethodModel.Pin)
setAutoConfirmFeatureEnabled(true)
setThrottleDuration(42)
}
@@ -321,10 +286,10 @@
}
@Test
- fun tryAutoConfirm_withoutAutoConfirmButCorrectPin_returnsNullAndHasNoEffects() =
+ fun tryAutoConfirm_withoutAutoConfirmButCorrectPin_returnsNull() =
testScope.runTest {
utils.authenticationRepository.apply {
- setAuthenticationMethod(DataLayerAuthenticationMethodModel.Pin)
+ setAuthenticationMethod(AuthenticationMethodModel.Pin)
setAutoConfirmFeatureEnabled(false)
}
assertThat(
@@ -334,53 +299,38 @@
)
)
.isEqualTo(AuthenticationResult.SKIPPED)
- val isUnlocked by collectLastValue(utils.deviceEntryRepository.isUnlocked)
- assertThat(isUnlocked).isFalse()
}
@Test
- fun tryAutoConfirm_withoutCorrectPassword_returnsNullAndHasNoEffects() =
+ fun tryAutoConfirm_withoutCorrectPassword_returnsNull() =
testScope.runTest {
utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Password
+ AuthenticationMethodModel.Password
)
assertThat(underTest.authenticate("password".toList(), tryAutoConfirm = true))
.isEqualTo(AuthenticationResult.SKIPPED)
- val isUnlocked by collectLastValue(utils.deviceEntryRepository.isUnlocked)
- assertThat(isUnlocked).isFalse()
}
@Test
fun throttling() =
testScope.runTest {
- val isUnlocked by collectLastValue(utils.deviceEntryRepository.isUnlocked)
val throttling by collectLastValue(underTest.throttling)
val isThrottled by collectLastValue(underTest.isThrottled)
- utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Pin
- )
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
underTest.authenticate(FakeAuthenticationRepository.DEFAULT_PIN)
- assertThat(isUnlocked).isTrue()
- assertThat(isThrottled).isFalse()
- assertThat(throttling).isEqualTo(AuthenticationThrottlingModel())
-
- utils.deviceEntryRepository.setUnlocked(false)
- assertThat(isUnlocked).isFalse()
assertThat(isThrottled).isFalse()
assertThat(throttling).isEqualTo(AuthenticationThrottlingModel())
// Make many wrong attempts, but just shy of what's needed to get throttled:
repeat(FakeAuthenticationRepository.MAX_FAILED_AUTH_TRIES_BEFORE_THROTTLING - 1) {
underTest.authenticate(listOf(5, 6, 7)) // Wrong PIN
- assertThat(isUnlocked).isFalse()
assertThat(isThrottled).isFalse()
assertThat(throttling).isEqualTo(AuthenticationThrottlingModel())
}
// Make one more wrong attempt, leading to throttling:
underTest.authenticate(listOf(5, 6, 7)) // Wrong PIN
- assertThat(isUnlocked).isFalse()
assertThat(isThrottled).isTrue()
assertThat(throttling)
.isEqualTo(
@@ -394,7 +344,6 @@
// Correct PIN, but throttled, so doesn't attempt it:
assertThat(underTest.authenticate(FakeAuthenticationRepository.DEFAULT_PIN))
.isEqualTo(AuthenticationResult.SKIPPED)
- assertThat(isUnlocked).isFalse()
assertThat(isThrottled).isTrue()
assertThat(throttling)
.isEqualTo(
@@ -427,7 +376,6 @@
// Move the clock forward one more second, to completely finish the throttling period:
advanceTimeBy(1000)
- assertThat(isUnlocked).isFalse()
assertThat(isThrottled).isFalse()
assertThat(throttling)
.isEqualTo(
@@ -441,7 +389,6 @@
// Correct PIN and no longer throttled so unlocks successfully:
assertThat(underTest.authenticate(FakeAuthenticationRepository.DEFAULT_PIN))
.isEqualTo(AuthenticationResult.SUCCEEDED)
- assertThat(isUnlocked).isTrue()
assertThat(isThrottled).isFalse()
assertThat(throttling).isEqualTo(AuthenticationThrottlingModel())
}
@@ -451,7 +398,7 @@
testScope.runTest {
val hintedPinLength by collectLastValue(underTest.hintedPinLength)
utils.authenticationRepository.apply {
- setAuthenticationMethod(DataLayerAuthenticationMethodModel.Pin)
+ setAuthenticationMethod(AuthenticationMethodModel.Pin)
setAutoConfirmFeatureEnabled(false)
}
@@ -463,7 +410,7 @@
testScope.runTest {
val hintedPinLength by collectLastValue(underTest.hintedPinLength)
utils.authenticationRepository.apply {
- setAuthenticationMethod(DataLayerAuthenticationMethodModel.Pin)
+ setAuthenticationMethod(AuthenticationMethodModel.Pin)
overrideCredential(
buildList {
repeat(utils.authenticationRepository.hintedPinLength - 1) { add(it + 1) }
@@ -480,7 +427,7 @@
testScope.runTest {
val hintedPinLength by collectLastValue(underTest.hintedPinLength)
utils.authenticationRepository.apply {
- setAuthenticationMethod(DataLayerAuthenticationMethodModel.Pin)
+ setAuthenticationMethod(AuthenticationMethodModel.Pin)
setAutoConfirmFeatureEnabled(true)
overrideCredential(
buildList {
@@ -497,7 +444,7 @@
testScope.runTest {
val hintedPinLength by collectLastValue(underTest.hintedPinLength)
utils.authenticationRepository.apply {
- setAuthenticationMethod(DataLayerAuthenticationMethodModel.Pin)
+ setAuthenticationMethod(AuthenticationMethodModel.Pin)
overrideCredential(
buildList {
repeat(utils.authenticationRepository.hintedPinLength + 1) { add(it + 1) }
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractorTest.kt
index 5775396..6ead0e9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractorTest.kt
@@ -19,16 +19,14 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
import com.android.systemui.authentication.domain.interactor.AuthenticationResult
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.authentication.shared.model.AuthenticationPatternCoordinate
import com.android.systemui.authentication.shared.model.AuthenticationThrottlingModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.res.R
import com.android.systemui.scene.SceneTestUtils
-import com.android.systemui.scene.shared.model.SceneKey
-import com.android.systemui.scene.shared.model.SceneModel
import com.google.common.truth.Truth.assertThat
import kotlin.math.ceil
import kotlin.time.Duration.Companion.milliseconds
@@ -48,17 +46,9 @@
private val utils = SceneTestUtils(this)
private val testScope = utils.testScope
private val authenticationInteractor = utils.authenticationInteractor()
- private val sceneInteractor = utils.sceneInteractor()
- private val deviceEntryInteractor =
- utils.deviceEntryInteractor(
- authenticationInteractor = authenticationInteractor,
- sceneInteractor = sceneInteractor,
- )
private val underTest =
utils.bouncerInteractor(
- deviceEntryInteractor = deviceEntryInteractor,
authenticationInteractor = authenticationInteractor,
- sceneInteractor = sceneInteractor,
)
@Before
@@ -74,16 +64,10 @@
@Test
fun pinAuthMethod() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
val message by collectLastValue(underTest.message)
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
runCurrent()
- utils.deviceEntryRepository.setUnlocked(false)
- underTest.showOrUnlockDevice()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
- assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PIN)
-
underTest.clearMessage()
assertThat(message).isEmpty()
@@ -94,7 +78,6 @@
assertThat(underTest.authenticate(listOf(9, 8, 7)))
.isEqualTo(AuthenticationResult.FAILED)
assertThat(message).isEqualTo(MESSAGE_WRONG_PIN)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
underTest.resetMessage()
assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PIN)
@@ -102,37 +85,25 @@
// Correct input.
assertThat(underTest.authenticate(FakeAuthenticationRepository.DEFAULT_PIN))
.isEqualTo(AuthenticationResult.SUCCEEDED)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
}
@Test
fun pinAuthMethod_tryAutoConfirm_withAutoConfirmPin() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
- val message by collectLastValue(underTest.message)
val isAutoConfirmEnabled by collectLastValue(underTest.isAutoConfirmEnabled)
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
runCurrent()
utils.authenticationRepository.setAutoConfirmFeatureEnabled(true)
- utils.deviceEntryRepository.setUnlocked(false)
- underTest.showOrUnlockDevice()
assertThat(isAutoConfirmEnabled).isTrue()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
- assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PIN)
- underTest.clearMessage()
// Incomplete input.
assertThat(underTest.authenticate(listOf(1, 2), tryAutoConfirm = true))
.isEqualTo(AuthenticationResult.SKIPPED)
- assertThat(message).isEmpty()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
// Wrong 6-digit pin
assertThat(underTest.authenticate(listOf(1, 2, 3, 5, 5, 6), tryAutoConfirm = true))
.isEqualTo(AuthenticationResult.FAILED)
- assertThat(message).isEqualTo(MESSAGE_WRONG_PIN)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
// Correct input.
assertThat(
@@ -142,27 +113,20 @@
)
)
.isEqualTo(AuthenticationResult.SUCCEEDED)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
}
@Test
fun pinAuthMethod_tryAutoConfirm_withoutAutoConfirmPin() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
val message by collectLastValue(underTest.message)
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
runCurrent()
- utils.deviceEntryRepository.setUnlocked(false)
- underTest.showOrUnlockDevice()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
- underTest.clearMessage()
// Incomplete input.
assertThat(underTest.authenticate(listOf(1, 2), tryAutoConfirm = true))
.isEqualTo(AuthenticationResult.SKIPPED)
assertThat(message).isEmpty()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
// Correct input.
assertThat(
@@ -173,25 +137,16 @@
)
.isEqualTo(AuthenticationResult.SKIPPED)
assertThat(message).isEmpty()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
}
@Test
fun passwordAuthMethod() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
val message by collectLastValue(underTest.message)
utils.authenticationRepository.setAuthenticationMethod(
AuthenticationMethodModel.Password
)
runCurrent()
- utils.deviceEntryRepository.setUnlocked(false)
- underTest.showOrUnlockDevice()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
- assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PASSWORD)
-
- underTest.clearMessage()
- assertThat(message).isEmpty()
underTest.resetMessage()
assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PASSWORD)
@@ -200,7 +155,6 @@
assertThat(underTest.authenticate("alohamora".toList()))
.isEqualTo(AuthenticationResult.FAILED)
assertThat(message).isEqualTo(MESSAGE_WRONG_PASSWORD)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
underTest.resetMessage()
assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PASSWORD)
@@ -208,26 +162,16 @@
// Correct input.
assertThat(underTest.authenticate("password".toList()))
.isEqualTo(AuthenticationResult.SUCCEEDED)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
}
@Test
fun patternAuthMethod() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
val message by collectLastValue(underTest.message)
utils.authenticationRepository.setAuthenticationMethod(
AuthenticationMethodModel.Pattern
)
runCurrent()
- utils.deviceEntryRepository.setUnlocked(false)
- underTest.showOrUnlockDevice()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
- assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PATTERN)
-
- underTest.clearMessage()
- assertThat(message).isEmpty()
-
underTest.resetMessage()
assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PATTERN)
@@ -243,7 +187,6 @@
assertThat(wrongPattern.size).isAtLeast(utils.authenticationRepository.minPatternLength)
assertThat(underTest.authenticate(wrongPattern)).isEqualTo(AuthenticationResult.FAILED)
assertThat(message).isEqualTo(MESSAGE_WRONG_PATTERN)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
underTest.resetMessage()
assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PATTERN)
@@ -257,7 +200,6 @@
assertThat(underTest.authenticate(tooShortPattern))
.isEqualTo(AuthenticationResult.SKIPPED)
assertThat(message).isEqualTo(MESSAGE_WRONG_PATTERN)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
underTest.resetMessage()
assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PATTERN)
@@ -265,51 +207,6 @@
// Correct input.
assertThat(underTest.authenticate(FakeAuthenticationRepository.PATTERN))
.isEqualTo(AuthenticationResult.SUCCEEDED)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
- }
-
- @Test
- fun showOrUnlockDevice_notLocked_switchesToGoneScene() =
- testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
- utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
- utils.deviceEntryRepository.setUnlocked(true)
- runCurrent()
-
- underTest.showOrUnlockDevice()
-
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
- }
-
- @Test
- fun showOrUnlockDevice_authMethodNotSecure_switchesToGoneScene() =
- testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
- utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
- utils.deviceEntryRepository.setUnlocked(false)
-
- underTest.showOrUnlockDevice()
-
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
- }
-
- @Test
- fun showOrUnlockDevice_customMessageShown() =
- testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
- val message by collectLastValue(underTest.message)
- utils.authenticationRepository.setAuthenticationMethod(
- AuthenticationMethodModel.Password
- )
- runCurrent()
- utils.deviceEntryRepository.setUnlocked(false)
-
- val customMessage = "Hello there!"
- underTest.showOrUnlockDevice(customMessage)
-
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
- assertThat(message).isEqualTo(customMessage)
}
@Test
@@ -318,15 +215,9 @@
val isThrottled by collectLastValue(underTest.isThrottled)
val throttling by collectLastValue(underTest.throttling)
val message by collectLastValue(underTest.message)
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
- runCurrent()
- underTest.showOrUnlockDevice()
- runCurrent()
- assertThat(currentScene?.key).isEqualTo(SceneKey.Bouncer)
assertThat(isThrottled).isFalse()
assertThat(throttling).isEqualTo(AuthenticationThrottlingModel())
- assertThat(message).isEqualTo(MESSAGE_ENTER_YOUR_PIN)
repeat(FakeAuthenticationRepository.MAX_FAILED_AUTH_TRIES_BEFORE_THROTTLING) { times ->
// Wrong PIN.
assertThat(underTest.authenticate(listOf(6, 7, 8, 9)))
@@ -355,7 +246,6 @@
// Correct PIN, but throttled, so doesn't change away from the bouncer scene:
assertThat(underTest.authenticate(FakeAuthenticationRepository.DEFAULT_PIN))
.isEqualTo(AuthenticationResult.SKIPPED)
- assertThat(currentScene?.key).isEqualTo(SceneKey.Bouncer)
assertTryAgainMessage(
message,
FakeAuthenticationRepository.THROTTLE_DURATION_MS.milliseconds.inWholeSeconds
@@ -381,42 +271,24 @@
FakeAuthenticationRepository.MAX_FAILED_AUTH_TRIES_BEFORE_THROTTLING,
)
)
- assertThat(currentScene?.key).isEqualTo(SceneKey.Bouncer)
// Correct PIN and no longer throttled so changes to the Gone scene:
assertThat(underTest.authenticate(FakeAuthenticationRepository.DEFAULT_PIN))
.isEqualTo(AuthenticationResult.SUCCEEDED)
- assertThat(currentScene?.key).isEqualTo(SceneKey.Gone)
assertThat(isThrottled).isFalse()
assertThat(throttling).isEqualTo(AuthenticationThrottlingModel())
}
@Test
- fun hide_whenOnBouncerScene_hidesBouncerAndGoesToLockscreenScene() =
+ fun imeHiddenEvent_isTriggered() =
testScope.runTest {
- sceneInteractor.changeScene(SceneModel(SceneKey.Bouncer), "")
- sceneInteractor.onSceneChanged(SceneModel(SceneKey.Bouncer), "")
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
- val bouncerSceneKey = currentScene?.key
- assertThat(bouncerSceneKey).isEqualTo(SceneKey.Bouncer)
+ val imeHiddenEvent by collectLastValue(underTest.onImeHidden)
+ runCurrent()
underTest.onImeHidden()
+ runCurrent()
- assertThat(currentScene?.key).isEqualTo(SceneKey.Lockscreen)
- }
-
- @Test
- fun hide_whenNotOnBouncerScene_doesNothing() =
- testScope.runTest {
- sceneInteractor.changeScene(SceneModel(SceneKey.Shade), "")
- sceneInteractor.onSceneChanged(SceneModel(SceneKey.Shade), "")
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
- val notBouncerSceneKey = currentScene?.key
- assertThat(notBouncerSceneKey).isNotEqualTo(SceneKey.Bouncer)
-
- underTest.onImeHidden()
-
- assertThat(currentScene?.key).isEqualTo(notBouncerSceneKey)
+ assertThat(imeHiddenEvent).isNotNull()
}
private fun assertTryAgainMessage(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/AuthMethodBouncerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/AuthMethodBouncerViewModelTest.kt
index 8e1f5ac..cfcb545 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/AuthMethodBouncerViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/AuthMethodBouncerViewModelTest.kt
@@ -19,8 +19,8 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.scene.SceneTestUtils
import com.android.systemui.scene.shared.model.SceneKey
@@ -37,23 +37,16 @@
private val utils = SceneTestUtils(this)
private val testScope = utils.testScope
- private val authenticationInteractor = utils.authenticationInteractor()
private val sceneInteractor = utils.sceneInteractor()
- private val deviceEntryInteractor =
- utils.deviceEntryInteractor(
- authenticationInteractor = authenticationInteractor,
- sceneInteractor = sceneInteractor,
+ private val bouncerInteractor =
+ utils.bouncerInteractor(
+ authenticationInteractor = utils.authenticationInteractor(),
)
private val underTest =
PinBouncerViewModel(
applicationContext = context,
viewModelScope = testScope.backgroundScope,
- interactor =
- utils.bouncerInteractor(
- deviceEntryInteractor = deviceEntryInteractor,
- authenticationInteractor = authenticationInteractor,
- sceneInteractor = sceneInteractor,
- ),
+ interactor = bouncerInteractor,
isInputEnabled = MutableStateFlow(true),
)
@@ -85,18 +78,14 @@
@Test
fun onImeVisibilityChanged() =
testScope.runTest {
- val desiredScene by collectLastValue(sceneInteractor.desiredScene)
sceneInteractor.changeScene(SceneModel(SceneKey.Bouncer), "")
sceneInteractor.onSceneChanged(SceneModel(SceneKey.Bouncer), "")
- assertThat(desiredScene?.key).isEqualTo(SceneKey.Bouncer)
-
- underTest.onImeVisibilityChanged(false)
- assertThat(desiredScene?.key).isEqualTo(SceneKey.Bouncer)
+ val onImeHidden by collectLastValue(bouncerInteractor.onImeHidden)
underTest.onImeVisibilityChanged(true)
- assertThat(desiredScene?.key).isEqualTo(SceneKey.Bouncer)
+ assertThat(onImeHidden).isNull()
underTest.onImeVisibilityChanged(false)
- assertThat(desiredScene?.key).isEqualTo(SceneKey.Lockscreen)
+ assertThat(onImeHidden).isNotNull()
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModelTest.kt
index 6357a1a..f4346b5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModelTest.kt
@@ -19,10 +19,8 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel as DataLayerAuthenticationMethodModel
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel as DomainLayerAuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.Flags
import com.android.systemui.scene.SceneTestUtils
@@ -48,16 +46,9 @@
private val testScope = utils.testScope
private val authenticationInteractor = utils.authenticationInteractor()
private val actionButtonInteractor = utils.bouncerActionButtonInteractor()
- private val deviceEntryInteractor =
- utils.deviceEntryInteractor(
- authenticationInteractor = authenticationInteractor,
- sceneInteractor = utils.sceneInteractor(),
- )
private val bouncerInteractor =
utils.bouncerInteractor(
- deviceEntryInteractor = deviceEntryInteractor,
authenticationInteractor = authenticationInteractor,
- sceneInteractor = utils.sceneInteractor(),
)
private val underTest =
utils.bouncerViewModel(
@@ -96,8 +87,7 @@
@Test
fun authMethodChanged_doesNotReuseInstances() =
testScope.runTest {
- val seen =
- mutableMapOf<DomainLayerAuthenticationMethodModel, AuthMethodBouncerViewModel>()
+ val seen = mutableMapOf<AuthenticationMethodModel, AuthMethodBouncerViewModel>()
val authMethodViewModel: AuthMethodBouncerViewModel? by
collectLastValue(underTest.authMethodViewModel)
@@ -137,7 +127,7 @@
@Test
fun authMethodsToTest_returnsCompleteSampleOfAllAuthMethodTypes() {
assertThat(authMethodsToTest().map { it::class }.toSet())
- .isEqualTo(DomainLayerAuthenticationMethodModel::class.sealedSubclasses.toSet())
+ .isEqualTo(AuthenticationMethodModel::class.sealedSubclasses.toSet())
}
@Test
@@ -145,9 +135,7 @@
testScope.runTest {
val message by collectLastValue(underTest.message)
val throttling by collectLastValue(bouncerInteractor.throttling)
- utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Pin
- )
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
assertThat(message?.isUpdateAnimated).isTrue()
repeat(FakeAuthenticationRepository.MAX_FAILED_AUTH_TRIES_BEFORE_THROTTLING) {
@@ -170,9 +158,7 @@
}
)
val throttling by collectLastValue(bouncerInteractor.throttling)
- utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Pin
- )
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
assertThat(isInputEnabled).isTrue()
repeat(FakeAuthenticationRepository.MAX_FAILED_AUTH_TRIES_BEFORE_THROTTLING) {
@@ -189,9 +175,7 @@
fun throttlingDialogMessage() =
testScope.runTest {
val throttlingDialogMessage by collectLastValue(underTest.throttlingDialogMessage)
- utils.authenticationRepository.setAuthenticationMethod(
- DataLayerAuthenticationMethodModel.Pin
- )
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
repeat(FakeAuthenticationRepository.MAX_FAILED_AUTH_TRIES_BEFORE_THROTTLING) {
// Wrong PIN.
@@ -243,34 +227,12 @@
assertThat(isFoldSplitRequired).isTrue()
}
- private fun authMethodsToTest(): List<DomainLayerAuthenticationMethodModel> {
+ private fun authMethodsToTest(): List<AuthenticationMethodModel> {
return listOf(
- DomainLayerAuthenticationMethodModel.None,
- DomainLayerAuthenticationMethodModel.Swipe,
- DomainLayerAuthenticationMethodModel.Pin,
- DomainLayerAuthenticationMethodModel.Password,
- DomainLayerAuthenticationMethodModel.Pattern,
- )
- }
-
- private fun FakeAuthenticationRepository.setAuthenticationMethod(
- model: DomainLayerAuthenticationMethodModel,
- ) {
- setAuthenticationMethod(
- when (model) {
- is DomainLayerAuthenticationMethodModel.None,
- is DomainLayerAuthenticationMethodModel.Swipe ->
- DataLayerAuthenticationMethodModel.None
- is DomainLayerAuthenticationMethodModel.Pin ->
- DataLayerAuthenticationMethodModel.Pin
- is DomainLayerAuthenticationMethodModel.Password ->
- DataLayerAuthenticationMethodModel.Password
- is DomainLayerAuthenticationMethodModel.Pattern ->
- DataLayerAuthenticationMethodModel.Pattern
- }
- )
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(
- model !is DomainLayerAuthenticationMethodModel.None
+ AuthenticationMethodModel.None,
+ AuthenticationMethodModel.Pin,
+ AuthenticationMethodModel.Password,
+ AuthenticationMethodModel.Pattern,
)
}
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt
index 390742031..c498edf 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PasswordBouncerViewModelTest.kt
@@ -19,8 +19,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel as DomainAuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.res.R
import com.android.systemui.scene.SceneTestUtils
@@ -46,16 +45,9 @@
private val testScope = utils.testScope
private val authenticationInteractor = utils.authenticationInteractor()
private val sceneInteractor = utils.sceneInteractor()
- private val deviceEntryInteractor =
- utils.deviceEntryInteractor(
- authenticationInteractor = authenticationInteractor,
- sceneInteractor = utils.sceneInteractor(),
- )
private val bouncerInteractor =
utils.bouncerInteractor(
- deviceEntryInteractor = deviceEntryInteractor,
authenticationInteractor = authenticationInteractor,
- sceneInteractor = sceneInteractor,
)
private val bouncerViewModel =
utils.bouncerViewModel(
@@ -88,8 +80,7 @@
assertThat(message?.text).isEqualTo(ENTER_YOUR_PASSWORD)
assertThat(password).isEqualTo("")
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
- assertThat(underTest.authenticationMethod)
- .isEqualTo(DomainAuthenticationMethodModel.Password)
+ assertThat(underTest.authenticationMethod).isEqualTo(AuthenticationMethodModel.Password)
}
@Test
@@ -110,19 +101,19 @@
@Test
fun onAuthenticateKeyPressed_whenCorrect() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
+ val authResult by
+ collectLastValue(authenticationInteractor.authenticationChallengeResult)
lockDeviceAndOpenPasswordBouncer()
underTest.onPasswordInputChanged("password")
underTest.onAuthenticateKeyPressed()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
+ assertThat(authResult).isTrue()
}
@Test
fun onAuthenticateKeyPressed_whenWrong() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
val message by collectLastValue(bouncerViewModel.message)
val password by collectLastValue(underTest.password)
lockDeviceAndOpenPasswordBouncer()
@@ -132,13 +123,11 @@
assertThat(password).isEqualTo("")
assertThat(message?.text).isEqualTo(WRONG_PASSWORD)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
}
@Test
fun onAuthenticateKeyPressed_whenEmpty() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
val message by collectLastValue(bouncerViewModel.message)
val password by collectLastValue(underTest.password)
utils.authenticationRepository.setAuthenticationMethod(
@@ -147,7 +136,6 @@
utils.deviceEntryRepository.setUnlocked(false)
sceneInteractor.changeScene(SceneModel(SceneKey.Bouncer), "reason")
sceneInteractor.onSceneChanged(SceneModel(SceneKey.Bouncer), "reason")
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
underTest.onShown()
// Enter nothing.
@@ -155,13 +143,13 @@
assertThat(password).isEqualTo("")
assertThat(message?.text).isEqualTo(ENTER_YOUR_PASSWORD)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
}
@Test
fun onAuthenticateKeyPressed_correctAfterWrong() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
+ val authResult by
+ collectLastValue(authenticationInteractor.authenticationChallengeResult)
val message by collectLastValue(bouncerViewModel.message)
val password by collectLastValue(underTest.password)
lockDeviceAndOpenPasswordBouncer()
@@ -171,7 +159,7 @@
underTest.onAuthenticateKeyPressed()
assertThat(password).isEqualTo("")
assertThat(message?.text).isEqualTo(WRONG_PASSWORD)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
+ assertThat(authResult).isFalse()
// Enter the correct password:
underTest.onPasswordInputChanged("password")
@@ -179,7 +167,7 @@
underTest.onAuthenticateKeyPressed()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
+ assertThat(authResult).isTrue()
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt
index 47db4f8..3f5ddba 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PatternBouncerViewModelTest.kt
@@ -19,9 +19,8 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel as DomainAuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.authentication.shared.model.AuthenticationPatternCoordinate as Point
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.res.R
@@ -49,16 +48,9 @@
private val testScope = utils.testScope
private val authenticationInteractor = utils.authenticationInteractor()
private val sceneInteractor = utils.sceneInteractor()
- private val deviceEntryInteractor =
- utils.deviceEntryInteractor(
- authenticationInteractor = authenticationInteractor,
- sceneInteractor = utils.sceneInteractor(),
- )
private val bouncerInteractor =
utils.bouncerInteractor(
- deviceEntryInteractor = deviceEntryInteractor,
authenticationInteractor = authenticationInteractor,
- sceneInteractor = sceneInteractor,
)
private val bouncerViewModel =
utils.bouncerViewModel(
@@ -96,8 +88,7 @@
assertThat(selectedDots).isEmpty()
assertThat(currentDot).isNull()
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
- assertThat(underTest.authenticationMethod)
- .isEqualTo(DomainAuthenticationMethodModel.Pattern)
+ assertThat(underTest.authenticationMethod).isEqualTo(AuthenticationMethodModel.Pattern)
}
@Test
@@ -120,7 +111,8 @@
@Test
fun onDragEnd_whenCorrect() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
+ val authResult by
+ collectLastValue(authenticationInteractor.authenticationChallengeResult)
val selectedDots by collectLastValue(underTest.selectedDots)
val currentDot by collectLastValue(underTest.currentDot)
lockDeviceAndOpenPatternBouncer()
@@ -150,7 +142,7 @@
underTest.onDragEnd()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
+ assertThat(authResult).isTrue()
}
@Test
@@ -344,7 +336,8 @@
@Test
fun onDragEnd_correctAfterWrong() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
+ val authResult by
+ collectLastValue(authenticationInteractor.authenticationChallengeResult)
val message by collectLastValue(bouncerViewModel.message)
val selectedDots by collectLastValue(underTest.selectedDots)
val currentDot by collectLastValue(underTest.currentDot)
@@ -356,14 +349,14 @@
assertThat(selectedDots).isEmpty()
assertThat(currentDot).isNull()
assertThat(message?.text).isEqualTo(WRONG_PATTERN)
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
+ assertThat(authResult).isFalse()
// Enter the correct pattern:
CORRECT_PATTERN.forEach(::dragToCoordinate)
underTest.onDragEnd()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
+ assertThat(authResult).isTrue()
}
private fun dragOverCoordinates(vararg coordinatesDragged: Point) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt
index e07c0b8..6da6951 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/viewmodel/PinBouncerViewModelTest.kt
@@ -19,9 +19,8 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel as DomainAuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.res.R
import com.android.systemui.scene.SceneTestUtils
@@ -48,16 +47,9 @@
private val testScope = utils.testScope
private val sceneInteractor = utils.sceneInteractor()
private val authenticationInteractor = utils.authenticationInteractor()
- private val deviceEntryInteractor =
- utils.deviceEntryInteractor(
- authenticationInteractor = authenticationInteractor,
- sceneInteractor = utils.sceneInteractor(),
- )
private val bouncerInteractor =
utils.bouncerInteractor(
- deviceEntryInteractor = deviceEntryInteractor,
authenticationInteractor = authenticationInteractor,
- sceneInteractor = sceneInteractor,
)
private val bouncerViewModel =
utils.bouncerViewModel(
@@ -96,8 +88,7 @@
assertThat(message?.text).ignoringCase().isEqualTo(ENTER_YOUR_PIN)
assertThat(pin).isEmpty()
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
- assertThat(underTest.authenticationMethod)
- .isEqualTo(DomainAuthenticationMethodModel.Pin)
+ assertThat(underTest.authenticationMethod).isEqualTo(AuthenticationMethodModel.Pin)
}
@Test
@@ -181,7 +172,8 @@
@Test
fun onAuthenticateButtonClicked_whenCorrect() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
+ val authResult by
+ collectLastValue(authenticationInteractor.authenticationChallengeResult)
lockDeviceAndOpenPinBouncer()
FakeAuthenticationRepository.DEFAULT_PIN.forEach { digit ->
@@ -190,7 +182,7 @@
underTest.onAuthenticateButtonClicked()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
+ assertThat(authResult).isTrue()
}
@Test
@@ -217,7 +209,8 @@
@Test
fun onAuthenticateButtonClicked_correctAfterWrong() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
+ val authResult by
+ collectLastValue(authenticationInteractor.authenticationChallengeResult)
val message by collectLastValue(bouncerViewModel.message)
val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
lockDeviceAndOpenPinBouncer()
@@ -230,7 +223,7 @@
underTest.onAuthenticateButtonClicked()
assertThat(message?.text).ignoringCase().isEqualTo(WRONG_PIN)
assertThat(pin).isEmpty()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
+ assertThat(authResult).isFalse()
// Enter the correct PIN:
FakeAuthenticationRepository.DEFAULT_PIN.forEach { digit ->
@@ -240,21 +233,22 @@
underTest.onAuthenticateButtonClicked()
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
+ assertThat(authResult).isTrue()
}
@Test
fun onAutoConfirm_whenCorrect() =
testScope.runTest {
- val currentScene by collectLastValue(sceneInteractor.desiredScene)
utils.authenticationRepository.setAutoConfirmFeatureEnabled(true)
+ val authResult by
+ collectLastValue(authenticationInteractor.authenticationChallengeResult)
lockDeviceAndOpenPinBouncer()
FakeAuthenticationRepository.DEFAULT_PIN.forEach { digit ->
underTest.onPinButtonClicked(digit)
}
- assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
+ assertThat(authResult).isTrue()
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryRepositoryTest.kt
index 2c80035..97ac8c6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryRepositoryTest.kt
@@ -83,16 +83,27 @@
}
@Test
- fun isInsecureLockscreenEnabled() =
+ fun isLockscreenEnabled() =
testScope.runTest {
whenever(lockPatternUtils.isLockScreenDisabled(USER_INFOS[0].id)).thenReturn(false)
whenever(lockPatternUtils.isLockScreenDisabled(USER_INFOS[1].id)).thenReturn(true)
userRepository.setSelectedUserInfo(USER_INFOS[0])
- assertThat(underTest.isInsecureLockscreenEnabled()).isTrue()
+ assertThat(underTest.isLockscreenEnabled()).isTrue()
userRepository.setSelectedUserInfo(USER_INFOS[1])
- assertThat(underTest.isInsecureLockscreenEnabled()).isFalse()
+ assertThat(underTest.isLockscreenEnabled()).isFalse()
+ }
+
+ @Test
+ fun reportSuccessfulAuthentication_shouldUpdateIsUnlocked() =
+ testScope.runTest {
+ val isUnlocked by collectLastValue(underTest.isUnlocked)
+ assertThat(isUnlocked).isFalse()
+
+ underTest.reportSuccessfulAuthentication()
+
+ assertThat(isUnlocked).isTrue()
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractorTest.kt
index aebadc5..abd9f28 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/deviceentry/domain/interactor/DeviceEntryInteractorTest.kt
@@ -19,7 +19,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.deviceentry.data.repository.FakeDeviceEntryRepository
import com.android.systemui.keyguard.data.repository.FakeDeviceEntryFaceAuthRepository
@@ -60,7 +60,7 @@
testScope.runTest {
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
utils.deviceEntryRepository.apply {
- setInsecureLockscreenEnabled(false)
+ setLockscreenEnabled(false)
// Toggle isUnlocked, twice.
//
@@ -83,8 +83,7 @@
@Test
fun isUnlocked_whenAuthMethodIsNoneAndLockscreenEnabled_isTrue() =
testScope.runTest {
- utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ setupSwipeDeviceEntryMethod()
val isUnlocked by collectLastValue(underTest.isUnlocked)
assertThat(isUnlocked).isTrue()
@@ -94,8 +93,7 @@
fun isDeviceEntered_onLockscreenWithSwipe_isFalse() =
testScope.runTest {
val isDeviceEntered by collectLastValue(underTest.isDeviceEntered)
- utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ setupSwipeDeviceEntryMethod()
switchToScene(SceneKey.Lockscreen)
assertThat(isDeviceEntered).isFalse()
@@ -105,8 +103,7 @@
fun isDeviceEntered_onShadeBeforeDismissingLockscreenWithSwipe_isFalse() =
testScope.runTest {
val isDeviceEntered by collectLastValue(underTest.isDeviceEntered)
- utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ setupSwipeDeviceEntryMethod()
switchToScene(SceneKey.Lockscreen)
runCurrent()
switchToScene(SceneKey.Shade)
@@ -118,8 +115,7 @@
fun isDeviceEntered_afterDismissingLockscreenWithSwipe_isTrue() =
testScope.runTest {
val isDeviceEntered by collectLastValue(underTest.isDeviceEntered)
- utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ setupSwipeDeviceEntryMethod()
switchToScene(SceneKey.Lockscreen)
runCurrent()
switchToScene(SceneKey.Gone)
@@ -131,8 +127,7 @@
fun isDeviceEntered_onShadeAfterDismissingLockscreenWithSwipe_isTrue() =
testScope.runTest {
val isDeviceEntered by collectLastValue(underTest.isDeviceEntered)
- utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ setupSwipeDeviceEntryMethod()
switchToScene(SceneKey.Lockscreen)
runCurrent()
switchToScene(SceneKey.Gone)
@@ -148,7 +143,7 @@
utils.authenticationRepository.setAuthenticationMethod(
AuthenticationMethodModel.Pattern
)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ utils.deviceEntryRepository.setLockscreenEnabled(true)
switchToScene(SceneKey.Lockscreen)
runCurrent()
switchToScene(SceneKey.Bouncer)
@@ -160,8 +155,7 @@
@Test
fun canSwipeToEnter_onLockscreenWithSwipe_isTrue() =
testScope.runTest {
- utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ setupSwipeDeviceEntryMethod()
switchToScene(SceneKey.Lockscreen)
val canSwipeToEnter by collectLastValue(underTest.canSwipeToEnter)
@@ -172,7 +166,7 @@
fun canSwipeToEnter_onLockscreenWithPin_isFalse() =
testScope.runTest {
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ utils.deviceEntryRepository.setLockscreenEnabled(true)
switchToScene(SceneKey.Lockscreen)
val canSwipeToEnter by collectLastValue(underTest.canSwipeToEnter)
@@ -182,8 +176,7 @@
@Test
fun canSwipeToEnter_afterLockscreenDismissedInSwipeMode_isFalse() =
testScope.runTest {
- utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ setupSwipeDeviceEntryMethod()
switchToScene(SceneKey.Lockscreen)
runCurrent()
switchToScene(SceneKey.Gone)
@@ -192,6 +185,11 @@
assertThat(canSwipeToEnter).isFalse()
}
+ private fun setupSwipeDeviceEntryMethod() {
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
+ utils.deviceEntryRepository.setLockscreenEnabled(true)
+ }
+
@Test
fun canSwipeToEnter_whenTrustedByTrustManager_isTrue() =
testScope.runTest {
@@ -278,12 +276,68 @@
}
@Test
+ fun showOrUnlockDevice_notLocked_switchesToGoneScene() =
+ testScope.runTest {
+ val currentScene by collectLastValue(sceneInteractor.desiredScene)
+ switchToScene(SceneKey.Lockscreen)
+ assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
+
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
+ utils.deviceEntryRepository.setUnlocked(true)
+ runCurrent()
+
+ underTest.attemptDeviceEntry()
+
+ assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
+ }
+
+ @Test
+ fun showOrUnlockDevice_authMethodNotSecure_switchesToGoneScene() =
+ testScope.runTest {
+ val currentScene by collectLastValue(sceneInteractor.desiredScene)
+ switchToScene(SceneKey.Lockscreen)
+ assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
+
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
+
+ underTest.attemptDeviceEntry()
+
+ assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
+ }
+
+ @Test
+ fun showOrUnlockDevice_authMethodSwipe_switchesToGoneScene() =
+ testScope.runTest {
+ val currentScene by collectLastValue(sceneInteractor.desiredScene)
+ switchToScene(SceneKey.Lockscreen)
+ assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
+
+ utils.deviceEntryRepository.setLockscreenEnabled(true)
+ utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
+
+ underTest.attemptDeviceEntry()
+
+ assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Gone))
+ }
+
+ @Test
fun isBypassEnabled_disabledInRepository_false() =
testScope.runTest {
utils.deviceEntryRepository.setBypassEnabled(false)
assertThat(underTest.isBypassEnabled.value).isFalse()
}
+ @Test
+ fun successfulAuthenticationChallengeAttempt_updatedIsUnlockedState() =
+ testScope.runTest {
+ val isUnlocked by collectLastValue(underTest.isUnlocked)
+ assertThat(isUnlocked).isFalse()
+
+ utils.authenticationRepository.reportAuthenticationAttempt(true)
+
+ assertThat(isUnlocked).isTrue()
+ }
+
private fun switchToScene(sceneKey: SceneKey) {
sceneInteractor.changeScene(SceneModel(sceneKey), "reason")
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt
index 7de28de..0b3bc9d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModelTest.kt
@@ -19,7 +19,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.scene.SceneTestUtils
import com.android.systemui.scene.shared.model.SceneKey
@@ -45,7 +45,7 @@
testScope.runTest {
val upTransitionSceneKey by collectLastValue(underTest.upDestinationSceneKey)
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ utils.deviceEntryRepository.setLockscreenEnabled(true)
utils.deviceEntryRepository.setUnlocked(true)
sceneInteractor.changeScene(SceneModel(SceneKey.Lockscreen), "reason")
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt
index a9f8239..d582b9e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/ui/viewmodel/QuickSettingsSceneViewModelTest.kt
@@ -19,7 +19,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.FakeFeatureFlagsClassic
import com.android.systemui.flags.Flags
@@ -90,13 +90,8 @@
underTest =
QuickSettingsSceneViewModel(
- bouncerInteractor =
- utils.bouncerInteractor(
- deviceEntryInteractor =
- utils.deviceEntryInteractor(
- authenticationInteractor = authenticationInteractor,
- sceneInteractor = sceneInteractor,
- ),
+ deviceEntryInteractor =
+ utils.deviceEntryInteractor(
authenticationInteractor = authenticationInteractor,
sceneInteractor = sceneInteractor,
),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt b/packages/SystemUI/tests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt
index e84d274..d1db9c1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/scene/SceneFrameworkIntegrationTest.kt
@@ -26,7 +26,7 @@
import com.android.internal.util.EmergencyAffordanceManager
import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel as DomainLayerAuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.bouncer.domain.interactor.BouncerActionButtonInteractor
import com.android.systemui.bouncer.ui.viewmodel.BouncerViewModel
import com.android.systemui.bouncer.ui.viewmodel.PinBouncerViewModel
@@ -39,7 +39,6 @@
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest
import com.android.systemui.power.domain.interactor.PowerInteractorFactory
-import com.android.systemui.scene.SceneTestUtils.Companion.toDataLayer
import com.android.systemui.scene.domain.startable.SceneContainerStartable
import com.android.systemui.scene.shared.model.ObservableTransitionState
import com.android.systemui.scene.shared.model.SceneKey
@@ -60,6 +59,7 @@
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
+import junit.framework.Assert.assertTrue
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.MutableStateFlow
@@ -72,7 +72,6 @@
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
-import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations
@@ -135,9 +134,7 @@
private val bouncerInteractor =
utils.bouncerInteractor(
- deviceEntryInteractor = deviceEntryInteractor,
authenticationInteractor = authenticationInteractor,
- sceneInteractor = sceneInteractor,
)
private lateinit var mobileConnectionsRepository: FakeMobileConnectionsRepository
@@ -234,7 +231,6 @@
ShadeSceneViewModel(
applicationScope = testScope.backgroundScope,
deviceEntryInteractor = deviceEntryInteractor,
- bouncerInteractor = bouncerInteractor,
shadeHeaderViewModel = shadeHeaderViewModel,
)
@@ -247,7 +243,6 @@
applicationScope = testScope.backgroundScope,
sceneInteractor = sceneInteractor,
deviceEntryInteractor = deviceEntryInteractor,
- authenticationInteractor = authenticationInteractor,
keyguardInteractor = keyguardInteractor,
flags = utils.sceneContainerFlags,
sysUiState = sysUiState,
@@ -255,6 +250,7 @@
sceneLogger = mock(),
falsingCollector = utils.falsingCollector(),
powerInteractor = powerInteractor,
+ bouncerInteractor = bouncerInteractor,
)
startable.start()
@@ -298,7 +294,7 @@
@Test
fun swipeUpOnLockscreen_withAuthMethodSwipe_dismissesLockscreen() =
testScope.runTest {
- setAuthMethod(DomainLayerAuthenticationMethodModel.Swipe)
+ setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true)
val upDestinationSceneKey by
collectLastValue(lockscreenSceneViewModel.upDestinationSceneKey)
@@ -312,7 +308,7 @@
fun swipeUpOnShadeScene_withAuthMethodSwipe_lockscreenNotDismissed_goesToLockscreen() =
testScope.runTest {
val upDestinationSceneKey by collectLastValue(shadeSceneViewModel.upDestinationSceneKey)
- setAuthMethod(DomainLayerAuthenticationMethodModel.Swipe)
+ setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true)
assertCurrentScene(SceneKey.Lockscreen)
// Emulate a user swipe to the shade scene.
@@ -329,7 +325,8 @@
fun swipeUpOnShadeScene_withAuthMethodSwipe_lockscreenDismissed_goesToGone() =
testScope.runTest {
val upDestinationSceneKey by collectLastValue(shadeSceneViewModel.upDestinationSceneKey)
- setAuthMethod(DomainLayerAuthenticationMethodModel.Swipe)
+ setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true)
+ assertTrue(deviceEntryInteractor.canSwipeToEnter.value)
assertCurrentScene(SceneKey.Lockscreen)
// Emulate a user swipe to dismiss the lockscreen.
@@ -349,7 +346,7 @@
@Test
fun withAuthMethodNone_deviceWakeUp_skipsLockscreen() =
testScope.runTest {
- setAuthMethod(DomainLayerAuthenticationMethodModel.None)
+ setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = false)
putDeviceToSleep(instantlyLockDevice = false)
assertCurrentScene(SceneKey.Lockscreen)
@@ -360,7 +357,7 @@
@Test
fun withAuthMethodSwipe_deviceWakeUp_doesNotSkipLockscreen() =
testScope.runTest {
- setAuthMethod(DomainLayerAuthenticationMethodModel.Swipe)
+ setAuthMethod(AuthenticationMethodModel.None, enableLockscreen = true)
putDeviceToSleep(instantlyLockDevice = false)
assertCurrentScene(SceneKey.Lockscreen)
@@ -428,7 +425,7 @@
@Test
fun dismissingIme_whileOnPasswordBouncer_navigatesToLockscreen() =
testScope.runTest {
- setAuthMethod(DomainLayerAuthenticationMethodModel.Password)
+ setAuthMethod(AuthenticationMethodModel.Password)
val upDestinationSceneKey by
collectLastValue(lockscreenSceneViewModel.upDestinationSceneKey)
assertThat(upDestinationSceneKey).isEqualTo(SceneKey.Bouncer)
@@ -445,7 +442,7 @@
@Test
fun bouncerActionButtonClick_opensEmergencyServicesDialer() =
testScope.runTest {
- setAuthMethod(DomainLayerAuthenticationMethodModel.Password)
+ setAuthMethod(AuthenticationMethodModel.Password)
val upDestinationSceneKey by
collectLastValue(lockscreenSceneViewModel.upDestinationSceneKey)
assertThat(upDestinationSceneKey).isEqualTo(SceneKey.Bouncer)
@@ -464,7 +461,7 @@
@Test
fun bouncerActionButtonClick_duringCall_returnsToCall() =
testScope.runTest {
- setAuthMethod(DomainLayerAuthenticationMethodModel.Password)
+ setAuthMethod(AuthenticationMethodModel.Password)
startPhoneCall()
val upDestinationSceneKey by
collectLastValue(lockscreenSceneViewModel.upDestinationSceneKey)
@@ -508,19 +505,19 @@
/** Updates the current authentication method and related states in the data layer. */
private fun TestScope.setAuthMethod(
- authMethod: DomainLayerAuthenticationMethodModel,
+ authMethod: AuthenticationMethodModel,
+ enableLockscreen: Boolean = true
) {
+ if (authMethod.isSecure) {
+ assert(enableLockscreen) {
+ "Lockscreen cannot be disabled with a secure authentication method."
+ }
+ }
// Set the lockscreen enabled bit _before_ set the auth method as the code picks up on the
// lockscreen enabled bit _after_ the auth method is changed and the lockscreen enabled bit
// is not an observable that can trigger a new evaluation.
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(
- authMethod !is DomainLayerAuthenticationMethodModel.None
- )
- utils.authenticationRepository.setAuthenticationMethod(authMethod.toDataLayer())
- if (!authMethod.isSecure) {
- // When the auth method is not secure, the device is never considered locked.
- utils.deviceEntryRepository.setUnlocked(true)
- }
+ utils.deviceEntryRepository.setLockscreenEnabled(enableLockscreen)
+ utils.authenticationRepository.setAuthenticationMethod(authMethod)
runCurrent()
}
@@ -648,6 +645,9 @@
emulateUserDrivenTransition(SceneKey.Bouncer)
enterPin()
+ // This repository state is not changed by the AuthInteractor, it relies on
+ // KeyguardStateController.
+ utils.deviceEntryRepository.setUnlocked(true)
emulateUiSceneTransition(
expectedVisible = false,
)
@@ -707,7 +707,7 @@
}
/** Emulates the dismissal of the IME (soft keyboard). */
- private fun TestScope.dismissIme(
+ private suspend fun TestScope.dismissIme(
showImeBeforeDismissing: Boolean = true,
) {
bouncerViewModel.authMethodViewModel.value?.apply {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt b/packages/SystemUI/tests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt
index f6362fe..2f654e2 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/scene/domain/startable/SceneContainerStartableTest.kt
@@ -24,16 +24,15 @@
import androidx.test.filters.SmallTest
import com.android.systemui.Flags as AconfigFlags
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.classifier.FalsingCollector
import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.kosmos.testScope
+import com.android.systemui.keyguard.data.repository.FakeDeviceEntryFaceAuthRepository
import com.android.systemui.model.SysUiState
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAsleepForTest
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest
import com.android.systemui.power.domain.interactor.PowerInteractorFactory
import com.android.systemui.scene.SceneTestUtils
-import com.android.systemui.scene.SceneTestUtils.Companion.toDataLayer
import com.android.systemui.scene.shared.model.ObservableTransitionState
import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.shared.model.SceneModel
@@ -63,8 +62,12 @@
private val sceneInteractor = utils.sceneInteractor()
private val sceneContainerFlags = utils.sceneContainerFlags
private val authenticationInteractor = utils.authenticationInteractor()
+ private val bouncerInteractor =
+ utils.bouncerInteractor(authenticationInteractor = authenticationInteractor)
+ private val faceAuthRepository = FakeDeviceEntryFaceAuthRepository()
private val deviceEntryInteractor =
utils.deviceEntryInteractor(
+ faceAuthRepository = faceAuthRepository,
authenticationInteractor = authenticationInteractor,
sceneInteractor = sceneInteractor,
)
@@ -78,7 +81,6 @@
applicationScope = testScope.backgroundScope,
sceneInteractor = sceneInteractor,
deviceEntryInteractor = deviceEntryInteractor,
- authenticationInteractor = authenticationInteractor,
keyguardInteractor = keyguardInteractor,
flags = sceneContainerFlags,
sysUiState = sysUiState,
@@ -86,6 +88,7 @@
sceneLogger = mock(),
falsingCollector = falsingCollector,
powerInteractor = powerInteractor,
+ bouncerInteractor = bouncerInteractor,
)
@Before
@@ -198,12 +201,55 @@
assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen)
underTest.start()
+ // Authenticate using a passive auth method like face auth while bypass is disabled.
+ faceAuthRepository.isAuthenticated.value = true
utils.deviceEntryRepository.setUnlocked(true)
assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen)
}
@Test
+ fun stayOnCurrentSceneWhenDeviceIsUnlockedAndUserIsNotOnLockscreen() =
+ testScope.runTest {
+ val currentSceneKey by collectLastValue(sceneInteractor.desiredScene.map { it.key })
+ val transitionStateFlowValue =
+ prepareState(
+ isBypassEnabled = true,
+ authenticationMethod = AuthenticationMethodModel.Pin,
+ initialSceneKey = SceneKey.Lockscreen,
+ )
+ underTest.start()
+ runCurrent()
+
+ sceneInteractor.changeScene(SceneModel(SceneKey.Shade), "switch to shade")
+ transitionStateFlowValue.value = ObservableTransitionState.Idle(SceneKey.Shade)
+ assertThat(currentSceneKey).isEqualTo(SceneKey.Shade)
+
+ utils.deviceEntryRepository.setUnlocked(true)
+ runCurrent()
+
+ assertThat(currentSceneKey).isEqualTo(SceneKey.Shade)
+ }
+
+ @Test
+ fun switchToGoneWhenDeviceIsUnlockedAndUserIsOnBouncerWithBypassDisabled() =
+ testScope.runTest {
+ val currentSceneKey by collectLastValue(sceneInteractor.desiredScene.map { it.key })
+ prepareState(
+ isBypassEnabled = false,
+ initialSceneKey = SceneKey.Bouncer,
+ )
+ assertThat(currentSceneKey).isEqualTo(SceneKey.Bouncer)
+ underTest.start()
+
+ // Authenticate using a passive auth method like face auth while bypass is disabled.
+ faceAuthRepository.isAuthenticated.value = true
+ utils.deviceEntryRepository.setUnlocked(true)
+
+ assertThat(currentSceneKey).isEqualTo(SceneKey.Gone)
+ }
+
+ @Test
fun switchToLockscreenWhenDeviceSleepsLocked() =
testScope.runTest {
val currentSceneKey by collectLastValue(sceneInteractor.desiredScene.map { it.key })
@@ -255,6 +301,7 @@
prepareState(
initialSceneKey = SceneKey.Lockscreen,
authenticationMethod = AuthenticationMethodModel.None,
+ isLockscreenEnabled = false,
)
assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen)
underTest.start()
@@ -269,7 +316,8 @@
val currentSceneKey by collectLastValue(sceneInteractor.desiredScene.map { it.key })
prepareState(
initialSceneKey = SceneKey.Lockscreen,
- authenticationMethod = AuthenticationMethodModel.Swipe,
+ authenticationMethod = AuthenticationMethodModel.None,
+ isLockscreenEnabled = true,
)
assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen)
underTest.start()
@@ -406,6 +454,24 @@
}
@Test
+ fun bouncerImeHidden_shouldTransitionBackToLockscreen() =
+ testScope.runTest {
+ val currentSceneKey by collectLastValue(sceneInteractor.desiredScene.map { it.key })
+ prepareState(
+ initialSceneKey = SceneKey.Lockscreen,
+ authenticationMethod = AuthenticationMethodModel.Password,
+ isDeviceUnlocked = false,
+ )
+ underTest.start()
+ runCurrent()
+
+ bouncerInteractor.onImeHidden()
+ runCurrent()
+
+ assertThat(currentSceneKey).isEqualTo(SceneKey.Lockscreen)
+ }
+
+ @Test
fun collectFalsingSignals_screenOnAndOff_aodUnavailable() =
testScope.runTest {
utils.keyguardRepository.setAodAvailable(false)
@@ -526,8 +592,14 @@
isBypassEnabled: Boolean = false,
initialSceneKey: SceneKey? = null,
authenticationMethod: AuthenticationMethodModel? = null,
+ isLockscreenEnabled: Boolean = true,
startsAwake: Boolean = true,
): MutableStateFlow<ObservableTransitionState> {
+ if (authenticationMethod?.isSecure == true) {
+ assert(isLockscreenEnabled) {
+ "Lockscreen cannot be disabled while having a secure authentication method"
+ }
+ }
sceneContainerFlags.enabled = true
utils.deviceEntryRepository.setUnlocked(isDeviceUnlocked)
utils.deviceEntryRepository.setBypassEnabled(isBypassEnabled)
@@ -542,11 +614,9 @@
sceneInteractor.onSceneChanged(SceneModel(it), "reason")
}
authenticationMethod?.let {
- utils.authenticationRepository.setAuthenticationMethod(
- authenticationMethod.toDataLayer()
- )
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(
- authenticationMethod != AuthenticationMethodModel.None
+ utils.authenticationRepository.setAuthenticationMethod(authenticationMethod)
+ utils.deviceEntryRepository.setLockscreenEnabled(
+ isLockscreenEnabled = isLockscreenEnabled
)
}
if (startsAwake) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
index 589f9ae..fa849fe 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
@@ -19,7 +19,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.FakeFeatureFlagsClassic
import com.android.systemui.flags.Flags
@@ -96,12 +96,6 @@
ShadeSceneViewModel(
applicationScope = testScope.backgroundScope,
deviceEntryInteractor = deviceEntryInteractor,
- bouncerInteractor =
- utils.bouncerInteractor(
- deviceEntryInteractor = deviceEntryInteractor,
- authenticationInteractor = authenticationInteractor,
- sceneInteractor = sceneInteractor,
- ),
shadeHeaderViewModel = shadeHeaderViewModel,
)
}
@@ -130,7 +124,7 @@
fun upTransitionSceneKey_authMethodSwipe_lockscreenNotDismissed_goesToLockscreen() =
testScope.runTest {
val upTransitionSceneKey by collectLastValue(underTest.upDestinationSceneKey)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ utils.deviceEntryRepository.setLockscreenEnabled(true)
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
sceneInteractor.changeScene(SceneModel(SceneKey.Lockscreen), "reason")
sceneInteractor.onSceneChanged(SceneModel(SceneKey.Lockscreen), "reason")
@@ -142,7 +136,7 @@
fun upTransitionSceneKey_authMethodSwipe_lockscreenDismissed_goesToGone() =
testScope.runTest {
val upTransitionSceneKey by collectLastValue(underTest.upDestinationSceneKey)
- utils.deviceEntryRepository.setInsecureLockscreenEnabled(true)
+ utils.deviceEntryRepository.setLockscreenEnabled(true)
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.None)
sceneInteractor.changeScene(SceneModel(SceneKey.Gone), "reason")
sceneInteractor.onSceneChanged(SceneModel(SceneKey.Gone), "reason")
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/authentication/data/repository/FakeAuthenticationRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/authentication/data/repository/FakeAuthenticationRepository.kt
index 81c5d9c..6e9363b 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/authentication/data/repository/FakeAuthenticationRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/authentication/data/repository/FakeAuthenticationRepository.kt
@@ -20,16 +20,16 @@
import com.android.internal.widget.LockPatternView
import com.android.internal.widget.LockscreenCredential
import com.android.keyguard.KeyguardSecurityModel.SecurityMode
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel
+import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.authentication.shared.model.AuthenticationPatternCoordinate
import com.android.systemui.authentication.shared.model.AuthenticationResultModel
import com.android.systemui.authentication.shared.model.AuthenticationThrottlingModel
import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.deviceentry.data.repository.FakeDeviceEntryRepository
import dagger.Binds
import dagger.Module
import dagger.Provides
import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
@@ -37,13 +37,13 @@
import kotlinx.coroutines.test.currentTime
class FakeAuthenticationRepository(
- private val deviceEntryRepository: FakeDeviceEntryRepository,
private val currentTime: () -> Long,
) : AuthenticationRepository {
private val _isAutoConfirmFeatureEnabled = MutableStateFlow(false)
override val isAutoConfirmFeatureEnabled: StateFlow<Boolean> =
_isAutoConfirmFeatureEnabled.asStateFlow()
+ override val authenticationChallengeResult = MutableSharedFlow<Boolean>()
override val hintedPinLength: Int = HINTING_PIN_LENGTH
@@ -80,7 +80,7 @@
override suspend fun reportAuthenticationAttempt(isSuccessful: Boolean) {
failedAttemptCount = if (isSuccessful) 0 else failedAttemptCount + 1
- deviceEntryRepository.setUnlocked(isSuccessful)
+ authenticationChallengeResult.emit(isSuccessful)
}
override suspend fun getPinLength(): Int {
@@ -216,9 +216,8 @@
@Provides
@SysUISingleton
fun provideFake(
- deviceEntryRepository: FakeDeviceEntryRepository,
scope: TestScope,
- ) = FakeAuthenticationRepository(deviceEntryRepository, currentTime = { scope.currentTime })
+ ) = FakeAuthenticationRepository(currentTime = { scope.currentTime })
@Module
interface Bindings {
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/data/repository/FakeDeviceEntryRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/data/repository/FakeDeviceEntryRepository.kt
index f029348..ba70d46 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/data/repository/FakeDeviceEntryRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/deviceentry/data/repository/FakeDeviceEntryRepository.kt
@@ -27,7 +27,7 @@
@SysUISingleton
class FakeDeviceEntryRepository @Inject constructor() : DeviceEntryRepository {
- private var isInsecureLockscreenEnabled = true
+ private var isLockscreenEnabled = true
private val _isBypassEnabled = MutableStateFlow(false)
override val isBypassEnabled: StateFlow<Boolean> = _isBypassEnabled
@@ -35,16 +35,20 @@
private val _isUnlocked = MutableStateFlow(false)
override val isUnlocked: StateFlow<Boolean> = _isUnlocked.asStateFlow()
- override suspend fun isInsecureLockscreenEnabled(): Boolean {
- return isInsecureLockscreenEnabled
+ override suspend fun isLockscreenEnabled(): Boolean {
+ return isLockscreenEnabled
+ }
+
+ override fun reportSuccessfulAuthentication() {
+ _isUnlocked.value = true
}
fun setUnlocked(isUnlocked: Boolean) {
_isUnlocked.value = isUnlocked
}
- fun setInsecureLockscreenEnabled(isLockscreenEnabled: Boolean) {
- this.isInsecureLockscreenEnabled = isLockscreenEnabled
+ fun setLockscreenEnabled(isLockscreenEnabled: Boolean) {
+ this.isLockscreenEnabled = isLockscreenEnabled
}
fun setBypassEnabled(isBypassEnabled: Boolean) {
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt
index 36ec18f..72cc08f 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt
@@ -26,11 +26,9 @@
import com.android.internal.logging.MetricsLogger
import com.android.internal.util.EmergencyAffordanceManager
import com.android.systemui.SysuiTestCase
-import com.android.systemui.authentication.data.model.AuthenticationMethodModel as DataLayerAuthenticationMethodModel
import com.android.systemui.authentication.data.repository.AuthenticationRepository
import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor
-import com.android.systemui.authentication.domain.model.AuthenticationMethodModel as DomainLayerAuthenticationMethodModel
import com.android.systemui.bouncer.data.repository.BouncerRepository
import com.android.systemui.bouncer.data.repository.EmergencyServicesRepository
import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepository
@@ -110,7 +108,6 @@
val deviceEntryRepository: FakeDeviceEntryRepository by lazy { FakeDeviceEntryRepository() }
val authenticationRepository: FakeAuthenticationRepository by lazy {
FakeAuthenticationRepository(
- deviceEntryRepository = deviceEntryRepository,
currentTime = { testScope.currentTime },
)
}
@@ -181,6 +178,7 @@
sceneInteractor = sceneInteractor,
deviceEntryFaceAuthRepository = faceAuthRepository,
trustRepository = trustRepository,
+ flags = FakeSceneContainerFlags(enabled = true)
)
}
@@ -192,7 +190,6 @@
repository = repository,
backgroundDispatcher = testDispatcher,
userRepository = userRepository,
- deviceEntryRepository = deviceEntryRepository,
clock = mock { whenever(elapsedRealtime()).thenAnswer { testScope.currentTime } }
)
}
@@ -221,17 +218,13 @@
}
fun bouncerInteractor(
- deviceEntryInteractor: DeviceEntryInteractor,
authenticationInteractor: AuthenticationInteractor,
- sceneInteractor: SceneInteractor,
): BouncerInteractor {
return BouncerInteractor(
applicationScope = applicationScope(),
applicationContext = context,
repository = BouncerRepository(featureFlags),
- deviceEntryInteractor = deviceEntryInteractor,
authenticationInteractor = authenticationInteractor,
- sceneInteractor = sceneInteractor,
flags = sceneContainerFlags,
falsingInteractor = falsingInteractor(),
)
@@ -345,19 +338,4 @@
dozeLogger = dozeLogger,
)
}
-
- companion object {
- fun DomainLayerAuthenticationMethodModel.toDataLayer(): DataLayerAuthenticationMethodModel {
- return when (this) {
- DomainLayerAuthenticationMethodModel.None -> DataLayerAuthenticationMethodModel.None
- DomainLayerAuthenticationMethodModel.Swipe ->
- DataLayerAuthenticationMethodModel.None
- DomainLayerAuthenticationMethodModel.Pin -> DataLayerAuthenticationMethodModel.Pin
- DomainLayerAuthenticationMethodModel.Password ->
- DataLayerAuthenticationMethodModel.Password
- DomainLayerAuthenticationMethodModel.Pattern ->
- DataLayerAuthenticationMethodModel.Pattern
- }
- }
- }
}