diff --git a/library/src/main/java/moe/feng/support/biometricprompt/BiometricPromptApi23Impl.java b/library/src/main/java/moe/feng/support/biometricprompt/BiometricPromptApi23Impl.java index c81655d..6e8ddd0 100644 --- a/library/src/main/java/moe/feng/support/biometricprompt/BiometricPromptApi23Impl.java +++ b/library/src/main/java/moe/feng/support/biometricprompt/BiometricPromptApi23Impl.java @@ -97,10 +97,14 @@ public void authenticate( } this.cancellationSignal = cancel; this.callback = callback; - if (cancel == null) { - cancel = new CancellationSignal(); + if (cancellationSignal == null) { + cancellationSignal = new CancellationSignal(); } - cancel.setOnCancelListener(dialog::cancel); + CancellationSignal innerCancel = new CancellationSignal(); + cancellationSignal.setOnCancelListener(() -> { + innerCancel.cancel(); + dialog.cancel(); + }); dialog.setOnDismissListener(dialogInterface -> { if (cancellationSignal != null && !cancellationSignal.isCanceled()) { @@ -116,7 +120,7 @@ public void authenticate( dialog.getFingerprintIcon().setState( FingerprintIconView.State.ON, false); fingerprintManager.authenticate( - toCryptoObjectApi23(crypto), cancellationSignal, + toCryptoObjectApi23(crypto), innerCancel, 0, fmAuthCallback, mainHandler); }); @@ -133,16 +137,20 @@ BiometricPromptCompatDialog getAuthenticateDialogForFragment( } this.cancellationSignal = cancel; this.callback = callback; - if (cancel == null) { - cancel = new CancellationSignal(); + if (cancellationSignal == null) { + cancellationSignal = new CancellationSignal(); } - cancel.setOnCancelListener(dialog::cancel); + CancellationSignal innerCancel = new CancellationSignal(); + cancellationSignal.setOnCancelListener(() -> { + innerCancel.cancel(); + dialog.cancel(); + }); dialog.setOnShowListener(d -> { dialog.getFingerprintIcon().setState( FingerprintIconView.State.ON, false); fingerprintManager.authenticate( - toCryptoObjectApi23(crypto), cancellationSignal, + toCryptoObjectApi23(crypto), innerCancel, 0, fmAuthCallback, mainHandler); });