Merge "[Feature][ZXW-139]fix esdk error after P50U02"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sms-demo/files/lynq-qser-sms-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sms-demo/files/lynq-qser-sms-demo.cpp
index 16be058..7e4c03c 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sms-demo/files/lynq-qser-sms-demo.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-sms-demo/files/lynq-qser-sms-demo.cpp
@@ -6,6 +6,7 @@
 #include <unistd.h>

 #include <dlfcn.h>

 #include <stdint.h>

+#include <ctype.h>

 

 #include"lynq-qser-sms-demo.h"

 

@@ -28,260 +29,156 @@
 int (*qser_sms_getsmscenteraddress)(sms_client_handle_type h_sms, QSER_sms_service_center_cfg_t *set_sca_cfg);

 int (*qser_sms_setsmscenteraddress)(sms_client_handle_type h_sms, QSER_sms_service_center_cfg_t *get_sca_cfg);

 

-

-typedef struct

-{

-    int  cmdIdx;

-    const char *funcName;

-} st_api_test_case;

-    

-//for server test

-st_api_test_case at_api_testcases[] = 

-{

-    {0,   "qser_sms_client_init"},

-    {1,   "qser_sms_client_deinit"},

-    {2,   "qser_sms_send_sms"},

-    {3,   "qser_sms_addrxmsghandler"},

-    {4,   "qser_sms_deletefromstorage"},

-    {5,   "qser_sms_getsmscenteraddress"},

-    {6,   "qser_sms_setsmscenteraddress"},

-    {-1,    NULL}

-};

-

-void print_help(void)

-{

-    int i;

-    printf("Supported test cases:\n");

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

-    {

-        if(at_api_testcases[i].cmdIdx == -1)

-        {

-            break;

-        }

-        printf("%d:\t%s\n", at_api_testcases[i].cmdIdx, at_api_testcases[i].funcName);

-    }

-}

-

 void qser_sms_handler(QSER_SMS_MsgRef msgRef, void* contextPtr) {

     printf("[%s-%d] sms handler, msgRef->sms_data = %s\n", __FUNCTION__, __LINE__, msgRef->sms_data);

 }

 

+bool isNumeric(char *phnum) {

+    int length = strlen(phnum);

+    

+    if (length == 0) {

+        return false;

+    }

+    

+    if (phnum[0] != '+' && (phnum[0] < '0' || phnum[0] > '9')) {

+        return false;

+    }

+    

+    if (phnum[0] == '+' && length < 3) {

+        return false;

+    }

+    

+    for (int i = 1; i < length; i++) {

+        if (phnum[i] < '0' || phnum[i] > '9') {

+            return false;

+        }

+    }

+    

+    return true;

+}

+

