Set 10sec timeout for acquired wakeLock
This commit is contained in:
parent
8db0e41628
commit
c678162e58
|
@ -23,9 +23,7 @@ private const val TAG = "RegisterBroadcastReceiver"
|
|||
class RegisterBroadcastReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
wakeLock?.let {
|
||||
it.acquire()
|
||||
}
|
||||
wakeLock?.acquire(10000L /*10 secs*/)
|
||||
when (intent!!.action) {
|
||||
ACTION_REGISTER ->{
|
||||
Log.i(TAG,"REGISTER")
|
||||
|
|
|
@ -36,9 +36,7 @@ class SSEListener (val context: Context) : EventSourceListener() {
|
|||
|
||||
override fun onEvent(eventSource: EventSource, id: String?, type: String?, data: String) {
|
||||
Log.d(TAG, "New SSE message event=$type message=$data")
|
||||
wakeLock?.let {
|
||||
it.acquire()
|
||||
}
|
||||
wakeLock?.acquire(10000L /*10 secs*/)
|
||||
when (type) {
|
||||
"warning" -> Log.d(TAG, "Warning event received.")
|
||||
"ping" -> Log.d(TAG, "SSE ping received.")
|
||||
|
|
|
@ -99,7 +99,7 @@ class StartService: Service(){
|
|||
// we need this lock so our service gets not affected by Doze Mode
|
||||
wakeLock = (getSystemService(Context.POWER_SERVICE) as PowerManager).run {
|
||||
newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKE_LOCK_TAG).apply {
|
||||
acquire()
|
||||
acquire(10000L /*10 secs*/)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue