diff options
author | Harsh Shandilya <msfjarvis@gmail.com> | 2020-08-23 16:41:04 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-23 16:41:04 +0530 |
commit | 2414c48d9fa2adab76721ba03eb07d7e68159007 (patch) | |
tree | 4ca982c79703e68129cfb8bff6c04adce6231dd2 /app/src/main/java | |
parent | 70aa41ae61fdfae1cbf2093cd5848c5808b08013 (diff) |
BiometricAuthenticator: fix multiple regressions from AndroidX update (#1045)
Fixes: 80e43e5675bf ("Update dependencies (#1039)")
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/utils/BiometricAuthenticator.kt | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/BiometricAuthenticator.kt b/app/src/main/java/com/zeapo/pwdstore/utils/BiometricAuthenticator.kt index 11db7ed0..648ed3e1 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/BiometricAuthenticator.kt +++ b/app/src/main/java/com/zeapo/pwdstore/utils/BiometricAuthenticator.kt @@ -9,6 +9,7 @@ import android.os.Handler import androidx.annotation.StringRes import androidx.biometric.BiometricConstants import androidx.biometric.BiometricManager +import androidx.biometric.BiometricManager.Authenticators import androidx.biometric.BiometricPrompt import androidx.core.content.getSystemService import androidx.fragment.app.FragmentActivity @@ -60,13 +61,15 @@ object BiometricAuthenticator { callback(Result.Success(result.cryptoObject)) } } - val biometricPrompt = BiometricPrompt(activity, { handler.post(it) }, authCallback) - val promptInfo = BiometricPrompt.PromptInfo.Builder() - .setTitle(activity.getString(dialogTitleRes)) - .build() - if (BiometricManager.from(activity).canAuthenticate(BiometricManager.Authenticators.DEVICE_CREDENTIAL) - == BiometricManager.BIOMETRIC_SUCCESS || activity.getSystemService<KeyguardManager>()?.isDeviceSecure == true) { - biometricPrompt.authenticate(promptInfo) + val validAuthenticators = Authenticators.DEVICE_CREDENTIAL or Authenticators.BIOMETRIC_STRONG + val canAuth = BiometricManager.from(activity).canAuthenticate(validAuthenticators) == BiometricManager.BIOMETRIC_SUCCESS + val deviceHasKeyguard = activity.getSystemService<KeyguardManager>()?.isDeviceSecure == true + if (canAuth || deviceHasKeyguard) { + val promptInfo = BiometricPrompt.PromptInfo.Builder() + .setTitle(activity.getString(dialogTitleRes)) + .setAllowedAuthenticators(validAuthenticators) + .build() + BiometricPrompt(activity, { handler.post(it) }, authCallback).authenticate(promptInfo) } else { callback(Result.HardwareUnavailableOrDisabled) } |