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

Commit 7e73502a authored by Chandru S's avatar Chandru S
Browse files

Add API to interactors that are required for implementing the 2-line bouncer messages.

The subsequent CLs in this chain use the properties added here.

Bug: 299343534
Flag: ACONFIG com.android.systemui.compose_bouncer DEVELOPMENT
Test: added unit tests for all the interactors.
Change-Id: Ie5d5931386597406d28932d055421e15afe65574
parent 5978d49d
Loading
Loading
Loading
Loading
+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)
        }
}
+15 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.deviceentry.domain.interactor

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.data.repository.BiometricSettingsRepository
import com.android.systemui.keyguard.shared.model.AuthenticationFlags
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
@@ -31,9 +32,22 @@ class DeviceEntryBiometricSettingsInteractor
constructor(
    repository: BiometricSettingsRepository,
) {

    /**
     * Flags that control the device entry authentication behavior.
     *
     * This exposes why biometrics may not be currently allowed.
     */
    val authenticationFlags: Flow<AuthenticationFlags> = repository.authenticationFlags

    /** Whether the current user has enrolled and enabled fingerprint auth. */
    val isFingerprintAuthEnrolledAndEnabled: Flow<Boolean> =
        repository.isFingerprintEnrolledAndEnabled

    val fingerprintAuthCurrentlyAllowed: Flow<Boolean> =
        repository.isFingerprintAuthCurrentlyAllowed
    val faceAuthEnrolledAndEnabled: Flow<Boolean> = repository.isFaceAuthEnrolledAndEnabled
    /** Whether the current user has enrolled and enabled face auth. */
    val isFaceAuthEnrolledAndEnabled: Flow<Boolean> = repository.isFaceAuthEnrolledAndEnabled
    val faceAuthCurrentlyAllowed: Flow<Boolean> = repository.isFaceAuthCurrentlyAllowed

    /** Whether both fingerprint and face are enrolled and enabled for device entry. */
+4 −0
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@ interface DeviceEntryFaceAuthInteractor {
    /** Current detection status */
    val detectionStatus: Flow<FaceDetectionStatus>

    val lockedOut: Flow<Boolean>

    val authenticated: Flow<Boolean>

    /** Can face auth be run right now */
    fun canFaceAuthRun(): Boolean

+25 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.deviceentry.domain.interactor

import com.android.systemui.biometrics.data.repository.FingerprintPropertyRepository
import com.android.systemui.biometrics.shared.model.FingerprintSensorType
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.data.repository.DeviceEntryFingerprintAuthRepository
import com.android.systemui.keyguard.shared.model.ErrorFingerprintAuthenticationStatus
@@ -23,14 +25,20 @@ import com.android.systemui.keyguard.shared.model.FailFingerprintAuthenticationS
import com.android.systemui.keyguard.shared.model.FingerprintAuthenticationStatus
import com.android.systemui.keyguard.shared.model.HelpFingerprintAuthenticationStatus
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.map

@OptIn(ExperimentalCoroutinesApi::class)
@SysUISingleton
class DeviceEntryFingerprintAuthInteractor
@Inject
constructor(
    repository: DeviceEntryFingerprintAuthRepository,
    biometricSettingsInteractor: DeviceEntryBiometricSettingsInteractor,
    fingerprintPropertyRepository: FingerprintPropertyRepository,
) {
    /** Whether fingerprint authentication is currently running or not */
    val isRunning: Flow<Boolean> = repository.isRunning
@@ -47,4 +55,21 @@ constructor(
        repository.authenticationStatus.filterIsInstance<ErrorFingerprintAuthenticationStatus>()
    val fingerprintHelp: Flow<HelpFingerprintAuthenticationStatus> =
        repository.authenticationStatus.filterIsInstance<HelpFingerprintAuthenticationStatus>()

    /**
     * Whether fingerprint authentication is currently allowed for the user. This is true if the
     * user has fingerprint auth enabled, enrolled, it is not disabled by any security timeouts by
     * [com.android.systemui.keyguard.shared.model.AuthenticationFlags] and not locked out due to
     * too many incorrect attempts.
     */
    val isFingerprintAuthCurrentlyAllowed: Flow<Boolean> =
        combine(isLockedOut, biometricSettingsInteractor.fingerprintAuthCurrentlyAllowed, ::Pair)
            .map { (lockedOut, currentlyAllowed) -> !lockedOut && currentlyAllowed }

    /**
     * Whether the fingerprint sensor is present under the display as opposed to being on the power
     * button or behind/rear of the phone.
     */
    val isSensorUnderDisplay =
        fingerprintPropertyRepository.sensorType.map(FingerprintSensorType::isUdfps)
}
+2 −2
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ constructor(

    private fun startUpdatingFaceHelpMessageDeferral() {
        scope.launch {
            biometricSettingsInteractor.faceAuthEnrolledAndEnabled
            biometricSettingsInteractor.isFaceAuthEnrolledAndEnabled
                .flatMapLatest { faceEnrolledAndEnabled ->
                    if (faceEnrolledAndEnabled) {
                        faceAcquired
@@ -94,7 +94,7 @@ constructor(
        }

        scope.launch {
            biometricSettingsInteractor.faceAuthEnrolledAndEnabled
            biometricSettingsInteractor.isFaceAuthEnrolledAndEnabled
                .flatMapLatest { faceEnrolledAndEnabled ->
                    if (faceEnrolledAndEnabled) {
                        faceHelp
Loading