From dd8c8fffea845f64ed9b7ec86b09d48442e04689 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Wed, 1 Apr 2026 10:24:04 +0300 Subject: [PATCH] Added try/catch to updatePartialWakeLock --- .../com/tutpro/baresip/BaresipService.kt | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index a583e6d5..256ffced 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -1552,16 +1552,20 @@ class BaresipService: Service() { val isAnyUaActive = uasStatus.value.values.any { it != R.drawable.circle_white } val isAnyCallActive = calls.isNotEmpty() val needsToStayAwake = isAnyUaActive || isAnyCallActive - if (needsToStayAwake) { - if (!partialWakeLock.isHeld) { - Log.d(TAG, "Acquiring Partial Wake Lock") - partialWakeLock.acquire() - } - } else { - if (partialWakeLock.isHeld) { - Log.d(TAG, "Releasing Partial Wake Lock") - partialWakeLock.release() + try { + if (needsToStayAwake) { + if (!partialWakeLock.isHeld) { + Log.d(TAG, "Acquiring Partial Wake Lock (UA Active or Call in progress)") + partialWakeLock.acquire() + } + } else { + if (partialWakeLock.isHeld) { + Log.d(TAG, "Releasing Partial Wake Lock (All UAs idle and no calls)") + partialWakeLock.release() + } } + } catch (e: Exception) { + Log.e(TAG, "Error managing partialWakeLock: ${e.message}") } }