setDeviceCredentialAllowed and ERROR_USER_CANCELED
Asked Answered
L

1

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!

Lazes answered 2/1, 2020 at 22:27 Comment(2)
I found this issue (issuetracker.google.com/issues/142740104), its similar but it has the error code ERROR_CANCELED instead of ERROR_USER_CANCELED. Related possibly?Lazes
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.Alnico
S
0

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

Shani answered 5/1, 2021 at 9:57 Comment(1)
A reference to the issue/bug would help. So people could track if that bug has been fixed in the future.Flaming

© 2022 - 2024 — McMap. All rights reserved.