+//以下示例默认为所有API 执行都成功的情况下,依次执行后续API

 int main(int argc, char *argv[])

 {

-    int cmdIdx = 0;

     int ret    = 0;

-    

+    //char phnum[SMS_BUF]={0};

+

     const char *lynq_libpath_sms = "/lib/liblynq-qser-sms.so";

     void *dlHandle_sms = dlopen(lynq_libpath_sms, RTLD_NOW);

+    

     if (dlHandle_sms == NULL) 

     {

         printf("dlopen dlHandle_sms failed: %s\n", dlerror());

         exit(EXIT_FAILURE);

     }

 

-    print_help();

-    while(1)

+    if(argc != 2 || !isNumeric(argv[1]))

     {

-        printf("\nplease input cmd index(-1 exit): ");

-        scanf("%d", &cmdIdx);

-        if(cmdIdx == -1)

-        {

-            break;

-        }

-

-        switch(cmdIdx)

-        {

-            //"qser_sms_client_init"

-            case 0:

-            {

-                if(flag_init == 1)

-                {

-                   printf("init is already\n"); 

-                   break;

-                }

-                else{

-                    //int token;

-                    printf("input token\n");

-                    //scanf("%d", &token);

-

-                    qser_sms_client_init = (int(*)(sms_client_handle_type  *ph_sms))dlsym(dlHandle_sms,"qser_sms_client_init");

-                    if(NULL != qser_sms_client_init)

-                    {

-                        ret = qser_sms_client_init(&ph_sms);

-                        if(ret == 0)

-                        {

-                            printf("Run qser_sms_client_init\n");

-                             flag_init = 1;

-                        }else{

-                            printf("qser_sim_client_init error\n");

-                        }

-                     }else{

-                            printf("qser_sim_client_init dlsym error\n");

-                     }

-                     break;

-                    }

-                }

-            //"qser_sms_client_deinit"

-            case 1:

-            {

-                 if(flag_init == 0){

-                    printf("must init first\n");

-                }

-                else{

-                    qser_sms_client_deinit = (int (*)(sms_client_handle_type h_sms))dlsym(dlHandle_sms,"qser_sms_client_deinit");

-                    if(NULL != qser_sms_client_deinit)

-                    {

-                        ret = qser_sms_client_deinit(h_sms);

-                        if(ret == 0)

-                        {

-                            printf("sms deinit success");

-                        }else{

-                            printf("sms deinit error, ret = %d\n", ret);

-                        }

-                    }else{

-                        printf("qser_sms_client_deinit dlsym error\n");

-                    }

-                }

-                break;

-            }

-            //"qser_sms_send_sms"

-            case 2:

-            {

-                 if(flag_init == 0){

-                    printf("must init first\n");

-                }

-                else{

-                    char telephony_num[SMS_BUF] = {};

-                    char msg[MSG_BUF] = {};

-                    QSER_sms_info_t  pt_sms_info;

-                    sprintf(telephony_num,"10086");

-                    sprintf(msg,"hello");

-                    strncpy(pt_sms_info.src_addr, telephony_num, SMS_BUF);

-                    strncpy(pt_sms_info.sms_data, msg, MSG_BUF);

-                    pt_sms_info.format = QSER_SMS_8BIT;

-                    printf("[%s,%d]  src_addr=%s, telephony_num = %s\n",__FUNCTION__,__LINE__, pt_sms_info.src_addr, telephony_num);

-                    printf("[%s,%d]  sms_data=%s, msg = %s\n",__FUNCTION__,__LINE__, pt_sms_info.sms_data, msg);

-

-                    qser_sms_send_sms = (int (*)(sms_client_handle_type h_sms, QSER_sms_info_t *pt_sms_info))dlsym(dlHandle_sms,"qser_sms_send_sms");

-                    if(NULL != qser_sms_send_sms)

-                    {

-                        ret = qser_sms_send_sms(h_sms, &pt_sms_info);

-                        if(ret == 0)

-                        {

-                            printf("send sms success");

-                        }else{

-                            printf("send sms error, ret = %d\n", ret);

-                        }

-                    }else{

-                        printf("qser_sms_send_sms dlsym error\n");

-                    }

-                }

-                break;

-            }

-            //"qser_sms_addrxmsghandler"

-            case 3:

-            {

-                 if(flag_init == 0){

-                    printf("must init first\n");

-                }

-                else{

-

-                    qser_sms_addrxmsghandler = (int(*)(QSER_SMS_RxMsgHandlerFunc_t handlerPtr, void* contextPtr))dlsym(dlHandle_sms,"qser_sms_addrxmsghandler");

-

-                    if(NULL != qser_sms_addrxmsghandler)

-                    {

-                        ret = qser_sms_addrxmsghandler(qser_sms_handler, NULL);

-                        if(ret == 0)

-                        {

-                            printf("qser_sms_addrxmsghandler success");

-                        }else{

-                            printf("qser_sms_addrxmsghandler error, ret = %d\n", ret);

-                        }

-                    }else{

-                        printf("qser_sms_addrxmsghandler dlsym error\n");

-                    }

-                }

-                break;

-            }

-            //"qser_sms_deletefromstorage"

-            case 4:

-            {

-                 if(flag_init == 0){

-                    printf("must init first\n");

-                }

-                else{

-                    QSER_sms_storage_info_t  pt_sms_storage;

-                    pt_sms_storage.storage_idx = 1;

-                    qser_sms_deletefromstorage = (int (*)(sms_client_handle_type  h_sms, QSER_sms_storage_info_t  *pt_sms_storage))dlsym(dlHandle_sms,"qser_sms_deletefromstorage");

-                    if(NULL != qser_sms_deletefromstorage)

-                    {

-                        ret = qser_sms_deletefromstorage(h_sms, &pt_sms_storage);

-                        if(ret == 0)

-                        {

-                            printf("ret= %d\n",ret);

-                        }else{

-                            printf("del sms error, ret = %d\n", ret);

-                        }

-                    }else{

-                        printf("qser_sms_deletefromstorage dlsym error\n");

-                    }

-                }

-                break;

-            }

-             //"qser_sms_getsmscenteraddress"

-            case 5:

-            {

-                if(flag_init == 0){

-                    printf("must init first\n");

-                }

-                else{ 

-                    QSER_sms_service_center_cfg_t get_sca_cfg;

-                    qser_sms_getsmscenteraddress = (int (*)(sms_client_handle_type h_sms, QSER_sms_service_center_cfg_t *get_sca_cfg))dlsym(dlHandle_sms,"qser_sms_getsmscenteraddress");

-                    if(NULL != qser_sms_getsmscenteraddress)

-                    {

-                        ret = qser_sms_getsmscenteraddress(h_sms, &get_sca_cfg);

-                        if(ret == 0)

-                        {

-                            printf("get smsc success,service_center_addr = %s\n",get_sca_cfg.service_center_addr);

-                        }else{

-                            printf("get smsc error, ret = %d\n", ret);

-                        }

-                    }else{

-                        printf("qser_sms_getsmscenteraddress dlsym error\n");

-                    }

-                }

-                break;

-            }

-             //"qser_sms_setsmscenteraddress"

-            case 6:

-            {

-                if(flag_init == 0){

-                    printf("must init first\n");

-                }

-                else{ 

-                    QSER_sms_service_center_cfg_t set_sca_cfg;

-                    strncpy(set_sca_cfg.service_center_addr, "+8613800230500", 14);

-                    qser_sms_setsmscenteraddress = (int (*)(sms_client_handle_type h_sms, QSER_sms_service_center_cfg_t *set_sca_cfg))dlsym(dlHandle_sms,"qser_sms_setsmscenteraddress");

-                    if(NULL != qser_sms_setsmscenteraddress)

-                    {

-                        ret = qser_sms_setsmscenteraddress(h_sms, &set_sca_cfg);

-                        if(ret == 0)

-                        {

-                            printf("set smsc success");

-                        }else{

-                            printf("set smsc error, ret = %d\n", ret);

-                        }

-                    }else{

-                        printf("qser_sms_setsmscenteraddress dlsym error\n");

-                    }

-                }

-                break;

-            }

-            default:

-                print_help();

-                break;

-        }           

+        printf("[%s][%d] please input correct phnum\n",__FUNCTION__,__LINE__);

+        exit(1);

     }

     

-   return 0;

+    qser_sms_client_init = (int(*)(sms_client_handle_type  *ph_sms))dlsym(dlHandle_sms,"qser_sms_client_init");

+    if(NULL != qser_sms_client_init)

+    {

+        ret = qser_sms_client_init(&ph_sms);

+        if(ret == 0)

+        {

+            printf("Run qser_sms_client_init\n");

+        }else{

+            printf("qser_sim_client_init error\n");

+        }

+     }else{

+            printf("qser_sim_client_init dlsym error\n");

+     }

+

+    sleep(2);

+

+    qser_sms_addrxmsghandler = (int(*)(QSER_SMS_RxMsgHandlerFunc_t handlerPtr, void* contextPtr))dlsym(dlHandle_sms,"qser_sms_addrxmsghandler");

+

+    if(NULL != qser_sms_addrxmsghandler)

+    {

+        ret = qser_sms_addrxmsghandler(qser_sms_handler, NULL);

+        if(ret == 0)

+    {

+        printf("qser_sms_addrxmsghandler success");

+    }else{

+        printf("qser_sms_addrxmsghandler error, ret = %d\n", ret);

+    }

+    }else{

+        printf("qser_sms_addrxmsghandler dlsym error\n");

+    }

+    

+    QSER_sms_service_center_cfg_t get_sca_cfg;

+    qser_sms_getsmscenteraddress = (int (*)(sms_client_handle_type h_sms, QSER_sms_service_center_cfg_t *get_sca_cfg))dlsym(dlHandle_sms,"qser_sms_getsmscenteraddress");

+    if(NULL != qser_sms_getsmscenteraddress)

+    {

+        ret = qser_sms_getsmscenteraddress(h_sms, &get_sca_cfg);

+        if(ret == 0)

+        {

+            printf("get smsc success,service_center_addr = %s\n",get_sca_cfg.service_center_addr);

+        }else{

+            printf("get smsc error, ret = %d\n", ret);

+        }

+    }else{

+        printf("qser_sms_getsmscenteraddress dlsym error\n");

+    }

+    sleep(1);

+    QSER_sms_service_center_cfg_t set_sca_cfg;

+    strncpy(set_sca_cfg.service_center_addr, "+8613800230500", 14);//smsc ÊǸù¾Ý²»Í¬ÔËÓªÉÌ£¬²»Í¬¿¨À´ÅäÖõÄ

+    qser_sms_setsmscenteraddress = (int (*)(sms_client_handle_type h_sms, QSER_sms_service_center_cfg_t *set_sca_cfg))dlsym(dlHandle_sms,"qser_sms_setsmscenteraddress");

+    if(NULL != qser_sms_setsmscenteraddress)

+    {

+        ret = qser_sms_setsmscenteraddress(h_sms, &set_sca_cfg);

+        if(ret == 0)

+        {

+            printf("set smsc success");

+        }else{

+            printf("set smsc error, ret = %d\n", ret);

+        }

+    }else{

+        printf("qser_sms_setsmscenteraddress dlsym error\n");

+    }

+

+   // char telephony_num[SMS_BUF] = {};

+    char msg[MSG_BUF] = {};

+    QSER_sms_info_t  pt_sms_info;

+   // sprintf(telephony_num,"10086");//请用户务必替换此号码,随意向运营商发短消息极有可能被封号。

+    sprintf(msg,"hello");

+    strncpy(pt_sms_info.src_addr, argv[1], SMS_BUF);

+    strncpy(pt_sms_info.sms_data, msg, MSG_BUF);

+    pt_sms_info.format = QSER_SMS_8BIT;

+  //  printf("[%s,%d]  src_addr=%s, telephony_num = %s\n",__FUNCTION__,__LINE__, pt_sms_info.src_addr, telephony_num);

+    printf("[%s,%d]  sms_data=%s, msg = %s\n",__FUNCTION__,__LINE__, pt_sms_info.sms_data, msg);

+

+    qser_sms_send_sms = (int (*)(sms_client_handle_type h_sms, QSER_sms_info_t *pt_sms_info))dlsym(dlHandle_sms,"qser_sms_send_sms");

+    if(NULL != qser_sms_send_sms)

+    {

+        ret = qser_sms_send_sms(h_sms, &pt_sms_info);

+        if(ret == 0)

+        {

+            printf("send sms success");

+        }else{

+            printf("send sms error, ret = %d\n", ret);

+        }

+    }else{

+        printf("qser_sms_send_sms dlsym error\n");

+    }

+

+    sleep(120);//在此期间向模组发送短消息,即可触发“接受新短消息事件”。

+    qser_sms_client_deinit = (int (*)(sms_client_handle_type h_sms))dlsym(dlHandle_sms,"qser_sms_client_deinit");

+    if(NULL != qser_sms_client_deinit)

+    {

+        ret = qser_sms_client_deinit(h_sms);

+        if(ret == 0)

+        {

+            printf("sms deinit success");

+        }else{

+            printf("sms deinit error, ret = %d\n", ret);

+        }

+    }else{

+        printf("qser_sms_client_deinit dlsym error\n");

+    }

+    

 }

