Merge "[Bugfix][T106BUG-454][AUTOSUSPEND]find Segmentation fault when deinit after deinit"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
index 2c4f1e0..84a727b 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
@@ -48,16 +48,21 @@
         return -1;

 

     }

-

-    //read fota upgrade flag, 0 :upgrade failed, 1:upgrade success

+    

     fread(&sync_flag,sizeof(int),1,fp);

-

+    

     if(sync_flag == FOTA_SYNC_FLAG)

     {

-        printf("upgrade flag is success ");

-        return 0;

+        ret = lynq_sync_system();

+        if(ret != 0)

+        {

+            printf("sync faild\n");

+            fclose(fp);

+        }

+       system("rm -rf /mnt/userdata/.back_up_flag");

+        

     }

-    else if(sync_flag != FOTA_SYNC_FLAG) 

+    else if(sync_flag != FOTA_SYNC_FLAG)

     {

         ret = lynq_fota_get_addr_value(tmp_addr);

         if(ret != 0)

@@ -81,8 +86,7 @@
         }

         

     }

-    

-

+   

     return 0;

 

 }

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/poweralarm-demo/files/poweralarm-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/poweralarm-demo/files/poweralarm-demo.cpp
index 2e0f71f..0bca3bb 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/poweralarm-demo/files/poweralarm-demo.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/poweralarm-demo/files/poweralarm-demo.cpp
@@ -8,7 +8,7 @@
 

 

 #define INIT_SUCCESS    0

-

+#define RTC_DEINIT    -1

 typedef struct

 {

     int  cmdIdx;

@@ -285,6 +285,10 @@
                             printf("lynq rtc service deinit failed \n");

                             return -1;

                         }

+                        else

+                        {

+                            init_flag = RTC_DEINIT;

+                        }

                     }

                     break;

                 }

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 395cf95..fb7494a 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
@@ -603,6 +603,61 @@
     return RESULT_ERROR;
 }
 
+int apn_xml_handle_clean()
+{
+    int node_num = 0;
+    int default_handle = LYNQ_APN_CHANNEL_MAX + 1;
+    xmlNodePtr node = NULL;
+    xmlNodePtr modify_node = NULL;
+    xmlChar *temp_char;
+    char temp_buff[12];
+
+    if(NULL == apn_table_xml_pdoc)
+    {
+        LYERRLOG("open xml file error");
+        goto FAILED;
+    }
+    
+    node = xmlDocGetRootElement(apn_table_xml_pdoc);
+    if (NULL == node)
+    {
+        LYERRLOG("xmlDocGetRootElement() error");
+        goto FAILED;
+    }
+    modify_node = node->xmlChildrenNode;
+    if(modify_node != NULL)
+    {
+        modify_node = modify_node->next;
+    }
+    else
+    {
+        LYERRLOG("modify_node is null\n");
+        goto FAILED;
+    }
+    while (modify_node != NULL)
+    {
+        temp_char = xmlGetProp(modify_node, "handle");
+        if (temp_char == NULL) 
+        {
+            modify_node = modify_node->next;
+            continue;
+        }
+        bzero(temp_buff,12);
+        snprintf(temp_buff,sizeof(temp_buff),"%d",default_handle);
+        xmlSetProp(modify_node,BAD_CAST"handle",(xmlChar *)temp_buff);
+        modify_node = modify_node->next;
+    }
+    xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1);
+    return RESULT_OK;
+
+    FAILED:
+    // if (apn_table_xml_pdoc)
+    // {
+    //     xmlFreeDoc(apn_table_xml_pdoc);
+    // }
+    return RESULT_ERROR;
+}
+
 int apn_xml_add(qser_apn_add_s *apn,unsigned char *apn_num)
 {
     int node_num = 0;
@@ -1254,6 +1309,12 @@
         LYERRLOG("open xml file error");
         return RESULT_ERROR;
     }
+    ret = apn_xml_handle_clean();
+    if(ret != RESULT_OK)
+    {
+        LYERRLOG("clean handle error");
+        return RESULT_ERROR;
+    }
     g_lynq_qser_data_init_flag = 1;
     return RESULT_OK;
 }
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp
index fb00165..d349bd5 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp
@@ -64,6 +64,8 @@
 extern int sc_rtc_time_get(int srcid, sc_rtc_time_get_cb rtc_notify);

 extern int sc_cfg_get(char *name, char* buf, int bufLen);

 extern int sc_cfg_set (char *name, char *value);

+extern int get_terminate_flag(void);

