Prevent crash at start when baresip is not default phone app

This commit is contained in:
Juha Heinanen
2026-08-15 16:28:09 +03:00
parent 8fb718fdd2
commit c25c93d4a5

View File

@ -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)