rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | #include <dlfcn.h> |
| 2 | #include <string.h> |
| 3 | #include <stdint.h> |
| 4 | #include <signal.h> |
| 5 | #include <unistd.h> |
| 6 | #include <fcntl.h> |
| 7 | #include "lynq_common.h" |
| 8 | #include "lynq_call.h" |
| 9 | #include <vendor-ril/telephony/ril.h> |
| 10 | #include <stateManager/stateManager.h> |
| 11 | #include <cutils/jstring.h> |
| 12 | |
| 13 | //#include "Parcel.h" |
| 14 | |
| 15 | //#include <sys/time.h> |
| 16 | //#include <time.h> |
| 17 | |
| 18 | //#include <vendor-ril/mtk-rilproxy/atchannel.h> |
| 19 | #undef LOG_TAG |
| 20 | #define LOG_TAG "LYNQ_CALL" |
| 21 | |
| 22 | //rita add @2020.7.8 for add call api |
| 23 | //mobiletek @2020.11.10 add api statemanager |
| 24 | int timer_count=0; |
| 25 | enum {EXIT ,CHECK}status_call; |
| 26 | callInfoLink * callInfoLinkhead =NULL; |
| 27 | |
| 28 | int call_Info_Init() |
| 29 | { |
| 30 | callInfoLinkhead=create_callInfoLink(); |
| 31 | if(callInfoLinkhead==NULL) |
| 32 | { |
| 33 | RLOGD("init call info fail,maybe malloc fail!"); |
| 34 | return -1; |
| 35 | } |
| 36 | return 0; |
| 37 | } |
| 38 | void sigalrm_handler(int sig) |
| 39 | { |
| 40 | timer_count++; |
| 41 | printf("timer signal.. %d\n", timer_count); |
| 42 | } |
| 43 | void updateCallBackInfo(lynqCallList *message,lynq_call_list *calllsit) |
| 44 | { |
| 45 | message->call_id=calllsit->callid; |
| 46 | message->call_state=(lynqCallState)calllsit->callState; |
| 47 | message->toa=calllsit->toa; |
| 48 | message->addr = calllsit->addr; |
| 49 | //memcpy(message->addr, calllsit->addr, strlen(calllsit->addr)+1); |
| 50 | return; |
| 51 | } |
| 52 | void showCallList(lynq_call_list *calllsit) |
| 53 | { |
| 54 | if (calllsit==NULL) |
| 55 | { |
| 56 | RLOGD("the call list is null"); |
| 57 | return; |
| 58 | } |
| 59 | LYINFLOG("lynq token is %d\n",calllsit->token); |
| 60 | LYINFLOG("lynq callid is %d\n",calllsit->callid); |
| 61 | LYINFLOG("lynq toa is %d\n",calllsit->toa); |
| 62 | LYINFLOG("lynq addr is %s\n",calllsit->addr); |
| 63 | LYINFLOG("lynq callstate is %d\n",calllsit->callState); |
| 64 | LYINFLOG("lynq lynq_error is %d\n",calllsit->lynq_error); |
| 65 | LYINFLOG("lynq isMT is %d\n",calllsit->isMT); |
| 66 | LYINFLOG("lynq serflen is %d\n",calllsit->selflen); |
| 67 | return; |
| 68 | } |
| 69 | void checkCallInfo(lynqCallList *message,const char *UserPhonyNum,int32_t token) |
| 70 | { |
| 71 | int resplen=0; |
| 72 | int time_call =100;//10 s. |
| 73 | callInfoLink *temp; |
| 74 | enum{RUN,EXIT}state; |
| 75 | state=RUN; |
| 76 | while(time_call--) |
| 77 | { |
| 78 | millli_sleep_with_restart(100); |
| 79 | temp=callInfoLinkhead; |
| 80 | if (temp != NULL) |
| 81 | { |
| 82 | do |
| 83 | { |
| 84 | LYDBGLOG("[%s][%d][%s]token=%x Error_tok=%d,request is %d\n",__FUNCTION__, __LINE__,__FILE__, |
| 85 | temp->token, temp->Error_tok,temp->request); |
| 86 | //RLOGD("token=%x Error_tok=%d", p->token, p->Error_tok,p->request); |
| 87 | switch (temp->request) |
| 88 | { |
| 89 | case RIL_REQUEST_DIAL: |
| 90 | { |
| 91 | if(temp->Error_tok==RIL_E_GENERIC_FAILURE) |
| 92 | { |
| 93 | message->call_state=LYNQ_CALL_DACTIVE; |
| 94 | message->base.e = temp->Error_tok; |
| 95 | return; |
| 96 | } |
| 97 | if((temp->calllist_tok==NULL)||(temp->calllist_tok[0]==NULL)) |
| 98 | { |
| 99 | RLOGD("call list is null"); |
| 100 | state=EXIT; |
| 101 | break; |
| 102 | } |
| 103 | resplen=temp->calllist_tok[0]->selflen; |
| 104 | //printf("----resplen %d----\n",resplen); |
| 105 | for(int i=0;i<resplen;i++) |
| 106 | { |
| 107 | printf("temp->token %x,input token is %x\n",temp->token,token); |
| 108 | if((temp->token==token)&&(temp->calllist_tok[i]->callState==2)) |
| 109 | { |
| 110 | //showCallList(temp->calllist_tok[i]);//for test |
| 111 | if(strcmp(temp->calllist_tok[i]->addr, UserPhonyNum)==0) |
| 112 | { |
| 113 | updateCallBackInfo(message,temp->calllist_tok[i]); |
| 114 | state=EXIT; |
| 115 | return; |
| 116 | } |
| 117 | } |
| 118 | /* |
| 119 | if(temp->calllist_tok[i]->lynq_error==RIL_E_GENERIC_FAILURE) |
| 120 | { |
| 121 | printf("RIL_E_GENERIC_FAILURE\n"); |
| 122 | state=EXIT; |
| 123 | break; |
| 124 | }*/ |
| 125 | } |
| 126 | break; |
| 127 | } |
| 128 | case RIL_REQUEST_ANSWER: |
| 129 | { |
| 130 | if(temp->Error_tok==RIL_E_GENERIC_FAILURE) |
| 131 | { |
| 132 | printf("RIL_E_GENERIC_FAILURE\n"); |
| 133 | message->call_state=LYNQ_CALL_INCOMING; |
| 134 | message->base.e = temp->Error_tok; |
| 135 | return; |
| 136 | } |
| 137 | if((temp->calllist_tok==NULL)||(temp->calllist_tok[0]==NULL)) |
| 138 | { |
| 139 | RLOGD("call list is null"); |
| 140 | state=EXIT; |
| 141 | break; |
| 142 | } |
| 143 | resplen=temp->calllist_tok[0]->selflen; |
| 144 | //printf("----resplen %d----\n",resplen); |
| 145 | for(int i=0;i<resplen;i++) |
| 146 | { |
| 147 | printf("temp->token %x,input token is %x\n",temp->token,token); |
| 148 | if((temp->token==token)&&(temp->calllist_tok[i]->isMT==1) |
| 149 | &&(temp->calllist_tok[i]->callState==0)) |
| 150 | { |
| 151 | showCallList(temp->calllist_tok[i]);//for test |
| 152 | updateCallBackInfo(message,temp->calllist_tok[i]); |
| 153 | state=EXIT; |
| 154 | return; |
| 155 | } |
| 156 | } |
| 157 | time_call=time_call-5; |
| 158 | break; |
| 159 | } |
| 160 | default: |
| 161 | break; |
| 162 | } |
| 163 | |
| 164 | temp = temp->next; |
| 165 | } |
| 166 | while ((temp != NULL)&&(state==RUN)); |
| 167 | } |
| 168 | else |
| 169 | { |
| 170 | RLOGD("call info link head is null"); |
| 171 | continue; |
| 172 | } |
| 173 | } |
| 174 | printf("time_call is %d \n",time_call); |
| 175 | if(time_call<0) |
| 176 | { |
| 177 | message->call_state=LYNQ_CALL_DACTIVE; |
| 178 | message->base.e = -1; |
| 179 | } |
| 180 | return ; |
| 181 | } |
| 182 | static char *strdupReadString(Parcel &p) { |
| 183 | size_t stringlen; |
| 184 | const char16_t *s16; |
| 185 | |
| 186 | s16 = p.readString16Inplace(&stringlen); |
| 187 | |
| 188 | return strndup16to8(s16, stringlen); |
| 189 | } |
| 190 | static lynq_call_list ** parcelToCallList(Parcel &p,int &len) |
| 191 | { |
| 192 | int num = 0; |
| 193 | int uusPresent; |
| 194 | lynq_call_list **pCallLists = NULL; |
| 195 | lynq_call_list *pCallList = NULL; |
| 196 | int32_t res; |
| 197 | p.setDataPosition(0); |
| 198 | if (p.dataAvail() > 0) |
| 199 | { |
| 200 | p.readInt32(&num); |
| 201 | len=num; |
| 202 | pCallLists = (lynq_call_list **) calloc(1, sizeof(lynq_call_list *) * num); |
| 203 | memset(pCallLists,0,sizeof(lynq_call_list *) * num); |
| 204 | for (int i = 0; i < num; i++) |
| 205 | { |
| 206 | pCallList = (lynq_call_list *) calloc(1, sizeof(lynq_call_list)); |
| 207 | memset(pCallList,0,sizeof(lynq_call_list)); |
| 208 | pCallLists[i] = pCallList; |
| 209 | p.readInt32(&res); |
| 210 | pCallLists[i]->callState = (RIL_CallState) res; |
| 211 | p.readInt32(&pCallLists[i]->callid); |
| 212 | p.readInt32(&pCallLists[i]->toa); |
| 213 | p.readInt32(&res); |
| 214 | pCallLists[i]->isMpty = (uint8_t) res; |
| 215 | p.readInt32(&res); |
| 216 | pCallLists[i]->isMT = (uint8_t) res; |
| 217 | pCallLists[i]->addr = strdupReadString(p); |
| 218 | pCallLists[i]->selflen = num; |
| 219 | } |
| 220 | } |
| 221 | return pCallLists; |
| 222 | } |
| 223 | static void updateCallLists(const char *UserPhonyNum,lynqCallList *message,lynqQueue * node,int time) |
| 224 | { |
| 225 | int resplen=0; |
| 226 | int time_call =time; |
| 227 | lynq_call_list ** call_list=NULL; |
| 228 | if(node ==NULL) |
| 229 | { |
| 230 | LYDBGLOG("update call lists node is null!"); |
| 231 | return; |
| 232 | } |
| 233 | while(time_call--) |
| 234 | { |
| 235 | millli_sleep_with_restart(10); |
| 236 | switch (node->request) |
| 237 | { |
| 238 | case RIL_REQUEST_DIAL: |
| 239 | { |
| 240 | call_list = parcelToCallList(node->parcel, resplen); |
| 241 | if(call_list==NULL) |
| 242 | { |
| 243 | LYDBGLOG("call lists is null"); |
| 244 | break; |
| 245 | } |
| 246 | for(int i=0;i<resplen;i++) |
| 247 | { |
| 248 | if(call_list[i]->callState==2) |
| 249 | { |
| 250 | //showCallList(call_list[i]);//for test |
| 251 | if(strcmp(call_list[i]->addr, UserPhonyNum)==0) |
| 252 | { |
| 253 | updateCallBackInfo(message,call_list[i]); |
| 254 | return; |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | break; |
| 259 | } |
| 260 | case RIL_REQUEST_ANSWER: |
| 261 | { |
| 262 | call_list = parcelToCallList(node->parcel, resplen); |
| 263 | if(call_list==NULL) |
| 264 | { |
| 265 | LYDBGLOG("incoming call lists is null"); |
| 266 | break; |
| 267 | } |
| 268 | if(node->t_Errno==RIL_E_GENERIC_FAILURE) |
| 269 | { |
| 270 | for(int i=0;i<resplen;i++) |
| 271 | { |
| 272 | if(call_list[i]->isMT==1) |
| 273 | { |
| 274 | message->call_state=(lynqCallState)call_list[i]->callState; |
| 275 | break; |
| 276 | } |
| 277 | } |
| 278 | message->base.e = node->t_Errno; |
| 279 | return; |
| 280 | } |
| 281 | for(int i=0;i<resplen;i++) |
| 282 | { |
| 283 | if((call_list[i]->isMT==1)&&(call_list[i]->callState==RIL_CALL_ACTIVE)) |
| 284 | { |
| 285 | //showCallList(call_list[i]);//for test |
| 286 | updateCallBackInfo(message,call_list[i]); |
| 287 | return; |
| 288 | } |
| 289 | } |
| 290 | break; |
| 291 | } |
| 292 | case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: |
| 293 | case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: |
| 294 | case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: |
| 295 | { |
| 296 | call_list = parcelToCallList(node->parcel, resplen); |
| 297 | if(call_list==NULL) |
| 298 | { |
| 299 | LYDBGLOG("[%s] call lists is null\n",__FUNCTION__); |
| 300 | break; |
| 301 | } |
| 302 | for(int i =0;i<resplen;i++) |
| 303 | { |
| 304 | if(call_list[i]->callState==RIL_CALL_ACTIVE) |
| 305 | { |
| 306 | //showCallList(call_list[i]);//for test |
| 307 | updateCallBackInfo(message,call_list[i]); |
| 308 | return; |
| 309 | } |
| 310 | } |
| 311 | break; |
| 312 | } |
| 313 | case RIL_REQUEST_CONFERENCE: |
| 314 | { |
| 315 | call_list = parcelToCallList(node->parcel, resplen); |
| 316 | if(call_list==NULL) |
| 317 | { |
| 318 | LYDBGLOG("call lists is null"); |
| 319 | break; |
| 320 | } |
| 321 | for(int i =0;i<resplen;i++) |
| 322 | { |
| 323 | if((call_list[i]->callState==RIL_CALL_ACTIVE)&&(call_list[i]->isMpty !=0)) |
| 324 | { |
| 325 | //showCallList(call_list[i]);//for test |
| 326 | updateCallBackInfo(message,call_list[i]); |
| 327 | return; |
| 328 | } |
| 329 | } |
| 330 | break; |
| 331 | } |
| 332 | default: |
| 333 | break; |
| 334 | } |
| 335 | } |
| 336 | LYDBGLOG("[%S] time_call is %d \n",__FUNCTION__,time_call); |
| 337 | if(time_call<0) |
| 338 | { |
| 339 | message->call_state=LYNQ_CALL_DACTIVE; |
| 340 | message->base.e = -1; |
| 341 | } |
| 342 | return ; |
| 343 | |
| 344 | } |
| 345 | void checkParcelCallInfo(lynqCallList *message,const char *UserPhonyNum,int32_t token,int time) |
| 346 | { |
| 347 | int resplen=0; |
| 348 | int time_call =time; |
| 349 | lynqQueue *temp=NULL; |
| 350 | //enum{RUN,EXIT}state; |
| 351 | //state=RUN; |
| 352 | message->base.e=-1; |
| 353 | printf("checkCallInfo start\n"); |
| 354 | lynq_call_list ** call_list=NULL; |
| 355 | lynqQueue * node = NULL; |
| 356 | while(time_call--) |
| 357 | { |
| 358 | millli_sleep_with_restart(10); |
| 359 | temp=LynqQueueHead; |
| 360 | if (temp != NULL) |
| 361 | { |
| 362 | node = searchTokeninQueue(token, temp); |
| 363 | if(node ==NULL) |
| 364 | { |
| 365 | RLOGD("can not find token %x in this queue",token); |
| 366 | continue; |
| 367 | } |
| 368 | message->base.e = node->t_Errno; |
| 369 | /*if(node->t_Errno==RIL_E_GENERIC_FAILURE) |
| 370 | { |
| 371 | RLOGD("RIL_E_GENERIC_FAILURE"); |
| 372 | return; |
| 373 | } |
| 374 | */ |
| 375 | //printf("token=%x Error_tok=%d,request is %d\n", node->token, node->t_Errno,node->request); |
| 376 | switch (node->request) |
| 377 | { |
| 378 | case RIL_REQUEST_DIAL: |
| 379 | { |
| 380 | if(node->t_Errno==RIL_E_GENERIC_FAILURE) |
| 381 | { |
| 382 | RLOGD("RIL_E_GENERIC_FAILURE"); |
| 383 | message->call_state=LYNQ_CALL_DACTIVE; |
| 384 | message->base.e = node->t_Errno; |
| 385 | return; |
| 386 | } |
| 387 | call_list = parcelToCallList(node->parcel, resplen); |
| 388 | if(call_list==NULL) |
| 389 | { |
| 390 | RLOGD("call lists is null"); |
| 391 | break; |
| 392 | } |
| 393 | //printf("----resplen %d----\n",resplen); |
| 394 | for(int i=0;i<resplen;i++) |
| 395 | { |
| 396 | printf("temp->token %x,input token is %x\n",node->token,token); |
| 397 | if((node->token==token)&&(call_list[i]->callState==2)) |
| 398 | { |
| 399 | //showCallList(call_list[i]);//for test |
| 400 | if(strcmp(call_list[i]->addr, UserPhonyNum)==0) |
| 401 | { |
| 402 | updateCallBackInfo(message,call_list[i]); |
| 403 | return; |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | break; |
| 408 | } |
| 409 | case RIL_REQUEST_ANSWER: |
| 410 | { |
| 411 | call_list = parcelToCallList(node->parcel, resplen); |
| 412 | if(call_list==NULL) |
| 413 | { |
| 414 | RLOGD("incoming call lists is null"); |
| 415 | break; |
| 416 | } |
| 417 | if(node->t_Errno==RIL_E_GENERIC_FAILURE) |
| 418 | { |
| 419 | RLOGD("RIL_E_GENERIC_FAILURE"); |
| 420 | for(int i=0;i<resplen;i++) |
| 421 | { |
| 422 | if(call_list[i]->isMT==1) |
| 423 | { |
| 424 | message->call_state=(lynqCallState)call_list[i]->callState; |
| 425 | break; |
| 426 | } |
| 427 | } |
| 428 | message->base.e = node->t_Errno; |
| 429 | return; |
| 430 | } |
| 431 | //printf("----resplen %d----\n",resplen); |
| 432 | for(int i=0;i<resplen;i++) |
| 433 | { |
| 434 | printf("temp->token %x,input token is %x\n",node->token,token); |
| 435 | if((call_list[i]->isMT==1)&&(call_list[i]->callState==0)) |
| 436 | { |
| 437 | showCallList(call_list[i]);//for test |
| 438 | updateCallBackInfo(message,call_list[i]); |
| 439 | return; |
| 440 | } |
| 441 | } |
| 442 | break; |
| 443 | } |
| 444 | case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: |
| 445 | { |
| 446 | call_list = parcelToCallList(node->parcel, resplen); |
| 447 | if(call_list==NULL) |
| 448 | { |
| 449 | RLOGD("call lists is null"); |
| 450 | break; |
| 451 | } |
| 452 | if(node->t_Errno==RIL_E_GENERIC_FAILURE) |
| 453 | { |
| 454 | RLOGD("RIL_E_GENERIC_FAILURE"); |
| 455 | message->base.e = node->t_Errno; |
| 456 | return; |
| 457 | } |
| 458 | //printf("----resplen %d----\n",resplen); |
| 459 | if(resplen == 1) |
| 460 | { |
| 461 | showCallList(call_list[0]);//for test |
| 462 | message->call_id=call_list[0]->callid; |
| 463 | message->call_state=(lynqCallState)call_list[0]->callState; |
| 464 | message->toa=call_list[0]->toa; |
| 465 | message->addr = call_list[0]->addr; |
| 466 | //updateCallBackInfo(message,call_list[0]); |
| 467 | message->base.e = node->t_Errno; |
| 468 | //printf("message->call_state is %d\n",message->call_state); |
| 469 | //printf("test pass\n"); |
| 470 | return; |
| 471 | } |
| 472 | break; |
| 473 | } |
| 474 | default: |
| 475 | break; |
| 476 | } |
| 477 | |
| 478 | } |
| 479 | else |
| 480 | { |
| 481 | RLOGD("call info link head is null"); |
| 482 | continue; |
| 483 | } |
| 484 | } |
| 485 | printf("time_call is %d \n",time_call); |
| 486 | if(time_call<0) |
| 487 | { |
| 488 | message->call_state=LYNQ_CALL_DACTIVE; |
| 489 | message->base.e = -1; |
| 490 | } |
| 491 | return ; |
| 492 | } |
| 493 | |
| 494 | |
| 495 | int lynq_call_old(RIL_Dial *pRilDail)//function:dial;address:callnumber,clir:0 is default value,uusInfo:NULL or Pointer to User-User Signaling Information |
| 496 | { |
| 497 | int lenth; |
| 498 | char *argv[MAX_LEN] = {}; |
| 499 | char indexStr[MAX_QUEST_LEN] = ""; |
| 500 | char uusType[MAX_QUEST_LEN] = ""; |
| 501 | char uusDcs[MAX_QUEST_LEN] = ""; |
| 502 | char uusLength[MAX_QUEST_LEN] = ""; |
| 503 | |
| 504 | sprintf(indexStr, "%d", pRilDail->clir); |
| 505 | |
| 506 | argv[0] = "RIL_REQUEST_DIAL"; |
| 507 | argv[1] = pRilDail->address; |
| 508 | argv[2] = indexStr; |
| 509 | |
| 510 | if(pRilDail->uusInfo) |
| 511 | { |
| 512 | //printf("=========>[%s,%d],uusInfo exist!!!\n",__FUNCTION__,__LINE__); |
| 513 | sprintf(uusType,"%d",pRilDail->uusInfo->uusType); |
| 514 | sprintf(uusDcs,"%d",pRilDail->uusInfo->uusDcs); |
| 515 | sprintf(uusLength,"%d",pRilDail->uusInfo->uusLength); |
| 516 | |
| 517 | argv[3] = uusType; |
| 518 | argv[4] = uusDcs; |
| 519 | argv[5] = uusLength; |
| 520 | argv[6] = pRilDail->uusInfo->uusData; |
| 521 | lenth = 7; |
| 522 | } |
| 523 | else |
| 524 | { |
| 525 | //printf("=========>[%s,%d],uusInfo is NULL!!!\n",__FUNCTION__,__LINE__); |
| 526 | lenth = 3; |
| 527 | } |
| 528 | |
| 529 | return android::getRequestData(argv, lenth); |
| 530 | } |
| 531 | int lynq_call(const char *addr,lynqCallList* msg)//function:dial;address:callnumber,clir:0 is default value,uusInfo:NULL or Pointer to User-User Signaling Information |
| 532 | { |
| 533 | int32_t token=0; |
| 534 | int resplen=0; |
| 535 | RIL_Errno err=-1; |
| 536 | lynqQueue *node = NULL; |
| 537 | const char *argv[MAX_LEN]={}; |
| 538 | char indexStr[MAX_QUEST_LEN] = ""; |
| 539 | argv[0] = "RIL_REQUEST_DIAL"; |
| 540 | if(addr==NULL) |
| 541 | { |
| 542 | RLOGD("addr is null!"); |
| 543 | LYDBGLOG("addr is null!\n"); |
| 544 | msg->call_state=LYNQ_CALL_DACTIVE; |
| 545 | msg->base.e = -1; |
| 546 | return 0; |
| 547 | } |
| 548 | argv[1] = addr; |
| 549 | argv[2]= "0"; |
| 550 | if(token = android::getRequestData(argv, 3)) |
| 551 | { |
| 552 | msg->base.token=token; |
| 553 | msg->base.request=RIL_REQUEST_DIAL; |
| 554 | node = commonUpdateEstatus(token,500, err);//wait 5s |
| 555 | msg->base.e = err; |
| 556 | if(err !=RIL_E_SUCCESS) |
| 557 | { |
| 558 | LYDBGLOG("lynq_call error code is %d!",err); |
| 559 | msg->call_state=LYNQ_CALL_DACTIVE; |
| 560 | lynqDeQueue(token); |
| 561 | return token; |
| 562 | } |
| 563 | updateCallLists(addr,msg,node,9000);//wait 90s |
| 564 | //setCallStatus(LYNQ_CALL_ON); |
| 565 | lynqDeQueue(token); |
| 566 | } |
| 567 | return token; |
| 568 | } |
| 569 | int lynq_call_answer(lynqCallList* msg)//function:answer a call |
| 570 | { |
| 571 | int lenth; |
| 572 | int32_t token=0; |
| 573 | int resplen=0; |
| 574 | RIL_Errno err=-1; |
| 575 | lynqQueue *node = NULL; |
| 576 | char requestStr[MAX_LEN] = {"RIL_REQUEST_ANSWER"}; |
| 577 | if(LYNQ_CALL_OFF==getCallStatus()) |
| 578 | { |
| 579 | msg->base.request = RIL_REQUEST_HANGUP; |
| 580 | msg->base.token=token; |
| 581 | msg->base.e=LYNQ_E_CONFLICT;//logic conflict,if must |
| 582 | return token; |
| 583 | } |
| 584 | if(token=lynqNoneParame(requestStr)) |
| 585 | { |
| 586 | msg->base.token=token; |
| 587 | msg->base.request=RIL_REQUEST_ANSWER; |
| 588 | node = commonUpdateEstatus(token,500, err); |
| 589 | msg->base.e = err; |
| 590 | if(err !=RIL_E_SUCCESS) |
| 591 | { |
| 592 | LYDBGLOG("lynq_call_answer error code is %d!",err); |
| 593 | msg->call_state=LYNQ_CALL_DACTIVE; |
| 594 | lynqDeQueue(token); |
| 595 | return token; |
| 596 | } |
| 597 | updateCallLists(NULL,msg,node,200); |
| 598 | lynqDeQueue(token); |
| 599 | } |
| 600 | return token; |
| 601 | } |
| 602 | |
| 603 | int lynq_call_hang_up(const int callId,lynqBase *base)//function:hang up a call |
| 604 | { |
| 605 | char *argv[MAX_LEN] = {}; |
| 606 | char indexStr[MAX_QUEST_LEN] = ""; |
| 607 | int32_t token=0; |
| 608 | int status = 0; |
| 609 | RIL_Errno err=-1; |
| 610 | lynqQueue * node = NULL; |
| 611 | sprintf(indexStr, "%d", callId); |
| 612 | argv[0] = "RIL_REQUEST_HANGUP"; |
| 613 | argv[1] = indexStr; |
| 614 | if(LYNQ_CALL_OFF==getCallStatus()) |
| 615 | { |
| 616 | base->request = RIL_REQUEST_HANGUP; |
| 617 | base->token=token; |
| 618 | base->e=LYNQ_E_CONFLICT;//logic conflict,if must |
| 619 | return token; |
| 620 | } |
| 621 | if(token = android::getRequestData(argv, 2)) |
| 622 | { |
| 623 | base->request = RIL_REQUEST_HANGUP; |
| 624 | base->token=token; |
| 625 | node = commonUpdateEstatus(token,500,err); |
| 626 | base->e=err; |
| 627 | lynqDeQueue(token); |
| 628 | } |
| 629 | return token; |
| 630 | } |
| 631 | |
| 632 | int lynq_reject_call(lynqBase *base)//function:hang up all call or reject call |
| 633 | { |
| 634 | char requestStr[MAX_LEN] = {"RIL_REQUEST_UDUB"}; |
| 635 | int32_t token=0; |
| 636 | int status = 0; |
| 637 | RIL_Errno err=-1; |
| 638 | lynqQueue * node = NULL; |
| 639 | if(LYNQ_CALL_OFF==getCallStatus()) |
| 640 | { |
| 641 | base->request = RIL_REQUEST_UDUB; |
| 642 | base->token=token; |
| 643 | base->e=LYNQ_E_CONFLICT;//logic conflict,if must |
| 644 | return token; |
| 645 | } |
| 646 | if(token =lynqNoneParame(requestStr)) |
| 647 | { |
| 648 | base->request = RIL_REQUEST_UDUB; |
| 649 | base->token=token; |
| 650 | node = commonUpdateEstatus(token,500,err); |
| 651 | base->e=err; |
| 652 | lynqDeQueue(token); |
| 653 | } |
| 654 | return token; |
| 655 | } |
| 656 | |
| 657 | int lynq_set_auto_answercall(int mode,int *status)// 1:enable,0:disable |
| 658 | { |
| 659 | char *argv[MAX_LEN] = {}; |
| 660 | char modeStr[MAX_QUEST_LEN] = ""; |
| 661 | int32_t token=0; |
| 662 | sprintf(modeStr, "%d", mode); |
| 663 | argv[0] = "RIL_REQUEST_AUTO_ANSWER"; |
| 664 | argv[1] = modeStr; |
| 665 | token = android::getRequestData(argv, 2); |
| 666 | *status = autoAnswerMode; |
| 667 | return token; |
| 668 | } |
| 669 | |
| 670 | int lynq_get_mute_status(int *status) |
| 671 | { |
| 672 | char *argv[MAX_LEN] = {}; |
| 673 | int32_t token; |
| 674 | char enableStr[MAX_QUEST_LEN] = ""; |
| 675 | ///sprintf(enableStr, "%d", enable); |
| 676 | argv[0] = "RIL_REQUEST_GET_MUTE"; |
| 677 | //argv[1] = enableStr; |
| 678 | *status = android::specialRequestController(argv, 1,&token); |
| 679 | return token; |
| 680 | |
| 681 | } |
| 682 | int lynq_get_mute_mic(int *status) // 1:enable 0:disable |
| 683 | { |
| 684 | char *argv[MAX_LEN] = {}; |
| 685 | int32_t token; |
| 686 | char enableStr[MAX_QUEST_LEN] = ""; |
| 687 | argv[0] = "RIL_REQUEST_GET_MUTE"; |
| 688 | *status = android::specialRequestController(argv, 1,&token); |
| 689 | return 0; |
| 690 | } |
| 691 | int lynq_set_mute_mic(const int enable,int *status) // 1:enable 0:disable |
| 692 | { |
| 693 | char *argv[MAX_LEN] = {}; |
| 694 | int32_t token; |
| 695 | char enableStr[MAX_QUEST_LEN] = ""; |
| 696 | sprintf(enableStr, "%d", enable); |
| 697 | argv[0] = "RIL_REQUEST_SET_MUTE"; |
| 698 | argv[1] = enableStr; |
| 699 | int ret = android::specialRequestController(argv, 2,&token); |
| 700 | if(ret) |
| 701 | { |
| 702 | LYDBGLOG("set mute failed !!"); |
| 703 | *status = -1; |
| 704 | return token; |
| 705 | } |
| 706 | lynq_get_mute_mic(status); |
| 707 | *status = (enable>0)?1:0; |
| 708 | return token; |
| 709 | } |
| 710 | |
| 711 | int lynq_set_DTMF(const char callnum,lynqBase *base)//callnum: 0-9,*,# |
| 712 | { |
| 713 | char *argv[MAX_LEN] = {}; |
| 714 | char callnumStr[MAX_QUEST_LEN] = ""; |
| 715 | int32_t token=0; |
| 716 | //int status = 0; |
| 717 | RIL_Errno err=-1; |
| 718 | lynqQueue * node = NULL; |
| 719 | if(LYNQ_CALL_OFF==getCallStatus()) |
| 720 | { |
| 721 | base->request = RIL_REQUEST_DTMF; |
| 722 | base->token=token; |
| 723 | base->e=LYNQ_E_CONFLICT;//logic conflict,if must |
| 724 | return token; |
| 725 | } |
| 726 | if (INDEX_IS_NUMBER(callnum) || (callnum == '#') || (callnum == '*')) |
| 727 | { |
| 728 | sprintf(callnumStr, "%c", callnum); |
| 729 | argv[0] = "RIL_REQUEST_DTMF"; |
| 730 | argv[1] = callnumStr; |
| 731 | if(token =android::getRequestData(argv, 2)) |
| 732 | { |
| 733 | base->request = RIL_REQUEST_DTMF; |
| 734 | base->token=token; |
| 735 | node = commonUpdateEstatus(token,500,err); |
| 736 | base->e=err; |
| 737 | lynqDeQueue(token); |
| 738 | } |
| 739 | return token; |
| 740 | } |
| 741 | else |
| 742 | { |
| 743 | base->e=err; |
| 744 | LYERRLOG("[%s][%d][%s] invalid parameter!!! \n",__FUNCTION__,__LINE__,__FILE__); |
| 745 | return -1; |
| 746 | } |
| 747 | } |
| 748 | int lynq_set_DTMF_volume(const int volume)//volume : 0 to 36 |
| 749 | { |
| 750 | char *argv[MAX_LEN] = {}; |
| 751 | char volumeStr[MAX_QUEST_LEN] = ""; |
| 752 | |
| 753 | if((volume<=36) && (volume>=0)) |
| 754 | { |
| 755 | argv[0] = "RIL_REQUEST_SET_DTMF_VOLUME"; |
| 756 | sprintf(volumeStr, "%d", volume); |
| 757 | argv[1] = volumeStr; |
| 758 | |
| 759 | return android::getRequestData(argv, 2); |
| 760 | } |
| 761 | else{ |
| 762 | LYERRLOG("[%s][%d][%s] invalid parameter!!! \n",__FUNCTION__,__LINE__,__FILE__); |
| 763 | return -1; |
| 764 | } |
| 765 | } |
| 766 | |
| 767 | int lynq_do_multi_conference(lynqCallList *msg) |
| 768 | { |
| 769 | int32_t token=0; |
| 770 | int resplen=0; |
| 771 | RIL_Errno err=-1; |
| 772 | lynqQueue * node = NULL; |
| 773 | char requestStr[MAX_LEN] = {"RIL_REQUEST_CONFERENCE"}; |
| 774 | if(LYNQ_CALL_OFF==getCallStatus()) |
| 775 | { |
| 776 | msg->base.request = RIL_REQUEST_CONFERENCE; |
| 777 | msg->base.token=token; |
| 778 | msg->base.e=LYNQ_E_CONFLICT;//logic conflict,if must |
| 779 | return token; |
| 780 | } |
| 781 | if(token =lynqNoneParame(requestStr)) |
| 782 | { |
| 783 | msg->base.request=RIL_REQUEST_CONFERENCE; |
| 784 | msg->base.token=token; |
| 785 | node = commonUpdateEstatus(token,500,err); |
| 786 | msg->base.e = err; |
| 787 | if(err !=RIL_E_SUCCESS) |
| 788 | { |
| 789 | LYDBGLOG("[%s] error code is %d!",__FUNCTION__,err); |
| 790 | lynqDeQueue(token); |
| 791 | return token; |
| 792 | } |
| 793 | updateCallLists(NULL,msg,node,200); |
| 794 | lynqDeQueue(token); |
| 795 | } |
| 796 | return token; |
| 797 | } |
| 798 | |
| 799 | int lynq_othercall_hold(const int callindex,lynqBase *base)//other select call turn hold |
| 800 | { |
| 801 | int32_t token=0; |
| 802 | int resplen=0; |
| 803 | RIL_Errno err=-1; |
| 804 | lynqQueue * node = NULL; |
| 805 | char *argv[MAX_LEN] = {}; |
| 806 | char callindexStr[MAX_QUEST_LEN] = ""; |
| 807 | sprintf(callindexStr, "%d", callindex); |
| 808 | argv[0] = "RIL_REQUEST_SEPARATE_CONNECTION"; |
| 809 | argv[1] = callindexStr; |
| 810 | if(LYNQ_CALL_OFF==getCallStatus()) |
| 811 | { |
| 812 | base->request = RIL_REQUEST_SEPARATE_CONNECTION; |
| 813 | base->token=token; |
| 814 | base->e=LYNQ_E_CONFLICT;//logic conflict,if must |
| 815 | return token; |
| 816 | } |
| 817 | if(token = android::getRequestData(argv, 2)) |
| 818 | { |
| 819 | base->request=RIL_REQUEST_SEPARATE_CONNECTION; |
| 820 | base->token=token; |
| 821 | node = commonUpdateEstatus(token,500,err); |
| 822 | base->e = err; |
| 823 | lynqDeQueue(token); |
| 824 | } |
| 825 | return token; |
| 826 | } |
| 827 | |
| 828 | int lynq_hangup_wating_for_call(lynqCallList *msg) |
| 829 | { |
| 830 | int lenth; |
| 831 | int32_t token=0; |
| 832 | int resplen=0; |
| 833 | RIL_Errno err=-1; |
| 834 | lynqQueue * node = NULL; |
| 835 | //status_call = CHECK; |
| 836 | char requestStr[MAX_LEN] = {"RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND"}; |
| 837 | if(LYNQ_CALL_OFF==getCallStatus()) |
| 838 | { |
| 839 | msg->base.request = RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND; |
| 840 | msg->base.token=token; |
| 841 | msg->base.e=LYNQ_E_CONFLICT;//logic conflict,if must |
| 842 | return token; |
| 843 | } |
| 844 | //token=lynqNoneParame(requestStr); |
| 845 | //msg->base.token=token; |
| 846 | //msg->base.request=RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND; |
| 847 | if(token =lynqNoneParame(requestStr)) |
| 848 | { |
| 849 | msg->base.request=RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND; |
| 850 | msg->base.token=token; |
| 851 | node = commonUpdateEstatus(token,500,err); |
| 852 | msg->base.e = err; |
| 853 | if(err !=RIL_E_SUCCESS) |
| 854 | { |
| 855 | LYDBGLOG("[%s] error code is %d!",__FUNCTION__,err); |
| 856 | lynqDeQueue(token); |
| 857 | return token; |
| 858 | } |
| 859 | updateCallLists(NULL,msg,node,200); |
| 860 | lynqDeQueue(token); |
| 861 | } |
| 862 | return token; |
| 863 | } |
| 864 | |
| 865 | int lynq_hangup_foreground_resume_background(lynqCallList *msg) |
| 866 | { |
| 867 | int32_t token=0; |
| 868 | int resplen=0; |
| 869 | RIL_Errno err=-1; |
| 870 | lynqQueue * node = NULL; |
| 871 | char requestStr[MAX_LEN] = {"RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND"}; |
| 872 | if(LYNQ_CALL_OFF==getCallStatus()) |
| 873 | { |
| 874 | msg->base.request = RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND; |
| 875 | msg->base.token=token; |
| 876 | msg->base.e=LYNQ_E_CONFLICT;//logic conflict,if must |
| 877 | return token; |
| 878 | } |
| 879 | if(token =lynqNoneParame(requestStr)) |
| 880 | { |
| 881 | msg->base.request=RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND; |
| 882 | msg->base.token=token; |
| 883 | node = commonUpdateEstatus(token,500,err); |
| 884 | msg->base.e = err; |
| 885 | if(err !=RIL_E_SUCCESS) |
| 886 | { |
| 887 | LYDBGLOG("[%s] error code is %d!",__FUNCTION__,err); |
| 888 | lynqDeQueue(token); |
| 889 | return token; |
| 890 | } |
| 891 | updateCallLists(NULL,msg,node,200); |
| 892 | lynqDeQueue(token); |
| 893 | } |
| 894 | return token; |
| 895 | } |
| 896 | |
| 897 | int lynq_switch_hold_and_active_call(lynqCallList *msg) |
| 898 | { |
| 899 | int32_t token=0; |
| 900 | int resplen=0; |
| 901 | RIL_Errno err=-1; |
| 902 | lynqQueue * node = NULL; |
| 903 | char requestStr[MAX_LEN] = {"RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE"}; |
| 904 | if(LYNQ_CALL_OFF==getCallStatus()) |
| 905 | { |
| 906 | msg->base.request = RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE; |
| 907 | msg->base.token=token; |
| 908 | msg->base.e=LYNQ_E_CONFLICT;//logic conflict,if must |
| 909 | return token; |
| 910 | } |
| 911 | if(token =lynqNoneParame(requestStr)) |
| 912 | { |
| 913 | msg->base.request=RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE; |
| 914 | msg->base.token=token; |
| 915 | node = commonUpdateEstatus(token,500,err); |
| 916 | msg->base.e = err; |
| 917 | if(err !=RIL_E_SUCCESS) |
| 918 | { |
| 919 | LYDBGLOG("[%s] error code is %d!",__FUNCTION__,err); |
| 920 | lynqDeQueue(token); |
| 921 | return token; |
| 922 | } |
| 923 | updateCallLists(NULL,msg,node,200); |
| 924 | lynqDeQueue(token); |
| 925 | } |
| 926 | return token; |
| 927 | } |
| 928 | //AT< +CEER. |
| 929 | int lynq_get_last_call_fail_cause(lynqLastCallFailCause *msg) |
| 930 | { |
| 931 | int32_t token; |
| 932 | int time=500; |
| 933 | RIL_Errno err = -1; |
| 934 | int num=0; |
| 935 | int res=0; |
| 936 | lynqQueue * node = NULL; |
| 937 | lynqQueue * temp = NULL; |
| 938 | char requestStr[MAX_LEN] = {"RIL_REQUEST_LAST_CALL_FAIL_CAUSE"}; |
| 939 | if(token = lynqNoneParame(requestStr)) |
| 940 | { |
| 941 | msg->base.token = token; |
| 942 | msg->base.request = RIL_REQUEST_LAST_CALL_FAIL_CAUSE; |
| 943 | node = commonUpdateEstatus(token,time,err); |
| 944 | msg->base.e=err; |
| 945 | if(err !=RIL_E_SUCCESS) |
| 946 | { |
| 947 | LYDBGLOG("[%s] error code is %d!",__FUNCTION__,err); |
| 948 | lynqDeQueue(token); |
| 949 | return token; |
| 950 | } |
| 951 | if(node) |
| 952 | { |
| 953 | node->parcel.setDataPosition(0); |
| 954 | if (node->parcel.dataAvail() > 0) |
| 955 | { |
| 956 | node->parcel.readInt32(&num); |
| 957 | node->parcel.readInt32(&res); |
| 958 | msg->cause_code = (RIL_LastCallFailCause)res; |
| 959 | char * vendor_cause = strdupReadString(node->parcel); |
| 960 | memcpy(msg->vendor_cause,vendor_cause,strlen(vendor_cause)+1); |
| 961 | msg->base.e = node->t_Errno; |
| 962 | lynqDeQueue(token); |
| 963 | return token; |
| 964 | } |
| 965 | } |
| 966 | } |
| 967 | msg->cause_code = -1; |
| 968 | msg->base.e=-1; |
| 969 | lynqDeQueue(token); |
| 970 | } |
| 971 | /* |
| 972 | void lynq_incoming_call_cb(RIL_SOCKET_ID soc_id,int index, char * addr, RIL_CallState state, int toa) |
| 973 | { |
| 974 | printf("[SIM%d]index is %d,addr is %s,state is %d,toa is %d\n",soc_id,index,addr,state,toa); |
| 975 | } |
| 976 | */ |