tel: URI related bug fixes and improvements

This commit is contained in:
Juha Heinanen
2026-05-10 10:07:30 +03:00
parent 6a6ccba10e
commit cb0b87950f
3 changed files with 13 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package com.tutpro.baresip
import android.content.Context
import android.content.Intent
import android.net.Uri
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
@ -369,7 +370,8 @@ private fun Calls(
)
secondButtonText.value = ctx.getString(R.string.add_contact)
secondAction.value = {
navController.navigate("baresip_contact/$peerUri/new")
val uri = Utils.sipToTel(peerUri)
navController.navigate("baresip_contact/$uri/new")
}
lastButtonText.value = ctx.getString(R.string.delete)
lastAction.value = {

View File

@ -115,7 +115,7 @@ class ConnectionService : ConnectionService() {
val onHoldCallp = rootExtras?.getLong("onHoldCallp", 0L).takeIf { it != 0L }
?: nestedExtras?.getLong("onHoldCallp") ?: 0L
val destination = request?.address?.schemeSpecificPart ?: ""
val destination = request?.address?.encodedSchemeSpecificPart ?: ""
Log.d(TAG, "onCreateOutgoingConnection to $destination (uap=$uap)")

View File

@ -380,6 +380,15 @@ object Utils {
"@" + hostPart + ";user=phone"
}
fun sipToTel(sipUri: String): String {
if (sipUri.contains(";user=phone")) {
val user = uriUserPart(sipUri)
if (user != "")
return "tel:${user.replace("%23", "#")}"
}
return sipUri
}
fun checkName(name: String): Boolean {
return name.isNotEmpty() && name == String(name.toByteArray(), Charsets.UTF_8) &&
name.lines().size == 1 && !name.contains('"')