Merge "[Bugfix][T800][bug-view-218]Fix the issue of incomplete display caused by long data"
diff --git a/IC_meta/mtk/2735/liblynq-sdk-ready/liblynq-sdk-ready.bb b/IC_meta/mtk/2735/liblynq-sdk-ready/liblynq-sdk-ready.bb
new file mode 100755
index 0000000..dc2f062
--- /dev/null
+++ b/IC_meta/mtk/2735/liblynq-sdk-ready/liblynq-sdk-ready.bb
@@ -0,0 +1,34 @@
+inherit externalsrc package workonsrc

+

+DESCRIPTION = "lynq sdk ready"

+LICENSE = "CLOSED"

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

+DEPENDS += "platform-libs liblynq-sim liblynq-uci liblynq-misc"

+

+WORKONSRC = "${TOPDIR}/../LYNQ_PUBLIC/common_src/lib/liblynq-sdk-ready"

+TARGET_CC_ARCH += "${LDFLAGS}"

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

+               ${base_bindir}\

+               ${base_sbindir}"

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

+do_compile () {

+	if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then

+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"

+	else

+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"

+	fi

+}

+

+do_install() {

+	install -d ${D}${base_libdir}/

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

+	install ${S}liblynq-sdk-ready.so ${D}${base_libdir}/

+	install ${S}include/lynq_sdk_ready.h ${D}${includedir}/

+}

diff --git a/IC_meta/mtk/2735/packagegroups/packagegroup-lynq-mt2735.bb b/IC_meta/mtk/2735/packagegroups/packagegroup-lynq-mt2735.bb
index a93698d..67e3acb 100755
--- a/IC_meta/mtk/2735/packagegroups/packagegroup-lynq-mt2735.bb
+++ b/IC_meta/mtk/2735/packagegroups/packagegroup-lynq-mt2735.bb
@@ -59,4 +59,5 @@
     liblynq-at-fota \
     liblynq-bootctrl \
     libdlta \
+    liblynq-sdk-ready \
     "
diff --git a/IC_src/mtk/telephonyware/3.0/hardware/ril/fusion/libril/rilmipc/telephony/data/RpDataController.cpp b/IC_src/mtk/telephonyware/3.0/hardware/ril/fusion/libril/rilmipc/telephony/data/RpDataController.cpp
index 0fe5cdf..7bbbad7 100755
--- a/IC_src/mtk/telephonyware/3.0/hardware/ril/fusion/libril/rilmipc/telephony/data/RpDataController.cpp
+++ b/IC_src/mtk/telephonyware/3.0/hardware/ril/fusion/libril/rilmipc/telephony/data/RpDataController.cpp
@@ -101,7 +101,7 @@
 #if 1
     RFX_LOG_D(RFX_LOG_TAG, "%s dump DataCall Act begin", __FUNCTION__);
 
