[Feature][ZXW-11][ZXW-12]support liblynq-network and liblynq-sms

Change-Id: Iae64d4f11c4b0932460501f934a3099c92416f26
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf
index 7e27354..0ef3377 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf
+++ b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc.conf
@@ -132,13 +132,17 @@
 	libvoice \
 	libmedia \
 	libdebug-info \
+	libbinder \
+	libril \
         liblynq-uci \
         liblynq-shm \
         liblynq-log \
         libapn \
         libpal \
         libvendor-ril \
-        liblynq-call \	
+        liblynq-call \
+        liblynq-network \
+        liblynq-sms \	
 	"
 zxic_lib += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'RIL', 'libbinder libril', 'libtelsvr', d)}"
 
@@ -175,6 +179,7 @@
 	ethtest \
 	sc-at-test \
 	dialtest \
+	rild \
 	sc-nw-mgr-test \
         lynq-ril-service \
         uci \
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-network/liblynq-network.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-network/liblynq-network.bb
new file mode 100755
index 0000000..c7f55bc
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-network/liblynq-network.bb
@@ -0,0 +1,60 @@
+inherit externalsrc package

+

+DESCRIPTION = "liblynq-network.so"

+LICENSE = "MobileTekProprietary"

+LIC_FILES_CHKSUM = "file://LICENSE;md5=b1e07e8d88e26263e71d3a9e2aa9a2ff"

+DEPENDS += "libpal liblynq-log libvendor-ril liblynq-shm"

+inherit workonsrc

+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-network/"

+

+TARGET_CC_ARCH += "${LDFLAGS}"

+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"

+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"

+#Parameters passed to do_compile()

+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\

+                'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\

+                'TARGET_PLATFORM = ${TARGET_PLATFORM}'"

+

+FILES_${PN} = "${base_libdir}/*.so "

+FILES_${PN} += "/data/ril/network"

+

+FILES_${PN}-dev = "/test \

+                   ${includedir}"

+

+FILES_${PN}-doc = "/doc"

+

+FILES_${PN}-dbg ="${base_bindir}/.debug \

+                  ${base_libdir}/.debug \

+                  ${base_sbindir}/.debug"

+

+INSANE_SKIP_${PN} += "already-stripped"

+INSANE_SKIP_${PN} += "installed-vs-shipped"

+

+

+#INHIBIT_PACKAGE_STRIP = "1"

+do_compile () {

+	if [ "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" ]; then

+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"

+	elif [ "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4" ]; then

+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"

+	elif [ "${PACKAGE_ARCH}" = "cortexa53hf-neon-fp-armv8" ]; then

+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE -mhard-float -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 -mtune=cortex-a53"

+	else

+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"

+	fi

+}

+

+do_install () {

+    oe_runmake install ROOT=${D}

+	

+    if [ -d "${WORKONSRC}" ] ; then

+        install -d ${D}${includedir}/lynq_network

+        cp -arf ${S}/include/lynq_network ${D}${includedir}/lynq_network	

+        install -d ${D}/data/ril/network		

+    fi 

+}

+

+addtask bachclean

+do_bachclean () {

+    oe_runmake clean

+}

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-sms/liblynq-sms.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-sms/liblynq-sms.bb
new file mode 100755
index 0000000..2161303
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-sms/liblynq-sms.bb
@@ -0,0 +1,58 @@
+inherit externalsrc package
+
+DESCRIPTION = "liblynq-uci.so demo"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "libpal liblynq-log libvendor-ril liblynq-shm"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-sms/"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+                'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+                'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+FILES_${PN} = "${base_libdir}/*.so "
+
+FILES_${PN}-dev = "/test \
+                   ${includedir}"
+
+FILES_${PN}-doc = "/doc"
+
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+                  ${base_libdir}/.debug \
+                  ${base_sbindir}/.debug"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+	if [ "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" ]; then
+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+	elif [ "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4" ]; then
+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+	elif [ "${PACKAGE_ARCH}" = "cortexa53hf-neon-fp-armv8" ]; then
+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE -mhard-float -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 -mtune=cortex-a53"
+	else
+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"
+	fi
+}
+
+do_install () {
+    oe_runmake install ROOT=${D}
+	
+    if [ -d "${WORKONSRC}" ] ; then
+        install -d ${D}${includedir}/
+        cp -af ${S}/include/libsms ${D}${includedir}/
+    fi 
+}
+
+addtask bachclean
+do_bachclean () {
+    oe_runmake clean
+}
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/mobiletek-tester-rdit/mobiletek-tester-rdit.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/mobiletek-tester-rdit/mobiletek-tester-rdit.bb
index 90b3164..c6ae48a 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/mobiletek-tester-rdit/mobiletek-tester-rdit.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/mobiletek-tester-rdit/mobiletek-tester-rdit.bb
@@ -4,7 +4,7 @@
 LICENSE = "MobileTekProprietary"
 LICENSE = "CLOSED"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=b1e07e8d88e26263e71d3a9e2aa9a2ff"
-DEPENDS += "liblynq-call"
+DEPENDS += "liblynq-call liblynq-sms liblynq-network"
 inherit workonsrc
 WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/Mobiletek_Tester_RDIT"
 
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/packagegroups/packagegroup-lynq-t106.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/packagegroups/packagegroup-lynq-t106.bb
index 916dab9..f647e4e 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/packagegroups/packagegroup-lynq-t106.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/packagegroups/packagegroup-lynq-t106.bb
@@ -8,5 +8,8 @@
     liblynq-log \
     liblynq-uci \
     liblynq-shm \
+    liblynq-call \
+    liblynq-network \
+    liblynq-sms \
     "
 
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-network/LICENSE b/cap/zx297520v3/src/lynq/lib/liblynq-network/LICENSE
new file mode 100755
index 0000000..605b7ea
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MobileTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MobileTek Inc. and/or its licensors. Without
+the prior written permission of MobileTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MobileTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MobileTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MobileTek SOFTWARE")
+RECEIVED FROM MobileTek AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MobileTek EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MobileTek PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MobileTek SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MobileTek
+SOFTWARE. MobileTek SHALL ALSO NOT BE RESPONSIBLE FOR ANY MobileTek SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MobileTek'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MobileTek SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MobileTek'S OPTION, TO REVISE OR REPLACE THE
+MobileTek SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MobileTek FOR SUCH MobileTek SOFTWARE AT ISSUE.
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-network/include/lynq_network/lynq_network.h b/cap/zx297520v3/src/lynq/lib/liblynq-network/include/lynq_network/lynq_network.h
new file mode 100755
index 0000000..ba7c1f4
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/include/lynq_network/lynq_network.h
@@ -0,0 +1,130 @@
+#ifndef LYNQ_NETWORK_H

+#define LYNQ_NETWORK_H 

+#ifdef __cplusplus

+extern "C" {

+#endif

+#define MODEM_GEN97 1

+#define CELLINFO_MAX_NUM  10

+#define LY_RECOVER_TIMER_INTERVAL 128

+/*T800 platform support gsm,wcdma lte,nr */

+typedef struct{

+    int gw_sig_valid; /*1 valid,1 invalid*/

+    int rssi;         /* Valid values are (0-31, 99) as defined in TS 27.007 8.5 */

+    int wcdma_sig_valid;/*1 valid,0 invalid*/

+    int rscp;        /* The Received Signal Code Power in dBm multipled by -1.

+                      * Range : 25 to 120

+                      * INT_MAX: 0x7FFFFFFF denotes invalid value.

+                      * Reference: 3GPP TS 25.123, section 9.1.1.1 */

+    int ecno;        /* Valid values are positive integers.  This value is the actual Ec/Io multiplied

+                      * by -10.  Example: If the actual Ec/Io is -12.5 dB, then this response value

+                      * will be 125.*/

+    int lte_sig_valid;/*1 valid,0 invalid*/

+    int rsrp;        /* The current Reference Signal Receive Power in dBm multipled by -1.

+                      * Range: 44 to 140 dBm

+                      * INT_MAX: 0x7FFFFFFF denotes invalid value.

+                      * Reference: 3GPP TS 36.133 9.1.4 */

+    int rsrq;        /* The current Reference Signal Receive Quality in dB multiplied by -1.

+                      * Range: 20 to 3 dB.

+                      * INT_MAX: 0x7FFFFFFF denotes invalid value.

+                      * Reference: 3GPP TS 36.133 9.1.7 */

+    int rssnr;       /* The current reference signal signal-to-noise ratio in 0.1 dB units.

+                      * Range: -200 to +300 (-200 = -20.0 dB, +300 = 30dB).

+                      * INT_MAX : 0x7FFFFFFF denotes invalid value.

+                      * Reference: 3GPP TS 36.101 8.1.1 */

+    int nr_sig_valid;/*1 valid,0 invalid*/

+    int ssRsrp;      /* SS(Synchronization Signal) reference signal received power, multipled by -1.

+                      * Reference: 3GPP TS 38.215.

+                      * Range [44, 140], INT_MAX means invalid/unreported.*/

+    int ssRsrq;      /* SS reference signal received quality, multipled by -1.

+                      * Reference: 3GPP TS 38.215.

+                      * Range [3, 20], INT_MAX means invalid/unreported.*/

+    int ssSinr;      /* SS signal-to-noise and interference ratio.

+                      * Reference: 3GPP TS 38.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1.

+                      * Range [-23, 40], INT_MAX means invalid/unreported.*/

+    int csiRsrp;     /* CSI reference signal received power, multipled by -1.

+                      * Reference: 3GPP TS 38.215.

+                      * Range [44, 140], INT_MAX means invalid/unreported.*/

+    int csiRsrq;     /* CSI reference signal received quality, multipled by -1.

+                      * Reference: 3GPP TS 38.215.

+                      * Range [3, 20], INT_MAX means invalid/unreported.*/

+    int csiSinr;     /* CSI signal-to-noise and interference ratio.

+                      * Reference: 3GPP TS 138.215 section 5.1.*, 3GPP TS 38.133 section 10.1.16.1.

+                      * Range [-23, 40], INT_MAX means invalid/unreported.*/

+}signalStrength_t;

+

+typedef enum { 

+    NETWORK_RADIO_ON_TYPE_CFUN_0=0,  

+    NETWORK_RADIO_ON_TYPE_NORMAL_MODE=1,

+    NETWORK_RADIO_ON_TYPE_FLIGHT_MODE=4,

+}lynq_network_radio_on_type;  

+

+int lynq_network_init(int utoken);

+int lynq_network_deinit(void);

+int lynq_query_operater(char *OperatorFN,char *OperatorSH,char *MccMnc);

+int lynq_query_network_selection_mode(int *netselMode);

+int lynq_set_network_selection_mode(const char *mode,const char* mccmnc);

+int lynq_query_available_network(char *OperatorFN,char *OperatorSH,char *MccMnc,char * NetStatus);

+int lynq_query_registration_state(const char *type,int* regState,int* imsRegState,char * LAC,char * CID,int *netType,int *radioTechFam,int *netRejected);

+int lynq_query_prefferred_networktype(int *preNetType);

+int lynq_set_prefferred_networktype(const int preffertype);

+int lynq_query_cell_info(uint64_t cellinfo[CELLINFO_MAX_NUM],int tac[CELLINFO_MAX_NUM],int earfcn[CELLINFO_MAX_NUM],int * realNum);

+int lynq_set_unsol_cell_info_listrate(const int rate);

+int lynq_set_band_mode(const int bandmode);

+int lynq_query_available_bandmode(int availBanMode[]);

+int lynq_radio_on(const lynq_network_radio_on_type type);

+int lynq_query_radio_state(int *radio_state);

+int lynq_query_radio_tech(int* radioTech);

+int lynq_solicited_signal_strength(signalStrength_t *solSigStren);

+int lynq_set_ims(const int ims_mode);

+int lynq_wait_signalchanges(int *handle);

