[Feature][ZXW-229]add sim change api
Change-Id: If8b83a8bd4ece63ffb0e0d367ba56dff9b17e085
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-sim/liblynq-sim.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-sim/liblynq-sim.bb
index 59701c7..7b8ff1d 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-sim/liblynq-sim.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-sim/liblynq-sim.bb
@@ -56,7 +56,7 @@
if [ -d "${WORKONSRC}" ] ; then
install -d ${D}${includedir}/
- cp -af ${SRC-DIR}/include/ ${D}${includedir}/
+ cp -af ${SRC-DIR}/include/libsim ${D}${includedir}/
fi
}
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sim-demo/files/lynq-qser-sim-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sim-demo/files/lynq-qser-sim-demo.cpp
index 204c98b..348fd81 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sim-demo/files/lynq-qser-sim-demo.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sim-demo/files/lynq-qser-sim-demo.cpp
@@ -55,6 +55,7 @@
int (*qser_reset_modem)(sim_client_handle_type h_sim);
int (*qser_get_version)(sim_client_handle_type h_sim, char *buf);
int (*qser_reset_sim)(sim_client_handle_type h_sim);
+int (*qser_sim_addrxmsghandler)(QSER_SIM_RxMsgHandlerFunc_t handlerPtr);
typedef struct
@@ -81,7 +82,8 @@
{12, "qser_reset_modem"},
{13, "qser_get_version"},
{14, "qser_reset_sim"},
- {15, "qser_deinit_sim"},
+ {15, "qser_sim_addrxmsghandler"},
+ {16, "qser_deinit_sim"},
{-1, NULL}
};
@@ -99,6 +101,10 @@
}
}
+void qser_sim_handler(QSER_SIM_MsgRef msgRef) {
+ printf("[%s-%d] sim, state = 0x%x========\n", __FUNCTION__, __LINE__, msgRef->e_card_state);
+}
+
int main(int argc, char const *argv[])
{
int cmdIdx = 0;
@@ -538,8 +544,31 @@
//flag_init = 0;
break;
}
+ case 15://qser_sim_addrxmsghandler
+ {
+ if(flag_init == 0){
+ printf("must init first\n");
+ }
+ else{
+ qser_sim_addrxmsghandler = (int(*)(QSER_SIM_RxMsgHandlerFunc_t handlerPtr))dlsym(dlHandle_sim,"qser_sim_addrxmsghandler");
+ if(NULL != qser_sim_addrxmsghandler)
+ {
+ res = qser_sim_addrxmsghandler(qser_sim_handler);
+ if(res == 0)
+ {
+ printf("sim addrxmsghandler success is!!!\n");
+ }else{
+ printf("sim addrxmsghandler errors, res = %d\n", res);
+ }
+ }else{
+ printf("qser_sim_addrxmsghandler dlsym error\n");
+ }
+ }
+ //flag_init = 0;
+ break;
+ }
//qser_deinit_sim
- case 15:
+ case 16:
{
if(flag_init == 0){
printf("must init first\n");
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sim-demo/files/lynq-qser-sim-demo.h b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sim-demo/files/lynq-qser-sim-demo.h
index c878b20..1a4829b 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sim-demo/files/lynq-qser-sim-demo.h
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sim-demo/files/lynq-qser-sim-demo.h
@@ -165,3 +165,7 @@
QSER_SIM_CARD_TYPE_T e_card_type; /**< Card type. */
QSER_SIM_CARD_ALL_APP_INFO_T card_app_info; /**< Stores all relevant application information. */
}QSER_SIM_CARD_STATUS_INFO_T;
+typedef QSER_SIM_CARD_STATUS_INFO_T* QSER_SIM_MsgRef;
+/* Callback function registered to qser_sim_addrxmsghandler, msgRef contains the detail msg infor */
+typedef void (*QSER_SIM_RxMsgHandlerFunc_t)(QSER_SIM_MsgRef msgRef);
+
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/mtk_ril_unsol_commands.h b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/mtk_ril_unsol_commands.h
index 5c461f4..5c4f022 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/mtk_ril_unsol_commands.h
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/mtk_ril_unsol_commands.h
@@ -50,3 +50,5 @@
{ RIL_UNSOL_ECC_NUM,responseString, WAKE_PARTIAL},
{RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR, responseStrings, WAKE_PARTIAL},
{RIL_UNSOL_CALL_INFO_INDICATION, responseStrings, WAKE_PARTIAL},
+{RIL_UNSOL_SIM_STATUS_COMMAND, responseSimStatus, WAKE_PARTIAL},
+
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/powerManager.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/powerManager.cpp
index 9a2551e..9bda379 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/powerManager.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/powerManager.cpp
@@ -219,6 +219,7 @@
case RIL_UNSOL_ECALL_MSDHACK:
case RIL_UNSOL_SIM_REFRESH:
case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED:
+ case RIL_UNSOL_SIM_STATUS_COMMAND:
case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED:
case RIL_UNSOL_STK_SESSION_END:
case RIL_UNSOL_STK_PROACTIVE_COMMAND:
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
index 4c51a16..3ec4365 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
@@ -4771,6 +4771,12 @@
//unsol trigger other things.
switch(unsolResponse) {
+ case RIL_UNSOL_SIM_STATUS_COMMAND:
+ {
+ RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) data);
+ updateCardStatusV6(p_cur, soc_id);
+ break;
+ }
#ifdef LED_SUPPORT
case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: //add this for API-720
ARspRequest(RIL_REQUEST_GET_CURRENT_CALLS, soc_id);
@@ -5792,6 +5798,7 @@
{
switch(requestCode)
{
+ case RIL_UNSOL_SIM_STATUS_COMMAND: return 1;
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return 1;
case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return 1;
case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return 1;
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/include/lynq_qser_sim.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/include/lynq_qser_sim.h
index 801c56d..3260899 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/include/lynq_qser_sim.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/include/lynq_qser_sim.h
@@ -182,6 +182,11 @@
QSER_SIM_CARD_ALL_APP_INFO_T card_app_info; /**< Stores all relevant application information. */
}QSER_SIM_CARD_STATUS_INFO_T;
+typedef QSER_SIM_CARD_STATUS_INFO_T* QSER_SIM_MsgRef;
+/* Callback function registered to qser_sms_addrxmsghandler, msgRef contains the detail msg infor */
+typedef void (*QSER_SIM_RxMsgHandlerFunc_t)(QSER_SIM_MsgRef msgRef);
+
+
int qser_sim_client_init(sim_client_handle_type *ph_sim);
int qser_sim_client_deinit(sim_client_handle_type h_sim);
@@ -381,6 +386,9 @@
int qser_get_version(sim_client_handle_type h_sim, char *buf);
int qser_reset_sim(sim_client_handle_type h_sim);
+int qser_sim_addrxmsghandler(QSER_SIM_RxMsgHandlerFunc_t handlerPtr);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp
index 5e12c84..4f66957 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp
@@ -4,11 +4,11 @@
#include <string.h>
#include <unistd.h>
#include <log/log.h>
-#include <include/lynq_sim.h>
#include <stdlib.h>
#include <pthread.h>
#include <liblog/lynq_deflog.h>
#include "lynq_qser_sim.h"
+#include <libsim/lynq_sim.h>
#define USER_LOG_TAG "LYNQ_QSER_SIM"
@@ -36,6 +36,63 @@
}
return lynq_sim_deinit();
}
+QSER_SIM_RxMsgHandlerFunc_t tmp_sim = NULL;
+void *new_sim_thread_recv(void *p)
+{
+ int handle = 0;
+ int sim_status = 0;
+ QSER_SIM_CARD_STATUS_INFO_T QSER_sim_info;
+ while (1)
+ {
+ if(!lynq_wait_sim_state_change(&handle))
+ {
+ if(!lynq_read_sim_status(handle, &sim_status))
+ {
+ if(1 == sim_status)
+ {
+ QSER_sim_info.e_card_state = 0xB03;
+ }
+ else if(0 == sim_status)
+ {
+
+ QSER_sim_info.e_card_state = 0xB02;
+ }
+ else{
+ QSER_sim_info.e_card_state = 0xB01;
+ }
+ tmp_sim(&QSER_sim_info);
+ }
+ else
+ {
+ LYDBGLOG("lynq_read_sim_status error\n");
+ }
+ }
+ else
+ {
+ LYDBGLOG("lynq_wait_receive_new_sim error\n");
+ break;
+ }
+ }
+ return NULL;
+}
+
+int qser_sim_addrxmsghandler(QSER_SIM_RxMsgHandlerFunc_t handlerPtr)
+{
+ if(NULL == handlerPtr)
+ {
+ return E_QSER_ERROR_BADPARM;
+ }
+
+ tmp_sim = handlerPtr;
+ pthread_t lynq_new_sim_tid = -1;
+ int ret = pthread_create(&lynq_new_sim_tid, NULL, new_sim_thread_recv, NULL);
+ if(ret < 0)
+ {
+ LYDBGLOG("qser_sim_addrxmsghandler pthread_create error!!!\n");
+ return -1;
+ }
+ return E_QSER_SUCCESS;
+}
int qser_sim_getimsi(sim_client_handle_type h_sim, QSER_SIM_APP_ID_INFO_T *pt_info, char *imsi, size_t imsiLen)
{
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/makefile
index 12704dd..2826255 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/makefile
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/makefile
@@ -22,6 +22,7 @@
-I$(LOCAL_PATH)/include/ \
-I$(ROOT)$(includedir)/logger \
-I$(ROOT)$(includedir)/liblog \
+ -I$(ROOT)$(includedir)/libsim \
LOCAL_LIBS := \
-L. \
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sim/include/libsim/lynq_sim.h b/cap/zx297520v3/src/lynq/lib/liblynq-sim/include/libsim/lynq_sim.h
new file mode 100755
index 0000000..d4f2678
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sim/include/libsim/lynq_sim.h
@@ -0,0 +1,103 @@
+/*=============================================================================
+# FileName: lynq_sim.h
+# Desc: about SIMAPI
+# Author: lei
+# Version: V2.0
+# LastChange: 2023-03-13
+# History:
+# If you need to use any API under lynq_sim, you must first call the lynq_sim_init() function to initialize these functions.
+=============================================================================*/
+#ifndef __LYNQ_SIM__
+#define __LYNQ_SIM__
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int lynq_get_sim_status(int *card_status);
+int lynq_get_imsi(char buf[]);
+int lynq_sim_init(int utoken);
+int lynq_sim_deinit(void);
+int lynq_enable_pin(char pin[]);
+int lynq_disable_pin(char pin[]);
+int lynq_get_iccid(char buf[]);
+int lynq_query_pin_lock(char *pin,int buf[]);
+int lynq_verify_pin(char *pin);
+int lynq_change_pin(char *old_pin, char *new_pin);
+int lynq_unlock_pin(char *puk, char *pin);
+int lynq_query_phone_number(char buf[]);
+int lynq_switch_card(int slot);
+int lynq_screen(int num);
+int lynq_get_imei(char buf[]);
+int lynq_get_imei_and_sv(char imei[],char sv[]);
+int lynq_wait_sim_state_change(int *handle);
+void send_sim_state_change();
+void wait_sim_state();
+int lynq_read_sim_status(int handle, int *card_status);
+
+
+
+/**
+ * @brief Request SIM I/O operation.
+ * This is similar to the TS 27.007 "restricted SIM" operation
+ * where it assumes all of the EF selection will be done by the callee.
+ * @param list type: [IN] list[0]:one of the commands listed for TS 27.007 +CRSM.(command)
+ * type: [IN] list[1]:EF id(fileid)
+ * type: [IN] list[2]:offset(p1)
+ * type: [IN] list[3]:offset(p2)
+ * type: [IN] list[4]:response len,sometimes needn't care(p3)
+ * @param path type: [IN] "pathid" from TS 27.007 +CRSM command.
+ type: [IN] Path is in hex asciii format eg "7f205f70"
+ type: [IN] Path must always be provided.
+ * @param data type: [IN] May be NULL
+ * @param pin2 type: [IN] May be NULL
+ * @param aidPtr type: [IN] AID value, See ETSI 102.221 8.1 and 101.220 4, NULL if no value.
+ * @param sw type: [OUT]
+ * @param simResponse type: [OUT] response
+ * @return int
+ */
+int lynq_req_sim_io(int list[5], char *path, char *data, char *pin2, char *aidPtr, int sw[2], char *simResponse);
+
+/**
+ * @brief
+ * @param options type: [IN] [options] define whether you want to halt, power-off, or reboot the machine.May be NULL
+ * @param time type: [IN] [time] specifies when you want the shutdown to perform.May be NULL
+ * @param message type: [IN] [message] adds a message that announces the shutdown.May be NULL
+ * @return int
+ */
+int lynq_shutdown(char options[], char time[], char message[]);
+
+/**
+ * @brief get currnet version of mobiletek
+ * @param buf type: [out] My Param doc
+ * @return int
+ */
+int lynq_get_version(char buf[]);
+
+/**
+ * @brief sim power on/off
+ *
+ */
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+int lynq_reset_sim(void);
+#else
+int lynq_sim_power(int mode);
+#endif
+/**
+ * @brief reset modem
+ *
+ */
+int lynq_reset_modem(void);
+
+/**
+ * @brief factory test to both radio on/off
+ *
+ */
+int lynq_factory_radio_state(int num);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_module_common.h b/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_module_common.h
new file mode 100755
index 0000000..60719ef
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_module_common.h
@@ -0,0 +1,76 @@
+#ifndef LYNQ_MODULE_COMMON_H
+#define LYNQ_MODULE_COMMON_H
+
+#define RESULT_OK (0)
+#define RESULT_ERROR (-1)
+
+/*the same with lynq_interface.h begin*/
+#define LYNQ_REQUEST_VENDOR_BASE 8000
+#define LYNQ_URC_VENDOR_BASE 9000
+#define LYNQ_AT_SNED (LYNQ_REQUEST_VENDOR_BASE +1)
+#define LYNQ_URC_CALL_STATUS_IND (LYNQ_URC_VENDOR_BASE+1)
+#define LYNQ_URC_DATA_STATUS_IND (LYNQ_URC_VENDOR_BASE+2)
+#define LYNQ_URC_DATA_CALL_STATUS_IND (LYNQ_URC_VENDOR_BASE+3)
+#define LYNQ_AUTO_ANSWER_CALL (LYNQ_REQUEST_VENDOR_BASE +2)
+#define LYNQ_REQUEST_SET_DTMF_VOLUME (LYNQ_REQUEST_VENDOR_BASE +3)
+#define LYNQ_URC_MODIFY_APNDB (LYNQ_URC_VENDOR_BASE+4)
+#define LYNQ_URC_RESET_APNDB (LYNQ_URC_VENDOR_BASE+5)
+
+
+#define LYNQ_REQUEST_WRITE_SMS_TO_MEMORY (LYNQ_REQUEST_VENDOR_BASE +4)
+#define LYNQ_REQUEST_READ_SMS_FROM_MEMORY (LYNQ_REQUEST_VENDOR_BASE + 5)
+#define LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY (LYNQ_REQUEST_VENDOR_BASE + 6)
+#define LYNQ_REQUEST_LIST_SMS_FROM_MEMORY (LYNQ_REQUEST_VENDOR_BASE + 7)
+#define LYNQ_REQUEST_SET_DEFAULT_SIM_ALL (LYNQ_REQUEST_VENDOR_BASE + 8)
+
+#define LYNQ_REQUEST_SET_SPEECH_VOLUME (LYNQ_REQUEST_VENDOR_BASE +9)
+#define LYNQ_REQUEST_GET_SPEECH_VOLUME (LYNQ_REQUEST_VENDOR_BASE +10)
+#define LYNQ_REQUEST_RECORD (LYNQ_REQUEST_VENDOR_BASE +11)
+#define LYNQ_REQUEST_OOS_RECOVER_TIMER_INTERVAL (LYNQ_REQUEST_VENDOR_BASE +12)
+#define LYNQ_REQUEST_OOS_DEEP_SLEEP_RECOVER_TIMER_INTERVAL (LYNQ_REQUEST_VENDOR_BASE +13)
+#define LYNQ_REQUEST_CHANGE_SCREEN_STATE (LYNQ_REQUEST_VENDOR_BASE + 14)/*jb.qi add for two sim suspend 2022/9/19*/
+#define LYNQ_REQUEST_CHANGE_RADIO (LYNQ_REQUEST_VENDOR_BASE + 15)
+/*the same with lynq_interface.h end*/
+
+typedef enum{
+ /*base abnormal*/
+ LYNQ_E_PARAMETER_ANONALY=7000,
+ LYNQ_E_SEND_REQUEST_FAIL=7001,
+ LYNQ_E_GET_HEAD_ERROR=7002,
+ LYNQ_E_INNER_ERROR=7100,
+ LYNQ_E_MALLOC_ERROR=7101,
+ /**/
+ LYNQ_E_CARDSTATE_ERROR=8000,
+ /* The voice service state is out of service*/
+ LYNQ_E_STATE_OUT_OF_SERVICE=8001,
+ /* The voice service state is EMERGENCY_ONLY*/
+ LYNQ_E_STATE_EMERGENCY_ONLY=8002,
+ /* The radio power is power off*/
+ LYNQ_E_STATE_POWER_OFF=8003,
+ LYNQ_E_TIME_OUT=8004,
+ /*create or open sms DB fail */
+ LYNQ_E_SMS_DB_FAIL=8005,
+ /*Failed to execute sql statement*/
+ LYNQ_E_SMS_SQL_FAIL = 8006,
+ LYNQ_E_SMS_NOT_FIND = 8007,
+ /* The logic conflict*/
+ LYNQ_E_CONFLICT=9000,
+ /*Null anomaly*/
+ LYNQ_E_NULL_ANONALY=9001,
+ /*Invalid id anomaly*/
+ LYNQ_E_INVALID_ID_ANONALY=9002,
+#ifdef ECALL_SUPPORT
+ LYNQ_E_ECALL_BEING_RUNNING =9003,
+ LYNQ_E_ECALL_MSD_LENGTH_ERROR =9004,
+ LYNQ_E_ECALL_DAILING_NO_ANSWER =9005,
+#endif
+ LYNQ_E_SMS_MSGLEN_OUT_OF_RANGE = 9006,
+}LYNQ_E;
+
+#define MODULE_CLOSED (0)
+#define MODULE_SWITCHING (1)
+#define MODULE_RUNNING (2)
+
+extern int g_module_init_flag;
+
+#endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_module_socket.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_module_socket.cpp
new file mode 100755
index 0000000..a604125
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_module_socket.cpp
@@ -0,0 +1,1033 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <string.h>
+#include <unistd.h>
+#include <binder/Parcel.h>
+#include <log/log.h>
+#include <cutils/jstring.h>
+#include <pthread.h>
+#include <list>
+#include <vendor-ril/telephony/ril.h>
+#include <vendor-ril/telephony/mtk_ril_sp.h>
+#include "lynq_sim.h"
+#include "lynq_module_common.h"
+#include "lynq_module_socket.h"
+#include "liblog/lynq_deflog.h"
+#include "lynq_shm.h"
+
+#define LYNQ_SERVICE_PORT 8088
+#define LYNQ_ADDRESS "127.0.0.1"
+#define LYNQ_URC_SERVICE_PORT 8086
+#define LYNQ_URC_ADDRESS "0.0.0.0"
+#define LYNQ_REQUEST_PARAM_BUF 8192
+#define LYNQ_REC_BUF 8192
+
+#define USER_LOG_TAG "LYNQ_SIM"
+
+typedef struct{
+ int uToken;
+ int request;
+ int paramLen;
+ char param[LYNQ_REQUEST_PARAM_BUF];
+}lynq_client_t;
+
+
+
+typedef struct{
+ int resp_type;
+ int urcid;
+}lynq_head_t;
+
+lynq_client_t client_t;
+lynq_resp_t response;
+
+int module_len_rc_addr_serv;
+int module_len_urc_addr_serv;
+struct sockaddr_in module_rc_addr_serv;
+struct sockaddr_in module_urc_addr_serv;
+static int module_rc_sock_fd = -1;
+static int module_urc_sock_fd = -1;
+int module_urc_status = 1;
+int module_rc_status = 1;
+pthread_t module_urc_tid = -1;
+pthread_t module_rc_tid = -1;
+static pthread_mutex_t s_urc_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/*hq add for set waiting time 2022/09/13 begin*/
+static pthread_mutex_t s_sendto_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t s_RecvMsgBlockMutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t s_WaitRecvMsgCond = PTHREAD_COND_INITIALIZER;
+#define BLOCK_RECV_MSG_LOCK() pthread_mutex_lock(&s_RecvMsgBlockMutex)
+#define BLOCK_RECV_MSG_UNLOCK() pthread_mutex_unlock(&s_RecvMsgBlockMutex)
+#define BLOCK_WAIT_RECV_MSG_TIME_OUT(a) pthread_cond_timedwait(&s_WaitRecvMsgCond, &s_RecvMsgBlockMutex,(a))
+#define BLOCK_WAKEUP_RECV_MSG() pthread_cond_broadcast(&s_WaitRecvMsgCond)
+static std::list<Parcel*> s_recv_parcel_list;
+const int waitResponse(int token,int time_out);
+/*hq add for set waiting time 2022/09/13 end*/
+
+/*hq add for urc process asynchronous 2022/12/26 begin*/
+static pthread_mutex_t s_ProcessUrcMsgBlockMutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t s_WaitProcessUrcMsgCond = PTHREAD_COND_INITIALIZER;
+
+#define BLOCK_PROCESS_URC_MSG_INIT() pthread_mutex_init(&s_ProcessUrcMsgBlockMutex,NULL)
+#define BLOCK_PROCESS_URC_MSG_LOCK() pthread_mutex_lock(&s_ProcessUrcMsgBlockMutex)
+#define BLOCK_PROCESS_URC_MSG_UNLOCK() pthread_mutex_unlock(&s_ProcessUrcMsgBlockMutex)
+#define BLOCK_WAIT_PROCESS_URC_MSG() pthread_cond_wait(&s_WaitProcessUrcMsgCond, &s_ProcessUrcMsgBlockMutex)
+#define BLOCK_WAKEUP_PROCESS_URC_MSG() pthread_cond_broadcast(&s_WaitProcessUrcMsgCond)
+static std::list<Parcel*> s_recv_urc_parcel_list;
+void *thread_urc_process(void *p);
+pthread_t module_urc_process_tid = -1;
+int module_urc_process_status = 1;
+/*hq add for urc process asynchronous 2022/12/26 end*/
+
+int g_module_Global_uToken = 0;
+int g_wait_time=5;
+
+/*inner test*/
+static int s_inner_test=0;
+
+/**@brief just for inner test
+* @param test_mode [IN]: test mode
+* 0:success
+* other:failure
+*/
+void lynq_set_test_mode(const int test_mode)
+{
+ if(test_mode<0)
+ {
+ g_wait_time = -test_mode;
+ }
+ else if(test_mode==9999)
+ {
+ LYERRLOG("%s inner test para %d %d",__FUNCTION__,s_inner_test,g_wait_time);
+ }
+ else
+ {
+ s_inner_test = test_mode;
+ }
+}
+
+void cleanup_RecvMsgBlock_mutex(void *arg)
+{
+ BLOCK_RECV_MSG_UNLOCK();
+}
+
+/**@brief wait response with expected token and write msg to parcel in some time
+* @param p [IN]: pointer the parcel
+* @param token [IN]: the expected token for the response msg
+* @param time_out [IN]: timeout.
+* @return
+* 0:success
+* other:failure
+*/
+const int waitResponse(Parcel*& p, int token,int time_out)
+{
+ int waitToken = token;
+ int wakeup_token=-1;
+ int resp_type;
+ struct timeval now;
+ struct timespec timeout;
+ int ret;
+ std::list<Parcel*>::iterator iter;
+ int cnt=0;
+
+ gettimeofday(&now,NULL);
+ timeout.tv_sec = now.tv_sec+time_out; //timeout is 1min
+ timeout.tv_nsec = now.tv_usec*1000;
+
+ LYINFLOG("%s wait token is %d, wait time is %d",__FUNCTION__,waitToken,time_out);
+
+ BLOCK_RECV_MSG_LOCK();
+ pthread_cleanup_push(cleanup_RecvMsgBlock_mutex, NULL); // thread cleanup handler
+ while(module_rc_status){
+ cnt++;
+ for(iter=s_recv_parcel_list.begin();iter!=s_recv_parcel_list.end();++iter)
+ {
+ (*iter)->setDataPosition(0);
+ (*iter)->readInt32(&resp_type);
+ (*iter)->readInt32(&wakeup_token);
+ if(wakeup_token==waitToken)
+ {
+ LYINFLOG("%s get waitToken",__FUNCTION__);
+ p=(*iter);
+ p->setDataPosition(0);
+ s_recv_parcel_list.erase(iter);
+ goto waitResponse_end;
+ }
+ }
+ LYINFLOG("%s no wait Token in msg list, list size is %d",__FUNCTION__,s_recv_parcel_list.size());
+ ret=BLOCK_WAIT_RECV_MSG_TIME_OUT(&timeout);
+ if(ret!=0)
+ {
+ LYERRLOG("%s no expected token %d after %d second",__FUNCTION__,waitToken,time_out);
+ break;
+ }
+ }
+waitResponse_end:
+ LYINFLOG("%s wait token is %d wakeup_token is %d, cnt is %d",__FUNCTION__,waitToken,wakeup_token,cnt);
+ pthread_cleanup_pop(0);
+ BLOCK_RECV_MSG_UNLOCK();
+ return wakeup_token==waitToken ? 0:LYNQ_E_TIME_OUT;
+}
+
+/**@brief print solicied response msg's head information
+* @param head [IN]: head information
+* @return none
+*/
+void PrintHeaderNew(lynq_resp_t& head)
+{
+ LYINFLOG("resp_type=%d,token=%d,request=%d,slot_id=%d,error_code=%d",head.resp_type,head.token,head.request,head.slot_id,head.error);
+}
+
+/**@brief get solicied response msg's head
+* @param head [OUT]: head information
+* @return
+* 0:success
+* other:failure
+*/
+int GetHeaderNew(Parcel* &p, lynq_resp_t& head)
+{
+ LYINFLOG("get header");
+ if(p->dataAvail() > 0)
+ {
+ p->readInt32(&(head.resp_type));
+ p->readInt32(&(head.token));
+ p->readInt32(&(head.request));
+ p->readInt32(&(head.slot_id));
+ p->readInt32(&(head.error));
+ PrintHeaderNew(head);
+ return RESULT_OK;
+ }
+ else
+ {
+ return RESULT_ERROR;
+ }
+}
+
+/**@brief send msg to service and get response from service
+* @param request_id [IN]: request id
+* @param time_out [IN]: wait time uplimit
+* @param p [IN]: point to response msg's parcel
+* @param argc [IN]: how many parameters in parameter string
+* @param format [IN]: parameter string's format
+* @param ... [IN]: the specific parameter
+* @return
+* 0:success
+* other:failure
+*/
+int lynq_send_common_request(Parcel*& p, int time_out, int request_id, int argc, const char* format,...)
+{
+ lynq_client_t client;
+ int ret;
+ int send_num;
+
+ client.uToken = g_module_Global_uToken;
+ g_module_Global_uToken=(g_module_Global_uToken+1)%10000;/*0-10000*/
+ client.request = request_id;
+ client.paramLen = argc;
+ bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
+ if(argc!=0)
+ {
+ va_list args;
+ va_start(args, format);
+ vsnprintf(client.param, LYNQ_REQUEST_PARAM_BUF, format, args);
+ va_end(args);
+ }
+ LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+ pthread_mutex_lock(&s_sendto_mutex);
+ if(s_inner_test==1)
+ {
+ send_num = 1;
+ }
+ else
+ {
+ send_num = sendto(module_rc_sock_fd,&client,sizeof(client),0,(struct sockaddr *)&module_rc_addr_serv,module_len_rc_addr_serv);
+ }
+ if(s_inner_test>=1000)
+ {
+ time_out = s_inner_test-1000;
+ }
+ pthread_mutex_unlock(&s_sendto_mutex);
+
+ if(send_num <= 0)
+ {
+ LYERRLOG("send request fail, send num is %d", send_num);
+ return LYNQ_E_SEND_REQUEST_FAIL;
+ }
+ ret = waitResponse(p, client.uToken,time_out);
+
+ if(ret==0)
+ {
+ lynq_resp_t head;
+ ret=GetHeaderNew(p,head);
+ if(ret!=0)
+ {
+ LYERRLOG("%s %d get head error %d",__FUNCTION__,client.uToken,ret);
+ delete p;
+ return LYNQ_E_GET_HEAD_ERROR;
+ }
+ if(head.error!=0)
+ {
+ LYERRLOG("%s %d mdm return head error %d",__FUNCTION__,client.uToken,head.error);
+ delete p;
+ return head.error;
+ }
+ LYERRLOG("%s %d suc",__FUNCTION__,client.uToken);
+ return RESULT_OK;
+ }
+
+ LYERRLOG("%s %d fail, ret is %d",__FUNCTION__,client.uToken,ret);
+
+ return ret;
+}
+
+/*hq add for urc broadcase optimisson 2023/01/03 begin*/
+#define SHM_BUFFER_INDEX_OFFSET 1
+#define SHM_BUFFER_SIZE_OFFSET 16
+#define SHM_BUFFER_INDEX_MASK 0x0000007F
+#define SHM_BUFFER_SIZE_MASK 0x0000FFFF
+
+bool urc_data_is_in_shm_data(int responseType,int& level, int& index, int& size)
+{
+ int shm_index=((responseType>>SHM_BUFFER_INDEX_OFFSET)&SHM_BUFFER_INDEX_MASK);
+ if (shm_index>0)
+ {
+ index=shm_index-1;
+ size=((responseType>>SHM_BUFFER_SIZE_OFFSET)&SHM_BUFFER_SIZE_MASK);
+ if(size>=sizeof(int32_t)*3 && get_shem_buffer_level(size,&level))
+ {
+ LYINFLOG("urc_data_is_in_shm_data level is %d, index is %d size is %d",level,index,size);
+ return true;
+ }
+ }
+ LYINFLOG("urc_data_is_in_shm_data return false, responseType is %d",responseType);
+ return false;
+}
+/*hq add for urc broadcase optimisson 2023/01/03 end*/
+
+void *thread_urc_recv(void *p)
+{
+ Parcel *urc_p =NULL;
+ char urc_data[LYNQ_REC_BUF];
+ int res = 0;
+ lynq_head_t* phead;
+ int level,index,size;
+ LYINFLOG("urc recv thread is running");
+ while(module_urc_status)
+ {
+ bzero(urc_data,LYNQ_REC_BUF);
+ res = recvfrom(module_urc_sock_fd,urc_data,sizeof(urc_data),0,(struct sockaddr *)&module_urc_addr_serv,(socklen_t*)&module_len_urc_addr_serv);
+ if(res<sizeof(int32_t)*2)
+ {
+ LYERRLOG("thread_urc_recv step2 fail: res is %d",res);
+ continue;
+ }
+ LYDBGLOG("__FUNCTION__ %s __LINE__ %d\n", __FUNCTION__, __LINE__);
+ phead=(lynq_head_t*) urc_data;
+ if(is_support_urc(phead->urcid)==false)
+ {
+ continue;
+ }
+ urc_p = new Parcel();
+ if(urc_p == NULL)
+ {
+ LYERRLOG("new parcel failure!!!");
+ continue;
+ }
+ LYDBGLOG("__FUNCTION__ %s __LINE__ %d\n", __FUNCTION__, __LINE__);
+
+ if(urc_data_is_in_shm_data(phead->resp_type,level,index,size))
+ {
+ LYINFLOG("__FUNCTION__ %s __LINE__ %d,use share memory\n", __FUNCTION__, __LINE__);
+ urc_p->setData((uint8_t *)get_shem_buffer(level,index),size); // p.setData((uint8_t *) buffer, buflen);
+ }
+ else if(res>=sizeof(int32_t)*3)
+ {
+ urc_p->setData((uint8_t *)urc_data,res); // p.setData((uint8_t *) buffer, buflen);
+ }
+ else
+ {
+ LYERRLOG("res %d error!!!", res);
+ delete urc_p;
+ urc_p = NULL;
+ continue;
+ }
+ urc_p->setDataPosition(0);
+ if(urc_p->dataAvail()>0)
+ {
+ BLOCK_PROCESS_URC_MSG_LOCK();
+ s_recv_urc_parcel_list.push_back(urc_p);
+ BLOCK_WAKEUP_PROCESS_URC_MSG();
+ BLOCK_PROCESS_URC_MSG_UNLOCK();
+ LYDBGLOG("__FUNCTION__ %s __LINE__ %d\n", __FUNCTION__, __LINE__);
+ }
+ else
+ {
+ delete urc_p;
+ urc_p = NULL;
+ }
+ LYDBGLOG("__FUNCTION__ %s __LINE__ %d\n", __FUNCTION__, __LINE__);
+ }
+ LYINFLOG("urc recv thread ended");
+ return NULL;
+}
+
+void cleanup_urc_process_mutex(void *arg)
+{
+ BLOCK_PROCESS_URC_MSG_UNLOCK();
+}
+
+void *thread_urc_process(void *p)
+{
+ Parcel *urc_p =NULL;
+ std::list<Parcel*>::iterator iter;
+
+ LYINFLOG("urc process thread is running");
+ pthread_cleanup_push(cleanup_urc_process_mutex, NULL); // thread cleanup handler
+ while(module_urc_process_status)
+ {
+ BLOCK_PROCESS_URC_MSG_LOCK();
+ while(s_recv_urc_parcel_list.empty())
+ {
+ LYDBGLOG("__FUNCTION__ %s __LINE__ %d\n", __FUNCTION__, __LINE__);
+ BLOCK_WAIT_PROCESS_URC_MSG();
+ LYDBGLOG("__FUNCTION__ %s __LINE__ %d\n", __FUNCTION__, __LINE__);
+ }
+ iter=s_recv_urc_parcel_list.begin();
+ urc_p=(*iter);
+ s_recv_urc_parcel_list.erase(iter);
+ BLOCK_PROCESS_URC_MSG_UNLOCK();
+ urc_p->setDataPosition(0);
+ if(urc_p->dataAvail()>0)
+ {
+ LYDBGLOG("__FUNCTION__ %s __LINE__ %d\n", __FUNCTION__, __LINE__);
+ pthread_mutex_lock(&s_urc_mutex);
+ urc_msg_process(urc_p);
+ pthread_mutex_unlock(&s_urc_mutex);
+ LYDBGLOG("__FUNCTION__ %s __LINE__ %d\n", __FUNCTION__, __LINE__);
+ }
+ delete urc_p;
+ urc_p = NULL;
+ }
+ pthread_cleanup_pop(0);
+ LYINFLOG("urc process thread ended");
+ return NULL;
+}
+
+void lynq_close_urc_rev_thread()
+{
+ int ret;
+
+ BLOCK_PROCESS_URC_MSG_LOCK(); //just cancel urc process tid when recv from
+ module_urc_status = 0;
+ if(module_urc_tid!=-1)
+ {
+ ret = pthread_cancel(module_urc_tid);
+ LYINFLOG("pthread cancel urc rev ret = %d",ret);
+ }
+ BLOCK_PROCESS_URC_MSG_UNLOCK();
+ if(module_urc_tid != -1)
+ {
+ ret = pthread_join(module_urc_tid,NULL);
+ LYINFLOG("pthread join urc tid ret = %d",ret);
+ module_urc_tid =-1;
+ }
+}
+
+void lynq_close_urc_process_thread()
+{
+ int ret;
+ BLOCK_PROCESS_URC_MSG_LOCK(); //just cancel urc process tid when not process urc msg in list
+ pthread_mutex_lock(&s_urc_mutex); //just cancel urc process tid when not process urg msg avoid mutual lock for tid may call pthread_cond_wait
+ module_urc_process_status = 0;
+ if(module_urc_process_tid!=-1)
+ {
+ ret = pthread_cancel(module_urc_process_tid);
+ LYINFLOG("pthread cancel urc process ret = %d",ret);
+ }
+ pthread_mutex_unlock(&s_urc_mutex);
+ BLOCK_PROCESS_URC_MSG_UNLOCK();
+ if(module_urc_process_tid != -1)
+ {
+ ret = pthread_join(module_urc_process_tid,NULL);
+ LYINFLOG("pthread join urc process tid ret = %d",ret);
+ module_urc_process_tid =-1;
+ }
+}
+
+int lynq_setup_urc_socket()
+{
+ int on = 1;
+ int ret = 0;
+ module_len_urc_addr_serv = sizeof(sockaddr_in);
+ module_urc_sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (module_urc_sock_fd <0){
+ LYERRLOG("urc socket error");
+ return RESULT_ERROR;
+ }
+ module_urc_addr_serv.sin_family = AF_INET;
+ module_urc_addr_serv.sin_port = htons(LYNQ_URC_SERVICE_PORT);
+ module_urc_addr_serv.sin_addr.s_addr = inet_addr(LYNQ_URC_ADDRESS);
+ /* Set socket to allow reuse of address and port, SO_REUSEADDR value is 2*/
+ ret = setsockopt(module_urc_sock_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on);
+ if(ret <0)
+ {
+ LYERRLOG("urc socket set error");
+ close(module_urc_sock_fd);
+ module_urc_sock_fd =-1;
+ return RESULT_ERROR;
+ }
+ ret = bind(module_urc_sock_fd ,(struct sockaddr*)&module_urc_addr_serv, sizeof(module_urc_addr_serv));
+ if(ret <0)
+ {
+ LYERRLOG("urc socket bind error");
+ close(module_urc_sock_fd);
+ module_urc_sock_fd =-1;
+ return RESULT_ERROR;
+ }
+ return RESULT_OK;
+}
+
+void lynq_close_urc_socket()
+{
+ if (module_urc_sock_fd >= 0)
+ {
+ close(module_urc_sock_fd);
+ module_urc_sock_fd =-1;
+ }
+}
+
+int lynq_start_all_urc_socket_thread()
+{
+
+ if(ril_init_mem()!=0)
+ {
+ LYERRLOG("ril_init_mem fail");
+ return RESULT_ERROR;
+ }
+
+ int ret= lynq_setup_urc_socket();
+ if(ret!=RESULT_OK)
+ {
+ LYERRLOG("sim lynq_setup_urc_socket fail");
+ ril_deinit_mem();
+ return RESULT_ERROR;
+ }
+
+ BLOCK_PROCESS_URC_MSG_INIT();
+ BLOCK_PROCESS_URC_MSG_LOCK();
+ std::list<Parcel*>::iterator iter;
+ for(iter=s_recv_urc_parcel_list.begin();iter!=s_recv_urc_parcel_list.end();++iter)
+ {
+ delete (*iter);
+ }
+ s_recv_urc_parcel_list.clear();
+ BLOCK_PROCESS_URC_MSG_UNLOCK();
+
+ pthread_mutex_init(&s_urc_mutex, NULL);
+
+ module_urc_status = 1;
+ // pthread_attr_init(&attr);
+ // pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ ret = pthread_create(&module_urc_tid,/*&attr*/NULL,thread_urc_recv,NULL);
+ if(ret <0)
+ {
+ LYERRLOG("urc recv pthread create error");
+ module_urc_status = 0;
+ lynq_close_urc_socket();
+ ril_deinit_mem();
+ return RESULT_ERROR;
+ }
+
+ module_urc_process_status = 1;
+ ret = pthread_create(&module_urc_process_tid,/*&attr*/NULL,thread_urc_process,NULL);
+ if(ret <0)
+ {
+ LYERRLOG("urc process pthread create error");
+ module_urc_process_status = 0;
+ lynq_close_urc_socket();
+ lynq_close_urc_rev_thread();
+ ril_deinit_mem();
+ return RESULT_ERROR;
+ }
+
+ LYINFLOG("urc start success");
+
+ return RESULT_OK;
+}
+
+void lynq_close_all_urc_socket_thread()
+{
+
+ lynq_close_urc_rev_thread();
+ lynq_close_urc_socket();
+ lynq_close_urc_process_thread();
+
+ BLOCK_PROCESS_URC_MSG_LOCK();
+ std::list<Parcel*>::iterator iter;
+ for(iter=s_recv_urc_parcel_list.begin();iter!=s_recv_urc_parcel_list.end();++iter)
+ {
+ delete (*iter);
+ }
+ s_recv_urc_parcel_list.clear();
+ BLOCK_PROCESS_URC_MSG_UNLOCK();
+
+ ril_deinit_mem();
+}
+
+bool is_support_request(int req_id)
+{
+ switch(req_id)
+ {
+ case RIL_REQUEST_SEND_SMS:
+ case RIL_REQUEST_SET_SMSC_ADDRESS:
+ case RIL_REQUEST_GET_SMSC_ADDRESS:
+ case LYNQ_REQUEST_READ_SMS_FROM_MEMORY:
+ case LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY:
+ case RIL_UNSOL_SIM_STATUS_COMMAND:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/**@ a thread just for recv\buffer solicited msg's response and notice waiting thread
+* @param p [IN]: no meaning
+* @return
+* always null
+*/
+void *thread_rc_recv(void *p)
+{
+ Parcel* rc_p;
+ std::list<Parcel*>::iterator iter;
+ int resp_type = -1;
+ char rc_data[LYNQ_REC_BUF];
+ int rc_len;
+ int null_cnt=0;
+ int wakeup_token;
+ int resquest;
+ LYINFLOG("rc thread is running");
+ while(module_rc_status)
+ {
+ bzero(rc_data,LYNQ_REC_BUF);
+ while(true)
+ {
+ rc_len = recvfrom(module_rc_sock_fd,rc_data,sizeof(rc_data),0,(struct sockaddr *)&module_rc_addr_serv,(socklen_t *)&module_len_rc_addr_serv);
+ if(rc_len<sizeof(int32_t)*2)
+ {
+ LYERRLOG("%s recv len %d less %d",__FUNCTION__, rc_len,sizeof(int)*2);
+ continue;
+ }
+ rc_p= new Parcel;
+ if(rc_p==NULL)
+ {
+ null_cnt++;
+ LYERRLOG("%s rc_p is NULL, cnt is %d",__FUNCTION__, null_cnt);
+ if(null_cnt>20)
+ {
+ goto rc_recv_end;
+ }
+ continue;
+ }
+ else
+ {
+ null_cnt=0;
+ }
+
+ rc_p->setData((uint8_t *)rc_data,rc_len); // p.setData((uint8_t *) buffer, buflen);
+ rc_p->setDataPosition(0);
+ if(rc_p->dataAvail()>0)
+ {
+ rc_p->readInt32(&resp_type);
+ rc_p->readInt32(&wakeup_token);
+ rc_p->readInt32(&resquest);
+
+ BLOCK_RECV_MSG_LOCK();
+ s_recv_parcel_list.push_back(rc_p);
+ LYINFLOG("%s wakeup token is %d, list size is %d!",__FUNCTION__,wakeup_token,s_recv_parcel_list.size());
+ if(s_recv_parcel_list.size()>20) //max 20
+ {
+ iter=s_recv_parcel_list.begin();
+ (*iter)->setDataPosition(0);
+ (*iter)->readInt32(&resp_type);
+ (*iter)->readInt32(&wakeup_token);
+ delete (*(s_recv_parcel_list.begin()));
+ LYERRLOG("%s wakeup token %d is deleted!",__FUNCTION__,wakeup_token);
+ s_recv_parcel_list.erase(iter);
+ }
+ BLOCK_WAKEUP_RECV_MSG();
+ BLOCK_RECV_MSG_UNLOCK();
+ break;
+ }
+ else
+ {
+ LYERRLOG("%s rc_p data Avail %d not greater than 0",__FUNCTION__, rc_p->dataAvail());
+ delete rc_p;
+ }
+ }
+ }
+
+rc_recv_end:
+ LYINFLOG("rc thread ended");
+ return NULL;
+}
+
+int lynq_start_all_rc_socket_thread()
+{
+ module_rc_sock_fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if(module_rc_sock_fd < 0)
+ {
+ LYERRLOG("socket open error");
+ return -1;
+ }
+
+ LYINFLOG("module_rc_sock_fd = %d",module_rc_sock_fd);
+
+ memset(&module_rc_addr_serv, 0, sizeof(module_rc_addr_serv));
+ module_rc_addr_serv.sin_family = AF_INET;
+ module_rc_addr_serv.sin_addr.s_addr = inet_addr(LYNQ_ADDRESS);
+ module_rc_addr_serv.sin_port = htons(LYNQ_SERVICE_PORT);
+ module_len_rc_addr_serv = sizeof(module_rc_addr_serv);
+
+ BLOCK_RECV_MSG_LOCK();
+ std::list<Parcel*>::iterator iter;
+ for(iter=s_recv_parcel_list.begin();iter!=s_recv_parcel_list.end();++iter)
+ {
+ delete (*iter);
+ }
+ s_recv_parcel_list.clear();
+ BLOCK_RECV_MSG_UNLOCK();
+
+// pthread_attr_t attr;
+ int ret;
+
+ pthread_mutex_init(&s_sendto_mutex, NULL);
+ pthread_mutex_init(&s_RecvMsgBlockMutex, NULL);
+
+ module_rc_status = 1;
+// pthread_attr_init(&attr);
+// pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ ret = pthread_create(&module_rc_tid,/*&attr*/NULL,thread_rc_recv,NULL);
+ if(ret <0)
+ {
+ LYERRLOG("rc pthread create error");
+ module_rc_status =0;
+ close(module_rc_sock_fd);
+ module_rc_sock_fd =-1;
+ return ret;
+ }
+
+ LYINFLOG("rc start success");
+
+ return RESULT_OK;
+}
+
+void lynq_close_all_rc_socket_thread()
+{
+ int ret;
+ BLOCK_RECV_MSG_LOCK();
+ module_rc_status = 0;
+ BLOCK_WAKEUP_RECV_MSG();
+ if(module_rc_tid != -1)
+ {
+ ret = pthread_cancel(module_rc_tid);
+ LYINFLOG("pthread cancel rc ret = %d",ret);
+ }
+ BLOCK_RECV_MSG_UNLOCK();
+ if(module_rc_tid != -1)
+ {
+ ret = pthread_join(module_rc_tid,NULL);
+ module_rc_tid =-1;
+ LYINFLOG("pthread join rc tid ret = %d",ret);
+
+ }
+
+ if (module_rc_sock_fd > 0)
+ {
+ close(module_rc_sock_fd);
+ module_rc_sock_fd =-1;
+ }
+
+ BLOCK_RECV_MSG_LOCK();
+ std::list<Parcel*>::iterator iter;
+ for(iter=s_recv_parcel_list.begin();iter!=s_recv_parcel_list.end();++iter)
+ {
+ delete (*iter);
+ }
+ s_recv_parcel_list.clear();
+ BLOCK_RECV_MSG_UNLOCK();
+}
+
+const char * requestToString(int request)
+{
+ /*
+ cat libs/telephony/ril_commands.h \
+ | egrep "^ *{RIL_" \
+ | sed -re 's/\{RIL_([^,]+),[^,]+,([^}]+).+/case RIL_\1: return "\1";/'
+
+
+ cat libs/telephony/ril_unsol_commands.h \
+ | egrep "^ *{RIL_" \
+ | sed -re 's/\{RIL_([^,]+),([^}]+).+/case RIL_\1: return "\1";/'
+
+ */
+ switch(request) {
+ case RIL_REQUEST_GET_SIM_STATUS: return "GET_SIM_STATUS";
+ case RIL_REQUEST_ENTER_SIM_PIN: return "ENTER_SIM_PIN";
+ case RIL_REQUEST_ENTER_SIM_PUK: return "ENTER_SIM_PUK";
+ case RIL_REQUEST_ENTER_SIM_PIN2: return "ENTER_SIM_PIN2";
+ case RIL_REQUEST_ENTER_SIM_PUK2: return "ENTER_SIM_PUK2";
+ case RIL_REQUEST_CHANGE_SIM_PIN: return "CHANGE_SIM_PIN";
+ case RIL_REQUEST_CHANGE_SIM_PIN2: return "CHANGE_SIM_PIN2";
+ case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: return "ENTER_NETWORK_DEPERSONALIZATION";
+ case RIL_REQUEST_GET_CURRENT_CALLS: return "GET_CURRENT_CALLS";
+ case RIL_REQUEST_DIAL: return "DIAL";
+ case RIL_REQUEST_GET_IMSI: return "GET_IMSI";
+ case RIL_REQUEST_HANGUP: return "HANGUP";
+ case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: return "HANGUP_WAITING_OR_BACKGROUND";
+ case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: return "HANGUP_FOREGROUND_RESUME_BACKGROUND";
+ case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: return "SWITCH_WAITING_OR_HOLDING_AND_ACTIVE";
+ case RIL_REQUEST_CONFERENCE: return "CONFERENCE";
+ case RIL_REQUEST_UDUB: return "UDUB";
+ case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: return "LAST_CALL_FAIL_CAUSE";
+ case RIL_REQUEST_SIGNAL_STRENGTH: return "SIGNAL_STRENGTH";
+ case RIL_REQUEST_VOICE_REGISTRATION_STATE: return "VOICE_REGISTRATION_STATE";
+ case RIL_REQUEST_DATA_REGISTRATION_STATE: return "DATA_REGISTRATION_STATE";
+ case RIL_REQUEST_OPERATOR: return "OPERATOR";
+ case RIL_REQUEST_RADIO_POWER: return "RADIO_POWER";
+ case RIL_REQUEST_DTMF: return "DTMF";
+ case RIL_REQUEST_SEND_SMS: return "SEND_SMS";
+ case RIL_REQUEST_SEND_SMS_EXPECT_MORE: return "SEND_SMS_EXPECT_MORE";
+ case RIL_REQUEST_SETUP_DATA_CALL: return "SETUP_DATA_CALL";
+ case RIL_REQUEST_SIM_IO: return "SIM_IO";
+ case RIL_REQUEST_SEND_USSD: return "SEND_USSD";
+ case RIL_REQUEST_CANCEL_USSD: return "CANCEL_USSD";
+ case RIL_REQUEST_GET_CLIR: return "GET_CLIR";
+ case RIL_REQUEST_SET_CLIR: return "SET_CLIR";
+ case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: return "QUERY_CALL_FORWARD_STATUS";
+ case RIL_REQUEST_SET_CALL_FORWARD: return "SET_CALL_FORWARD";
+ case RIL_REQUEST_QUERY_CALL_WAITING: return "QUERY_CALL_WAITING";
+ case RIL_REQUEST_SET_CALL_WAITING: return "SET_CALL_WAITING";
+ case RIL_REQUEST_SMS_ACKNOWLEDGE: return "SMS_ACKNOWLEDGE";
+ case RIL_REQUEST_GET_IMEI: return "GET_IMEI";
+ case RIL_REQUEST_GET_IMEISV: return "GET_IMEISV";
+ case RIL_REQUEST_ANSWER: return "ANSWER";
+ case RIL_REQUEST_DEACTIVATE_DATA_CALL: return "DEACTIVATE_DATA_CALL";
+ case RIL_REQUEST_QUERY_FACILITY_LOCK: return "QUERY_FACILITY_LOCK";
+ case RIL_REQUEST_SET_FACILITY_LOCK: return "SET_FACILITY_LOCK";
+ case RIL_REQUEST_CHANGE_BARRING_PASSWORD: return "CHANGE_BARRING_PASSWORD";
+ case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: return "QUERY_NETWORK_SELECTION_MODE";
+ case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: return "SET_NETWORK_SELECTION_AUTOMATIC";
+ case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: return "SET_NETWORK_SELECTION_MANUAL";
+ case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : return "QUERY_AVAILABLE_NETWORKS ";
+ case RIL_REQUEST_DTMF_START: return "DTMF_START";
+ case RIL_REQUEST_DTMF_STOP: return "DTMF_STOP";
+ case RIL_REQUEST_BASEBAND_VERSION: return "BASEBAND_VERSION";
+ case RIL_REQUEST_SEPARATE_CONNECTION: return "SEPARATE_CONNECTION";
+ case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: return "SET_PREFERRED_NETWORK_TYPE";
+ case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: return "GET_PREFERRED_NETWORK_TYPE";
+ case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: return "GET_NEIGHBORING_CELL_IDS";
+ case RIL_REQUEST_SET_MUTE: return "SET_MUTE";
+ case RIL_REQUEST_GET_MUTE: return "GET_MUTE";
+ case RIL_REQUEST_QUERY_CLIP: return "QUERY_CLIP";
+ case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: return "LAST_DATA_CALL_FAIL_CAUSE";
+ case RIL_REQUEST_DATA_CALL_LIST: return "DATA_CALL_LIST";
+ case RIL_REQUEST_RESET_RADIO: return "RESET_RADIO";
+ case RIL_REQUEST_OEM_HOOK_RAW: return "OEM_HOOK_RAW";
+ case RIL_REQUEST_OEM_HOOK_STRINGS: return "OEM_HOOK_STRINGS";
+ case RIL_REQUEST_SET_BAND_MODE: return "SET_BAND_MODE";
+ case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: return "QUERY_AVAILABLE_BAND_MODE";
+ case RIL_REQUEST_STK_GET_PROFILE: return "STK_GET_PROFILE";
+ case RIL_REQUEST_STK_SET_PROFILE: return "STK_SET_PROFILE";
+ case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: return "STK_SEND_ENVELOPE_COMMAND";
+ case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: return "STK_SEND_TERMINAL_RESPONSE";
+ case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: return "STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM";
+ case RIL_REQUEST_SCREEN_STATE: return "SCREEN_STATE";
+ case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: return "EXPLICIT_CALL_TRANSFER";
+ case RIL_REQUEST_SET_LOCATION_UPDATES: return "SET_LOCATION_UPDATES";
+ case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE:return"CDMA_SET_SUBSCRIPTION_SOURCE";
+ case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE:return"CDMA_SET_ROAMING_PREFERENCE";
+ case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE:return"CDMA_QUERY_ROAMING_PREFERENCE";
+ case RIL_REQUEST_SET_TTY_MODE:return"SET_TTY_MODE";
+ case RIL_REQUEST_QUERY_TTY_MODE:return"QUERY_TTY_MODE";
+ case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE";
+ case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE:return"CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE";
+ case RIL_REQUEST_CDMA_FLASH:return"CDMA_FLASH";
+ case RIL_REQUEST_CDMA_BURST_DTMF:return"CDMA_BURST_DTMF";
+ case RIL_REQUEST_CDMA_SEND_SMS:return"CDMA_SEND_SMS";
+ case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE:return"CDMA_SMS_ACKNOWLEDGE";
+ case RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG:return"GSM_GET_BROADCAST_SMS_CONFIG";
+ case RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG:return"GSM_SET_BROADCAST_SMS_CONFIG";
+ case RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION:return "GSM_SMS_BROADCAST_ACTIVATION";
+ case RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG:return "CDMA_GET_BROADCAST_SMS_CONFIG";
+ case RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG:return "CDMA_SET_BROADCAST_SMS_CONFIG";
+ case RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION:return "CDMA_SMS_BROADCAST_ACTIVATION";
+ case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: return"CDMA_VALIDATE_AND_WRITE_AKEY";
+ case RIL_REQUEST_CDMA_SUBSCRIPTION: return"CDMA_SUBSCRIPTION";
+ case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: return "CDMA_WRITE_SMS_TO_RUIM";
+ case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: return "CDMA_DELETE_SMS_ON_RUIM";
+ case RIL_REQUEST_DEVICE_IDENTITY: return "DEVICE_IDENTITY";
+ case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: return "EXIT_EMERGENCY_CALLBACK_MODE";
+ case RIL_REQUEST_GET_SMSC_ADDRESS: return "GET_SMSC_ADDRESS";
+ case RIL_REQUEST_SET_SMSC_ADDRESS: return "SET_SMSC_ADDRESS";
+ case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: return "REPORT_SMS_MEMORY_STATUS";
+ case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: return "REPORT_STK_SERVICE_IS_RUNNING";
+ case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: return "CDMA_GET_SUBSCRIPTION_SOURCE";
+ case RIL_REQUEST_ISIM_AUTHENTICATION: return "ISIM_AUTHENTICATION";
+ case RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU: return "RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU";
+ case RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS: return "RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS";
+ case RIL_REQUEST_VOICE_RADIO_TECH: return "VOICE_RADIO_TECH";
+ case RIL_REQUEST_GET_CELL_INFO_LIST: return"GET_CELL_INFO_LIST";
+ case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: return"SET_UNSOL_CELL_INFO_LIST_RATE";
+ case RIL_REQUEST_SET_INITIAL_ATTACH_APN: return "RIL_REQUEST_SET_INITIAL_ATTACH_APN";
+ case RIL_REQUEST_IMS_REGISTRATION_STATE: return "IMS_REGISTRATION_STATE";
+ case RIL_REQUEST_IMS_SEND_SMS: return "IMS_SEND_SMS";
+ case RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC: return "SIM_TRANSMIT_APDU_BASIC";
+ case RIL_REQUEST_SIM_OPEN_CHANNEL: return "SIM_OPEN_CHANNEL";
+ case RIL_REQUEST_SIM_CLOSE_CHANNEL: return "SIM_CLOSE_CHANNEL";
+ case RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL: return "SIM_TRANSMIT_APDU_CHANNEL";
+ case RIL_REQUEST_GET_RADIO_CAPABILITY: return "RIL_REQUEST_GET_RADIO_CAPABILITY";
+ case RIL_REQUEST_SET_RADIO_CAPABILITY: return "RIL_REQUEST_SET_RADIO_CAPABILITY";
+ case RIL_REQUEST_SET_UICC_SUBSCRIPTION: return "SET_UICC_SUBSCRIPTION";
+ case RIL_REQUEST_ALLOW_DATA: return "ALLOW_DATA";
+ case RIL_REQUEST_GET_HARDWARE_CONFIG: return "GET_HARDWARE_CONFIG";
+ case RIL_REQUEST_SIM_AUTHENTICATION: return "SIM_AUTHENTICATION";
+ case RIL_REQUEST_GET_DC_RT_INFO: return "GET_DC_RT_INFO";
+ case RIL_REQUEST_SET_DC_RT_INFO_RATE: return "SET_DC_RT_INFO_RATE";
+ case RIL_REQUEST_SET_DATA_PROFILE: return "SET_DATA_PROFILE";
+ case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: return "UNSOL_RESPONSE_RADIO_STATE_CHANGED";
+ case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: return "UNSOL_RESPONSE_CALL_STATE_CHANGED";
+ case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
+ case RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED: return "UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED";
+ case RIL_UNSOL_RESPONSE_NEW_SMS: return "UNSOL_RESPONSE_NEW_SMS";
+ case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: return "UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT";
+ case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: return "UNSOL_RESPONSE_NEW_SMS_ON_SIM";
+ case RIL_UNSOL_ON_USSD: return "UNSOL_ON_USSD";
+ case RIL_UNSOL_ON_USSD_REQUEST: return "UNSOL_ON_USSD_REQUEST(obsolete)";
+ case RIL_UNSOL_NITZ_TIME_RECEIVED: return "UNSOL_NITZ_TIME_RECEIVED";
+ case RIL_UNSOL_SIGNAL_STRENGTH: return "UNSOL_SIGNAL_STRENGTH";
+ case RIL_UNSOL_STK_SESSION_END: return "UNSOL_STK_SESSION_END";
+ case RIL_UNSOL_STK_PROACTIVE_COMMAND: return "UNSOL_STK_PROACTIVE_COMMAND";
+ case RIL_UNSOL_STK_EVENT_NOTIFY: return "UNSOL_STK_EVENT_NOTIFY";
+ case RIL_UNSOL_STK_CALL_SETUP: return "UNSOL_STK_CALL_SETUP";
+ case RIL_UNSOL_SIM_SMS_STORAGE_FULL: return "UNSOL_SIM_SMS_STORAGE_FUL";
+ case RIL_UNSOL_SIM_REFRESH: return "UNSOL_SIM_REFRESH";
+ case RIL_UNSOL_DATA_CALL_LIST_CHANGED: return "UNSOL_DATA_CALL_LIST_CHANGED";
+ case RIL_UNSOL_CALL_RING: return "UNSOL_CALL_RING";
+ case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: return "UNSOL_RESPONSE_SIM_STATUS_CHANGED";
+ case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: return "UNSOL_NEW_CDMA_SMS";
+ case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: return "UNSOL_NEW_BROADCAST_SMS";
+ case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: return "UNSOL_CDMA_RUIM_SMS_STORAGE_FULL";
+ case RIL_UNSOL_RESTRICTED_STATE_CHANGED: return "UNSOL_RESTRICTED_STATE_CHANGED";
+ case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: return "UNSOL_ENTER_EMERGENCY_CALLBACK_MODE";
+ case RIL_UNSOL_CDMA_CALL_WAITING: return "UNSOL_CDMA_CALL_WAITING";
+ case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS";
+ case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC";
+ case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW";
+ case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE";
+ case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE";
+ case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED";
+ case RIL_UNSOL_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED";
+ case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: return "UNSOL_EXIT_EMERGENCY_CALLBACK_MODE";
+ case RIL_UNSOL_RIL_CONNECTED: return "UNSOL_RIL_CONNECTED";
+ case RIL_UNSOL_VOICE_RADIO_TECH_CHANGED: return "UNSOL_VOICE_RADIO_TECH_CHANGED";
+ case RIL_UNSOL_CELL_INFO_LIST: return "UNSOL_CELL_INFO_LIST";
+ case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED: return "RESPONSE_IMS_NETWORK_STATE_CHANGED";
+ case RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED: return "UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED";
+ case RIL_UNSOL_SRVCC_STATE_NOTIFY: return "UNSOL_SRVCC_STATE_NOTIFY";
+ case RIL_UNSOL_HARDWARE_CONFIG_CHANGED: return "HARDWARE_CONFIG_CHANGED";
+ case RIL_UNSOL_DC_RT_INFO_CHANGED: return "UNSOL_DC_RT_INFO_CHANGED";
+ case RIL_REQUEST_SHUTDOWN: return "SHUTDOWN";
+ case RIL_UNSOL_RADIO_CAPABILITY: return "RIL_UNSOL_RADIO_CAPABILITY";
+ case RIL_REQUEST_SET_TRM: return "RIL_REQUEST_SET_TRM";
+ case RIL_REQUEST_SET_IMS_ENABLE:return "RIL_REQUEST_SET_IMS_ENABLE";
+ case RIL_REQUEST_SET_AUDIO_PATH: return "SET_AUDIO_PATH";
+ case RIL_REQUEST_HANGUP_ALL: return "HANGUP_ALL";
+ case RIL_REQUEST_FORCE_RELEASE_CALL: return "FORCE_RELEASE_CALL";
+ case RIL_REQUEST_EMERGENCY_DIAL: return "RIL_REQUEST_EMERGENCY_DIAL";
+ case RIL_REQUEST_SET_ECC_SERVICE_CATEGORY: return "RIL_REQUEST_SET_ECC_SERVICE_CATEGORY";
+ case RIL_REQUEST_SET_ECC_LIST: return "RIL_REQUEST_SET_ECC_LIST";
+ case RIL_REQUEST_AT_COMMAND_WITH_PROXY: return "AT_COMMAND_WITH_PROXY";
+ case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: return "RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION";
+ case RIL_REQUEST_SET_CLIP: return "RIL_REQUEST_SET_CLIP";
+ case RIL_REQUEST_GET_COLP: return "RIL_REQUEST_GET_COLP";
+ case RIL_REQUEST_SET_COLP: return "RIL_REQUEST_SET_COLP";
+ case RIL_REQUEST_GET_COLR: return "RIL_REQUEST_GET_COLR";
+ case RIL_REQUEST_ADD_IMS_CONFERENCE_CALL_MEMBER: return "ADD_IMS_CONFERENCE_CALL_MEMBER";
+ case RIL_REQUEST_REMOVE_IMS_CONFERENCE_CALL_MEMBER: return "REMOVE_IMS_CONFERENCE_CALL_MEMBER";
+ case RIL_REQUEST_CONFERENCE_DIAL: return "CONFERENCE_DIAL";
+ case RIL_REQUEST_DIAL_WITH_SIP_URI: return "DIAL_WITH_SIP_URI";
+ case RIL_REQUEST_HOLD_CALL: return "HOLD_CALL";
+ case RIL_REQUEST_RESUME_CALL: return "RESUME_CALL";
+ case RIL_UNSOL_ECONF_SRVCC_INDICATION : return "ECONF_SRVCC_INDICATION";
+ case RIL_UNSOL_ECONF_RESULT_INDICATION : return "ECONF_RESULT_INDICATION";
+ case RIL_UNSOL_MAL_AT_INFO : return "UNSOL_MAL_AT_INFO";
+ case RIL_REQUEST_MODEM_POWEROFF: return "MODEM_POWEROFF";
+ case RIL_REQUEST_MODEM_POWERON: return "MODEM_POWERON";
+ case RIL_REQUEST_WRITE_SMS_TO_SIM: return "WRITE_SMS_TO_SIM";
+ case RIL_REQUEST_QUERY_ICCID: return "RIL_REQUEST_QUERY_ICCID";
+ case RIL_UNSOL_TX_POWER: return "RIL_UNSOL_TX_POWER";
+ case RIL_UNSOL_NETWORK_INFO: return "RIL_UNSOL_NETWORK_INFO";
+ case RIL_REQUEST_DELETE_SMS_ON_SIM: return "DELETE_SMS_ON_SIM";
+ case RIL_REQUEST_SET_IMSCFG: return "RIL_REQUEST_SET_IMSCFG";
+#ifdef ECALL_SUPPORT
+ case RIL_REQUEST_ECALL_FAST_MAKE_ECALL: return "ECALL_FAST_MAKE_ECALL";
+ case RIL_REQUEST_ECALL_SET_IVS: return "RIL_REQUEST_ECALL_SET_IVS";
+ case RIL_REQUEST_ECALL_SET_PSAP: return "RIL_REQUEST_ECALL_SET_PSAP";
+ case RIL_REQUEST_ECALL_MAKE_ECALL: return "RIL_REQUEST_ECALL_MAKE_ECALL";
+ case RIL_REQUEST_ECALL_IVS_PUSH_MSD: return "RIL_REQUEST_ECALL_IVS_PUSH_MSD";
+ case RIL_REQUEST_ECALL_PSAP_PULL_MSD: return "RIL_REQUEST_ECALL_PSAP_PULL_MSD";
+ case RIL_UNSOL_ECALL_MSDHACK : return "ECALL_MSDHACK";
+ case RIL_REQUEST_ECALL_SET_MSD: return "RIL_REQUEST_ECALL_SET_MSD";
+ case RIL_REQUEST_ECALL_CTRL_SEQUENCE: return "ECALL_SET_CTRL_SEQUENCE";
+ case RIL_UNSOL_ECALL_INDICATIONS : return "ECALL_INDICATIONS";
+ case RIL_REQUEST_ECALL_RESET_IVS: return "RIL_REQUEST_ECALL_RESET_IVS";
+ case RIL_REQUEST_ECALL_SET_PRI: return "RIL_REQUEST_ECALL_SET_PRI";
+ case RIL_REQUEST_ECALL_SET_TEST_NUM: return "RIL_REQUEST_ECALL_SET_TEST_NUM";
+ case RIL_REQUEST_ECALL_SET_RECONF_NUM: return "RIL_REQUEST_ECALL_SET_RECONF_NUM";
+ case RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD: return "RIL_REQUEST_SYNC_DATA_SETTINGS_TO_MD";
+ case RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME: return "RIL_REQUEST_ECALL_SET_NAD_DEREGISTRATION_TIME";
+ case RIL_REQUEST_ECALL_SET_REGISTRATION_STATE: return "RIL_REQUEST_ECALL_SET_REGISTRATION_STATE";
+#endif /*ECALL_SUPPORT*/
+#ifdef KEEP_ALIVE
+ case RIL_REQUEST_START_KEEPALIVE_PRO: return "RIL_REQUEST_START_KEEPALIVE_PRO";
+ case RIL_REQUEST_STOP_KEEPALIVE_PRO: return "RIL_REQUEST_STOP_KEEPALIVE_PRO";
+ case RIL_UNSOL_KEEPALIVE_STATUS_PRO: return "RIL_UNSOL_KEEPALIVE_STATUS_PRO";
+#endif /*KEEP_ALIVE*/
+ case RIL_REQUEST_SEND_USSI: return "SEND_USSI";
+ case RIL_REQUEST_CANCEL_USSI: return "CANCEL_USSI";
+ case RIL_REQUEST_GET_SMS_SIM_MEM_STATUS: return "GET_SMS_SIM_MEM_STATUS";
+ case RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR: return "RIL_UNSOL_SIP_CALL_PROGRESS_INDICATOR";
+ case RIL_REQUEST_REPORT_AIRPLANE_MODE: return "RIL_REQUEST_REPORT_AIRPLANE_MODE";
+ case RIL_REQUEST_SET_ECC_NUM: return "RIL_REQUEST_SET_ECC_NUM";
+ case RIL_REQUEST_GET_ECC_NUM: return "RIL_REQUEST_GET_ECC_NUM";
+ case RIL_UNSOL_ECC_NUM: return "RIL_UNSOL_ECC_NUM";
+ case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT: return "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS_WITH_ACT";
+ case RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_GET_BROADCAST_LANGUAGE";
+ case RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE: return "RIL_REQUEST_GSM_SET_BROADCAST_LANGUAGE";
+ case RIL_UNSOL_CALL_INFO_INDICATION: return "RIL_UNSOL_CALL_INFO_INDICATION";
+ case RIL_REQUEST_MODIFY_APN: return "RIL_REQUEST_MODIFY_APN";
+ case RIL_REQUEST_RESET_APN: return "RIL_REQUEST_RESET_APN";
+ case RIL_REQUEST_QUERY_SIM_RETRY_COUNT: return "RIL_REQUEST_QUERY_SIM_RETRY_COUNT";
+ case RIL_REQUEST_QUERY_EID: return "RIL_REQUEST_QUERY_EID";
+ case LYNQ_REQUEST_SET_DTMF_VOLUME: return "RIL_REQUEST_SET_DTMF_VOLUME";
+ case LYNQ_REQUEST_SET_SPEECH_VOLUME: return "RIL_REQUEST_SET_SPEECH_VOLUME";
+ case LYNQ_REQUEST_GET_SPEECH_VOLUME: return "RIL_REQUEST_GET_SPEECH_VOLUME";
+ case LYNQ_REQUEST_RECORD: return "RIL_REQUEST_RECORD";
+ /*warren add for t800 ril service 2022/1/22 start*/
+ case LYNQ_REQUEST_WRITE_SMS_TO_MEMORY: return "LYNQ_REQUEST_WRITE_SMS_TO_MEMORY";
+ case LYNQ_REQUEST_READ_SMS_FROM_MEMORY: return "LYNQ_REQUEST_READ_SMS_FROM_MEMORY";
+ case LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY: return "LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY";
+ case LYNQ_REQUEST_LIST_SMS_FROM_MEMORY: return "LYNQ_REQUEST_LIST_SMS_FROM_MEMORY";
+ case LYNQ_REQUEST_SET_DEFAULT_SIM_ALL:return "SET_DEFAULT_SIM_ALL";
+ case LYNQ_REQUEST_CHANGE_SCREEN_STATE:return "LYNQ_REQUEST_CHANGE_SCREEN_STATE";/*jb.qi add for two sim sleep 2022/9/19*/
+ case LYNQ_REQUEST_CHANGE_RADIO:return "LYNQ_REQUEST_CHANGE_RADIO";/*lei add for factory test of sleep 2022/9/19*/
+ case RIL_UNSOL_SIM_STATUS_COMMAND:return "RIL_UNSOL_SIM_STATUS_COMMAND";/*rita add for sim change 2024/3/1*/
+ /*warren add for t800 ril service 2022/1/22 end*/
+ default: return "<unknown request>";
+ }
+}
+
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_module_socket.h b/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_module_socket.h
new file mode 100755
index 0000000..1898ee2
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_module_socket.h
@@ -0,0 +1,35 @@
+#ifndef LYNQ_MODULE_SOCKET_H
+#define LYNQ_MODULE_SOCKET_H
+
+using ::android::Parcel;
+
+
+typedef struct{
+ int resp_type;
+ int token;
+ int request;
+ int slot_id;
+ int error;
+}lynq_resp_t;
+
+
+int lynq_set_test_network(const int test_mode);
+
+extern int g_module_Global_uToken;
+extern int g_wait_time;
+int lynq_send_common_request(Parcel*& p, int time_out, int request_id, int argc, const char* format,...);
+int lynq_start_all_urc_socket_thread();
+void lynq_close_all_urc_socket_thread();
+int lynq_start_all_rc_socket_thread();
+void lynq_close_all_rc_socket_thread();
+
+
+
+
+const char * requestToString(int request);
+
+void urc_msg_process(Parcel *p);
+bool is_support_urc(int urc_id);
+bool is_support_request(int req_id);
+
+#endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sim/src/lynq_sim.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_sim.cpp
similarity index 67%
rename from cap/zx297520v3/src/lynq/lib/liblynq-sim/src/lynq_sim.cpp
rename to cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_sim.cpp
index 75a1d0b..32fdd41 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-sim/src/lynq_sim.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_sim.cpp
@@ -16,6 +16,7 @@
#include <log/log.h>
#include <cutils/jstring.h>
#include <pthread.h>
+#include "liblog/lynq_deflog.h"
#include <vendor-ril/telephony/ril.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -23,15 +24,17 @@
#include <errno.h> /*add for get recvfrom errorid on 20220921*/
#include <sys/stat.h>
#include <fcntl.h>
+#include "lynq_module_common.h"
+#include "lynq_module_socket.h"
#include "lynq_sim.h"
#define MAX_BUF 20
#define MAX_NUM 80
-#define LYNQ_REQUEST_SET_DEFAULT_SIM_ALL 8008
-#define LYNQ_REQUEST_CHANGE_SCREEN_STATE 8014 /*add for two sim suspend on 20220919*/
-#define LYNQ_REQUEST_CHANGE_RADIO 8015
+//#define LYNQ_REQUEST_SET_DEFAULT_SIM_ALL 8008
+//#define LYNQ_REQUEST_CHANGE_SCREEN_STATE 8014 /*add for two sim suspend on 20220919*/
+//#define LYNQ_REQUEST_CHANGE_RADIO 8015
#define MAX_LEN 1024*8
#define MAX_NUM 10
-#define LOG_TAG "LYNQ_SIM"
+#define USER_LOG_TAG "LYNQ_SIM"
#define FLAG_TESS 0
using ::android::Parcel;
#define DEST_PORT 8088
@@ -55,7 +58,7 @@
* 0: deinit state
* 1: init state
*/
-int g_lynq_sim_init_flag = 0;
+//int g_lynq_sim_init_flag = 0;
/**
* @brief lynq_req_sim_io need to send request
@@ -71,17 +74,11 @@
char time_buf[32] = {0};
char message_buf[32] = {0};
-typedef struct{
- int resp_type;
- int token;
- int request;
- int slot_id;
- int error;
-}lynq_resp_t;
+
#define RESULT_OK (0)
#define RESULT_ERROR (-1)
-
+#if 0
typedef enum{
/*base abnormal*/
LYNQ_E_PARAMETER_ANONALY=7000,
@@ -115,7 +112,7 @@
LYNQ_E_ECALL_DAILING_NO_ANSWER =9005,
#endif
}LYNQ_E;
-
+#endif
/**@brief print solicied response msg's head information
* @param head [IN]: head information
* @return none
@@ -125,6 +122,7 @@
RLOGD("resp_type=%d,token=%d,request=%d,slot_id=%d,error_code=%d",head.resp_type,head.token,head.request,head.slot_id,head.error);
}
+
int GetHeader(Parcel* &p, lynq_resp_t& head, int request_id)
{
RLOGD("get header");
@@ -145,6 +143,8 @@
}
}
+
+#if 0
int lynq_send_common_request(Parcel* p, int request_id, int argc, int cnt, const char* format,...)
{
lynq_client_t client;
@@ -212,13 +212,129 @@
return ret;
}
+#endif
+
+
+static pthread_mutex_t s_sim_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t s_sim_state_change_cond = PTHREAD_COND_INITIALIZER;
+
+int g_module_init_flag = 0;
+
+void wait_sim_state()
+{
+ LYINFLOG("sim state changed");
+ printf("sim state changed");
+ pthread_mutex_lock(&s_sim_state_change_mutex);
+ pthread_cond_wait(&s_sim_state_change_cond,&s_sim_state_change_mutex);
+ pthread_mutex_unlock(&s_sim_state_change_mutex);
+}
+
+
+void send_sim_state_change()
+{
+ LYINFLOG("send sim state change");
+ pthread_mutex_lock(&s_sim_state_change_mutex);
+ pthread_cond_signal(&s_sim_state_change_cond);
+ pthread_mutex_unlock(&s_sim_state_change_mutex);
+}
+
+int lynq_wait_sim_state_change(int *handle)
+{
+ if(g_module_init_flag != MODULE_RUNNING)
+ {
+
+ printf("%s module state %d error",__func__,g_module_init_flag);
+ LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
+ return LYNQ_E_CONFLICT;
+ }
+ wait_sim_state();
+ LYINFLOG("lynq sim state change\n");
+ printf("lynq sim state change\n");
+ return RESULT_OK;
+}
+
+bool is_support_urc(int urc_id)
+{
+ switch(urc_id)
+ {
+ case RIL_UNSOL_SIM_STATUS_COMMAND:
+ return true;
+ default:
+ return false;
+ }
+}
+
+void urc_msg_process(Parcel *p)
+{
+ int resp_type;
+ int urcid;
+ int slot_id;
+
+ int size=p->dataSize();
+ p->readInt32(&resp_type);
+ p->readInt32(&urcid);
+ p->readInt32(&slot_id);
+ LYINFLOG("%s urc id = %d, slot_id = %d, size is %d, msg is %s",__func__, urcid,slot_id,size,requestToString(urcid));
+ switch (urcid)
+ {
+ case RIL_UNSOL_SIM_STATUS_COMMAND://sim changed
+ {
+ LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);
+ send_sim_state_change();
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+#if 1
+int lynq_sim_init(int utoken)
+{
+ if(g_module_init_flag != MODULE_CLOSED)
+ {
+ LYERRLOG("module state is %d",g_module_init_flag);
+ return LYNQ_E_CONFLICT;
+ }
+ if(utoken <0){
+ LYERRLOG("uToken is less than 0",utoken);
+ return LYNQ_E_PARAMETER_ANONALY;
+ }
+ g_module_init_flag = MODULE_SWITCHING;
+
+ LYLOGSET(LOG_INFO);
+ LYLOGEINIT(USER_LOG_TAG);
+
+ g_module_Global_uToken = utoken;
+
+ int ret = lynq_start_all_urc_socket_thread();
+ if(ret != RESULT_OK)
+ {
+ LYERRLOG("init socket urc fail!!!");
+ g_module_init_flag = MODULE_CLOSED;
+ return LYNQ_E_INNER_ERROR;
+ }
+
+ ret = lynq_start_all_rc_socket_thread();
+ if(ret !=RESULT_OK)
+ {
+ LYERRLOG("init socket client fail!!!");
+ lynq_close_all_urc_socket_thread();
+ g_module_init_flag = MODULE_CLOSED;
+ return LYNQ_E_INNER_ERROR;
+ }
+ g_module_init_flag = MODULE_RUNNING;
+ return RESULT_OK;
+}
+
+#else
int lynq_sim_init(int utoken){
- if(g_lynq_sim_init_flag == 1)
+ if(g_module_init_flag == 1)
{
RLOGD("lynq_sim_init failed");
return -1;
}
- g_lynq_sim_init_flag = 1;
+ g_module_init_flag = 1;
if(utoken < 0){
return -1;
}
@@ -246,17 +362,57 @@
return 0;
}
+#endif
+
+int lynq_sim_deinit(void)
+{
+ if (g_module_init_flag != MODULE_RUNNING)
+ {
+ LYERRLOG("module state is %d",g_module_init_flag);
+ return LYNQ_E_CONFLICT;
+ }
+ g_module_init_flag = MODULE_SWITCHING;
+ lynq_close_all_urc_socket_thread();
+ lynq_close_all_rc_socket_thread();
+ g_module_init_flag = MODULE_CLOSED;
+ return RESULT_OK;
+}
+
+
+int lynq_read_sim_status(int handle, int *card_status)
+{
+ if(g_module_init_flag != MODULE_RUNNING)
+ {
+ LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
+ printf("1111111111\n");
+ return LYNQ_E_CONFLICT;
+ }
+ Parcel *p=NULL;
+ //RIL_UNSOL_SIM_STATUS_COMMAND
+ int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_GET_SIM_STATUS,0,"");
+ if(ret!=0)
+ {
+ return ret;
+ }
+ LYDBGLOG("RIL_UNSOL_SIM_STATUS_COMMAND SUCCESS!");
+
+ p->readInt32(card_status);
+ delete p;
+ return RESULT_OK;
+}
+
+#if 0
int lynq_sim_deinit(void){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
RLOGD("lynq_sim_deinit failed");
return -1;
}
- g_lynq_sim_init_flag = 0;
+ g_module_init_flag = 0;
close(sock_fd);
return 0;
}
-
+#endif
static char * lynqStrdupReadString(Parcel &p) {
size_t stringlen;
const char16_t *s16;
@@ -268,35 +424,39 @@
/*If you need to use any API under lynq_sim, you mustfirst call the lynq_sim_init() function to initialize these functions.*/
int lynq_get_sim_status(int *card_status)
{
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_GET_SIM_STATUS,0,1,"");
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_GET_SIM_STATUS,0,1,"");
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_GET_SIM_STATUS,0,"");
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
return res;
}
- p.readInt32(card_status);
+ p->readInt32(card_status);
return res;
}
int lynq_get_imsi(char buf[])
{
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_GET_IMSI,0,1,"");
+ Parcel *p;
+ // int res = lynq_send_common_request(&p,RIL_REQUEST_GET_IMSI,0,1,"");
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_GET_IMSI,0,"");
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
return res;
}
- char * test = lynqStrdupReadString(p);
+ char * test = lynqStrdupReadString(*p);
memcpy(buf, test, strlen(test));
free(test);
return res;
@@ -306,30 +466,33 @@
/*add by lei*/
int lynq_get_iccid(char buf[]){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_QUERY_ICCID,0,1,"");
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_QUERY_ICCID,0,1,"");
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_QUERY_ICCID,0,"");
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
return res;
}
- char * test = lynqStrdupReadString(p);
+ char * test = lynqStrdupReadString(*p);
memcpy(buf, test, strlen(test));
free(test);
return res;
}
int lynq_enable_pin(char *pin){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_SET_FACILITY_LOCK,4,1,"%s %s %s %s\n", "SC", pin, "11", "1");
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_SET_FACILITY_LOCK,4,1,"%s %s %s %s\n", "SC", pin, "11", "1");
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SET_FACILITY_LOCK,4,"%s %s %s %s", "SC", pin, "11", "1");
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
@@ -341,12 +504,14 @@
#ifdef MOBILETEK_TARGET_PLATFORM_T106
int lynq_reset_sim(void)
{
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_RESET_SIMCARD,0,1,"");
+ Parcel *p;
+ // int res = lynq_send_common_request(&p,RIL_REQUEST_RESET_SIMCARD,0,1,"");
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_RESET_SIMCARD,0,"");
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
@@ -357,12 +522,14 @@
#else
int lynq_sim_power(int mode)
{
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_OEM_HOOK_RAW,1,1,"%s%d", "AT+ESIMPOWER=", mode);
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_OEM_HOOK_RAW,1,1,"%s%d", "AT+ESIMPOWER=", mode);
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_OEM_HOOK_RAW,2,"%s %d", "AT+ESIMPOWER=", mode);
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
@@ -373,12 +540,14 @@
#endif
int lynq_disable_pin(char *pin){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_SET_FACILITY_LOCK,4,1,"%s %s %s %s\n", "SC", pin, "11", "0");
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_SET_FACILITY_LOCK,4,1,"%s %s %s %s\n", "SC", pin, "11", "0");
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SET_FACILITY_LOCK,4,"%s %s %s %s", "SC", pin, "11", "0");
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
@@ -388,24 +557,26 @@
}
int lynq_query_pin_lock(char *pin,int buf[]){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_QUERY_FACILITY_LOCK,3,1,"%s %s %s\n", "SC", pin, "11");
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_QUERY_FACILITY_LOCK,3,1,"%s %s %s\n", "SC", pin, "11");
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_QUERY_FACILITY_LOCK,3,"%s %s %s", "SC", pin, "11");
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
return res;
}
int num = -1;
- p.readInt32(&num);
+ p->readInt32(&num);
if(num > 0)
{
int *test = (int *)calloc(num, sizeof(int));
for(int i =0; i <num; i++){
- p.readInt32(&test[i]);
+ p->readInt32(&test[i]);
buf[i] = test[i];
}
free(test);
@@ -414,12 +585,14 @@
}
int lynq_verify_pin(char *pin){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_ENTER_SIM_PIN,1,1,"%s\n", pin);
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_ENTER_SIM_PIN,1,1,"%s\n", pin);
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ENTER_SIM_PIN,1,"%s", pin);
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
@@ -429,7 +602,7 @@
}
int lynq_change_pin(char *old_pin, char *new_pin){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
@@ -440,8 +613,10 @@
return res;
if(!strlen(old_pin))
return res;
- Parcel p;
- res = lynq_send_common_request(&p,RIL_REQUEST_CHANGE_SIM_PIN,2,1,"%s %s\n", old_pin, new_pin);
+ Parcel *p;
+ //res = lynq_send_common_request(&p,RIL_REQUEST_CHANGE_SIM_PIN,2,1,"%s %s\n", old_pin, new_pin);
+
+ int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_CHANGE_SIM_PIN,2,"%s %s", old_pin, new_pin);
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
@@ -451,7 +626,7 @@
}
int lynq_unlock_pin(char *puk, char *pin){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
@@ -461,8 +636,10 @@
if(strlen(puk) < 4 || strlen(pin) < 4){
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_ENTER_SIM_PUK,2,1,"%s %s\n", puk, pin);
+ Parcel *p;
+ // int res = lynq_send_common_request(&p,RIL_REQUEST_ENTER_SIM_PUK,2,1,"%s %s\n", puk, pin);
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ENTER_SIM_PUK,2,"%s %s", puk, pin);
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
@@ -534,31 +711,33 @@
}
#ifdef MOBILETEK_TARGET_PLATFORM_T106
int lynq_query_phone_number(char buf[]){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_GET_MSISDN,0,1,"");
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_GET_MSISDN,0,1,"");
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_GET_MSISDN,0,"");
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
return res;
}
- char * test = lynqStrdupReadString(p);
+ char * test = lynqStrdupReadString(*p);
memcpy(buf, test, strlen(test));
return res;
}
#else
int lynq_query_phone_number(char buf[]){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_OEM_HOOK_RAW,1,1,"%s\n", "AT+CNUM");
+ Parcel *p;
+ // int res = lynq_send_common_request(&p,RIL_REQUEST_OEM_HOOK_RAW,1,1,"%s\n", "AT+CNUM");
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_OEM_HOOK_RAW,1,"%s", "AT+CNUM");
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
@@ -580,20 +759,22 @@
int lynq_get_imei(char buf[])
{
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_DEVICE_IDENTITY,0,1,"");
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_DEVICE_IDENTITY,0,1,"");
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_DEVICE_IDENTITY,0,"");
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
return res;
}
int num = 0;
- p.readInt32(&num);
- char * test = lynqStrdupReadString(p);
+ p->readInt32(&num);
+ char * test = lynqStrdupReadString(*p);
memcpy(buf, test, strlen(test));
free(test);
return res;
@@ -601,19 +782,21 @@
int lynq_get_imei_and_sv(char imei[],char sv[])
{
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_DEVICE_IDENTITY,0,1,"");
+ Parcel *p;
+ // int res = lynq_send_common_request(&p,RIL_REQUEST_DEVICE_IDENTITY,0,1,"");
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_DEVICE_IDENTITY,0,"");
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
return res;
}
int num = 0;
- p.readInt32(&num);
+ p->readInt32(&num);
if(num<2)
{
RLOGD("%s num %d error, should greater than 1",__func__,num);
@@ -623,7 +806,7 @@
int i;
for(i=0;i<2;i++)
{
- resp[i]= lynqStrdupReadString(p);
+ resp[i]= lynqStrdupReadString(*p);
if(resp[i]==NULL)
{
break;
@@ -659,7 +842,7 @@
}
int lynq_switch_card(int slot){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
@@ -687,14 +870,16 @@
*return int
*/
int lynq_screen(int num){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
if(!judge(num))
return -1;
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_SCREEN_STATE,1,2,"%d\n",num);
+ Parcel *p;
+ // int res = lynq_send_common_request(&p,RIL_REQUEST_SCREEN_STATE,1,2,"%d\n",num);
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SCREEN_STATE,1,"%d", num);
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
@@ -709,14 +894,16 @@
*return int
*/
int lynq_factory_radio_state(int num){
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
if(!judge(num))
return -1;
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_RADIO_POWER,1,2,"%d\n",num);
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_RADIO_POWER,1,2,"%d\n",num);
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_RADIO_POWER,1,"%d", num);
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
@@ -790,7 +977,7 @@
int lynq_req_sim_io(int list[5], char *path, char *data, char *pin2, char *aidPtr, int sw[2], char *simResponse)
{
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
@@ -798,16 +985,17 @@
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_SIM_IO,9,1,"%d %d %s %d %d %d %s %s %s\n", list[0], list[1], path, list[2], list[3], list[4], data_buf, pin2_buf, aidPtr_buf);
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_SIM_IO,9,1,"%d %d %s %d %d %d %s %s %s\n", list[0], list[1], path, list[2], list[3], list[4], data_buf, pin2_buf, aidPtr_buf);
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SIM_IO,9,"%d %d %s %d %d %d %s %s %s", list[0], list[1], path, list[2], list[3], list[4], data_buf, pin2_buf, aidPtr_buf);
if(res != 0)
{
RLOGD("function %s execute error", __FUNCTION__);
return res;
}
- p.readInt32(&sw[0]);
- p.readInt32(&sw[1]);
- char * test = lynqStrdupReadString(p);
+ p->readInt32(&sw[0]);
+ p->readInt32(&sw[1]);
+ char * test = lynqStrdupReadString(*p);
memcpy(simResponse, test, strlen(test));
free(test);
return res;
@@ -834,13 +1022,15 @@
int lynq_reset_modem(void)
{
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
- Parcel p;
- int res = lynq_send_common_request(&p,RIL_REQUEST_RESET_RADIO,0,1,"");
+ Parcel *p;
+ //int res = lynq_send_common_request(&p,RIL_REQUEST_RESET_RADIO,0,1,"");
+
+ int res=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_RESET_RADIO,0,"");
if(res != 0)
{
@@ -855,7 +1045,7 @@
#else
int lynq_reset_modem(void)
{
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
@@ -930,7 +1120,7 @@
{
FILE * fp;
char buffer[128];
- if(g_lynq_sim_init_flag == 0)
+ if(g_module_init_flag == 0)
{
return -1;
}
@@ -961,3 +1151,5 @@
return 0;
}
+DEFINE_LYNQ_LIB_LOG(LYNQ_SIM)
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sim/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-sim/makefile
index 219bda7..171052a 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-sim/makefile
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sim/makefile
@@ -23,6 +23,7 @@
LOCAL_C_INCLUDES = \
-I. \
-I$(LOCAL_PATH)/include \
+ -I$(LOCAL_PATH)/include/libsim \
-I$(ROOT)$(includedir)/vendor-ril \
-I$(ROOT)$(includedir)/logger \
-I$(ROOT)$(includedir)/liblog \
@@ -41,7 +42,7 @@
-llynq-log \
-llynq-shm \
-SOURCES = $(wildcard *.c wildcard *.h src/*.cpp)
+SOURCES = $(wildcard *.cpp)
EXECUTABLE = liblynq-sim.so