diff --git a/tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt b/tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt index 6c4c08ba..57c5ee24 100644 --- a/tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt +++ b/tools/chatgui-android/app/src/main/java/com/utun/chat/data/NativeLib.kt @@ -268,6 +268,9 @@ object NativeLib { fun callDecline(callId: Long) { nativeCallDecline(callId) } fun callHangup(callId: Long) { nativeCallHangup(callId) } fun callIsOnline(channelId: String, peerNodeId: Long): Boolean = nativeCallIsOnline(channelId, peerNodeId) + /* 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) + private external fun nativeRadioCall(id: Long, group: Long, peer: Long, action: Int): Boolean /* ── P2P аудио-звонок (медиа) ── */ fun callAudioStart(callId: Long): Boolean = nativeCallAudioStart(callId) diff --git a/tools/chatgui-android/jni_bridge/android_jni_bridge.c b/tools/chatgui-android/jni_bridge/android_jni_bridge.c index 4b75b4e9..67d6bc8e 100644 --- a/tools/chatgui-android/jni_bridge/android_jni_bridge.c +++ b/tools/chatgui-android/jni_bridge/android_jni_bridge.c @@ -19,6 +19,7 @@ #include "../../../src/call/call_audio.h" #include "../../../src/call/call.h" #include "../../../src/radio/radio.h" +#include "../../../src/radio/radio_call.h" #include "../../../src/radio/radio_audio.h" #include "../../../src/dm/dm_core.h" #include "../../../src/dm/dm_media.h" @@ -2784,6 +2785,27 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeCallAccept( utun_bridge_call_accept((uint64_t)callId); } +/* Команда адресного вызова рации: копируем запрос до передачи в поток ядра. */ +JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeRadioCall( + JNIEnv* env, jobject thiz, jlong id, jlong group, jlong peer, jint action) { + (void)env; (void)thiz; + struct UTUN_INSTANCE* inst = instance_lite_get_instance(); + struct UASYNC* ua = instance_lite_get_uasync(); + if (!inst || !ua || !uasync_is_running(ua) || !id || action < RADIO_CALL_START || action > RADIO_CALL_REJECT_BUSY) { + DEBUG_ERROR(DEBUG_CATEGORY_RADIO, "radio call JNI rejected id=%lld action=%d core=%p", (long long)id, action, (void*)inst); + return JNI_FALSE; + } + struct radio_call_request* req = u_calloc(1, sizeof(*req)); + struct posted_task* task = u_calloc(1, sizeof(*task)); + if (!req || !task) { + DEBUG_ERROR(DEBUG_CATEGORY_RADIO, "radio call JNI allocation failed"); u_free(req); u_free(task); return JNI_FALSE; + } + req->inst = inst; req->id = (uint64_t)id; req->group = (uint64_t)group; req->peer = (uint64_t)peer; req->action = action; + task->callback = radio_call_trampoline; task->arg = req; + uasync_post_reserved(ua, task); + return JNI_TRUE; +} + JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeCallDecline( JNIEnv* env, jobject thiz, jlong callId) { (void)env; (void)thiz;