+int lynq_get_urc_info(const int handle,signalStrength_t *solSigStren,int *slot_id);

+

+typedef enum {

+    NETWORK_STATE_BUFFER_TYPE_VOICE_REG,

+    NETWORK_STATE_BUFFER_TYPE_DATA_REG,

+    NETWORK_STATE_BUFFER_TYPE_IMS_REG,

+    NETWORK_STATE_BUFFER_TYPE_MAX,

+}lynq_network_state_buffer_type;    

+int lynq_set_state_buffer_valid_period_of_network(lynq_network_state_buffer_type type,int valid_period);

+int lynq_get_state_buffer_valid_period_of_network(lynq_network_state_buffer_type type);

+#ifdef MODEM_GEN97

+/**@brief set or get OOS recover timer interval

+* @param mode [IN] <mode>:

+*  0:set

+*  1:get

+* @param interval [IN] <interval>: the recovery timer interval.

+*  field:

+*    T1,T2,...,T23:integer value 0~0xFFFFFFFF

+*    The length of time in seconds.

+*    defualt interval: 20,20,60,60,60,60,90,90,90,90,90,90,180,180,180,180,180,180,360,360,360,360,360

+* @param result [OUT] <result>: the recovery timer interval,when the mode is 1, this parameter is valid.

+

+* @return

+*  0:success

+*  other:failure

+*/

+int lynq_oos_recover_timer_interval(int mode, char interval[LY_RECOVER_TIMER_INTERVAL],char result[LY_RECOVER_TIMER_INTERVAL]);

+/**@brief set deep sleep recover timer interval

+

+* @param recovery_threshold [IN] <recovery_threshold>: valid range 2-10  //After performing several rounds of normal recovery, deep sleep mode optimization will be applied

+

+* @param fullband_timer [IN] <fullband_timer>:valid range 90-360 //fullband intervarl length in deep sleep mode

+

+* @param sniffer_timer [IN] <sniffer_timer>:valid range 10-60 // sniffe intervarl length in deep sleep mode.

+

+* @param inactive_mode [IN] <inactive_mode>:

+*  0 Exit inactive mode 

+*  1 enter inactive mode

+

+* @return

+*  0:success

+*  other:failure

+*/

+int lynq_oos_deep_sleep_recover_timer_interval(int recovery_threshold,int fullband_timer,int sniffer_timer,int inactive_mode);

+#endif

+void lynq_set_test_mode(const int test_mode);

+#ifdef __cplusplus

+}

+#endif

+

+#endif

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_common.h b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_common.h
new file mode 100755
index 0000000..57ea5b2
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_common.h
@@ -0,0 +1,68 @@
+#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,   

+}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-network/lynq_module_socket.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_socket.cpp
new file mode 100755
index 0000000..c3f7334
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_socket.cpp
@@ -0,0 +1,1015 @@
+#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_network.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_NETWORK"

+

+typedef struct{

+    int uToken;

+    int request;

+    int paramLen;

+    char param[LYNQ_REQUEST_PARAM_BUF];

+}lynq_client_t;

+

+typedef struct{

+    int resp_type;

+    int token;

+    int request;

+    int slot_id;

+    int error;

+}lynq_resp_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",__func__,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",__func__,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",__func__);

+                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",__func__,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",__func__,waitToken,time_out);

+            break;

+        }        

+    }

+waitResponse_end:

+    LYINFLOG("%s wait token is %d wakeup_token is %d, cnt is %d",__func__,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 PrintHeader(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 GetHeader(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));

+        PrintHeader(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=GetHeader(p,head);

+        if(ret!=0)

+        {

+            LYERRLOG("%s %d get head error %d",__func__,client.uToken,ret);

+            delete p;

+            return LYNQ_E_GET_HEAD_ERROR;

+        }

+        if(head.error!=0)

+        {

+            LYERRLOG("%s %d mdm return head error %d",__func__,client.uToken,head.error);

+            delete p;

+            return head.error;

+        }

+        LYERRLOG("%s %d suc",__func__,client.uToken);

+        return RESULT_OK;  

+    }

+

+    LYERRLOG("%s %d fail, ret is %d",__func__,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;

+    uint8_t * shm_buffer;

+   

+    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;

+        }

+

+        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;

+        }        

+        if(urc_data_is_in_shm_data(phead->resp_type,level,index,size))

+        {

+            shm_buffer = (uint8_t *) get_shem_buffer(level,index);

+            LYINFLOG("shm pointer is %p", shm_buffer); 

+            urc_p->setData(shm_buffer,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();

+        }

+        else 

+        {

+            delete urc_p;

+            urc_p = NULL;

+        }        

+    }

+    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())

+        {

+            BLOCK_WAIT_PROCESS_URC_MSG();

+        }  

+        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)

+        {          

+            pthread_mutex_lock(&s_urc_mutex);

+            urc_msg_process(urc_p);            

+            pthread_mutex_unlock(&s_urc_mutex);

+        }

+        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("call 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();    

+}

+

+/**@ 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; 

+ 

+    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",__func__, 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",__func__, 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); 

+                BLOCK_RECV_MSG_LOCK();

+                s_recv_parcel_list.push_back(rc_p);                

+                LYINFLOG("%s wakeup token is %d, list size is %d!",__func__,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!",__func__,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",__func__, 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*/

+        /*warren add for t800 ril service 2022/1/22 end*/

+        default: return "<unknown request>";

+    }

+}

+

+

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_socket.h b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_socket.h
new file mode 100755
index 0000000..98f968e
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_socket.h
@@ -0,0 +1,22 @@
+#ifndef LYNQ_MODULE_SOCKET_H

+#define LYNQ_MODULE_SOCKET_H 

+

+using ::android::Parcel;

+

+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);

+

+#endif

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_state_buffer.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_state_buffer.cpp
new file mode 100755
index 0000000..1d0b5af
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_state_buffer.cpp
@@ -0,0 +1,387 @@
+#include <stdio.h>

+#include <stdint.h>  /*just for uint64_t in lynq_query_cell_info 20220819 hq*/

+#include <sys/types.h>

+#include <string.h>

+#include <unistd.h>

+#include <pthread.h>

+#include <signal.h>

+#include <errno.h>
+#include <fcntl.h>

+#include <stdarg.h>

+#include <climits>

+#include "liblog/lynq_deflog.h"

+#include "lynq_network.h"

+#include "lynq_module_common.h"

+#include "lynq_module_state_buffer.h"

+

+#define USER_LOG_TAG "LYNQ_NETWORK"

+

+static timer_t s_state_buffer_timer[NETWORK_STATE_BUFFER_TYPE_MAX];

+

+static int s_state_buffer_sig_value[NETWORK_STATE_BUFFER_TYPE_MAX]={2,3,4};

+

+static int s_state_buffer_valid[NETWORK_STATE_BUFFER_TYPE_MAX]={false,false,false};

+

+static char* s_state_buffer_file[NETWORK_STATE_BUFFER_TYPE_MAX]={

+     "/data/ril/network/.network_register_voice_buffer",

+     "/data/ril/network/.network_register_data_buffer",

+     "/data/ril/network/.network_register_ims_buffer"

+};

+

+#define STATE_BUFFER_CONFIG_FILE  "/data/ril/network/.state_buffer_cfg"

+typedef struct{

+    int valid_period[NETWORK_STATE_BUFFER_TYPE_MAX];   

+}network_state_buffer_cfg;

+static network_state_buffer_cfg s_state_buffer_cfg;

+static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;

+

+void get_state_buffer_timer_length_from_file()

+{

+    int fd_backup;

+    int ret;

+    memset(&s_state_buffer_cfg,0,sizeof (s_state_buffer_cfg));

+    fd_backup = open(STATE_BUFFER_CONFIG_FILE,O_RDONLY | O_CREAT,0777);

+    if (fd_backup < 0) {

+        LYERRLOG("%s open file faile, error is %s\n",__func__,strerror(errno));       

+        return;

+    }

+      

+    ret = read(fd_backup,&s_state_buffer_cfg,sizeof (s_state_buffer_cfg));

+    if(ret<=0)

+    {

+        LYERRLOG("%s read fail, ret is %d",__func__,ret);

+        memset(&s_state_buffer_cfg,0,sizeof (s_state_buffer_cfg));

+    } 

+    else 

+    {

+        LYINFLOG("%s suc",__func__);  

+    }    

+    close(fd_backup);   

+   

+    return;   

+}

+

+int set_state_buffer_timer_length_to_file()

+{

+    int fd_backup;

+    int ret;

+    fd_backup = open(STATE_BUFFER_CONFIG_FILE,O_WRONLY | O_CREAT,0777);

+    if (fd_backup < 0) {

+        LYERRLOG("%s open file fail, error is %s\n",__func__,strerror(errno));       

+        return -1;

+    }

+      

+    ret = write(fd_backup,&s_state_buffer_cfg,sizeof (s_state_buffer_cfg));

+    if(ret<=0)

+    {

+        LYERRLOG("%s write fail, ret is %d",__func__,ret);         

+    } 

+    else 

+    {

+        LYINFLOG("%s suc",__func__);  

+    }    

+    close(fd_backup);   

+   

+    return ret>0? 0:-2;   

+}

+

+void start_network_timer(timer_t timer, int signal_value, int milliseconds) {

+    LYINFLOG("start_network_timer(), timer_id=%ld, signal_value=%d, time=%d",(long)timer, signal_value, milliseconds);

+
+    struct itimerspec expire;
+    expire.it_interval.tv_sec = 0;
+    expire.it_interval.tv_nsec = 0;
+    expire.it_value.tv_sec = milliseconds/1000;
+    expire.it_value.tv_nsec = (milliseconds%1000)*1000000;
+    if (timer_settime(timer, 0, &expire, NULL) == -1) {
+        LYERRLOG("timer_settime  failed reason=[%s]", strerror(errno));

+    }
+}
+
+void stop_network_timer(timer_t timer, int signal_value) {

+    LYINFLOG("stop_network_timer(), timer_id=%ld, signal_value=%d", (long)timer, signal_value);

+    struct itimerspec timespec;
+    if(timer_gettime(timer, &timespec) == -1) {
+        LYERRLOG("stop_network_timer(), get time fail(%s)", strerror(errno));

+        return;
+    }
+    LYINFLOG("stop_network_timer(), tv_sec=%ld, tv_nsec=%ld",timespec.it_value.tv_sec, timespec.it_value.tv_nsec);

+    if((timespec.it_value.tv_sec == 0)  && (timespec.it_value.tv_nsec == 0) ) {
+        LYINFLOG("stop_network_timer(), timer_id(%ld) had stopped, just return", (long)timer);

+        return;
+    } else {
+        start_network_timer(timer, signal_value, 0);

+    }
+}

+

+void network_timer_handler(sigval_t sig) {    

+    LYINFLOG("network_timer_handler, sig_value: %d", sig.sival_int);

+    int s;   

+    s = pthread_mutex_lock(&mtx);
+    if(s != 0) {
+        LYERRLOG("network_timer_handler, pthead_mutex_lock fail");

+    }   

+    for(int i=0;i<NETWORK_STATE_BUFFER_TYPE_MAX;i++)

+    {

+        if(sig.sival_int == s_state_buffer_sig_value[i]) 

+        {

+            s_state_buffer_valid[i]=false; 

+            break;

+        }        

+    }    

+    s = pthread_mutex_unlock(&mtx);
+    if(s != 0) {
+        LYERRLOG("network_timer_handler, pthread_mutex_unlock fail");

+    }

+}

+

+void init_network_timer(timer_t* timer, int signal_value) 

