[Feature][T8TSK-141][Voice]voice Added end Status Added a call state event notification
Change-Id: I3f70c7a4b85ffe3c6aa1416960a8794dd1d70c75
diff --git a/lib/liblynq-call/lynq_call.cpp b/lib/liblynq-call/lynq_call.cpp
index 2d49208..10a4ea0 100755
--- a/lib/liblynq-call/lynq_call.cpp
+++ b/lib/liblynq-call/lynq_call.cpp
@@ -74,9 +74,9 @@
static int s_module_isDial = 0;
static pthread_mutex_t call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t call_state_change_cond = PTHREAD_COND_INITIALIZER;
-static int s_IncomingCallId = 0;
-static pthread_mutex_t s_incoming_call_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t s_incoming_call_cond = PTHREAD_COND_INITIALIZER;
+static int s_CallId = 0;
+static pthread_mutex_t s_call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t s_call_state_change_cond = PTHREAD_COND_INITIALIZER;
static int s_module_call_state =CALL_OFF;
static int s_call_auto_answer = 0;
@@ -299,6 +299,8 @@
s_call_lists[lynq_call_id].used = 0;
memset(s_call_lists[lynq_call_id].addr,0,sizeof(s_call_lists[lynq_call_id].addr));
}
+
+
int getUnusedElement()
{
for(int i=0;i < LYNQ_CALL_MAX; i++)
@@ -329,15 +331,15 @@
callList->direction = direction;
return;
}
-int waitIncomingCall()
+
+void wait_call_state()
{
- LYINFLOG("wait incming call");
- int ret = 0;
- pthread_mutex_lock(&s_incoming_call_mutex);
- ret = pthread_cond_wait(&s_incoming_call_cond,&s_incoming_call_mutex);
- pthread_mutex_unlock(&s_incoming_call_mutex);
- return ret;
+ LYINFLOG("call state changed");
+ pthread_mutex_lock(&s_call_state_change_mutex);
+ pthread_cond_wait(&s_call_state_change_cond,&s_call_state_change_mutex);
+ pthread_mutex_unlock(&s_call_state_change_mutex);
}
+
int checkHasCall(char addr[])
{
for(int i = 0;i<LYNQ_CALL_MAX;i++)
@@ -384,18 +386,25 @@
pthread_cond_signal(&call_state_change_cond);
pthread_mutex_unlock(&call_state_change_mutex);
}
-void sendSignalIncomingCall()
+void send_call_state_change()
{
- LYINFLOG("send incoming call signal");
- pthread_mutex_lock(&s_incoming_call_mutex);
- pthread_cond_signal(&s_incoming_call_cond);
- pthread_mutex_unlock(&s_incoming_call_mutex);
+ LYINFLOG("send call state change");
+ pthread_mutex_lock(&s_call_state_change_mutex);
+ pthread_cond_signal(&s_call_state_change_cond);
+ pthread_mutex_unlock(&s_call_state_change_mutex);
}
void cleanup_call_list_mutex(void *arg)
{
pthread_mutex_unlock(&s_notice_get_call_list_mutex);
}
+
+void update_end_state(int lynq_call_id)
+{
+ LYINFLOG("update_end_state local idx is %d, id is %d",lynq_call_id,s_call_lists[lynq_call_id].call_id);
+ s_call_lists[lynq_call_id].call_state = (int)LYNQ_CALL_END;
+}
+
void *triggerGetCallList(void *parg)
{
int ret=0;
@@ -447,8 +456,11 @@
}
if(call_end == 0)
{
- LYINFLOG("MT hungup,then clean call info local idx is %d id is %d",i, s_call_lists[i].call_id);
- cleanCallList(i);
+ 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
+ cleanCallList(i);
+ send_call_state_change();//means mt/mo call is end
+ //cleanCallList(i);
}
} //fix bug API-54
else
@@ -494,8 +506,8 @@
{
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_IncomingCallId = call_list[i].call_id;
- sendSignalIncomingCall();
+ s_CallId = call_list[i].call_id;
+ send_call_state_change();
}
else if(s_call_lists[n].call_state == call_list[i].call_state)
{
@@ -507,15 +519,15 @@
**fix bug API-54
*/
LYINFLOG("resend incoming call signal");
- sendSignalIncomingCall();
+ send_call_state_change();
}
}
else
{
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);
- }
+ 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
+ }
}
else
{
@@ -525,19 +537,20 @@
{
if(s_call_lists[n].used && ((strcmp(call_list[i].addr,s_call_lists[n].addr)==0)||(call_list[i].call_id==s_call_lists[n].call_id)))
{
+ s_CallId = call_list[i].call_id;
if(s_call_lists[n].call_id==0)
{
- LYINFLOG("add a call id");
- update=1;
+ LYINFLOG("add a call id");
+ update=1;//for send sigal
}
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
break;
}
}
-
- if(call_end == 0)
+ if(call_end == 0)//1.there is no space to use 2.can't find addr in buffer 3.call_id not equal eg:when call is error return 8004/handle <= 0 will into this
{
LYINFLOG("need to hangup id %d", call_list[i].call_id);
#ifdef ECALL_SUPPORT
@@ -550,6 +563,7 @@
LYINFLOG("hang up service call id %d",call_list[i].call_id);
lynq_call_hungup(&(call_list[i].call_id));
}
+
}
LYDBGLOG("servie idx %d end",i);
}
@@ -891,6 +905,7 @@
return s_module_isDial;
}
+
int lynq_call(int* handle,char addr[])
{
if(g_module_init_flag != MODULE_RUNNING)
@@ -921,25 +936,22 @@
return LYNQ_E_ECALL_BEING_RUNNING;
}
#endif
-
Parcel* p=NULL;
lynq_call_id = addAddr(addr,0);
int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_DIAL,2,"%s %d",addr, 0);
if(ret!=0)
{
- cleanCallList(lynq_call_id);
+ cleanCallList(lynq_call_id);
return ret;
- }
-
- delete p;
-
+ }
+ delete p;
s_module_isDial = 1;
if(waitCallstateChange(6000)==ETIMEDOUT)//6000ms
{
//if timeout,this call need destroy.
s_module_isDial = 0;
LYERRLOG("lynq_call timeout:wait Call state fail!!! clear local idx %d",lynq_call_id);
- cleanCallList(lynq_call_id);
+ cleanCallList(lynq_call_id);
return LYNQ_E_TIME_OUT;
}
s_module_isDial = 0;
@@ -954,8 +966,9 @@
LYERRLOG("lynq_call dial addr %s fail, invalid id",addr);
cleanCallList(lynq_call_id);
return LYNQ_E_INVALID_ID_ANONALY;
- }
+ }
}
+
int lynq_call_answer()
{
if(g_module_init_flag != MODULE_RUNNING)
@@ -972,6 +985,7 @@
}
return ret;
}
+
int lynq_call_hungup(int* handle)
{
if(g_module_init_flag != MODULE_RUNNING)
@@ -1018,17 +1032,18 @@
}
return ret;
}
-int lynq_wait_incoming_call(int *handle)
+
+int lynq_wait_call_state_change(int *handle)
{
if(g_module_init_flag != MODULE_RUNNING)
{
LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
return LYNQ_E_CONFLICT;
}
- waitIncomingCall();
- *handle = s_IncomingCallId;
- LYINFLOG("lynq incoming call id:%d",s_IncomingCallId);
- return RESULT_OK;
+ wait_call_state();
+ *handle = s_CallId;
+ LYINFLOG("lynq mo/mt call id:%d",s_CallId);
+ return RESULT_OK;
}
int lynq_set_auto_answercall(const int mode)
@@ -1042,6 +1057,19 @@
LYINFLOG("auto answer call mode =%d",mode);
return RESULT_OK;
}
+
+int lynq_find_already_end()
+{
+ for(int i=0;i < LYNQ_CALL_MAX; i++)
+ {
+ if(s_call_lists[i].call_state == 6)
+ {
+ return 0;
+ }
+ }
+ return INVALID_ID;
+}
+
int lynq_get_current_call_state(int *handle, int *call_state,int *toa,int *direction,char addr[])
{
if(g_module_init_flag != MODULE_RUNNING)
@@ -1056,16 +1084,31 @@
LYERRLOG("handle is NULL");
return LYNQ_E_PARAMETER_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)
{
- return LYNQ_E_INVALID_ID_ANONALY;
+ if(lynq_find_already_end)
+ {
+ LYINFLOG("not end update\n ");
+ return LYNQ_E_INVALID_ID_ANONALY;
+ }
+ //find end state
+ if((*handle) >= 0)
+ {
+ *call_state = (int)LYNQ_CALL_END;
+ return RESULT_OK;
+ }
+ else
+ {
+ return LYNQ_E_INVALID_ID_ANONALY;
+ }
}
*call_state = s_call_lists[lynq_call_id].call_state;
*toa = s_call_lists[lynq_call_id].toa;
*direction = s_call_lists[lynq_call_id].direction;
memcpy(addr,s_call_lists[lynq_call_id].addr,strlen(s_call_lists[lynq_call_id].addr)+1);
- return RESULT_OK;
+ return RESULT_OK;
}
int lynq_get_current_call_number()