Merge "[Bugfix][T106][bug-view-408]fix the problem of after deleting all sms,the database states incorrect"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-sim/liblynq-sim.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-sim/liblynq-sim.bb
index 7b8ff1d..65d5358 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-sim/liblynq-sim.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-sim/liblynq-sim.bb
@@ -3,7 +3,7 @@
 DESCRIPTION = "lynq sim"
 LICENSE = "CLOSED"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
-DEPENDS += "libpal gstreamer1.0 glib-2.0 libapn liblynq-log libvendor-ril liblynq-shm libbinder"
+DEPENDS += "libpal gstreamer1.0 glib-2.0 libapn liblynq-log libvendor-ril liblynq-shm libbinder liblynq-uci libsctel"
 #inherit workonsrc
 WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-sim/"
 FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/lib/:"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp
index e0e20c9..3e55731 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp
@@ -25,6 +25,11 @@
 #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) 

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

 

@@ -43,6 +48,12 @@
 int g_module_init_flag = 0;

 

 int lynq_network_init(int utoken){

+

+    LYLOGSET(LOG_INFO);

+    LYLOGEINIT(USER_LOG_TAG);

+

+    LYERRLOG("%s start, parameter is %d", __func__,utoken);

+

     if(g_module_init_flag != MODULE_CLOSED)

     {

         LYERRLOG("module state is %d",g_module_init_flag);

@@ -57,9 +68,7 @@
     g_module_init_flag = MODULE_SWITCHING;

 

     g_module_Global_uToken = utoken;

-    LYLOGSET(LOG_INFO);

-    LYLOGEINIT(USER_LOG_TAG);

-    

+	   

     int ret;

 

     init_network_timer_all();

@@ -81,12 +90,16 @@
         return LYNQ_E_INNER_ERROR;

     }

     g_module_init_flag = MODULE_RUNNING;

+

+    LYERRLOG("%s end suc", __func__);

     

     return RESULT_OK;    

 }

 

 int lynq_network_deinit(void){

 

+    LYERRLOG("%s start", __func__);

+

     if (g_module_init_flag != MODULE_RUNNING)

     {

        LYERRLOG("module state is %d",g_module_init_flag);

@@ -99,6 +112,8 @@
     deinit_network_timer_all();

 

     g_module_init_flag = MODULE_CLOSED;

+

+    LYERRLOG("%s end suc", __func__);

     return RESULT_OK;    

 }

 

@@ -651,7 +666,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)

     {

@@ -1379,11 +1394,11 @@
 

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

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

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

     }

 

     if(ret!=RESULT_OK)

@@ -1641,7 +1656,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);

@@ -1661,52 +1676,50 @@
         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;   

 }

 

+

 static pthread_mutex_t urc_signal_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;

 static pthread_cond_t urc_signal_state_change_cond = PTHREAD_COND_INITIALIZER;

 

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/include/lynq_qser_sim.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/include/lynq_qser_sim.h
index 3260899..dc9874b 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/include/lynq_qser_sim.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/include/lynq_qser_sim.h
@@ -388,7 +388,7 @@
 
 int qser_sim_addrxmsghandler(QSER_SIM_RxMsgHandlerFunc_t handlerPtr);
 
-
+int qser_sim_profile(char *cmd, char *rsp);
 #ifdef __cplusplus
 }
 #endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp
index bca9b0c..672a532 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp
@@ -366,5 +366,12 @@
     ret = lynq_reset_sim();
     return ret;
 }
+
+int qser_sim_profile(char *cmd, char *rsp)
+{
+    if(lynq_req_sim_profile(cmd, rsp))
+        return -1;
+    return 0;
+}
 DEFINE_LYNQ_LIB_LOG(LYNQ_QSER_SIM)
 
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sim/include/libsim/lynq_sim.h b/cap/zx297520v3/src/lynq/lib/liblynq-sim/include/libsim/lynq_sim.h
index 9304a14..4af682c 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-sim/include/libsim/lynq_sim.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sim/include/libsim/lynq_sim.h
@@ -38,7 +38,7 @@
 int lynq_get_imei_and_sv(char imei[],char sv[]);
 int lynq_wait_sim_state_change(int *handle);
 int lynq_read_sim_status(int handle, int *card_status);
