Wire incoming call policy and caller continuation through JNI
This commit is contained in:
1 parent
7d5399cd62
commit
4cebd0be54
3 files changed
+8
-8
No files matched your search
@@ -3,7 +3,7 @@ package com.utun.chat.data
|
|||||||
import com.utun.chat.R
|
import com.utun.chat.R
|
||||||
|
|
||||||
/** Состояние единственной звонковой сессии; не зависит от Activity или ViewModel. */
|
/** Состояние единственной звонковой сессии; не зависит от Activity или ViewModel. */
|
||||||
enum class CallPhase { NONE, OUTGOING, RINGING, INCOMING, ACTIVE, ENDED }
|
enum class CallPhase { NONE, OUTGOING, RINGING, INCOMING, ACTIVE, ENDED, WAIT_DECISION, PENDING_INCOMING }
|
||||||
|
|
||||||
/** Значения CONN_TYPE_* общего ядра. */
|
/** Значения CONN_TYPE_* общего ядра. */
|
||||||
enum class CallConnectionType(val labelRes: Int) {
|
enum class CallConnectionType(val labelRes: Int) {
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ object NativeLib {
|
|||||||
fun callDecline(callId: Long) { nativeCallDecline(callId) }
|
fun callDecline(callId: Long) { nativeCallDecline(callId) }
|
||||||
fun callHangup(callId: Long) { nativeCallHangup(callId) }
|
fun callHangup(callId: Long) { nativeCallHangup(callId) }
|
||||||
fun callContinue(callId: Long) { nativeCallContinue(callId) }
|
fun callContinue(callId: Long) { nativeCallContinue(callId) }
|
||||||
fun setPhoneState(state: Int) { nativeSetPhoneState(state) }
|
fun setPhoneState(state: Int, policy: Int) { nativeSetPhoneState(state, policy) }
|
||||||
fun callIsOnline(channelId: String, peerNodeId: Long): Boolean = nativeCallIsOnline(channelId, peerNodeId)
|
fun callIsOnline(channelId: String, peerNodeId: Long): Boolean = nativeCallIsOnline(channelId, peerNodeId)
|
||||||
/* action: radio_call_action, результат — CHAT_EVT_RADIO_CALL (65). */
|
/* action: radio_call_action, результат — CHAT_EVT_RADIO_CALL (65). */
|
||||||
fun radioCall(id: Long, action: Int, group: Long = 0, peer: Long = 0): Boolean = nativeRadioCall(id, group, peer, action)
|
fun radioCall(id: Long, action: Int, group: Long = 0, peer: Long = 0): Boolean = nativeRadioCall(id, group, peer, action)
|
||||||
@@ -419,7 +419,7 @@ object NativeLib {
|
|||||||
private external fun nativeCallDecline(callId: Long)
|
private external fun nativeCallDecline(callId: Long)
|
||||||
private external fun nativeCallHangup(callId: Long)
|
private external fun nativeCallHangup(callId: Long)
|
||||||
private external fun nativeCallContinue(callId: Long)
|
private external fun nativeCallContinue(callId: Long)
|
||||||
private external fun nativeSetPhoneState(state: Int)
|
private external fun nativeSetPhoneState(state: Int, policy: Int)
|
||||||
private external fun nativeCallIsOnline(channelId: String, peerNodeId: Long): Boolean
|
private external fun nativeCallIsOnline(channelId: String, peerNodeId: Long): Boolean
|
||||||
private external fun nativeCallAudioStart(callId: Long): Boolean
|
private external fun nativeCallAudioStart(callId: Long): Boolean
|
||||||
private external fun nativeCallAudioFeed(callId: Long, samples: ShortArray, capturePtsUs: Long): Boolean
|
private external fun nativeCallAudioFeed(callId: Long, samples: ShortArray, capturePtsUs: Long): Boolean
|
||||||
|
|||||||
@@ -2824,18 +2824,18 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeCallContinue(
|
|||||||
bridge_call_id_action((uint64_t)callId, "continue", call_continue_trampoline);
|
bridge_call_id_action((uint64_t)callId, "continue", call_continue_trampoline);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct phone_state_request { struct UTUN_INSTANCE* inst; int state; };
|
struct phone_state_request { struct UTUN_INSTANCE* inst; int state; unsigned policy; };
|
||||||
static void phone_state_execute(void* arg) {
|
static void phone_state_execute(void* arg) {
|
||||||
struct phone_state_request* req = arg;
|
struct phone_state_request* req = arg;
|
||||||
call_set_phone_state(req->inst, req->state); u_free(req);
|
call_set_phone_state(req->inst, req->state, req->policy); u_free(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeSetPhoneState(
|
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeSetPhoneState(
|
||||||
JNIEnv* env, jobject thiz, jint state) {
|
JNIEnv* env, jobject thiz, jint state, jint policy) {
|
||||||
(void)env; (void)thiz;
|
(void)env; (void)thiz;
|
||||||
struct UTUN_INSTANCE* inst = instance_lite_get_instance();
|
struct UTUN_INSTANCE* inst = instance_lite_get_instance();
|
||||||
struct UASYNC* ua = instance_lite_get_uasync();
|
struct UASYNC* ua = instance_lite_get_uasync();
|
||||||
if (!inst || !ua || !uasync_is_running(ua) || state < 0 || state > 2) {
|
if (!inst || !ua || !uasync_is_running(ua) || state < 0 || state > 2 || policy < 0 || policy > 31) {
|
||||||
DEBUG_WARN(DEBUG_CATEGORY_CALL, "phone state JNI unavailable state=%d", state); return;
|
DEBUG_WARN(DEBUG_CATEGORY_CALL, "phone state JNI unavailable state=%d", state); return;
|
||||||
}
|
}
|
||||||
struct phone_state_request* req = u_calloc(1, sizeof(*req));
|
struct phone_state_request* req = u_calloc(1, sizeof(*req));
|
||||||
@@ -2843,7 +2843,7 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeSetPhoneState(
|
|||||||
if (!req || !task) {
|
if (!req || !task) {
|
||||||
DEBUG_ERROR(DEBUG_CATEGORY_CALL, "phone state JNI allocation failed"); u_free(req); u_free(task); return;
|
DEBUG_ERROR(DEBUG_CATEGORY_CALL, "phone state JNI allocation failed"); u_free(req); u_free(task); return;
|
||||||
}
|
}
|
||||||
req->inst = inst; req->state = state;
|
req->inst = inst; req->state = state; req->policy = (unsigned)policy;
|
||||||
task->callback = phone_state_execute; task->arg = req; uasync_post_reserved(ua, task);
|
task->callback = phone_state_execute; task->arg = req; uasync_post_reserved(ua, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user