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

Commit b5856147 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Introduce bouncer delay behind flag

Whenever the flag is enabled, the 250ms bouncer
delay is enabled as long as face auth is enrolled
and could run or if active unlock (regardless of whether
it's actually available) could've run based on the device
state.

This doesn't yet use the true active unlock available signal yet
since the API isn't available.

Test: atest PrimaryBouncerInteractorTest
Bug: 267322286
Change-Id: I1f87d2e4848f112880dad64995309ed384407b63
parent 348bb0e2
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -889,4 +889,8 @@
    -->
    <dimen name="shade_swipe_collapse_threshold">0.5</dimen>
    <!-- [END] MULTI SHADE -->

    <!-- Time (in ms) to delay the bouncer views from showing when passive auth may be used for
    device entry. -->
    <integer name="primary_bouncer_passive_auth_delay">250</integer>
</resources>
+27 −13
Original line number Diff line number Diff line
@@ -2884,7 +2884,19 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
    }

    /**
     * If the current state of the device allows for triggering active unlock. This does not
     * include active unlock availability.
     */
    public boolean canTriggerActiveUnlockBasedOnDeviceState() {
        return shouldTriggerActiveUnlock(/* shouldLog */ false);
    }

    private boolean shouldTriggerActiveUnlock() {
        return shouldTriggerActiveUnlock(/* shouldLog */ true);
    }

    private boolean shouldTriggerActiveUnlock(boolean shouldLog) {
        // Triggers:
        final boolean triggerActiveUnlockForAssistant = shouldTriggerActiveUnlockForAssistant();
        final boolean awakeKeyguard = mPrimaryBouncerFullyShown || mAlternateBouncerShowing
@@ -2914,6 +2926,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                        && !mKeyguardGoingAway
                        && !mSecureCameraLaunched;

        if (shouldLog) {
            // Aggregate relevant fields for debug logging.
            logListenerModelData(
                    new KeyguardActiveUnlockModel(
@@ -2927,6 +2940,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                            mSwitchingUser,
                            triggerActiveUnlockForAssistant,
                            userCanDismissLockScreen));
        }

        return shouldTriggerActiveUnlock;
    }
+0 −2
Original line number Diff line number Diff line
@@ -46,8 +46,6 @@ interface KeyguardFaceAuthModule {
        impl: SystemUIKeyguardFaceAuthInteractor
    ): KeyguardFaceAuthInteractor

    @Binds fun trustRepository(impl: TrustRepositoryImpl): TrustRepository

    companion object {
        @Provides
        @SysUISingleton
+2 −0
Original line number Diff line number Diff line
@@ -45,4 +45,6 @@ interface KeyguardRepositoryModule {

    @Binds
    fun keyguardBouncerRepository(impl: KeyguardBouncerRepositoryImpl): KeyguardBouncerRepository

    @Binds fun trustRepository(impl: TrustRepositoryImpl): TrustRepository
}
+14 −7
Original line number Diff line number Diff line
@@ -28,7 +28,9 @@ import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
@@ -40,6 +42,9 @@ import kotlinx.coroutines.flow.shareIn
interface TrustRepository {
    /** Flow representing whether the current user is trusted. */
    val isCurrentUserTrusted: Flow<Boolean>

    /** Flow representing whether active unlock is available for the current user. */
    val isCurrentUserActiveUnlockAvailable: StateFlow<Boolean>
}

@SysUISingleton
@@ -89,11 +94,13 @@ constructor(
            }
            .shareIn(applicationScope, started = SharingStarted.Eagerly, replay = 1)

    override val isCurrentUserTrusted: Flow<Boolean>
        get() =
    override val isCurrentUserTrusted: Flow<Boolean> =
        combine(trust, userRepository.selectedUserInfo, ::Pair)
            .map { latestTrustModelForUser[it.second.id]?.isTrusted ?: false }
            .distinctUntilChanged()
            .onEach { logger.isCurrentUserTrusted(it) }
            .onStart { emit(false) }

    // TODO: Implement based on TrustManager callback b/267322286
    override val isCurrentUserActiveUnlockAvailable: StateFlow<Boolean> = MutableStateFlow(true)
}
Loading