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

Commit b78c35bf authored by Junchen Quan's avatar Junchen Quan Committed by Android (Google) Code Review
Browse files

Merge "[Biometrics] Ensure AuthSession propagates fallback option dismissals to client." into main

parents fef35050 bb57d45b
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -893,7 +893,13 @@ public final class AuthSession implements IBinder.DeathRecipient {
                    break;

                default:
                    // Check range of fallback option values.
                    if (reason >= BiometricPrompt.DISMISSED_REASON_FALLBACK_OPTION_BASE
                            && reason < BiometricPrompt.DISMISSED_REASON_FALLBACK_OPTION_MAX) {
                        mClientReceiver.onDialogDismissed(reason);
                    } else {
                        Slog.w(TAG, "Unhandled reason: " + reason);
                    }
                    break;
            }
        } catch (RemoteException e) {
+28 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_NEG
import static android.hardware.biometrics.BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRMED;
import static android.hardware.biometrics.BiometricPrompt.DISMISSED_REASON_BIOMETRIC_CONFIRM_NOT_REQUIRED;
import static android.hardware.biometrics.BiometricPrompt.DISMISSED_REASON_CONTENT_VIEW_MORE_OPTIONS;
import static android.hardware.biometrics.BiometricPrompt.DISMISSED_REASON_FALLBACK_OPTION_BASE;
import static android.hardware.biometrics.BiometricPrompt.DISMISSED_REASON_NEGATIVE;
import static android.hardware.biometrics.BiometricPrompt.DISMISSED_REASON_USER_CANCEL;

@@ -673,6 +674,33 @@ public class AuthSessionTest {
                eq(0) /* userId */);
    }

    @Test
    public void onDialogDismissed_withFallbackReason_notifiesClientReceiverWithCorrectReason()
            throws RemoteException {
        setupFingerprint(0 /* id */, FingerprintSensorProperties.TYPE_REAR);

        final AuthSession session = createAuthSession(
                mSensors,
                false /* checkDevicePolicyManager */,
                Authenticators.BIOMETRIC_STRONG,
                TEST_REQUEST_ID,
                0 /* operationId */,
                0 /* userId */
        );

        session.onDialogDismissed(DISMISSED_REASON_FALLBACK_OPTION_BASE,
                null /* credentialAttestation */);

        verify(mClientReceiver).onDialogDismissed(
                eq(DISMISSED_REASON_FALLBACK_OPTION_BASE)
        );

        verify(mClientReceiver, never()).onError(anyInt(), anyInt(), anyInt());
        verify(mClientReceiver, never()).onAuthenticationSucceeded(anyInt());
        verify(mClientReceiver, never()).onAuthenticationFailed();
        verify(mClientReceiver, never()).onAcquired(anyInt(), any());
    }

    @Test
    public void onErrorReceivedAfterOnTryAgainPressedWhenSensorsAuthenticating() throws Exception {
        setupFingerprint(0 /* id */, FingerprintSensorProperties.TYPE_UDFPS_OPTICAL);