[Feature][T8TSK-289]merge old platform branch, add meta to public rep

Only Configure: No
Affected branch: MR3.0-Merge-v2.0
Affected module: all lynq
Is it affected on both ZXIC and MTK: only MTK
Self-test: No
Doc Update: No
diff --git a/common_src/lib/liblynq-call/lynq_call.cpp b/common_src/lib/liblynq-call/lynq_call.cpp
index ebdfa2a..8e80462 100755
--- a/common_src/lib/liblynq-call/lynq_call.cpp
+++ b/common_src/lib/liblynq-call/lynq_call.cpp
@@ -391,9 +391,10 @@
     pthread_cond_signal(&call_state_change_cond);

     pthread_mutex_unlock(&call_state_change_mutex);

 }

-void send_call_state_change()

+void send_call_state_change(int callid)

 {

     LYINFLOG("send call state change");

+    s_CallId = callid;

     pthread_mutex_lock(&s_call_state_change_mutex);

     pthread_cond_signal(&s_call_state_change_cond);

     pthread_mutex_unlock(&s_call_state_change_mutex);

@@ -423,16 +424,17 @@
 #endif

     pthread_mutex_lock(&s_notice_get_call_list_mutex);

     pthread_cleanup_push(cleanup_call_list_mutex, NULL); // thread cleanup handler

+    int tmp_call_id;

     while(s_call_list_loop)

     {

         update=0;       

         pthread_cond_wait(&s_notice_get_call_list_cond, &s_notice_get_call_list_mutex);

-        LYDBGLOG("triggerGetCallList event!!!");

+        LYINFLOG("triggerGetCallList event %p!!!", pthread_self());

         memset(call_list,0,sizeof(call_list));

         ret = lynq_get_current_call_list(call_list);

         if(ret != RESULT_OK)

         {

-            LYDBGLOG("get current call list failure!!!");          

+            LYERRLOG("get current call list failure!!!");

             continue;

         }

         LYINFLOG("++++++++++++++triggerGetCallList++++++++++++++");

@@ -463,8 +465,10 @@
                 {

                     LYINFLOG("MT/MO hungup,then clean call info local idx is %d id is %d",i, s_call_lists[i].call_id);

                     //update_end_state(i);//lei modify for:update end state for this call

+                    tmp_call_id = s_call_lists[i].call_id;

                     cleanCallList(i);

-                    send_call_state_change();//means mt/mo call is end

+                    //Release the end handle

+                    send_call_state_change(tmp_call_id);//means mt/mo call is end

                     //cleanCallList(i);

                 }

             } //fix bug API-54

@@ -511,8 +515,7 @@
                 {

                     n = addAddr(call_list[i].addr,call_list[i].call_id);

                     updateCallList(&s_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);

-                    s_CallId = call_list[i].call_id;

-                    send_call_state_change();

+                    send_call_state_change(call_list[i].call_id);

                 }

                 else if(s_call_lists[n].call_state == call_list[i].call_state)

                 {

@@ -524,7 +527,7 @@
                         **fix bug API-54

                         */

                         LYINFLOG("resend incoming call signal");

-                        send_call_state_change();

+                        send_call_state_change(call_list[i].call_id);

                     }

                 }

                 else 

@@ -532,7 +535,7 @@
                     LYINFLOG("state changed from %d to %d",s_call_lists[n].call_state,call_list[i].call_state);

                     

                     updateCallList(&s_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);//update mt call

-                    send_call_state_change();

+                    send_call_state_change(call_list[i].call_id);

                 }                            

             }

             else

@@ -547,12 +550,11 @@
                         {

                             LYINFLOG("add a call id");

                             update=1;//for send sigal

-                            s_CallId = call_list[i].call_id;

                         }

                         LYINFLOG("local idx %d updated, original call id is %d origial addr is %s original state is %d",n,s_call_lists[n].call_id,s_call_lists[n].addr,s_call_lists[n].call_state);                    

                         updateCallList(&s_call_lists[n],call_list[i].call_id,call_list[i].call_state,call_list[i].toa,call_list[i].direction);

                         call_end = 1;

-                        send_call_state_change();//means mo call is success

+                        send_call_state_change(call_list[i].call_id);//means mo call is success

                         break;

                     }                    

                 }

@@ -600,10 +602,11 @@
 

 void lynqNoticeGetModuleCallList()

 {

+    LYINFLOG("RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED send start");

     pthread_mutex_lock(&s_notice_get_call_list_mutex);

     pthread_cond_signal(&s_notice_get_call_list_cond);

     pthread_mutex_unlock(&s_notice_get_call_list_mutex);

-    

+    LYINFLOG("RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED send end");

 }

 

 #if 0

@@ -897,14 +900,17 @@
     LYINFLOG("wait Call state Change");

     int ret = 0;

     int sec = 0;

-    int usec = 0;

+    int ms  = 0;

     struct timeval now;

     struct timespec timeout;

     gettimeofday(&now,NULL);

     sec = mtime/1000;

-    usec = mtime%1000;

+    ms  = mtime%1000;

     timeout.tv_sec = now.tv_sec+sec;

-    timeout.tv_nsec = now.tv_usec*1000+usec*1000000;

+    unsigned long long ns;

+    ns = now.tv_usec*1000ull + ms*1000000ull;

+    timeout.tv_sec += ns/1000000000;

+    timeout.tv_nsec = ns % 1000000000;

     pthread_mutex_lock(&call_state_change_mutex);

     ret = pthread_cond_timedwait(&call_state_change_cond,&call_state_change_mutex,&timeout);

     pthread_mutex_unlock(&call_state_change_mutex);

@@ -1010,7 +1016,7 @@
         s_module_isDial = 0;      

         LYERRLOG("lynq_call timeout:wait Call state fail!!! clear local idx %d",lynq_call_id);

         cleanCallList(lynq_call_id);

-        send_call_state_change();

+        send_call_state_change(lynq_call_id);

         return LYNQ_E_TIME_OUT;

     }

     s_module_isDial = 0;

@@ -1024,7 +1030,7 @@
     {   

         LYERRLOG("lynq_call dial addr %s fail, invalid id",addr);

         cleanCallList(lynq_call_id);

-        send_call_state_change();

+        send_call_state_change(lynq_call_id);

         return LYNQ_E_INVALID_ID_ANONALY;

     }        

 }

@@ -1065,16 +1071,17 @@
     if(ret!=0)

     {

         return ret; 

-    }     

+    }

     delete p; 

 

-    int  lynq_call_id=find_call_id_with_call_id(call_id);

+    int lynq_call_id=find_call_id_with_call_id(call_id);

     if(lynq_call_id!=INVALID_ID)

     {

+        //lei  modify for API-857

         cleanCallList(lynq_call_id);

-    }        

-    

-    return RESULT_OK;     

+        send_call_state_change(call_id);

+    }

+    return RESULT_OK;

 }

 int lynq_call_hungup_all()

 {

@@ -1144,6 +1151,11 @@
         LYERRLOG("handle is NULL");

         return LYNQ_E_PARAMETER_ANONALY;

     }

+    if((*handle) <= 0)

+    {

+        LYINFLOG("lynq_get_current_call_state input error %d\n ", *handle);

+        return LYNQ_E_INVALID_ID_ANONALY;

+    }

     LYINFLOG("lynq_get_current_call_state %d\n ", *handle);

     lynq_call_id = find_call_id_with_call_id(*handle);

     if(lynq_call_id==INVALID_ID)