diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index a9c04af798..dbd152c315 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -168,7 +168,6 @@ class MainActivity : NoSplashAppCompatActivity() { override fun onResume() { super.onResume() - protectionCheck.resetAuthorization() if (!isProtectionCheckActive) { isProtectionCheckActive = true protectionCheck.queryProtection(this, ProtectionCheck.Protection.APPLICATION, UIRunnable { isProtectionCheckActive = false }, diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.kt b/app/src/main/java/info/nightscout/androidaps/MainApp.kt index 781ab707c3..ef74b5c6f2 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.kt @@ -6,6 +6,7 @@ import android.content.IntentFilter import android.net.ConnectivityManager import android.net.wifi.WifiManager import android.os.Build +import androidx.lifecycle.ProcessLifecycleOwner import com.uber.rxdogtag.RxDogTag import dagger.android.AndroidInjector import dagger.android.DaggerApplication @@ -35,6 +36,7 @@ import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver import info.nightscout.androidaps.services.AlarmSoundServiceHelper import info.nightscout.androidaps.utils.ActivityMonitor import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.ProcessLifecycleListener import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.locale.LocaleHelper import info.nightscout.androidaps.utils.protection.PasswordCheck @@ -70,6 +72,7 @@ class MainApp : DaggerApplication() { @Inject lateinit var passwordCheck: PasswordCheck @Inject lateinit var alarmSoundServiceHelper: AlarmSoundServiceHelper @Inject lateinit var notificationStore: NotificationStore + @Inject lateinit var processLifecycleListener: ProcessLifecycleListener override fun onCreate() { super.onCreate() @@ -77,6 +80,7 @@ class MainApp : DaggerApplication() { RxDogTag.install() setRxErrorHandler() LocaleHelper.update(this) + ProcessLifecycleOwner.get().lifecycle.addObserver(processLifecycleListener) var gitRemote: String? = BuildConfig.REMOTE var commitHash: String? = BuildConfig.HEAD diff --git a/app/src/main/java/info/nightscout/androidaps/utils/ProcessLifecycleListener.kt b/app/src/main/java/info/nightscout/androidaps/utils/ProcessLifecycleListener.kt new file mode 100644 index 0000000000..e1bc3a719b --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/utils/ProcessLifecycleListener.kt @@ -0,0 +1,13 @@ +package info.nightscout.androidaps.utils + +import androidx.lifecycle.DefaultLifecycleObserver +import androidx.lifecycle.LifecycleOwner +import info.nightscout.androidaps.utils.protection.ProtectionCheck +import javax.inject.Inject + +class ProcessLifecycleListener @Inject constructor(private val protectionCheck: ProtectionCheck) : DefaultLifecycleObserver { + + override fun onPause(owner: LifecycleOwner) { + protectionCheck.resetAuthorization() + } +} diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index 7698187f4a..3ae0cb84dc 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -86,6 +86,7 @@ android:inputType="number" android:key="@string/key_protection_timeout" android:title="@string/protection_timeout_title" + android:summary="@string/protection_timeout_summary" app:defaultValue="0" validate:maxNumber="180" validate:minNumber="0" diff --git a/core/core_dependencies.gradle b/core/core_dependencies.gradle index 7b9748a2d8..a84479cf9f 100644 --- a/core/core_dependencies.gradle +++ b/core/core_dependencies.gradle @@ -14,6 +14,7 @@ dependencies { api "androidx.browser:browser:1.3.0" api "androidx.activity:activity-ktx:${activity_version}" api "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" + api "androidx.lifecycle:lifecycle-process:$lifecycle_version" api 'androidx.cardview:cardview:1.0.0' api 'androidx.recyclerview:recyclerview:1.2.1' api 'androidx.gridlayout:gridlayout:1.0.0' diff --git a/core/src/main/res/values/protection.xml b/core/src/main/res/values/protection.xml index 10e0136fb2..9f6c0e279b 100644 --- a/core/src/main/res/values/protection.xml +++ b/core/src/main/res/values/protection.xml @@ -12,7 +12,8 @@ Application PIN Bolus password Bolus PIN - Time before Bolus and Settings password / PIN expires (seconds) + Password and PIN retention [s] + Time before the password or PIN should be entered Unlock settings Biometric Custom password