desktop: prevent desktop being locked after the call (#7505)

Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
Evgeny
2026-09-30 09:28:58 +01:00
committed by GitHub
co-authored by Evgeny @ SimpleX Chat
parent 485bec5d5d
commit 3d3dd421ff
4 changed files with 7 additions and 3 deletions
@@ -269,6 +269,7 @@ object AppLock {
fun elapsedRealtime(): Long = System.nanoTime() / 1_000_000
fun recheckAuthState() {
if (ChatModel.showCallView.value) return
val enteredBackgroundVal = enteredBackground.value
val delay = ChatController.appPrefs.laLockDelay.get()
if (enteredBackgroundVal == null || elapsedRealtime() - enteredBackgroundVal >= delay * 1000) {
@@ -1,5 +1,6 @@
package chat.simplex.common.views.call
import chat.simplex.common.AppLock
import chat.simplex.common.model.*
import chat.simplex.common.platform.*
import chat.simplex.common.views.helpers.withBGApi
@@ -78,6 +79,7 @@ class CallManager(val chatModel: ChatModel) {
// Don't destroy WebView if you plan to accept next call right after this one
if (!switchingCall.value) {
AppLock.appWasHidden()
showCallView.value = false
activeCall.value?.androidCallState?.close()
activeCall.value = null
@@ -182,9 +182,10 @@ private fun ApplicationScope.AppWindow(closedByError: MutableState<Boolean>) {
}
}
var windowFocused by remember { simplexWindowState.windowFocused }
LaunchedEffect(windowFocused) {
val showCallView = ChatModel.showCallView.value
LaunchedEffect(windowFocused, showCallView) {
val delay = ChatController.appPrefs.laLockDelay.get()
if (!windowFocused && ChatModel.showAuthScreen.value && delay > 0) {
if (!windowFocused && !showCallView && ChatModel.showAuthScreen.value && delay > 0) {
delay(delay * 1000L)
// Trigger auth state check when delay ends (and if it ends)
AppLock.recheckAuthState()
+1 -1
View File
@@ -302,7 +302,7 @@ object AppLock {
### Lock Delay
The `laLockDelay` preference controls how long after backgrounding the app requires re-authentication. When `laLockDelay == 0`, screen rotation triggers a 3-second grace period (line ~270) to prevent unnecessary re-auth.
The `laLockDelay` preference controls how long after backgrounding the app requires re-authentication. When `laLockDelay == 0`, screen rotation triggers a 3-second grace period (line ~270) to prevent unnecessary re-auth. A call counts as activity: `recheckAuthState()` is a no-op while `showCallView` is true, and `CallManager.endCall()` resets `enteredBackground`, so the delay is counted from the end of the call.
### Lock Modes