Improved handling of call auto-rejection
This commit is contained in:
@ -175,7 +175,13 @@ static void ua_event_handler(struct ua *ua, enum ua_event ev,
|
||||
len = re_snprintf(event_buf, sizeof event_buf, "registering failed,%s", prm);
|
||||
break;
|
||||
case UA_EVENT_CALL_INCOMING:
|
||||
len = re_snprintf(event_buf, sizeof event_buf, "call incoming");
|
||||
if (uag_call_count() > 1) {
|
||||
LOGD("auto-rejecting call from %s\n", prm);
|
||||
ua_hangup(ua, call, 486, "Busy Here");
|
||||
len = re_snprintf(event_buf, sizeof event_buf, "call rejected,%s", prm);
|
||||
} else {
|
||||
len = re_snprintf(event_buf, sizeof event_buf, "call incoming,%s", prm);
|
||||
}
|
||||
break;
|
||||
case UA_EVENT_CALL_OUTGOING:
|
||||
len = re_snprintf(event_buf, sizeof event_buf, "call outgoing");
|
||||
|
||||
@ -565,7 +565,7 @@ class BaresipService: Service() {
|
||||
}
|
||||
|
||||
val call = Call.ofCallp(callp)
|
||||
if (call == null && callp != "0" && ev[0] != "call incoming") {
|
||||
if (call == null && callp != "0" && ev[0] != "call incoming" && ev[0] != "call rejected") {
|
||||
Log.w(TAG, "uaEvent $event did not find call $callp")
|
||||
return
|
||||
}
|
||||
@ -635,15 +635,17 @@ class BaresipService: Service() {
|
||||
return
|
||||
}
|
||||
"call incoming" -> {
|
||||
val peerUri = Api.call_peeruri(callp)
|
||||
if (Call.calls().size > 0 ||
|
||||
!Utils.checkPermissions(this, arrayOf(Manifest.permission.RECORD_AUDIO))) {
|
||||
Log.d(TAG, "Auto-rejecting incoming call $uap/$callp/$peerUri")
|
||||
Api.ua_hangup(uap, callp, 486, "Busy Here")
|
||||
playUnInterrupted(R.raw.callwaiting, 1)
|
||||
if (!Utils.isVisible())
|
||||
return
|
||||
newEvent = "call rejected"
|
||||
val peerUri = ev[1]
|
||||
if (!Utils.checkPermissions(this, arrayOf(Manifest.permission.RECORD_AUDIO))) {
|
||||
toast(getString(R.string.no_calls))
|
||||
if (ua.account.callHistory) {
|
||||
NewCallHistory.add(NewCallHistory(aor, peerUri, "in"))
|
||||
NewCallHistory.save()
|
||||
ua.account.missedCalls = true
|
||||
}
|
||||
if (!isMainVisible)
|
||||
return
|
||||
newEvent = "call rejected"
|
||||
} else {
|
||||
Log.d(TAG, "Incoming call $uap/$callp/$peerUri")
|
||||
Call(callp, ua, peerUri, "in", "incoming",
|
||||
@ -724,6 +726,19 @@ class BaresipService: Service() {
|
||||
return
|
||||
}
|
||||
}
|
||||
"call rejected" -> {
|
||||
playUnInterrupted(R.raw.callwaiting, 1)
|
||||
if (ua.account.callHistory) {
|
||||
NewCallHistory.add(NewCallHistory(aor, ev[1], "in"))
|
||||
NewCallHistory.save()
|
||||
ua.account.missedCalls = true
|
||||
if (!isMainVisible)
|
||||
return
|
||||
newEvent = "call rejected"
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
"call answered" -> {
|
||||
stopMediaPlayer()
|
||||
if (call!!.status == "incoming")
|
||||
|
||||
Reference in New Issue
Block a user