mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-02-07 14:58:24 +00:00
Factorized code for call.terminate()/call.decline()
This commit is contained in:
parent
0d96010865
commit
6e97466a86
5 changed files with 14 additions and 24 deletions
|
|
@ -501,21 +501,16 @@ class CoreContext @UiThread constructor(val context: Context) : HandlerThread("C
|
|||
call.acceptWithParams(params)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun declineCall(call: Call) {
|
||||
val reason = if (core.callsNb > 1) {
|
||||
Reason.Busy
|
||||
} else {
|
||||
Reason.Declined
|
||||
}
|
||||
Log.i("$TAG Declining call [$call] with reason [$reason]")
|
||||
call.decline(reason)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun terminateCall(call: Call) {
|
||||
Log.i("$TAG Terminating call [${call.remoteAddress.asStringUriOnly()}]")
|
||||
call.terminate()
|
||||
if (call.dir == Call.Dir.Incoming && LinphoneUtils.isCallIncoming(call.state)) {
|
||||
val reason = if (call.core.callsNb > 1) Reason.Busy else Reason.Declined
|
||||
Log.i("$TAG Declining call [${call.remoteAddress.asStringUriOnly()}] with reason [$reason]")
|
||||
call.decline(reason)
|
||||
} else {
|
||||
Log.i("$TAG Terminating call [${call.remoteAddress.asStringUriOnly()}]")
|
||||
call.terminate()
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
|
|
|
|||
|
|
@ -63,11 +63,7 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
|||
if (intent.action == NotificationsManager.INTENT_ANSWER_CALL_NOTIF_ACTION) {
|
||||
coreContext.answerCall(call)
|
||||
} else {
|
||||
if (LinphoneUtils.isCallIncoming(call.state)) {
|
||||
coreContext.declineCall(call)
|
||||
} else {
|
||||
coreContext.terminateCall(call)
|
||||
}
|
||||
coreContext.terminateCall(call)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.linphone.telecom
|
|||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.telecom.DisconnectCause
|
||||
import androidx.annotation.WorkerThread
|
||||
import androidx.core.telecom.CallAttributesCompat
|
||||
import androidx.core.telecom.CallsManager
|
||||
|
|
@ -33,6 +34,7 @@ import org.linphone.core.AudioDevice
|
|||
import org.linphone.core.Call
|
||||
import org.linphone.core.Core
|
||||
import org.linphone.core.CoreListenerStub
|
||||
import org.linphone.core.Reason
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
|
||||
|
|
@ -110,10 +112,7 @@ class TelecomManager @WorkerThread constructor(context: Context) {
|
|||
"$TAG We're asked to terminate the call with reason [$disconnectCause]"
|
||||
)
|
||||
coreContext.postOnCoreThread {
|
||||
Log.i(
|
||||
"$TAG Terminating call [${call.remoteAddress.asStringUriOnly()}]"
|
||||
)
|
||||
call.terminate() // TODO FIXME: use cause
|
||||
coreContext.terminateCall(call)
|
||||
}
|
||||
},
|
||||
{ // onSetActive
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class CallModel @WorkerThread constructor(val call: Call) {
|
|||
fun hangUp() {
|
||||
coreContext.postOnCoreThread {
|
||||
Log.i("$TAG Terminating call [${call.remoteAddress.asStringUriOnly()}]")
|
||||
call.terminate()
|
||||
coreContext.terminateCall(call)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ class CurrentCallViewModel @UiThread constructor() : ViewModel() {
|
|||
if (::currentCall.isInitialized) {
|
||||
Log.i("$TAG Terminating call [${currentCall.remoteAddress.asStringUriOnly()}]")
|
||||
terminatedByUsed = true
|
||||
currentCall.terminate()
|
||||
coreContext.terminateCall(currentCall)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue