Toast reason when incoming call gets closed by baresip lib

This commit is contained in:
Juha Heinanen
2022-09-26 16:28:45 +03:00
parent a5f2a99a41
commit 67f9a06952
3 changed files with 89 additions and 75 deletions
+9
View File
@@ -1269,6 +1269,15 @@ Java_com_tutpro_baresip_Api_call_1replace_1transfer(JNIEnv *env, jobject thiz, j
return res == 0 ? true : false;
}
JNIEXPORT jstring JNICALL
Java_com_tutpro_baresip_Api_call_1peer_1uri(JNIEnv *env, jobject thiz, jlong call)
{
const char *uri = call_peeruri((struct call *)call);
if (uri)
return (*env)->NewStringUTF(env, uri);
return (*env)->NewStringUTF(env, "");
}
JNIEXPORT jstring JNICALL
Java_com_tutpro_baresip_Api_call_1diverter_1uri(JNIEnv *env, jobject thiz, jlong call)
{
@@ -79,6 +79,7 @@ object Api {
external fun call_state(callp: Long): Int
external fun call_replaces(callp: Long): Boolean
external fun call_replace_transfer(xfer_callp: Long, callp: Long): Boolean
external fun call_peer_uri(callp: Long): String
external fun call_diverter_uri(callp: Long): String
external fun call_destroy(callp: Long)
@@ -591,7 +591,8 @@ class BaresipService: Service() {
Log.d(TAG, "got uaEvent $event/$aor/$callp")
val call = Call.ofCallp(callp)
if (call == null && callp != 0L && ev[0] != "call incoming" && ev[0] != "call rejected") {
if (call == null && callp != 0L && ev[0] != "call incoming" && ev[0] != "call rejected" &&
ev[0] != "call closed") {
Log.w(TAG, "uaEvent $event did not find call $callp")
return
}
@@ -865,11 +866,12 @@ class BaresipService: Service() {
return
}
"call closed" -> {
nm.cancel(CALL_NOTIFICATION_ID)
Log.d(TAG, "AoR $aor call $callp is closed")
if (call != null) {
nm.cancel(CALL_NOTIFICATION_ID)
stopRinging()
stopMediaPlayer()
val newCall = call!!.newCall
val newCall = call.newCall
if (newCall != null) {
newCall.onHoldCall = null
call.newCall = null
@@ -946,12 +948,14 @@ class BaresipService: Service() {
}
return
}
}
val reason = ev[1].trim()
if ((reason != "") && (ua.calls().isEmpty())) {
if (reason[0].isDigit())
toast("${getString(R.string.call_failed)}: $reason")
else
toast("${getString(R.string.call_closed)}: $reason")
toast("${getString(R.string.call_closed)}: " +
"$reason ${Api.call_peer_uri(callp)}")
}
}
}