Skip to content

Commit

Permalink
PreferenceBaseActivity: Only attempt to use device credential auth on…
Browse files Browse the repository at this point in the history
… API >=30

Previous Android versions do not support it.

Issue: #93

Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
  • Loading branch information
chenxiaolong committed Oct 25, 2024
1 parent 7935f95 commit 432b7f1
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,14 @@ abstract class PreferenceBaseActivity : AppCompatActivity() {
private fun startBiometricAuth() {
Log.d(tag, "Starting biometric authentication")

val deviceCredential = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Authenticators.DEVICE_CREDENTIAL
} else {
0
}

val promptInfo = BiometricPrompt.PromptInfo.Builder()
.setAllowedAuthenticators(Authenticators.BIOMETRIC_STRONG or Authenticators.DEVICE_CREDENTIAL)
.setAllowedAuthenticators(Authenticators.BIOMETRIC_STRONG or deviceCredential)
.setTitle(getString(R.string.biometric_title))
.build()

Expand Down

0 comments on commit 432b7f1

Please sign in to comment.