+

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.cpp
index 5feff58..3b35553 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.cpp
@@ -83,7 +83,11 @@
     switch(level)
     {
         case LOG_VERBOSE:
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+            __android_log_vprint(ANDROID_LOG_ERROR,log_entry->module_name, format, args);
+#else
             __android_log_vprint(ANDROID_LOG_VERBOSE,log_entry->module_name, format, args);
+#endif
             break;
         case LOG_ERROR:
             __android_log_vprint(ANDROID_LOG_ERROR,log_entry->module_name, format, args);
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
index 6a79c6c..d1114fc 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
@@ -614,6 +614,11 @@
             continue;
         }
         modify_node = modify_node->next;
+        if(modify_node == NULL)
+        {
+            LYERRLOG("modify_node is null\n");
+            goto FAILED;
+        }
     }
     apn->profile_idx = (unsigned char)atoi(xmlGetProp(modify_node, "profile_idx"));
     apn->pdp_type = (qser_apn_pdp_type_e)atoi(xmlGetProp(modify_node, "pdp_type"));
@@ -743,6 +748,7 @@
     int table_num = 0;
     lynq_apn_info **apn_table = NULL;
     qser_apn_info_s apn;
+    int ret = 0;
     apn_table = (lynq_apn_info **)malloc(sizeof(lynq_apn_info *)*LYNQ_APN_CHANNEL_MAX);
     if (NULL == apn_table)
     {
@@ -764,7 +770,12 @@
     }
     lynq_get_apn_table(&table_num,apn_table);
     memset(&apn,0,sizeof(qser_apn_info_s));
