fix(biometric) Incorrect error reported on Android with no device passcode set and fallback allowed #2648
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe the problem
When performing biometric authentication on Android with no biometry or device credential set, but fallback credential allowed, the error
biometryNotEnrolled
is reported. While this error is technically correct, the expected error would bepasscodeNotSet
, closer matching the actual error and the behavior of other platforms.Steps to reproduce
In my case, I tested this using the
examples/api
app, but general reproduction steps are as follows:allowDeviceCredential
set to truebiometryNotEnrolled
as opposed topasscodeNotSet
Cause
In my testing, I found that the following seem to be the cause of the issue:
manager.isDeviceSecure
returns false that prevents settingAuthenticators.DEVICE_CREDENTIAL
as a valid authenticator -- This is actually intended behavior and isn't the root cause as seen nextERROR_NO_BIOMETRICS
even after allowing device credential on an insecure device (manager.isDeviceSecure == false
). It seems this is the intended behavior of the Android API, but nevertheless should be corrected in the biometric plugin aspasscodeNotSet
more accurately describes the error.Proposed solution
Override the error code and message to
ERROR_NO_DEVICE_CREDENTIAL
in the event that a fallback credential is allowed, but error codeERROR_NO_BIOMETRICS
was received.Additional notes
Also corrected the Android module mapping
ERROR_NO_DEVICE_CREDENTIAL
tonoDeviceCredential
when it should bepasscodeNotSet
.