diff --git a/app/src/main/kotlin/com/tutpro/baresip/Call.kt b/app/src/main/kotlin/com/tutpro/baresip/Call.kt index 3dff670e..3762fb6e 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/Call.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/Call.kt @@ -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 diff --git a/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt index 5a5a5afd..0712be38 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/MainScreen.kt @@ -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 {