Improved attended call transfer and call hold/resume
This commit is contained in:
@@ -57,11 +57,15 @@ class Call(val callp: Long, val ua: UserAgent, val peerUri: String, val dir: Str
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun hold(): Boolean {
|
fun hold(): Boolean {
|
||||||
return Api.call_hold(callp, true) == 0
|
if (Api.call_hold(callp, true) == 0)
|
||||||
|
onhold = true
|
||||||
|
return onhold
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resume(): Boolean {
|
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 {
|
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 {
|
fun isAnyCallActive(ctx: Context): Boolean {
|
||||||
// Check SIP calls managed by baresip
|
// Check if there exist SIP calls that are not onhold or held
|
||||||
if (inCall()) return true
|
if (BaresipService.calls.any { !it.onhold && !it.held }) return true
|
||||||
// MODE_IN_CALL indicates a PSTN call is active
|
// MODE_IN_CALL indicates a PSTN call is active
|
||||||
val am = ctx.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
val am = ctx.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||||
return am.mode == AudioManager.MODE_IN_CALL
|
return am.mode == AudioManager.MODE_IN_CALL
|
||||||
|
|||||||
@@ -1531,14 +1531,12 @@ private fun CallRow(
|
|||||||
"AoR ${call.ua.account.aor} resuming call ${call.callp} with ${call.callUri.value}"
|
"AoR ${call.ua.account.aor} resuming call ${call.callp} with ${call.callUri.value}"
|
||||||
)
|
)
|
||||||
call.resume()
|
call.resume()
|
||||||
call.onhold = false
|
|
||||||
} else {
|
} else {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
"AoR ${call.ua.account.aor} holding call ${call.callp} with ${call.callUri.value}"
|
"AoR ${call.ua.account.aor} holding call ${call.callp} with ${call.callUri.value}"
|
||||||
)
|
)
|
||||||
call.hold()
|
call.hold()
|
||||||
call.onhold = true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
@@ -2157,6 +2155,7 @@ private fun transfer(ctx: Context, viewModel: ViewModel, ua: UserAgent, uriText:
|
|||||||
if (call.hold()) {
|
if (call.hold()) {
|
||||||
call.referTo = uri
|
call.referTo = uri
|
||||||
call(ctx, viewModel, ua, uri, false,call)
|
call(ctx, viewModel, ua, uri, false,call)
|
||||||
|
showCall(ctx, viewModel, ua, call)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user