Prevent call transfer if state is Ended, Error or Released

This commit is contained in:
Sylvain Berfini 2025-03-17 13:10:38 +01:00
parent 4979bca704
commit 489c799332
2 changed files with 19 additions and 1 deletions

View file

@ -945,6 +945,17 @@ class CurrentCallViewModel
@WorkerThread
fun attendedTransferCallTo(to: Call) {
if (::currentCall.isInitialized) {
val toCallState = to.state
if (LinphoneUtils.isCallEnding(toCallState, considerReleasedAsEnding = true)) {
Log.e("$TAG Do not attempt attended transfer to call in state [$toCallState]")
return
}
val currentCallState = currentCall.state
if (LinphoneUtils.isCallEnding(currentCallState, considerReleasedAsEnding = true)) {
Log.e("$TAG Do not attempt attended transfer of call in state [$currentCallState]")
return
}
Log.i(
"$TAG Doing an attended transfer between currently displayed call [${currentCall.remoteAddress.asStringUriOnly()}] and paused call [${to.remoteAddress.asStringUriOnly()}]"
)
@ -959,6 +970,12 @@ class CurrentCallViewModel
@WorkerThread
fun blindTransferCallTo(to: Address) {
if (::currentCall.isInitialized) {
val callState = currentCall.state
if (LinphoneUtils.isCallEnding(callState, considerReleasedAsEnding = true)) {
Log.e("$TAG Do not attempt blind transfer of call in state [$callState]")
return
}
Log.i(
"$TAG Call [${currentCall.remoteAddress.asStringUriOnly()}] is being blindly transferred to [${to.asStringUriOnly()}]"
)

View file

@ -168,9 +168,10 @@ class LinphoneUtils {
}
@AnyThread
fun isCallEnding(callState: Call.State): Boolean {
fun isCallEnding(callState: Call.State, considerReleasedAsEnding: Boolean = false): Boolean {
return when (callState) {
Call.State.End, Call.State.Error -> true
Call.State.Released -> considerReleasedAsEnding
else -> false
}
}