blob: d25675abdf673af740620c150a4eb6e8ac7b0ec3 [file] [log] [blame]
q.huang52921662022-10-20 15:25:45 +08001#include <stdio.h>
2#include <sys/types.h>
3#include <sys/socket.h>
4#include <arpa/inet.h>
5#include <fcntl.h>
6#include <string.h>
7#include <stdlib.h>
8#include <unistd.h>
9#include <binder/Parcel.h>
10#include <log/log.h>
11#include <cutils/jstring.h>
12#include <pthread.h>
13#include "liblog/lynq_deflog.h"
14#include <sys/time.h>
15#include <string.h>
16#include <vendor-ril/telephony/ril.h>
17#include <vendor-ril/telephony/mtk_ril_sp.h>
18#include <vendor-ril/telephony/mtk_ril_ivt.h>
19#include "lynq_call.h"
20#include "lynq_module_common.h"
21#include "lynq_module_socket.h"
22#include "lynq_call_common.h"
23
24#define USER_LOG_TAG "LYNQ_CALL"
25
26using ::android::Parcel;
27
28#ifdef ECALL_SUPPORT
29typedef enum{
30 LYNQ_ECALL_TYPE_TEST = 0, /* Test eCall */
31 LYNQ_ECALL_TYPE_RECONFIG = 1, /* Reconfiguration eCall */
32 LYNQ_ECALL_MANUAL_EMERGENCY = 2, /*Manual Emergency eCall */
33 LYNQ_ECALL_TYPE_AUTO_EMERGENCY = 3, /* Automatic Emergency eCall */
34}LYNQ_ECall_Type;
35typedef enum{
36 LYNQ_ECALL_DAILING_STATE_NONE =0,
37 LYNQ_ECALL_DAILING_STATE_STARTED = 1,
38 LYNQ_ECALL_DAILING_STATE_ANSWERED = 2,
39}LYNQ_ECall_Dailing_State;
40static LYNQ_ECall_Dailing_State s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
41int IsECallDialing()
42{
43 return s_module_is_ecall_dial != LYNQ_ECALL_DAILING_STATE_NONE;
44}
45static int s_ecallId = INVALID_ID;
46char e_call_addr[LYNQ_ECALL_VAR_MAX][LYNQ_PHONE_NUMBER_MAX]={"test_ecall","emergency_ecall","reconf_ecall"};
47
48static pthread_mutex_t s_incoming_e_call_mutex = PTHREAD_MUTEX_INITIALIZER;
49static pthread_cond_t s_incoming_e_call_cond = PTHREAD_COND_INITIALIZER;
50static pthread_mutex_t s_ecall_variable_mutex = PTHREAD_MUTEX_INITIALIZER;
51
52static LYNQ_ECall_Indication s_IncomingEcallIndication;
53int s_IncomingEcallId=INVALID_ID;
54LYNQ_ECall_Variant s_EcallVariant=LYNQ_ECALL_VAR_NONE;
55int s_ecall_whether_preempt=0;
56
57void sendSignalIncomingECallEvent()
58{
59 LYINFLOG("send incoming ecall event signal");
60 pthread_mutex_lock(&s_incoming_e_call_mutex);
61 pthread_cond_signal(&s_incoming_e_call_cond);
62 pthread_mutex_unlock(&s_incoming_e_call_mutex);
63}
64
65int lynq_is_msd_suc(LYNQ_ECall_Indication lynqIncomingEcallIndication)
66{
67 if(LYNQ_ECALL_LLACK_RECEIVED == lynqIncomingEcallIndication ||
68 LYNQ_ECALL_ALACK_POSITIVE_RECEIVED == lynqIncomingEcallIndication ||
69 LYNQ_ECALL_ALACK_CLEARDOWN_RECEIVED == lynqIncomingEcallIndication ||
70 //LYNQ_ECALL_T5_TIMER_OUT == lynqIncomingEcallIndication ||
71 LYNQ_ECALL_T6_TIMER_OUT == lynqIncomingEcallIndication ||
72 LYNQ_ECALL_T7_TIMER_OUT == lynqIncomingEcallIndication)
73 {
74 return 1;
75 }
76
77 return 0;
78}
79
80int lynq_ecall_is_running()
81{
82 return (s_module_is_ecall_dial!=LYNQ_ECALL_DAILING_STATE_NONE) || (s_ecallId !=INVALID_ID || s_EcallVariant == LYNQ_ECALL_CALLBACK);
83}
84
85void print_ecall_info()
86{
87 LYERRLOG("%s is ecall dial is %d, ecall id is %d, ecall vairant is %d, incoming ecall ind is %d, incoming ecall id is %d, whether preempt is %d",__func__,s_module_is_ecall_dial,s_ecallId,s_EcallVariant,s_IncomingEcallIndication,s_IncomingEcallId,s_ecall_whether_preempt);
88}
89
90int lynq_ecall_is_permit_in_call(int ecall_id)
91{
92 return s_EcallVariant == LYNQ_ECALL_CALLBACK && (s_ecallId ==INVALID_ID || s_ecallId ==ecall_id);
93}
94
95int Is_handup_IncomingMT(int ecall_id)
96{
97 pthread_mutex_lock(&s_ecall_variable_mutex);
98 int handupIncomingMT=lynq_ecall_is_running() && (lynq_ecall_is_permit_in_call(ecall_id)==false);
99 pthread_mutex_unlock(&s_ecall_variable_mutex);
100 return handupIncomingMT;
101}
102
103int lynq_ecall_is_in_voice()
104{
105 return (s_module_is_ecall_dial==LYNQ_ECALL_DAILING_STATE_NONE) && (s_ecallId !=INVALID_ID);
106}
107
108LYNQ_ECall_Variant lynq_get_lynq_ecall_variant_from_lynq_type(LYNQ_ECall_Type type)
109{
110 switch(type)
111 {
112 case LYNQ_ECALL_TYPE_TEST:
113 return LYNQ_ECALL_TEST;
114 case LYNQ_ECALL_TYPE_RECONFIG:
115 return LYNQ_ECALL_RECONFIG;
116 default:
117 return LYNQ_ECALL_EMERGENCY;
118 }
119}
120
121RIL_ECall_Variant lynq_get_ril_ecall_variant_from_lynq_variant(LYNQ_ECall_Variant type)
122{
123 switch(type)
124 {
125 case LYNQ_ECALL_TEST:
126 return ECALL_TEST;
127 case LYNQ_ECALL_RECONFIG:
128 return ECALL_RECONFIG;
129 default:
130 return ECALL_EMERGENCY;
131 }
132}
133
134RIL_ECall_Category lynq_get_ril_ecall_cat_from_lynq_cat(LYNQ_ECall_Category cat)
135{
136 switch(cat)
137 {
138 case LYNQ_EMER_CAT_MANUAL_ECALL:
139 return EMER_CAT_MANUAL_ECALL;
140 default:
141 return EMER_CAT_AUTO_ECALL;
142 }
143}
144
145
146int lynq_set_test_num(LYNQ_ECall_Set_Type type, const char *test_num, int test_num_length)
147{
148 if(g_module_init_flag != MODULE_RUNNING)
149 {
150 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
151 return LYNQ_E_CONFLICT;
152 }
153 if(test_num==NULL || test_num_length > LYNQ_PHONE_NUMBER_MAX )
154 {
155 LYERRLOG("test_num is null or test_num_length %d s greater than %d ",test_num_length,LYNQ_PHONE_NUMBER_MAX);
156 return LYNQ_E_PARAMETER_ANONALY;
157 }
158
159// error=lynq_set_common_request(RIL_REQUEST_ECALL_SET_TEST_NUM,2,"%d %s",type,test_num);
160
161 Parcel* p=NULL;
162 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_SET_TEST_NUM,2,"%d %s",type,test_num);
163 if(ret==RESULT_OK)
164 {
165 snprintf(e_call_addr[LYNQ_ECALL_TEST],LYNQ_PHONE_NUMBER_MAX,"%s",test_num);
166 delete p;
167 }
168 return ret;
169}
170
171int lynq_ecall_can_be_preempted(LYNQ_ECall_Variant old_variant,LYNQ_ECall_Variant new_variant)
172{
173 int ret;
174
175 if(old_variant == LYNQ_ECALL_EMERGENCY)
176 {
177 return false;
178 }
179 else if(new_variant == LYNQ_ECALL_EMERGENCY)
180 {
181 return true;
182 }
183 else if(old_variant==LYNQ_ECALL_DAILING_STATE_NONE)
184 {
185 return true;
186 }
187 else
188 {
189 ret = (s_ecall_whether_preempt & 0x01);
190 }
191 LYINFLOG("ecall clear conflict call, lynq_ecall_can_be_preempted is true");
192 return ret;
193}
194
195int lynq_clear_current_call()
196{
197 int cnt;
198 int ret=lynq_call_hungup_all();
199
200 if(ret!=RESULT_OK)
201 {
202 LYERRLOG("ecall clear conflict call, hangup all failure");
203 return ret;
204 }
205 cnt=0;
206 while(lynq_get_current_call_number()!=0 && cnt<80)
207 {
208 lynqNoticeGetModuleCallList();
209 usleep(200 * 1000);//200ms
210 cnt++;
211 }
212 if(lynq_get_current_call_number()!=0)
213 {
214 LYERRLOG("ecall clear conflict call, current call list can't cleared after 15s");
215 return LYNQ_E_INNER_ERROR;
216 }
217
218 LYINFLOG("ecall clear conflict call, after %d 0.2s, call list is cleared", cnt);
219 return RESULT_OK;
220}
221
222int lynq_clear_current_conflict_call(LYNQ_ECall_Variant old_variant,LYNQ_ECall_Variant new_variant)
223{
224 int cnt;
225 int ret;
226
227 if(lynq_ecall_is_running()==false)
228 {
229 if(lynq_get_current_call_number()==0)
230 {
231 LYINFLOG("ecall clear conflict call, no conflict ecall and normal call");
232 }
233 else if(s_ecall_whether_preempt & 0x02)
234 {
235 ret=lynq_clear_current_call();
236 LYERRLOG("ecall clear conflict call, relase current normal call ret is %d",ret);
237 }
238 return RESULT_OK;
239 }
240
241 LYINFLOG("ecall clear conflict call, two ecall occure at the same time, new is %d, old is %d, g_preempt is %d",new_variant,old_variant,s_ecall_whether_preempt);
242
243 if(lynq_ecall_can_be_preempted(old_variant,new_variant)==false)
244 {
245 LYERRLOG("ecall clear conflict call, new ecall %d can't preempt old ecall %d",new_variant,old_variant);
246 return LYNQ_E_CONFLICT;
247 }
248
249 ret=lynq_clear_current_call();
250 LYINFLOG("ecall clear conflict call, relase current call(including ecall) ret is %d",ret);
251
252 if(s_module_is_ecall_dial != LYNQ_ECALL_DAILING_STATE_NONE)
253 {
254 sendSignalToWaitCallStateChange();
255 LYINFLOG("ecall clear conflict call, stop ecall in dailing status");
256 }
257
258 cnt=0;
259 while(lynq_ecall_is_running() && cnt<80)
260 {
261 usleep(200 * 1000);//200ms
262 cnt++;
263 }
264
265 if(lynq_ecall_is_running())
266 {
267 LYERRLOG("ecall clear conflict call, after 16s, lynq ecall is still running");
268 }
269 else
270 {
271 LYINFLOG("ecall clear conflict call, after %d 0.2s, ecall info is cleared", cnt);
272 }
273
274 sleep(3);// for ecall disconnect
275 print_ecall_info();
276 return RESULT_OK;
277}
278
279int lynq_fast_ecall(int* handle, LYNQ_ECall_Category lynq_ecall_cat, LYNQ_ECall_Variant lynq_ecall_variant, const char *addr, int addr_length, const unsigned char *msd_data,int msd_length)
280{
281 if(g_module_init_flag != MODULE_RUNNING)
282 {
283 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
284 return LYNQ_E_CONFLICT;
285 }
286 RIL_ECall_Variant ril_ecall_variant = lynq_get_ril_ecall_variant_from_lynq_variant (lynq_ecall_variant);
287 RIL_ECall_Category ril_ecall_cat = lynq_get_ril_ecall_cat_from_lynq_cat(lynq_ecall_cat);
288 char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};
289 unsigned int i;
290
291 if(msd_length > MSD_MAX_LENGTH || msd_length <=0 || lynq_ecall_variant >=LYNQ_ECALL_MO_MAX)
292 {
293 LYERRLOG("lynq_fast_ecall msd_length %d or ecall variant %d parameter error",msd_length,lynq_ecall_variant);
294 return LYNQ_E_PARAMETER_ANONALY;
295 }
296
297 if(lynq_clear_current_conflict_call(s_EcallVariant,lynq_ecall_variant)!=0)
298 {
299 LYERRLOG("%s call lynq_clear_current_conflict_call false, old is %d, new is %d",__func__,s_EcallVariant,lynq_ecall_variant);
300 return LYNQ_E_CONFLICT;
301 }
302
303 pthread_mutex_lock(&s_ecall_variable_mutex);
304 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_STARTED;
305 s_EcallVariant = lynq_ecall_variant;
306 s_ecallId = INVALID_ID;
307 pthread_mutex_unlock(&s_ecall_variable_mutex);
308
309 for(i =0; i<msd_length;i++)
310 {
311 sprintf(&(lynq_msd_data[i<<1]),"%02x",msd_data[i]);
312 }
313
314
315 LYINFLOG("lynq_fast_ecall addr is %s",e_call_addr[lynq_ecall_variant]);
316
317// error=lynq_set_common_request(RIL_REQUEST_ECALL_FAST_MAKE_ECALL,4,"%d %d %s %s",ril_ecall_cat, ril_ecall_variant, "null", lynq_msd_data);
318
319 Parcel* p=NULL;
320 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_FAST_MAKE_ECALL,4,"%d %d %s %s",ril_ecall_cat, ril_ecall_variant, "null", lynq_msd_data);
321 if(ret!=RESULT_OK)
322 {
323 pthread_mutex_lock(&s_ecall_variable_mutex);
324 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
325 s_EcallVariant = LYNQ_ECALL_VAR_NONE;
326 s_ecallId = INVALID_ID;
327 pthread_mutex_unlock(&s_ecall_variable_mutex);
328 return ret;
329 }
330
331 delete p;
332 if(waitCallstateChange(270000)==ETIMEDOUT)//4.5 min, dailing 1 min, alerting 1 min, sending msd 30s, redial 2min
333 {
334 pthread_mutex_lock(&s_ecall_variable_mutex);
335 LYERRLOG("lynq_fast_ecall timeout:wait Call state time out!!!");
336 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
337 lynqNoticeGetModuleCallList();
338 pthread_mutex_unlock(&s_ecall_variable_mutex);
339 return LYNQ_E_TIME_OUT;
340 }
341 pthread_mutex_lock(&s_ecall_variable_mutex);
342 if(s_module_is_ecall_dial == LYNQ_ECALL_DAILING_STATE_STARTED)
343 {
344 /*just dail, no recv answer*/
345 LYERRLOG("lynq_fast_ecall, no answer!");
346 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
347 lynqNoticeGetModuleCallList();
348 pthread_mutex_unlock(&s_ecall_variable_mutex);
349 return LYNQ_E_ECALL_DAILING_NO_ANSWER;
350 }
351
352 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
353 lynqNoticeGetModuleCallList();
354
355 if(s_ecallId != INVALID_ID)
356 {
357 *handle=s_ecallId;
358 LYINFLOG("lynq_fast_ecall id is %d",s_ecallId);
359 pthread_mutex_unlock(&s_ecall_variable_mutex);
360 return RESULT_OK;
361 }
362
363 LYERRLOG("lynq_fast_ecall service return fail");
364 pthread_mutex_unlock(&s_ecall_variable_mutex);
365 return LYNQ_E_INVALID_ID_ANONALY;
366
367}
368
369int lynq_set_psap(int enable)
370{
371 if(g_module_init_flag != MODULE_RUNNING)
372 {
373 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
374 return LYNQ_E_CONFLICT;
375 }
376// return lynq_set_common_request(RIL_REQUEST_ECALL_SET_PSAP,1,"%d",enable);
377 Parcel* p=NULL;
378 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_SET_PSAP,1,"%d",enable);
379 if(ret==RESULT_OK)
380 {
381 delete p;
382 }
383 return ret;
384}
385
386int lynq_psap_pull_msd()
387{
388 if(g_module_init_flag != MODULE_RUNNING)
389 {
390 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
391 return LYNQ_E_CONFLICT;
392 }
393// return lynq_set_common_request(RIL_REQUEST_ECALL_PSAP_PULL_MSD,0,"");
394 Parcel* p=NULL;
395 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_PSAP_PULL_MSD,0,"");
396 if(ret==RESULT_OK)
397 {
398 delete p;
399 }
400 return ret;
401}
402
403int lynq_make_ecall(int* handle, LYNQ_ECall_Type type)
404{
405 return RESULT_OK;
406#if 0
407 LYNQ_ECall_Variant lynq_ecall_variant;
408 int error = -1;
409 int lynq_call_id = -1;
410
411 if(handle==NULL)
412 {
413 LYERRLOG("handle is NULL, parameter error ");
414 return -1;
415 }
416
417 error=lynq_set_common_request(RIL_REQUEST_ECALL_MAKE_ECALL,1,"%d",type);
418
419 if(error==0)
420 {
421 lynq_ecall_variant=lynq_get_lynq_ecall_variant_from_lynq_type(type);
422
423 lynq_call_id = addAddr(e_call_addr[lynq_ecall_variant]);
424 s_module_isDial = 1;
425 if(waitCallstateChange(10000)==ETIMEDOUT)//10000ms
426 {
427 error = LYNQ_E_TIME_OUT;
428 LYERRLOG("timeout:wait Call state fail!!!");
429 return error;
430 }
431
432 *handle = lynq_call_id;
433 }
434
435 return error;
436#endif
437}
438
439
440int lynq_set_msd(int* handle, const unsigned char *msd_data, int msd_length)
441{
442 if(g_module_init_flag != MODULE_RUNNING)
443 {
444 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
445 return LYNQ_E_CONFLICT;
446 }
447 char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};
448 unsigned int i;
449
450 if(handle==NULL || ((*handle) >= LYNQ_CALL_MAX) || msd_length > MSD_MAX_LENGTH || msd_length <= 0 || msd_data ==NULL)
451 {
452 LYERRLOG("lynq_set_msd handle is NULL or *handle %d is greater or equeal to %d or msd_length %d is greater than %d or msd_data %s is NULL, parameter error",*handle,LYNQ_CALL_MAX,msd_length,MSD_MAX_LENGTH, msd_data);
453 return LYNQ_E_PARAMETER_ANONALY;
454 }
455
456 for(i=0; i<msd_length;i++)
457 {
458 sprintf(&(lynq_msd_data[i<<1]),"%02x",msd_data[i]);
459 }
460
461 LYINFLOG("lynq_set_msd ");
462
463// return lynq_set_common_request(RIL_REQUEST_ECALL_SET_MSD,2,"%d %s",*handle,lynq_msd_data);
464 Parcel* p=NULL;
465 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_SET_MSD,2,"%d %s",*handle,lynq_msd_data);
466 if(ret==RESULT_OK)
467 {
468 delete p;
469 }
470 return ret;
471}
472
473int lynq_set_ivs(int enable)
474{
475 if(g_module_init_flag != MODULE_RUNNING)
476 {
477 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
478 return LYNQ_E_CONFLICT;
479 }
480 if(enable<0)
481 {
q.huang5bbadde2023-02-09 16:50:52 +0800482 if(enable >-200)
q.huang52921662022-10-20 15:25:45 +0800483 {
484 goto set_ivs_end;
485// lynq_set_common_request(RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
486 }
487 else if(enable== -1000)
488 {
489 print_ecall_info();
490 }
491 else
492 {
q.huang5bbadde2023-02-09 16:50:52 +0800493 s_ecall_whether_preempt= ((-200-enable) & 0x11);
q.huang52921662022-10-20 15:25:45 +0800494 }
495 return RESULT_OK;
496 }
497
498// return lynq_set_common_request(RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
499set_ivs_end:
500 Parcel* p=NULL;
501 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
502 if(ret==RESULT_OK)
503 {
504 delete p;
505 }
506 return ret;
507}
508
509int lynq_reset_ivs()
510{
511 if(g_module_init_flag != MODULE_RUNNING)
512 {
513 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
514 return LYNQ_E_CONFLICT;
515 }
516// return lynq_set_common_request(RIL_REQUEST_ECALL_RESET_IVS,0,"");
517 Parcel* p=NULL;
518 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_RESET_IVS,0,"");
519 if(ret==RESULT_OK)
520 {
521 delete p;
522 }
523 return ret;
524}
525
526int lynq_ivs_push_msd()
527{
528 if(g_module_init_flag != MODULE_RUNNING)
529 {
530 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
531 return LYNQ_E_CONFLICT;
532 }
533// return lynq_set_common_request(RIL_REQUEST_ECALL_IVS_PUSH_MSD,0,"");
534 Parcel* p=NULL;
535 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_IVS_PUSH_MSD,0,"");
536 if(ret==RESULT_OK)
537 {
538 delete p;
539 }
540 return ret;
541}
542
543int wait_ecall_event()
544{
545 int ret = 0;
546 pthread_mutex_lock(&s_incoming_e_call_mutex);
547 ret = pthread_cond_wait(&s_incoming_e_call_cond,&s_incoming_e_call_mutex);
548 pthread_mutex_unlock(&s_incoming_e_call_mutex);
549 return ret;
550}
551
552int lynq_wait_ecall_indication(int* handle, LYNQ_ECall_Indication *eCall_Indication)
553{
554 if(g_module_init_flag != MODULE_RUNNING)
555 {
556 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
557 return LYNQ_E_CONFLICT;
558 }
559 wait_ecall_event();
560 *handle = s_IncomingEcallId;
561 *eCall_Indication = s_IncomingEcallIndication;
562 LYINFLOG("lynq_wait_ecall_indication handle %d, Ind id: %d", *handle, *eCall_Indication);
563 return RESULT_OK;
564}
565void urc_ecall_msg_process(Parcel *p)
566{
567 int ecall_ind;
568 int ecallId;
569 int send_signal_to_wait_call_state;
570 int handup_ecall_id;
571
572 pthread_mutex_lock(&s_ecall_variable_mutex);
573 send_signal_to_wait_call_state = false;
574 handup_ecall_id=false;
575 p->readInt32(&ecall_ind);
576 s_IncomingEcallIndication = ecall_ind;
577 p->readInt32(&ecallId);
578 s_IncomingEcallId = ecallId;
579 LYINFLOG("**************:RIL_UNSOL_ECALL_INDICATIONS ,Id %d, ind %d, ecall dialing is %d, normal dialing is %d, local ecall id is %d",ecallId,ecall_ind,s_module_is_ecall_dial,IsNormalCallDailing(),s_ecallId);
580 switch (s_IncomingEcallIndication)
581 {
582 case LYNQ_ECALL_ACTIVE:
583 if(s_module_is_ecall_dial)
584 {
585 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_ANSWERED;
586 }
587 break;
588 case LYNQ_ECALL_SENDING_START:
589 if(lynq_ecall_is_in_voice())
590 {
591 LYINFLOG("recv msd in voice, ind is changed to %d",LYNQ_ECALL_SENDING_START_IN_VOICE);
592 s_IncomingEcallIndication = LYNQ_ECALL_SENDING_START_IN_VOICE;
593 }
594 break;
595 case LYNQ_ECALL_LLACK_RECEIVED:
596 case LYNQ_ECALL_ALACK_POSITIVE_RECEIVED:
597 case LYNQ_ECALL_ALACK_CLEARDOWN_RECEIVED:
598 //case LYNQ_ECALL_T5_TIMER_OUT: /*when Certificate CP 1.1.10.2, no msd start (ind 1), so T5 timeout is not regard as success*/
599 case LYNQ_ECALL_T6_TIMER_OUT:
600 case LYNQ_ECALL_T7_TIMER_OUT:
601 if(s_module_is_ecall_dial)
602 {
603 LYINFLOG("ecall is dialing, recv suc indication");
604 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
605 if(ecallId >0 && find_call_id_with_call_id(ecallId)==INVALID_ID)
606 {
607 LYINFLOG("add ecall in loacl list");
608 s_ecallId = ecallId;
609 addAddr("ecall",s_ecallId);
610 }
611 send_signal_to_wait_call_state=true;
612 }
613 else if(ecallId >0 && (find_call_id_with_call_id(ecallId)==INVALID_ID) && (s_EcallVariant != LYNQ_ECALL_CALLBACK))
614 {
615 LYERRLOG("ecall is not in dialing and first recv suc indication, hangup");
616 handup_ecall_id=true;
617 }
618 else
619 {
620 LYERRLOG("ecall is not in dialing and not first recv suc indication");
621 }
622 break;
623 case LYNQ_ECALL_PSAP_CALLBACK_START:
624 if(lynq_ecall_is_running()==0)
625 {
626 if(ecallId>0)
627 {
628 LYINFLOG("ecall is not running, recv psap call back msd start, set ecall running");
629 s_EcallVariant = LYNQ_ECALL_CALLBACK;
630 s_ecallId = ecallId;
631 if(IsNormalCallDailing())
632 {
633 LYINFLOG("stop normal dial");
634 send_signal_to_wait_call_state=true;
635 }
636 else
637 {
638 LYINFLOG("no normal dial");
639 }
640 }
641 else
642 {
643 LYERRLOG("ecallId is abnormal in psap callback");
644 }
645 }
646 else
647 {
648 LYERRLOG("ecall is running, recv psap call back msd start");
649 }
650 break;
651 case LYNQ_ECALL_ABNORMAL_HANGUP:
652 if(s_module_is_ecall_dial == LYNQ_ECALL_DAILING_STATE_NONE)
653 {
654 LYERRLOG("ecall is not in dialing , recv abnormal hangup");
655 s_ecallId = INVALID_ID;
656 }
657 else if (s_module_is_ecall_dial == LYNQ_ECALL_DAILING_STATE_STARTED)
658 {
659 LYERRLOG("ecall is in dialing state, recv no answer, recv abnormal hangup, dont' redial");
660 s_ecallId = INVALID_ID;
661 send_signal_to_wait_call_state=true;
662 }
663 else {
664 LYINFLOG("ecall is in dialing and recv answer, recv abnormal hangup");
665 }
666 break;
667 case LYNQ_ECALL_DISCONNECTED:
668 case LYNQ_ECALL_REDIAL_TIMER_OUT:
669 case LYNQ_ECALL_T2_TIMER_OUT :
670 case LYNQ_ECALL_IMS_DISCONNECTED:
671 s_ecallId = INVALID_ID;
672 if(s_EcallVariant == LYNQ_ECALL_CALLBACK)
673 {
674 s_EcallVariant = LYNQ_ECALL_VAR_NONE; /*other type, needn't re-initialize*/
675 }
676 if(s_module_is_ecall_dial != LYNQ_ECALL_DAILING_STATE_NONE)
677 {
678 LYERRLOG("ecall is in dialing, recv like disconnect indication");
679 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
680 send_signal_to_wait_call_state=true;
681 }
682 else
683 {
684 LYINFLOG("ecall is not in dialing, recv like disconnect indication");
685 }
686 break;
687 default:
688 LYINFLOG("not special indication");
689 }
690 pthread_mutex_unlock(&s_ecall_variable_mutex);
691 if(send_signal_to_wait_call_state)
692 {
693 sendSignalToWaitCallStateChange();
694 }
695 sendSignalIncomingECallEvent();
696 if(handup_ecall_id)
697 {
698 lynq_call_hungup(&ecallId);
699 }
700 LYINFLOG("**************:RIL_UNSOL_ECALL_INDICATIONS, local ecall id is %d", s_ecallId);
701 return;
702}
703#endif