Merge "[Bugfix][T106BUG-197][T106BUG-199][T106BUG-200][T106BUG-201] fix qser sms demo error"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh
index 604cd22..b6946d5 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh
@@ -1,7 +1,9 @@
 #!/bin/sh
 
-if [ ! -f "/mnt/userdata/config" ];then
+if [ ! -d "/mnt/userdata/config/" ];then
 	cp -R /etc/config /mnt/userdata/
+else
+	echo "uci config has exist"
 fi
 
 # 0 for usb, 1 for net
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/lynq-autosuspend.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/lynq-autosuspend.cpp
index 54c88fd..ced8635 100644
--- a/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/lynq-autosuspend.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/lynq-autosuspend.cpp
@@ -405,26 +405,27 @@
     int ret;
     printf("Get param:%s \n", name);
     ret = sc_pm_wakelock_lock(name);
-    if (ret)
+    if (ret != 0)
     {
         printf("do_wakelock failed, err:%d", ret);
-        return ret;
+        return -1;
     }
+
     printf("do_wakelock succeed\n");
-    return ret;
+    return 1;
 }
 int release_wake_lock(char *name)
 {
     int ret;
     printf("Get param:%s \n", name);
     ret = sc_pm_wakelock_unlock(name);
-    if (ret)
+    if (ret != 0)
     {
         printf("do_wakeunlock failed, err:%d", ret);
-        return ret;
+        return -1;
     }
     printf("do_wakeunlock succeed\n");
-    return ret;
+    return 1;
 }
 int lynq_set_lpmode(int lp_mode)
 {
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-autosuspend/include/lynq-qser-autosuspend.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/include/lynq-qser-autosuspend.h
index 54b663f..8ea9c01 100644
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/include/lynq-qser-autosuspend.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/include/lynq-qser-autosuspend.h
@@ -13,7 +13,9 @@
 
 #define E_READ -2
 #define E_WRITE -3
-#define E_INIT -4
+#define E_TABLE_FULL -4
+#define E_LOCK_EXIST -5
+#define E_INPUT_ERROR -6
 
 typedef enum 
 {
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
index c037505..2a5ff52 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
@@ -6,11 +6,8 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <pthread.h>
-
 #include<unistd.h>
 
-
-
 #include <lynq_autosuspend.h>
 #include "lynq-qser-autosuspend.h"
 #include "liblog/lynq_deflog.h"
@@ -54,7 +51,7 @@
     {
         LYINFLOG("write fail\n");
         close(file_fd);
-        return -1;
+        return E_WRITE;
     }
     sync();
     close(file_fd);
@@ -75,7 +72,7 @@
         ret = lock_table_init();
         if(ret < 0)
         {
-            return -2;
+            return E_READ;
         }
     }
 
@@ -84,7 +81,7 @@
     {
         err = errno;
         LYINFLOG("Error open lock_table file:%s\n", strerror(errno));
-        return -2;
+        return E_READ;
     }
 
     memset(&lock_status, 0, sizeof(lock_status));
@@ -94,7 +91,7 @@
     if(ret <= 0)
     {
         close(file_fd);
-        return -2;
+        return E_READ;
     }
 
     for(i=0;i<MAX_LOCK_NUM;i++)
@@ -119,7 +116,7 @@
     {
         err = errno;
         LYINFLOG("Error open lock_table file:%s\n", strerror(errno));
-        return -3;
+        return E_WRITE;
     }
     LYINFLOG("write lock_name[0]: %s\n", lock_status.lock_name[0]);
     ret = write(file_fd, (unsigned char *)&lock_status, sizeof(lock_status));
@@ -128,7 +125,7 @@
     {
         LYINFLOG("write fail\n");
         close(file_fd);
-        return -3;
+        return E_WRITE;
     }
     sync();
     close(file_fd);
@@ -189,7 +186,7 @@
         }
         if(i == MAX_LOCK_NUM)
         {
-            return -1;
+            return E_TABLE_FULL;
         }
         else
         {
@@ -198,7 +195,7 @@
     }
     else
     {
-        num = check_flag;
+        return E_LOCK_EXIST;
     }
 
     LYINFLOG("num = %d\n", num);
@@ -255,6 +252,7 @@
     return 0;
 }
 
+
 int qser_autosuspend_enable(char enable)
 {
     int ret;
@@ -269,19 +267,24 @@
     }
     else
     {
-        ret = -1;
+        return E_INPUT_ERROR;
 
     }
+    if(ret >= 0)
+    {
+        ret = 0;
+    }
     return ret;
 
 }
 
+
 int qser_wakelock_create(const char *name, size_t len)
 {
     int ret;
     if(name == NULL)
     {
-        return -1;
+        return E_INPUT_ERROR;
     }
     LYINFLOG("%s\n", name);
     ret = add_lock(name);
@@ -294,10 +297,18 @@
     int ret;
     if(fd < 0 || fd >= MAX_LOCK_NUM)
     {
-        return -4;
+        return E_INPUT_ERROR;
     }
     ret = read_lock_table();
     ret = acquire_wake_lock( 0, lock_status.lock_name[fd]);
+    if(ret > 0)
+    {
+        ret = 0;
+    }
+    else
+    {
+        ret = -1;
+    }
     return ret;
 }
 
@@ -306,7 +317,7 @@
     int ret;
     if(fd < 0 || fd >= MAX_LOCK_NUM)
     {
-        return -4;
+        return E_INPUT_ERROR;
     }
     ret = read_lock_table();
     if(strlen(lock_status.lock_name[fd]) == 0)
@@ -315,6 +326,14 @@
         return -1;
     }
     ret = release_wake_lock(lock_status.lock_name[fd]);
+    if(ret > 0)
+    {
+        ret = 0;
+    }
+    else
+    {
+        ret = -1;
+    }
     return ret;
 }
 
@@ -323,7 +342,7 @@
     int ret;
     if(fd < 0 || fd >= MAX_LOCK_NUM)
     {
-        return -4;
+        return E_INPUT_ERROR;
     }
     ret = delete_lock(fd);
     return ret;
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)