From 152b5466e52ce677656d75009861845c7a9d399d Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Thu, 9 Apr 2026 18:17:31 +0300 Subject: [PATCH] Even when Android 12+, set MODE_IN_COMMUNICATION if not set --- .../kotlin/com/tutpro/baresip/BaresipService.kt | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 0704a936..d309c164 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -1871,19 +1871,12 @@ class BaresipService: Service() { } private fun ensureCommunicationMode() { - // Android 11 (API 30) and below: Manual mode switching is often required - // to ensure the system routes audio through the correct VOIP hardware path. - if (VERSION.SDK_INT < 31) { - if (Call.inCall() && am.mode != MODE_IN_COMMUNICATION) { + if (Call.inCall() && am.mode != MODE_IN_COMMUNICATION) { + am.mode = MODE_IN_COMMUNICATION + if (VERSION.SDK_INT < 31) Log.d(TAG, "Manual Mode Guard (SDK < 31): Setting MODE_IN_COMMUNICATION") - am.mode = MODE_IN_COMMUNICATION - } - } - else { - // For Android 12+, log if the system hasn't set the mode correctly. - if (Call.inCall() && am.mode != MODE_IN_COMMUNICATION) { - Log.w(TAG, "ConnectionService has not set MODE_IN_COMMUNICATION on Android 12+") - } + else + Log.d(TAG, "Manual Mode Guard (SDK >= 31): Setting MODE_IN_COMMUNICATION") } }