mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-13 20:48:56 +01:00
Allow weaker unlock methods (closes #4265)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package eu.kanade.tachiyomi.widget
|
||||
|
||||
import android.content.Context
|
||||
import androidx.biometric.BiometricManager
|
||||
import androidx.biometric.BiometricManager.Authenticators
|
||||
|
||||
object BiometricUtil {
|
||||
|
||||
fun getSupportedAuthenticators(context: Context): Int {
|
||||
return listOf(
|
||||
Authenticators.BIOMETRIC_STRONG,
|
||||
Authenticators.BIOMETRIC_WEAK,
|
||||
Authenticators.DEVICE_CREDENTIAL,
|
||||
)
|
||||
.filter { BiometricManager.from(context).canAuthenticate(it) == BiometricManager.BIOMETRIC_SUCCESS }
|
||||
.fold(0) { acc, auth -> acc or auth }
|
||||
}
|
||||
|
||||
fun isSupported(context: Context): Boolean {
|
||||
return getSupportedAuthenticators(context) != 0
|
||||
}
|
||||
|
||||
fun isDeviceCredentialAllowed(context: Context): Boolean {
|
||||
return getSupportedAuthenticators(context) and Authenticators.DEVICE_CREDENTIAL != 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user