-
+int lynq_req_sim_profile(char *cmd, char *rsp);
 
 
 /**
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_sim.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_sim.cpp
index e5905c2..10a86fa 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_sim.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sim/lynq_sim.cpp
@@ -27,6 +27,7 @@
 #include "lynq_module_common.h"
 #include "lynq_module_socket.h"
 #include "lynq_sim.h"
+#include "sc_at.h"
 #define MAX_BUF 20
 #define MAX_NUM 80
 //#define LYNQ_REQUEST_SET_DEFAULT_SIM_ALL 8008
@@ -1261,5 +1262,41 @@
     return 0;
 }
 
+int check_cmd(char* cmd_str,char* check_str)
+{
+    int check_size = strlen(check_str);
+    for(int i = 0; i < check_size; i++)
+    {
+        if (!isalpha(cmd_str[i]))
+        {
+            return -1;
+        }
+        if (tolower(cmd_str[i]) != check_str[i] && toupper(cmd_str[i]) != check_str[i])
+        {
+            return -1;
+        }
+    }
+    return 0;
+}
+
+int lynq_req_sim_profile(char *cmd, char *rsp)
+{
+    int ret;
+    char* check_str = "AT";
+    ret = check_cmd(cmd,check_str);
+    if(ret)
+    {
+        RLOGE("wrong input\r\n");
+        return -1;
+    }
+    ret = sc_at_send(1,cmd,rsp,sizeof(rsp));
+    if(ret)
+    {
+        RLOGE("at_send failed.the reason is: %s\r\n",rsp);
+        return -1;
+    }
+    return 0;
+}
+
 DEFINE_LYNQ_LIB_LOG(LYNQ_SIM)
 
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sim/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-sim/makefile
index 4010fd6..40beb7a 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-sim/makefile
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sim/makefile
@@ -32,6 +32,7 @@
   -I$(ROOT)$(includedir)/logger \
   -I$(ROOT)$(includedir)/liblog \
   -I$(ROOT)$(includedir)/lynq_shm \
+  -I$(ROOT)$(includedir)\
 
 
 LOCAL_LIBS := \
@@ -41,11 +42,16 @@
     -llog \
     -lcutils \
     -lutils \
-    -lbinder \
     -lpthread \
     -llynq-log \
+    -lxml2 \
+    -llynq-uci \
+    -lsctel \
+    -lbinder \
     -llynq-shm \
 
+
+
 SOURCES = $(wildcard *.cpp)
 
 EXECUTABLE = liblynq-sim.so
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_mm.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_mm.c
index 3835d91..d734936 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_mm.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_mm.c
@@ -643,7 +643,7 @@
 			gsm->signalStrengthGsm.signalStrength = 99;

 		} else if (tGsmEmInfo->bRssi > 99 && tGsmEmInfo->bRssi < 200) {

 			gsm->signalStrengthGsm.signalStrength = changeCSQdbmToLevel(tGsmEmInfo->bRssi - 216, 3);

-		} else if (tGsmEmInfo->bRssi > 1 && tGsmEmInfo->bRssi <= 60) {

+		} else if (tGsmEmInfo->bRssi >= 1 && tGsmEmInfo->bRssi <= 60) { //LYNQ_HUANG_QING_AT_20241126_ZXW_BUG_18_CR_20240807C6B104DE_CHANGE_>_TO_>=

 			gsm->signalStrengthGsm.signalStrength = (tGsmEmInfo->bRssi+ 1) / 2 + 1; /*2-31,99*/

 		} else if (60 < tGsmEmInfo->bRssi && tGsmEmInfo->bRssi <= 63) {

 			gsm->signalStrengthGsm.signalStrength = 31;

@@ -810,7 +810,7 @@
 

 		if (tMeasInfo->bRssi > 99 && tMeasInfo->bRssi < 200) {

 			gsm->signalStrengthGsm.signalStrength = changeCSQdbmToLevel(tMeasInfo->bRssi - 216, 3);

-		} else if (tMeasInfo->bRssi > 1 && tMeasInfo->bRssi <= 60) {

+		} else if (tMeasInfo->bRssi >= 1 && tMeasInfo->bRssi <= 60) { //LYNQ_HUANG_QING_AT_20241126_ZXW_BUG_18_CR_20240807C6B104DE_CHANGE_>_TO_>=

 			gsm->signalStrengthGsm.signalStrength = (tMeasInfo->bRssi+ 1) / 2 + 1; /*2-31,99*/

 		} else if (60 < tMeasInfo->bRssi && tMeasInfo->bRssi <= 63) {

 			gsm->signalStrengthGsm.signalStrength = 31;

@@ -1726,7 +1726,7 @@
 			level = 99;

 		}else if (rxlev > 99 && rxlev < 200) {

 			level = changeCSQdbmToLevel(rxlev - 216, 3);

-		} else if (rxlev > 1 && rxlev <= 60) {

+		} else if (rxlev >= 1 && rxlev <= 60) { //LYNQ_HUANG_QING_AT_20241126_ZXW_BUG_18_CR_20240807C6B104DE_CHANGE_>_TO_>=

 			level = (rxlev + 1) / 2 + 1; /*2-31,99*/

 		} else if (60 < rxlev && rxlev <= 63) {

 			level = 31;