From 2b3915a91fa87219b0df92388166c7b0a0e2dfe3 Mon Sep 17 00:00:00 2001 From: Chris Date: Fri, 24 Apr 2020 00:28:43 +1000 Subject: [PATCH] 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. --- src/Android/Services/DeviceActionService.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Android/Services/DeviceActionService.cs b/src/Android/Services/DeviceActionService.cs index 02cee112a..78390e741 100644 --- a/src/Android/Services/DeviceActionService.cs +++ b/src/Android/Services/DeviceActionService.cs @@ -446,7 +446,8 @@ namespace Bit.Droid.Services new BiometricAuthenticationCallback { Success = authResult => result.TrySetResult(true), - Failed = () => result.TrySetResult(false), + Error = () => result.TrySetResult(false), + Failed = () => { }, Help = (helpCode, helpString) => { } }); return result.Task; @@ -866,6 +867,7 @@ namespace Bit.Droid.Services private class BiometricAuthenticationCallback : BiometricPrompt.AuthenticationCallback { public Action Success { get; set; } + public Action Error { get; set; } public Action Failed { get; set; } public Action Help { get; set; } @@ -875,6 +877,12 @@ namespace Bit.Droid.Services Success?.Invoke(authResult); } + public override void OnAuthenticationError([GeneratedEnum] BiometricErrorCode errorCode, Java.Lang.ICharSequence errString) + { + base.OnAuthenticationError(errorCode, errString); + Error?.Invoke(); + } + public override void OnAuthenticationFailed() { base.OnAuthenticationFailed();