+{

+    struct sigevent sevp;

+    memset(&sevp, 0, sizeof(sevp));
+    sevp.sigev_value.sival_int = signal_value;
+    sevp.sigev_notify = SIGEV_THREAD;
+    sevp.sigev_notify_function = network_timer_handler;

+
+    if(timer_create(CLOCK_MONOTONIC, &sevp, timer) == -1) {
+        LYERRLOG("init_network_timer()  failed reason=[%s]", strerror(errno));

+    }
+    LYINFLOG("init_network_timer(), timer_Id = %ld, signal_value=%d", (long)(*timer), signal_value);

+}
+
+void init_network_timer_all() {

+

+    for(int i=0;i<NETWORK_STATE_BUFFER_TYPE_MAX;i++){

+        init_network_timer(&s_state_buffer_timer[i],s_state_buffer_sig_value[i]); 

+        s_state_buffer_valid[i] = false;

+    }

+    get_state_buffer_timer_length_from_file();

+}

+

+void deinit_network_timer_all() 

+{

+    for(int i=0;i<NETWORK_STATE_BUFFER_TYPE_MAX;i++){

+        stop_network_timer(s_state_buffer_timer[i],s_state_buffer_sig_value[i]); 

+        s_state_buffer_valid[i] = false;

+    }

+}

+

+int is_period_equal_not_valid(int period)

+{

+    return period<=0 || (period > INT_MAX/1000);

+}

+

+void set_state_buffer_valid(lynq_network_state_buffer_type type,int valid)

+{

+    if(is_period_equal_not_valid(s_state_buffer_cfg.valid_period[type]))

+    {

+        valid=false;

+    }

+    s_state_buffer_valid[type] = valid;

+    if(s_state_buffer_valid[type]==false)

+    {

+        stop_network_timer(s_state_buffer_timer[type], s_state_buffer_sig_value[type]);

+    }

+    else 

+    {

+        start_network_timer(s_state_buffer_timer[type], s_state_buffer_sig_value[type],s_state_buffer_cfg.valid_period[type]*1000);

+    }

+    LYINFLOG("%s type %d valid is %d",__func__,type,valid);    

+}

+

+int get_state_buffer_valid(lynq_network_state_buffer_type type)

+{

+    return s_state_buffer_valid[type];

+}

+

+void set_state_to_buf(lynq_network_state_buffer_type type,...)

+{

+    int ret;

+    int fd_backup;

+    

+    if(is_period_equal_not_valid(s_state_buffer_cfg.valid_period[type]))

+    {

+        LYINFLOG("%s type %d timer length %d is equal not valid",__func__,type,s_state_buffer_cfg.valid_period[type]);

+        return;

+    }

+        

+    fd_backup = open(s_state_buffer_file[type],O_WRONLY | O_CREAT,0777);

+

+    if (fd_backup < 0) {

+        LYERRLOG("%s Error opening registrate buffer file: %s\n",__func__,strerror(errno));

+        return ;

+    }

+

+    va_list pArgs;

+    va_start(pArgs, type);

+

+    int int_num;

+    int i,int_value;

+

+    int_num = va_arg(pArgs, int);

+    LYINFLOG("%s int_num is %d",__func__,int_num);

+    for(i=0;i<int_num;i++)

+    {

+        int_value=va_arg(pArgs, int);

+        LYINFLOG("%s int_value is %d",__func__,int_value);

+        ret = write(fd_backup,&int_value,sizeof (int));

+        if(ret<=0)

+        {

+            LYERRLOG("%s write int %d value %d fail, ret is %d",__func__,i,int_value,ret);

+            goto set_state_error_done;  

+        }   

+        

+    }

+

+    int stringNum;

+    char * p_value;

+    int stringLen;

+

+    stringNum = va_arg(pArgs, int);

+    LYINFLOG("%s stringNum is %d",__func__,stringNum);

+    for(i=0;i<stringNum;i++)

+    {

+        p_value=va_arg(pArgs, char*);

+        stringLen=strlen(p_value)+1;

+        LYINFLOG("%s p_value is %s,stringlen is %d",__func__,p_value,stringLen);

+        ret = write(fd_backup,&stringLen,sizeof(int));

+        if(ret<=0)

+        {

+            LYERRLOG("%s write %i stringlen %d fail, ret is %d",__func__,i,stringLen,ret);

+            goto set_state_error_done;

+        }   

+        ret = write(fd_backup,p_value,stringLen);  

+        if(ret<=0)

+        {

+            LYERRLOG("%s write string %d stringlen %d fail, ret is %d",__func__,i, stringLen,ret);

+            goto set_state_error_done;  

+        }   

+    }   

+

+    va_end(pArgs);

+

+    sync();

+    close(fd_backup); 

+    set_state_buffer_valid(type,true);  

+    LYINFLOG("%s type %d suc",__func__,type);

+    return;

+

+set_state_error_done:    

+    set_state_buffer_valid(type,false);

+    close(fd_backup); 

+    return;   

+}

+

+int get_state_from_buf(lynq_network_state_buffer_type type,...)

+{

+    int ret;

+    int fd_backup;

+    

+    if(!get_state_buffer_valid(type))

+    {

+        LYINFLOG("%s type %d buffer not valid",__func__,type);

+        return 1;

+    }

+

+    fd_backup = open(s_state_buffer_file[type], O_RDONLY);

+

+    if (fd_backup < 0) {

+        LYERRLOG("%s Error opening type %d buffer file: %s\n",__func__,type,strerror(errno));

+        set_state_buffer_valid(type,false); 

+        return -1;

+    }

+

+    va_list pArgs;

+    va_start(pArgs, type);

+    int int_p_num; 

+    int i;

+    int* int_p_value;

+

+    int_p_num= va_arg(pArgs, int); 

+    LYINFLOG("%s int_num is %d",__func__,int_p_num);

+    for(i=0;i<int_p_num;i++)

+    {

+        int_p_value=va_arg(pArgs, int*);        

+        ret = read(fd_backup,int_p_value,sizeof (int));

+        LYINFLOG("%s int_p_value is %d",__func__,(*int_p_value));

+        if(ret<=0)

+        {

+            LYERRLOG("%s read int %d fail, ret is %d",__func__,i,ret);

+            goto get_state_error_done;  

+        }   

+        

+    }

+

+    int stringNum;

+    char * p_value;

+    int stringLen;

+

+    stringNum = va_arg(pArgs, int);

+    LYINFLOG("%s stringNum is %d",__func__,stringNum);

+    for(i=0;i<stringNum;i++)

+    {

+        ret = read(fd_backup,&stringLen,sizeof (int));

+        if(ret<=0)

+        {

+            LYERRLOG("%s get %d string len fail, ret is %d",__func__,i,ret);

+            goto get_state_error_done;

+        }

+        LYINFLOG("%s stringlen is %d",__func__,stringLen);

+        p_value=va_arg(pArgs, char*);          

+        ret = read(fd_backup,p_value,stringLen);

+        if(ret<=0)

+        {

+            LYERRLOG("%s get %d string fail, stringlen is %d,  ret is %d",__func__, stringLen,ret);

+            goto get_state_error_done;

+        } 

+        LYINFLOG("%s p_value is %s",__func__,p_value);

+    } 

+    va_end(pArgs);

+

+    close(fd_backup);   

+    LYINFLOG("%s type %d suc",__func__,type);

+    return 0;  

+    

+get_state_error_done:

+    set_state_buffer_valid(type,false); 

+    close(fd_backup); 

+    return -1;

+}

+

+int lynq_set_state_buffer_valid_period_of_network(lynq_network_state_buffer_type type,int valid_period)

+{

+    if(type>NETWORK_STATE_BUFFER_TYPE_MAX || type <0)

+    {

+        LYERRLOG("%s type %d error",__func__,type);

+        return -1;

+    }

+    if(valid_period>INT_MAX/1000 || valid_period <0)

+    {

+        LYERRLOG("%s type %d error",__func__,valid_period);

+        return -2;

+    }

+   

+    network_state_buffer_cfg cfg_back=s_state_buffer_cfg;

+    s_state_buffer_cfg.valid_period[type]=valid_period;    

+    int ret=set_state_buffer_timer_length_to_file();

+    if(ret!=0)

+    {

+        s_state_buffer_cfg=cfg_back;

+    }

+    else 

+    {

+        set_state_buffer_valid(type,false);   

+    }

+    LYINFLOG("%s type %d period %d ret is %d",__func__,type,valid_period,ret);

+    return ret;

+}

+

+int lynq_get_state_buffer_valid_period_of_network(lynq_network_state_buffer_type type)

+{

+    if(type>NETWORK_STATE_BUFFER_TYPE_MAX || type <0)

+    {

+        LYERRLOG("%s type %d error",__func__,type);

+        return 0;

+    }

+    return s_state_buffer_cfg.valid_period[type];

+}

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_state_buffer.h b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_state_buffer.h
new file mode 100755
index 0000000..35357a3
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_module_state_buffer.h
@@ -0,0 +1,17 @@
+#ifndef LYNQ_MODULE_STATE_BUFFER_H

+#define LYNQ_MODULE_STATE_BUFFER_H 

+#ifdef __cplusplus

+extern "C" {

+#endif

+

+void set_state_buffer_valid(lynq_network_state_buffer_type type,int valid);

+void set_state_to_buf(lynq_network_state_buffer_type type,...);

+int get_state_from_buf(lynq_network_state_buffer_type type,...);

+void init_network_timer_all();

+void deinit_network_timer_all();

+

+#ifdef __cplusplus

+}

+#endif

+

+#endif

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp
new file mode 100755
index 0000000..c025404
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp
@@ -0,0 +1,1498 @@
+#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 <vendor-ril/telephony/ril.h>

+#include <vendor-ril/telephony/mtk_ril_sp.h>

+#include "liblog/lynq_deflog.h"

+#include "lynq_network.h"

+#include "lynq_module_common.h"

+#include "lynq_module_socket.h"

+#include "lynq_module_state_buffer.h"

+

+#define LYNQ_RESP_STRING_MAX_NUM 128

+#define LYNQ_TYPE_BUF 10

+#define USER_LOG_TAG "LYNQ_NETWORK"

+

+/*in CR AUTO00210807 MTK confirm set network selection mode max time is 14min 30s, first set 5 min 10s*/

+#define WAIT_TIME_LENGTH_FOR_SET_NETWORK_SELECTION_MODE (310)

+/*in CR AUTO00207414, in modem, 23G detach need 10s, 5g ims detach need 5s, so set length to 12s */

+#define WAIT_TIME_LENGTH_FOR_SET_PREFFERRED_NETWORK_TYPE (12) 

+

+

+using ::android::Parcel;

+

+static int s_module_wait_urc_id;

+static int s_module_urc_slot_id;

+static signalStrength_t s_network_urc_solSigStren;

+

+/**g_module_init_flag

+* @brief mark network initialization state

+* 0:deinit status

+* 1:init state

+*/

+int g_module_init_flag = 0;

+

+int lynq_network_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;

+

+    g_module_Global_uToken = utoken;

+    LYLOGSET(LOG_INFO);

+    LYLOGEINIT(USER_LOG_TAG);

+    

+    int ret;

+

+    init_network_timer_all();

+	

+    ret = lynq_start_all_urc_socket_thread();

+    if(ret != 0)

+    {

+        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 !=0)

+    {

+        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;    

+}

+

+int lynq_network_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();    

+    deinit_network_timer_all();

+

+    g_module_init_flag = MODULE_CLOSED;

+    return RESULT_OK;    

+}

+

+int strUpper(char * str)

+{

+    int i=0;

+    while(1)

+    {

+        if(str[i]=='\0')

+        {

+            break;

+        }

+        if(str[i]>='a'&&str[i]<='z')

+        {

+             str[i]=str[i]-32;

+        }

+        i++;

+    }

+    return RESULT_OK;      

+}

+

+int copyCellInfoList(Parcel* &p,uint64_t *cellinfo,int *tac,int *earfcn)

