7

I'm implementing biometrics and I would like to be able to fall back to using PIN if user doesn't want/have biometrics.

The issue is that when the user selects "Use PIN", enters their pin, and authenticates two different callbacks get triggered:

The first: onAuthenticationSucceeded which is expected. The second: onAuthenticationError with BiometricConstants.ERROR_USER_CANCELED.

Why does entering a PIN instead of biometric trigger ERROR_USER_CANCELED? I had handled this error by finishing my Activity which is not what I want in this flow. I did so because when the user taps outside of the dialog I want to close the app and this same error triggers in that case (despite this fix).

Is there a way to differentiate between cancelling the dialog intentionally (through the back button or by tapping outside the dialog) and entering a PIN?

Here is my PromptInfo:

        val promptInfo = BiometricPrompt.PromptInfo.Builder()
                .setTitle(getString(R.string.lock_title))
                .setSubtitle(getString(R.string.lock_summary))
                .setConfirmationRequired(false)
                .setDeviceCredentialAllowed(true)
                .build()

Testing on a Pixel 2 with Android 10. Using version "androidx.biometric:biometric:1.0.1". Thank you!

alisonthemonster
  • 1,095
  • 1
  • 11
  • 28
  • I found this issue (https://issuetracker.google.com/issues/142740104), its similar but it has the error code ERROR_CANCELED instead of ERROR_USER_CANCELED. Related possibly? – alisonthemonster Jan 02 '20 at 22:47
  • 1
    As alisonthemonster commented, it is indeed a bug. I have a Mi 5S, on Android 8 with MIUI 11, the PIN works fine. However on my Android 10 Emulator,"USE PIN" will cause authentication get cancelled. Maybe this bug is only affecting Emulator images. – Tommy Vercetti Jun 27 '20 at 00:16

1 Answers1

0

its a bug still need to be solved, i am currently using redmi note 8 pro and getting same issue.