[Bugfix][T800-199]Set the timeout period to the relative interval instead of the system time

    Only Configure: No
    Affected branch: ALL
    Affected module: data
    Is it affected on both ZXIC and MTK: only MTK
    Self-test: Yes
    Doc Update: No

Change-Id: Ifc31c406603f86b322957b0572618ac865975005
diff --git a/common_src/lib/liblynq-data/lynq_data.cpp b/common_src/lib/liblynq-data/lynq_data.cpp
index 2a14545..c307b32 100755
--- a/common_src/lib/liblynq-data/lynq_data.cpp
+++ b/common_src/lib/liblynq-data/lynq_data.cpp
@@ -83,14 +83,20 @@
 int lynq_telephony_restart_g = 0;
 pthread_t lynq_data_tid =-1;
 static pthread_mutex_t s_data_call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t s_data_call_state_change_cond = PTHREAD_COND_INITIALIZER;
+//xy.he modified started @20240716
+static pthread_cond_t s_data_call_state_change_cond;
+//xy.he modified ended @20240716
 
 static pthread_mutex_t s_data_call_deactived_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t s_data_call_deactived_cond = PTHREAD_COND_INITIALIZER;
+//xy.he modified started @20240716
+static pthread_cond_t s_data_call_deactived_cond;
+//xy.he modified ended @20240716
 
 
 static pthread_mutex_t s_lynq_apn_change_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t s_lynq_apn_change_cond = PTHREAD_COND_INITIALIZER;
+//xy.he modified started @20240716
+static pthread_cond_t s_lynq_apn_change_cond;
+//xy.he modified ended @20240716
 static pthread_mutex_t s_lynq_urc_vector_mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t s_lynq_urc_vector_cond = PTHREAD_COND_INITIALIZER;
 /**g_lynq_data_sendto_mutex
@@ -300,13 +306,15 @@
     LYINFLOG("start wait apn result!!!");
     int sec = 0;
     int usec = 0;
-    struct timeval now;
+    //xy.he modified started @20240716
     struct timespec timeout;
-    gettimeofday(&now, NULL);
+    struct timespec now;
     sec = 20000 / 1000;
     usec = 20000 % 1000;
+    clock_gettime(CLOCK_MONOTONIC, &now);
     timeout.tv_sec = now.tv_sec + sec;
-    timeout.tv_nsec = now.tv_usec * 1000 + usec * 1000000;
+    timeout.tv_nsec = now.tv_nsec + usec * 1000000;
+    //xy.he modified ended @20240716
     pthread_mutex_lock(&s_lynq_apn_change_mutex);
     ret = pthread_cond_timedwait(&s_lynq_apn_change_cond, &s_lynq_apn_change_mutex, &timeout);
     pthread_mutex_unlock(&s_lynq_apn_change_mutex);
@@ -335,13 +343,15 @@
     int ret = 0;
     int sec = 0;
     int usec = 0;
-    struct timeval now;
+    //xy.he modified started @20240716
     struct timespec timeout;
-    gettimeofday(&now,NULL);
-    sec = mtime/1000;
-    usec = mtime%1000;
-    timeout.tv_sec = now.tv_sec+sec;
-    timeout.tv_nsec = now.tv_usec*1000+usec*1000000;
+    struct timespec now;
+    sec = mtime / 1000;
+    usec = mtime % 1000;
+    clock_gettime(CLOCK_MONOTONIC, &now);
+    timeout.tv_sec = now.tv_sec + sec;
+    timeout.tv_nsec = now.tv_nsec + usec * 1000000;
+    //xy.he modified ended @20240716
     pthread_mutex_lock(&s_data_call_state_change_mutex);
     ret = pthread_cond_timedwait(&s_data_call_state_change_cond,&s_data_call_state_change_mutex,&timeout);
     pthread_mutex_unlock(&s_data_call_state_change_mutex);
@@ -359,13 +369,15 @@
     int ret = 0;
     int sec = 0;
     int usec = 0;
-    struct timeval now;
+    //xy.he modified started @20240716
     struct timespec timeout;
-    gettimeofday(&now,NULL);
-    sec = mtime/1000;
-    usec = mtime%1000;
-    timeout.tv_sec = now.tv_sec+sec;
-    timeout.tv_nsec = now.tv_usec*1000+usec*1000000;
+    struct timespec now;
+    sec = mtime / 1000;
+    usec = mtime % 1000;
+    clock_gettime(CLOCK_MONOTONIC, &now);
+    timeout.tv_sec = now.tv_sec + sec;
+    timeout.tv_nsec = now.tv_nsec + usec * 1000000;
+    //xy.he modified ended @20240716
     pthread_mutex_lock(&s_data_call_deactived_mutex);
     ret = pthread_cond_timedwait(&s_data_call_deactived_cond,&s_data_call_deactived_mutex,&timeout);
     pthread_mutex_unlock(&s_data_call_deactived_mutex);
@@ -866,6 +878,16 @@
     LYLOGSET(LOG_INFO);
     LYLOGEINIT(USER_LOG_TAG);
     LYERRLOG("%s start, parameter is %d", __func__,uToken);
+    //xy.he modified started @20240716
+    pthread_condattr_t attr;
+    pthread_condattr_init(&attr);
+
+    pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
+    pthread_cond_init(&s_lynq_apn_change_cond,&attr);
+    pthread_cond_init(&s_data_call_state_change_cond,&attr);
+    pthread_cond_init(&s_data_call_deactived_cond,&attr);
+    //xy.he modified ended @20240716
+    
 
     if (g_lynq_data_init_flag == 1)
     {
@@ -2378,4 +2400,4 @@
     return error;
 
 
-}
\ No newline at end of file
+}