Added try/catch to updatePartialWakeLock
This commit is contained in:
@ -1552,16 +1552,20 @@ class BaresipService: Service() {
|
|||||||
val isAnyUaActive = uasStatus.value.values.any { it != R.drawable.circle_white }
|
val isAnyUaActive = uasStatus.value.values.any { it != R.drawable.circle_white }
|
||||||
val isAnyCallActive = calls.isNotEmpty()
|
val isAnyCallActive = calls.isNotEmpty()
|
||||||
val needsToStayAwake = isAnyUaActive || isAnyCallActive
|
val needsToStayAwake = isAnyUaActive || isAnyCallActive
|
||||||
if (needsToStayAwake) {
|
try {
|
||||||
if (!partialWakeLock.isHeld) {
|
if (needsToStayAwake) {
|
||||||
Log.d(TAG, "Acquiring Partial Wake Lock")
|
if (!partialWakeLock.isHeld) {
|
||||||
partialWakeLock.acquire()
|
Log.d(TAG, "Acquiring Partial Wake Lock (UA Active or Call in progress)")
|
||||||
}
|
partialWakeLock.acquire()
|
||||||
} else {
|
}
|
||||||
if (partialWakeLock.isHeld) {
|
} else {
|
||||||
Log.d(TAG, "Releasing Partial Wake Lock")
|
if (partialWakeLock.isHeld) {
|
||||||
partialWakeLock.release()
|
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}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user