From 228bd76e787d4d578e3110df5a01f64b38ec2211 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 20 Apr 2020 01:18:10 +0200 Subject: [PATCH] No protection by default --- .../java/info/nightscout/androidaps/MainActivity.kt | 12 +++++++++--- .../androidaps/utils/protection/BiometricCheck.kt | 12 ++++++++---- app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/pref_general.xml | 6 +++--- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index a590afe32f..3972faefba 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -51,7 +51,7 @@ import info.nightscout.androidaps.tabs.TabPageAdapter import info.nightscout.androidaps.utils.AndroidPermission import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.LocaleHelper.update -import info.nightscout.androidaps.utils.alertDialogs.OKDialog.show +import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest import info.nightscout.androidaps.utils.protection.ProtectionCheck @@ -160,7 +160,13 @@ class MainActivity : NoSplashAppCompatActivity() { override fun onResume() { super.onResume() - protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, null, Runnable { finish() }, Runnable { finish() }) + protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, null, + Runnable { + OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) + }, + Runnable { + OKDialog.show(this, "", resourceHelper.gs(R.string.authorizationfailed), Runnable { finish() }) + }) } private fun setWakeLock() { @@ -226,7 +232,7 @@ class MainActivity : NoSplashAppCompatActivity() { if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) { when (requestCode) { AndroidPermission.CASE_STORAGE -> //show dialog after permission is granted - show(this, "", resourceHelper.gs(R.string.alert_dialog_storage_permission_text)) + OKDialog.show(this, "", resourceHelper.gs(R.string.alert_dialog_storage_permission_text)) AndroidPermission.CASE_LOCATION, AndroidPermission.CASE_SMS, AndroidPermission.CASE_BATTERY, AndroidPermission.CASE_PHONE_STATE, AndroidPermission.CASE_SYSTEM_WINDOW -> { } diff --git a/app/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt b/app/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt index 47d38be3d1..7a9018d132 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/protection/BiometricCheck.kt @@ -21,18 +21,22 @@ object BiometricCheck { BiometricConstants.ERROR_LOCKOUT, BiometricConstants.ERROR_VENDOR, BiometricConstants.ERROR_LOCKOUT_PERMANENT, - BiometricConstants.ERROR_USER_CANCELED -> { + BiometricConstants.ERROR_USER_CANCELED -> { ToastUtils.showToastInUiThread(activity.baseContext, errString.toString()) fail?.run() } - BiometricConstants.ERROR_NEGATIVE_BUTTON -> + BiometricConstants.ERROR_NEGATIVE_BUTTON -> cancel?.run() + + BiometricConstants.ERROR_NO_DEVICE_CREDENTIAL -> + // call ok, because it's not possible to bypass it when biometrics is setup, hw not present and no pin set + ok?.run() + BiometricConstants.ERROR_NO_SPACE, BiometricConstants.ERROR_HW_UNAVAILABLE, BiometricConstants.ERROR_HW_NOT_PRESENT, - BiometricConstants.ERROR_NO_DEVICE_CREDENTIAL, - BiometricConstants.ERROR_NO_BIOMETRICS -> + BiometricConstants.ERROR_NO_BIOMETRICS -> // call ok, because it's not possible to bypass it when biometrics fail // ok?.run() // changed to fail as you can use PIN instead with setDeviceCredentialAllowed enabled diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index baa40e36ba..efb5b8b0a0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1803,4 +1803,5 @@ Predictions Deviation slope graphconfig + Authorization failed diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index 3ee920cc01..a672398b20 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -37,7 +37,7 @@ />