-    apn_xml_query(profile_idx,&apn);
+    ret = apn_xml_query(profile_idx,&apn);
+    if (ret < 0)
+    {
+        LYERRLOG("apn_xml_query error");
+        return ret;
+    }
     for (int j = 0;j < table_num;j++)
     {
         if (strcmp(apn.apn_type,apn_table[j]->apnType) == 0)
@@ -966,7 +977,12 @@
     {
         char pdptype[16];
         qser_apn_info_s apn_info;
-        qser_apn_get(data_call->profile_idx,&apn_info);
+        ret = qser_apn_get(data_call->profile_idx,&apn_info);
+        if (ret != 0)
+        {
+            LYERRLOG("qser_apn_get error");
+            return ret;
+        }
         judge_pdp_type(apn_info.pdp_type,pdptype);
         ret = lynq_setup_data_call_sp(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,NULL,pdptype,pdptype);
     }
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts
index ff55fb9..1067603 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts
@@ -202,7 +202,7 @@
 	
 	label = "GPIO Key USER2";//flight mode
 	linux,code = <KEY_WAKEUP>;
-	status = "okay";
+	status = "disabled";
 };
 
 
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c
index a2a8400..81108b2 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_cc.c
@@ -621,8 +621,15 @@
 

 void requestAnswer(void *data __unused, size_t datalen __unused, RIL_Token t)

 {

-	at_send_command("ATA", NULL);

-

+    //l.yang modify for bug id T106BUG-54 2023/9/20 start 

+    ATResponse *p_response = NULL;

+    at_send_command("ATA", &p_response);

+    if( p_response->success == 0) 

+    {

+        goto error;

+    }

+    //l.yang modify for bug id T106BUG-54 2023/9/20 end 

+    

 #ifdef WORKAROUND_ERRONEOUS_ANSWER

 	s_expectAnswer = 1;

 #endif /* WORKAROUND_ERRONEOUS_ANSWER */

@@ -630,6 +637,11 @@
 	/* success or failure is ignored by the upper layer here.

 	   it will call GET_CURRENT_CALLS and determine success that way */

 	RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);

+    //l.yang modify for bug id T106BUG-54 2023/9/20 start 

+error:

+    RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);

+    at_response_free(p_response);

+    //l.yang modify for bug id T106BUG-54 2023/9/20 end 

 }

 

 void requestConference(void *data __unused, size_t datalen __unused, RIL_Token t)