[Bugfix][bug-view-847] Fixed the problem that the qser_data_call_start_async interface always fail after a timeout.

Only Configure:No
Affected branch:master
Affected module:DATA
Is it affected on: only ZXIC
Self-test: Yes
Doc Update:No

Change-Id: I8ee0c397e52072eddfa8b902b1268957fd22a622
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
index d9f9858..740f4bf 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
@@ -1548,7 +1548,7 @@
     return 0;
 }
 //xf.li@20230610 add for T106 start
-void updateRILDataCallResponsev11(int num ,RIL_Data_Call_Response_v11* p_cur)
+void updateRILDataCallResponsev11(int num ,RIL_Data_Call_Response_v11* p_cur, int uToken)
 {
     int i = 0;
     int pdp_count = 0;
@@ -1572,7 +1572,7 @@
     //update lynq_apn_cid_table at there whitch dialing = 1
     for(int j = 0; j < LYNQ_APN_CHANNEL_MAX; j++)
     {
-        if(lynq_apn_cid_table[j].used == 1 && lynq_apn_cid_table[j].dialing == 1)
+        if(lynq_apn_cid_table[j].used == 1 && lynq_apn_cid_table[j].dialing == 1 && lynq_apn_cid_table[j].uToken == uToken)
         {
             if((int)p_cur[i].status == 0)
             {
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.h b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.h
index 49793fd..4f7c306 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.h
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.h
@@ -49,7 +49,7 @@
 int getApnDbIms();
 void updateRILDataCallResponsev6(int num ,RIL_Data_Call_Response_v6* p_cur);
 //xf.il@20230610 modify for T106 data start
-void updateRILDataCallResponsev11(int num ,RIL_Data_Call_Response_v11* p_cur);
+void updateRILDataCallResponsev11(int num ,RIL_Data_Call_Response_v11* p_cur, int uToken);
 //xf.il@20230610 modify for T106 data end
 int getDataCallList(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
 //LYNQ_MODIFY_ZXW_TASK794_CR2024120449D612E5_XF.Li_20241221_START
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
index 8ad93bb..8ad5280 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
@@ -4436,7 +4436,7 @@
                    int num = responselen / sizeof(RIL_Data_Call_Response_v11);
                    RLOGD("the num of RIL_REQUEST_SETUP_DATA_CALL is %d", num);
                    RIL_Data_Call_Response_v11 *p_cur = (RIL_Data_Call_Response_v11 *) response;
-                   updateRILDataCallResponsev11(num,p_cur);
+                   updateRILDataCallResponsev11(num,p_cur,pRI->uToken);
                    #else
                    int num = responselen / sizeof(RIL_Data_Call_Response_v6);
                    RIL_Data_Call_Response_v6 *p_cur = (RIL_Data_Call_Response_v6 *) response;
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp
index d892973..35a2d3c 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp
@@ -360,7 +360,8 @@
 */
 int get_utoken()
 {
-    return (Global_uToken++)%10000;/*0-10000*/
+    pid_t pid = getpid();
+    return pid*10000+(Global_uToken++)%10000;/*0-10000*/
 }
 /**@brief wait response with expected token and write msg to parcel in some time
 * @param fd [IN]: socket fd
@@ -464,7 +465,7 @@
         return -1;
     }
 }
-void free_parcel(Parcel *p)
+void free_parcel(Parcel *&p)
 {
     if(p)
     {
@@ -1244,12 +1245,11 @@
             return NULL;
         }
 
-        error = wait_response(lynq_client_sockfd,p,g_setup_utoken,g_wait_time);
+        error = wait_response(lynq_client_sockfd,p,g_setup_utoken,120);
         if(error!=0)
         {
             LYERRLOG("wait_response fail,ret:%d",error);
             printf_apn_table();
-            pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
             for(lynq_data_call_id = 0; lynq_data_call_id < LYNQ_APN_CHANNEL_MAX; lynq_data_call_id++)
             {
                 if(lynq_apn_table[lynq_data_call_id].hasUsed == 1 && lynq_apn_table[lynq_data_call_id].cid <= 0)
@@ -1264,7 +1264,6 @@
                     sendSignalPdnChange();
                 }
             }
-            free_parcel(p);
             continue;
         }
         set_list_buffer_valid(false);
@@ -1328,6 +1327,21 @@
         if (lynq_data_call_id == LYNQ_APN_CHANNEL_MAX)
         {
             LYERRLOG("update apn table fail error id = %d",lynq_data_call_id);
+            printf_apn_table();
+            for(lynq_data_call_id = 0; lynq_data_call_id < LYNQ_APN_CHANNEL_MAX; lynq_data_call_id++)
+            {
+                if(lynq_apn_table[lynq_data_call_id].hasUsed == 1 && lynq_apn_table[lynq_data_call_id].cid <= 0)
+                {
+                    memset(lynq_apn_table[lynq_data_call_id].apn, 0, strlen(lynq_apn_table[lynq_data_call_id].apn) + 1);
+                    memset(lynq_apn_table[lynq_data_call_id].apnType, 0, strlen(lynq_apn_table[lynq_data_call_id].apnType) + 1);
+                    lynq_apn_table[lynq_data_call_id].hasUsed = 0;
+
+                    pthread_mutex_lock(&s_lynq_urc_vector_mutex);
+                    s_data_urc_wait_list.push_back(lynq_data_call_id);
+                    pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
+                    sendSignalPdnChange();
+                }
+            }
             free_parcel(p);
             continue;
         }
@@ -1552,6 +1566,14 @@
             return LYNQ_E_REPETITIVE_APN;
         }
     }
+    pthread_mutex_lock(&g_lynq_data_sendto_mutex);
+    if(send_request(lynq_client_sockfd,&client)==-1)
+    {
+        LYERRLOG("send request fail");
+        perror("[LYNQ_DATA] send request fail:");
+        pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
+        return -1;
+    }
     //find lynq_data_call_id
     for(lynq_data_call_id = 0; lynq_data_call_id < LYNQ_APN_CHANNEL_MAX; lynq_data_call_id++)
     {
@@ -1563,16 +1585,6 @@
     if (lynq_data_call_id == LYNQ_APN_CHANNEL_MAX)
     {
         LYERRLOG("update apn table fail error id = %d",lynq_data_call_id);
-        return -1;
-    }
-    LYINFLOG("lynq_data_call_id = %d\n", lynq_data_call_id);
-    //ready to send request
-    pthread_mutex_lock(&g_lynq_data_sendto_mutex);
- 
-    if(send_request(lynq_client_sockfd,&client)==-1)
-    {
-        LYERRLOG("send request fail");
-        perror("[LYNQ_DATA] send request fail:");
         pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
         return -1;
     }