This commit is contained in:
lucky 2022-02-17 04:43:45 +03:00
parent 33a6681052
commit 349c9af9e8
1 changed files with 3 additions and 4 deletions

View File

@ -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()
}