+{

+    int32_t v=0;

+    int64_t v6=0;

+    if(NULL == cellinfo)

+    {

+        LYERRLOG("*cellinfo error");

+        return LYNQ_E_PARAMETER_ANONALY;   

+    }

+

+    int nothing = 0;

+    int tmp_uint64 = 0;

+    p->readInt32(&v);

+    RIL_CellInfoType cellinfoType  = RIL_CellInfoType(v);

+    p->readInt32(&nothing);

+    // cellinfo->cellinfo.cellInfoType = RIL_CellInfoType(v);

+    // p->readInt32(&cellinfo->cellinfo.registered);

+    p->readInt32(&v);

+    // cellinfo->cellinfo.timeStampType = RIL_TimeStampType(v);

+    p->readInt64(&v6);

+    // cellinfo->cellinfo.timeStamp = v6;

+    switch(cellinfoType) {

+        case RIL_CELL_INFO_TYPE_GSM: {

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&tmp_uint64);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            *cellinfo = (uint64_t)tmp_uint64;

+            tac = &nothing;

+            earfcn = &nothing;

+            break;

+        }

+        case RIL_CELL_INFO_TYPE_WCDMA: {

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&tmp_uint64);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            *cellinfo = (uint64_t)tmp_uint64;

+            tac = &nothing;

+            earfcn = &nothing;

+            break;

+        }

+        case RIL_CELL_INFO_TYPE_CDMA: {

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            cellinfo = 0;

+            tac = &nothing;

+            earfcn = &nothing;

+            break;

+        }

+        case RIL_CELL_INFO_TYPE_LTE: {

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&tmp_uint64);

+            p->readInt32(&nothing);

+            p->readInt32(tac);

+            p->readInt32(earfcn);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            *cellinfo = (uint64_t)tmp_uint64;

+            break;

+        }

+        case RIL_CELL_INFO_TYPE_TD_SCDMA: {

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&tmp_uint64);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            *cellinfo = (uint64_t)tmp_uint64;

+            tac = &nothing;

+            earfcn = &nothing;

+            break;

+        }

+        case RIL_CELL_INFO_TYPE_NR: {

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readUint64(cellinfo);

+            p->readInt32(&nothing);

+            p->readInt32(tac);

+            p->readInt32(earfcn);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            p->readInt32(&nothing);

+            break;

+        }

+    }

+    LYINFLOG("CID in fUNC :%llu",*cellinfo);

+    LYINFLOG("tac in fUNC :%d",*tac);

+    LYINFLOG("earfcn in fUNC :%d",*earfcn);

+    return RESULT_OK;    

+}

+

+static char * lynqStrdupReadString(Parcel* &p) {

+    size_t stringlen;

+    const char16_t *s16;

+

+    s16 = p->readString16Inplace(&stringlen);

+    return strndup16to8(s16, stringlen);

+}

+

+int lynq_query_operater(char *OperatorFN,char *OperatorSH,char *MccMnc)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    

+    if(NULL == OperatorFN||NULL == OperatorSH|| NULL == MccMnc)

+    {

+        LYERRLOG("%s some parameter OperatorFN OperatorSH MccMnc %s %s %s is NULL",__func__,OperatorFN,OperatorSH,MccMnc);  

+        return LYNQ_E_PARAMETER_ANONALY;   

+    }    

+

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_OPERATOR,0,"");

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }       

+ 

+    int num ;

+    char *resp[LYNQ_RESP_STRING_MAX_NUM];

+

+    p->readInt32(&num);

+    if(num == 0 || num > LYNQ_RESP_STRING_MAX_NUM)

+    {

+        LYERRLOG("no paramters or num %d too great",num);        

+        delete p;      

+        return LYNQ_E_INNER_ERROR;    

+    }else{

+        int i;

+        for(i = 0; i<num;i++)

+        {

+            resp[i] = lynqStrdupReadString(p);

+        }

+        if(NULL != resp[0])

+        {

+            strcpy(OperatorFN,resp[0]);

+        }

+        if(NULL != resp[1])

+        {

+            strcpy(OperatorSH,resp[1]);

+        }

+        if(NULL != resp[2])

+        {

+            strcpy(MccMnc,resp[2]);

+        }

+        for(i = 0; i<num;i++)

+        {

+            if(resp[i]!=NULL)

+            {

+                free(resp[i]);            

+            }            

+        }

+    }

+

+    LYINFLOG("%s suc",__func__);   

+    delete p;       

+    return RESULT_OK;    

+}

+

+int lynq_query_network_selection_mode(int *netselMode)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+

+    if(NULL == netselMode)

+    {

+        LYERRLOG("%s parameter is NULL",__func__);  

+        return LYNQ_E_PARAMETER_ANONALY;   

+    }    

+ 

+    Parcel* p=NULL;    

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE,0,"");

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }   

+    

+    int readnum;

+    p->readInt32(&readnum);

+    p->readInt32(netselMode);

+

+    LYINFLOG("%s suc",__func__);   

+    delete p;       

+    return RESULT_OK;  

+}

+

+int lynq_set_network_selection_mode(const char *mode,const char* mccmnc)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    

+    if(NULL == mode || (strlen(mode) == 0))

+    {

+        LYERRLOG("%s parameter mod %s is error",__func__,mode);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }

+

+    if(!strcmp(mode,"Manual"))

+    {

+        if(mccmnc == NULL || strlen(mccmnc) == 0)

+        {

+             LYERRLOG("%s parameter mccmnc %s is error",__func__,mccmnc);  

+             return LYNQ_E_PARAMETER_ANONALY;

+        }        

+    }

+    

+    Parcel* p=NULL;

+    int ret;

+

+    if(!strcmp(mode,"Auto"))

+    {

+        ret=lynq_send_common_request(p,WAIT_TIME_LENGTH_FOR_SET_NETWORK_SELECTION_MODE,RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC,0,"");

+    }

+    else if(!strcmp(mode,"Manual"))

+    {

+        ret=lynq_send_common_request(p,WAIT_TIME_LENGTH_FOR_SET_NETWORK_SELECTION_MODE,RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,1,"%s",mccmnc); 

+    }

+    else 

+    {

+        LYERRLOG("%s parameter mode %s is errir",__func__,mode);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }   

+        

+    LYINFLOG("%s set mode %s mccmnc %s suc",__func__,mode,mccmnc);   

+    delete p;

+    return RESULT_OK;  

+}

+

+int lynq_query_available_network(char *OperatorFN,char *OperatorSH,char *MccMnc,char * NetStatus)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    if(NULL == OperatorFN||NULL == OperatorSH||NULL == MccMnc||NULL == NetStatus)

+    {

+        LYERRLOG("%s there is parameter is NULL",__func__);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }  

+

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,600,RIL_REQUEST_QUERY_AVAILABLE_NETWORKS,0,"");

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }   

+

+    int num =p->readInt32();

+    char *resp[LYNQ_RESP_STRING_MAX_NUM];

+    if(num == 0 || num > LYNQ_RESP_STRING_MAX_NUM)

+    {

+        LYERRLOG("no paramters or num %d too great",num);        

+        delete p;      

+        return LYNQ_E_INNER_ERROR;    

+    }else{

+        int i;

+        for(i = 0; i<num;i++)

+        {

+            resp[i] = lynqStrdupReadString(p);

+        }

+        if(NULL != resp[0])

+        {

+            strcpy(OperatorFN,resp[0]);

+        }

+        if(NULL != resp[1])

+        {

+            strcpy(OperatorSH,resp[1]);

+        }

+        if(NULL != resp[2])

+        {

+            strcpy(MccMnc,resp[2]);

+        }

+        if(NULL != resp[3])

+        {

+            strcpy(NetStatus,resp[3]);

+        }

+        for(i = 0; i<num;i++)

+        {

+            if(resp[i]!=NULL)

+            {

+                free(resp[i]);            

+            }            

+        }

+    }

+    delete p;

+    LYINFLOG("%s suc",__func__);   

+    return RESULT_OK;  

+}

+

+int lynq_query_registration_state(const char *type,int* regState,int* imsRegState,char * LAC,char * CID,int *netType,int *radioTechFam,int *netRejected)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    

+    if(NULL == type || NULL ==regState ||NULL ==imsRegState ||NULL ==LAC ||NULL ==CID ||NULL ==netType ||NULL ==radioTechFam || NULL == netRejected)

+    {

+        LYERRLOG("%s there is parameter is NULL",__func__);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }  

+    if(strlen(type)>LYNQ_TYPE_BUF)

+    {

+        LYERRLOG("[%s]the parameter is inavaliable !",__FUNCTION__);

+        return LYNQ_E_PARAMETER_ANONALY;   

+    }   

+    

+    int request;

+    char str[LYNQ_TYPE_BUF];   

+    memcpy(str,type,strlen(type)+1);

+    strUpper(str);

+    if(!strcmp(str,"VOICE"))

+    {

+        if(get_state_from_buf(NETWORK_STATE_BUFFER_TYPE_VOICE_REG,3,regState,netType,netRejected,0)==0)

+        {

+            return RESULT_OK;  

+        }       

+        request = RIL_REQUEST_VOICE_REGISTRATION_STATE;

+    }else if(!strcmp(str,"DATA")){

+        if(get_state_from_buf(NETWORK_STATE_BUFFER_TYPE_DATA_REG,2,regState,netType,2,LAC,CID)==0)

+        {

+            return RESULT_OK;  

+        }      

+        request = RIL_REQUEST_DATA_REGISTRATION_STATE;

+    }else if(!strcmp(str,"IMS")){

+        if(get_state_from_buf(NETWORK_STATE_BUFFER_TYPE_IMS_REG,2,imsRegState,radioTechFam,0)==0)

+        {

+            return RESULT_OK;  

+        }       

+        request = RIL_REQUEST_IMS_REGISTRATION_STATE;

+    }else{

+        LYERRLOG("request error");

+        return LYNQ_E_PARAMETER_ANONALY;

+    }    

+

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,request,0,"");

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }   

+    

+    int num,i;

+    char *resp[LYNQ_RESP_STRING_MAX_NUM];       

+    if(!strcmp(str,"VOICE"))

+    {

+        p->readInt32(&num);

+        if(num == 15)

+        {

+            for(i=0;i<15;i++)

+            {

+                resp[i]=lynqStrdupReadString(p);

+            }            

+            *regState = atoi(resp[0]);

+            *netType = atoi(resp[3]);

+            *netRejected = atoi(resp[14]);     

+            for(i=0;i<15;i++)

+            {

+                if(resp[i]!=NULL)

+                {

+                    free(resp[i]);            

+                }            

+            }            

+            set_state_to_buf(NETWORK_STATE_BUFFER_TYPE_VOICE_REG,3,*regState,*netType,*netRejected,0);

+        }

+        else 

+        {

+            LYERRLOG("%s type %s num %d error",__func__,str,num);

+            delete p;

+            return LYNQ_E_INNER_ERROR;

+        }            

+    }

+    else if(!strcmp(str,"DATA")){

+        p->readInt32(&num);

+        if(num == 11)

+        {                

+            for(i=0;i<4;i++)

+            {

+                resp[i]=lynqStrdupReadString(p);

+            }            

+            *regState = atoi(resp[0]);

+            strcpy(LAC,resp[1]);

+            strcpy(CID,resp[2]);

+            *netType = atoi(resp[3]);

+            for(i=0;i<4;i++)

+            {

+                if(resp[i]!=NULL)

+                {

+                    free(resp[i]);            

+                }           

+            }            

+            set_state_to_buf(NETWORK_STATE_BUFFER_TYPE_DATA_REG,2,*regState,*netType,2,LAC,CID);

+        }

+        else 

+        {

+            LYERRLOG("%s type %s num %d error",__func__,str,num);

+            delete p;

+            return LYNQ_E_INNER_ERROR;

+        }            

+

+    }

+    else // "IMS"

