mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 16:45:06 +01:00
Allow weaker unlock methods in Android 6 - 10 (fixes #4833)
This commit is contained in:
parent
0586e1d3ad
commit
126e1e2d9d
@ -6,6 +6,7 @@ import androidx.biometric.BiometricPrompt
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.util.system.BiometricUtil
|
import eu.kanade.tachiyomi.util.system.BiometricUtil
|
||||||
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
@ -27,6 +28,7 @@ class BiometricUnlockActivity : AppCompatActivity() {
|
|||||||
object : BiometricPrompt.AuthenticationCallback() {
|
object : BiometricPrompt.AuthenticationCallback() {
|
||||||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
||||||
super.onAuthenticationError(errorCode, errString)
|
super.onAuthenticationError(errorCode, errString)
|
||||||
|
Timber.e(errString.toString())
|
||||||
finishAffinity()
|
finishAffinity()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,17 @@
|
|||||||
package eu.kanade.tachiyomi.util.system
|
package eu.kanade.tachiyomi.util.system
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
import androidx.biometric.BiometricManager
|
import androidx.biometric.BiometricManager
|
||||||
import androidx.biometric.BiometricManager.Authenticators
|
import androidx.biometric.BiometricManager.Authenticators
|
||||||
|
|
||||||
object BiometricUtil {
|
object BiometricUtil {
|
||||||
|
|
||||||
fun getSupportedAuthenticators(context: Context): Int {
|
fun getSupportedAuthenticators(context: Context): Int {
|
||||||
|
if (isLegacySecured(context)) {
|
||||||
|
return Authenticators.BIOMETRIC_WEAK or Authenticators.DEVICE_CREDENTIAL
|
||||||
|
}
|
||||||
|
|
||||||
return listOf(
|
return listOf(
|
||||||
Authenticators.BIOMETRIC_STRONG,
|
Authenticators.BIOMETRIC_STRONG,
|
||||||
Authenticators.BIOMETRIC_WEAK,
|
Authenticators.BIOMETRIC_WEAK,
|
||||||
@ -17,10 +22,22 @@ object BiometricUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isSupported(context: Context): Boolean {
|
fun isSupported(context: Context): Boolean {
|
||||||
return getSupportedAuthenticators(context) != 0
|
return isLegacySecured(context) || getSupportedAuthenticators(context) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isDeviceCredentialAllowed(context: Context): Boolean {
|
fun isDeviceCredentialAllowed(context: Context): Boolean {
|
||||||
return getSupportedAuthenticators(context) and Authenticators.DEVICE_CREDENTIAL != 0
|
return isLegacySecured(context) || (getSupportedAuthenticators(context) and Authenticators.DEVICE_CREDENTIAL != 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the device is secured with a PIN, pattern or password.
|
||||||
|
*/
|
||||||
|
private fun isLegacySecured(context: Context): Boolean {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) {
|
||||||
|
if (context.keyguardManager.isDeviceSecure) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.util.system
|
package eu.kanade.tachiyomi.util.system
|
||||||
|
|
||||||
import android.app.ActivityManager
|
import android.app.ActivityManager
|
||||||
|
import android.app.KeyguardManager
|
||||||
import android.app.Notification
|
import android.app.Notification
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
@ -153,24 +154,18 @@ val Float.dpToPxEnd: Float
|
|||||||
val Resources.isLTR
|
val Resources.isLTR
|
||||||
get() = configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR
|
get() = configuration.layoutDirection == View.LAYOUT_DIRECTION_LTR
|
||||||
|
|
||||||
/**
|
|
||||||
* Property to get the notification manager from the context.
|
|
||||||
*/
|
|
||||||
val Context.notificationManager: NotificationManager
|
val Context.notificationManager: NotificationManager
|
||||||
get() = getSystemService()!!
|
get() = getSystemService()!!
|
||||||
|
|
||||||
/**
|
|
||||||
* Property to get the connectivity manager from the context.
|
|
||||||
*/
|
|
||||||
val Context.connectivityManager: ConnectivityManager
|
val Context.connectivityManager: ConnectivityManager
|
||||||
get() = getSystemService()!!
|
get() = getSystemService()!!
|
||||||
|
|
||||||
/**
|
|
||||||
* Property to get the power manager from the context.
|
|
||||||
*/
|
|
||||||
val Context.powerManager: PowerManager
|
val Context.powerManager: PowerManager
|
||||||
get() = getSystemService()!!
|
get() = getSystemService()!!
|
||||||
|
|
||||||
|
val Context.keyguardManager: KeyguardManager
|
||||||
|
get() = getSystemService()!!
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method to acquire a partial wake lock.
|
* Convenience method to acquire a partial wake lock.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user