mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-27 12:56:03 +00:00
android: hold wakelock for 30 seconds after received event was processed, to prevent race condition with incoming call activity. (#6224)
* android: hold wakelock for 45 seconds after event is received * create new lock instances, delay release by 30 seconds * comment
This commit is contained in:
+5
-2
@@ -12,8 +12,11 @@ actual fun getWakeLock(timeout: Long): (() -> Unit) {
|
||||
}
|
||||
}
|
||||
return {
|
||||
wakeLock?.release()
|
||||
wakeLock = null
|
||||
val lock = wakeLock
|
||||
if (lock != null) {
|
||||
if (lock.isHeld) lock.release()
|
||||
wakeLock = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -653,7 +653,14 @@ object ChatController {
|
||||
break
|
||||
}
|
||||
try {
|
||||
releaseLock()
|
||||
val release = releaseLock
|
||||
// delaying the release of wake lock in order to:
|
||||
// 1. avoid race condition with the incoming call activity that fails to show if called after wake lock release (primary reason),
|
||||
// 2. allow any other necessary processing for a bit of time with wakelock held.
|
||||
launch {
|
||||
delay(30000)
|
||||
release()
|
||||
}
|
||||
val msg = recvMsg(ctrl)
|
||||
releaseLock = getWakeLock(timeout = 60000)
|
||||
if (msg != null) {
|
||||
|
||||
+1
-4
@@ -1,6 +1,3 @@
|
||||
package chat.simplex.common.platform
|
||||
|
||||
actual fun getWakeLock(timeout: Long): (() -> Unit) {
|
||||
return {}
|
||||
}
|
||||
|
||||
actual fun getWakeLock(timeout: Long): (() -> Unit) = {}
|
||||
|
||||
Reference in New Issue
Block a user