mirror of
https://github.com/pppscn/SmsForwarder
synced 2025-08-03 01:17:41 +08:00
优化:监听Screen
事件细分On/Off/Locked/Unlocked
#399
This commit is contained in:
parent
9379882ca3
commit
f4f6080b9a
@ -68,7 +68,12 @@ class LockScreenWorker(context: Context, params: WorkerParameters) : CoroutineWo
|
||||
.putString(TaskWorker.taskActions, task.actions)
|
||||
.putString(TaskWorker.msgInfo, Gson().toJson(msgInfo))
|
||||
.build()
|
||||
val duration = if (action == Intent.ACTION_SCREEN_ON) lockScreenSetting.timeAfterScreenOn else lockScreenSetting.timeAfterScreenOff
|
||||
val duration = when (action) {
|
||||
Intent.ACTION_SCREEN_ON -> lockScreenSetting.timeAfterScreenOn
|
||||
Intent.ACTION_SCREEN_OFF -> lockScreenSetting.timeAfterScreenOff
|
||||
Intent.ACTION_USER_PRESENT -> lockScreenSetting.timeAfterScreenUnlocked
|
||||
else -> lockScreenSetting.timeAfterScreenLocked
|
||||
}
|
||||
val actionRequest = OneTimeWorkRequestBuilder<ActionWorker>()
|
||||
.setInitialDelay(duration.toLong(), TimeUnit.MINUTES)
|
||||
.setInputData(actionData).build()
|
||||
|
Loading…
x
Reference in New Issue
Block a user