+    {

+        p->readInt32(&num);

+        if(num == 2)

+        {

+            p->readInt32(imsRegState);

+            p->readInt32(radioTechFam);

+            set_state_to_buf(NETWORK_STATE_BUFFER_TYPE_IMS_REG,2,*imsRegState,*radioTechFam,0);

+        }

+        else 

+        {

+            LYERRLOG("%s type %s num %d error",__func__,str,num);

+            delete p;

+            return LYNQ_E_INNER_ERROR;

+        }            

+    }

+    LYINFLOG("%s suc",__func__); 

+    delete p;        

+    return RESULT_OK;     

+}

+

+int lynq_query_prefferred_networktype(int *preNetType)

+{    

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    if(NULL == preNetType)

+    {

+        LYERRLOG("%s there is parameter is NULL",__func__);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }          

+

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE,0,"");

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }   

+    

+    int num;

+    p->readInt32(&num);

+    p->readInt32(preNetType);  

+    

+    LYINFLOG("%s suc",__func__); 

+    delete p;

+    return RESULT_OK;  

+}

+

+int lynq_set_prefferred_networktype(const int preffertype)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    if(preffertype < 0||preffertype >33)

+    {

+        LYERRLOG("%s parameter %d error",__func__,preffertype);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }     

+

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,WAIT_TIME_LENGTH_FOR_SET_PREFFERRED_NETWORK_TYPE,RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE,1,"%d",preffertype);

+     

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }   

+    

+    LYINFLOG("%s set %d suc",__func__,preffertype);     

+    delete p;

+    return RESULT_OK;  

+   

+}

+

+int lynq_query_cell_info(uint64_t cellinfo[CELLINFO_MAX_NUM],int tac[CELLINFO_MAX_NUM],int earfcn[CELLINFO_MAX_NUM],int * realNum)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    if(NULL == realNum)

+    {

+        LYERRLOG("%s there is parameter is NULL",__func__);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }      

+    

+    Parcel* p=NULL;      

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_GET_CELL_INFO_LIST,0,"");

+    

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }   

+    

+    int num;

+

+    p->readInt32(&num);

+    LYINFLOG("cell info num:%d",num);

+    *realNum = num;

+    for(int i = 0;i<num;i++)

+    {

+        copyCellInfoList(p,&cellinfo[i],&tac[i],&earfcn[i]);

+    }

+    

+    LYINFLOG("%s suc",__func__); 

+    delete p;

+    return RESULT_OK;  

+}

+

+int lynq_set_unsol_cell_info_listrate(const int rate)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    Parcel* p=NULL;      

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE,1,"%d",rate);

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }   

+    

+    LYINFLOG("%s set %d suc",__func__,rate);    

+    delete p;

+    return RESULT_OK;      

+}

+

+int lynq_set_band_mode(const int bandmode)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    Parcel* p=NULL;      

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SET_BAND_MODE,1,"%d",bandmode);

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }   

+    

+    LYINFLOG("%s set %d suc",__func__,bandmode);    

+    delete p;

+    return RESULT_OK;  

+}

+

+int lynq_query_available_bandmode(int availBanMode[])

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    if(NULL == availBanMode)

+    {

+        LYERRLOG("%s parameter is NULL",__func__);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }

+

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE,0,"");

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }   

+    

+    int num = 0;

+    int res = 0;

+    int i;

+

+    p->readInt32(&num);

+    LYINFLOG("num = %d",num);

+    availBanMode[0] = num;

+    for(i=1 ;i<=num;i++)

+    {

+        p->readInt32(&res);

+        availBanMode[i]=res;

+    }

+ 

+    LYINFLOG("%s suc",__func__);  

+    delete p;

+    return RESULT_OK;                

+}

+

+int lynq_radio_on(const lynq_network_radio_on_type type)

+{     

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    if (type != NETWORK_RADIO_ON_TYPE_CFUN_0  && type != NETWORK_RADIO_ON_TYPE_NORMAL_MODE && type!=NETWORK_RADIO_ON_TYPE_FLIGHT_MODE)

+    {

+        LYERRLOG("%s parameter %d error",__func__,type);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }     

+    

+    Parcel* p=NULL;      

+    int ret;

+

+    if(type==NETWORK_RADIO_ON_TYPE_CFUN_0)

+    {

+        ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_OEM_HOOK_RAW,1,"%s","AT+CFUN=0");

+    }

+    else 

+    {

+        ret=lynq_send_common_request(p,65,RIL_REQUEST_RADIO_POWER,1,"%d",(type==NETWORK_RADIO_ON_TYPE_NORMAL_MODE));

+    }

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }       

+

+    LYINFLOG("%s set %d suc",__func__,type);  

+    delete p;

+    return RESULT_OK;  

+}

+

+const char * lynq_get_raw_data(Parcel* &p, int* data_len) 

+{

+    int32_t len;

+    int status;

+    char *data;

+

+    *data_len=0;

+

+    status = p->readInt32(&len);

+

+    if (status != 0) {

+        LYERRLOG("%s status is %d",__func__,status);

+        return NULL;

+    }

+

+    // The java code writes -1 for null arrays

+    if (((int)len) == -1 || ((int)len) == 0) 

+    {

+        LYERRLOG("%s len is %d",__func__,len);

+        return NULL;

+    }

+    LYINFLOG("%s len is %d",__func__,len);

+

+    data = (char*) p->readInplace(len); 

+    *data_len=len;

+

+    return data;

+}

+

+int lynq_query_radio_state(int *radio_state)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    if(NULL == radio_state)

+    {

+        LYERRLOG("%s radio state is NULL",__func__);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }

+

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_OEM_HOOK_RAW,1,"%s","AT+CFUN");

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }           

+

+    int bfind=false;

+    const char* data;

+    int data_len;

+    char* data_str;

+    char* start;

+    int length;

+    int i;

+    int num_start;

+    data = lynq_get_raw_data(p,&data_len);

+    if(data==NULL || data_len == 0)

+    {

+        LYERRLOG("%s lynq_get_raw_data NULL or data_len is 0",__func__);    

+        delete p;

+        return LYNQ_E_INNER_ERROR; 

+    }

+    data_str = (char*) calloc(1,data_len+1);

+    if (NULL == data_str) 

+    {

+         LYERRLOG("%s alloc mem error, data_len is %d",__func__,data_len+1);         

+         delete p;

+         return LYNQ_E_MALLOC_ERROR;

+    }

+    memmove(data_str, data, data_len);     

+    data_str[data_len]='\0';           

+    LYINFLOG("%s return string is %s",__func__,data_str);  

+    start = strstr(data_str,"CFUN");

+    if(start!=NULL)

+    {

+         start=start+4;

+         length=strlen(start);

+         for(i=0; i<length;i++)

+         {

+             if((!bfind) && (start[i] >= '0') && (start[i] <= '9'))

+             {

+                 bfind=true;  

+                 num_start=i;

+             }

+             else if(bfind && ((start[i] < '0') || (start[i] > '9')))

+             {

+                start[i]='\0';

+                break;

+             }

+         }

+         if(bfind)

+         {                    

+             (*radio_state) = atoi(start+num_start);

+             LYINFLOG("%s, radio state is %s %d",__func__,start+num_start,*radio_state);  

+             free(data_str);

+             delete p;

+             return RESULT_OK;                         

+         }

+    }             

+    LYERRLOG("%s return string %s no cfun or no digit",__func__,data_str);  

+    free(data_str);

+    delete p;

+    return LYNQ_E_INNER_ERROR;              

+}

+

+int lynq_query_radio_tech(int* radioTech)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    if(NULL == radioTech)

+    {

+        LYERRLOG("%s radio tech is NULL",__func__);  

+        return LYNQ_E_PARAMETER_ANONALY;   

+    }    

+

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_VOICE_RADIO_TECH,0,"");

+    

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }              

+         

+    int num;

+    p->readInt32(&num);

+    p->readInt32(radioTech);

+

+    LYINFLOG("%s suc",__func__);  

+    delete p;

+    return RESULT_OK;   

+}

+

+int lynq_solicited_signal_strength(signalStrength_t *solSigStren)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    if(NULL == solSigStren)

+    {

+        LYERRLOG("%s parameter is NULL",__func__);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }

+

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SIGNAL_STRENGTH,0,"");

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }            

+    

+    int sum = 0;

+    int LTE_signalstrength = 0;

+    int WCDMA_signalstrength = 0;

+    int none = 0;

+

+    p->readInt32(&solSigStren->rssi);

+    if((solSigStren->rssi!=99)&&(solSigStren->rssi!=0))

+    {

+        solSigStren->gw_sig_valid = 1;

+    }else{

+        solSigStren->gw_sig_valid = 0;

+    }

+

+    p->readInt32(&none);

+    p->readInt32(&none);

+    p->readInt32(&none);

+    p->readInt32(&none);

+    p->readInt32(&none);

+    p->readInt32(&none);

+    p->readInt32(&none);

+    p->readInt32(&LTE_signalstrength);

+    // p->readInt32(&solSigStren->signalStrength.LTE_SignalStrength.signalStrength);

+    p->readInt32(&solSigStren->rsrp);

+    p->readInt32(&solSigStren->rsrq);

+    p->readInt32(&solSigStren->rssnr);

+    LYINFLOG("LTE_signalstrength:%d",LTE_signalstrength);

+    if((LTE_signalstrength!=99)&&(LTE_signalstrength!=0))

+    {

+        solSigStren->lte_sig_valid = 1;

+    }else{

+        solSigStren->lte_sig_valid = 0;

+    }

+

+    p->readInt32(&none);

+    p->readInt32(&none);

+    p->readInt32(&none);

+    p->readInt32(&none);

+    p->readInt32(&none);

+    p->readInt32(&WCDMA_signalstrength);

+    p->readInt32(&none);

+    p->readInt32(&solSigStren->rscp);

+    p->readInt32(&solSigStren->ecno);

+    LYINFLOG("WCDMA_signalstrength:%d",WCDMA_signalstrength);

+    if((WCDMA_signalstrength!=99)&&(WCDMA_signalstrength!=0))

+    {

+        solSigStren->wcdma_sig_valid = 1;

+    }else{

+        solSigStren->wcdma_sig_valid = 0;

+    }

+    /*bug fix*/

+    p->readInt32(&solSigStren->ssRsrp);

+    p->readInt32(&solSigStren->ssRsrq);

+    p->readInt32(&solSigStren->ssSinr);

+    p->readInt32(&solSigStren->csiRsrp);

+    p->readInt32(&solSigStren->csiRsrq);

+    p->readInt32(&solSigStren->csiSinr);

+    sum = (solSigStren->ssRsrp) + (solSigStren->ssRsrq) + (solSigStren->ssSinr) + (solSigStren->csiRsrp)+\

+    (solSigStren->csiRsrq) + (solSigStren->csiSinr);

+    if(sum != 0)

+    {

+        solSigStren->nr_sig_valid = 1;

+    }else{

+        LYERRLOG("None of NR signal info");

+    }        

+

+    LYINFLOG("%s suc",__func__);  

+    delete p;

+    return RESULT_OK;    

+}

+

+int lynq_set_ims(const int ims_mode)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    if (ims_mode < 0 || ims_mode > 1)

+    {

+        LYERRLOG("%s parameter %d error",__func__,ims_mode);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }     

+

+    Parcel* p=NULL;

+    int ret = lynq_send_common_request(p,65,RIL_REQUEST_SET_IMS_ENABLE,1,"%d",ims_mode);

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }        

+    

+    LYINFLOG("%s set %d suc",__func__,ims_mode);    

+    delete p;

+    return RESULT_OK;   

+}

+

+/*Used to get urc info*/

+int lynq_get_urc_info(const int handle,signalStrength_t *solSigStren,int *slot_id)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    LYDBGLOG("start get urc info");

+    if(handle != RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED &&handle != RIL_UNSOL_SIGNAL_STRENGTH)

