From 0dcd0735545a9d5555b4090262db89b7413c385e Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 13 Jan 2018 05:49:47 +0800 Subject: [PATCH] Fix crashes on Lollipop --- .../magisk/utils/FingerprintHelper.java | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/topjohnwu/magisk/utils/FingerprintHelper.java b/src/main/java/com/topjohnwu/magisk/utils/FingerprintHelper.java index f9a961f7e..1808f06e5 100644 --- a/src/main/java/com/topjohnwu/magisk/utils/FingerprintHelper.java +++ b/src/main/java/com/topjohnwu/magisk/utils/FingerprintHelper.java @@ -18,7 +18,7 @@ import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; @TargetApi(Build.VERSION_CODES.M) -public abstract class FingerprintHelper extends FingerprintManager.AuthenticationCallback { +public abstract class FingerprintHelper { private FingerprintManager manager; private Cipher cipher; @@ -54,10 +54,38 @@ public abstract class FingerprintHelper extends FingerprintManager.Authenticatio } } + public abstract void onAuthenticationError(int errorCode, CharSequence errString); + + public abstract void onAuthenticationHelp(int helpCode, CharSequence helpString); + + public abstract void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result); + + public abstract void onAuthenticationFailed(); + public void startAuth() { cancel = new CancellationSignal(); FingerprintManager.CryptoObject cryptoObject = new FingerprintManager.CryptoObject(cipher); - manager.authenticate(cryptoObject, cancel, 0, this, null); + manager.authenticate(cryptoObject, cancel, 0, new FingerprintManager.AuthenticationCallback() { + @Override + public void onAuthenticationError(int errorCode, CharSequence errString) { + FingerprintHelper.this.onAuthenticationError(errorCode, errString); + } + + @Override + public void onAuthenticationHelp(int helpCode, CharSequence helpString) { + FingerprintHelper.this.onAuthenticationHelp(helpCode, helpString); + } + + @Override + public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) { + FingerprintHelper.this.onAuthenticationSucceeded(result); + } + + @Override + public void onAuthenticationFailed() { + FingerprintHelper.this.onAuthenticationFailed(); + } + }, null); } public void cancel() {