From 349c9af9e858b5c3ef38f865b7a8c9a962809c2f Mon Sep 17 00:00:00 2001 From: lucky <> Date: Thu, 17 Feb 2022 04:43:45 +0300 Subject: [PATCH] ref --- app/src/main/java/me/lucky/wasted/ForegroundService.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/me/lucky/wasted/ForegroundService.kt b/app/src/main/java/me/lucky/wasted/ForegroundService.kt index 8357cf7..6b8ffaf 100644 --- a/app/src/main/java/me/lucky/wasted/ForegroundService.kt +++ b/app/src/main/java/me/lucky/wasted/ForegroundService.kt @@ -15,7 +15,7 @@ class ForegroundService : Service() { private const val NOTIFICATION_ID = 1000 } - private lateinit var unlockReceiver: UnlockReceiver + private val unlockReceiver = UnlockReceiver() override fun onCreate() { super.onCreate() @@ -28,7 +28,6 @@ class ForegroundService : Service() { } private fun init() { - unlockReceiver = UnlockReceiver() registerReceiver(unlockReceiver, IntentFilter(Intent.ACTION_USER_PRESENT)) } @@ -56,8 +55,8 @@ class ForegroundService : Service() { private class UnlockReceiver : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { if (context == null || - context.getSystemService(KeyguardManager::class.java)?.isDeviceSecure != true) - return + context.getSystemService(KeyguardManager::class.java)?.isDeviceSecure != true || + !Preferences(context).isWipeOnInactivity) return Thread(Runner(context, goAsync())).start() }