+    {

+        LYINFLOG("invalid handle!!!");

+        return LYNQ_E_PARAMETER_ANONALY;

+    }

+    if((handle ==RIL_UNSOL_SIGNAL_STRENGTH && NULL == solSigStren) || 

+        (handle ==RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED && NULL == slot_id))

+    {

+        LYINFLOG("incoming solSigStren or slot_id is NULL!!!");

+        return LYNQ_E_PARAMETER_ANONALY;

+    }

+    switch(handle)

+    {

+        case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: //1002

+        {

+            LYDBGLOG("get state update to VOICE");

+            *slot_id = s_module_urc_slot_id;

+            LYINFLOG("slot_id = %d",s_module_urc_slot_id);

+            break;

+        }

+        case RIL_UNSOL_SIGNAL_STRENGTH: //1009

+        {

+            LYDBGLOG("get state update to signal info");

+            solSigStren->gw_sig_valid = s_network_urc_solSigStren.gw_sig_valid;

+            solSigStren->rssi = s_network_urc_solSigStren.rssi;

+            solSigStren->wcdma_sig_valid = s_network_urc_solSigStren.wcdma_sig_valid;

+            solSigStren->rscp = s_network_urc_solSigStren.rscp;

+            solSigStren->ecno = s_network_urc_solSigStren.ecno;

+            solSigStren->lte_sig_valid = s_network_urc_solSigStren.lte_sig_valid;

+            solSigStren->rsrp = s_network_urc_solSigStren.rsrp;

+            solSigStren->rsrq = s_network_urc_solSigStren.rsrq;

+            solSigStren->rssnr = s_network_urc_solSigStren.rssnr;

+            solSigStren->nr_sig_valid = s_network_urc_solSigStren.nr_sig_valid;

+            solSigStren->ssRsrp = s_network_urc_solSigStren.ssRsrp;

+            solSigStren->ssRsrq = s_network_urc_solSigStren.ssRsrq;

+            solSigStren->ssSinr = s_network_urc_solSigStren.ssSinr;

+            solSigStren->csiRsrp = s_network_urc_solSigStren.csiRsrp;

+            solSigStren->csiRsrq = s_network_urc_solSigStren.csiRsrq;

+            solSigStren->csiSinr = s_network_urc_solSigStren.csiSinr;

+            break;

+        }

+    }

+    return RESULT_OK;   

+}

+

+static pthread_mutex_t urc_signal_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;

+static pthread_cond_t urc_signal_state_change_cond = PTHREAD_COND_INITIALIZER;

+

+int wait_urc_signal_changes()

+{

+    pthread_mutex_lock(&urc_signal_state_change_mutex);

+    pthread_cond_wait(&urc_signal_state_change_cond,&urc_signal_state_change_mutex);

+    pthread_mutex_unlock(&urc_signal_state_change_mutex);

+    return RESULT_OK;   

+}

+

+void send_urc_signal_changes()

+{

+    pthread_mutex_lock(&urc_signal_state_change_mutex);

+    pthread_cond_signal(&urc_signal_state_change_cond);

+    pthread_mutex_unlock(&urc_signal_state_change_mutex);

+    return;

+}

+

+bool is_support_urc(int urc_id)

+{

+    switch(urc_id)

+    {

+        case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:

+        case RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED:

+        case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED:

+        case RIL_UNSOL_SIGNAL_STRENGTH:

+            return true;                

+        default:

+            return false;

+    }    

+}

+

+void urc_msg_process(Parcel *p)

+{ 

+    int resp_type; 

+    int none = 0;

+    int NR_sum = 0;

+    int urc_LTE_signalstrength = 0;

+    int urc_WCDMA_signalstrength = 0;

+

+    int size=p->dataSize();

+    p->readInt32(&resp_type);

+    p->readInt32(&s_module_wait_urc_id);

+    p->readInt32(&s_module_urc_slot_id);

+    LYINFLOG("%s urc id = %d, slot_id = %d, size is %d, msg is %s",__func__, s_module_wait_urc_id,s_module_urc_slot_id,size,requestToString(s_module_wait_urc_id));

+    switch(s_module_wait_urc_id)

+    {

+        case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:

+        {

+            set_state_buffer_valid(NETWORK_STATE_BUFFER_TYPE_VOICE_REG,false);

+            send_urc_signal_changes();

+            break;

+        }

+        case RIL_UNSOL_RESPONSE_PS_NETWORK_STATE_CHANGED:

+        {                    

+            set_state_buffer_valid(NETWORK_STATE_BUFFER_TYPE_DATA_REG,false);

+            send_urc_signal_changes();

+            break;

+        }

+        case RIL_UNSOL_RESPONSE_IMS_NETWORK_STATE_CHANGED:

+        {                   

+            set_state_buffer_valid(NETWORK_STATE_BUFFER_TYPE_IMS_REG,false);                                       

+            send_urc_signal_changes();

+            break;

+        }

+        case RIL_UNSOL_SIGNAL_STRENGTH:

+        {

+            p->readInt32(&s_network_urc_solSigStren.rssi);

+            if((s_network_urc_solSigStren.rssi!=99)&&(s_network_urc_solSigStren.rssi!=0))

+            {

+                s_network_urc_solSigStren.gw_sig_valid = 1;

+            }else{

+                s_network_urc_solSigStren.gw_sig_valid = 0;

+            }

+            if(s_network_urc_solSigStren.gw_sig_valid == 1)

+            {

+                LYINFLOG("urc_GSM_signalstrength:%d",s_network_urc_solSigStren.rssi);

+            }

+            p->readInt32(&none);

+            p->readInt32(&none);

+            p->readInt32(&none);

+            p->readInt32(&none);

+            p->readInt32(&none);

+            p->readInt32(&none);

+            p->readInt32(&none);

+            p->readInt32(&urc_LTE_signalstrength);

+            // p.readInt32(&solSigStren->signalStrength.LTE_SignalStrength.signalStrength);

+            p->readInt32(&s_network_urc_solSigStren.rsrp);

+            p->readInt32(&s_network_urc_solSigStren.rsrq);

+            p->readInt32(&s_network_urc_solSigStren.rssnr);

+            if((urc_LTE_signalstrength!=99)&&(urc_LTE_signalstrength!=0))

+            {

+                s_network_urc_solSigStren.lte_sig_valid = 1;

+            }else{

+                s_network_urc_solSigStren.lte_sig_valid = 0;

+            }

+            if(s_network_urc_solSigStren.lte_sig_valid == 1)

+            {

+                LYINFLOG("urc_LTE_signalstrength:%d",urc_LTE_signalstrength);

+            }

+            p->readInt32(&none);

+            p->readInt32(&none);

+            p->readInt32(&none);

+            p->readInt32(&none);

+            p->readInt32(&none);

+            p->readInt32(&urc_WCDMA_signalstrength);

+            p->readInt32(&none);

+            p->readInt32(&s_network_urc_solSigStren.rscp);

+            p->readInt32(&s_network_urc_solSigStren.ecno);

+            if((urc_WCDMA_signalstrength!=99)&&(urc_WCDMA_signalstrength!=0))

+            {

+                s_network_urc_solSigStren.wcdma_sig_valid = 1;

+            }else{

+                s_network_urc_solSigStren.wcdma_sig_valid = 0;

+            }

+            if(s_network_urc_solSigStren.wcdma_sig_valid == 1)

+            {

+                LYINFLOG("urc_WCDMA_signalstrength:%d",urc_WCDMA_signalstrength);

+            }

+            p->readInt32(&s_network_urc_solSigStren.ssRsrp);

+            p->readInt32(&s_network_urc_solSigStren.ssRsrq);

+            p->readInt32(&s_network_urc_solSigStren.ssSinr);

+            p->readInt32(&s_network_urc_solSigStren.csiRsrp);

+            p->readInt32(&s_network_urc_solSigStren.csiRsrq);

+            p->readInt32(&s_network_urc_solSigStren.csiSinr);

+            NR_sum = (s_network_urc_solSigStren.ssRsrp) + (s_network_urc_solSigStren.ssRsrq) + (s_network_urc_solSigStren.ssSinr) + (s_network_urc_solSigStren.csiRsrp)+\

+            (s_network_urc_solSigStren.csiRsrq) + (s_network_urc_solSigStren.csiSinr);

+            if(NR_sum != 0)

+            {

+                s_network_urc_solSigStren.nr_sig_valid = 1;

+            }else{

+                s_network_urc_solSigStren.nr_sig_valid = 0;

+            }

+            if(s_network_urc_solSigStren.nr_sig_valid == 1)

+            {

+                LYINFLOG("[NR signal]ssRsrp is %d , ssRsrq is %d , ssSinr is %d , csiRsrp is %d , csiRsrq is %d , csiSinr is %d",\

+                s_network_urc_solSigStren.ssRsrp,s_network_urc_solSigStren.ssRsrq,s_network_urc_solSigStren.ssSinr, \

+                s_network_urc_solSigStren.csiRsrp,s_network_urc_solSigStren.csiRsrq,s_network_urc_solSigStren.csiSinr);

+            }             

+            send_urc_signal_changes();

+            break;

+        }

+    }

+}

+

+/*Used to wait for an update signal*/

+int lynq_wait_signalchanges(int *handle)

+{

+    LYDBGLOG("start wait signalchanges info");

+    if(NULL == handle)

+    {

+        LYERRLOG("illegal input");

+        return LYNQ_E_PARAMETER_ANONALY;

+    }

+    wait_urc_signal_changes();

+    LYDBGLOG("get signalchanges");

+    *handle = s_module_wait_urc_id;

+    return RESULT_OK;   

+}

+

+#ifdef MODEM_GEN97

+/**@brief parse at response,return error code,and the response

+* @param response [IN] <response>:original at response,This parameter must be a character array.

+

+* @param value [OUT] <value>: Used to receive the parsed value, if multiple values are separated by ";".

+*  field:

+*    eg:

+*       "+cnum: 123456\n+cnum: 456"

+*       value:12345;456;

+* @param value_len [IN] <value_len>: The value length.

+

+* @return:AT error code

+*/

+static int parse_at_result(char response[],char value[],int value_len)

+{

+    if(response == NULL || value == NULL)

+    {

+        LYERRLOG("parameter invalid");

+        return LYNQ_E_PARAMETER_ANONALY;

+    }

+    if(strstr(response,"ERROR"))

+    {

+        int i;

+        for(i = 0;i < strlen(response);i++)

+        {

+            if(response[i]==':')

+            {

+                break;

+            }

+        }

+        if(i < strlen(response))

+        {

+            LYINFLOG("parse_result:%d\n",atoi(response+i+1));

+            return atoi(response+i+1);

+        }

+        else

+        {

+            LYINFLOG("%s parse_result:fail,this response invalid\n",response);

+            return 100; //unknown

+        }

+    }

+    else if(strstr(response,"OK"))

+    {

+        /** parse the at response value

+        * eg:

+        * --> at+cnum

+        * <-- +CNUM:"1243452"

+        * need parse the "1243452" to <value>

+        *@  To-Do

+        */

+        int count;

+        int resp_addr[32] = {0};

+        char temp_buf[1024] = {0};

+        char *dest;

+        dest = NULL;

+        count = 0;

+        int res_len = strlen(response);

+        LYINFLOG("res_len:%d",res_len);

+        for(int i = 0; i < res_len; i++)

+        {

+            if(response[i]==':')

+            {

+                resp_addr[count] = i;

+                count++;

+            }

+            if(response[i] == '\n')

+            {

+                response[i] = '\0';

+            }

+        }

+        LYINFLOG("count:%d",count);

+        if(count > 0)

+        {

+            for(int i = 0; i < count; i++)

+            {

+                if((strlen(temp_buf) + strlen(response+resp_addr[i]+2)) >= 1023)

+                {

+                    LYINFLOG("2 will be out of range\n");

+                    break;

+                }

+                if(strlen(temp_buf) >= 1023)

+                {

+                    LYINFLOG("1 will be out of range\n");

+                    break;

+                }

+                strcat(temp_buf,response+resp_addr[i]+2);

+

+                if(strlen(temp_buf) >= 1023)

+                {

+                    LYINFLOG("1 will be out of range\n");

+                    break;

+                }

+                strcat(temp_buf,";");

+                printf("parse_result[%d]:%s,strcated:%s\n",i,response+resp_addr[i]+2,temp_buf);

+            }

+            LYINFLOG("parse_result:%s\n",temp_buf);

+            if(strlen(temp_buf) > value_len)

+            {

+                printf("result length over value:%ld,%d\n",strlen(temp_buf),value_len);

+                memcpy(value,temp_buf,value_len);

+            }

+            else

+            {

+                memcpy(value,temp_buf,strlen(temp_buf));

+            }

+        }

+        return RESULT_OK;   

+    }

+    else

+    {

+        LYINFLOG("%s this response invalid\n",response);

+        return LYNQ_E_INNER_ERROR;

+    }

+}

