diff --git a/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt b/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt index 9174d6a16..f5dd96e66 100644 --- a/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt +++ b/app/src/main/java/com/kunzisoft/keepass/activities/PasswordActivity.kt @@ -51,7 +51,7 @@ import com.kunzisoft.keepass.activities.selection.SpecialModeActivity import com.kunzisoft.keepass.app.database.CipherDatabaseEntity import com.kunzisoft.keepass.autofill.AutofillHelper import com.kunzisoft.keepass.biometric.AdvancedUnlockManager -import com.kunzisoft.keepass.biometric.BiometricUnlockDatabaseHelper +import com.kunzisoft.keepass.biometric.AdvancedUnlockHelper import com.kunzisoft.keepass.database.action.ProgressDatabaseTaskProvider import com.kunzisoft.keepass.database.element.Database import com.kunzisoft.keepass.database.exception.DuplicateUuidDatabaseException @@ -674,7 +674,7 @@ open class PasswordActivity : SpecialModeActivity() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !readOnlyEducationPerformed) { - val biometricCanAuthenticate = BiometricUnlockDatabaseHelper.canAuthenticate(this) + val biometricCanAuthenticate = AdvancedUnlockHelper.canAuthenticate(this) PreferencesUtil.isAdvancedUnlockEnable(applicationContext) && (biometricCanAuthenticate == BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED || biometricCanAuthenticate == BiometricManager.BIOMETRIC_SUCCESS) && advancedUnlockInfoView != null && advancedUnlockInfoView?.visibility == View.VISIBLE @@ -727,7 +727,7 @@ open class PasswordActivity : SpecialModeActivity() { // To get device credential unlock result if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - // TODO Advanced unlock response + advancedUnlockManager?.onActivityResult(requestCode, resultCode, data) } // To get entry in result diff --git a/app/src/main/java/com/kunzisoft/keepass/biometric/BiometricUnlockDatabaseHelper.kt b/app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockHelper.kt similarity index 83% rename from app/src/main/java/com/kunzisoft/keepass/biometric/BiometricUnlockDatabaseHelper.kt rename to app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockHelper.kt index 3e84ed72e..ce3efb427 100644 --- a/app/src/main/java/com/kunzisoft/keepass/biometric/BiometricUnlockDatabaseHelper.kt +++ b/app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright 2019 Jeremy Jamet / Kunzisoft. + * Copyright 2020 Jeremy Jamet / Kunzisoft. * * This file is part of KeePassDX. * @@ -19,8 +19,10 @@ */ package com.kunzisoft.keepass.biometric +import android.app.Activity import android.app.KeyguardManager import android.content.Context +import android.content.Intent import android.os.Build import android.security.keystore.KeyGenParameterSpec import android.security.keystore.KeyPermanentlyInvalidatedException @@ -45,15 +47,28 @@ import javax.crypto.SecretKey import javax.crypto.spec.IvParameterSpec @RequiresApi(api = Build.VERSION_CODES.M) -class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { +class AdvancedUnlockHelper(private val context: FragmentActivity) { private var keyStore: KeyStore? = null private var keyGenerator: KeyGenerator? = null private var cipher: Cipher? = null private var biometricPrompt: BiometricPrompt? = null - var authenticationCallback: BiometricPrompt.AuthenticationCallback? = null - var biometricUnlockCallback: BiometricUnlockCallback? = null + private var authenticationCallback = object: BiometricPrompt.AuthenticationCallback() { + override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { + advancedUnlockCallback?.onAuthenticationSucceeded() + } + + override fun onAuthenticationFailed() { + advancedUnlockCallback?.onAuthenticationFailed() + } + + override fun onAuthenticationError(errorCode: Int, errString: CharSequence) { + advancedUnlockCallback?.onAuthenticationError(errorCode, errString) + } + } + + var advancedUnlockCallback: AdvancedUnlockCallback? = null private var isKeyManagerInit = false @@ -63,7 +78,7 @@ class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { val isKeyManagerInitialized: Boolean get() { if (!isKeyManagerInit) { - biometricUnlockCallback?.onBiometricException(Exception("Biometric not initialized")) + advancedUnlockCallback?.onGenericException(Exception("Biometric not initialized")) } return isKeyManagerInit } @@ -99,7 +114,7 @@ class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { } catch (e: Exception) { Log.e(TAG, "Unable to initialize the keystore", e) isKeyManagerInit = false - biometricUnlockCallback?.onBiometricException(e) + advancedUnlockCallback?.onGenericException(e) } } else { // really not much to do when no fingerprint support found @@ -139,14 +154,14 @@ class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { } } catch (e: Exception) { Log.e(TAG, "Unable to create a key in keystore", e) - biometricUnlockCallback?.onBiometricException(e) + advancedUnlockCallback?.onGenericException(e) } return keyStore.getKey(ADVANCED_UNLOCK_KEYSTORE_KEY, null) as SecretKey? } } catch (e: Exception) { Log.e(TAG, "Unable to retrieve the key in keystore", e) - biometricUnlockCallback?.onBiometricException(e) + advancedUnlockCallback?.onGenericException(e) } return null } @@ -173,13 +188,13 @@ class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { } } catch (unrecoverableKeyException: UnrecoverableKeyException) { Log.e(TAG, "Unable to initialize encrypt data", unrecoverableKeyException) - biometricUnlockCallback?.onInvalidKeyException(unrecoverableKeyException) + advancedUnlockCallback?.onInvalidKeyException(unrecoverableKeyException) } catch (invalidKeyException: KeyPermanentlyInvalidatedException) { Log.e(TAG, "Unable to initialize encrypt data", invalidKeyException) - biometricUnlockCallback?.onInvalidKeyException(invalidKeyException) + advancedUnlockCallback?.onInvalidKeyException(invalidKeyException) } catch (e: Exception) { Log.e(TAG, "Unable to initialize encrypt data", e) - biometricUnlockCallback?.onBiometricException(e) + advancedUnlockCallback?.onGenericException(e) } } @@ -194,12 +209,12 @@ class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { // passes updated iv spec on to callback so this can be stored for decryption cipher?.parameters?.getParameterSpec(IvParameterSpec::class.java)?.let{ spec -> val ivSpecValue = Base64.encodeToString(spec.iv, Base64.NO_WRAP) - biometricUnlockCallback?.handleEncryptedResult(encryptedBase64, ivSpecValue) + advancedUnlockCallback?.handleEncryptedResult(encryptedBase64, ivSpecValue) } } catch (e: Exception) { val exception = Exception(context.getString(R.string.keystore_not_accessible), e) Log.e(TAG, "Unable to encrypt data", e) - biometricUnlockCallback?.onBiometricException(exception) + advancedUnlockCallback?.onGenericException(exception) } } @@ -232,10 +247,10 @@ class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { deleteKeystoreKey() } catch (invalidKeyException: KeyPermanentlyInvalidatedException) { Log.e(TAG, "Unable to initialize decrypt data", invalidKeyException) - biometricUnlockCallback?.onInvalidKeyException(invalidKeyException) + advancedUnlockCallback?.onInvalidKeyException(invalidKeyException) } catch (e: Exception) { Log.e(TAG, "Unable to initialize decrypt data", e) - biometricUnlockCallback?.onBiometricException(e) + advancedUnlockCallback?.onGenericException(e) } } @@ -247,15 +262,15 @@ class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { // actual decryption here val encrypted = Base64.decode(encryptedValue, Base64.NO_WRAP) cipher?.doFinal(encrypted)?.let { decrypted -> - biometricUnlockCallback?.handleDecryptedResult(String(decrypted)) + advancedUnlockCallback?.handleDecryptedResult(String(decrypted)) } } catch (badPaddingException: BadPaddingException) { Log.e(TAG, "Unable to decrypt data", badPaddingException) - biometricUnlockCallback?.onInvalidKeyException(badPaddingException) + advancedUnlockCallback?.onInvalidKeyException(badPaddingException) } catch (e: Exception) { val exception = Exception(context.getString(R.string.keystore_not_accessible), e) Log.e(TAG, "Unable to decrypt data", exception) - biometricUnlockCallback?.onBiometricException(exception) + advancedUnlockCallback?.onGenericException(exception) } } @@ -265,7 +280,7 @@ class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { keyStore?.deleteEntry(ADVANCED_UNLOCK_KEYSTORE_KEY) } catch (e: Exception) { Log.e(TAG, "Unable to delete entry key in keystore", e) - biometricUnlockCallback?.onBiometricException(e) + advancedUnlockCallback?.onGenericException(e) } } @@ -274,9 +289,9 @@ class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { fun openAdvancedUnlockPrompt(cryptoPrompt: AdvancedUnlockCryptoPrompt) { // Init advanced unlock prompt if (biometricPrompt == null) { - authenticationCallback?.let { callback -> - biometricPrompt = BiometricPrompt(context, Executors.newSingleThreadExecutor(), callback) - } + biometricPrompt = BiometricPrompt(context, + Executors.newSingleThreadExecutor(), + authenticationCallback) } val promptTitle = context.getString(cryptoPrompt.promptTitleId) @@ -310,23 +325,37 @@ class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { } } + @Synchronized + fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + if (requestCode == REQUEST_DEVICE_CREDENTIAL) { + if (resultCode == Activity.RESULT_OK) { + advancedUnlockCallback?.onAuthenticationSucceeded() + } else { + advancedUnlockCallback?.onAuthenticationFailed() + } + } + } + fun closeBiometricPrompt() { biometricPrompt?.cancelAuthentication() } - interface BiometricUnlockErrorCallback { + interface AdvancedUnlockErrorCallback { fun onInvalidKeyException(e: Exception) - fun onBiometricException(e: Exception) + fun onGenericException(e: Exception) } - interface BiometricUnlockCallback : BiometricUnlockErrorCallback { + interface AdvancedUnlockCallback : AdvancedUnlockErrorCallback { + fun onAuthenticationSucceeded() + fun onAuthenticationFailed() + fun onAuthenticationError(errorCode: Int, errString: CharSequence) fun handleEncryptedResult(encryptedValue: String, ivSpec: String) fun handleDecryptedResult(decryptedValue: String) } companion object { - private val TAG = BiometricUnlockDatabaseHelper::class.java.name + private val TAG = AdvancedUnlockHelper::class.java.name private const val ADVANCED_UNLOCK_KEYSTORE = "AndroidKeyStore" private const val ADVANCED_UNLOCK_KEYSTORE_KEY = "com.kunzisoft.keepass.biometric.key" @@ -423,20 +452,25 @@ class BiometricUnlockDatabaseHelper(private val context: FragmentActivity) { */ @RequiresApi(api = Build.VERSION_CODES.M) fun deleteEntryKeyInKeystoreForBiometric(context: FragmentActivity, - biometricCallback: BiometricUnlockErrorCallback) { - BiometricUnlockDatabaseHelper(context).apply { - biometricUnlockCallback = object : BiometricUnlockCallback { + advancedCallback: AdvancedUnlockErrorCallback) { + AdvancedUnlockHelper(context).apply { + advancedUnlockCallback = object : AdvancedUnlockCallback { + override fun onAuthenticationSucceeded() {} + + override fun onAuthenticationFailed() {} + + override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {} override fun handleEncryptedResult(encryptedValue: String, ivSpec: String) {} override fun handleDecryptedResult(decryptedValue: String) {} override fun onInvalidKeyException(e: Exception) { - biometricCallback.onInvalidKeyException(e) + advancedCallback.onInvalidKeyException(e) } - override fun onBiometricException(e: Exception) { - biometricCallback.onBiometricException(e) + override fun onGenericException(e: Exception) { + advancedCallback.onGenericException(e) } } deleteKeystoreKey() diff --git a/app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockManager.kt b/app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockManager.kt index 46e0046de..e79a0fd02 100644 --- a/app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockManager.kt +++ b/app/src/main/java/com/kunzisoft/keepass/biometric/AdvancedUnlockManager.kt @@ -48,9 +48,9 @@ class AdvancedUnlockManager(var context: FragmentActivity, var passwordView: TextView?, private var loadDatabaseAfterRegisterCredentials: (encryptedPassword: String?, ivSpec: String?) -> Unit, private var loadDatabaseAfterRetrieveCredentials: (decryptedPassword: String?) -> Unit) - : BiometricUnlockDatabaseHelper.BiometricUnlockCallback { + : AdvancedUnlockHelper.AdvancedUnlockCallback { - private var biometricUnlockDatabaseHelper: BiometricUnlockDatabaseHelper? = null + private var advancedUnlockHelper: AdvancedUnlockHelper? = null private var biometricMode: Mode = Mode.BIOMETRIC_UNAVAILABLE // Only to fix multiple fingerprint menu #332 @@ -104,7 +104,7 @@ class AdvancedUnlockManager(var context: FragmentActivity, // biometric not supported (by API level or hardware) so keep option hidden // or manually disable - val biometricCanAuthenticate = BiometricUnlockDatabaseHelper.canAuthenticate(context) + val biometricCanAuthenticate = AdvancedUnlockHelper.canAuthenticate(context) allowOpenBiometricPrompt = true if (!PreferencesUtil.isAdvancedUnlockEnable(context) @@ -120,14 +120,13 @@ class AdvancedUnlockManager(var context: FragmentActivity, } else { // Check if fingerprint well init (be called the first time the fingerprint is configured // and the activity still active) - if (biometricUnlockDatabaseHelper?.isKeyManagerInitialized != true) { - biometricUnlockDatabaseHelper = BiometricUnlockDatabaseHelper(context) + if (advancedUnlockHelper?.isKeyManagerInitialized != true) { + advancedUnlockHelper = AdvancedUnlockHelper(context) // callback for fingerprint findings - biometricUnlockDatabaseHelper?.biometricUnlockCallback = this - biometricUnlockDatabaseHelper?.authenticationCallback = biometricAuthenticationCallback + advancedUnlockHelper?.advancedUnlockCallback = this } // Recheck to change the mode - if (biometricUnlockDatabaseHelper?.isKeyManagerInitialized != true) { + if (advancedUnlockHelper?.isKeyManagerInitialized != true) { toggleMode(Mode.KEY_MANAGER_UNAVAILABLE) } else { if (checkboxPasswordView?.isChecked == true) { @@ -157,55 +156,6 @@ class AdvancedUnlockManager(var context: FragmentActivity, } } - private val biometricAuthenticationCallback = object : BiometricPrompt.AuthenticationCallback () { - - override fun onAuthenticationError( - errorCode: Int, - errString: CharSequence) { - context.runOnUiThread { - Log.e(TAG, "Biometric authentication error. Code : $errorCode Error : $errString") - setAdvancedUnlockedMessageView(errString.toString()) - } - } - - override fun onAuthenticationFailed() { - context.runOnUiThread { - Log.e(TAG, "Biometric authentication failed, biometric not recognized") - setAdvancedUnlockedMessageView(R.string.advanced_unlock_not_recognized) - } - } - - override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { - context.runOnUiThread { - when (biometricMode) { - Mode.BIOMETRIC_UNAVAILABLE -> { - } - Mode.BIOMETRIC_SECURITY_UPDATE_REQUIRED -> { - } - Mode.BIOMETRIC_NOT_CONFIGURED -> { - } - Mode.KEY_MANAGER_UNAVAILABLE -> { - } - Mode.WAIT_CREDENTIAL -> { - } - Mode.STORE_CREDENTIAL -> { - // newly store the entered password in encrypted way - biometricUnlockDatabaseHelper?.encryptData(passwordView?.text.toString()) - AdvancedUnlockNotificationService.startServiceForTimeout(context) - } - Mode.EXTRACT_CREDENTIAL -> { - // retrieve the encrypted value from preferences - cipherDatabaseAction.getCipherDatabase(databaseFileUri) { cipherDatabase -> - cipherDatabase?.encryptedValue?.let { value -> - biometricUnlockDatabaseHelper?.decryptData(value) - } ?: deleteEncryptedDatabaseKey() - } - } - } - } - } - } - private fun initNotAvailable() { showFingerPrintViews(false) @@ -248,7 +198,7 @@ class AdvancedUnlockManager(var context: FragmentActivity, setAdvancedUnlockedMessageView("") advancedUnlockInfoView?.setIconViewClickListener(false) { - biometricAuthenticationCallback.onAuthenticationError(BiometricPrompt.ERROR_UNABLE_TO_PROCESS, + onAuthenticationError(BiometricPrompt.ERROR_UNABLE_TO_PROCESS, context.getString(R.string.credential_before_click_advanced_unlock_button)) } } @@ -257,7 +207,8 @@ class AdvancedUnlockManager(var context: FragmentActivity, context.runOnUiThread { if (allowOpenBiometricPrompt) { try { - biometricUnlockDatabaseHelper?.openAdvancedUnlockPrompt(cryptoPrompt) + advancedUnlockHelper + ?.openAdvancedUnlockPrompt(cryptoPrompt) } catch (e: Exception) { Log.e(TAG, "Unable to open advanced unlock prompt", e) setAdvancedUnlockedTitleView(R.string.advanced_unlock_prompt_not_initialized) @@ -271,7 +222,7 @@ class AdvancedUnlockManager(var context: FragmentActivity, setAdvancedUnlockedTitleView(R.string.open_advanced_unlock_prompt_store_credential) setAdvancedUnlockedMessageView("") - biometricUnlockDatabaseHelper?.initEncryptData { cryptoPrompt -> + advancedUnlockHelper?.initEncryptData { cryptoPrompt -> // Set listener to open the biometric dialog and save credential advancedUnlockInfoView?.setIconViewClickListener { _ -> openAdvancedUnlockPrompt(cryptoPrompt) @@ -284,10 +235,10 @@ class AdvancedUnlockManager(var context: FragmentActivity, setAdvancedUnlockedTitleView(R.string.open_advanced_unlock_prompt_unlock_database) setAdvancedUnlockedMessageView("") - if (biometricUnlockDatabaseHelper != null) { + if (advancedUnlockHelper != null) { cipherDatabaseAction.getCipherDatabase(databaseFileUri) { cipherDatabase -> cipherDatabase?.let { - biometricUnlockDatabaseHelper?.initDecryptData(it.specParameters) { cryptoPrompt -> + advancedUnlockHelper?.initDecryptData(it.specParameters) { cryptoPrompt -> // Set listener to open the biometric dialog and check credential advancedUnlockInfoView?.setIconViewClickListener { _ -> @@ -338,7 +289,7 @@ class AdvancedUnlockManager(var context: FragmentActivity, fun destroy() { // Close the biometric prompt allowOpenBiometricPrompt = false - biometricUnlockDatabaseHelper?.closeBiometricPrompt() + advancedUnlockHelper?.closeBiometricPrompt() // Restore the checked listener checkboxPasswordView?.setOnCheckedChangeListener(onCheckedPasswordChangeListener) cipherDatabaseAction.unregisterDatabaseListener(cipherDatabaseListener) @@ -352,12 +303,60 @@ class AdvancedUnlockManager(var context: FragmentActivity, fun deleteEncryptedDatabaseKey() { allowOpenBiometricPrompt = false advancedUnlockInfoView?.setIconViewClickListener(false, null) - biometricUnlockDatabaseHelper?.closeBiometricPrompt() + advancedUnlockHelper?.closeBiometricPrompt() cipherDatabaseAction.deleteByDatabaseUri(databaseFileUri) { checkBiometricAvailability() } } + fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + advancedUnlockHelper?.onActivityResult(requestCode, resultCode, data) + } + + override fun onAuthenticationError(errorCode: Int, errString: CharSequence) { + context.runOnUiThread { + Log.e(TAG, "Biometric authentication error. Code : $errorCode Error : $errString") + setAdvancedUnlockedMessageView(errString.toString()) + } + } + + override fun onAuthenticationFailed() { + context.runOnUiThread { + Log.e(TAG, "Biometric authentication failed, biometric not recognized") + setAdvancedUnlockedMessageView(R.string.advanced_unlock_not_recognized) + } + } + + override fun onAuthenticationSucceeded() { + context.runOnUiThread { + when (biometricMode) { + Mode.BIOMETRIC_UNAVAILABLE -> { + } + Mode.BIOMETRIC_SECURITY_UPDATE_REQUIRED -> { + } + Mode.BIOMETRIC_NOT_CONFIGURED -> { + } + Mode.KEY_MANAGER_UNAVAILABLE -> { + } + Mode.WAIT_CREDENTIAL -> { + } + Mode.STORE_CREDENTIAL -> { + // newly store the entered password in encrypted way + advancedUnlockHelper?.encryptData(passwordView?.text.toString()) + AdvancedUnlockNotificationService.startServiceForTimeout(context) + } + Mode.EXTRACT_CREDENTIAL -> { + // retrieve the encrypted value from preferences + cipherDatabaseAction.getCipherDatabase(databaseFileUri) { cipherDatabase -> + cipherDatabase?.encryptedValue?.let { value -> + advancedUnlockHelper?.decryptData(value) + } ?: deleteEncryptedDatabaseKey() + } + } + } + } + } + override fun handleEncryptedResult(encryptedValue: String, ivSpec: String) { loadDatabaseAfterRegisterCredentials.invoke(encryptedValue, ivSpec) } @@ -371,7 +370,7 @@ class AdvancedUnlockManager(var context: FragmentActivity, setAdvancedUnlockedMessageView(R.string.advanced_unlock_invalid_key) } - override fun onBiometricException(e: Exception) { + override fun onGenericException(e: Exception) { val errorMessage = e.cause?.localizedMessage ?: e.localizedMessage ?: "" setAdvancedUnlockedMessageView(errorMessage) } diff --git a/app/src/main/java/com/kunzisoft/keepass/settings/NestedAppSettingsFragment.kt b/app/src/main/java/com/kunzisoft/keepass/settings/NestedAppSettingsFragment.kt index f713f40da..c7cfc5582 100644 --- a/app/src/main/java/com/kunzisoft/keepass/settings/NestedAppSettingsFragment.kt +++ b/app/src/main/java/com/kunzisoft/keepass/settings/NestedAppSettingsFragment.kt @@ -41,7 +41,7 @@ import com.kunzisoft.keepass.activities.dialogs.UnavailableFeatureDialogFragment import com.kunzisoft.keepass.activities.stylish.Stylish import com.kunzisoft.keepass.app.database.CipherDatabaseAction import com.kunzisoft.keepass.app.database.FileDatabaseHistoryAction -import com.kunzisoft.keepass.biometric.BiometricUnlockDatabaseHelper +import com.kunzisoft.keepass.biometric.AdvancedUnlockHelper import com.kunzisoft.keepass.education.Education import com.kunzisoft.keepass.icons.IconPackChooser import com.kunzisoft.keepass.notifications.AdvancedUnlockNotificationService @@ -218,7 +218,7 @@ class NestedAppSettingsFragment : NestedSettingsFragment() { val tempAdvancedUnlockPreference: SwitchPreference? = findPreference(getString(R.string.temp_advanced_unlock_enable_key)) val biometricUnlockSupported = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - BiometricUnlockDatabaseHelper.biometricUnlockSupported(activity) + AdvancedUnlockHelper.biometricUnlockSupported(activity) } else false biometricUnlockEnablePreference?.apply { // False if under Marshmallow @@ -259,7 +259,7 @@ class NestedAppSettingsFragment : NestedSettingsFragment() { } val deviceCredentialUnlockSupported = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - BiometricUnlockDatabaseHelper.deviceCredentialUnlockSupported(activity) + AdvancedUnlockHelper.deviceCredentialUnlockSupported(activity) } else false deviceCredentialUnlockEnablePreference?.apply { if (!deviceCredentialUnlockSupported) { @@ -337,9 +337,9 @@ class NestedAppSettingsFragment : NestedSettingsFragment() { validate?.invoke() deleteKeysAlertDialog?.setOnDismissListener(null) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - BiometricUnlockDatabaseHelper.deleteEntryKeyInKeystoreForBiometric( + AdvancedUnlockHelper.deleteEntryKeyInKeystoreForBiometric( activity, - object : BiometricUnlockDatabaseHelper.BiometricUnlockErrorCallback { + object : AdvancedUnlockHelper.AdvancedUnlockErrorCallback { fun showException(e: Exception) { Toast.makeText(context, getString(R.string.advanced_unlock_scanning_error, e.localizedMessage), @@ -350,7 +350,7 @@ class NestedAppSettingsFragment : NestedSettingsFragment() { showException(e) } - override fun onBiometricException(e: Exception) { + override fun onGenericException(e: Exception) { showException(e) } })