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

Commit e31362de authored by Chandru S's avatar Chandru S
Browse files

Remove redundant methods and change existing flows to StateFlows

The underlying flows are already StateFlows and this removes duplicate
method that are not required anymore.

Bug: 328783311
Test: everything builds
Flag: NONE removes duplicate methods
Change-Id: I60b52eba0688ae67dec19eeb17308c6543b0667f
parent a713e174
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1384,7 +1384,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
     */
    @Deprecated
    public boolean getIsFaceAuthenticated() {
        return getFaceAuthInteractor() != null && getFaceAuthInteractor().isAuthenticated();
        return getFaceAuthInteractor() != null
                && getFaceAuthInteractor().isAuthenticated().getValue();
    }

    public boolean getUserCanSkipBouncer(int userId) {
@@ -1426,7 +1427,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
     */
    @Deprecated
    public boolean isCurrentUserUnlockedWithFace() {
        return getFaceAuthInteractor() != null && getFaceAuthInteractor().isAuthenticated();
        return getFaceAuthInteractor() != null
                && getFaceAuthInteractor().isAuthenticated().getValue();
    }

    /**
@@ -1516,7 +1518,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            return false;
        }
        boolean isFaceLockedOut =
                getFaceAuthInteractor() != null && getFaceAuthInteractor().isLockedOut();
                getFaceAuthInteractor() != null && getFaceAuthInteractor().isLockedOut().getValue();
        boolean isFaceAuthStrong =
                getFaceAuthInteractor() != null && getFaceAuthInteractor().isFaceAuthStrong();
        boolean isFingerprintLockedOut = isFingerprintLockedOut();
@@ -2967,7 +2969,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
     */
    @Deprecated
    public boolean isFaceLockedOut() {
        return getFaceAuthInteractor() != null && getFaceAuthInteractor().isLockedOut();
        return getFaceAuthInteractor() != null && getFaceAuthInteractor().isLockedOut().getValue();
    }

    /**
+3 −7
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.deviceentry.domain.interactor
import com.android.systemui.deviceentry.shared.model.FaceAuthenticationStatus
import com.android.systemui.deviceentry.shared.model.FaceDetectionStatus
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow

/**
 * Interactor that exposes API to get the face authentication status and handle any events that can
@@ -32,9 +33,9 @@ interface DeviceEntryFaceAuthInteractor {
    /** Current detection status */
    val detectionStatus: Flow<FaceDetectionStatus>

    val lockedOut: Flow<Boolean>
    val isLockedOut: StateFlow<Boolean>

    val authenticated: Flow<Boolean>
    val isAuthenticated: StateFlow<Boolean>

    /** Whether bypass is enabled. If enabled, face unlock dismisses the lock screen. */
    val isBypassEnabled: Flow<Boolean>
@@ -45,14 +46,9 @@ interface DeviceEntryFaceAuthInteractor {
    /** Whether face auth is currently running or not. */
    fun isRunning(): Boolean

    /** Whether face auth is in lock out state. */
    fun isLockedOut(): Boolean

    /** Whether face auth is enrolled and enabled for the current user */
    fun isFaceAuthEnabledAndEnrolled(): Boolean

    /** Whether the current user is authenticated successfully with face auth */
    fun isAuthenticated(): Boolean
    /**
     * Register listener for use from code that cannot use [authenticationStatus] or
     * [detectionStatus]
+1 −1
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ constructor(
            if (faceEnabled || fingerprintEnabled || trustEnabled) {
                combine(
                        biometricSettingsInteractor.authenticationFlags,
                        faceAuthInteractor.lockedOut,
                        faceAuthInteractor.isLockedOut,
                        fingerprintAuthInteractor.isLockedOut,
                        trustInteractor.isTrustAgentCurrentlyAllowed,
                        ::Quad
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ constructor(
    private val deviceUnlockSource =
        merge(
            fingerprintAuthInteractor.fingerprintSuccess.map { DeviceUnlockSource.Fingerprint },
            faceAuthInteractor.authenticated
            faceAuthInteractor.isAuthenticated
                .filter { it }
                .map {
                    if (deviceEntryRepository.isBypassEnabled.value) {
+4 −6
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import com.android.systemui.deviceentry.shared.model.FaceAuthenticationStatus
import com.android.systemui.deviceentry.shared.model.FaceDetectionStatus
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flowOf

@@ -34,22 +36,18 @@ import kotlinx.coroutines.flow.flowOf
class NoopDeviceEntryFaceAuthInteractor @Inject constructor() : DeviceEntryFaceAuthInteractor {
    override val authenticationStatus: Flow<FaceAuthenticationStatus> = emptyFlow()
    override val detectionStatus: Flow<FaceDetectionStatus> = emptyFlow()
    override val lockedOut: Flow<Boolean> = emptyFlow()
    override val authenticated: Flow<Boolean> = emptyFlow()
    override val isLockedOut: StateFlow<Boolean> = MutableStateFlow(false)
    override val isAuthenticated: StateFlow<Boolean> = MutableStateFlow(false)
    override val isBypassEnabled: Flow<Boolean> = flowOf(false)

    override fun canFaceAuthRun(): Boolean = false

    override fun isRunning(): Boolean = false

    override fun isLockedOut(): Boolean = false

    override fun isFaceAuthEnabledAndEnrolled(): Boolean = false

    override fun isFaceAuthStrong(): Boolean = false

    override fun isAuthenticated(): Boolean = false

    override fun registerListener(listener: FaceAuthenticationListener) {}

    override fun unregisterListener(listener: FaceAuthenticationListener) {}
Loading