+

+int lynq_oos_recover_timer_interval(int mode, char interval[LY_RECOVER_TIMER_INTERVAL],char result[LY_RECOVER_TIMER_INTERVAL])

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+

+    if((mode < 0) || (mode >1) || (mode == 0 && NULL == interval) || (NULL == result))

+    {

+        LYERRLOG("%s mode %d interval %s result %s error",__func__,mode,interval,result);  

+        return LYNQ_E_PARAMETER_ANONALY;

+    }

+

+    Parcel* p=NULL;

+    int ret;

+

+    if(mode == 0)

+    {

+        ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_OEM_HOOK_RAW,1,"AT+ERSCFG=%s",interval);

+    }

+    else 

+    {

+        ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_OEM_HOOK_RAW,1,"AT+ERSCFG?");

+    }

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }        

+

+    int recv_len;    

+    char res_data[LY_RECOVER_TIMER_INTERVAL] = {0};

+    char response_interval[LY_RECOVER_TIMER_INTERVAL*2] = {0};

+

+    LYINFLOG("get recover timer interval");

+    p->readInt32(&recv_len);

+    if(recv_len == -1)

+    {

+        LYINFLOG("no responset");

+        delete p;

+        return LYNQ_E_INNER_ERROR;

+    }

+    else

+    {

+        LYINFLOG("recv_len:%d",recv_len);

+        p->read(response_interval,recv_len);

+    }

+    LYINFLOG("response_interval:%s",response_interval);

+    ret = parse_at_result(response_interval,res_data,LY_RECOVER_TIMER_INTERVAL);

+    if(mode == 1)

+    {

+        if(strlen(res_data) <= LY_RECOVER_TIMER_INTERVAL)

+        {

+            memcpy(result,res_data,strlen(res_data));

+        }

+    }

+    LYERRLOG("%s ret:%d",__func__,ret);

+    delete p;

+    return ret;         

+}

+

+int lynq_oos_deep_sleep_recover_timer_interval(int recovery_threshold,int fullband_timer,int sniffer_timer,int inactive_mode)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+     if(((recovery_threshold < 2) || (recovery_threshold > 10)) || (fullband_timer < 90) || 

+    ((sniffer_timer < 10) || (sniffer_timer > 60)) || ((inactive_mode < 0) || (inactive_mode > 1)))

+    {

+        LYERRLOG("%s paramter recovery_threshold %d fullband_timer %d sniffer_timer %d inactive_mode %d error!",__func__,recovery_threshold,fullband_timer,sniffer_timer,inactive_mode);

+        return LYNQ_E_PARAMETER_ANONALY;

+    }

+

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_OEM_HOOK_RAW,1,"AT+ESRVREC=%d,%d,%d,%d",recovery_threshold,fullband_timer,sniffer_timer,inactive_mode);

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

+        return ret;  

+    }        

+ 

+    int recv_len;   

+    char res_data[LY_RECOVER_TIMER_INTERVAL] = {0};

+    char response_interval[LY_RECOVER_TIMER_INTERVAL*2] = {0};

+ 

+    p->readInt32(&recv_len);

+    if(recv_len == -1)

+    {

+        LYINFLOG("no responset");

+        delete p;

+        return LYNQ_E_INNER_ERROR;

+    }

+    else

+    {

+        LYINFLOG("recv_len:%d",recv_len);

+        p->read(response_interval,recv_len);

+    }

+    LYINFLOG("response_interval:%s",response_interval);

+    ret = parse_at_result(response_interval,res_data,LY_RECOVER_TIMER_INTERVAL);

+    LYERRLOG("%s ret:%d",__func__,ret);

+    delete p;

+    return ret;      

+ 

+}

+#endif

+

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-network/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-network/makefile
new file mode 100755
index 0000000..cf6f538
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/makefile
@@ -0,0 +1,78 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -std=c++11 \
+                -g -Os \
+                -flto \
+                -fPIC \
+                -DRIL_SHLIB \
+                -DATCI_PARSE \
+                -DKEEP_ALIVE \
+                -DECALL_SUPPORT
+
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0
+endif
+
+$(warning ################# lynq network demo ROOT: $(ROOT),includedir:$(includedir))
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH)/include/lynq_network \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/liblog \
+  -I$(ROOT)$(includedir)/vendor-ril \
+  -I$(ROOT)$(includedir)/include \
+  -I$(ROOT)$(includedir)/lynq_shm \
+
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lrt \
+    -llog \
+    -lbinder \
+    -lpthread \
+    -llynq-log \
+	-lutils \
+    -lcutils \
+    -llynq-shm \
+
+SOURCES = $(wildcard *.cpp)
+
+EXECUTABLE = liblynq-network.so
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+build:  $(EXECUTABLE)
+	$(warning ########## build $(EXECUTABLE)  ##########)
+
+install:
+	$(warning ################# lynq network demo EXECUTABLE: $(EXECUTABLE),base:$(base_libdir))
+	mkdir -p $(ROOT)$(base_libdir)/
+	install $(EXECUTABLE) $(ROOT)$(base_libdir)/
+
+pack_rootfs:
+	$(warning ################# lynq network demo PACK: $(PACK_INITRAMFS_TO),base:$(base_libdir))
+	mkdir -p $(PACK_INITRAMFS_TO)$(base_libdir)/
+	cp -af $(EXECUTABLE) $(PACK_INITRAMFS_TO)$(base_libdir)/
+	$(CROSS)strip $(PACK_INITRAMFS_TO)$(base_libdir)/$(EXECUTABLE)
+	mkdir -p $(PACK_TO)$(base_libdir)/
+	cp -af $(EXECUTABLE) $(PACK_TO)$(base_libdir)/
+	$(CROSS)strip $(PACK_TO)$(base_libdir)/$(EXECUTABLE)
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
+
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sms/LICENSE b/cap/zx297520v3/src/lynq/lib/liblynq-sms/LICENSE
new file mode 100755
index 0000000..605b7ea
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sms/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MobileTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MobileTek Inc. and/or its licensors. Without
+the prior written permission of MobileTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MobileTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MobileTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MobileTek SOFTWARE")
+RECEIVED FROM MobileTek AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MobileTek EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MobileTek PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MobileTek SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MobileTek
+SOFTWARE. MobileTek SHALL ALSO NOT BE RESPONSIBLE FOR ANY MobileTek SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MobileTek'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MobileTek SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MobileTek'S OPTION, TO REVISE OR REPLACE THE
+MobileTek SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MobileTek FOR SUCH MobileTek SOFTWARE AT ISSUE.
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sms/include/libsms/lynq_sms.h b/cap/zx297520v3/src/lynq/lib/liblynq-sms/include/libsms/lynq_sms.h
new file mode 100755
index 0000000..0d346a6
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sms/include/libsms/lynq_sms.h
@@ -0,0 +1,28 @@
+#ifndef LYNQ_SMS_H

+#define LYNQ_SMS_H 1

+#ifdef __cplusplus

+extern "C" {

+#endif

+

+#define MIN_MSM_PARAM_NUM 4

+#define MIN_IMS_MSM_PARAM_NUM 6

+#define MIN_WRITE_MSM_PARAM_NUM 5

+#define MSG_MAX_LEN 1024

+#define TELEPHONE_NUM_LEN 64

+#define STORAGE_SMS_MAX_SIZE 128

+#define SMSC_MAX_LEN 22

+#define SMS_NUM_MAX 255

+

+int lynq_sms_init(int uToken);

+int lynq_sms_deinit(void);

+int lynq_send_sms(char telephony_num[TELEPHONE_NUM_LEN], int charset, char *msg, int msglen);

+int lynq_read_sms(int index,int *status,int *charset,char smsc[SMSC_MAX_LEN],int *smscLen,int *smslen,char message[MSG_MAX_LEN],char teleNum[TELEPHONE_NUM_LEN],int *numLen,int *current,int *total);

+int lynq_get_smsc_address(char service_num[SMSC_MAX_LEN]);

+int lynq_set_smsc_address(const char* service_num);

+int lynq_list_sms(char index_list[SMS_NUM_MAX]);

+int lynq_delete_sms(int index);

+int lynq_wait_receive_new_sms(int *handle);

+#ifdef __cplusplus

+}

+#endif

+#endif

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_module_common.h b/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_module_common.h
new file mode 100755
index 0000000..60719ef
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sms/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-sms/lynq_module_socket.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_module_socket.cpp
new file mode 100755
index 0000000..8d012da
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_module_socket.cpp
@@ -0,0 +1,1041 @@
+#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_sms.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_SMS"

+

+typedef struct{

+    int uToken;

+    int request;

+    int paramLen;

+    char param[LYNQ_REQUEST_PARAM_BUF];

+}lynq_client_t;

+

+typedef struct{

+    int resp_type;

+    int token;

+    int request;

+    int slot_id;

+    int error;

+}lynq_resp_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 PrintHeader(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 GetHeader(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));

+        PrintHeader(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=GetHeader(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("sms 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 LYNQ_REQUEST_LIST_SMS_FROM_MEMORY:

+            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);

+                if(!is_support_request(resquest))

+                {

+                    continue;

+                }

+                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*/

+        /*warren add for t800 ril service 2022/1/22 end*/

+        default: return "<unknown request>";

+    }

+}

+

+

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_module_socket.h b/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_module_socket.h
new file mode 100755
index 0000000..aabac32
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_module_socket.h
@@ -0,0 +1,22 @@
+#ifndef LYNQ_MODULE_SOCKET_H

+#define LYNQ_MODULE_SOCKET_H 

+

+using ::android::Parcel;

+

+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-sms/lynq_sms.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_sms.cpp
new file mode 100755
index 0000000..f0b2bbd
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_sms.cpp
@@ -0,0 +1,366 @@
+

+#include <stdio.h>

+#include <sys/types.h>

+#include <sys/socket.h>

+#include <arpa/inet.h>

+#include <fcntl.h>

+#include <string.h>

+#include <stdlib.h>

+#include <unistd.h>

+#include <binder/Parcel.h>

+#include <log/log.h>

+#include <cutils/jstring.h>

+#include <pthread.h>

+#include "liblog/lynq_deflog.h"

+#include <sys/time.h>

+#include <string.h>

+#include <vendor-ril/telephony/ril.h>

+#include <vendor-ril/telephony/mtk_ril_sp.h>

+#include <vendor-ril/telephony/mtk_ril_ivt.h>

+#include "lynq_sms.h"

+#include "lynq_module_common.h"

+#include "lynq_module_socket.h"

+

+#define CALL_OFF (0)

+#define CALL_ON  (1)

+#define USER_LOG_TAG "LYNQ_SMS"

+

+using ::android::Parcel;

+

+

+int sms_storage_index = 0;

+

+/**

+ * @brief mark call initialization state

+ * 0: deinit state

+ * 1: init state

+ */

+int g_module_init_flag = 0;

+

+//static lynq_call_list_e_t s_call_lists[LYNQ_CALL_MAX]={};

+//static bool s_call_list_loop = 0;

+//static pthread_t s_call_list_loop_tid = -1;

+static pthread_mutex_t s_notice_new_sms_mutex  = PTHREAD_MUTEX_INITIALIZER;

+static pthread_cond_t s_notice_new_sms_cond = PTHREAD_COND_INITIALIZER;

+

+//static int s_module_isDial = 0;

+//static pthread_mutex_t call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;

+//static pthread_cond_t call_state_change_cond = PTHREAD_COND_INITIALIZER;

+//static int s_CallId = 0;

+//static pthread_mutex_t s_call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;

+//static pthread_cond_t s_call_state_change_cond = PTHREAD_COND_INITIALIZER;

+

+

+static char *strdupReadString(Parcel* &p) {

+    size_t stringlen;

+    const char16_t *s16;

+    s16 = p->readString16Inplace(&stringlen);

+    return strndup16to8(s16, stringlen);

+}

+

+void lynqNoticeGetModuleNewSms()

+{

+    pthread_mutex_lock(&s_notice_new_sms_mutex);

+    pthread_cond_signal(&s_notice_new_sms_cond);

+    pthread_mutex_unlock(&s_notice_new_sms_mutex);

+    

+}

+

+void lynqNoticeWaitModuleNewSms()

+{

+    pthread_mutex_lock(&s_notice_new_sms_mutex);

+    pthread_cond_wait(&s_notice_new_sms_cond, &s_notice_new_sms_mutex);

+    pthread_mutex_unlock(&s_notice_new_sms_mutex);

+}

+

+int lynq_sms_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;

+}

+

+/*

+Converts an array to a hexadecimal string

+*/

+void ArrayToStr(unsigned char *Buff, unsigned int BuffLen, char *OutputStr)

+{

+    int i = 0;

+    char TempBuff[MSG_MAX_LEN * 2 +1] = {0};

+    char strBuff[MSG_MAX_LEN * 2 +1] = {0};

+

+    for(i = 0; i<BuffLen;i++)

+    {

+        sprintf(TempBuff,"%02x",(unsigned char)Buff[i]);

+        strncat(strBuff,TempBuff,BuffLen*2);

+    }

+    strncpy(OutputStr, strBuff, BuffLen*2);

+    return;

+}

+

+int lynq_send_sms(char telephony_num[TELEPHONE_NUM_LEN], int charset, char *msg, int msglen)

+{

+    LYINFLOG("charset is %d, msglen %d\n", charset, msglen);

+    if(msglen > MSG_MAX_LEN || msglen < 0)

+    {

+        LYERRLOG("msglen out of the range");

+        return LYNQ_E_SMS_MSGLEN_OUT_OF_RANGE;

+    }

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    Parcel* p=NULL;

+    if(charset == 1)//means 8 bit

+    {

+        char msg_e_b[msglen*2+1] = {0};// +1 for end of string.*2:A char array contains two elements of a string for each value

+        ArrayToStr(msg, msglen, msg_e_b);

+        LYINFLOG("tel, charset, msg_e_b: %s, %d, %s", telephony_num, charset, msg_e_b);

+        int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SEND_SMS,3,"%s %d %s",telephony_num, charset, msg_e_b);

+        if(ret!=RESULT_OK)

+        {

+            LYERRLOG("%s  8bit send error %d",__func__,__LINE__);

+            return ret;

+        }

+        delete p;

+        return RESULT_OK;

+    }

+    else//other bit

+    {

+        int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SEND_SMS,3,"%s %d %s",telephony_num, charset, msg);

+        if(ret!=RESULT_OK)

+        {

+            LYERRLOG("%s  7bit send error %d",__func__,__LINE__);

+            return ret;

+        }

+        delete p;

+        return RESULT_OK;

+    }

+}

