Merge "[Feature][T106][task-view-1120] support ng-ecall, for 1.1.16.3 case, cleardown may be -1"
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-call/lynq_call_ecall.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call_ecall.cpp
index f594388..15dc6dc 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call_ecall.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call_ecall.cpp
@@ -451,9 +451,9 @@
     char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};

     unsigned int i;

 

-    if(handle==NULL || ((*handle) >= LYNQ_CALL_MAX) || msd_length > MSD_MAX_LENGTH || msd_length <= 0 || msd_data ==NULL)

+    if(handle==NULL || ((*handle) <= 0) || msd_length > MSD_MAX_LENGTH || msd_length <= 0 || msd_data ==NULL)

     {

-        LYERRLOG("lynq_set_msd handle is NULL or handle %d is null or msd_length %d is greater than %d or msd_data %s is NULL, parameter error", handle, msd_length,MSD_MAX_LENGTH, msd_data);

+        LYERRLOG("lynq_set_msd handle %d is NULL or *handle is less 0 or msd_length %d is greater than 140 or msd_data %d is NULL, param error", handle, msd_length, msd_data);

         return LYNQ_E_PARAMETER_ANONALY;

     }    

 

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;
     }