+

 

 

 char sync_from_rtc_cb_flag = 1;

@@ -230,6 +232,7 @@
     int ret = -1;

     int srcid = -1;

     int i = 0;

+    int count = 0;

     if ((srcid = sc_rtc_timer_init()) <= 0)

     {

         LYERRLOG("rtc_timer_demo:rtc_timer_init fail!\n");

@@ -264,6 +267,12 @@
         LYERRLOG("uninit failed \n");

         return -1;

     }

+    //xy.he add for T106BUG-413 2024-01-04

+    while((get_terminate_flag() == 0) && (count <100))

+    {

+        usleep(10*1000);

+        count ++;

+    }

     return 0;

 }

 

@@ -274,6 +283,7 @@
     LYDBGLOG("[%s][%d] enter.\n", __FUNCTION__, __LINE__);

     int ret = -1;

     int srcid = -1;

+    int count = 0;

     if ((srcid = sc_rtc_timer_init()) <= 0)

     {

         LYERRLOG("rtc_timer_demo:rtc_timer_init fail!\n");

@@ -291,7 +301,13 @@
         LYERRLOG("uninit failed \n");

         return -1;

     }

-    usleep(5000);

+    //xy.he add for T106BUG-413 2024-01-04

+    while((get_terminate_flag() == 0) && (count <100))

+    {

+        usleep(10*1000);

+        count ++;

+    }

+    printf("lynq_set_rtc_time_success\n");

     return 0;

 }

 

@@ -303,6 +319,7 @@
     int ret = -1;

     int srcid = -1;

     int i = 0;

+    int count = 0;

     if (NULL == ulsec)

     {

         LYERRLOG("NULL parameter!\n");

@@ -341,6 +358,12 @@
         LYERRLOG("uninit failed \n");

         return -1;

     }

+    //xy.he add for T106BUG-413 2024-01-04

+    while((get_terminate_flag() == 0) && (count <100))

+    {

+        usleep(10*1000);

+        count ++;

+    }

     return 0;

 }

 #endif

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-systime/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-systime/makefile
index d0e37e8..20fc50a 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-systime/makefile
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-systime/makefile
@@ -38,6 +38,7 @@
     -llynq-uci \

     -llynq-log \

     -lnvram \

+    -lscipc \

 

 

 SOURCES = $(wildcard *.cpp)

diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c
index 7b32b99..04dc0c4 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libscipc/sc_ipc.c
@@ -52,6 +52,8 @@
 static int s_local_fd = -1;

 static int s_local_key = -1;

 static int s_remote_fd = -1;

+//xy.he add for T106BUG-413 2024-01-04

+int terminate_loop_flag = 0;

 

 static pthread_t s_tid_dispatch;

 //static pthread_t s_tid_reader;

@@ -284,6 +286,8 @@
 

 	pthread_mutex_lock(&s_startupMutex);

     s_started = 1;

+    //xy.he add for T106BUG-413 2024-01-04

+    terminate_loop_flag = 0;

     pthread_cond_broadcast(&s_startupCond);

     pthread_mutex_unlock(&s_startupMutex);

 	

@@ -311,7 +315,9 @@
 

     if(-1 != s_local_fd)

         sc_ipc_destroy_msg_fd(s_local_fd);

-

+    //xy.he add for T106BUG-413 2024-01-04

+    terminate_loop_flag = 1;

+    

     return (void*)0;

 }

 

@@ -641,7 +647,7 @@
     int ret = 0;

     sc_ipc_msg msg = {0};

 

-	if(s_started)

+	if(!s_started)

 		goto Done;

 

     msg.type = 0;

@@ -680,3 +686,10 @@
 	return;

 }

 

+//xy.he add for T106BUG-413 2024-01-04

+int get_terminate_flag()

+{

+    return terminate_loop_flag;

+}

+

+

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 0d3cf4b..f84e878 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
@@ -465,6 +465,10 @@
 		goto exit;

 	}

 

+	//l.yang modify for bug id T106BUG-57 2023/9/13 start 

+	usleep(600000);

+	//l.yang modify for bug id T106BUG-57 2023/9/13 end

+

 	err = at_send_command_multiline("AT+CLCC", "+CLCC:", &response);

 	if (err < 0) {

 		RLOGD("ril_request_get_current_calls  err= %d", err);

@@ -625,15 +629,35 @@
 

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

 

+

 	/* 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-268 2023/9/28 start 

+	at_response_free(p_response);

+	return;

+	//l.yang modify for bug id T106BUG-268 2023/9/28 end 

+     

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