+

+int lynq_read_sms(int index,int *status,int *charset,char smsc[SMSC_MAX_LEN],int *smscLen,int *smslen,char message[MSG_MAX_LEN],char teleNum[TELEPHONE_NUM_LEN],int *numLen,int *current,int *total)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,LYNQ_REQUEST_READ_SMS_FROM_MEMORY,1,"%d",index);

+    if(ret!=0)

+    {

+        return ret;

+    }

+    LYDBGLOG("LYNQ_REQUEST_READ_SMS_FROM_MEMORY SUCCESS!");

+    p->readInt32(&index);

+    p->readInt32(status);

+    p->readInt32(charset);

+    /*lei add for gws 2022/5/12*/

+    p->readInt32(current);

+    p->readInt32(total);

+    /*lei add for gws 2022/5/12*/

+    char *phone_num = NULL;

+    phone_num = strdupReadString(p);

+    *numLen = strlen(phone_num);

+    strcpy(teleNum, phone_num);

+    char *smscenter = NULL;

+    smscenter = strdupReadString(p);

+    *smscLen = strlen(smscenter);

+    strcpy(smsc,smscenter);

+    char *msg = NULL;

+    msg = strdupReadString(p);

+    *smslen = strlen(msg);

+    strcpy(message,msg);

+    free(phone_num);

+    free(smscenter);

+    free(msg);

+    delete p;

+    return RESULT_OK;

+}

+

+int lynq_get_smsc_address(char service_num[SMSC_MAX_LEN])

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_GET_SMSC_ADDRESS,0,"");

+    if(ret!=0)

+    {

+        return ret;

+    }

+    LYDBGLOG("lynq_get_smsc_address SUCCESS!");

+    char *temp = strdupReadString(p);

+    strcpy(service_num, temp);

+    free(temp);

+    delete p;

+    return RESULT_OK;

+}

+

+int lynq_wait_receive_new_sms(int *handle)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    if(handle==NULL)

+    {

+        LYERRLOG("handle is null!!!");

+        return LYNQ_E_NULL_ANONALY;

+    }

+    lynqNoticeWaitModuleNewSms();

+    *handle = sms_storage_index;

+    return RESULT_OK;

+}

+

+int lynq_set_smsc_address(const char* service_num)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_SET_SMSC_ADDRESS,1,"%s", service_num);

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s  8bit send error %d",__func__,__LINE__);

+        return ret;

+    }

+    LYDBGLOG("lynq_set_smsc_address SUCCESS!");

+    delete p;

+    return RESULT_OK;

+}

+

+int lynq_list_sms(char index_list[SMS_NUM_MAX])

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,LYNQ_REQUEST_LIST_SMS_FROM_MEMORY,0,"");

+    if(ret!=0)

+    {

+        return ret;

+    }

+    LYDBGLOG("lynq_list_sms SUCCESS!");

+    char *temp = strdupReadString(p);

+    strcpy(index_list, temp);

+    free(temp);

+    delete p;

+    return RESULT_OK;

+}

+

+int lynq_delete_sms(int index)

+{

+    if(g_module_init_flag != MODULE_RUNNING)

+    {

+        LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

+        return LYNQ_E_CONFLICT;

+    }

+    Parcel* p=NULL;

+    int ret=lynq_send_common_request(p,g_wait_time,LYNQ_REQUEST_DELETE_SMS_FROM_MEMORY,1,"%d", index);

+

+    if(ret!=RESULT_OK)

+    {

+        LYERRLOG("%s  8bit send error %d",__func__,__LINE__);

+        return ret;

+    }

+    LYDBGLOG("lynq_delete_sms SUCCESS!");

+    delete p;

+    return RESULT_OK;

+}

+

+bool is_support_urc(int urc_id)

+{

+    switch(urc_id)

+    {

+        case RIL_UNSOL_RESPONSE_NEW_SMS:

+            return true;

+        default:

+            return false;

+    }

+}

+

+int lynq_sms_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;

+}

+

+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_RESPONSE_NEW_SMS://new sms received

+        {

+            LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d",resp_type,urcid,slot_id);

+            char *msg = NULL;

+            int index = 0;

+            msg = strdupReadString(p);

+            p->readInt32(&index);

+            sms_storage_index = index;

+            lynqNoticeGetModuleNewSms();

+            free(msg);

+            break;

+        }

+        default:

+            break;

+    }

+}

+

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sms/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-sms/makefile
new file mode 100755
index 0000000..b316414
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sms/makefile
@@ -0,0 +1,74 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -std=c++11 \
+                -g -Os \
+                -flto \
+                -DRIL_SHLIB \
+                -DATCI_PARSE \
+                -fPIC \
+                -DKEEP_ALIVE \
+                -DECALL_SUPPORT \
+                -fpermissive \
+
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0
+endif
+
+$(warning ################# lynq data demo ROOT: $(ROOT),includedir:$(includedir))
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH)/include/libsms \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/liblog \
+  -I$(ROOT)$(includedir)/vendor-ril \
+  -I$(ROOT)$(includedir)/lynq_shm \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -llog \
+    -lcutils \
+    -lutils \
+    -lbinder \
+    -lpthread \
+    -llynq-log \
+    -llynq-shm \
+
+SOURCES = $(wildcard *.cpp)
+
+EXECUTABLE = liblynq-sms.so
+
+OBJECTS=$(SOURCES:.cpp=.o)
+
+
+.PHONY: build clean install pack_rootfs 
+all: build
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+build:  $(EXECUTABLE)
+	$(warning ########## build $(EXECUTABLE)  ##########)
+install:
+	mkdir -p $(ROOT)$(base_libdir)/
+	install $(EXECUTABLE) $(ROOT)$(base_libdir)/
+	mkdir -p $(ROOT)$(includedir)/$(NAME)/sdk
+pack_rootfs:
+	mkdir -p $(PACK_INITRAMFS_TO)$(base_libdir)/
+	cp -af $(EXECUTABLE) $(PACK_INITRAMFS_TO)$(base_libdir)/
+	$(CROSS)strip $(PACK_INITRAMFS_TO)$(base_libdir)/$(EXECUTABLE)
+	mkdir -p $(PACK_TO)$(base_libdir)/
+	cp -af $(EXECUTABLE) $(PACK_TO)$(base_libdir)/
+	$(CROSS)strip $(PACK_TO)$(base_libdir)/$(EXECUTABLE)
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
+	-find . -name "*.o" -delete
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/Parcel.cpp b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/Parcel.cpp
index b5b73f1..d1d56ee 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/Parcel.cpp
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/Parcel.cpp
@@ -1320,6 +1320,15 @@
     return readAligned<int32_t>();
 }
 
+status_t Parcel::readUint32(uint32_t *pArg) const
+{
+    return readAligned(pArg);
+}
+
+uint32_t Parcel::readUint32() const
+{
+    return readAligned<uint32_t>();
+}
 
 status_t Parcel::readInt64(int64_t *pArg) const
 {
@@ -1332,6 +1341,16 @@
     return readAligned<int64_t>();
 }
 
+status_t Parcel::readUint64(uint64_t *pArg) const
+{
+    return readAligned(pArg);
+}
+
+uint64_t Parcel::readUint64() const
+{
+    return readAligned<uint64_t>();
+}
+
 status_t Parcel::readPointer(uintptr_t *pArg) const
 {
     status_t ret;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/include/binder/Parcel.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/include/binder/Parcel.h
index 677e2a0..4b4125d 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/include/binder/Parcel.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/binder/include/binder/Parcel.h
@@ -166,8 +166,12 @@
 const void*         readInplace(size_t len) const;
 int32_t             readInt32() const;
 status_t            readInt32(int32_t *pArg) const;
+uint32_t            readUint32() const;
+status_t            readUint32(uint32_t *pArg) const;
 int64_t             readInt64() const;
 status_t            readInt64(int64_t *pArg) const;
+uint64_t            readUint64() const;
+status_t            readUint64(uint64_t *pArg) const;
 float               readFloat() const;
 status_t            readFloat(float *pArg) const;
 double              readDouble() const;