diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2020-09-13 18:34:17 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2020-09-13 18:34:17 +0530 |
commit | dd0ff8fe60daea6ae3666b5fe655c37303b77626 (patch) | |
tree | f0ba3ea4e3520e26795e2a11c1a94e3b08ad995a /ui/src/main/java/com | |
parent | 45a179580df8c81acfb95a04725da6cf0eb2c541 (diff) |
ui: remove hacky manual check for keyguard
Setting the correct value for the allowedAuthenticators field lets the library correctly detect this by itself as verified on an API 21 emulator
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/java/com')
-rw-r--r-- | ui/src/main/java/com/wireguard/android/util/BiometricAuthenticator.kt | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/ui/src/main/java/com/wireguard/android/util/BiometricAuthenticator.kt b/ui/src/main/java/com/wireguard/android/util/BiometricAuthenticator.kt index ade7f435..d5de319f 100644 --- a/ui/src/main/java/com/wireguard/android/util/BiometricAuthenticator.kt +++ b/ui/src/main/java/com/wireguard/android/util/BiometricAuthenticator.kt @@ -5,10 +5,6 @@ package com.wireguard.android.util -import android.annotation.SuppressLint -import android.app.KeyguardManager -import android.content.Context -import android.os.Build import android.os.Handler import android.os.Looper import android.util.Log @@ -17,7 +13,6 @@ 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.Fragment import com.wireguard.android.R @@ -35,20 +30,6 @@ object BiometricAuthenticator { object Cancelled : Result() } - @SuppressLint("PrivateApi") - private fun isPinEnabled(context: Context): Boolean { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) - return context.getSystemService<KeyguardManager>()!!.isDeviceSecure - return try { - val lockUtilsClass = Class.forName("com.android.internal.widget.LockPatternUtils") - val lockUtils = lockUtilsClass.getConstructor(Context::class.java).newInstance(context) - val method = lockUtilsClass.getMethod("isLockScreenDisabled") - !(method.invoke(lockUtils) as Boolean) - } catch (e: Exception) { - false - } - } - fun authenticate( @StringRes dialogTitleRes: Int, fragment: Fragment, @@ -86,7 +67,7 @@ object BiometricAuthenticator { .setTitle(fragment.getString(dialogTitleRes)) .setAllowedAuthenticators(allowedAuthenticators) .build() - if (BiometricManager.from(fragment.requireContext()).canAuthenticate(allowedAuthenticators) == BiometricManager.BIOMETRIC_SUCCESS || isPinEnabled(fragment.requireContext())) { + if (BiometricManager.from(fragment.requireContext()).canAuthenticate(allowedAuthenticators) == BiometricManager.BIOMETRIC_SUCCESS) { biometricPrompt.authenticate(promptInfo) } else { callback(Result.HardwareUnavailableOrDisabled) |