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

Commit f9a62563 authored by Austin Delgado's avatar Austin Delgado
Browse files

Fix reset lockout behavior in Biometric Prompt

Fixes issue where returning to lockout after one reset crashes prompt.
Also allows propmt to launch when lockout has already occured.

Bug: 420950003
Test: atest PreAuthInfoTest AuthSessionTest
Flag: android.hardware.biometrics.bp_fallback_options

Change-Id: I84cc157adb5ac1cc4964051940f7dbdb96e7fb7d
parent 39b576bc
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ constructor(
            }

            when (kind) {
                is PromptKind.Biometric ->
                is PromptKind.Biometric -> {
                    BiometricPromptRequest.Biometric(
                        info = promptInfo,
                        userInfo =
@@ -189,6 +189,7 @@ constructor(
                            },
                        opPackageName = opPackageName,
                    )
                }
                else -> null
            }
        }
@@ -296,7 +297,6 @@ constructor(

    override fun onSwitchToCredential() {
        _currentView.value = BiometricPromptView.CREDENTIAL

        val modalities: BiometricModalities =
            if (promptRepository.promptKind.value.isBiometric())
                (promptRepository.promptKind.value as PromptKind.Biometric).activeModalities
@@ -366,9 +366,6 @@ constructor(
                _currentView.value = BiometricPromptView.CREDENTIAL
            }
        } else if (Utils.isBiometricAllowed(promptInfo) || showBpWithoutIconForCredential) {
            if (updateView) {
                _currentView.value = BiometricPromptView.BIOMETRIC
            }
            // TODO(b/330908557): Subscribe to
            // displayStateInteractor.currentRotation.value.isDefaultOrientation() for checking
            // `isLandscape` after removing AuthContainerView.
@@ -386,11 +383,14 @@ constructor(
                } else {
                    PromptKind.Biometric(modalities)
                }
            if (updateView) {
                _currentView.value = BiometricPromptView.BIOMETRIC
            }
        } else if (isDeviceCredentialAllowed(promptInfo)) {
            kind = getCredentialType(lockPatternUtils, effectiveUserId)
            if (updateView) {
                _currentView.value = BiometricPromptView.CREDENTIAL
            }
            kind = getCredentialType(lockPatternUtils, effectiveUserId)
        }

        promptRepository.setPrompt(
+2 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ object CredentialPasswordViewBinder {
                                        0, // flag
                                    )
                                    host.onCredentialMatched(attestation, isAllowed)
                                    viewModel.resetAttestation()
                                } else {
                                    passwordField.setText("")
                                }
@@ -106,6 +107,7 @@ object CredentialPasswordViewBinder {
                                    0, // flag
                                )
                                host.onCredentialMatched(attestation)
                                viewModel.resetAttestation()
                            } else {
                                passwordField.setText("")
                            }
+4 −0
Original line number Diff line number Diff line
@@ -196,6 +196,10 @@ constructor(
        promptSelectorInteractor.onSwitchToAuth()
    }

    suspend fun resetAttestation() {
        _validatedAttestation.emit(null)
    }

    /** Check a PIN or password and update [validatedAttestation] or [remainingAttempts]. */
    suspend fun checkCredential(text: CharSequence, header: CredentialHeaderViewModel) =
        checkCredential(promptCredentialInteractor.checkCredential(header.asRequest(), text = text))
+2 −1
Original line number Diff line number Diff line
@@ -692,7 +692,8 @@ public final class AuthSession implements IBinder.DeathRecipient {
            return;
        }

        if (mState != STATE_AUTH_PAUSED && mState != STATE_SHOWING_DEVICE_CREDENTIAL) {
        if (mState != STATE_AUTH_PAUSED && mState != STATE_SHOWING_DEVICE_CREDENTIAL
                && mState != STATE_AUTH_STARTED_UI_SHOWING) {
            Slog.w(TAG, "onResumeAuthentication, state: " + mState);
            return;
        }
+2 −1
Original line number Diff line number Diff line
@@ -284,7 +284,8 @@ class PreAuthInfo {
                    sensor.impl.getLockoutModeForUser(userId);
            if (lockoutMode == LockoutTracker.LOCKOUT_TIMED) {
                return BIOMETRIC_LOCKOUT_TIMED;
            } else if (lockoutMode == LockoutTracker.LOCKOUT_PERMANENT) {
            } else if (lockoutMode == LockoutTracker.LOCKOUT_PERMANENT
                    && !Flags.bpFallbackOptions()) {
                return BIOMETRIC_LOCKOUT_PERMANENT;
            }
        } catch (RemoteException e) {
Loading