Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e35ff4f3 authored by Chandru S's avatar Chandru S Committed by Android (Google) Code Review
Browse files

Merge changes If71980e6,Ie5d59313,Ic86aebc9 into main

* changes:
  [flexiglass] Add device entry restriction reason to DeviceEntryInteractor
  Add API to interactors that are required for implementing the 2-line bouncer messages.
  Expose sim bouncer messages as events instead of state.
parents 4127d641 ba160eb4
Loading
Loading
Loading
Loading
+34 −18
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
@@ -201,6 +202,7 @@ class SimBouncerInteractorTest : SysuiTestCase() {
    @Test
    fun verifySimPin() =
        testScope.runTest {
            val msg by collectLastValue(underTest.bouncerMessageChanged)
            bouncerSimRepository.setSubscriptionId(1)
            bouncerSimRepository.setSimPukLocked(false)
            whenever(telephonyManager.createForSubscriptionId(anyInt()))
@@ -208,8 +210,7 @@ class SimBouncerInteractorTest : SysuiTestCase() {
            whenever(telephonyManager.supplyIccLockPin(anyString()))
                .thenReturn(PinResult(PinResult.PIN_RESULT_TYPE_SUCCESS, 1))

            val msg: String? = underTest.verifySim(listOf(0, 0, 0, 0))
            runCurrent()
            verifySim(listOf(0, 0, 0, 0))
            assertThat(msg).isNull()

            verify(keyguardUpdateMonitor).reportSimUnlocked(1)
@@ -218,6 +219,7 @@ class SimBouncerInteractorTest : SysuiTestCase() {
    @Test
    fun verifySimPin_incorrect_oneRemainingAttempt() =
        testScope.runTest {
            val msg by collectLastValue(underTest.bouncerMessageChanged)
            bouncerSimRepository.setSubscriptionId(1)
            bouncerSimRepository.setSimPukLocked(false)
            whenever(telephonyManager.createForSubscriptionId(anyInt()))
@@ -229,9 +231,7 @@ class SimBouncerInteractorTest : SysuiTestCase() {
                        1,
                    )
                )

            val msg: String? = underTest.verifySim(listOf(0, 0, 0, 0))
            runCurrent()
            verifySim(listOf(0, 0, 0, 0))

            assertThat(msg).isNull()
            val errorDialogMessage by collectLastValue(bouncerSimRepository.errorDialogMessage)
@@ -245,6 +245,7 @@ class SimBouncerInteractorTest : SysuiTestCase() {
    @Test
    fun verifySimPin_incorrect_threeRemainingAttempts() =
        testScope.runTest {
            val msg by collectLastValue(underTest.bouncerMessageChanged)
            bouncerSimRepository.setSubscriptionId(1)
            bouncerSimRepository.setSimPukLocked(false)
            whenever(telephonyManager.createForSubscriptionId(anyInt()))
@@ -257,8 +258,7 @@ class SimBouncerInteractorTest : SysuiTestCase() {
                    )
                )

            val msg = underTest.verifySim(listOf(0, 0, 0, 0))
            runCurrent()
            verifySim(listOf(0, 0, 0, 0))

            assertThat(msg).isEqualTo("Enter SIM PIN. You have 3 remaining attempts.")
        }
@@ -266,10 +266,11 @@ class SimBouncerInteractorTest : SysuiTestCase() {
    @Test
    fun verifySimPin_notCorrectLength_tooShort() =
        testScope.runTest {
            val msg by collectLastValue(underTest.bouncerMessageChanged)
            bouncerSimRepository.setSubscriptionId(1)
            bouncerSimRepository.setSimPukLocked(false)

            val msg = underTest.verifySim(listOf(0))
            verifySim(listOf(0))

            assertThat(msg).isEqualTo(resources.getString(R.string.kg_invalid_sim_pin_hint))
        }
@@ -277,10 +278,12 @@ class SimBouncerInteractorTest : SysuiTestCase() {
    @Test
    fun verifySimPin_notCorrectLength_tooLong() =
        testScope.runTest {
            val msg by collectLastValue(underTest.bouncerMessageChanged)

            bouncerSimRepository.setSubscriptionId(1)
            bouncerSimRepository.setSimPukLocked(false)

            val msg = underTest.verifySim(listOf(0, 0, 0, 0, 0, 0, 0, 0, 0))
            verifySim(listOf(0, 0, 0, 0, 0, 0, 0, 0, 0))

            assertThat(msg).isEqualTo(resources.getString(R.string.kg_invalid_sim_pin_hint))
        }
@@ -288,6 +291,7 @@ class SimBouncerInteractorTest : SysuiTestCase() {
    @Test
    fun verifySimPuk() =
        testScope.runTest {
            val msg by collectLastValue(underTest.bouncerMessageChanged)
            whenever(telephonyManager.createForSubscriptionId(anyInt()))
                .thenReturn(telephonyManager)
            whenever(telephonyManager.supplyIccLockPuk(anyString(), anyString()))
@@ -295,13 +299,13 @@ class SimBouncerInteractorTest : SysuiTestCase() {
            bouncerSimRepository.setSubscriptionId(1)
            bouncerSimRepository.setSimPukLocked(true)

            var msg = underTest.verifySim(listOf(0, 0, 0, 0, 0, 0, 0, 0, 0))
            verifySim(listOf(0, 0, 0, 0, 0, 0, 0, 0, 0))
            assertThat(msg).isEqualTo(resources.getString(R.string.kg_puk_enter_pin_hint))

            msg = underTest.verifySim(listOf(0, 0, 0, 0))
            verifySim(listOf(0, 0, 0, 0))
            assertThat(msg).isEqualTo(resources.getString(R.string.kg_enter_confirm_pin_hint))

            msg = underTest.verifySim(listOf(0, 0, 0, 0))
            verifySim(listOf(0, 0, 0, 0))
            assertThat(msg).isNull()

            runCurrent()
@@ -311,37 +315,49 @@ class SimBouncerInteractorTest : SysuiTestCase() {
    @Test
    fun verifySimPuk_inputTooShort() =
        testScope.runTest {
            val msg by collectLastValue(underTest.bouncerMessageChanged)

            bouncerSimRepository.setSubscriptionId(1)
            bouncerSimRepository.setSimPukLocked(true)
            val msg = underTest.verifySim(listOf(0, 0, 0, 0))

            verifySim(listOf(0, 0, 0, 0))
            assertThat(msg).isEqualTo(resources.getString(R.string.kg_invalid_sim_puk_hint))
        }

    @Test
    fun verifySimPuk_pinNotCorrectLength() =
        testScope.runTest {
            val msg by collectLastValue(underTest.bouncerMessageChanged)
            bouncerSimRepository.setSubscriptionId(1)
            bouncerSimRepository.setSimPukLocked(true)

            underTest.verifySim(listOf(0, 0, 0, 0, 0, 0, 0, 0, 0))
            verifySim(listOf(0, 0, 0, 0, 0, 0, 0, 0, 0))

            verifySim(listOf(0, 0, 0))

            val msg = underTest.verifySim(listOf(0, 0, 0))
            assertThat(msg).isEqualTo(resources.getString(R.string.kg_invalid_sim_pin_hint))
        }

    @Test
    fun verifySimPuk_confirmedPinDoesNotMatch() =
        testScope.runTest {
            val msg by collectLastValue(underTest.bouncerMessageChanged)

            bouncerSimRepository.setSubscriptionId(1)
            bouncerSimRepository.setSimPukLocked(true)

            underTest.verifySim(listOf(0, 0, 0, 0, 0, 0, 0, 0, 0))
            underTest.verifySim(listOf(0, 0, 0, 0))
            verifySim(listOf(0, 0, 0, 0, 0, 0, 0, 0, 0))
            verifySim(listOf(0, 0, 0, 0))

            val msg = underTest.verifySim(listOf(0, 0, 0, 1))
            verifySim(listOf(0, 0, 0, 1))
            assertThat(msg).isEqualTo(resources.getString(R.string.kg_puk_enter_pin_hint))
        }

    private suspend fun TestScope.verifySim(pinDigits: List<Int>) {
        runCurrent()
        underTest.verifySim(pinDigits)
    }

    @Test
    fun onErrorDialogDismissed_clearsErrorDialogMessageInRepository() {
        bouncerSimRepository.setSimVerificationErrorMessage("abc")
+23 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.data.repository.biometricSettingsRepository
import com.android.systemui.kosmos.testScope
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -35,6 +36,7 @@ class DeviceEntryBiometricSettingsInteractorTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val biometricSettingsRepository = kosmos.biometricSettingsRepository
    private val underTest = kosmos.deviceEntryBiometricSettingsInteractor
    private val testScope = kosmos.testScope

    @Test
    fun isCoex_true() = runTest {
@@ -59,4 +61,25 @@ class DeviceEntryBiometricSettingsInteractorTest : SysuiTestCase() {
        biometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true)
        assertThat(isCoex).isFalse()
    }

    @Test
    fun authenticationFlags_providesAuthFlagsFromRepository() =
        testScope.runTest {
            assertThat(underTest.authenticationFlags)
                .isSameInstanceAs(biometricSettingsRepository.authenticationFlags)
        }

    @Test
    fun isFaceAuthEnrolledAndEnabled_providesValueFromRepository() =
        testScope.runTest {
            assertThat(underTest.isFaceAuthEnrolledAndEnabled)
                .isSameInstanceAs(biometricSettingsRepository.isFaceAuthEnrolledAndEnabled)
        }

    @Test
    fun isFingerprintAuthEnrolledAndEnabled_providesValueFromRepository() =
        testScope.runTest {
            assertThat(underTest.isFingerprintAuthEnrolledAndEnabled)
                .isSameInstanceAs(biometricSettingsRepository.isFingerprintEnrolledAndEnabled)
        }
}
+214 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.deviceentry.domain.interactor
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.compose.animation.scene.SceneKey
import com.android.internal.widget.LockPatternUtils
import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository
import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository
@@ -27,8 +28,21 @@ import com.android.systemui.authentication.shared.model.AuthenticationMethodMode
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.deviceentry.data.repository.fakeDeviceEntryRepository
import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReason
import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReason.AdaptiveAuthRequest
import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReason.BouncerLockedOut
import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReason.DeviceNotUnlockedSinceReboot
import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReason.NonStrongBiometricsSecurityTimeout
import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReason.PolicyLockdown
import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReason.SecurityTimeout
import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReason.TrustAgentDisabled
import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReason.UnattendedUpdate
import com.android.systemui.deviceentry.shared.model.DeviceEntryRestrictionReason.UserLockdown
import com.android.systemui.flags.fakeSystemPropertiesHelper
import com.android.systemui.keyguard.data.repository.fakeBiometricSettingsRepository
import com.android.systemui.keyguard.data.repository.fakeDeviceEntryFaceAuthRepository
import com.android.systemui.keyguard.data.repository.fakeTrustRepository
import com.android.systemui.keyguard.shared.model.AuthenticationFlags
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags
@@ -36,6 +50,7 @@ import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
@@ -230,8 +245,8 @@ class DeviceEntryInteractorTest : SysuiTestCase() {
            assertThat(canSwipeToEnter).isFalse()

            trustRepository.setCurrentUserTrusted(true)
            runCurrent()
            faceAuthRepository.isAuthenticated.value = false
            runCurrent()

            assertThat(canSwipeToEnter).isTrue()
        }
@@ -383,6 +398,204 @@ class DeviceEntryInteractorTest : SysuiTestCase() {
            assertThat(isUnlocked).isTrue()
        }

    @Test
    fun deviceEntryRestrictionReason_whenFaceOrFingerprintOrTrust_alwaysNull() =
        testScope.runTest {
            kosmos.fakeBiometricSettingsRepository.setIsFaceAuthEnrolledAndEnabled(false)
            kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(false)
            kosmos.fakeTrustRepository.setTrustUsuallyManaged(false)
            runCurrent()

            verifyRestrictionReasonsForAuthFlags(
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT to null,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST to null,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT to null,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_TIMEOUT to null,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN to null,
                LockPatternUtils.StrongAuthTracker
                    .STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT to null,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED to
                    null,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_FOR_UNATTENDED_UPDATE to
                    null,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW to null
            )
        }

    @Test
    fun deviceEntryRestrictionReason_whenFaceIsEnrolledAndEnabled_mapsToAuthFlagsState() =
        testScope.runTest {
            kosmos.fakeBiometricSettingsRepository.setIsFaceAuthEnrolledAndEnabled(true)
            kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(false)
            kosmos.fakeTrustRepository.setTrustUsuallyManaged(false)
            kosmos.fakeSystemPropertiesHelper.set(
                DeviceEntryInteractor.SYS_BOOT_REASON_PROP,
                "not mainline reboot"
            )
            runCurrent()

            verifyRestrictionReasonsForAuthFlags(
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT to
                    DeviceNotUnlockedSinceReboot,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST to
                    AdaptiveAuthRequest,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT to
                    BouncerLockedOut,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_TIMEOUT to
                    SecurityTimeout,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN to
                    UserLockdown,
                LockPatternUtils.StrongAuthTracker
                    .STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT to
                    NonStrongBiometricsSecurityTimeout,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_FOR_UNATTENDED_UPDATE to
                    UnattendedUpdate,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW to
                    PolicyLockdown,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST to null,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED to
                    null,
            )
        }

    @Test
    fun deviceEntryRestrictionReason_whenFingerprintIsEnrolledAndEnabled_mapsToAuthFlagsState() =
        testScope.runTest {
            kosmos.fakeBiometricSettingsRepository.setIsFaceAuthEnrolledAndEnabled(false)
            kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true)
            kosmos.fakeTrustRepository.setTrustUsuallyManaged(false)
            kosmos.fakeSystemPropertiesHelper.set(
                DeviceEntryInteractor.SYS_BOOT_REASON_PROP,
                "not mainline reboot"
            )
            runCurrent()

            verifyRestrictionReasonsForAuthFlags(
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT to
                    DeviceNotUnlockedSinceReboot,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST to
                    AdaptiveAuthRequest,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT to
                    BouncerLockedOut,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_TIMEOUT to
                    SecurityTimeout,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN to
                    UserLockdown,
                LockPatternUtils.StrongAuthTracker
                    .STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT to
                    NonStrongBiometricsSecurityTimeout,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_FOR_UNATTENDED_UPDATE to
                    UnattendedUpdate,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW to
                    PolicyLockdown,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST to null,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED to
                    null,
            )
        }

    @Test
    fun deviceEntryRestrictionReason_whenTrustAgentIsEnabled_mapsToAuthFlagsState() =
        testScope.runTest {
            kosmos.fakeBiometricSettingsRepository.setIsFaceAuthEnrolledAndEnabled(false)
            kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(false)
            kosmos.fakeTrustRepository.setTrustUsuallyManaged(true)
            kosmos.fakeTrustRepository.setCurrentUserTrustManaged(false)
            kosmos.fakeSystemPropertiesHelper.set(
                DeviceEntryInteractor.SYS_BOOT_REASON_PROP,
                "not mainline reboot"
            )
            runCurrent()

            verifyRestrictionReasonsForAuthFlags(
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT to
                    DeviceNotUnlockedSinceReboot,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST to
                    AdaptiveAuthRequest,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT to
                    BouncerLockedOut,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_TIMEOUT to
                    SecurityTimeout,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN to
                    UserLockdown,
                LockPatternUtils.StrongAuthTracker
                    .STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT to
                    NonStrongBiometricsSecurityTimeout,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_FOR_UNATTENDED_UPDATE to
                    UnattendedUpdate,
                LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW to
                    PolicyLockdown,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST to
                    TrustAgentDisabled,
                LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED to
                    TrustAgentDisabled,
            )
        }

    @Test
    fun deviceEntryRestrictionReason_whenDeviceRebootedForMainlineUpdate_mapsToTheCorrectReason() =
        testScope.runTest {
            val deviceEntryRestrictionReason by
                collectLastValue(underTest.deviceEntryRestrictionReason)
            kosmos.fakeSystemPropertiesHelper.set(
                DeviceEntryInteractor.SYS_BOOT_REASON_PROP,
                DeviceEntryInteractor.REBOOT_MAINLINE_UPDATE
            )
            kosmos.fakeBiometricSettingsRepository.setAuthenticationFlags(
                AuthenticationFlags(
                    userId = 1,
                    flag = LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT
                )
            )
            runCurrent()

            kosmos.fakeBiometricSettingsRepository.setIsFaceAuthEnrolledAndEnabled(false)
            kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(false)
            kosmos.fakeTrustRepository.setTrustUsuallyManaged(false)
            runCurrent()

            assertThat(deviceEntryRestrictionReason).isNull()

            kosmos.fakeBiometricSettingsRepository.setIsFaceAuthEnrolledAndEnabled(true)
            runCurrent()

            assertThat(deviceEntryRestrictionReason)
                .isEqualTo(DeviceEntryRestrictionReason.DeviceNotUnlockedSinceMainlineUpdate)

            kosmos.fakeBiometricSettingsRepository.setIsFaceAuthEnrolledAndEnabled(false)
            kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(true)
            runCurrent()

            assertThat(deviceEntryRestrictionReason)
                .isEqualTo(DeviceEntryRestrictionReason.DeviceNotUnlockedSinceMainlineUpdate)

            kosmos.fakeBiometricSettingsRepository.setIsFingerprintAuthEnrolledAndEnabled(false)
            kosmos.fakeTrustRepository.setTrustUsuallyManaged(true)
            runCurrent()

            assertThat(deviceEntryRestrictionReason)
                .isEqualTo(DeviceEntryRestrictionReason.DeviceNotUnlockedSinceMainlineUpdate)
        }

    private fun TestScope.verifyRestrictionReasonsForAuthFlags(
        vararg authFlagToDeviceEntryRestriction: Pair<Int, DeviceEntryRestrictionReason?>
    ) {
        val deviceEntryRestrictionReason by collectLastValue(underTest.deviceEntryRestrictionReason)

        authFlagToDeviceEntryRestriction.forEach { (flag, expectedReason) ->
            kosmos.fakeBiometricSettingsRepository.setAuthenticationFlags(
                AuthenticationFlags(userId = 1, flag = flag)
            )
            runCurrent()

            if (expectedReason == null) {
                assertThat(deviceEntryRestrictionReason).isNull()
            } else {
                assertThat(deviceEntryRestrictionReason).isEqualTo(expectedReason)
            }
        }
    }

    private fun switchToScene(sceneKey: SceneKey) {
        sceneInteractor.changeScene(sceneKey, "reason")
    }
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ class ShadeControllerSceneImplTest : SysuiTestCase() {
    private val kosmos = Kosmos()
    private val testScope = kosmos.testScope
    private val sceneInteractor = kosmos.sceneInteractor
    private val deviceEntryInteractor = kosmos.deviceEntryInteractor
    private val deviceEntryInteractor by lazy { kosmos.deviceEntryInteractor }

    private lateinit var shadeInteractor: ShadeInteractor
    private lateinit var underTest: ShadeControllerSceneImpl
+1 −1
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ constructor(
                        )
                        .toMessage()
                } else if (
                    trustOrBiometricsAvailable && flags.primaryAuthRequiredForUnattendedUpdate
                    trustOrBiometricsAvailable && flags.isPrimaryAuthRequiredForUnattendedUpdate
                ) {
                    BouncerMessageStrings.authRequiredForUnattendedUpdate(
                            currentSecurityMode.toAuthModel()
Loading