From c25c93d4a5b12b0029f78e6eef78e341b915b691 Mon Sep 17 00:00:00 2001 From: Juha Heinanen Date: Sat, 15 Aug 2026 16:28:09 +0300 Subject: [PATCH] Prevent crash at start when baresip is not default phone app --- app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt index 9da3fcb3..cffa176d 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/BaresipService.kt @@ -3073,6 +3073,13 @@ class BaresipService: Service() { val sipHandle = getPhoneAccountHandle(this, SIP_ACCOUNT_ID) val pstnHandle = getPhoneAccountHandle(this, PSTN_ACCOUNT_ID) + try { + tm.unregisterPhoneAccount(sipHandle) + tm.unregisterPhoneAccount(pstnHandle) + } catch (e: Exception) { + Log.w(TAG, "Failed to unregister phone accounts: $e") + } + val sipAccount = android.telecom.PhoneAccount.builder(sipHandle, getString(R.string.app_name)) .setCapabilities(android.telecom.PhoneAccount.CAPABILITY_SELF_MANAGED or android.telecom.PhoneAccount.CAPABILITY_SUPPORTS_VIDEO_CALLING)