Improved attended call transfer and call hold/resume

This commit is contained in:
Juha Heinanen
2026-04-03 11:38:19 +03:00
parent 6ccf6f596e
commit 67be5292d8
2 changed files with 9 additions and 6 deletions

View File

@ -57,11 +57,15 @@ class Call(val callp: Long, val ua: UserAgent, val peerUri: String, val dir: Str
}
fun hold(): Boolean {
return Api.call_hold(callp, true) == 0
if (Api.call_hold(callp, true) == 0)
onhold = true
return onhold
}
fun resume(): Boolean {
return Api.call_hold(callp, false) == 0
if (Api.call_hold(callp, false) == 0)
onhold = false
return !onhold
}
fun transfer(uri: String): Boolean {
@ -146,8 +150,8 @@ class Call(val callp: Long, val ua: UserAgent, val peerUri: String, val dir: Str
}
fun isAnyCallActive(ctx: Context): Boolean {
// Check SIP calls managed by baresip
if (inCall()) return true
// Check if there exist SIP calls that are not onhold or held
if (BaresipService.calls.any { !it.onhold && !it.held }) return true
// MODE_IN_CALL indicates a PSTN call is active
val am = ctx.getSystemService(Context.AUDIO_SERVICE) as AudioManager
return am.mode == AudioManager.MODE_IN_CALL

View File

@ -1531,14 +1531,12 @@ private fun CallRow(
"AoR ${call.ua.account.aor} resuming call ${call.callp} with ${call.callUri.value}"
)
call.resume()
call.onhold = false
} else {
Log.d(
TAG,
"AoR ${call.ua.account.aor} holding call ${call.callp} with ${call.callUri.value}"
)
call.hold()
call.onhold = true
}
},
) {
@ -2157,6 +2155,7 @@ private fun transfer(ctx: Context, viewModel: ViewModel, ua: UserAgent, uriText:
if (call.hold()) {
call.referTo = uri
call(ctx, viewModel, ua, uri, false,call)
showCall(ctx, viewModel, ua, call)
}
}
else {