blob: b012907f4bba71af3c668483328054c3ae3c652c [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;
q.huangdf0723c2023-04-28 16:03:01 +080055int s_ecall_whether_preempt=0x02;
q.huang52921662022-10-20 15:25:45 +080056
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 }
q.huangdf0723c2023-04-28 16:03:01 +0800238 else
239 {
240 LYINFLOG("ecall clear conflict call, exits conflict normal call, let mtk release them");
241 }
q.huang52921662022-10-20 15:25:45 +0800242 return RESULT_OK;
243 }
244
245 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);
246
247 if(lynq_ecall_can_be_preempted(old_variant,new_variant)==false)
248 {
249 LYERRLOG("ecall clear conflict call, new ecall %d can't preempt old ecall %d",new_variant,old_variant);
250 return LYNQ_E_CONFLICT;
251 }
252
253 ret=lynq_clear_current_call();
254 LYINFLOG("ecall clear conflict call, relase current call(including ecall) ret is %d",ret);
255
256 if(s_module_is_ecall_dial != LYNQ_ECALL_DAILING_STATE_NONE)
257 {
258 sendSignalToWaitCallStateChange();
259 LYINFLOG("ecall clear conflict call, stop ecall in dailing status");
260 }
261
262 cnt=0;
263 while(lynq_ecall_is_running() && cnt<80)
264 {
265 usleep(200 * 1000);//200ms
266 cnt++;
267 }
268
269 if(lynq_ecall_is_running())
270 {
271 LYERRLOG("ecall clear conflict call, after 16s, lynq ecall is still running");
272 }
273 else
274 {
275 LYINFLOG("ecall clear conflict call, after %d 0.2s, ecall info is cleared", cnt);
276 }
277
278 sleep(3);// for ecall disconnect
279 print_ecall_info();
280 return RESULT_OK;
281}
282
283int 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)
284{
285 if(g_module_init_flag != MODULE_RUNNING)
286 {
287 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
288 return LYNQ_E_CONFLICT;
289 }
290 RIL_ECall_Variant ril_ecall_variant = lynq_get_ril_ecall_variant_from_lynq_variant (lynq_ecall_variant);
291 RIL_ECall_Category ril_ecall_cat = lynq_get_ril_ecall_cat_from_lynq_cat(lynq_ecall_cat);
292 char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};
293 unsigned int i;
294
295 if(msd_length > MSD_MAX_LENGTH || msd_length <=0 || lynq_ecall_variant >=LYNQ_ECALL_MO_MAX)
296 {
297 LYERRLOG("lynq_fast_ecall msd_length %d or ecall variant %d parameter error",msd_length,lynq_ecall_variant);
298 return LYNQ_E_PARAMETER_ANONALY;
299 }
300
301 if(lynq_clear_current_conflict_call(s_EcallVariant,lynq_ecall_variant)!=0)
302 {
303 LYERRLOG("%s call lynq_clear_current_conflict_call false, old is %d, new is %d",__func__,s_EcallVariant,lynq_ecall_variant);
304 return LYNQ_E_CONFLICT;
305 }
306
307 pthread_mutex_lock(&s_ecall_variable_mutex);
308 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_STARTED;
309 s_EcallVariant = lynq_ecall_variant;
310 s_ecallId = INVALID_ID;
311 pthread_mutex_unlock(&s_ecall_variable_mutex);
312
313 for(i =0; i<msd_length;i++)
314 {
315 sprintf(&(lynq_msd_data[i<<1]),"%02x",msd_data[i]);
316 }
317
318
319 LYINFLOG("lynq_fast_ecall addr is %s",e_call_addr[lynq_ecall_variant]);
320
321// 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);
322
323 Parcel* p=NULL;
324 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);
325 if(ret!=RESULT_OK)
326 {
327 pthread_mutex_lock(&s_ecall_variable_mutex);
328 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
329 s_EcallVariant = LYNQ_ECALL_VAR_NONE;
330 s_ecallId = INVALID_ID;
331 pthread_mutex_unlock(&s_ecall_variable_mutex);
332 return ret;
333 }
334
335 delete p;
336 if(waitCallstateChange(270000)==ETIMEDOUT)//4.5 min, dailing 1 min, alerting 1 min, sending msd 30s, redial 2min
337 {
338 pthread_mutex_lock(&s_ecall_variable_mutex);
339 LYERRLOG("lynq_fast_ecall timeout:wait Call state time out!!!");
340 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
341 lynqNoticeGetModuleCallList();
342 pthread_mutex_unlock(&s_ecall_variable_mutex);
343 return LYNQ_E_TIME_OUT;
344 }
345 pthread_mutex_lock(&s_ecall_variable_mutex);
346 if(s_module_is_ecall_dial == LYNQ_ECALL_DAILING_STATE_STARTED)
347 {
348 /*just dail, no recv answer*/
349 LYERRLOG("lynq_fast_ecall, no answer!");
350 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
351 lynqNoticeGetModuleCallList();
352 pthread_mutex_unlock(&s_ecall_variable_mutex);
353 return LYNQ_E_ECALL_DAILING_NO_ANSWER;
354 }
355
356 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
357 lynqNoticeGetModuleCallList();
358
359 if(s_ecallId != INVALID_ID)
360 {
361 *handle=s_ecallId;
362 LYINFLOG("lynq_fast_ecall id is %d",s_ecallId);
363 pthread_mutex_unlock(&s_ecall_variable_mutex);
364 return RESULT_OK;
365 }
366
367 LYERRLOG("lynq_fast_ecall service return fail");
368 pthread_mutex_unlock(&s_ecall_variable_mutex);
369 return LYNQ_E_INVALID_ID_ANONALY;
370
371}
372
373int lynq_set_psap(int enable)
374{
375 if(g_module_init_flag != MODULE_RUNNING)
376 {
377 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
378 return LYNQ_E_CONFLICT;
379 }
380// return lynq_set_common_request(RIL_REQUEST_ECALL_SET_PSAP,1,"%d",enable);
381 Parcel* p=NULL;
382 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_SET_PSAP,1,"%d",enable);
383 if(ret==RESULT_OK)
384 {
385 delete p;
386 }
387 return ret;
388}
389
390int lynq_psap_pull_msd()
391{
392 if(g_module_init_flag != MODULE_RUNNING)
393 {
394 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
395 return LYNQ_E_CONFLICT;
396 }
397// return lynq_set_common_request(RIL_REQUEST_ECALL_PSAP_PULL_MSD,0,"");
398 Parcel* p=NULL;
399 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_PSAP_PULL_MSD,0,"");
400 if(ret==RESULT_OK)
401 {
402 delete p;
403 }
404 return ret;
405}
406
407int lynq_make_ecall(int* handle, LYNQ_ECall_Type type)
408{
409 return RESULT_OK;
410#if 0
411 LYNQ_ECall_Variant lynq_ecall_variant;
412 int error = -1;
413 int lynq_call_id = -1;
414
415 if(handle==NULL)
416 {
417 LYERRLOG("handle is NULL, parameter error ");
418 return -1;
419 }
420
421 error=lynq_set_common_request(RIL_REQUEST_ECALL_MAKE_ECALL,1,"%d",type);
422
423 if(error==0)
424 {
425 lynq_ecall_variant=lynq_get_lynq_ecall_variant_from_lynq_type(type);
426
427 lynq_call_id = addAddr(e_call_addr[lynq_ecall_variant]);
428 s_module_isDial = 1;
429 if(waitCallstateChange(10000)==ETIMEDOUT)//10000ms
430 {
431 error = LYNQ_E_TIME_OUT;
432 LYERRLOG("timeout:wait Call state fail!!!");
433 return error;
434 }
435
436 *handle = lynq_call_id;
437 }
438
439 return error;
440#endif
441}
442
443
444int lynq_set_msd(int* handle, const unsigned char *msd_data, int msd_length)
445{
446 if(g_module_init_flag != MODULE_RUNNING)
447 {
448 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
449 return LYNQ_E_CONFLICT;
450 }
451 char lynq_msd_data[MSD_MAX_LENGTH*2+1]={0};
452 unsigned int i;
453
454 if(handle==NULL || ((*handle) >= LYNQ_CALL_MAX) || msd_length > MSD_MAX_LENGTH || msd_length <= 0 || msd_data ==NULL)
455 {
456 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);
457 return LYNQ_E_PARAMETER_ANONALY;
458 }
459
460 for(i=0; i<msd_length;i++)
461 {
462 sprintf(&(lynq_msd_data[i<<1]),"%02x",msd_data[i]);
463 }
464
465 LYINFLOG("lynq_set_msd ");
466
467// return lynq_set_common_request(RIL_REQUEST_ECALL_SET_MSD,2,"%d %s",*handle,lynq_msd_data);
468 Parcel* p=NULL;
469 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_SET_MSD,2,"%d %s",*handle,lynq_msd_data);
470 if(ret==RESULT_OK)
471 {
472 delete p;
473 }
474 return ret;
475}
476
477int lynq_set_ivs(int enable)
478{
479 if(g_module_init_flag != MODULE_RUNNING)
480 {
481 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
482 return LYNQ_E_CONFLICT;
483 }
484 if(enable<0)
485 {
q.huang5bbadde2023-02-09 16:50:52 +0800486 if(enable >-200)
q.huang52921662022-10-20 15:25:45 +0800487 {
488 goto set_ivs_end;
489// lynq_set_common_request(RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
490 }
491 else if(enable== -1000)
492 {
493 print_ecall_info();
494 }
495 else
496 {
q.huang5bbadde2023-02-09 16:50:52 +0800497 s_ecall_whether_preempt= ((-200-enable) & 0x11);
q.huang52921662022-10-20 15:25:45 +0800498 }
499 return RESULT_OK;
500 }
501
502// return lynq_set_common_request(RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
503set_ivs_end:
504 Parcel* p=NULL;
505 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_SET_IVS,1,"%d",enable);
506 if(ret==RESULT_OK)
507 {
508 delete p;
509 }
510 return ret;
511}
512
513int lynq_reset_ivs()
514{
515 if(g_module_init_flag != MODULE_RUNNING)
516 {
517 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
518 return LYNQ_E_CONFLICT;
519 }
520// return lynq_set_common_request(RIL_REQUEST_ECALL_RESET_IVS,0,"");
521 Parcel* p=NULL;
522 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_RESET_IVS,0,"");
523 if(ret==RESULT_OK)
524 {
525 delete p;
526 }
527 return ret;
528}
529
530int lynq_ivs_push_msd()
531{
532 if(g_module_init_flag != MODULE_RUNNING)
533 {
534 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
535 return LYNQ_E_CONFLICT;
536 }
537// return lynq_set_common_request(RIL_REQUEST_ECALL_IVS_PUSH_MSD,0,"");
538 Parcel* p=NULL;
539 int ret=lynq_send_common_request(p,g_wait_time,RIL_REQUEST_ECALL_IVS_PUSH_MSD,0,"");
540 if(ret==RESULT_OK)
541 {
542 delete p;
543 }
544 return ret;
545}
546
547int wait_ecall_event()
548{
549 int ret = 0;
550 pthread_mutex_lock(&s_incoming_e_call_mutex);
551 ret = pthread_cond_wait(&s_incoming_e_call_cond,&s_incoming_e_call_mutex);
552 pthread_mutex_unlock(&s_incoming_e_call_mutex);
553 return ret;
554}
555
556int lynq_wait_ecall_indication(int* handle, LYNQ_ECall_Indication *eCall_Indication)
557{
558 if(g_module_init_flag != MODULE_RUNNING)
559 {
560 LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
561 return LYNQ_E_CONFLICT;
562 }
563 wait_ecall_event();
564 *handle = s_IncomingEcallId;
565 *eCall_Indication = s_IncomingEcallIndication;
566 LYINFLOG("lynq_wait_ecall_indication handle %d, Ind id: %d", *handle, *eCall_Indication);
567 return RESULT_OK;
568}
569void urc_ecall_msg_process(Parcel *p)
570{
571 int ecall_ind;
572 int ecallId;
573 int send_signal_to_wait_call_state;
574 int handup_ecall_id;
575
576 pthread_mutex_lock(&s_ecall_variable_mutex);
577 send_signal_to_wait_call_state = false;
578 handup_ecall_id=false;
579 p->readInt32(&ecall_ind);
580 s_IncomingEcallIndication = ecall_ind;
581 p->readInt32(&ecallId);
582 s_IncomingEcallId = ecallId;
583 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);
584 switch (s_IncomingEcallIndication)
585 {
586 case LYNQ_ECALL_ACTIVE:
587 if(s_module_is_ecall_dial)
588 {
589 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_ANSWERED;
590 }
591 break;
592 case LYNQ_ECALL_SENDING_START:
593 if(lynq_ecall_is_in_voice())
594 {
595 LYINFLOG("recv msd in voice, ind is changed to %d",LYNQ_ECALL_SENDING_START_IN_VOICE);
596 s_IncomingEcallIndication = LYNQ_ECALL_SENDING_START_IN_VOICE;
597 }
598 break;
599 case LYNQ_ECALL_LLACK_RECEIVED:
600 case LYNQ_ECALL_ALACK_POSITIVE_RECEIVED:
601 case LYNQ_ECALL_ALACK_CLEARDOWN_RECEIVED:
602 //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*/
603 case LYNQ_ECALL_T6_TIMER_OUT:
604 case LYNQ_ECALL_T7_TIMER_OUT:
605 if(s_module_is_ecall_dial)
606 {
607 LYINFLOG("ecall is dialing, recv suc indication");
608 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
q.huangdf0723c2023-04-28 16:03:01 +0800609 if(ecallId >0)
q.huang52921662022-10-20 15:25:45 +0800610 {
q.huangdf0723c2023-04-28 16:03:01 +0800611 if(find_call_id_with_call_id(ecallId)==INVALID_ID)
612 {
613 LYINFLOG("add ecall in loacl list");
614 addAddr("ecall",ecallId);
615 }
616 s_ecallId = ecallId; //API-871 ecall id maybe exists in local list as noraml call to be replaced
617 }
q.huang52921662022-10-20 15:25:45 +0800618 send_signal_to_wait_call_state=true;
619 }
620 else if(ecallId >0 && (find_call_id_with_call_id(ecallId)==INVALID_ID) && (s_EcallVariant != LYNQ_ECALL_CALLBACK))
621 {
622 LYERRLOG("ecall is not in dialing and first recv suc indication, hangup");
623 handup_ecall_id=true;
624 }
625 else
626 {
627 LYERRLOG("ecall is not in dialing and not first recv suc indication");
628 }
629 break;
630 case LYNQ_ECALL_PSAP_CALLBACK_START:
631 if(lynq_ecall_is_running()==0)
632 {
633 if(ecallId>0)
634 {
635 LYINFLOG("ecall is not running, recv psap call back msd start, set ecall running");
636 s_EcallVariant = LYNQ_ECALL_CALLBACK;
637 s_ecallId = ecallId;
638 if(IsNormalCallDailing())
639 {
640 LYINFLOG("stop normal dial");
641 send_signal_to_wait_call_state=true;
642 }
643 else
644 {
645 LYINFLOG("no normal dial");
646 }
647 }
648 else
649 {
650 LYERRLOG("ecallId is abnormal in psap callback");
651 }
652 }
653 else
654 {
655 LYERRLOG("ecall is running, recv psap call back msd start");
656 }
657 break;
658 case LYNQ_ECALL_ABNORMAL_HANGUP:
659 if(s_module_is_ecall_dial == LYNQ_ECALL_DAILING_STATE_NONE)
660 {
661 LYERRLOG("ecall is not in dialing , recv abnormal hangup");
662 s_ecallId = INVALID_ID;
663 }
664 else if (s_module_is_ecall_dial == LYNQ_ECALL_DAILING_STATE_STARTED)
665 {
666 LYERRLOG("ecall is in dialing state, recv no answer, recv abnormal hangup, dont' redial");
667 s_ecallId = INVALID_ID;
668 send_signal_to_wait_call_state=true;
669 }
670 else {
671 LYINFLOG("ecall is in dialing and recv answer, recv abnormal hangup");
672 }
673 break;
674 case LYNQ_ECALL_DISCONNECTED:
675 case LYNQ_ECALL_REDIAL_TIMER_OUT:
676 case LYNQ_ECALL_T2_TIMER_OUT :
677 case LYNQ_ECALL_IMS_DISCONNECTED:
678 s_ecallId = INVALID_ID;
679 if(s_EcallVariant == LYNQ_ECALL_CALLBACK)
680 {
681 s_EcallVariant = LYNQ_ECALL_VAR_NONE; /*other type, needn't re-initialize*/
682 }
683 if(s_module_is_ecall_dial != LYNQ_ECALL_DAILING_STATE_NONE)
684 {
685 LYERRLOG("ecall is in dialing, recv like disconnect indication");
686 s_module_is_ecall_dial = LYNQ_ECALL_DAILING_STATE_NONE;
687 send_signal_to_wait_call_state=true;
688 }
689 else
690 {
691 LYINFLOG("ecall is not in dialing, recv like disconnect indication");
692 }
693 break;
694 default:
695 LYINFLOG("not special indication");
696 }
697 pthread_mutex_unlock(&s_ecall_variable_mutex);
698 if(send_signal_to_wait_call_state)
699 {
700 sendSignalToWaitCallStateChange();
701 }
702 sendSignalIncomingECallEvent();
703 if(handup_ecall_id)
704 {
705 lynq_call_hungup(&ecallId);
706 }
707 LYINFLOG("**************:RIL_UNSOL_ECALL_INDICATIONS, local ecall id is %d", s_ecallId);
708 return;
709}
710#endif