-    RFX_LOG_D(RFX_LOG_TAG, "%s result_code[%d] id[%d] apn[%s] pdp_type[%d] interface_id[%d]", __FUNCTION__, \
+    RFX_LOG_E(RFX_LOG_TAG, "%s result_code[%d] id[%d] apn[%s] pdp_type[%d] interface_id[%d]", __FUNCTION__, \
         dataCall->result_code, dataCall->id, dataCall->apn, dataCall->pdp_type, dataCall->interface_id);
 
     for (i = 0; i < dataCall->v4_addr_count; i++){
@@ -446,7 +446,7 @@
     mipc_data_call_deact_struct *result_ptr, void *cb_priv_ptr) {
     PdnInfo pdn_info;
 
-    RFX_LOG_D(RFX_LOG_TAG,"%s %d  sim_ps_id[%d] result_ptr[%p]",__FUNCTION__, __LINE__, sim_ps_id, result_ptr);
+    RFX_LOG_E(RFX_LOG_TAG,"%s %d  sim_ps_id[%d] result_ptr[%p]",__FUNCTION__, __LINE__, sim_ps_id, result_ptr);
 
     if (result_ptr == NULL){
         return;
@@ -485,7 +485,7 @@
     mipc_data_set_data_allow_struct_v *result_ptr,
     void *cb_priv_ptr) {
 
-    RFX_LOG_D(RFX_LOG_TAG,"%s %d  sim_ps_id[%d] result_ptr[%p]",__FUNCTION__, __LINE__, sim_ps_id, result_ptr);
+    RFX_LOG_E(RFX_LOG_TAG,"%s %d  sim_ps_id[%d] result_ptr[%p]",__FUNCTION__, __LINE__, sim_ps_id, result_ptr);
 
     if (result_ptr == NULL){
         return;
@@ -531,7 +531,7 @@
     int i = 0;
     RfxController::onInit();  // Required: invoke super class implementation
 
-    RFX_LOG_D(RFX_LOG_TAG, "RpDataController onInit");
+    RFX_LOG_E(RFX_LOG_TAG, "RpDataController onInit");
 
     for (i = 0; i < 2; i++) {
         if (m_mipcIndType[i]){
@@ -596,7 +596,7 @@
 
     registerToHandleUrc(urc_id_list, (sizeof(urc_id_list)/sizeof(int)));
 
-    RFX_LOG_D(RFX_LOG_TAG, "RpDataController onInit done");
+    RFX_LOG_E(RFX_LOG_TAG, "RpDataController onInit done");
 }
 
 void RpDataController::onDeinit() {
@@ -1945,7 +1945,7 @@
 
 
 void RpDataController::handleSetupDataRequest(const sp<RfxMessage>& request) {
-    RFX_LOG_D(RFX_LOG_TAG, "%s:%d  slotid[%d] clientid[%d] token[%d]", __FUNCTION__ ,  __LINE__, \
+    RFX_LOG_E(RFX_LOG_TAG, "%s:%d  slotid[%d] clientid[%d] token[%d]", __FUNCTION__ ,  __LINE__, \
                 request->getSlotId(), request->getClientId(), request->getToken());
     char *apn_ptr = NULL;
     char *protocol = NULL;
@@ -2232,7 +2232,7 @@
     int count = 0;
     int cid = -1;
     int result = -1;
-    RFX_LOG_D(RFX_LOG_TAG, "%s:%d  slotid[%d] clientid[%d] token[%d]", __FUNCTION__ ,  __LINE__, \
+    RFX_LOG_E(RFX_LOG_TAG, "%s:%d  slotid[%d] clientid[%d] token[%d]", __FUNCTION__ ,  __LINE__, \
                 request->getSlotId(), request->getClientId(), request->getToken());
     Parcel *request_parcel = NULL;
     request_parcel = request->getParcel();
@@ -2247,7 +2247,7 @@
     int ip_src[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
 
     result = mipc_data_set_ip_tuple_packet_filter(slot_id_to_mipc_sim_id(request->getSlotId()),0,cid,IP_TYPE,PROTOCOL,ip_src,ip_dst,SRC_PORT,DST_PORT);
-    RFX_LOG_D(RFX_LOG_TAG,"%s,result = %d",__FUNCTION__,result);
+    RFX_LOG_E(RFX_LOG_TAG,"%s,result = %d",__FUNCTION__,result);
     if(result != 0)
     {
         rfx_enqueue_response_message(NULL, request->getRilToken(),(RIL_SOCKET_ID)request->getSlotId(), RIL_E_GENERIC_FAILURE);
@@ -2269,7 +2269,7 @@
     int cid = -1;
     int result = -1;
     int operation = -1;
-    RFX_LOG_D(RFX_LOG_TAG, "%s:%d  slotid[%d] clientid[%d] token[%d]", __FUNCTION__ ,  __LINE__, \
+    RFX_LOG_E(RFX_LOG_TAG, "%s:%d  slotid[%d] clientid[%d] token[%d]", __FUNCTION__ ,  __LINE__, \
                 request->getSlotId(), request->getClientId(), request->getToken());
     Parcel *request_parcel = NULL;
     request_parcel = request->getParcel();
@@ -2279,7 +2279,7 @@
 
     RFX_LOG_D(RFX_LOG_TAG, "count = %d,cid = %d,operation = %d",count,cid,operation);
 
-    result = mipc_data_set_ip_tuple_packet_filter_mode(slot_id_to_mipc_sim_id(request->getSlotId()),0,cid,operation);
+    result = mipc_data_set_ip_tuple_packet_filter_mode(slot_id_to_mipc_sim_id(request->getSlotId()),2,cid,operation);
     RFX_LOG_D(RFX_LOG_TAG,"%s,result = %d",__FUNCTION__,result);
     
     if(result != 0)
@@ -2297,7 +2297,7 @@
 
 void RpDataController::handleGetIpTupleFilter(const sp<RfxMessage>& request)
 {
-    RFX_LOG_D(RFX_LOG_TAG, "%s:%d  slotid[%d] clientid[%d] token[%d]", __FUNCTION__ ,  __LINE__, \
+    RFX_LOG_E(RFX_LOG_TAG, "%s:%d  slotid[%d] clientid[%d] token[%d]", __FUNCTION__ ,  __LINE__, \
                 request->getSlotId(), request->getClientId(), request->getToken());
     int count = 0;
     int cid = -1;
@@ -2311,7 +2311,7 @@
     request_parcel->readInt32(&count);
     request_parcel->readInt32(&cid);
 
-    RFX_LOG_D(RFX_LOG_TAG, "count = %d,cid = %d",count,cid);
+    RFX_LOG_E(RFX_LOG_TAG, "count = %d,cid = %d",count,cid);
     result = mipc_data_get_ip_tuple_packet_filter(slot_id_to_mipc_sim_id(request->getSlotId()), 0, cid, &filter_count, &filter_mode);
     RFX_LOG_D(RFX_LOG_TAG,"%s,result = %d",__FUNCTION__,result);
     if(result != 0)
@@ -2331,7 +2331,7 @@
 
 void RpDataController::handleDelIpTupleFilter(const sp<RfxMessage>& request)
 {
-    RFX_LOG_D(RFX_LOG_TAG, "%s:%d  slotid[%d] clientid[%d] token[%d]", __FUNCTION__ ,  __LINE__, \
+    RFX_LOG_E(RFX_LOG_TAG, "%s:%d  slotid[%d] clientid[%d] token[%d]", __FUNCTION__ ,  __LINE__, \
                 request->getSlotId(), request->getClientId(), request->getToken());
     int count = 0;
     int cid = -1;
@@ -2341,7 +2341,7 @@
     request_parcel->readInt32(&count);
     request_parcel->readInt32(&cid);
 
-    RFX_LOG_D(RFX_LOG_TAG, "count = %d,cid = %d",count,cid);
+    RFX_LOG_E(RFX_LOG_TAG, "count = %d,cid = %d",count,cid);
     result = mipc_data_del_ip_tuple_packet_filter(slot_id_to_mipc_sim_id(request->getSlotId()), 0, cid);
     RFX_LOG_D(RFX_LOG_TAG,"%s,result = %d",__FUNCTION__,result);
 
@@ -2357,4 +2357,4 @@
         rfx_enqueue_response_message(p,request->getRilToken(),(RIL_SOCKET_ID)request->getSlotId(),RIL_E_SUCCESS);
     }
     
-}
\ No newline at end of file
+}
diff --git a/IC_src/mtk/telephonyware/3.0/hardware/ril/platformlib/libmipc/lib/src/api/mipc_data_api.c b/IC_src/mtk/telephonyware/3.0/hardware/ril/platformlib/libmipc/lib/src/api/mipc_data_api.c
index faee7f4..d675655 100644
--- a/IC_src/mtk/telephonyware/3.0/hardware/ril/platformlib/libmipc/lib/src/api/mipc_data_api.c
+++ b/IC_src/mtk/telephonyware/3.0/hardware/ril/platformlib/libmipc/lib/src/api/mipc_data_api.c
@@ -1295,7 +1295,7 @@
     mipc_api_result_enum ret = MIPC_API_RESULT_FAIL;
 
     //add tlv
-    if(global_set == 1)
+    if(global_set == 1 || global_set == 2)
     {
         mipc_data_set_ip_tuple_packet_filter_mode_req_add_global_set(msg_req_ptr,global_set);
     }
diff --git a/IC_src/mtk/telephonyware/3.0/libvendor-ril/mtk-rilproxy/telephony/data/DcTracker.cpp b/IC_src/mtk/telephonyware/3.0/libvendor-ril/mtk-rilproxy/telephony/data/DcTracker.cpp
index 96d2901..37ceafd 100755
--- a/IC_src/mtk/telephonyware/3.0/libvendor-ril/mtk-rilproxy/telephony/data/DcTracker.cpp
+++ b/IC_src/mtk/telephonyware/3.0/libvendor-ril/mtk-rilproxy/telephony/data/DcTracker.cpp
@@ -163,7 +163,7 @@
     string apnType = std::string(apnInfo);
     RpDataUtils::freeMemory(apnInfo);
 
-    RFX_LOG_D(RFX_LOG_TAG, "requestNetwork with apnType: %s, with request %s, and the mapped token: %d",
+    RFX_LOG_E(RFX_LOG_TAG, "requestNetwork with apnType: %s, with request %s, and the mapped token: %d",
             apnType.c_str(), RpDataUtils::requestOrUrcToString(request->getId()), request->getToken());
 
     if (!DcTracker::isValidRequest(apnType)) {
@@ -173,13 +173,13 @@
     RFX_LOG_D(RFX_LOG_TAG, "requestNetwork with valid apn type.");
     if(DcTracker::mApnContexts.find(apnType)==DcTracker::mApnContexts.end())
     {
-        RFX_LOG_D(RFX_LOG_TAG, "requestNetwork no APN DB not support.");
+        RFX_LOG_E(RFX_LOG_TAG, "requestNetwork no APN DB not support.");
         return;
     }
     ApnContext *apnContext = DcTracker::mApnContexts.find(apnType)->second;
     if(apnContext == NULL)
     {
-        RFX_LOG_D(RFX_LOG_TAG, "requestNetwork no APN DB exist.");
+        RFX_LOG_E(RFX_LOG_TAG, "requestNetwork no APN DB exist.");
         return;
     }
     apnContext->incRefCount();
@@ -189,7 +189,7 @@
 
         DcTracker::trySetupData(apnType, request, "user requested");
     } else {
-        RFX_LOG_D(RFX_LOG_TAG, "requestNetwork with apnType: %s , apnContext->getRefCount()=%d already exist, ignore "
+        RFX_LOG_E(RFX_LOG_TAG, "requestNetwork with apnType: %s , apnContext->getRefCount()=%d already exist, ignore "
             "this request!!!",apnType.c_str(), apnContext->getRefCount(), RpDataUtils::apnState2string(apnContext->getState()));
 
          apnContext->notifyStateChange(apnContext->getState());
@@ -214,7 +214,7 @@
     // get the requested apn
     string requestApn = std::string(apnInfo);
     RpDataUtils::freeMemory(apnInfo);
-    RFX_LOG_D(RFX_LOG_TAG, "deactiveNetwork with apnType: %s, with request %s, with token: %d, source %d,request=%X",
+    RFX_LOG_E(RFX_LOG_TAG, "deactiveNetwork with apnType: %s, with request %s, with token: %d, source %d,request=%X",
             requestApn.c_str(), RpDataUtils::requestOrUrcToString(request->getId()),
             request->getToken(),request->getSource(),request);
 
@@ -235,11 +235,11 @@
 
         DcTracker::cleanUpConnection(requestApn, request);
     } else if (apnContext->getRefCount() < 1) {
-        RFX_LOG_D(RFX_LOG_TAG, "deactiveNetwork with apnType: %s don't exist, ignore this request!!!", requestApn.c_str());
+        RFX_LOG_E(RFX_LOG_TAG, "deactiveNetwork with apnType: %s don't exist, ignore this request!!!", requestApn.c_str());
         apnContext->notifyStateChange(RIL_Data_Call_PdnState::PDN_DISCONNECTED);
     } else {
         apnContext->decRefCount();
-        RFX_LOG_D(RFX_LOG_TAG, "deactiveNetwork with apnType: %s is using, ignore this request!!!", requestApn.c_str());
+        RFX_LOG_E(RFX_LOG_TAG, "deactiveNetwork with apnType: %s is using, ignore this request!!!", requestApn.c_str());
         apnContext->notifyStateChange(apnContext->getState());
     }
 }
@@ -477,7 +477,7 @@
 }
 
 void DcTracker::trySetupData(string apnType, const sp<RfxMessage>& request, string reason) {
-    RFX_LOG_D(RFX_LOG_TAG, "trySetupData with apn type: %s, with reason: %s",
+    RFX_LOG_E(RFX_LOG_TAG, "trySetupData with apn type: %s, with reason: %s",
                     apnType.c_str(), reason.c_str());
 
     ApnContext *apnContext = DcTracker::mApnContexts.find(apnType)->second;
@@ -498,7 +498,7 @@
             RFX_LOG_D(RFX_LOG_TAG, "trySetupData set WaitingApns size=%d ", waitingApns.size());
             if (waitingApns.size() == 0) {
 
-                RFX_LOG_D(RFX_LOG_TAG, "trySetupData with apnType: %s ,but not find valid apn setting!!!! ",
+                RFX_LOG_E(RFX_LOG_TAG, "trySetupData with apnType: %s ,but not find valid apn setting!!!! ",
                          (apnContext->getApnType()).c_str());
 
                 apnContext->setSate(RIL_Data_Call_PdnState::PDN_IDLE);
diff --git a/IC_src/mtk/telephonyware/3.0/libvendor-ril/mtk-rilproxy/telephony/data/RpDataController.cpp b/IC_src/mtk/telephonyware/3.0/libvendor-ril/mtk-rilproxy/telephony/data/RpDataController.cpp
index 7d51994..5406f29 100755
--- a/IC_src/mtk/telephonyware/3.0/libvendor-ril/mtk-rilproxy/telephony/data/RpDataController.cpp
+++ b/IC_src/mtk/telephonyware/3.0/libvendor-ril/mtk-rilproxy/telephony/data/RpDataController.cpp
@@ -136,7 +136,7 @@
 }
 
 bool RpDataController::onHandleRequest(const sp<RfxMessage>& message) {
-    logD(RFX_LOG_TAG, "Handle request %s", RpDataUtils::requestOrUrcToString(message->getId()));
+    logE(RFX_LOG_TAG, "Handle request %s", RpDataUtils::requestOrUrcToString(message->getId()));
 
     switch (message->getId()) {
     case RIL_REQUEST_SETUP_DATA_CALL:
@@ -173,7 +173,7 @@
 }
 
 bool RpDataController::onHandleResponse(const sp<RfxMessage>& message) {
-    logD(RFX_LOG_TAG, "Handle response %s.", RpDataUtils::requestOrUrcToString(message->getId()));
+    logE(RFX_LOG_TAG, "Handle response %s.", RpDataUtils::requestOrUrcToString(message->getId()));
 
     switch (message->getId()) {
     case RIL_REQUEST_SETUP_DATA_CALL:
@@ -275,7 +275,7 @@
 }
 
 void RpDataController::handleSetupDataResponse(const sp<RfxMessage>& response) {
-    logD(RFX_LOG_TAG, "handleSetupDataResponse with clientId: %d, with token: %d",
+    logE(RFX_LOG_TAG, "handleSetupDataResponse with clientId: %d, with token: %d",
             response->getClientId(), response->getToken());
 
     if (response->getClientId() > 0 || mDcTracker.isLocalSetupPdnRequest(response)) {
@@ -286,7 +286,7 @@
 }
 
 void RpDataController::handleDeactivateDataResponse(const sp<RfxMessage>& response) {
-    logD(RFX_LOG_TAG, "handleSetupDataResponse with clientId: %d, with token: %d",
+    logE(RFX_LOG_TAG, "handleSetupDataResponse with clientId: %d, with token: %d",
             response->getClientId(), response->getToken());
 
     if (response->getClientId() > 0) {
@@ -575,7 +575,7 @@
         result = true;
     }
 
-    logD(RFX_LOG_TAG, "RpDataController::isAllCallingStateIdle, with result: %s", RpDataUtils::b2s(result).c_str());
+    logE(RFX_LOG_TAG, "RpDataController::isAllCallingStateIdle, with result: %s", RpDataUtils::b2s(result).c_str());
     return result;
 }
 
@@ -593,7 +593,7 @@
     bool result = false;
     result = getStatusManager()->getBoolValue(RFX_STATUS_KEY_PS_RESTRICT_STATE, false);
 
-    logD(RFX_LOG_TAG, "RpDataController::isPsRestricted, with result: %s", RpDataUtils::b2s(result).c_str());
+    logE(RFX_LOG_TAG, "RpDataController::isPsRestricted, with result: %s", RpDataUtils::b2s(result).c_str());
 
     return result;
 }
@@ -612,7 +612,7 @@
     RfxNwServiceState ss = getStatusManager()->getServiceStateValue(RFX_STATUS_KEY_SERVICE_STATE);
     result = ss.isInService(ss.getRilDataRegState());
  
-    logD(RFX_LOG_TAG, "RpDataController::isAttached, with result: %s", RpDataUtils::b2s(result).c_str());
+    logE(RFX_LOG_TAG, "RpDataController::isAttached, with result: %s", RpDataUtils::b2s(result).c_str());
 
     if (!result) {
         sp<RfxMessage> Req = RfxMessage::obtainRequest(m_slot_id,
diff --git a/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_custom/mipc.release.tar.gz b/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_custom/mipc.release.tar.gz
index caf7e60..eccf07d 100644
--- a/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_custom/mipc.release.tar.gz
+++ b/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_custom/mipc.release.tar.gz
Binary files differ
diff --git a/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_wide_temp_b30rx_custom/mipc.release.tar.gz b/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_wide_temp_b30rx_custom/mipc.release.tar.gz
index caf7e60..eccf07d 100644
--- a/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_wide_temp_b30rx_custom/mipc.release.tar.gz
+++ b/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_wide_temp_b30rx_custom/mipc.release.tar.gz
Binary files differ
diff --git a/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_wide_temp_custom/mipc.release.tar.gz b/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_wide_temp_custom/mipc.release.tar.gz
index caf7e60..eccf07d 100644
--- a/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_wide_temp_custom/mipc.release.tar.gz
+++ b/IC_src/mtk/telephonyware/3.0/mipc/mt2735_ivt_nlwg_wide_temp_custom/mipc.release.tar.gz
Binary files differ
diff --git a/IC_src/mtk/telephonyware/3.0/mipc/mt6890_evb_nlwg_custom/mipc.release.tar.gz b/IC_src/mtk/telephonyware/3.0/mipc/mt6890_evb_nlwg_custom/mipc.release.tar.gz
index caf7e60..eccf07d 100644
--- a/IC_src/mtk/telephonyware/3.0/mipc/mt6890_evb_nlwg_custom/mipc.release.tar.gz
+++ b/IC_src/mtk/telephonyware/3.0/mipc/mt6890_evb_nlwg_custom/mipc.release.tar.gz
Binary files differ
diff --git a/common_src/framework/lynq-ril-service/src/data/data_gdbus.cpp b/common_src/framework/lynq-ril-service/src/data/data_gdbus.cpp
index 5b93999..b724d0b 100755
--- a/common_src/framework/lynq-ril-service/src/data/data_gdbus.cpp
+++ b/common_src/framework/lynq-ril-service/src/data/data_gdbus.cpp
@@ -447,7 +447,7 @@
 
 void dumpResponse(MTK_Data_Call_Response_v1 *dataCallResponse)
 {
-    RLOGD("dumpResponse: netId: %d, pdnState: %s, status: %d, cId: %d, apnType: %s,"
+    RLOGI("dumpResponse: netId: %d, pdnState: %s, status: %d, cId: %d, apnType: %s,"
             " protocolType: %s, ifaceName: %s, address: %s, dns: %s, gateway: %s, pcscf: %s, mtu: %d, apn: %s",
             dataCallResponse->netId, apnState2string(RIL_Data_Call_PdnState(dataCallResponse->pdnState)),
             dataCallResponse->status, dataCallResponse->cId, dataCallResponse->apnType, dataCallResponse->type,
diff --git a/common_src/framework/lynq-ril-service/src/ril.cpp b/common_src/framework/lynq-ril-service/src/ril.cpp
index 9b5fcc7..7a56fd4 100755
--- a/common_src/framework/lynq-ril-service/src/ril.cpp
+++ b/common_src/framework/lynq-ril-service/src/ril.cpp
@@ -170,6 +170,8 @@
 #define LYNQ_SERVICE_PORT 8088
 #define LYNQ_AT_SERVICE_PORT 8087
 #define LYNQ_BRODCAST_PORT 8086
+#define LYNQ_SDK_READY_IP "127.0.0.1"
+#define LYNQ_SDK_READY_PORT 8157
 #ifdef GSW_RIL_CFG 
 /*Interfaces lo net addr 127.0.0.1,mask 255.0.0.0,so lo broadcast addr is 127.255.255.255*/
 #define LYNQ_RIL_FWK_BROADCAST_IP "127.255.255.255" /*hong.liu change broadcast addr on 2024.2.18*/
@@ -208,13 +210,13 @@
     #define startRequest           sprintf(printBuf, "(")
     #define closeRequest           sprintf(printBuf, "%s)", printBuf)
     #define printRequest(token, req) if(enable_syslog) {         \
-        RLOGD("[%x]> %s %s", token, requestToString(req), printBuf);} else {\
+        RLOGI("[%x]> %s %s", token, requestToString(req), printBuf);} else {\
         printf("[%x]> %s %s\n", token, requestToString(req), printBuf);}
 
     #define startResponse           sprintf(printBuf, "%s {", printBuf)
     #define closeResponse           sprintf(printBuf, "%s}", printBuf)
     #define printResponse            if(enable_syslog) { \
-                                    RLOGD("%s", printBuf); } else { \
+                                    RLOGI("%s", printBuf); } else { \
                                     printf("%s\n", printBuf);}
 
     #define clearPrintBuf           printBuf[0] = 0
@@ -3015,71 +3017,71 @@
         startResponse;
 
 #ifdef TELEMATIC_5G_SUPPORT
-        appendPrintBuf("%s[GW_SS.signalStrength=%d,GW_SS.bitErrorRate=%d,GW_SS.timingAdvance=%d,\
-                CDMA_SS.dbm=%d,CDMA_SS.ecio=%d,\
-                EVDO_SS.dbm=%d,EVDO_SS.ecio=%d,EVDO_SS.signalNoiseRatio=%d,\
-                LTE_SS.signalStrength=%d,LTE_SS.rsrp=%d,LTE_SS.rsrq=%d,LTE_SS.rssnr=%d,LTE_SS.cqi=%d,LTE_SS.timingAdvance=%d,\
-                TDSCDMA_SS.signalStrength=%d,TDSCDMA_SS.bitErrorRate=%d,TDSCDMA_SS.rscp=%d,\
-                WCDMA_SS.signalStrength=%d,WCDMA_SS.bitErrorRate=%d,WCDMA_SS.rscp=%d,WCDMA_SS.ecno=%d,\
-                NR_SignalStrength.ssRsrp=%d,NR_SignalStrength.ssRsrq=%d,NR_SignalStrength.ssSinr=%d,\
-                NR_SignalStrength.csiRsrp=%d,NR_SignalStrength.csiRsrq=%d,NR_SignalStrength.csiSinr=%d]",
+        appendPrintBuf("%s[GW.rssi=%d,GW.bER=%d,GW.tA=%d,"
+                "W.rssi=%d,W.bER=%d,W.rscp=%d,W.ecno=%d,"                
+                "LTE.rssi=%d,LTE.rsrp=%d,LTE.rsrq=%d,LTE.rssnr=%d,LTE.cqi=%d,LTE.tA=%d,"                
+                "NR.ssRsrp=%d,NR.ssRsrq=%d,NR.ssSinr=%d,"
+                "NR.csiRsrp=%d,NR.csiRsrq=%d,NR.csiSinr=%d"
+                "CD.dbm=%d,CD.ecio=%d,"
+                "EV.dbm=%d,EV.ecio=%d,EV.SNR=%d,"
+                "TD.rssi=%d,TD.bER=%d,TD.rscp=%d]",                
                 printBuf,
                 p_cur->GW_SignalStrength.signalStrength,
                 p_cur->GW_SignalStrength.bitErrorRate,
                 p_cur->GW_SignalStrength.timingAdvance,
-                p_cur->CDMA_SignalStrength.dbm,
-                p_cur->CDMA_SignalStrength.ecio,
-                p_cur->EVDO_SignalStrength.dbm,
-                p_cur->EVDO_SignalStrength.ecio,
-                p_cur->EVDO_SignalStrength.signalNoiseRatio,
+                p_cur->WCDMA_SignalStrength.signalStrength,
+                p_cur->WCDMA_SignalStrength.bitErrorRate,
+                p_cur->WCDMA_SignalStrength.rscp,
+                p_cur->WCDMA_SignalStrength.ecno,               
                 p_cur->LTE_SignalStrength.signalStrength,
                 p_cur->LTE_SignalStrength.rsrp,
                 p_cur->LTE_SignalStrength.rsrq,
                 p_cur->LTE_SignalStrength.rssnr,
                 p_cur->LTE_SignalStrength.cqi,
-                p_cur->LTE_SignalStrength.timingAdvance,
-                p_cur->TD_SCDMA_SignalStrength.signalStrength,
-                p_cur->TD_SCDMA_SignalStrength.bitErrorRate,
-                p_cur->TD_SCDMA_SignalStrength.rscp,
-                p_cur->WCDMA_SignalStrength.signalStrength,
-                p_cur->WCDMA_SignalStrength.bitErrorRate,
-                p_cur->WCDMA_SignalStrength.rscp,
-                p_cur->WCDMA_SignalStrength.ecno,
+                p_cur->LTE_SignalStrength.timingAdvance,             
                 p_cur->NR_SignalStrength.ssRsrp,
                 p_cur->NR_SignalStrength.ssRsrq,
                 p_cur->NR_SignalStrength.ssSinr,
                 p_cur->NR_SignalStrength.csiRsrp,
                 p_cur->NR_SignalStrength.csiRsrq,
-                p_cur->NR_SignalStrength.csiSinr);
-#else
-        appendPrintBuf("%s[GW_SS.signalStrength=%d,GW_SS.bitErrorRate=%d,GW_SS.timingAdvance=%d,\
-                CDMA_SS.dbm=%d,CDMA_SS.ecio=%d,\
-                EVDO_SS.dbm=%d,EVDO_SS.ecio=%d,EVDO_SS.signalNoiseRatio=%d,\
-                LTE_SS.signalStrength=%d,LTE_SS.rsrp=%d,LTE_SS.rsrq=%d,LTE_SS.rssnr=%d,LTE_SS.cqi=%d,LTE_SS.timingAdvance=%d,\
-                TDSCDMA_SS.signalStrength=%d,TDSCDMA_SS.bitErrorRate=%d,TDSCDMA_SS.rscp=%d,\
-                WCDMA_SS.signalStrength=%d,WCDMA_SS.bitErrorRate=%d,WCDMA_SS.rscp=%d,WCDMA_SS.ecno=%d]",
-                printBuf,
-                p_cur->GW_SignalStrength.signalStrength,
-                p_cur->GW_SignalStrength.bitErrorRate,
-                p_cur->GW_SignalStrength.timingAdvance,
+                p_cur->NR_SignalStrength.csiSinr,
                 p_cur->CDMA_SignalStrength.dbm,
                 p_cur->CDMA_SignalStrength.ecio,
                 p_cur->EVDO_SignalStrength.dbm,
                 p_cur->EVDO_SignalStrength.ecio,
                 p_cur->EVDO_SignalStrength.signalNoiseRatio,
+                p_cur->TD_SCDMA_SignalStrength.signalStrength,
+                p_cur->TD_SCDMA_SignalStrength.bitErrorRate,
+                p_cur->TD_SCDMA_SignalStrength.rscp);
+#else
+       appendPrintBuf("%s[GW.rssi=%d,GW.bER=%d,GW.tA=%d,"
+                "W.rssi=%d,W.bER=%d,W.rscp=%d,W.ecno=%d,"                
+                "LTE.rssi=%d,LTE.rsrp=%d,LTE.rsrq=%d,LTE.rssnr=%d,LTE.cqi=%d,LTE.tA=%d,"                
+                "CD.dbm=%d,CD.ecio=%d,"
+                "EV.dbm=%d,EV.ecio=%d,EV.SNR=%d,"
+                "TD.rssi=%d,TD.bER=%d,TD.rscp=%d]",              
+                printBuf,
+                p_cur->GW_SignalStrength.signalStrength,
+                p_cur->GW_SignalStrength.bitErrorRate,
+                p_cur->GW_SignalStrength.timingAdvance,
+                p_cur->WCDMA_SignalStrength.signalStrength,
+                p_cur->WCDMA_SignalStrength.bitErrorRate,
+                p_cur->WCDMA_SignalStrength.rscp,
+                p_cur->WCDMA_SignalStrength.ecno,               
                 p_cur->LTE_SignalStrength.signalStrength,
                 p_cur->LTE_SignalStrength.rsrp,
                 p_cur->LTE_SignalStrength.rsrq,
                 p_cur->LTE_SignalStrength.rssnr,
                 p_cur->LTE_SignalStrength.cqi,
-                p_cur->LTE_SignalStrength.timingAdvance,
+                p_cur->LTE_SignalStrength.timingAdvance,                          
+                p_cur->CDMA_SignalStrength.dbm,
+                p_cur->CDMA_SignalStrength.ecio,
+                p_cur->EVDO_SignalStrength.dbm,
+                p_cur->EVDO_SignalStrength.ecio,
+                p_cur->EVDO_SignalStrength.signalNoiseRatio,
                 p_cur->TD_SCDMA_SignalStrength.signalStrength,
                 p_cur->TD_SCDMA_SignalStrength.bitErrorRate,
-                p_cur->TD_SCDMA_SignalStrength.rscp,
-                p_cur->WCDMA_SignalStrength.signalStrength,
-                p_cur->WCDMA_SignalStrength.bitErrorRate,
-                p_cur->WCDMA_SignalStrength.rscp,
-                p_cur->WCDMA_SignalStrength.ecno);
+                p_cur->TD_SCDMA_SignalStrength.rscp);
 #endif
         closeResponse;
 
@@ -4190,6 +4192,27 @@
     }
 }
 
+int lynq_send_ril_restart()
+{
+    RLOGD("lynq send ril restart");
+    struct sockaddr_in sdk_ready_addr;
+    char BUF[8] = {0};
+    ssize_t sent = 0;
+    memset(&sdk_ready_addr,0,sizeof(sdk_ready_addr));
+    sdk_ready_addr.sin_family = AF_INET;        //IPv4
+    sdk_ready_addr.sin_port = htons(LYNQ_SDK_READY_PORT);
+    sdk_ready_addr.sin_addr.s_addr = inet_addr(LYNQ_SDK_READY_IP);
+    sprintf(BUF,"%d",RIL_UNSOL_TELEPHONY_RESTART);
+    BUF[4]='\0';
+    sent = sendto(lynq_urc_socket_fd,BUF,8,0, (struct sockaddr *)&sdk_ready_addr, sizeof(sdk_ready_addr));
+    if( sent < 0 )
+    {
+        RLOGE("LYNQ_RIL_urcBroadcast send datalen fail (sent=%d, sendFD=%d)",sent,lynq_urc_socket_fd);
+        return -1;
+    }
+    return 0;
+}
+
 static void lynq_get_sim_state(RIL_CardStatus_v6 *card_status)
 {
     g_lynq_sim_state = card_status->card_state;
@@ -4971,6 +4994,11 @@
         handleRingbackTone(data, datalen, soc_id);
         break;
     }
+    case RIL_UNSOL_TELEPHONY_RESTART:
+    {
+        lynq_send_ril_restart();
+        break;
+    }
     default:
         break;
     }
@@ -6220,11 +6248,11 @@
                     //xy.he@20240524 modify for T8TSK-338 start
                     if(client_tmp->request != RIL_REQUEST_MODIFY_APN)
                     {
-                        RLOGD("[LYNQ socketId] utoken=%d,request=%d,len=%d,param=%s",client_tmp->uToken,client_tmp->request,client_tmp->paramLen,client_tmp->param);
+                        RLOGI("[LYNQ socketId] utoken=%d,request=%d,len=%d,param=%s",client_tmp->uToken,client_tmp->request,client_tmp->paramLen,client_tmp->param);
                     }
                     else
                     {
-                        RLOGD("[LYNQ socketId] utoken=%d,request=%d,len=%d,param=(has got)",client_tmp->uToken,client_tmp->request,client_tmp->paramLen);
+                        RLOGI("[LYNQ socketId] utoken=%d,request=%d,len=%d,param=(has got)",client_tmp->uToken,client_tmp->request,client_tmp->paramLen);
                         encode_log(client_tmp->param,6);
                     }
                     //xy.he@20240524 modify for T8TSK-338 end
@@ -6246,11 +6274,11 @@
                     {
                         if(strstr(argv[t],"password") != NULL)
                         {
-                            RLOGD("LYNQ_REQUEST argv[%d]=(has got)\n",t);
+                            RLOGI("LYNQ_REQUEST argv[%d]=(has got)\n",t);
                         }
                         else
                         {
-                            RLOGD("LYNQ_REQUEST argv[%d]=%s\n",t,argv[t]);
+                            RLOGI("LYNQ_REQUEST argv[%d]=%s\n",t,argv[t]);
                         }
                     }
                     //xy.he@20240524 modify for T8TSK-338 end
@@ -6348,18 +6376,16 @@
      return ;
 }
 int LYNQ_RIL_respSocket(Parcel &p,RIL_Token t)
-{
-    RLOGD("LYNQ_RIL_respSocket send start");
+{    
     ssize_t sent = 0;
     RequestInfo *pRI = (RequestInfo *)t;
+    RLOGI("LYNQ_RIL_respSocket token [%x] event %d app_token %d",pRI->token,pRI->lynqEvent,pRI->uToken);
     if(pRI->lynqEvent!=2)
-    {
-        RLOGD("this is internal event!!!");
+    {  
         return -1;
     }
     int dataSize = p.dataSize();
-    const uint8_t* data = p.data();
-    RLOGD("lynqSocketSend RESPONSE!!!! ");
+    const uint8_t* data = p.data();  
     sent = sendto(server_socket_fd, data, dataSize, 0, (struct sockaddr *)&pRI->uClient_addr, sizeof(pRI->uClient_addr));
     if( sent < 0 )
     {
@@ -6370,21 +6396,15 @@
     return 0;
 }
 int LYNQ_RIL_respSocket_sp(Parcel &p,RequestInfo *pRI)
-{
-    RLOGD("LYNQ_RIL_respSocket send start");
-    int ret =0;
-    bool sendResult =false;
-    ssize_t sent = 0;
-    uint8_t dataLength[4];
-    int verify = 0x55aa;
+{    
+    ssize_t sent = 0;   
+    RLOGI("LYNQ_RIL_respSocket token [%x] event %d app_token %d",pRI->token,pRI->lynqEvent,pRI->uToken);    
     int dataSize = p.dataSize();
     const uint8_t* data = p.data();
     if(pRI->lynqEvent!=2)
-    {
-        RLOGD("this is internal event!!!");
+    {        
         return -1;
-    }
-    RLOGD("lynqSocketSend RESPONSE!!!! ");
+    }  
 
     sent = sendto(server_socket_fd, data, dataSize, 0, (struct sockaddr *)&pRI->uClient_addr, sizeof(pRI->uClient_addr));
     if( sent < 0 )
@@ -6434,6 +6454,7 @@
 
 int LYNQ_RIL_urcBroadcast(Parcel &p, int urc_id)
 {
+    printResponse;
     RLOGD("LYNQ_RIL_urcBroadcast send start");
     int ret =0;   
     ssize_t sent = 0;   
diff --git a/common_src/lib/liblynq-call/lynq_call.cpp b/common_src/lib/liblynq-call/lynq_call.cpp
index 0b7e385..43936e7 100755
--- a/common_src/lib/liblynq-call/lynq_call.cpp
+++ b/common_src/lib/liblynq-call/lynq_call.cpp
@@ -1015,7 +1015,7 @@
     } 

     else 

     {

-        LYINFLOG("System uptime is less than 40 seconds.");

+        LYERRLOG("System uptime is less than 40 seconds.");

         FILE *fp = NULL;

         if(check_file_access(CALL_REBOOT_FLAG) != 0)

         {

@@ -1033,6 +1033,17 @@
     return 0;

 

 }

+

+int lynq_call_pre_confirm(int call_type)

+{

+    try_reset_audio_service();

+

+#ifdef GSW_RIL_CFG

+    call_boot_check();

+#endif

+    return RESULT_OK;

+}

+

 int lynq_call(int* handle,char addr[])

 {

     if(g_module_init_flag != MODULE_RUNNING)

@@ -1040,11 +1051,8 @@
         LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

         return LYNQ_E_CONFLICT;

     }

-    try_reset_audio_service();

-

-#ifdef GSW_RIL_CFG

-    call_boot_check();

-#endif

+    

+    (void) lynq_call_pre_confirm(call_type_mo);

 

     int lynq_call_id = -1;

 

@@ -1111,6 +1119,8 @@
         return LYNQ_E_CONFLICT;

     }   

 

+    (void) lynq_call_pre_confirm(call_type_mt);

+

     Parcel* p=NULL;    

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

     if(ret==RESULT_OK)

diff --git a/common_src/lib/liblynq-call/lynq_call_ecall.cpp b/common_src/lib/liblynq-call/lynq_call_ecall.cpp
index 3471245..ce60074 100755
--- a/common_src/lib/liblynq-call/lynq_call_ecall.cpp
+++ b/common_src/lib/liblynq-call/lynq_call_ecall.cpp
@@ -291,6 +291,8 @@
     RIL_ECall_Category ril_ecall_cat = lynq_get_ril_ecall_cat_from_lynq_cat(lynq_ecall_cat);

     char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};

     unsigned int i;          

+

+    (void) lynq_call_pre_confirm(call_type_mo);

    

     if(msd_length > MSD_MAX_LENGTH || msd_length <=0 || lynq_ecall_variant >=LYNQ_ECALL_MO_MAX)

     {

diff --git a/common_src/lib/liblynq-call/lynq_module_common.h b/common_src/lib/liblynq-call/lynq_module_common.h
index b82b2d8..471814f 100755
--- a/common_src/lib/liblynq-call/lynq_module_common.h
+++ b/common_src/lib/liblynq-call/lynq_module_common.h
@@ -92,6 +92,10 @@
 #define MODULE_SWITCHING  (1)

 #define MODULE_RUNNING (2)

 

+#define call_type_mo (0)

+#define call_type_mt (1)

+int lynq_call_pre_confirm(int call_type);

+

 extern int g_module_init_flag;

 

 #endif

diff --git a/common_src/lib/liblynq-network/lynq_network.cpp b/common_src/lib/liblynq-network/lynq_network.cpp
index 7b3f79e..525a74c 100755
--- a/common_src/lib/liblynq-network/lynq_network.cpp
+++ b/common_src/lib/liblynq-network/lynq_network.cpp
@@ -28,6 +28,9 @@
 /*For T800-API-1475, cfun 0 need 7s */

 #define WAIT_TIME_LENGTH_FOR_RADIO_ON (65) 

 

+#define WAIT_TIME_LENGTH_FOR_QUERY_AVAILABLE_NETWORK (600) 

+#define WAIT_TIME_LENGTH_FOR_SET_IMS (65) 

+

 #define SET_SBP_OPEN    " AT+ESBP=5,\"SBP_NRRC_BAR_CELL_WITH_CONNECTION_FAILURE\",1 "

 #define SET_SBP_CLOSE   " AT+ESBP=5,\"SBP_NRRC_BAR_CELL_WITH_CONNECTION_FAILURE\",0 "

 #define QUERY_SBP_STATUS    "AT+ESBP=7,\"SBP_NRRC_BAR_CELL_WITH_CONNECTION_FAILURE\""

@@ -405,6 +408,25 @@
     return RESULT_OK;  

 }

 

+int is_network_registed(char* network_status)

+{

+    if(strcmp(network_status , "registered") != 0 && strcmp(network_status , "current") !=0)  // add by hq on 18/09/2024 for bug-188, registered is for T800, current is for T106

+    {

+        return false;

+    }

+    return true;

+}

+

+int is_network_available(char* network_status)

+{

+    if(strcmp(network_status , "visible") != 0 && strcmp(network_status , "available") !=0)  // add by hq on 18/09/2024 for bug-188, visible is for T800, available is for T106

+    {

+        return false;

+    }

+    return true;

+}

+

+

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

 {

     if(g_module_init_flag != MODULE_RUNNING)

@@ -419,7 +441,7 @@
     }  

 

     Parcel* p=NULL;

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

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

 

     if(ret!=RESULT_OK)

     {

@@ -429,34 +451,59 @@
 

     int num =p->readInt32();

     char *resp[LYNQ_RESP_STRING_MAX_NUM];

+    ret=RESULT_OK;

     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;    

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

+        ret=LYNQ_E_INNER_ERROR;    

     }else{

+        int string_index;

+        int network_index=-1;

         int i;

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

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

         {

-            resp[i] = lynqStrdupReadString(p);

+            resp[string_index] = lynqStrdupReadString(p);

+            if(string_index%4==3) // netstatus is the third word

+            {       

+                /*add by hq on 22/04/2024 for API-1575 */         

+                if(is_network_registed(resp[string_index])) 

+                {   

+                    network_index=string_index/4;                    

+                    break;

+                }  

+                else if(is_network_available(resp[string_index]))

+                {

+                    network_index=string_index/4;

+                }

+            }            

         }

-        if(NULL != resp[0])

+        if(network_index!=-1)

         {

-            strcpy(OperatorFN,resp[0]);

+            int start_index=network_index*4;

+            if(NULL != resp[start_index])

+            {

+                strcpy(OperatorFN,resp[start_index]);

+            }

+            if(NULL != resp[start_index+1])

+            {

+                strcpy(OperatorSH,resp[start_index+1]);

+            }

+            if(NULL != resp[start_index+2])

+            {

+                strcpy(MccMnc,resp[start_index+2]);

+            }

+            if(NULL != resp[start_index+3])

+            {

+                strcpy(NetStatus,resp[start_index+3]);

+            }

         }

-        if(NULL != resp[1])

+        else

         {

-            strcpy(OperatorSH,resp[1]);

+            LYERRLOG("%s no find available network after search %d information element",__func__,string_index);                    

+            ret=LYNQ_E_INNER_ERROR;    

         }

-        if(NULL != resp[2])

-        {

-            strcpy(MccMnc,resp[2]);

-        }

-        if(NULL != resp[3])

-        {

-            strcpy(NetStatus,resp[3]);

-        }

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

+        

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

         {

             if(resp[i]!=NULL)

             {

@@ -464,9 +511,13 @@
             }            

         }

     }

-    delete p;

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

-    return RESULT_OK;  

+    

+    delete p;    

+    if(ret==RESULT_OK)

+    {

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

+    }    

+    return ret;  

 }

 

 int lynq_query_registration_state_from_parcel(Parcel* p, int num,int reject_index, int* regState,char * LAC,char * CID,int *netType,int *netRejected)

@@ -1184,7 +1235,7 @@
     }     

 

     Parcel* p=NULL;

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

+    int ret = lynq_send_common_request(p,WAIT_TIME_LENGTH_FOR_SET_IMS,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);

@@ -1204,48 +1255,45 @@
         LYERRLOG("%s module state %d error",__func__,g_module_init_flag);

         return LYNQ_E_CONFLICT;

     }

-    LYDBGLOG("start get urc info");

+    LYINFLOG("get urc info, handle is %d, slot is %d",handle,s_module_urc_slot_id);

     if(is_support_urc(handle)==false)

     {

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

+        LYERRLOG("not support handle!!!");

         return LYNQ_E_PARAMETER_ANONALY;

     }

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

         (handle !=RIL_UNSOL_SIGNAL_STRENGTH && NULL == slot_id))

     {

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

+        LYERRLOG("solSigStren or slot_id is NULL!!!");

         return LYNQ_E_PARAMETER_ANONALY;

+    }  

+

+    if(slot_id!=NULL)

+    {

+        *slot_id = s_module_urc_slot_id;

     }

-    switch(handle)

-    {        

-        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_signalstrength = s_network_urc_solSigStren.wcdma_signalstrength;

-            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_signalstrength = s_network_urc_solSigStren.lte_signalstrength;

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

-        }

-        default:

-        {

-            *slot_id = s_module_urc_slot_id;

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

-		}

+  

+    if(handle==RIL_UNSOL_SIGNAL_STRENGTH)

+    {

+        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_signalstrength = s_network_urc_solSigStren.wcdma_signalstrength;

+        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_signalstrength = s_network_urc_solSigStren.lte_signalstrength;

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

     }        

     return RESULT_OK;   

 }

diff --git a/common_src/lib/liblynq-sdk-ready/demo_test.cpp b/common_src/lib/liblynq-sdk-ready/demo_test.cpp
new file mode 100755
index 0000000..23716fb
--- /dev/null
+++ b/common_src/lib/liblynq-sdk-ready/demo_test.cpp
@@ -0,0 +1,106 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include "lynq_sdk_ready.h"
+
+int (*sdk_ready_register)(const int uToken,const lynq_sdk_check_param_t* param,lynq_sdk_status_cb sdk_status_cb);
+int (*get_sdk_ready_status)(int *status);
+
+
+int demo_sdk_status_cb(const lynq_sdk_ready_t *sdk_ready, void *reserve)
+{
+    printf("sdk_ready_status:%d,ref_action:%d\n",sdk_ready->sdk_ready_status,sdk_ready->ref_action);
+    return 0;
+}
+
+void help()
+{
+    printf("help:\n\
+    argv[1]:isvalid(0/1)\n\
+    argv[2]:boot\n\
+    argv[3]:GNSS-MIN:60\n\
+    argv[4]:MD-MIN:30\n\
+    argv[5]:PTN-MIN:120\n\
+    argv[6]:RIL-MIN:10\n\
+    argv[7]:SYS-MIN:120\n\
+    argv[8]:INTR\n\
+    argv[9]:LOAD_AVG\n");
+    return;
+}
+void print_binary(int num) {
+    int i;
+    for (i = sizeof(num) * 8 - 1; i >= 0; i--) {
+        printf("%d", (num >> i) & 1);
+    }
+    printf("\n");
+}
+int main(int argc, char **argv)
+{
+    printf("lynq-sdk-ready begin");
+    lynq_sdk_check_param_t param;
+    void *dlHandle;
+    int bit_sdk_ready_status = 0;
+    memset(&param,0,sizeof(lynq_sdk_check_param_t));
+    const char *lynqLibPath = "/lib64/liblynq-sdk-ready.so";
+    dlHandle = dlopen(lynqLibPath, RTLD_NOW);
+    if (dlHandle == NULL) 
+    {
+        printf("dlopen dlHandle_call failed: %s", dlerror());
+        exit(EXIT_FAILURE);
+    }
+    sdk_ready_register = (int(*)(const int uToken,const lynq_sdk_check_param_t* param,lynq_sdk_status_cb sdk_status_cb))dlsym(dlHandle, "lynq_sdk_ready_register");
+    if (sdk_ready_register == NULL) {
+        printf("lynq_init_call not defined or exported in %s", lynqLibPath);
+        exit(EXIT_FAILURE);
+    }
+    get_sdk_ready_status = (int(*)(int *status))dlsym(dlHandle, "lynq_get_sdk_ready_status");
+    if (get_sdk_ready_status == NULL) {
+        printf("lynq_init_call not defined or exported in %s", lynqLibPath);
+        exit(EXIT_FAILURE);
+    }
+    help();
+    if(argc >= 2)
+    {
+        if(atoi(argv[1])==1 && argc >=10)
+        {
+            param.isvalid = atoi(argv[1]);
+            param.period.BOOT = atoi(argv[2]);
+            param.period.GNSS = atoi(argv[3]);
+            param.period.MD = atoi(argv[4]);
+            param.period.PTN = atoi(argv[5]);
+            param.period.RIL = atoi(argv[6]);
+            param.period.SYS = atoi(argv[7]);
+            param.threshold.interrupts = atoi(argv[8]);
+            param.threshold.load_average = atoi(argv[9]);
+        }
+    }
+    printf("You input param:\n\
+    param.isvalid:%d\n\
+    param.period.BOOT:%d\n\
+    param.period.GNSS:%d\n\
+    param.period.MD:%d\n\
+    param.period.PTN:%d\n\
+    param.period.RIL:%d\n\
+    param.period.SYS:%d\n\
+    param.threshold.interrupts:%llu\n\
+    param.threshold.load_average:%d\n",param.isvalid,
+            param.period.BOOT,
+            param.period.GNSS,
+            param.period.MD,
+            param.period.PTN,
+            param.period.RIL,
+            param.period.SYS,
+            param.threshold.interrupts,
+            param.threshold.load_average);
+    sdk_ready_register(1024,&param,demo_sdk_status_cb);
+    while (1)
+    {
+        sleep(30);
+        get_sdk_ready_status(&bit_sdk_ready_status);//需要的时候调用,不是必选项
+        print_binary(bit_sdk_ready_status);
+    }
+    return 0;
+}
diff --git a/common_src/lib/liblynq-sdk-ready/include/lynq_sdk_ready.h b/common_src/lib/liblynq-sdk-ready/include/lynq_sdk_ready.h
new file mode 100755
index 0000000..7ec43fd
--- /dev/null
+++ b/common_src/lib/liblynq-sdk-ready/include/lynq_sdk_ready.h
@@ -0,0 +1,103 @@
+/**@file     lynq_sdk_ready.h
+* @brief     Define sdk ready.
+* @details   SDK ready defines the exception type, configuration parameters, and corresponding exception handling methods.
+* @author    hong.liu@mobiletek.cn
+* @date      2024-10-26
+* @version   V1.0
+* @copyright Copyright (c) MobileTek 
+*/
+
+#ifndef __LYNQ_SDK_READY__
+#define __LYNQ_SDK_READY__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+typedef enum{
+    LYNQ_E_CONFLICT=9000,
+    LYNQ_E_NULL_ANONALY=9001,
+    LYNQ_E_NORMAL=9010,
+}LYNQ_E;
+
+typedef enum {
+    LYNQ_SDK_READY=0,               //ready status
+    LYNQ_SDK_MD_EXCPT=1,            //modem crash exception
+    LYNQ_SDK_MD_REBOOT_EXCPT=2,     //modem reboot exception
+    LYNQ_SDK_RIL_EXCPT=3,           //RIL channel exception
+    LYNQ_SDK_PARTITION_EXCPT=4,     //user data partition full
+    LYNQ_SDK_MIN_FREE_EXCPT=5,      //Memory is critically low
+    LYNQ_SDK_INTR_EXCPT=6,          //Interrupt exception reporting
+    LYNQ_SDK_LOAD_AVG_EXCPT=7,      //5-minute average load exception
+    LYNQ_SDK_NET_CHANNEL_EXCPT=8,   //systeme NET(data call) channel exception
+    LYNQ_SDK_GNSS_EXCPT=9,          //GNSS service exception
+} lynq_sdk_status_t;                //5,6,7 Generally used to evaluate whether the system may be in a busy state
+
+typedef enum {
+    LYNQ_ACTION_NOTHING=0,            //do nothing
+    LYNQ_ACTION_REBOOT=1,             //reboot
+    LYNQ_ACTION_RESET_MD=2,           //reset modem
+    LYNQ_ACTION_RETRY_DATA_CALL=3,    //retry data call
+    LYNQ_ACTION_PTN_CLEAN=4,          //clean user data partition
+    LYNQ_ACTION_SYS_WARNING=5,        //system resource shortage warning, restart recommended
+} lynq_sdk_ref_action_t;
+
+typedef struct {
+    lynq_sdk_status_t sdk_ready_status;
+    lynq_sdk_ref_action_t ref_action;
+} lynq_sdk_ready_t;
+
+typedef struct {
+    int MD;            //default 60s,modem check period
+    int RIL;           //default 30s,RIL channel check period
+    int GNSS;          //default 300s,GNSS channel check period
+    int PTN;           //default 120s,partition used check period
+    int SYS;           //default 120s,system resource check period
+    int BOOT;          //default 60s,Boot preparation time. No exceptions will be reported during this time. Only the LYNQ_SDK_READY status will be reported.
+} lynq_sdk_check_period_t;
+
+typedef struct {
+    unsigned long long interrupts;    //The number of interrupts added within lynq_sdk_check_period_t.SYS, confirmed based on actual hardware,default=(sys/30)*5000*(cpu core)
+    int load_average;        //Average load in lynq_sdk_check_period_t.SYS ​​(actually read the average load for 5 minutes), more confirmed by actual hardware,default=(cpu core)*2。
+} lynq_sdk_check_threshold_t;
+
+typedef struct {
+    int isvalid;       //Whether to use the following configuration, 0: not use, 1: use
+    lynq_sdk_check_period_t period;
+    lynq_sdk_check_threshold_t threshold;
+} lynq_sdk_check_param_t;
+
+/**@brief SDK ready callback function
+* @param lynq_sdk_ready_t *sdk_ready [OUT] <sdk_ready>: Exception type and handling information carried after the callback is triggered.
+* @param void *reserve [OUT] <reserve>: reserve param,Don't pay attention for now.
+* @warning Do not perform any blocking operations or locks in the callback function..
+* @return Return value: 0 if successful, other values ​​if failed
+*/
+typedef int (*lynq_sdk_status_cb)(const lynq_sdk_ready_t *sdk_ready, void *reserve);
+
+/**@brief Register callback function
+* @param uToken [IN] <uToken>: user identifier. If multiple processes call this library, uToken must be different for each process.
+* @param lynq_sdk_check_param_t* param [IN] <param>: SDK check related period and threshold
+* @param lynq_sdk_status_cb* sdk_status_cb [OUT] <sdk_status_cb>: Callback function, triggered when an exception event occurs.
+* @warning If the registration fails, the program will exit directly
+* @return Return value: 0 if successful, other values ​​if failed
+*/
+int lynq_sdk_ready_register(const int uToken, const lynq_sdk_check_param_t* param,lynq_sdk_status_cb sdk_status_cb);
+
+/**@brief get sdk ready status
+* @param int *status [OUT] <status>: sdk ready status Bitwise AND, 0 no exception, 1 exception
+* bit0:RIL
+* bit1:MD
+* bit2:GNSS
+* bit3:PTN
+* bit4:SYS
+* @return Return value: 0 if successful, other values ​​if failed
+*/
+int lynq_get_sdk_ready_status(int *status);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/common_src/lib/liblynq-sdk-ready/lynq_sdk_ready.cpp b/common_src/lib/liblynq-sdk-ready/lynq_sdk_ready.cpp
new file mode 100755
index 0000000..faf77b2
--- /dev/null
+++ b/common_src/lib/liblynq-sdk-ready/lynq_sdk_ready.cpp
@@ -0,0 +1,1158 @@
+#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 <sys/socket.h>

+#include <netinet/in.h>

+#include <arpa/inet.h>

+#include <errno.h>

+#include <include/lynq_uci.h>

+#include <lynq_misc/lynq_misc.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <assert.h>

+#include "lynq_sdk_ready.h"

+

+#define LOG_TAG "LYNQ_SDK_READY"

+#define DEST_PORT 8088

+#define LYNQ_BRODCAST_PORT 8086

+

+#define SDK_READY_PORT 8157

+#define DSET_IP_ADDRESS  "127.0.0.1"

+#define RIL_REQUEST_DEVICE_IDENTITY 98

+#define MAX_LEN 1024

+#define TIMER 30

+#define LOG_UCI_FILE "lynq_uci"

+#define LOG_UCI_MODULE "debug_mode"

+#define update_ril_digit 0x7 //The last three digits are reserved for RIL service,0x111

+#define update_userdata_digit 1<<3

+#define update_gnss_digit 1<<4

+

+#define DEFAULT_PERIOD_RIL 30

+#define DEFAULT_PERIOD_GNSS 300

+#define DEFAULT_PERIOD_MD 60

+#define DEFAULT_PERIOD_PTN 120

+#define DEFAULT_PERIOD_SYS 120

+#define DEFAULT_PERIOD_BOOT 60

+

+#define MIN_PERIOD_RIL 10

+#define MIN_PERIOD_GNSS 60

+#define MIN_PERIOD_MD 30

+#define MIN_PERIOD_PTN 120

+#define MIN_PERIOD_SYS 120

+#define RIL_UNSOL_TELEPHONY_RESTART 3113

+

+#define GET_CPU_NUM "cat /proc/cpuinfo | grep processor | wc -l"

+#define GET_LOAD_AVG_INFO "/proc/loadavg"

+#define GET_INTR_INFO "/proc/stat"

+#define GET_MEM_INFO "/proc/meminfo"

+#define GET_MIN_FREE "/proc/sys/vm/min_free_kbytes"

+

+#define BIT_EXCPT_RIL 1

+#define BIT_EXCPT_MD 1 << 1

+#define BIT_EXCPT_GNSS 1 << 2

+#define BIT_EXCPT_PTN 1 << 3

+#define BIT_EXCPT_SYS 1 << 4

+

+using ::android::Parcel;

+

+static pthread_mutex_t g_lynq_sim_sendto_mutex;

+static pthread_mutex_t lock;

+static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t s_startupCond = PTHREAD_COND_INITIALIZER;

+

+// 全局变量

+static lynq_sdk_check_param_t *global_param = NULL;

+static lynq_sdk_status_cb global_sdk_status_cb = NULL;

+static lynq_sdk_ready_t global_sdk_status;

+static int utoken = 0;

+static int global_sdk_ready_status = 1;

+static int s_ril_started = 0;

+static int s_sys_started = 0;

+static int s_ptn_started = 0;

+static int s_gnss_started = 0;

+static int boot_ril_check_timer[8] = {2,2,4,4,8,8,16,16};

+enum in_ril_excpt {

+    RIL_REQUEST_SUCCESS=0,

+    RIL_MODEM_BOOT_EXCPT=1,

+    RIL_RESP_ERROR_FAIL=2,

+    RIL_SOCKET_CREATE_FAIL=3,

+    RIL_SOCKET_SEND_REC_FAIL=4,

+};

+

+typedef struct{

+    int uToken;

+    int request;

+    int paramLen;

+    char param[MAX_LEN];

+}lynq_client_t;

+

+

+void unlock_with_s_start(int *s_start)

+{

+    pthread_mutex_lock(&s_startupMutex);

+    *s_start = 1;

+    pthread_cond_broadcast(&s_startupCond);
+    pthread_mutex_unlock(&s_startupMutex);

+}

+long get_uptime()

+{

+    struct timespec start_time;

+    clock_gettime(CLOCK_MONOTONIC, &start_time);

+    return start_time.tv_sec;

+}

+const char * sdk_status_excpt_to_string(lynq_sdk_status_t excpt)

+{

+    switch(excpt)

+    {

+        case LYNQ_SDK_READY: return "LYNQ_SDK_READY";

+        case LYNQ_SDK_MD_EXCPT: return "LYNQ_SDK_MD_EXCPT";

+        case LYNQ_SDK_MD_REBOOT_EXCPT: return "LYNQ_SDK_MD_REBOOT_EXCPT";

+        case LYNQ_SDK_RIL_EXCPT: return "LYNQ_SDK_RIL_EXCPT";

+        case LYNQ_SDK_PARTITION_EXCPT: return "LYNQ_SDK_PARTITION_EXCPT";

+        case LYNQ_SDK_MIN_FREE_EXCPT: return "LYNQ_SDK_MIN_FREE_EXCPT";

+        case LYNQ_SDK_INTR_EXCPT: return "LYNQ_ACTION_INTR_EXCPT";

+        case LYNQ_SDK_LOAD_AVG_EXCPT: return "LYNQ_SDK_LOAD_AVG_EXCPT";

+        case LYNQ_SDK_NET_CHANNEL_EXCPT: return "LYNQ_SDK_NET_CHANNEL_EXCPT";

+        case LYNQ_SDK_GNSS_EXCPT: return "LYNQ_SDK_GNSS_EXCPT";

+        default: return "<unknown excpt>";

+    }

+}

+const char * sdk_status_action_to_string(lynq_sdk_ref_action_t action)

+{

+    switch(action)

+    {

+        case LYNQ_ACTION_NOTHING: return "LYNQ_ACTION_NOTHING";

+        case LYNQ_ACTION_REBOOT: return "LYNQ_ACTION_REBOOT";

+        case LYNQ_ACTION_RESET_MD: return "LYNQ_ACTION_RESET_MD";

+        case LYNQ_ACTION_RETRY_DATA_CALL: return "LYNQ_ACTION_RETRY_DATA_CALL";

+        case LYNQ_ACTION_PTN_CLEAN: return "LYNQ_ACTION_PTN_CLEAN";

+        case LYNQ_ACTION_SYS_WARNING: return "LYNQ_ACTION_SYS_WARNING";

+        default: return "<unknown action>";

+    }

+}

+void reset_sdk_ready_status()

+{

+    global_sdk_status.sdk_ready_status = LYNQ_SDK_READY;

+    global_sdk_status.ref_action = LYNQ_ACTION_NOTHING;

+}

+void trigger_sdk_ready_cb(lynq_sdk_status_t excpt, lynq_sdk_ref_action_t action)

+{

+    pthread_mutex_lock(&lock);

+    RLOGI("trigger sdk ready cb excpt:%s,action:%s",sdk_status_excpt_to_string(excpt),sdk_status_action_to_string(action));

+    long uptime = get_uptime();

+    if((excpt != LYNQ_SDK_READY) && (uptime < global_param->period.BOOT))

+    {

+        goto end;

+    }

+    //if((global_sdk_status.sdk_ready_status == excpt) && (global_sdk_status.ref_action == action))

+    //{

+    //    goto end;

+    //}

+    global_sdk_status.sdk_ready_status = excpt;

+    global_sdk_status.ref_action = action;

+    global_sdk_status_cb(&global_sdk_status,NULL);

+end:

+    pthread_mutex_unlock(&lock);

+    return;

+}

+//maybe uci,or other

+void set_sdk_ready_nv(int value)

+{

+    char cmd[64] = {0};

+    RLOGI("set_sdk_ready_nv:%d",value);

+    sprintf(cmd,"uci set lynq_uci.sdk_ready=%d",value);//set uci

+    system(cmd);

+    return;

+}

+void set_sdk_ready_status_bit(int bit,int status)

+{

+    pthread_mutex_lock(&lock);

+    int old = 1;

+    if((global_sdk_ready_status & bit) == 0)

+    {

+        old = 0;

+    }

+    if(old == status)

+    {

+        goto end;

+    }

+    if(status == 1)

+    {

+        global_sdk_ready_status |= bit;

+    }

+    else

+    {

+        global_sdk_ready_status &= ~bit;

+    }

+    set_sdk_ready_nv(global_sdk_ready_status);

+end:

+    pthread_mutex_unlock(&lock);

+    return;

+}

+static int get_md_sta(void)

+{

+    FILE *fp;

+    char buffer[64]={};

+    fp = popen("cat /sys/kernel/ccci/boot","r");

+    if(fp == NULL)

+    {

+        RLOGD("function %s fp is null\n", __FUNCTION__);

+        return 0;

+    }

+    fgets(buffer,sizeof(buffer),fp);

+    if(!strlen(buffer))

+    {

+        RLOGD("function %s line %d\n", __FUNCTION__, __LINE__);

+        pclose(fp);

+        return 0;

+    }

+    if(buffer[4] == '4')

+    {

+        pclose(fp);

+        return 1;

+    }

+    RLOGD("function %s line %d\n", __FUNCTION__, __LINE__);

+    pclose(fp);

+    return 0;

+}

+

+static int check_service(const char *service)

+{

+    FILE *fp = NULL;

+    char buffer[1024]={};

+    if(!strcmp(service, "/usr/sbin/mtkfusionrild"))

+    {

+        fp = popen("ps -ef|grep rild","r");

+    }

+    else if(!strcmp(service, "lynq-ril-service"))

+    {

+        fp = popen("ps -ef|grep ril-service","r");

+    }

+    if(fp == NULL)

+    {

+        RLOGD("function %s fp is null\n", __FUNCTION__);

+        return 0;

+    }

+    while(NULL != fgets(buffer,sizeof(buffer),fp))

+    {

+        if(strstr(buffer,service))

+        {

+            pclose(fp);

+            RLOGD("check_service 1\n");

+            return 1;

+        }

+    }

+    RLOGD("check_service 0\n");

+    pclose(fp);

+    return 0;

+}

+

+/**
+ * @brief find partition zhengshu for exzample 5.7M,get value 5
+ * 
+ * @param arg 
+ * @return  
+ */
+static void removeSpaces(char* str) 
+{
+    char* dest = str;  
+    while (*str) {
+        if (*str != ' ') {
+            *dest++ = *str;  
+        }
+        str++;  
+    }
+    *dest = '\0';
+	return ;
+}
+void check_ril_sleep(int count)

+{

+    if((count < sizeof(boot_ril_check_timer)/sizeof(int)) && ((global_sdk_ready_status & 1) == 1))// total 60s

+    {

+        sleep(boot_ril_check_timer[count]);

+    }

+    else

+    {

+        sleep(global_param->period.RIL);

+    }

+    return;

+}

+void update_ril_value(int value)

+{

+    switch (value)

+    {

+        case RIL_REQUEST_SUCCESS:

+        {

+            trigger_sdk_ready_cb(LYNQ_SDK_READY, LYNQ_ACTION_NOTHING);

+            set_sdk_ready_status_bit(BIT_EXCPT_RIL,0);

+            set_sdk_ready_status_bit(BIT_EXCPT_MD, 0);

+            break;

+        }

+        case RIL_MODEM_BOOT_EXCPT:

+        {

+            set_sdk_ready_status_bit(BIT_EXCPT_RIL,1);

+            trigger_sdk_ready_cb(LYNQ_SDK_MD_EXCPT,LYNQ_ACTION_REBOOT);

+            break;

+        }

+        case RIL_RESP_ERROR_FAIL:

+        {

+            set_sdk_ready_status_bit(BIT_EXCPT_RIL,1);

+            trigger_sdk_ready_cb(LYNQ_SDK_RIL_EXCPT,LYNQ_ACTION_NOTHING);

+            break;

+        }

+        case RIL_SOCKET_CREATE_FAIL:

+        case RIL_SOCKET_SEND_REC_FAIL:

+        {

+            set_sdk_ready_status_bit(BIT_EXCPT_RIL,1);

+            trigger_sdk_ready_cb(LYNQ_SDK_RIL_EXCPT,LYNQ_ACTION_REBOOT);

+            break;

+        }

+        default:

+            RLOGE("Not this case:%d",value);

+    }

+    return;

+}

+

+void update_userdata_value()

+{

+    pthread_mutex_lock(&lock);

+    trigger_sdk_ready_cb(LYNQ_SDK_PARTITION_EXCPT, LYNQ_ACTION_REBOOT);

+    set_sdk_ready_status_bit(BIT_EXCPT_PTN,1);

+    pthread_mutex_unlock(&lock);

+    return;

+}

+

+void update_gnss_value()

+{

+    pthread_mutex_lock(&lock);

+    trigger_sdk_ready_cb(LYNQ_SDK_GNSS_EXCPT, LYNQ_ACTION_REBOOT);

+    set_sdk_ready_status_bit(BIT_EXCPT_GNSS,1);

+    pthread_mutex_unlock(&lock);

+    return;

+}

+/**

+ * @brief send request imei

+ * 

+ * @param arg 

+ * 线程run起来后前两个60s 不做异常上报,这段时间是模组就绪时间因此只报ready 状态,60s 以后如果还是检测到异常,说明是真异常

+ * @return void* 

+ */

+void * timer_request_imei(void * arg)

+{

+    unlock_with_s_start(&s_ril_started);

+    int send_num = -1;

+    int recv_num = -1;

+    int resp_type = -1;

+    int request = -1;

+    int slot_id = -1;

+    int token = -1;

+    int res_error = -1;

+    int count = 0;

+    Parcel p;

+    struct sockaddr_in addr_serv;

+    struct sockaddr_in liblynq_sdk_ready_socket;

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

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

+    addr_serv.sin_family = AF_INET;

+    addr_serv.sin_addr.s_addr = inet_addr(DSET_IP_ADDRESS);

+    addr_serv.sin_port = htons(DEST_PORT);

+    liblynq_sdk_ready_socket.sin_family = AF_INET;

+    liblynq_sdk_ready_socket.sin_addr.s_addr = inet_addr(DSET_IP_ADDRESS);

+    int len_addr_serv = sizeof(addr_serv);

+

+    lynq_client_t client_t;

+    char res_data[MAX_LEN] = {0};

+    client_t.request = RIL_REQUEST_DEVICE_IDENTITY;

+    client_t.paramLen = 0;

+    client_t.uToken = utoken;

+    memset(client_t.param, 0, sizeof(client_t.param));

+

+    struct timeval timeOut;

+    timeOut.tv_sec = 3;//timeout time 3s

+    timeOut.tv_usec = 0;

+

+    int sock_fd = socket(AF_INET, SOCK_DGRAM, 0);

+    if (-1 == sock_fd)

+    {

+        RLOGD("__FUNCTION__ %s create  sock_fd failed %s\n", __FUNCTION__, strerror(errno));

+        exit(EXIT_FAILURE);

+        return NULL;

+    }

+    int ret = bind(sock_fd, (struct sockaddr *)&liblynq_sdk_ready_socket, sizeof(liblynq_sdk_ready_socket));

+    if (-1 == ret)

+    {

+        RLOGE("liblynq_data_socket bind fail,errno:%d",errno);

+        return NULL;

+    }

+

+    if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, &timeOut, sizeof(timeOut)) < 0) 

+    {

+        RLOGD("__FUNCTION__ %s time out setting failed %s\n", __FUNCTION__, strerror(errno));

+        exit(EXIT_FAILURE);

+        return NULL;

+    }

+    while (1)

+    {

+        bzero(res_data, MAX_LEN);

+        pthread_mutex_lock(&g_lynq_sim_sendto_mutex);

+        send_num = sendto(sock_fd, &client_t, sizeof(client_t), 0, (struct sockaddr *)&addr_serv, len_addr_serv);

+        RLOGD("send_num %d\n", send_num);

+        if(send_num == 0)  

+        {

+            RLOGD("__FUNCTION__ %s Close to end %s\n", __FUNCTION__, strerror(errno));

+            //unknow

+            update_ril_value(RIL_SOCKET_SEND_REC_FAIL);

+            pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);

+            continue;

+        }

+        if(send_num < 0)  

+        {  

+            RLOGD("__FUNCTION__ %s sendto error %s\n", __FUNCTION__, strerror(errno));

+            //unknow

+            update_ril_value(RIL_SOCKET_SEND_REC_FAIL);

+            pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);

+            continue;

+        }

+        //get data msg

+        recv_num = recvfrom(sock_fd,res_data,sizeof(char)*MAX_LEN,0,(struct sockaddr *)&addr_serv,(socklen_t*)&len_addr_serv);

+        RLOGD("recv_num %d\n", recv_num);

+        if(recv_num == -1 && errno == EAGAIN)

+        {

+            RLOGD("__FUNCTION__ %srecvfrom fail because timeout\n", __FUNCTION__);

+            /*set uci*/

+            if(!get_md_sta())

+            {

+                update_ril_value(RIL_MODEM_BOOT_EXCPT);

+            }

+            else

+            {

+                if(check_service("/usr/sbin/mtkfusionrild"))//rild work

+                {

+                    if(!check_service("lynq-ril-service"))//not find,must be socket error

+                    {

+                        update_ril_value(RIL_SOCKET_CREATE_FAIL);

+                    }

+                    else

+                    {

+                        //unknow error

+                        update_ril_value(RIL_SOCKET_SEND_REC_FAIL);

+                    }

+                }

+                else//rild no work

+                {

+                    //unknow

+                    update_ril_value(RIL_SOCKET_SEND_REC_FAIL);

+                }

+            }

+            pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);

+            check_ril_sleep(count);

+            count++;

+            continue;

+        }

+        if(recv_num <= 0)

+        {

+            RLOGD("__FUNCTION__ %s recvfrom fail %s\n", __FUNCTION__, strerror(errno));

+            update_ril_value(RIL_SOCKET_SEND_REC_FAIL);

+            pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);

+            check_ril_sleep(count);

+            count++;

+            continue;

+        }

+        p.setData((uint8_t *)res_data,sizeof(char)*recv_num);

+        p.setDataPosition(0);

+        if(p.dataAvail() > 0)

+        {

+            p.readInt32(&resp_type);

+            p.readInt32(&token);

+            p.readInt32(&request);

+            p.readInt32(&slot_id);

+            p.readInt32(&res_error);

+        }

+        /*judge the res_error*/

+        if(!res_error)

+        {

+            update_ril_value(RIL_REQUEST_SUCCESS);

+        }

+        else

+        {

+            update_ril_value(RIL_RESP_ERROR_FAIL);

+        }

+        count = 0;

+        RLOGD("__FUNCTION__ %s res_error %d\n", __FUNCTION__, res_error);

+        /*judge the res_error*/

+        pthread_mutex_unlock(&g_lynq_sim_sendto_mutex);

+        check_ril_sleep(sizeof(boot_ril_check_timer)/sizeof(int));

+    }

+    return NULL;

+}

+

+void * wait_ril_event(void * arg)

+{

+    unlock_with_s_start(&s_ril_started);

+    int REC_BUFF_LEN = 64;

+    int recv_num = 0;

+    char rec_data[REC_BUFF_LEN] = {0};

+    int count = 0;

+    struct sockaddr_in wait_ril_event_socket;

+    struct sockaddr_in addr_client;

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

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

+    wait_ril_event_socket.sin_family = AF_INET;

+    wait_ril_event_socket.sin_addr.s_addr = inet_addr(DSET_IP_ADDRESS);

+    wait_ril_event_socket.sin_port = htons(SDK_READY_PORT);

+    int len_addr_serv = sizeof(addr_client);

+

+    int sock_fd = socket(AF_INET, SOCK_DGRAM, 0);

+    if (-1 == sock_fd)

+    {

+        RLOGD("__FUNCTION__ %s create  sock_fd failed %s\n", __FUNCTION__, strerror(errno));

+        exit(EXIT_FAILURE);

+        return NULL;

+    }

+    int ret = bind(sock_fd, (struct sockaddr *)&wait_ril_event_socket, sizeof(wait_ril_event_socket));

+    if (-1 == ret)

+    {

+        RLOGE("liblynq_data_socket bind fail,errno:%d",errno);

+        exit(EXIT_FAILURE);

+        return NULL;

+    }

+    while(1)

+    {

+        memset(rec_data,0,REC_BUFF_LEN);

+        recv_num = recvfrom(sock_fd,rec_data,sizeof(char)*REC_BUFF_LEN,0,(struct sockaddr *)&addr_client,(socklen_t*)&len_addr_serv);

+        if(recv_num <= 0)

+        {

+            RLOGD("__FUNCTION__ %s Close to end\n", __FUNCTION__);

+            update_ril_value(RIL_SOCKET_SEND_REC_FAIL);

+            continue;

+        }

+        rec_data[recv_num] = '\0';

+        if((atoi(rec_data) == RIL_UNSOL_TELEPHONY_RESTART) && (count%2 == 0))//this urc will be reported twice in a row

+        {

+            set_sdk_ready_status_bit(BIT_EXCPT_MD, 1);

+            trigger_sdk_ready_cb(LYNQ_SDK_MD_REBOOT_EXCPT,LYNQ_ACTION_RETRY_DATA_CALL);

+            count = 0;

+        }

+        count ++;

+    }

+    close(sock_fd);

+}

+

+

+void delete_enter(char data[])

+{

+    char *find = strchr(data, '\n');

+    if(find)

+        *find = '\0';

+    return ;

+}

+

+unsigned long long get_interrupts(int fd,char *buffer,int size)

+{

+    char *line = NULL;

+    unsigned long long intr_value = 0;

+    memset(buffer,0,size);

+    lseek(fd, 0, SEEK_SET);

+    ssize_t bytes_intr_read = read(fd,buffer, size - 1);

+    buffer[bytes_intr_read] = '\0';

+    line = strstr(buffer, "intr");

+    if (line == NULL)

+    {

+        RLOGE("get intr fail");

+    }

+    else

+    {

+        line += 5;

+        sscanf(line,"%llu",&intr_value);

+    }

+    return intr_value;

+}

+unsigned long long get_mem_free(int fd,char *buffer,int size)

+{

+    char *line = NULL;

+    unsigned long long mem_value = 0;

+    lseek(fd, 0, SEEK_SET);

+    memset(buffer,0,size);

+    ssize_t bytes_mem_read = read(fd, buffer, size - 1);

+    buffer[bytes_mem_read] = '\0';

+    line = strstr(buffer, "MemFree:");

+    if (line == NULL)

+    {

+        RLOGE("get MemFree fail");

+    }

+    else

+    {

+        line += 9;

+        while (*line == ' ')

+        {

+            line++;

+        }

+        sscanf(line,"%llu",&mem_value);

+    }

+    return mem_value;

+}

+

+void *check_system(void * arg)

+{

+    int fd_mem = 0;

+    int fd_intr = 0;

+    int fd_avg = 0;

+    int fd_free = 0;

+    int BUFFER_SIZE = 512;

+    unsigned long long min_free = 0;

+    unsigned long long mem_value = 0;

+    unsigned long long intr_value_old = 0;

+    unsigned long long intr_value_new = 0;

+    float avg_value = 0;

+    int excpt_flag = 0;

+    char sys_buffer[BUFFER_SIZE];

+    char min_free_buffer[BUFFER_SIZE];

+    unlock_with_s_start(&s_sys_started);

+    fd_mem = open(GET_MEM_INFO,O_RDONLY);

+    fd_free = open(GET_MIN_FREE,O_RDONLY);

+    fd_intr = open(GET_INTR_INFO,O_RDONLY);

+    fd_avg = open(GET_LOAD_AVG_INFO,O_RDONLY);

+    if((fd_mem < 0) || (fd_intr < 0) || (fd_avg < 0) || (fd_free < 0))

+    {

+        RLOGE("check system open fail");

+        exit(EXIT_FAILURE);

+    }

+    memset(min_free_buffer,0,BUFFER_SIZE);

+    ssize_t bytes_min_free_read = read(fd_free, min_free_buffer, BUFFER_SIZE - 1);

+    if(bytes_min_free_read == -1)

+    {

+        RLOGE("get min free fail");

+        exit(EXIT_FAILURE);

+    }

+    min_free = atoi(min_free_buffer);

+    close(fd_free);

+    ssize_t bytes_avg_read = 0;

+    intr_value_old  = get_interrupts(fd_intr, sys_buffer, BUFFER_SIZE);

+    while(1)

+    {

+        memset(sys_buffer,0,BUFFER_SIZE);

+        lseek(fd_avg, 0, SEEK_SET);

+        bytes_avg_read = read(fd_avg, sys_buffer, BUFFER_SIZE - 1);

+        sys_buffer[bytes_avg_read] = '\0';

+        sscanf(sys_buffer,"%*f %f",&avg_value);

+

+        mem_value = get_mem_free(fd_mem, sys_buffer, BUFFER_SIZE);

+        intr_value_new  = get_interrupts(fd_intr, sys_buffer, BUFFER_SIZE);

+        //pages_min = /proc/sys/vm/min_free_kbytes

+        //pages_low = pages_min*5/4

+        //pages_high = pages_min*3/2

+        if((mem_value >= min_free) && (mem_value < min_free*1.25))//pages_min-pages_low

+        {

+            trigger_sdk_ready_cb(LYNQ_SDK_MIN_FREE_EXCPT,LYNQ_ACTION_SYS_WARNING);

+            excpt_flag = 1;

+        }

+        if(mem_value < min_free)

+        {

+            trigger_sdk_ready_cb(LYNQ_SDK_MIN_FREE_EXCPT,LYNQ_ACTION_REBOOT);

+            excpt_flag = 1;

+        }

+        if(avg_value > global_param->threshold.load_average)

+        {

+            trigger_sdk_ready_cb(LYNQ_SDK_LOAD_AVG_EXCPT,LYNQ_ACTION_SYS_WARNING);

+            excpt_flag = 1;

+        }

+        if((intr_value_new - intr_value_old) > global_param->threshold.interrupts)

+        {

+            trigger_sdk_ready_cb(LYNQ_SDK_INTR_EXCPT,LYNQ_ACTION_SYS_WARNING);

+            excpt_flag = 1;

+        }

+        set_sdk_ready_status_bit(BIT_EXCPT_SYS,excpt_flag);

+        RLOGI("memfree:%llu,intr_old:%llu,intr_new:%llu,intr_delat:%llu,avg:%.2f\n",mem_value,intr_value_old,intr_value_new,(intr_value_new - intr_value_old),avg_value);

+        intr_value_old = intr_value_new;

+        excpt_flag = 0;

+        sleep(global_param->period.SYS);

+    }

+    close(fd_mem);

+    close(fd_intr);

+    close(fd_avg);

+}

+

+/* old code 2024/11/04 close

+void *check(void * arg)

+{

+

+    char pid[200][8];

+    char ffd[200][4];

+    char buf[64];

+    char check_time[4];

+    char timebuf[32];

+    int num = 1;

+    int i=0;

+    int j;

+    FILE *fp,*fp_1;

+    int ret;

+

+    RLOGD("check cpu/pid/interrupts/fd!!!\n");

+    system("mkdir /media/check_file");

+    system("touch /media/check_time");

+    fp_1 = popen("cat /media/check_time","r");

+    if(fgets(check_time, 4, fp_1) != NULL)

+    {

+        num = atoi(check_time);

+    }

+    pclose(fp_1);

+    while(1)

+    {

+        i = 0;

+        system("date >>/media/check_file/cpu_moniter.txt");

+        ret = system("top -b |head -n 25 >>/media/check_file/cpu_moniter.txt");

+        RLOGD("cpu ret %d", ret);

+        system("date >>/media/check_file/inter_moniter.txt");

+        ret = system("cat /proc/interrupts |grep -v \":          0          0\" >>/media/check_file/inter_moniter.txt");

+        RLOGD("interrupts ret %d", ret);

+

+        system("date >>/media/check_file/pid_moniter.txt");

+        ret = system("ps -eo \"%p %a\" | grep -v \"\\[\" >>/media/check_file/pid_moniter.txt");

+        RLOGD("pid ret %d", ret);

+

+        system("date >>/media/check_file/meminfo_moniter.txt");

+        ret = system("cat /proc/meminfo >>/media/check_file/meminfo_moniter.txt");

+        RLOGD("meminfo ret %d", ret);

+

+        system("date >>/media/check_file/buddyinfo_moniter.txt");

+        ret = system("cat /proc/buddyinfo >>/media/check_file/buddyinfo_moniter.txt");

+        RLOGD("buddyinfo ret %d", ret);

+

+        system("date >>/media/check_file/ps_auxw_moniter.txt");

+        ret = system("ps -auxw|grep -v \"0.0  0.0\"|grep -v \"0.1  0.0\"|grep -v \"0.0  0.1\" >>/media/check_file/ps_auxw_moniter.txt");

+        RLOGD("ps_auxw ret %d", ret);

+

+        system("date >>/media/check_file/cur_freq_moniter.txt");

+        ret = system("cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq >>/media/check_file/cur_freq_moniter.txt");

+        RLOGD("cur_freq ret %d", ret);

+

+        system("date >>/media/check_file/available_frequencies_moniter.txt");

+        ret = system("cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies >>/media/check_file/available_frequencies_moniter.txt");

+        RLOGD("available_frequencies ret %d", ret);

+

+        system("date >>/media/check_file/fd_moniter.txt");

+        fp = popen("ps -eo \"%p %a\" | grep -v \"\\[\"|awk '{print $1}'","r");

+        while(fgets(pid[i], 8, fp) != NULL)

+        {

+             delete_enter(pid[i]);

+             i++;

+        }

+        pclose(fp);

+

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

+        {

+            sprintf(buf, "ls /proc/%s/fd | wc -l", pid[j]);

+            fp = popen(buf, "r");

+            fgets(ffd[j], 4, fp);

+            sprintf(buf,"echo \"pid: %s, fd_num: %s\" >>/media/check_file/fd_moniter.txt",pid[j], ffd[j]);

+            system(buf);

+            pclose(fp);

+        }

+

+        if(num > 228)

+        {

+            system("cp /media/check_file/cpu_moniter.txt /media/check_file/cpu_moniter_1.txt");

+            system("cp /media/check_file/inter_moniter.txt /media/check_file/inter_moniter_1.txt");

+            system("cp /media/check_file/pid_moniter.txt /media/check_file/pid_moniter_1.txt");

+            system("cp /media/check_file/fd_moniter.txt /media/check_file/fd_moniter_1.txt");

+            system("cp /media/check_file/fd_moniter.txt /media/check_file/meminfo_moniter_1.txt");

+            system("cp /media/check_file/fd_moniter.txt /media/check_file/buddyinfo_moniter_1.txt");

+            system("cp /media/check_file/fd_moniter.txt /media/check_file/ps_auxw_moniter_1.txt");

+            system("cp /media/check_file/fd_moniter.txt /media/check_file/cur_freq_moniter_1.txt");

+            system("cp /media/check_file/fd_moniter.txt /media/check_file/available_frequencies_moniter_1.txt");

+

+

+            system("rm -rf /media/check_file/cpu_moniter.txt");

+            system("rm -rf /media/check_file/inter_moniter.txt");

+            system("rm -rf /media/check_file/pid_moniter.txt");

+            system("rm -rf /media/check_file/fd_moniter.txt");

+            system("rm -rf /media/check_file/meminfo_moniter.txt");

+            system("rm -rf /media/check_file/buddyinfo_moniter.txt");

+            system("rm -rf /media/check_file/ps_auxw_moniter.txt");

+            system("rm -rf /media/check_file/cur_freq_moniter.txt");

+            system("rm -rf /media/check_file/available_frequencies_moniter.txt");

+

+            num = 0;

+        }

+        num++;

+        sprintf(timebuf, "echo \"%d\" >/media/check_time", num);

+        ret = system(timebuf);

+        sleep(300);

+    }

+    return NULL;

+

+}

+

+int num = 0;

+void *check_uci(void * arg)

+{

+    int ret[6];

+    int result = 0;

+    int flag = 0;

+

+    char uci_0[]="/etc/config/lynq_uci";

+    char uci_1[]="/etc/config/lynq_uci_ro";

+    char uci_2[]="/etc/config/mdlog";

+    char uci_3[]="/etc/config/radio_property";

+    char uci_4[]="/etc/config/service";

+    char uci_5[]="/etc/config/usb";

+    RLOGD("start check uci\n");

+    while(num++ < 4)

+    {

+        RLOGD("@@@@@@@num=%d\n", num);

+        flag = 0;

+        ret[0] = system("uci show | grep \"lynq_uci.lynq_ril\" > /dev/null");

+        if(ret[0] != 0)

+        {

+            RLOGD("lynq_uci unload\n");

+            flag = 1;

+        }

+

+        ret[1] = system("uci show | grep \"^lynq_uci_ro\.\" > /dev/null");

+        if(ret[1] != 0)

+        {

+            RLOGD("lynq_uci_ro unload\n");

+            flag = 1;

+        }

+

+        ret[2] = system("uci show | grep \"^mdlog\.\"");

+        if(ret[2] != 0)

+        {

+            RLOGD("mdlog unload\n");

+            flag = 1;

+        }

+

+        ret[3] = system("uci show | grep \"^radio_property\.\" > /dev/null");

+        if(ret[3] != 0)

+        {

+            RLOGD("radio_property unload\n");

+            flag = 1;

+        }

+

+        ret[4] = system("uci show | grep \"^service\.\" > /dev/null");

+        if(ret[4] != 0)

+        {

+            RLOGD("service unload\n");

+            flag = 1;

+        }

+

+        ret[5] = system("uci show | grep \"^usb\.\" > /dev/null");

+        if(ret[5] != 0)

+        {

+            RLOGD("usb unload\n");

+            flag = 1;

+        }

+

+        RLOGD("flag=%d\n",flag);

+        if(flag != 0)

+        {

+            RLOGD("config reload\n");

+            result = chdir("/data_backup/");

+            result =system("tar -zxvf userdata.tar.gz -C /STATE/ >/dev/null");

+            if(result!= 0)

+            {

+                RLOGD("cp config fail\n");

+            }

+            if(ret[0] != 0)

+            {

+                lynq_load_config(uci_0);

+                RLOGD("reload lynq_uci\n");

+                system("systemctl start autosuspend");

+            }

+            if(ret[1] != 0)

+            {

+                lynq_load_config(uci_1);

+                RLOGD("reload lynq_uci_ro\n");

+            }

+            if(ret[2] != 0)

+            {

+                lynq_load_config(uci_2);

+                RLOGD("reload mdlog\n");

+            }

+            if(ret[3] != 0)

+            {

+                lynq_load_config(uci_3);

+                RLOGD("reload radio_property\n");

+                system("systemctl restart mtkfusionrild");

+            }

+            if(ret[4] != 0)

+            {

+                lynq_load_config(uci_4);

+                RLOGD("reload service\n");

+            }

+            if(ret[5] != 0)

+            {

+                lynq_load_config(uci_5);

+                RLOGD("reload usb\n");

+            }

+        }

+        else

+        {

+            RLOGD("uci check success, exit check!\n");

+            break;

+        }

+        sleep(2);

+    }

+    return NULL;

+}

+old code 2024/11/04 close*/

+

+static void t800_check_partition()

+{
+    char buf[64] = {0};

+    FILE *fp = NULL;

+    int q = 22*1024;

+    int ubisize = 0;

+
+    fp = popen("df -l| grep '/data$' | awk '{print $3}'","r");
+    if(fp == NULL)
+    {
+        RLOGD("Failed to run command\n");
+        return;
+    }

+    fgets(buf, sizeof(buf) - 1, fp);
+    RLOGD("buf is: %s\n",buf);
+    ubisize = atoi(buf);

+    if(ubisize >= q)

+    {

+        RLOGD(">set ready 5,userdata size is %d M\n",ubisize);

+        update_userdata_value();

+    }

+    else

+    {

+        set_sdk_ready_status_bit(BIT_EXCPT_PTN, 0);

+    }

+    pclose(fp);

+    return;

+}

+void t800_check_mnld()

+{
+    FILE *fp = NULL;

+    const char *symble = "NRestarts=";
+    const char *cmd = "systemctl show -p NRestarts mnld.service";

+    char buf[64];

+    int count_old = 0;

+    int count_new = 0;

+    while(1)

+    {

+        fp = popen(cmd,"r");

+        if(NULL == fp)

+        {

+            RLOGE("run cmd:%s fail",cmd);

+            sleep(1);

+            continue;

+        }

+        while(fgets(buf, sizeof(buf) - 1, fp) != NULL)

+        {

+            if(strncmp(buf,symble,strlen(symble)) == 0)

+                count_new = atoi(buf+strlen(symble));

+            memset(buf,0,sizeof(buf));

+        }

+        if((count_new - count_old) > 1)

+        {

+            update_gnss_value();//out put mnld severe abnormal state

+            RLOGD("mnld is severe abnormal state = %d\n",count_new - count_old);

+        }

+        else

+        {

+            set_sdk_ready_status_bit(BIT_EXCPT_GNSS,0);

+        }

+        pclose(fp);

+        count_old = count_new;

+        sleep(global_param->period.GNSS);

+    }

+    return;

+}
+void *check_partition(void *arg)

+{

+    unlock_with_s_start(&s_ptn_started);

+    while(1)

+    {

+        t800_check_partition();

+        sleep(global_param->period.PTN);

+    }

+    return NULL;

+}

+

+void *check_gnss(void * arg)

+{

+    unlock_with_s_start(&s_gnss_started);

+    t800_check_mnld();

+    return NULL;

+}

+int get_cpu_info()

+{

+    FILE *CPU_FD = NULL;

+    int cpu_num = 0;

+    char cpu_info[8];

+    CPU_FD = popen(GET_CPU_NUM,"r");

+    if(CPU_FD == NULL)

+    {
+        RLOGD("get cpu info fail:%s",GET_CPU_NUM);

+        return -1;

+    }

+    fgets(cpu_info, sizeof(cpu_info) - 1, CPU_FD);

+    cpu_num = atoi(cpu_info);

+    pclose(CPU_FD);

+    return cpu_num;

+}

+int set_default_sdk_check_param(lynq_sdk_check_param_t *param)

+{

+    int cpu_num = 0;

+    param->period.RIL = DEFAULT_PERIOD_RIL;

+    param->period.GNSS = DEFAULT_PERIOD_GNSS;

+    param->period.MD = DEFAULT_PERIOD_MD;

+    param->period.PTN = DEFAULT_PERIOD_PTN;

+    param->period.SYS = DEFAULT_PERIOD_SYS;

+    param->period.BOOT = DEFAULT_PERIOD_BOOT;

+    cpu_num = get_cpu_info();

+    if(cpu_num <= 0)

+    {

+        RLOGE("set default sdk check param fail");

+        return -1;

+    }

+    param->threshold.interrupts = (DEFAULT_PERIOD_SYS/30)*cpu_num*5000;

+    param->threshold.load_average = cpu_num*2;

+    return 0;

+}

+int create_check_threads(void)

+{

+    pthread_t thid,thid_1,thid_2,thid_3,thid_4;

+    pthread_attr_t attr;

+    pthread_attr_init(&attr);

+    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

+    int ret;

+    pthread_mutex_lock(&s_startupMutex);

+    ret = pthread_create(&thid, &attr, timer_request_imei, NULL);

+    if(ret != 0)

+    {

+        RLOGE("timer_request_imei error!!!");

+        goto excp;

+    }

+    while (s_ril_started == 0)

+    {

+        pthread_cond_wait(&s_startupCond, &s_startupMutex);
+    }

+    ret = pthread_create(&thid_1, &attr, check_system, NULL);

+    if(ret != 0)

+    {

+        RLOGE("check_system error!!!");

+        goto excp;

+    }

+    while (s_sys_started == 0)

+    {

+        pthread_cond_wait(&s_startupCond, &s_startupMutex);
+    }

+

+    ret = pthread_create(&thid_2, &attr,check_gnss,NULL);

+    if(ret != 0)
+    {
+        RLOGD("check_gnss error!!!");

+        goto excp;

+    }

+    while (s_gnss_started == 0)

+    {

+        pthread_cond_wait(&s_startupCond, &s_startupMutex);
+    }

+    ret = pthread_create(&thid_3, &attr,check_partition,NULL);

+    if(ret != 0)
+    {
+        RLOGD("check_partition error!!!");

+        goto excp;

+    }

+    while (s_ptn_started == 0)

+    {

+        pthread_cond_wait(&s_startupCond, &s_startupMutex);
+    }

+    s_ril_started = 0;

+    ret = pthread_create(&thid_4, &attr,wait_ril_event,NULL);

+    if(ret != 0)
+    {
+        RLOGD("wait_ril_event error!!!");

+        goto excp;

+    }

+    while (s_ril_started == 0)

+    {

+        pthread_cond_wait(&s_startupCond, &s_startupMutex);
+    }

+    pthread_mutex_unlock(&s_startupMutex);

+    return 0;

+excp:

+    pthread_mutex_unlock(&s_startupMutex);

+    return LYNQ_E_NORMAL;

+}

+int lynq_sdk_ready_register(const int uToken,const lynq_sdk_check_param_t* param,lynq_sdk_status_cb sdk_status_cb)

+{

+    int ret = 0;

+    if (param == NULL || sdk_status_cb == NULL)

+    {

+        RLOGE("input null");

+        return LYNQ_E_NULL_ANONALY;

+    }

+    utoken = uToken;

+    global_param = (lynq_sdk_check_param_t *)malloc(sizeof(lynq_sdk_check_param_t));

+    if(global_param == NULL)

+    {

+        RLOGE("malloc global_param fail");

+        goto end;

+    }

+    memset(global_param,0,sizeof(lynq_sdk_check_param_t));

+    if(param->isvalid == 0)

+    {

+        ret = set_default_sdk_check_param(global_param);

+        if (ret < 0)

+        {

+            RLOGE("get default param fail");

+            goto end;

+        }

+    }

+    else

+    {

+        if((param->period.RIL < MIN_PERIOD_RIL) || (param->period.GNSS < MIN_PERIOD_GNSS) || (param->period.MD < MIN_PERIOD_MD) 

+        || (param->period.PTN < MIN_PERIOD_PTN) || (param->period.SYS < MIN_PERIOD_SYS))

+        {

+            RLOGE("param excption");

+            goto end;

+        }

+        global_param->period.RIL = param->period.RIL;

+        global_param->period.GNSS = param->period.GNSS;

+        global_param->period.MD = param->period.MD;

+        global_param->period.PTN = param->period.PTN;

+        global_param->period.SYS = param->period.SYS;

+        global_param->period.BOOT = param->period.BOOT;

+        global_param->threshold.interrupts = param->threshold.interrupts;

+        global_param->threshold.load_average = param->threshold.load_average;

+    }

+    RLOGI("period.RIL:%d,period.GNSS:%d,period.MD:%d,period.PTN:%d,period.SYS:%d,threshold.interrupts:%llu,threshold.load_average:%d",

+    global_param->period.RIL,global_param->period.GNSS,global_param->period.MD,global_param->period.PTN,

+    global_param->period.SYS,global_param->threshold.interrupts,global_param->threshold.load_average);

+    global_sdk_status_cb = sdk_status_cb;

+    global_sdk_status.sdk_ready_status = (lynq_sdk_status_t)-1;

+    global_sdk_status.ref_action = (lynq_sdk_ref_action_t)-1;

+    set_sdk_ready_nv(1);//开机默认RIL 异常,第一次检测完成之后更新正确值

+    ret = create_check_threads();

+    if(ret != 0)

+    {

+        goto end;

+    }

+    return ret;

+end:

+    exit(EXIT_FAILURE);

+}

+int lynq_get_sdk_ready_status(int *status)

+{

+    if (status == NULL)

+    {

+        RLOGE("sdk_ready_status is null");

+        return LYNQ_E_NULL_ANONALY;

+    }

+    *status = global_sdk_ready_status;

+    return 0;

+}

diff --git a/common_src/lib/liblynq-sdk-ready/makefile b/common_src/lib/liblynq-sdk-ready/makefile
new file mode 100755
index 0000000..faaf70d
--- /dev/null
+++ b/common_src/lib/liblynq-sdk-ready/makefile
@@ -0,0 +1,56 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -std=gnu++14 \
+                -flto \
+                -fPIC \
+                -D__LINUX_OS__ \
+
+
+
+LOCAL_PATH   = .
+$(warning ################# LEI ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I./include \
+  -I$(LOCAL_PATH)/include \
+  -I$(LOCAL_PATH) \
+  -I$(ROOT)$(includedir)/ \
+  -I$(ROOT)$(includedir)/include  \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -llog \
+    -lcutils \
+    -lutils \
+    -lbinder \
+    -lpthread \
+    -llynq-uci \
+    -llynq-misc \
+
+SOURCES = ./lynq_sdk_ready.cpp
+
+EXECUTABLE = liblynq-sdk-ready.so
+
+OBJECTS=$(SOURCES:.cpp=.o)
+
+
+.PHONY: build clean
+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)  ##########)
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)