Expose Android phone state posting through the C bridge API
This commit is contained in:
1 parent
78864c202b
commit
77ba9ad43f
2 files changed
+27
-18
No files matched your search
@@ -1370,6 +1370,28 @@ int utun_bridge_set_active(int active) {
|
||||
return instance_lite_set_active(active);
|
||||
}
|
||||
|
||||
struct phone_state_request { struct UTUN_INSTANCE* inst; int state; unsigned policy; };
|
||||
static void phone_state_execute(void* arg) {
|
||||
struct phone_state_request* req = arg;
|
||||
call_set_phone_state(req->inst, req->state, req->policy); u_free(req);
|
||||
}
|
||||
|
||||
int utun_bridge_set_phone_state(int state, unsigned policy) {
|
||||
struct UTUN_INSTANCE* inst = instance_lite_get_instance();
|
||||
struct UASYNC* ua = instance_lite_get_uasync();
|
||||
if (!inst || !ua || !uasync_is_running(ua) || state < 0 || state > 2 || policy > 31) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_CALL, "phone state JNI unavailable state=%d policy=%u", state, policy); return -1;
|
||||
}
|
||||
struct phone_state_request* req = u_calloc(1, sizeof(*req));
|
||||
struct posted_task* task = u_calloc(1, sizeof(*task));
|
||||
if (!req || !task) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CALL, "phone state JNI allocation failed"); u_free(req); u_free(task); return -1;
|
||||
}
|
||||
req->inst = inst; req->state = state; req->policy = policy;
|
||||
task->callback = phone_state_execute; task->arg = req; uasync_post_reserved(ua, task);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bridge_notify_network_active_trampoline(void* arg) {
|
||||
(void)arg;
|
||||
bridge_log(BLEV_DEBUG, "network activity notified to standby");
|
||||
@@ -2874,27 +2896,10 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeCallContinue(
|
||||
bridge_call_id_action((uint64_t)callId, "continue", call_continue_trampoline);
|
||||
}
|
||||
|
||||
struct phone_state_request { struct UTUN_INSTANCE* inst; int state; unsigned policy; };
|
||||
static void phone_state_execute(void* arg) {
|
||||
struct phone_state_request* req = arg;
|
||||
call_set_phone_state(req->inst, req->state, req->policy); u_free(req);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeSetPhoneState(
|
||||
JNIEnv* env, jobject thiz, jint state, jint policy) {
|
||||
(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) || state < 0 || state > 2 || policy < 0 || policy > 31) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_CALL, "phone state JNI unavailable state=%d", state); return;
|
||||
}
|
||||
struct phone_state_request* req = u_calloc(1, sizeof(*req));
|
||||
struct posted_task* task = u_calloc(1, sizeof(*task));
|
||||
if (!req || !task) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CALL, "phone state JNI allocation failed"); u_free(req); u_free(task); return;
|
||||
}
|
||||
req->inst = inst; req->state = state; req->policy = (unsigned)policy;
|
||||
task->callback = phone_state_execute; task->arg = req; uasync_post_reserved(ua, task);
|
||||
utun_bridge_set_phone_state(state, (unsigned)policy);
|
||||
}
|
||||
|
||||
/* ── P2P аудио-звонок (медиа) ── */
|
||||
|
||||
@@ -258,6 +258,10 @@ void utun_bridge_on_network_change(void);
|
||||
|
||||
int utun_bridge_set_active(int active);
|
||||
|
||||
/* Состояние SIM: state=0 UNKNOWN/1 IDLE/2 BUSY, policy — маска call_policy (0..31).
|
||||
* 0 — задача поставлена, -1 — отказ; caller исключает stop/restart во время постановки. */
|
||||
int utun_bridge_set_phone_state(int state, unsigned policy);
|
||||
|
||||
/* Поставить уведомление standby в uasync; досрочный wake только в SLEEP после min_sleep. */
|
||||
|
||||
void utun_bridge_notify_network_active(void);
|
||||
|
||||
Reference in new issue
Block a user