diff --git a/core/build.gradle b/core/build.gradle index 9d71b4cec7..71ce3bd0da 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -7,7 +7,7 @@ android { compileSdkVersion 28 defaultConfig { - minSdkVersion 24 + minSdkVersion 26 targetSdkVersion 28 versionCode 1 versionName "1.0" diff --git a/core/core_dependencies.gradle b/core/core_dependencies.gradle index 16d6d836b8..68446f4544 100644 --- a/core/core_dependencies.gradle +++ b/core/core_dependencies.gradle @@ -10,7 +10,7 @@ dependencies { api 'androidx.legacy:legacy-support-v4:1.0.0' api "androidx.appcompat:appcompat:$appcompat_verison" api "androidx.preference:preference-ktx:$preferencektx_version" - api 'androidx.biometric:biometric:1.0.1' + api 'androidx.biometric:biometric:1.1.0' api "androidx.browser:browser:1.3.0" api "androidx.activity:activity-ktx:${activityVersion}" api "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0" diff --git a/core/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt b/core/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt index 22ef6a1b4a..b74b3377dc 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.utils.protection -import androidx.biometric.BiometricConstants import androidx.biometric.BiometricPrompt +import androidx.biometric.BiometricPrompt.* import androidx.fragment.app.FragmentActivity import info.nightscout.androidaps.core.R import info.nightscout.androidaps.utils.ToastUtils @@ -16,43 +16,43 @@ object BiometricCheck { override fun onAuthenticationError(errorCode: Int, errString: CharSequence) { super.onAuthenticationError(errorCode, errString) when (errorCode) { - BiometricConstants.ERROR_UNABLE_TO_PROCESS, - BiometricConstants.ERROR_TIMEOUT, - BiometricConstants.ERROR_CANCELED, - BiometricConstants.ERROR_LOCKOUT, - BiometricConstants.ERROR_VENDOR, - BiometricConstants.ERROR_LOCKOUT_PERMANENT, - BiometricConstants.ERROR_USER_CANCELED -> { + ERROR_UNABLE_TO_PROCESS, + ERROR_TIMEOUT, + ERROR_CANCELED, + ERROR_LOCKOUT, + ERROR_VENDOR, + ERROR_LOCKOUT_PERMANENT, + ERROR_USER_CANCELED -> { ToastUtils.showToastInUiThread(activity.baseContext, errString.toString()) // fallback to master password - runOnUiThread(Runnable { + runOnUiThread { passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { ok?.run() }, { cancel?.run() }, { fail?.run() }) - }) + } } - BiometricConstants.ERROR_NEGATIVE_BUTTON -> + ERROR_NEGATIVE_BUTTON -> cancel?.run() - BiometricConstants.ERROR_NO_DEVICE_CREDENTIAL -> { + ERROR_NO_DEVICE_CREDENTIAL -> { ToastUtils.showToastInUiThread(activity.baseContext, errString.toString()) // no pin set // fallback to master password - runOnUiThread(Runnable { + runOnUiThread { passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { ok?.run() }, { cancel?.run() }, { fail?.run() }) - }) + } } - BiometricConstants.ERROR_NO_SPACE, - BiometricConstants.ERROR_HW_UNAVAILABLE, - BiometricConstants.ERROR_HW_NOT_PRESENT, - BiometricConstants.ERROR_NO_BIOMETRICS -> - runOnUiThread(Runnable { + ERROR_NO_SPACE, + ERROR_HW_UNAVAILABLE, + ERROR_HW_NOT_PRESENT, + ERROR_NO_BIOMETRICS -> + runOnUiThread { passwordCheck.queryPassword(activity, R.string.master_password, R.string.key_master_password, { ok?.run() }, { cancel?.run() }, { fail?.run() }) - }) + } } } - override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { + override fun onAuthenticationSucceeded(result: AuthenticationResult) { super.onAuthenticationSucceeded(result) // Called when a biometric is recognized. ok?.run() @@ -65,7 +65,7 @@ object BiometricCheck { } }) - val promptInfo = BiometricPrompt.PromptInfo.Builder() + val promptInfo = PromptInfo.Builder() .setTitle(activity.getString(title)) .setDescription(activity.getString(R.string.biometric_title)) .setNegativeButtonText(activity.getString(R.string.cancel)) // not possible with setDeviceCredentialAllowed