Allow a BiometricPrompt to succeed after an initial failure (#791) (#847)

Previously a call to BiometricPrompt.AuthenticationCallback#OnAuthenticationFailed()
was treated as though an unrecoverable failure had occurred. However this is called on
each failed fingerprint match, for example, and is not a terminal failure. Now these
intermittent failures are ignored and a call to #OnAuthenticationError() is recognised
as an unrecoverable failure instead.
This commit is contained in:
Chris 2020-04-24 00:28:43 +10:00 committed by GitHub
parent 9a403ba0ed
commit 2b3915a91f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -446,7 +446,8 @@ namespace Bit.Droid.Services
new BiometricAuthenticationCallback new BiometricAuthenticationCallback
{ {
Success = authResult => result.TrySetResult(true), Success = authResult => result.TrySetResult(true),
Failed = () => result.TrySetResult(false), Error = () => result.TrySetResult(false),
Failed = () => { },
Help = (helpCode, helpString) => { } Help = (helpCode, helpString) => { }
}); });
return result.Task; return result.Task;
@ -866,6 +867,7 @@ namespace Bit.Droid.Services
private class BiometricAuthenticationCallback : BiometricPrompt.AuthenticationCallback private class BiometricAuthenticationCallback : BiometricPrompt.AuthenticationCallback
{ {
public Action<BiometricPrompt.AuthenticationResult> Success { get; set; } public Action<BiometricPrompt.AuthenticationResult> Success { get; set; }
public Action Error { get; set; }
public Action Failed { get; set; } public Action Failed { get; set; }
public Action<BiometricAcquiredStatus, Java.Lang.ICharSequence> Help { get; set; } public Action<BiometricAcquiredStatus, Java.Lang.ICharSequence> Help { get; set; }
@ -875,6 +877,12 @@ namespace Bit.Droid.Services
Success?.Invoke(authResult); Success?.Invoke(authResult);
} }
public override void OnAuthenticationError([GeneratedEnum] BiometricErrorCode errorCode, Java.Lang.ICharSequence errString)
{
base.OnAuthenticationError(errorCode, errString);
Error?.Invoke();
}
public override void OnAuthenticationFailed() public override void OnAuthenticationFailed()
{ {
base.OnAuthenticationFailed(); base.OnAuthenticationFailed();