rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* Copyright Statement: |
| 2 | * |
| 3 | * This software/firmware and related documentation ("MediaTek Software") are |
| 4 | * protected under relevant copyright laws. The information contained herein |
| 5 | * is confidential and proprietary to MediaTek Inc. and/or its licensors. |
| 6 | * Without the prior written permission of MediaTek inc. and/or its licensors, |
| 7 | * any reproduction, modification, use or disclosure of MediaTek Software, |
| 8 | * and information contained herein, in whole or in part, shall be strictly prohibited. |
| 9 | */ |
| 10 | /* MediaTek Inc. (C) 2010. All rights reserved. |
| 11 | * |
| 12 | * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 13 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 14 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON |
| 15 | * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 18 | * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 19 | * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 20 | * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH |
| 21 | * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES |
| 22 | * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES |
| 23 | * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK |
| 24 | * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR |
| 25 | * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND |
| 26 | * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 27 | * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 28 | * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO |
| 29 | * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 30 | * |
| 31 | * The following software/firmware and/or related documentation ("MediaTek Software") |
| 32 | * have been modified by MediaTek Inc. All revisions are subject to any receiver's |
| 33 | * applicable license agreements with MediaTek Inc. |
| 34 | */ |
| 35 | #include "stateManager/stateManager.h" |
| 36 | |
| 37 | #include <string> |
| 38 | #include <string.h> |
| 39 | #include <alloca.h> |
| 40 | #include <stdlib.h> |
| 41 | #include <vector> |
| 42 | #include <arpa/inet.h> |
| 43 | #include <string.h> |
| 44 | |
| 45 | #include "../util/AtLine.h" |
| 46 | #include "powerManager.h" |
| 47 | #include "util/utils.h" |
| 48 | #include <cutils/jstring.h> |
| 49 | #include <liblog/lynq_deflog.h> |
| 50 | #undef LOG_TAG |
| 51 | #define LOG_TAG "DEMO_MANAGER" |
| 52 | |
| 53 | lynqCallStatus s_callStatus = LYNQ_CALL_OFF; |
| 54 | |
| 55 | //static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER; |
| 56 | //RIL_REQUEST_DEVICE_IDENTITY |
| 57 | int getDeviceIdentity(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 58 | { |
| 59 | android::Parcel p; |
| 60 | pRI->pCI->dispatchFunction(p, pRI); |
| 61 | return 0; |
| 62 | } |
| 63 | // RIL_REQUEST_GET_IMEI |
| 64 | int getIMEI(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 65 | { |
| 66 | android::Parcel p; |
| 67 | pRI->pCI->dispatchFunction(p, pRI); |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | //RIL_REQUEST_GET_IMEISV |
| 72 | int getIMEISV(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 73 | { |
| 74 | android::Parcel p; |
| 75 | pRI->pCI->dispatchFunction(p, pRI); |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | //RIL_REQUEST_BASEBAND_VERSION |
| 80 | int getBasebandVersion(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 81 | { |
| 82 | android::Parcel p; |
| 83 | pRI->pCI->dispatchFunction(p, pRI); |
| 84 | return 0; |
| 85 | } |
| 86 | |
| 87 | //RIL_REQUEST_RESET_RADIO |
| 88 | int resetRadio(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 89 | { |
| 90 | android::Parcel p; |
| 91 | pRI->pCI->dispatchFunction(p, pRI); |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | //RIL_REQUEST_SCREEN_STATE |
| 96 | int getScreenState(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 97 | { |
| 98 | android::Parcel p; |
| 99 | size_t pos = p.dataPosition(); |
| 100 | |
| 101 | p.writeInt32(1); |
| 102 | p.writeInt32(atoi(argv[1])); |
| 103 | |
| 104 | p.setDataPosition(pos); |
| 105 | pRI->pCI->dispatchFunction(p, pRI); |
| 106 | return 0; |
| 107 | } |
| 108 | |
| 109 | //RIL_REQUEST_SET_TRM |
| 110 | int setTRM(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 111 | { |
| 112 | // android::Parcel p; |
| 113 | |
| 114 | // pRI->pCI->dispatchFunction(p, pRI); |
| 115 | free(pRI); |
| 116 | return 0; |
| 117 | } |
| 118 | //RIL_REQUEST_SET_IMS_ENABLE |
| 119 | int setIMSEnable(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 120 | { |
| 121 | android::Parcel p; |
| 122 | size_t pos = p.dataPosition(); |
| 123 | |
| 124 | p.writeInt32(1); |
| 125 | p.writeInt32(atoi(argv[1])); |
| 126 | p.setDataPosition(pos); |
| 127 | pRI->pCI->dispatchFunction(p, pRI); |
| 128 | return 0; |
| 129 | } |
| 130 | //RIL_REQUEST_OEM_HOOK_RAW |
| 131 | int sendATCMD(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 132 | { |
| 133 | android::Parcel p; |
| 134 | char *cmd = (char *)argv[1]; |
| 135 | size_t pos = p.dataPosition(); |
| 136 | if (cmd == NULL){ |
| 137 | RLOGD("sendATCMD:cmd is null\n"); |
| 138 | free(pRI); |
| 139 | return -1; |
| 140 | } |
| 141 | int len = strlen(cmd); |
| 142 | p.writeInt32(len); |
| 143 | p.write((const void*)cmd,len); |
| 144 | RLOGD("sendATCMD: %s %d",cmd,strlen(cmd)); |
| 145 | |
| 146 | p.setDataPosition(pos); |
| 147 | pRI->pCI->dispatchFunction(p, pRI); |
| 148 | return 0; |
| 149 | } |
| 150 | #ifdef KEEP_ALIVE |
| 151 | //RIL_REQUEST_START_KEEPALIVE_PRO |
| 152 | void tranferToNetByteOrder(int type, char* addr, std::vector<uint8_t> & dest) { |
| 153 | RLOGD("type is %d, addr: %s", type ,addr); |
| 154 | int ret; |
| 155 | int len = 0; |
| 156 | int domain; |
| 157 | if(type == static_cast<int>(RIL_PacketType::IPV4_TCP) || type == static_cast<int>(RIL_PacketType::IPV4_UDP)) { |
| 158 | len = sizeof(struct in_addr); |
| 159 | domain = AF_INET; |
| 160 | } else if(type == static_cast<int>(RIL_PacketType::IPV6_TCP) || type == static_cast<int>(RIL_PacketType::IPV6_UDP)) { |
| 161 | int len = sizeof(struct in6_addr); |
| 162 | domain = AF_INET6; |
| 163 | } |
| 164 | if (len > 0) { |
| 165 | unsigned char buf[len]; |
| 166 | ret = inet_pton(domain, addr, &buf); |
| 167 | if (ret <= 0) { |
| 168 | if (ret == 0) |
| 169 | RLOGE("Not in presentation format"); |
| 170 | else |
| 171 | RLOGE("inet_pton"); |
| 172 | return; |
| 173 | } |
| 174 | for (int i = 0 ; i < len; i++ ) { |
| 175 | dest.push_back(buf[i]); |
| 176 | RLOGD("tranferToNetByteOrder[%d]: %d", i,buf[i]); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | } |
| 181 | |
| 182 | int startKeepAlivePro(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 183 | if (argc != 10){ |
| 184 | RLOGD("startKeepAlivePro parameters number isn't enough"); |
| 185 | free(pRI); |
| 186 | return -1; |
| 187 | } |
| 188 | RLOGD("startKeepAlivePro"); |
| 189 | std::vector<uint8_t> sourceAddress; |
| 190 | std::vector<uint8_t> destinationAddress; |
| 191 | int type = atoi(argv[1]); |
| 192 | tranferToNetByteOrder(type, argv[2], sourceAddress); |
| 193 | int sourcePort = atoi(argv[3]); |
| 194 | tranferToNetByteOrder(type, argv[4], destinationAddress); |
| 195 | int destinationPort = atoi(argv[5]); |
| 196 | int netif_id = atoi(argv[6]); |
| 197 | int keepIdleTime = atoi(argv[7]); |
| 198 | int keepIntervalTime = atoi(argv[8]); |
| 199 | int retryCount = atoi(argv[9]); |
| 200 | |
| 201 | android::Parcel p; |
| 202 | size_t pos = p.dataPosition(); |
| 203 | |
| 204 | p.writeInt32(type); |
| 205 | p.writeByteVector(sourceAddress); |
| 206 | p.writeInt32(sourcePort); |
| 207 | p.writeByteVector(destinationAddress); |
| 208 | p.writeInt32(destinationPort); |
| 209 | p.writeInt32(netif_id); |
| 210 | p.writeInt32(keepIdleTime); |
| 211 | p.writeInt32(keepIntervalTime); |
| 212 | p.writeInt32(retryCount); |
| 213 | |
| 214 | p.setDataPosition(pos); |
| 215 | pRI->pCI->dispatchFunction(p, pRI); |
| 216 | return 0; |
| 217 | } |
| 218 | |
| 219 | //RIL_REQUEST_STOP_KEEPALIVE_PRO |
| 220 | int stopKeepAlivePro(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) { |
| 221 | if (argc != 2){ |
| 222 | RLOGD("stopKeepAlivePro parameters number isn't enough"); |
| 223 | free(pRI); |
| 224 | return -1; |
| 225 | } |
| 226 | RLOGD("stopKeepAlivePro"); |
| 227 | android::Parcel p; |
| 228 | uint32_t id = atoi(argv[1]); |
| 229 | RLOGD("stopKeepAlivePro sesssion id:%d", id); |
| 230 | size_t pos = p.dataPosition(); |
| 231 | p.writeInt32(1); |
| 232 | p.writeInt32(id); |
| 233 | |
| 234 | p.setDataPosition(pos); |
| 235 | pRI->pCI->dispatchFunction(p, pRI); |
| 236 | return 0; |
| 237 | } |
| 238 | |
| 239 | void composeMsg(int request,const void* data, size_t datalen) { |
| 240 | int* p_int = (int*) (data); |
| 241 | int numInts = datalen / sizeof(int); |
| 242 | if (numInts < 2) { |
| 243 | RLOGD("%s error.", android::requestToString(request)); |
| 244 | std::string fail(android::requestToString(request)); |
| 245 | fail.append(",fail"); |
| 246 | sendKeepAlive(fail.c_str()); |
| 247 | return; |
| 248 | } |
| 249 | std::string msg(android::requestToString(request)); |
| 250 | if(request == RIL_REQUEST_START_KEEPALIVE_PRO) { |
| 251 | msg.append(",ok"); |
| 252 | } |
| 253 | int sessionHandle = p_int[0]; |
| 254 | int code = p_int[1]; |
| 255 | msg.append(","); |
| 256 | msg.append(std::to_string(sessionHandle)); |
| 257 | msg.append(","); |
| 258 | msg.append(std::to_string(code)); |
| 259 | RLOGD("%s response(%s)", android::requestToString(request),msg.c_str()); |
| 260 | sendKeepAlive(msg.c_str()); |
| 261 | } |
| 262 | |
| 263 | void handleKeepAliveResponse(int request, const void* data, size_t datalen, RIL_SOCKET_ID soc_id, bool is_error) { |
| 264 | RLOGD("handleKeepAliveResponse(%s) is_error: %d", android::requestToString(request),is_error); |
| 265 | if(is_error) { |
| 266 | if(request == RIL_REQUEST_START_KEEPALIVE_PRO) { |
| 267 | sendKeepAlive("RIL_REQUEST_START_KEEPALIVE_PRO,fail"); |
| 268 | } else if(request == RIL_REQUEST_STOP_KEEPALIVE_PRO) { |
| 269 | sendKeepAlive("RIL_REQUEST_STOP_KEEPALIVE_PRO,fail"); |
| 270 | } |
| 271 | } else { |
| 272 | if(request == RIL_REQUEST_START_KEEPALIVE_PRO) { |
| 273 | composeMsg(request, data, datalen); |
| 274 | } else if(request == RIL_REQUEST_STOP_KEEPALIVE_PRO) { |
| 275 | sendKeepAlive("RIL_REQUEST_STOP_KEEPALIVE_PRO,ok"); |
| 276 | } else if (request == RIL_UNSOL_KEEPALIVE_STATUS_PRO) { |
| 277 | composeMsg(request, data, datalen); |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | #endif /*KEEP_ALIVE*/ |
| 282 | |
| 283 | void parseAtCmd(const char* line) { |
| 284 | if (strstr(line, "+ETHERMAL") != NULL) { |
| 285 | RLOGD("parse at command: ETHERMAL"); |
| 286 | AtLine* atLine = new AtLine(line, NULL); |
| 287 | int err; |
| 288 | atLine->atTokStart(&err); |
| 289 | if (err < 0) { |
| 290 | delete atLine; |
| 291 | RLOGW("this is not a valid response string"); |
| 292 | return; |
| 293 | } |
| 294 | int rat = atLine->atTokNextint(&err); |
| 295 | if (err < 0) { |
| 296 | delete atLine; |
| 297 | RLOGW("parse rat fail"); |
| 298 | return; |
| 299 | } |
| 300 | int temperature = atLine->atTokNextint(&err); |
| 301 | if (err < 0) { |
| 302 | delete atLine; |
| 303 | RLOGW("parse temperature fail"); |
| 304 | return; |
| 305 | } |
| 306 | int tx_power = atLine->atTokNextint(&err); |
| 307 | if (err < 0) { |
| 308 | delete atLine; |
| 309 | RLOGW("parse tx_power fail"); |
| 310 | return; |
| 311 | } |
| 312 | RLOGD("[tx_power]rat: %d, temperature: %d, tx_power: %d", rat, temperature, tx_power); |
| 313 | printf("[tx_power]rat: %d, temperature: %d, tx_power: %d\n", rat, temperature, tx_power); |
| 314 | delete atLine; |
| 315 | } else if (strstr(line, "+ECAL") != NULL) { |
| 316 | RLOGD("parse at command: ECAL"); |
| 317 | AtLine* atLine = new AtLine(line, NULL); |
| 318 | int err; |
| 319 | atLine->atTokStart(&err); |
| 320 | if (err < 0) { |
| 321 | delete atLine; |
| 322 | RLOGW("this is not a valid response string"); |
| 323 | return; |
| 324 | } |
| 325 | int cal = atLine->atTokNextint(&err); |
| 326 | if (err < 0) { |
| 327 | delete atLine; |
| 328 | RLOGW("parse rat fail"); |
| 329 | return; |
| 330 | } |
| 331 | RLOGD("calibration data is %s", cal == 1 ? "download" : "not download"); |
| 332 | if (cal == 0) { |
| 333 | printf( |
| 334 | "************************************************\n*** NOTICE: calibration data is not download ***\n************************************************\n"); |
| 335 | } |
| 336 | delete atLine; |
| 337 | } |
| 338 | } |
| 339 | //RIL_REQUEST_SET_IMSCFG |
| 340 | int setIMSCfg(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) |
| 341 | { |
| 342 | android::Parcel p; |
| 343 | size_t pos = p.dataPosition(); |
| 344 | |
| 345 | p.writeInt32(6); |
| 346 | p.writeInt32(atoi(argv[1])); |
| 347 | p.writeInt32(atoi(argv[2])); |
| 348 | p.writeInt32(atoi(argv[3])); |
| 349 | p.writeInt32(atoi(argv[4])); |
| 350 | p.writeInt32(atoi(argv[5])); |
| 351 | p.writeInt32(atoi(argv[6])); |
| 352 | p.setDataPosition(pos); |
| 353 | pRI->pCI->dispatchFunction(p, pRI); |
| 354 | return 0; |
| 355 | } |
| 356 | /*****mobiletek-add****/ |
| 357 | lynq_call_list **pCallList=NULL; |
| 358 | //lynq_call_list *CallList=NULL; |
| 359 | //callInfoLink * callInfoLinkhead = (callInfoLink *)malloc(sizeof(callInfoLink)); |
| 360 | //memset(callInfoLinkhead,0,sizeof(callInfoLink)); |
| 361 | int calllistNum=0; |
| 362 | int flag=0; |
| 363 | callInfoLink * create_callInfoLink() |
| 364 | { |
| 365 | callInfoLink * head = (callInfoLink *)malloc(sizeof(callInfoLink)); |
| 366 | if(head==NULL) |
| 367 | { |
| 368 | return NULL; |
| 369 | } |
| 370 | memset(head,0,sizeof(callInfoLink)); |
| 371 | head->next=NULL; |
| 372 | head->calllist_tok=NULL; |
| 373 | //head->parcel=NULL; |
| 374 | return head; |
| 375 | } |
| 376 | lynqQueue * createLynqQueue() |
| 377 | { |
| 378 | lynqQueue *head = (lynqQueue *)malloc(sizeof(lynqQueue)); |
| 379 | if(head==NULL) |
| 380 | { |
| 381 | return NULL; |
| 382 | } |
| 383 | memset(head,0,sizeof(lynqQueue)); |
| 384 | head->next=NULL; |
| 385 | return head; |
| 386 | } |
| 387 | lynqQueue * searchRequestinQueue(int32_t request,lynqQueue *head) |
| 388 | { |
| 389 | lynqQueue *p; |
| 390 | p=head; |
| 391 | if(p!=NULL) |
| 392 | { |
| 393 | do |
| 394 | { |
| 395 | if(p->request == request) |
| 396 | { |
| 397 | return p; |
| 398 | } |
| 399 | |
| 400 | p = p->next; |
| 401 | } while (p != NULL); |
| 402 | } |
| 403 | RLOGD("search request %d failure from lynq queue",request); |
| 404 | return NULL; |
| 405 | } |
| 406 | lynqQueue * searchTokeninQueue(int32_t token,lynqQueue *head) |
| 407 | { |
| 408 | lynqQueue *p; |
| 409 | p=head; |
| 410 | if(p!=NULL) |
| 411 | { |
| 412 | do |
| 413 | { |
| 414 | if(p->token == token) |
| 415 | { |
| 416 | return p; |
| 417 | } |
| 418 | p = p->next; |
| 419 | } while (p != NULL); |
| 420 | } |
| 421 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 422 | return NULL; |
| 423 | } |
| 424 | int lynqApiInit() |
| 425 | { |
| 426 | LynqQueueHead=createLynqQueue(); |
| 427 | LYDBGLOG("[%s] init head is %p\n",__FUNCTION__,LynqQueueHead); |
| 428 | if(LynqQueueHead==NULL) |
| 429 | { |
| 430 | LYERRLOG("[%s] init call lynq queue head fail,maybe malloc fail!",__FUNCTION__); |
| 431 | return -1; |
| 432 | } |
| 433 | return 0; |
| 434 | } |
| 435 | int getCallStatus(void) |
| 436 | { |
| 437 | return s_callStatus; |
| 438 | } |
| 439 | int setCallStatus(lynqCallStatus callStatus) |
| 440 | { |
| 441 | s_callStatus = callStatus; |
| 442 | return 0; |
| 443 | } |
| 444 | |
| 445 | simInfoLink *createSimInfoLink() |
| 446 | { |
| 447 | simInfoLink * head = (simInfoLink *)malloc(sizeof(simInfoLink)); |
| 448 | if(head==NULL) |
| 449 | { |
| 450 | RLOGD("create sim info queue fail"); |
| 451 | return NULL; |
| 452 | } |
| 453 | memset(head,0,sizeof(simInfoLink)); |
| 454 | head->next=NULL; |
| 455 | return head; |
| 456 | } |
| 457 | int callListToParcel(void *response,size_t responselen,Parcel &p); |
| 458 | static int updateCallStatus(void *response,size_t responselen); |
| 459 | int imsiToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 460 | int simInfoToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 461 | int lastCallFailCauseToParce(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 462 | int dataCalllistToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 463 | int currentOperatorInfoToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 464 | int queryNetSelectModeToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 465 | static int stringsToParecl(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 466 | static int stringToParecl(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 467 | static int intToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 468 | static int updateErrnoToQueue(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 469 | int cellinfoToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 470 | int neighboringCellToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 471 | int solicitedSignalStrengthToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 472 | int smsResponseToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 473 | int updateE_status(int32_t token,RIL_Errno respe) |
| 474 | { |
| 475 | lynqQueue *node =NULL; |
| 476 | node = searchTokeninQueue(token,LynqQueueHead); |
| 477 | if(node) |
| 478 | { |
| 479 | node->t_Errno = respe; |
| 480 | node->E_status = 1; |
| 481 | } |
| 482 | return 0; |
| 483 | } |
| 484 | void LYNQ_DispatchResponse(int request,int32_t token,RIL_Errno respe,lynq_call_list**nodeCallList,void *response,size_t respLen) |
| 485 | { |
| 486 | |
| 487 | switch (request) { |
| 488 | case RIL_REQUEST_DIAL: |
| 489 | case RIL_REQUEST_ANSWER: |
| 490 | case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: |
| 491 | case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: |
| 492 | case RIL_REQUEST_SEPARATE_CONNECTION: |
| 493 | case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: |
| 494 | case RIL_REQUEST_CONFERENCE: |
| 495 | case RIL_REQUEST_HANGUP: |
| 496 | case RIL_REQUEST_UDUB: |
| 497 | case RIL_REQUEST_DTMF: |
| 498 | { |
| 499 | /* |
| 500 | lynqQueue *node =NULL; |
| 501 | node = searchTokeninQueue(token,LynqQueueHead); |
| 502 | if(node) |
| 503 | { |
| 504 | node->t_Errno = respe; |
| 505 | node->E_status = 1; |
| 506 | } |
| 507 | */ |
| 508 | updateE_status(token,respe); |
| 509 | break; |
| 510 | } |
| 511 | case RIL_REQUEST_GET_IMSI: |
| 512 | { |
| 513 | updateE_status(token,respe); |
| 514 | imsiToParcel(request,token,response,respLen,respe); |
| 515 | //addImsiInfo(request,respe,token,simInfoLinkHead,response,respLen); |
| 516 | break; |
| 517 | } |
| 518 | case RIL_REQUEST_GET_SIM_STATUS: |
| 519 | { |
| 520 | updateE_status(token,respe); |
| 521 | simInfoToParcel(request,token,response,respLen,respe); |
| 522 | break; |
| 523 | } |
| 524 | case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: |
| 525 | { |
| 526 | /* |
| 527 | lynqQueue *node =NULL; |
| 528 | node = searchTokeninQueue(token,LynqQueueHead); |
| 529 | if(node) |
| 530 | { |
| 531 | node->t_Errno = respe; |
| 532 | node->E_status = 1; |
| 533 | } |
| 534 | */ |
| 535 | updateE_status(token,respe); |
| 536 | lastCallFailCauseToParce(request,token,response,respLen,respe); |
| 537 | break; |
| 538 | } |
| 539 | case RIL_REQUEST_DATA_CALL_LIST: |
| 540 | { |
| 541 | dataCalllistToParcel(request,token,response,respLen,respe); |
| 542 | break; |
| 543 | } |
| 544 | case RIL_REQUEST_OPERATOR: |
| 545 | case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: |
| 546 | case RIL_REQUEST_DATA_REGISTRATION_STATE: |
| 547 | case RIL_REQUEST_VOICE_REGISTRATION_STATE: |
| 548 | { |
| 549 | //currentOperatorInfoToParcel(request,token,response,respLen,respe); |
| 550 | updateE_status(token,respe); |
| 551 | stringsToParecl(request,token,response,respLen,respe); |
| 552 | break; |
| 553 | } |
| 554 | case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: |
| 555 | case RIL_REQUEST_IMS_REGISTRATION_STATE: |
| 556 | case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: |
| 557 | case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: |
| 558 | case RIL_REQUEST_VOICE_RADIO_TECH: |
| 559 | case RIL_REQUEST_WRITE_SMS_TO_SIM: |
| 560 | { |
| 561 | intToParcel(request,token,response,respLen,respe); |
| 562 | break; |
| 563 | } |
| 564 | case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: |
| 565 | case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: |
| 566 | case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: |
| 567 | case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: |
| 568 | case RIL_REQUEST_SET_BAND_MODE: |
| 569 | case RIL_REQUEST_RADIO_POWER: |
| 570 | case RIL_REQUEST_MODEM_POWERON: |
| 571 | case RIL_REQUEST_MODEM_POWEROFF: |
| 572 | case RIL_REQUEST_DELETE_SMS_ON_SIM: |
| 573 | case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: |
| 574 | case RIL_REQUEST_SET_SMSC_ADDRESS: |
| 575 | { |
| 576 | updateErrnoToQueue(request,token,response,respLen,respe); |
| 577 | break; |
| 578 | } |
| 579 | case RIL_REQUEST_GET_CELL_INFO_LIST: |
| 580 | { |
| 581 | cellinfoToParcel(request,token,response,respLen,respe); |
| 582 | break; |
| 583 | } |
| 584 | case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: |
| 585 | { |
| 586 | neighboringCellToParcel(request,token,response,respLen,respe); |
| 587 | break; |
| 588 | } |
| 589 | case RIL_REQUEST_SIGNAL_STRENGTH: |
| 590 | { |
| 591 | solicitedSignalStrengthToParcel(request,token,response,respLen,respe); |
| 592 | break; |
| 593 | } |
| 594 | case RIL_REQUEST_SEND_SMS: |
| 595 | case RIL_REQUEST_IMS_SEND_SMS: |
| 596 | { |
| 597 | smsResponseToParcel(request,token,response,respLen,respe); |
| 598 | break; |
| 599 | } |
| 600 | case RIL_REQUEST_GET_SMSC_ADDRESS: |
| 601 | { |
| 602 | stringToParecl(request,token,response,respLen,respe); |
| 603 | break; |
| 604 | } |
| 605 | default: |
| 606 | break; |
| 607 | } |
| 608 | } |
| 609 | callInfoLink* addCallInfo(int32_t tok,int request,RIL_Errno respe,callInfoLink* head,lynq_call_list**nodeCallList) |
| 610 | { |
| 611 | if (head == NULL) |
| 612 | { |
| 613 | flag= 0; |
| 614 | RLOGD("callInfoLink is null,set flag to 0!"); |
| 615 | return NULL; |
| 616 | } |
| 617 | if (flag == 0) |
| 618 | { |
| 619 | head->token = tok; |
| 620 | head->Error_tok = respe; |
| 621 | head->request=request; |
| 622 | if(nodeCallList!=NULL) |
| 623 | { |
| 624 | head->calllist_tok=nodeCallList; |
| 625 | } |
| 626 | head->next = NULL; |
| 627 | flag=1; |
| 628 | } |
| 629 | else |
| 630 | { |
| 631 | if (head->token != tok) |
| 632 | { |
| 633 | callInfoLink* Node = (callInfoLink*)malloc(sizeof(callInfoLink)); |
| 634 | memset(Node,0,sizeof(callInfoLink)); |
| 635 | if (Node) |
| 636 | { |
| 637 | printf("new node p is %p\n", Node); |
| 638 | Node->token = tok; |
| 639 | Node->Error_tok = respe; |
| 640 | Node->request=request; |
| 641 | if(nodeCallList!=NULL) |
| 642 | { |
| 643 | Node->calllist_tok=nodeCallList; |
| 644 | } |
| 645 | Node->next = head; |
| 646 | head = Node; |
| 647 | } |
| 648 | else |
| 649 | { |
| 650 | RLOGD("malloc Node failed!\n"); |
| 651 | flag = 0; |
| 652 | return NULL; |
| 653 | } |
| 654 | } |
| 655 | else |
| 656 | { |
| 657 | //head->token = tok; |
| 658 | //head->Error_tok = respe; |
| 659 | head->calllist_tok=nodeCallList; |
| 660 | } |
| 661 | |
| 662 | } |
| 663 | return head; |
| 664 | } |
| 665 | void updateLinkCallInfo(callInfoLink * callInfoLinkhead,lynq_call_list**nodeCallList) |
| 666 | { |
| 667 | callInfoLink *p; |
| 668 | p=callInfoLinkhead; |
| 669 | if(p!=NULL) |
| 670 | { |
| 671 | do |
| 672 | { |
| 673 | p->calllist_tok=nodeCallList; |
| 674 | p = p->next; |
| 675 | } while (p != NULL); |
| 676 | } |
| 677 | } |
| 678 | static int dispatchEvent(lynqQueue *node,void * response, size_t responselen, Parcel & p) |
| 679 | { |
| 680 | //printf("request is %d\n",node->request); |
| 681 | switch(node->request) |
| 682 | { |
| 683 | case RIL_REQUEST_DIAL: |
| 684 | case RIL_REQUEST_ANSWER: |
| 685 | //case RIL_REQUEST_HANGUP: |
| 686 | //case RIL_REQUEST_UDUB: |
| 687 | case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: |
| 688 | case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: |
| 689 | case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: |
| 690 | case RIL_REQUEST_CONFERENCE: |
| 691 | //case RIL_REQUEST_SEPARATE_CONNECTION: |
| 692 | //case RIL_REQUEST_DTMF: |
| 693 | { |
| 694 | //printf("request is %d\n",node->request); |
| 695 | callListToParcel(response, responselen, p); |
| 696 | break; |
| 697 | } |
| 698 | /* |
| 699 | case RIL_REQUEST_HANGUP: |
| 700 | { |
| 701 | break; |
| 702 | } |
| 703 | */ |
| 704 | default: |
| 705 | //printf("other test\n"); |
| 706 | //updateCallStatus(response,responselen); |
| 707 | break; |
| 708 | } |
| 709 | return 0; |
| 710 | } |
| 711 | void updateAsyncData(RIL_Token t, RIL_Errno e,void * response, size_t responselen,lynqQueue* head) |
| 712 | { |
| 713 | lynqQueue *p; |
| 714 | p=head; |
| 715 | if(p!=NULL) |
| 716 | { |
| 717 | do |
| 718 | { |
| 719 | dispatchEvent(p, response,responselen, p->parcel); |
| 720 | p = p->next; |
| 721 | } while (p != NULL); |
| 722 | } |
| 723 | updateCallStatus(response,responselen); |
| 724 | return; |
| 725 | } |
| 726 | void printlist(callInfoLink * callInfoLinkhead) |
| 727 | { |
| 728 | callInfoLink* p; |
| 729 | p = callInfoLinkhead; |
| 730 | if (p != NULL) |
| 731 | { |
| 732 | do |
| 733 | { |
| 734 | LYDBGLOG("[%s] token=%x Error_tok=%d,request =%d",__FUNCTION__,p->token, p->Error_tok,p->request); |
| 735 | p = p->next; |
| 736 | } while (p != NULL); |
| 737 | } |
| 738 | return ; |
| 739 | } |
| 740 | void setCallList_old(int token,RIL_Call **pCallLists,size_t respLen,RIL_Errno error) |
| 741 | { |
| 742 | /* |
| 743 | if(pCallLists!=NULL) |
| 744 | { |
| 745 | printf("DEMO_MANAGER:resplen is %d\n",respLen); |
| 746 | for(int i=0;i<respLen;i++) |
| 747 | { |
| 748 | RIL_Call* p_cur = pCallLists[i]; |
| 749 | printf("state is %d\n",p_cur->state); |
| 750 | RLOGD("state is %d\n",p_cur->state); |
| 751 | printf("callid is %d\n",p_cur->index); |
| 752 | RLOGD("callid is %d\n",p_cur->index); |
| 753 | printf("toa is %d\n",p_cur->toa); |
| 754 | RLOGD("toa is %d\n",p_cur->toa); |
| 755 | printf("addr is %s\n",p_cur->number); |
| 756 | RLOGD("addr is %s\n",p_cur->number); |
| 757 | } |
| 758 | } |
| 759 | */ |
| 760 | if(calllistNum!=0) |
| 761 | { |
| 762 | printf("calllistNum!=0\n"); |
| 763 | RLOGD("calllistNum!=0\n"); |
| 764 | if(calllistNum!=respLen) |
| 765 | { |
| 766 | if (pCallList != NULL) |
| 767 | { |
| 768 | for (int index = 0; index < calllistNum; index++ ) |
| 769 | { |
| 770 | if (pCallList[index] != NULL) |
| 771 | { |
| 772 | free(pCallList[index]->addr); |
| 773 | pCallList[index]->addr=NULL; |
| 774 | free(pCallList[index]); |
| 775 | } |
| 776 | } |
| 777 | free(pCallList); |
| 778 | pCallList=NULL; |
| 779 | RLOGD("free pCalllist\n"); |
| 780 | } |
| 781 | if(respLen==0) |
| 782 | { |
| 783 | RLOGD("the call list is NULL,the pCalllist is NULL"); |
| 784 | return; |
| 785 | } |
| 786 | if(!(pCallList=(lynq_call_list **)malloc(sizeof(lynq_call_list *)*respLen))) |
| 787 | { |
| 788 | RLOGD("malloc pCallList failed"); |
| 789 | printf("malloc pCallList failed"); |
| 790 | return; |
| 791 | } |
| 792 | |
| 793 | for(int index=0;index<respLen;index++) |
| 794 | { |
| 795 | if((pCallList[index]=(lynq_call_list *)malloc(sizeof(lynq_call_list)))==NULL) |
| 796 | { |
| 797 | RLOGD("malloc CallList failed"); |
| 798 | printf("malloc CallList failed"); |
| 799 | for(int i=0;i<index;i++) |
| 800 | { |
| 801 | free(pCallList[i]->addr); |
| 802 | pCallList[i]->addr=NULL; |
| 803 | free(pCallList[i]); |
| 804 | } |
| 805 | free(pCallList); |
| 806 | pCallList=NULL; |
| 807 | return; |
| 808 | } |
| 809 | pCallList[index]->addr=(char *)malloc(sizeof(char)*(sizeof(pCallLists[index]->number)+1)); |
| 810 | memcpy(pCallList[index]->addr, pCallLists[index]->number, strlen(pCallLists[index]->number)+1); |
| 811 | pCallList[index]->token=token; |
| 812 | //pCallList[index]->addr=pCallLists[index]->number; |
| 813 | pCallList[index]->callid=pCallLists[index]->index; |
| 814 | pCallList[index]->callState=pCallLists[index]->state; |
| 815 | pCallList[index]->toa= pCallLists[index]->toa; |
| 816 | pCallList[index]->lynq_error=error; |
| 817 | pCallList[index]->selflen=respLen; |
| 818 | |
| 819 | } |
| 820 | calllistNum=respLen; |
| 821 | } |
| 822 | else |
| 823 | { |
| 824 | for(int index=0;index<respLen;index++) |
| 825 | { |
| 826 | pCallList[index]->addr=(char *)malloc(sizeof(char)*(sizeof(pCallLists[index]->number)+1)); |
| 827 | memcpy(pCallList[index]->addr, pCallLists[index]->number, strlen(pCallLists[index]->number)+1); |
| 828 | pCallList[index]->token=token; |
| 829 | //pCallList[index]->addr=pCallLists[index]->number; |
| 830 | pCallList[index]->callid=pCallLists[index]->index; |
| 831 | pCallList[index]->callState=pCallLists[index]->state; |
| 832 | pCallList[index]->toa= pCallLists[index]->toa; |
| 833 | pCallList[index]->lynq_error=error; |
| 834 | pCallList[index]->selflen=respLen; |
| 835 | } |
| 836 | } |
| 837 | printf("retrun more than once\n"); |
| 838 | ///pthread_mutex_unlock(&s_startupMutex); |
| 839 | } |
| 840 | else |
| 841 | { |
| 842 | RLOGD("calllistNum==0\n"); |
| 843 | if((pCallList=(lynq_call_list **)malloc(sizeof(lynq_call_list *)*respLen))==NULL) |
| 844 | { |
| 845 | RLOGD("malloc pCallList failed"); |
| 846 | printf("malloc pCallList failed"); |
| 847 | return; |
| 848 | } |
| 849 | printf("pCalllist %p\n",pCallList); |
| 850 | for(int index=0;index<respLen;index++) |
| 851 | { |
| 852 | if((pCallList[index]=(lynq_call_list *)malloc(sizeof(lynq_call_list)))==NULL) |
| 853 | { |
| 854 | RLOGD("malloc CallList failed"); |
| 855 | printf("malloc CallList failed"); |
| 856 | for(int i=0;i<index;i++) |
| 857 | { |
| 858 | free(pCallList[i]->addr); |
| 859 | pCallList[i]->addr=NULL; |
| 860 | free(pCallList[i]); |
| 861 | } |
| 862 | free(pCallList); |
| 863 | pCallList=NULL; |
| 864 | return; |
| 865 | } |
| 866 | pCallList[index]->addr=(char *)malloc(sizeof(char)*(sizeof(pCallLists[index]->number)+1)); |
| 867 | memcpy(pCallList[index]->addr, pCallLists[index]->number, strlen(pCallLists[index]->number)+1); |
| 868 | pCallList[index]->token=token; |
| 869 | //pCallList[index]->addr=pCallLists[index]->number; |
| 870 | pCallList[index]->callid=pCallLists[index]->index; |
| 871 | pCallList[index]->callState=pCallLists[index]->state; |
| 872 | pCallList[index]->toa= pCallLists[index]->toa; |
| 873 | pCallList[index]->lynq_error=error; |
| 874 | pCallList[index]->selflen=respLen; |
| 875 | |
| 876 | } |
| 877 | calllistNum=respLen; |
| 878 | printf("retrun first\n"); |
| 879 | //pthread_mutex_unlock(&s_startupMutex); |
| 880 | } |
| 881 | } |
| 882 | static void StringWriteToParcel(Parcel &p, const char *s) { |
| 883 | char16_t *s16; |
| 884 | size_t s16_len; |
| 885 | s16 = strdup8to16(s, &s16_len); |
| 886 | p.writeString16(s16, s16_len); |
| 887 | free(s16); |
| 888 | } |
| 889 | char * lynqStrdupReadString(Parcel &p) { |
| 890 | size_t stringlen; |
| 891 | const char16_t *s16; |
| 892 | |
| 893 | s16 = p.readString16Inplace(&stringlen); |
| 894 | return strndup16to8(s16, stringlen); |
| 895 | } |
| 896 | void setCallList(int token,RIL_Call **pCallLists,size_t respLen,RIL_Errno error) |
| 897 | { |
| 898 | if(respLen==0) |
| 899 | { |
| 900 | LYDBGLOG("[%s] the call list is NULL",__FUNCTION__); |
| 901 | return; |
| 902 | } |
| 903 | if((pCallList=(lynq_call_list **)malloc(sizeof(lynq_call_list *)*respLen))==NULL) |
| 904 | { |
| 905 | LYDBGLOG("[%s] malloc pCallList failed",__FUNCTION__); |
| 906 | return; |
| 907 | } |
| 908 | //printf("pCalllist %p\n",pCallList); |
| 909 | for(int index=0;index<respLen;index++) |
| 910 | { |
| 911 | if((pCallList[index]=(lynq_call_list *)malloc(sizeof(lynq_call_list)))==NULL) |
| 912 | { |
| 913 | LYDBGLOG("[%s]malloc CallList failed",__FUNCTION__); |
| 914 | for(int i=0;i<index;i++) |
| 915 | { |
| 916 | free(pCallList[i]->addr); |
| 917 | pCallList[i]->addr=NULL; |
| 918 | free(pCallList[i]); |
| 919 | } |
| 920 | free(pCallList); |
| 921 | pCallList=NULL; |
| 922 | return; |
| 923 | } |
| 924 | pCallList[index]->addr=(char *)malloc(sizeof(char)*(sizeof(pCallLists[index]->number)+1)); |
| 925 | memcpy(pCallList[index]->addr, pCallLists[index]->number, strlen(pCallLists[index]->number)+1); |
| 926 | pCallList[index]->token=token; |
| 927 | pCallList[index]->callid=pCallLists[index]->index; |
| 928 | pCallList[index]->callState=pCallLists[index]->state; |
| 929 | pCallList[index]->toa= pCallLists[index]->toa; |
| 930 | pCallList[index]->lynq_error=error; |
| 931 | pCallList[index]->isMT = pCallLists[index]->isMT; |
| 932 | pCallList[index]->selflen=respLen; |
| 933 | } |
| 934 | } |
| 935 | void freeCallList(int respLen) |
| 936 | { |
| 937 | if(respLen!=0) |
| 938 | { |
| 939 | LYDBGLOG("call on going"); |
| 940 | return; |
| 941 | } |
| 942 | if (pCallList != NULL) |
| 943 | { |
| 944 | if (pCallList[0]==NULL) |
| 945 | { |
| 946 | LYDBGLOG("pCalllist pCallList[0]"); |
| 947 | return; |
| 948 | } |
| 949 | int length=pCallList[0]->selflen; |
| 950 | for (int index = 0; index < length; index++ ) |
| 951 | { |
| 952 | if (pCallList[index] != NULL) |
| 953 | { |
| 954 | free(pCallList[index]->addr); |
| 955 | pCallList[index]->addr=NULL; |
| 956 | free(pCallList[index]); |
| 957 | } |
| 958 | } |
| 959 | free(pCallList); |
| 960 | pCallList=NULL; |
| 961 | LYDBGLOG("free pCalllist"); |
| 962 | } |
| 963 | return ; |
| 964 | |
| 965 | } |
| 966 | void updateSimStatus(void *response,size_t respLen,simInfoLink *msg) |
| 967 | { |
| 968 | if(response!=NULL) |
| 969 | { |
| 970 | //printf("RIL_CardStatus_v6 length is %d\n",sizeof (RIL_CardStatus_v6)); |
| 971 | if (respLen == sizeof (RIL_CardStatus_v6)) |
| 972 | { |
| 973 | RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response); |
| 974 | msg->card_status=p_cur->card_state; |
| 975 | for(int i=0;i<p_cur->num_applications;i++) |
| 976 | { |
| 977 | msg->card_type=p_cur->applications[i].app_type; |
| 978 | msg->pin_state=p_cur->applications[i].pin1; |
| 979 | } |
| 980 | } |
| 981 | } |
| 982 | return; |
| 983 | } |
| 984 | void addSimInfo(int request,RIL_Errno respe,int32_t token,simInfoLink *head,void *response,size_t respLen) |
| 985 | { |
| 986 | if(head==NULL) |
| 987 | { |
| 988 | LYDBGLOG("[%s] the head is NULL!\n",__FUNCTION__); |
| 989 | return; |
| 990 | } |
| 991 | LYDBGLOG("addSimInfo respLen is %d\n",respLen); |
| 992 | if(response==NULL) |
| 993 | { |
| 994 | LYDBGLOG("the get sim status response is NULL!\n"); |
| 995 | return; |
| 996 | } |
| 997 | simInfoLink * temp=head; |
| 998 | do |
| 999 | { |
| 1000 | if(temp->token==token) |
| 1001 | { |
| 1002 | temp->Error_tok=respe; |
| 1003 | updateSimStatus(response,respLen,temp); |
| 1004 | temp->simInfoLen=respLen/sizeof(RIL_CardStatus_v6); |
| 1005 | break; |
| 1006 | } |
| 1007 | temp=temp->next; |
| 1008 | }while(temp!=NULL); |
| 1009 | return; |
| 1010 | } |
| 1011 | simInfoLink * inSimQueue(int request,int32_t token,simInfoLink *head) |
| 1012 | { |
| 1013 | simInfoLink* Node = (simInfoLink*)malloc(sizeof(simInfoLink)); |
| 1014 | memset(Node,0,sizeof(simInfoLink)); |
| 1015 | if (Node) |
| 1016 | { |
| 1017 | Node->token = token; |
| 1018 | Node->request=request; |
| 1019 | Node->next = head; |
| 1020 | head = Node; |
| 1021 | } |
| 1022 | else |
| 1023 | { |
| 1024 | LYDBGLOG("[%s] malloc Node failed!\n",__FUNCTION__); |
| 1025 | return NULL; |
| 1026 | } |
| 1027 | return head; |
| 1028 | |
| 1029 | } |
| 1030 | static lynqQueue * lynqInQueue(int request,int32_t token,lynqQueue *head) |
| 1031 | { |
| 1032 | lynqQueue* Node = (lynqQueue*)malloc(sizeof(lynqQueue)); |
| 1033 | memset(Node,0,sizeof(lynqQueue)); |
| 1034 | if (Node) |
| 1035 | { |
| 1036 | Node->token = token; |
| 1037 | Node->request=request; |
| 1038 | Node->next = head; |
| 1039 | head = Node; |
| 1040 | LYDBGLOG("[%s] node->token is %x,request is %d\n",__FUNCTION__,Node->token,Node->request); |
| 1041 | } |
| 1042 | else |
| 1043 | { |
| 1044 | LYDBGLOG("[%s] malloc Node failed!\n",__FUNCTION__); |
| 1045 | return head; |
| 1046 | } |
| 1047 | return head; |
| 1048 | |
| 1049 | } |
| 1050 | simInfoLink * deSimQueue(simInfoLink *head,int32_t token) |
| 1051 | { |
| 1052 | simInfoLink *p,*temp; |
| 1053 | p = head; |
| 1054 | if((head ==NULL)||(head->next==NULL)) |
| 1055 | { |
| 1056 | LYDBGLOG("deSimQueue head is NULL\n"); |
| 1057 | return head; |
| 1058 | } |
| 1059 | //delete head note |
| 1060 | if(p->token == token) |
| 1061 | { |
| 1062 | temp=head->next; |
| 1063 | free(head); |
| 1064 | head =NULL; |
| 1065 | head = temp; |
| 1066 | return head; |
| 1067 | } |
| 1068 | //delete intermediate node |
| 1069 | do |
| 1070 | { |
| 1071 | temp = p; |
| 1072 | p=p->next; |
| 1073 | if(p->token==token) |
| 1074 | { |
| 1075 | temp->next=p->next; |
| 1076 | free(p); |
| 1077 | p=NULL; |
| 1078 | return head; |
| 1079 | } |
| 1080 | }while(p->next->next!=NULL); |
| 1081 | return head; |
| 1082 | } |
| 1083 | void lynqDeQueue(int32_t token) |
| 1084 | { |
| 1085 | lynqQueue *p,*temp; |
| 1086 | p = LynqQueueHead; |
| 1087 | if((p ==NULL)||(p->next==NULL)) |
| 1088 | { |
| 1089 | LYDBGLOG("[%s] lynqDeQueue head is NULL\n",__FUNCTION__); |
| 1090 | return 0; |
| 1091 | //return head; |
| 1092 | } |
| 1093 | //delete head note |
| 1094 | if(p->token == token) |
| 1095 | { |
| 1096 | temp=p->next; |
| 1097 | free(p); |
| 1098 | p =NULL; |
| 1099 | LynqQueueHead = temp; |
| 1100 | LYDBGLOG("[%s] delete head note!!\n",__FUNCTION__); |
| 1101 | return 0; |
| 1102 | //return head; |
| 1103 | } |
| 1104 | //delete intermediate node |
| 1105 | do |
| 1106 | { |
| 1107 | temp = p; |
| 1108 | p=p->next; |
| 1109 | if(p->token==token) |
| 1110 | { |
| 1111 | temp->next=p->next; |
| 1112 | free(p); |
| 1113 | p=NULL; |
| 1114 | LYDBGLOG("[%s] delete intermediate node!!\n",__FUNCTION__); |
| 1115 | //return head; |
| 1116 | return 0; |
| 1117 | } |
| 1118 | }while(p->next->next!=NULL); |
| 1119 | LYDBGLOG("[%s] Not find this token,token is %d!!\n",__FUNCTION__,token); |
| 1120 | return 0; |
| 1121 | } |
| 1122 | void LYNQ_DispatchRequest(int32_t request,int32_t token) |
| 1123 | { |
| 1124 | switch(request) |
| 1125 | { |
| 1126 | //SIM CONTROLLER |
| 1127 | case RIL_REQUEST_GET_SIM_STATUS: |
| 1128 | case RIL_REQUEST_GET_IMSI: |
| 1129 | //CC CONTROLLER |
| 1130 | case RIL_REQUEST_DIAL: |
| 1131 | case RIL_REQUEST_ANSWER: |
| 1132 | case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: |
| 1133 | case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: |
| 1134 | case RIL_REQUEST_HANGUP: |
| 1135 | case RIL_REQUEST_UDUB: |
| 1136 | case RIL_REQUEST_DTMF: |
| 1137 | case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: |
| 1138 | case RIL_REQUEST_SEPARATE_CONNECTION: |
| 1139 | case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: |
| 1140 | case RIL_REQUEST_CONFERENCE: |
| 1141 | //DATA CONTROLLER |
| 1142 | //case RIL_REQUEST_SETUP_DATA_CALL: |
| 1143 | case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: |
| 1144 | case RIL_REQUEST_DATA_CALL_LIST: |
| 1145 | //NETWORK CONTROLLER |
| 1146 | case RIL_REQUEST_OPERATOR: |
| 1147 | case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: |
| 1148 | case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: |
| 1149 | case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: |
| 1150 | case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: |
| 1151 | case RIL_REQUEST_DATA_REGISTRATION_STATE: |
| 1152 | case RIL_REQUEST_VOICE_REGISTRATION_STATE: |
| 1153 | case RIL_REQUEST_IMS_REGISTRATION_STATE: |
| 1154 | case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: |
| 1155 | case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: |
| 1156 | case RIL_REQUEST_GET_CELL_INFO_LIST: |
| 1157 | case RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE: |
| 1158 | case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: |
| 1159 | case RIL_REQUEST_SET_BAND_MODE: |
| 1160 | case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: |
| 1161 | case RIL_REQUEST_RADIO_POWER: |
| 1162 | case RIL_REQUEST_VOICE_RADIO_TECH: |
| 1163 | case RIL_REQUEST_SIGNAL_STRENGTH: |
| 1164 | case RIL_REQUEST_MODEM_POWEROFF: |
| 1165 | case RIL_REQUEST_MODEM_POWERON: |
| 1166 | //SMS CONTROLLER |
| 1167 | case RIL_REQUEST_SEND_SMS: |
| 1168 | case RIL_REQUEST_IMS_SEND_SMS: |
| 1169 | case RIL_REQUEST_WRITE_SMS_TO_SIM: |
| 1170 | case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: |
| 1171 | case RIL_REQUEST_DELETE_SMS_ON_SIM: |
| 1172 | case RIL_REQUEST_GET_SMSC_ADDRESS: |
| 1173 | case RIL_REQUEST_SET_SMSC_ADDRESS: |
| 1174 | { |
| 1175 | //simInfoLinkHead=inSimQueue(request, token, simInfoLinkHead); |
| 1176 | LynqQueueHead = lynqInQueue(request,token,LynqQueueHead); |
| 1177 | break; |
| 1178 | } |
| 1179 | default: |
| 1180 | break; |
| 1181 | } |
| 1182 | return; |
| 1183 | } |
| 1184 | void addImsiInfo(int request,RIL_Errno respe,int32_t token,simInfoLink *head,void *response,size_t respLen) |
| 1185 | { |
| 1186 | if(head==NULL) |
| 1187 | { |
| 1188 | LYDBGLOG("[addImsiInfo] the head is NULL!\n"); |
| 1189 | return; |
| 1190 | } |
| 1191 | LYDBGLOG("addImsiInfo respLen is %d\n",respLen); |
| 1192 | if(response==NULL) |
| 1193 | { |
| 1194 | LYDBGLOG("the get IMSI response is NULL!\n"); |
| 1195 | return; |
| 1196 | } |
| 1197 | simInfoLink * temp=head; |
| 1198 | do |
| 1199 | { |
| 1200 | if(temp->token==token) |
| 1201 | { |
| 1202 | temp->Error_tok=respe; |
| 1203 | memcpy(temp->imsi,((char *)response),respLen+1); |
| 1204 | //temp->imsi = (char *)response; |
| 1205 | temp->simInfoLen=respLen/strlen((char*)response); |
| 1206 | break; |
| 1207 | } |
| 1208 | temp=temp->next; |
| 1209 | }while(temp!=NULL); |
| 1210 | return; |
| 1211 | } |
| 1212 | static int updateCallStatus(void *response,size_t responselen) |
| 1213 | { |
| 1214 | if(response ==NULL||responselen==0) |
| 1215 | { |
| 1216 | s_callStatus=LYNQ_CALL_OFF; |
| 1217 | LYDBGLOG("[%s] update call status to call off\n",__FUNCTION__); |
| 1218 | } |
| 1219 | return 0; |
| 1220 | } |
| 1221 | int callListToParcel(void *response,size_t responselen,Parcel &p) |
| 1222 | { |
| 1223 | int num; |
| 1224 | if (response == NULL && responselen != 0) { |
| 1225 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1226 | s_callStatus=LYNQ_CALL_OFF; |
| 1227 | return -1; |
| 1228 | } |
| 1229 | if(response ==NULL) |
| 1230 | { |
| 1231 | s_callStatus=LYNQ_CALL_OFF; |
| 1232 | LYDBGLOG("[%s] update call state to CALL_OFF!\n",__FUNCTION__); |
| 1233 | } |
| 1234 | if (responselen % sizeof (RIL_Call *) != 0) { |
| 1235 | LYDBGLOG("responseCallList: invalid response length %d expected multiple of %d\n", |
| 1236 | (int)responselen, (int)sizeof (RIL_Call *)); |
| 1237 | s_callStatus=LYNQ_CALL_OFF; |
| 1238 | return -1; |
| 1239 | } |
| 1240 | /* number of call info's */ |
| 1241 | num = responselen / sizeof(RIL_Call *); |
| 1242 | p.setDataPosition(0); |
| 1243 | p.writeInt32(num); |
| 1244 | for (int i = 0 ; i < num ; i++) |
| 1245 | { |
| 1246 | RIL_Call *p_cur = ((RIL_Call **) response)[i]; |
| 1247 | /* each call info */ |
| 1248 | p.writeInt32(p_cur->state); |
| 1249 | //printf("callListToParcel state is %d\n",p_cur->state); |
| 1250 | p.writeInt32(p_cur->index); |
| 1251 | p.writeInt32(p_cur->toa); |
| 1252 | p.writeInt32(p_cur->isMpty); |
| 1253 | p.writeInt32(p_cur->isMT); |
| 1254 | StringWriteToParcel(p, p_cur->number); |
| 1255 | s_callStatus=LYNQ_CALL_ON; |
| 1256 | //printf("----parcel write success----\n"); |
| 1257 | } |
| 1258 | return 0; |
| 1259 | } |
| 1260 | int imsiToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1261 | { |
| 1262 | int num; |
| 1263 | lynqQueue * node; |
| 1264 | if (response == NULL && responselen != 0) { |
| 1265 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1266 | return -1; |
| 1267 | } |
| 1268 | if(responselen ==0) |
| 1269 | { |
| 1270 | LYDBGLOG("[%s] get imsi fail\n"); |
| 1271 | return -1; |
| 1272 | } |
| 1273 | /* number of imsi info's */ |
| 1274 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1275 | if(node==NULL) |
| 1276 | { |
| 1277 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1278 | return -1; |
| 1279 | } |
| 1280 | node->t_Errno = e; |
| 1281 | num=responselen/strlen((char*)response); |
| 1282 | node->parcel.writeInt32(num); |
| 1283 | for (int i = 0 ; i < num ; i++) |
| 1284 | { |
| 1285 | StringWriteToParcel(node->parcel, response); |
| 1286 | LYDBGLOG("[%s] parcel write success\n",__FUNCTION__); |
| 1287 | } |
| 1288 | return 0; |
| 1289 | } |
| 1290 | int simInfoToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1291 | { |
| 1292 | int num; |
| 1293 | lynqQueue * node; |
| 1294 | if (response == NULL && responselen != 0) { |
| 1295 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1296 | return -1; |
| 1297 | } |
| 1298 | if(responselen ==0) |
| 1299 | { |
| 1300 | LYDBGLOG("[%s] get sim fail\n",__FUNCTION__); |
| 1301 | return -1; |
| 1302 | } |
| 1303 | /* number of imsi info's */ |
| 1304 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1305 | if(node==NULL) |
| 1306 | { |
| 1307 | LYDBGLOG("[%s] simInfoToParcel search token %d failure from lynq queue\n",__FUNCTION__,token); |
| 1308 | return -1; |
| 1309 | } |
| 1310 | node->t_Errno = e; |
| 1311 | if (responselen == sizeof (RIL_CardStatus_v6)) |
| 1312 | { |
| 1313 | RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response); |
| 1314 | node->parcel.writeInt32(p_cur->card_state); |
| 1315 | node->parcel.writeInt32(p_cur->num_applications); |
| 1316 | for(int i=0;i<p_cur->num_applications;i++) |
| 1317 | { |
| 1318 | node->parcel.writeInt32(p_cur->applications[i].app_type); |
| 1319 | node->parcel.writeInt32(p_cur->applications[i].pin1); |
| 1320 | LYDBGLOG("[%s] parcel write success\n",__FUNCTION__); |
| 1321 | } |
| 1322 | } |
| 1323 | return 0; |
| 1324 | } |
| 1325 | int lastCallFailCauseToParce(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1326 | { |
| 1327 | int num; |
| 1328 | lynqQueue * node; |
| 1329 | if (response == NULL && responselen != 0) { |
| 1330 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1331 | return -1; |
| 1332 | } |
| 1333 | if(responselen ==0) |
| 1334 | { |
| 1335 | LYDBGLOG("get last call fail cause fail\n"); |
| 1336 | return -1; |
| 1337 | } |
| 1338 | /* number of imsi info's */ |
| 1339 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1340 | if(node==NULL) |
| 1341 | { |
| 1342 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1343 | return -1; |
| 1344 | } |
| 1345 | node->t_Errno = e; |
| 1346 | node->parcel.writeInt32(responselen); |
| 1347 | RIL_LastCallFailCauseInfo *p_cur = (RIL_LastCallFailCauseInfo *)response; |
| 1348 | //num=responselen/strlen((char*)response); |
| 1349 | node->parcel.writeInt32(p_cur->cause_code); |
| 1350 | StringWriteToParcel(node->parcel, p_cur->vendor_cause); |
| 1351 | LYDBGLOG("[%s] parcel write success\n",__FUNCTION__); |
| 1352 | return 0; |
| 1353 | |
| 1354 | } |
| 1355 | int dataCalllistToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1356 | { |
| 1357 | int num; |
| 1358 | lynqQueue * node; |
| 1359 | if (response == NULL && responselen != 0) { |
| 1360 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1361 | return -1; |
| 1362 | } |
| 1363 | if(responselen ==0) |
| 1364 | { |
| 1365 | RLOGD("get data call list fail\n"); |
| 1366 | return -1; |
| 1367 | } |
| 1368 | /* number of data call list info's */ |
| 1369 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1370 | if(node==NULL) |
| 1371 | { |
| 1372 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1373 | return -1; |
| 1374 | } |
| 1375 | node->t_Errno = e; |
| 1376 | num = responselen/sizeof(RIL_Data_Call_Response_v11); |
| 1377 | node->parcel.writeInt32(num); |
| 1378 | RIL_Data_Call_Response_v11 *p_cur = (RIL_Data_Call_Response_v11 *)response; |
| 1379 | for(int i=0;i<num;i++) |
| 1380 | { |
| 1381 | //RIL_Data_Call_Response_v11 *p_cur = (RIL_Data_Call_Response_v11 *)response; |
| 1382 | node->parcel.writeInt32(p_cur[i].status); |
| 1383 | node->parcel.writeInt32(p_cur[i].suggestedRetryTime); |
| 1384 | node->parcel.writeInt32(p_cur[i].cid); |
| 1385 | node->parcel.writeInt32(p_cur[i].active); |
| 1386 | StringWriteToParcel(node->parcel, p_cur[i].type); |
| 1387 | StringWriteToParcel(node->parcel, p_cur[i].ifname); |
| 1388 | StringWriteToParcel(node->parcel, p_cur[i].addresses); |
| 1389 | StringWriteToParcel(node->parcel, p_cur[i].dnses); |
| 1390 | StringWriteToParcel(node->parcel, p_cur[i].gateways); |
| 1391 | StringWriteToParcel(node->parcel, p_cur[i].pcscf); |
| 1392 | node->parcel.writeInt32(p_cur[i].mtu); |
| 1393 | } |
| 1394 | LYDBGLOG("[%s] parcel write success\n",__FUNCTION__); |
| 1395 | return 0; |
| 1396 | |
| 1397 | } |
| 1398 | int currentOperatorInfoToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1399 | { |
| 1400 | int num; |
| 1401 | lynqQueue * node; |
| 1402 | char **pString=NULL; |
| 1403 | char * subString=NULL; |
| 1404 | if (response == NULL && responselen != 0) { |
| 1405 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1406 | return -1; |
| 1407 | } |
| 1408 | if(responselen ==0) |
| 1409 | { |
| 1410 | RLOGD("response is null\n"); |
| 1411 | return -1; |
| 1412 | } |
| 1413 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1414 | if(node==NULL) |
| 1415 | { |
| 1416 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1417 | return -1; |
| 1418 | } |
| 1419 | num = responselen/(sizeof(char*)); |
| 1420 | LYDBGLOG("currentOperatorInfoToParcel is %d\n",num); |
| 1421 | node->t_Errno = e; |
| 1422 | pString=(char **)response; |
| 1423 | node->parcel.writeInt32(num); |
| 1424 | for (int i=0;i<num;i++) |
| 1425 | { |
| 1426 | subString = pString[i]; |
| 1427 | LYDBGLOG("[%s] subString is %s\n",__FUNCTION__,subString); |
| 1428 | StringWriteToParcel(node->parcel,subString); |
| 1429 | } |
| 1430 | LYDBGLOG("[%s] parcel write success\n",__FUNCTION__); |
| 1431 | return 0; |
| 1432 | |
| 1433 | } |
| 1434 | //int queryNetSelectModeToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e); |
| 1435 | static int stringsToParecl(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1436 | { |
| 1437 | int num; |
| 1438 | lynqQueue * node; |
| 1439 | char **pString=NULL; |
| 1440 | char * subString=NULL; |
| 1441 | if (response == NULL && responselen != 0){ |
| 1442 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1443 | return -1; |
| 1444 | } |
| 1445 | if(responselen ==0) |
| 1446 | { |
| 1447 | LYDBGLOG("response is null\n"); |
| 1448 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1449 | if(node==NULL) |
| 1450 | { |
| 1451 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1452 | return -1; |
| 1453 | } |
| 1454 | node->parcel.writeInt32(0); |
| 1455 | node->t_Errno = e; |
| 1456 | return -1; |
| 1457 | } |
| 1458 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1459 | if(node==NULL) |
| 1460 | { |
| 1461 | LYDBGLOG("[%s][%d] search token %x failure from lynq queue\n",__FUNCTION__,__LINE__,token); |
| 1462 | return -1; |
| 1463 | } |
| 1464 | num = responselen/(sizeof(char*)); |
| 1465 | node->t_Errno = e; |
| 1466 | pString=(char **)response; |
| 1467 | node->parcel.writeInt32(num); |
| 1468 | for (int i=0;i<num;i++) |
| 1469 | { |
| 1470 | subString = pString[i]; |
| 1471 | LYDBGLOG("[%s] subString is %s\n",__FUNCTION__,subString); |
| 1472 | StringWriteToParcel(node->parcel,subString); |
| 1473 | } |
| 1474 | LYDBGLOG("[%s] parcel write success\n",__FUNCTION__); |
| 1475 | return 0; |
| 1476 | } |
| 1477 | static int stringToParecl(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1478 | { |
| 1479 | int num; |
| 1480 | lynqQueue * node; |
| 1481 | char *pString=NULL; |
| 1482 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1483 | if(node==NULL) |
| 1484 | { |
| 1485 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1486 | return -1; |
| 1487 | } |
| 1488 | node->t_Errno = e; |
| 1489 | if (response == NULL && responselen != 0){ |
| 1490 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1491 | return -1; |
| 1492 | } |
| 1493 | if(responselen ==0) |
| 1494 | { |
| 1495 | LYDBGLOG("[%s] response is null\n",__FUNCTION__); |
| 1496 | node->parcel.writeInt32(0); |
| 1497 | return -1; |
| 1498 | } |
| 1499 | pString=(char *)response; |
| 1500 | node->parcel.writeInt32(1); |
| 1501 | StringWriteToParcel(node->parcel,pString); |
| 1502 | LYDBGLOG("[%s] parcel write success\n",__FUNCTION__); |
| 1503 | return 0; |
| 1504 | } |
| 1505 | |
| 1506 | static int intToParcel(int32_t request, int32_t token, void * response, size_t responselen, RIL_Errno e) |
| 1507 | { |
| 1508 | int num; |
| 1509 | lynqQueue * node; |
| 1510 | int *pInts=NULL; |
| 1511 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1512 | if(node==NULL) |
| 1513 | { |
| 1514 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1515 | return -1; |
| 1516 | } |
| 1517 | node->t_Errno = e; |
| 1518 | if (response == NULL && responselen != 0){ |
| 1519 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1520 | return -1; |
| 1521 | } |
| 1522 | if(responselen ==0) |
| 1523 | { |
| 1524 | LYDBGLOG("[%s] response is null\n",__FUNCTION__); |
| 1525 | node->parcel.writeInt32(0); |
| 1526 | return -1; |
| 1527 | } |
| 1528 | num = responselen/(sizeof(int)); |
| 1529 | //printf("intToParcel is %d\n",num); |
| 1530 | pInts=(int*)response; |
| 1531 | node->parcel.writeInt32(num); |
| 1532 | for (int i=0;i<num;i++) |
| 1533 | { |
| 1534 | //printf("subints is %d\n",pInts[i]); |
| 1535 | node->parcel.writeInt32(pInts[i]); |
| 1536 | } |
| 1537 | LYDBGLOG("[%s] parcel write success\n",__FUNCTION__); |
| 1538 | return 0; |
| 1539 | } |
| 1540 | static int updateErrnoToQueue(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1541 | { |
| 1542 | int status=0;//something change |
| 1543 | lynqQueue * node; |
| 1544 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1545 | if(node==NULL) |
| 1546 | { |
| 1547 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1548 | return -1; |
| 1549 | } |
| 1550 | status =1; |
| 1551 | node->t_Errno=e; |
| 1552 | node->parcel.writeInt32(status); |
| 1553 | LYDBGLOG("[%s,%d] end!!! \n",__FUNCTION__,__LINE__); |
| 1554 | return 0; |
| 1555 | } |
| 1556 | int cellinfoToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1557 | { |
| 1558 | int num = 0; |
| 1559 | lynqQueue * node; |
| 1560 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1561 | if(node==NULL) |
| 1562 | { |
| 1563 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1564 | return -1; |
| 1565 | } |
| 1566 | node->t_Errno = e; |
| 1567 | if (response == NULL && responselen != 0) { |
| 1568 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1569 | return -1; |
| 1570 | } |
| 1571 | if(responselen ==0) |
| 1572 | { |
| 1573 | LYDBGLOG("[%s] response is null\n",__FUNCTION__); |
| 1574 | node->parcel.writeInt32(0); |
| 1575 | return -1; |
| 1576 | } |
| 1577 | num = responselen/sizeof(RIL_CellInfo); |
| 1578 | node->parcel.writeInt32(num); |
| 1579 | RIL_CellInfo *p_cur = (RIL_CellInfo *)response; |
| 1580 | for (int i = 0; i< num; i++) { |
| 1581 | node->parcel.writeInt32(p_cur[i].cellInfoType); |
| 1582 | node->parcel.writeInt32(p_cur[i].registered); |
| 1583 | node->parcel.writeInt32(p_cur[i].timeStampType); |
| 1584 | node->parcel.writeInt64(p_cur[i].timeStamp); |
| 1585 | switch(p_cur[i].cellInfoType) { |
| 1586 | case RIL_CELL_INFO_TYPE_GSM: { |
| 1587 | node->parcel.writeInt32(p_cur[i].CellInfo.gsm.cellIdentityGsm.mcc); |
| 1588 | node->parcel.writeInt32(p_cur[i].CellInfo.gsm.cellIdentityGsm.mnc); |
| 1589 | node->parcel.writeInt32(p_cur[i].CellInfo.gsm.cellIdentityGsm.lac); |
| 1590 | node->parcel.writeInt32(p_cur[i].CellInfo.gsm.cellIdentityGsm.cid); |
| 1591 | node->parcel.writeInt32(p_cur[i].CellInfo.gsm.signalStrengthGsm.signalStrength); |
| 1592 | node->parcel.writeInt32(p_cur[i].CellInfo.gsm.signalStrengthGsm.bitErrorRate); |
| 1593 | node->parcel.writeInt32(p_cur[i].CellInfo.gsm.signalStrengthGsm.timingAdvance); |
| 1594 | break; |
| 1595 | } |
| 1596 | case RIL_CELL_INFO_TYPE_WCDMA: { |
| 1597 | node->parcel.writeInt32(p_cur[i].CellInfo.wcdma.cellIdentityWcdma.mcc); |
| 1598 | node->parcel.writeInt32(p_cur[i].CellInfo.wcdma.cellIdentityWcdma.mnc); |
| 1599 | node->parcel.writeInt32(p_cur[i].CellInfo.wcdma.cellIdentityWcdma.lac); |
| 1600 | node->parcel.writeInt32(p_cur[i].CellInfo.wcdma.cellIdentityWcdma.cid); |
| 1601 | node->parcel.writeInt32(p_cur[i].CellInfo.wcdma.cellIdentityWcdma.psc); |
| 1602 | node->parcel.writeInt32(p_cur[i].CellInfo.wcdma.signalStrengthWcdma.signalStrength); |
| 1603 | node->parcel.writeInt32(p_cur[i].CellInfo.wcdma.signalStrengthWcdma.bitErrorRate); |
| 1604 | break; |
| 1605 | } |
| 1606 | case RIL_CELL_INFO_TYPE_CDMA: { |
| 1607 | node->parcel.writeInt32(p_cur[i].CellInfo.cdma.cellIdentityCdma.networkId); |
| 1608 | node->parcel.writeInt32(p_cur[i].CellInfo.cdma.cellIdentityCdma.systemId); |
| 1609 | node->parcel.writeInt32(p_cur[i].CellInfo.cdma.cellIdentityCdma.basestationId); |
| 1610 | node->parcel.writeInt32(p_cur[i].CellInfo.cdma.cellIdentityCdma.longitude); |
| 1611 | node->parcel.writeInt32(p_cur[i].CellInfo.cdma.cellIdentityCdma.latitude); |
| 1612 | node->parcel.writeInt32(p_cur[i].CellInfo.cdma.signalStrengthCdma.dbm); |
| 1613 | node->parcel.writeInt32(p_cur[i].CellInfo.cdma.signalStrengthCdma.ecio); |
| 1614 | node->parcel.writeInt32(p_cur[i].CellInfo.cdma.signalStrengthEvdo.dbm); |
| 1615 | node->parcel.writeInt32(p_cur[i].CellInfo.cdma.signalStrengthEvdo.ecio); |
| 1616 | node->parcel.writeInt32(p_cur[i].CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio); |
| 1617 | break; |
| 1618 | } |
| 1619 | case RIL_CELL_INFO_TYPE_LTE: { |
| 1620 | node->parcel.writeInt32(p_cur[i].CellInfo.lte.cellIdentityLte.mcc); |
| 1621 | node->parcel.writeInt32(p_cur[i].CellInfo.lte.cellIdentityLte.mnc); |
| 1622 | node->parcel.writeInt32(p_cur[i].CellInfo.lte.cellIdentityLte.ci); |
| 1623 | node->parcel.writeInt32(p_cur[i].CellInfo.lte.cellIdentityLte.pci); |
| 1624 | node->parcel.writeInt32(p_cur[i].CellInfo.lte.cellIdentityLte.tac); |
| 1625 | node->parcel.writeInt32(p_cur[i].CellInfo.lte.signalStrengthLte.signalStrength); |
| 1626 | node->parcel.writeInt32(p_cur[i].CellInfo.lte.signalStrengthLte.rsrp); |
| 1627 | node->parcel.writeInt32(p_cur[i].CellInfo.lte.signalStrengthLte.rsrq); |
| 1628 | node->parcel.writeInt32(p_cur[i].CellInfo.lte.signalStrengthLte.rssnr); |
| 1629 | node->parcel.writeInt32(p_cur[i].CellInfo.lte.signalStrengthLte.cqi); |
| 1630 | node->parcel.writeInt32(p_cur[i].CellInfo.lte.signalStrengthLte.timingAdvance); |
| 1631 | break; |
| 1632 | } |
| 1633 | case RIL_CELL_INFO_TYPE_TD_SCDMA: { |
| 1634 | node->parcel.writeInt32(p_cur[i].CellInfo.tdscdma.cellIdentityTdscdma.mcc); |
| 1635 | node->parcel.writeInt32(p_cur[i].CellInfo.tdscdma.cellIdentityTdscdma.mnc); |
| 1636 | node->parcel.writeInt32(p_cur[i].CellInfo.tdscdma.cellIdentityTdscdma.lac); |
| 1637 | node->parcel.writeInt32(p_cur[i].CellInfo.tdscdma.cellIdentityTdscdma.cid); |
| 1638 | node->parcel.writeInt32(p_cur[i].CellInfo.tdscdma.cellIdentityTdscdma.cpid); |
| 1639 | node->parcel.writeInt32(p_cur[i].CellInfo.tdscdma.signalStrengthTdscdma.rscp); |
| 1640 | break; |
| 1641 | } |
| 1642 | } |
| 1643 | } |
| 1644 | LYDBGLOG("[%s] parcel write success\n",__FUNCTION__); |
| 1645 | return 0; |
| 1646 | } |
| 1647 | int neighboringCellToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1648 | { |
| 1649 | int num = 0; |
| 1650 | lynqQueue * node; |
| 1651 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1652 | if(node==NULL) |
| 1653 | { |
| 1654 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1655 | return -1; |
| 1656 | } |
| 1657 | node->t_Errno = e; |
| 1658 | if (response == NULL && responselen != 0) { |
| 1659 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1660 | return -1; |
| 1661 | } |
| 1662 | if(responselen ==0) |
| 1663 | { |
| 1664 | LYDBGLOG("[%s] get cell list fail\n",__FUNCTION__); |
| 1665 | node->parcel.writeInt32(0); |
| 1666 | return -1; |
| 1667 | } |
| 1668 | num = responselen/sizeof(RIL_NeighboringCell*); |
| 1669 | node->parcel.writeInt32(num); |
| 1670 | RIL_NeighboringCell **p_cur = (RIL_NeighboringCell **)response; |
| 1671 | for (int i = 0; i< num; i++) { |
| 1672 | StringWriteToParcel(node->parcel,p_cur[i]->cid); |
| 1673 | node->parcel.writeInt32(p_cur[i]->rssi); |
| 1674 | } |
| 1675 | return 0; |
| 1676 | } |
| 1677 | int solicitedSignalStrengthToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1678 | { |
| 1679 | int num = 0; |
| 1680 | lynqQueue * node; |
| 1681 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1682 | if(node==NULL) |
| 1683 | { |
| 1684 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1685 | return -1; |
| 1686 | } |
| 1687 | node->t_Errno = e; |
| 1688 | if (response == NULL && responselen != 0) { |
| 1689 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1690 | return -1; |
| 1691 | } |
| 1692 | if(responselen ==0) |
| 1693 | { |
| 1694 | LYDBGLOG("[%s] get signal strength fail\n",__FUNCTION__); |
| 1695 | node->parcel.writeInt32(0); |
| 1696 | return -1; |
| 1697 | } |
| 1698 | num = responselen/sizeof(RIL_SignalStrength_v10); |
| 1699 | node->parcel.writeInt32(num); |
| 1700 | RIL_SignalStrength_v10 *p_cur = (RIL_SignalStrength_v10 *)response; |
| 1701 | node->parcel.writeInt32(p_cur->GW_SignalStrength.signalStrength); |
| 1702 | node->parcel.writeInt32(p_cur->GW_SignalStrength.bitErrorRate); |
| 1703 | node->parcel.writeInt32(p_cur->GW_SignalStrength.timingAdvance); |
| 1704 | node->parcel.writeInt32(p_cur->CDMA_SignalStrength.dbm); |
| 1705 | node->parcel.writeInt32(p_cur->CDMA_SignalStrength.ecio); |
| 1706 | node->parcel.writeInt32(p_cur->EVDO_SignalStrength.dbm); |
| 1707 | node->parcel.writeInt32(p_cur->EVDO_SignalStrength.ecio); |
| 1708 | node->parcel.writeInt32(p_cur->EVDO_SignalStrength.signalNoiseRatio); |
| 1709 | node->parcel.writeInt32(p_cur->LTE_SignalStrength.signalStrength); |
| 1710 | node->parcel.writeInt32(p_cur->LTE_SignalStrength.rsrp); |
| 1711 | node->parcel.writeInt32(p_cur->LTE_SignalStrength.rsrq); |
| 1712 | node->parcel.writeInt32(p_cur->LTE_SignalStrength.rssnr); |
| 1713 | node->parcel.writeInt32(p_cur->LTE_SignalStrength.cqi); |
| 1714 | node->parcel.writeInt32(p_cur->LTE_SignalStrength.timingAdvance); |
| 1715 | node->parcel.writeInt32(p_cur->TD_SCDMA_SignalStrength.signalStrength); |
| 1716 | node->parcel.writeInt32(p_cur->TD_SCDMA_SignalStrength.bitErrorRate); |
| 1717 | node->parcel.writeInt32(p_cur->TD_SCDMA_SignalStrength.rscp); |
| 1718 | node->parcel.writeInt32(p_cur->WCDMA_SignalStrength.signalStrength); |
| 1719 | node->parcel.writeInt32(p_cur->WCDMA_SignalStrength.bitErrorRate); |
| 1720 | node->parcel.writeInt32(p_cur->WCDMA_SignalStrength.rscp); |
| 1721 | node->parcel.writeInt32(p_cur->WCDMA_SignalStrength.ecno); |
| 1722 | return 0; |
| 1723 | } |
| 1724 | int smsResponseToParcel(int32_t request,int32_t token,void *response,size_t responselen,RIL_Errno e) |
| 1725 | { |
| 1726 | int num = 0; |
| 1727 | lynqQueue * node; |
| 1728 | node = searchTokeninQueue(token,LynqQueueHead); |
| 1729 | if(node==NULL) |
| 1730 | { |
| 1731 | LYDBGLOG("[%s] search token %x failure from lynq queue\n",__FUNCTION__,token); |
| 1732 | return -1; |
| 1733 | } |
| 1734 | node->t_Errno = e; |
| 1735 | if (response == NULL && responselen != 0) { |
| 1736 | LYDBGLOG("[%s] invalid response: NULL\n",__FUNCTION__); |
| 1737 | return -1; |
| 1738 | } |
| 1739 | if(responselen ==0) |
| 1740 | { |
| 1741 | LYDBGLOG("[%s] sms response\n",__FUNCTION__); |
| 1742 | node->parcel.writeInt32(0); |
| 1743 | return -1; |
| 1744 | } |
| 1745 | num = responselen/sizeof(RIL_SMS_Response); |
| 1746 | node->parcel.writeInt32(num); |
| 1747 | RIL_SMS_Response *p_cur = (RIL_SMS_Response *)response; |
| 1748 | node->parcel.writeInt32(p_cur->messageRef); |
| 1749 | StringWriteToParcel(node->parcel,p_cur->ackPDU); |
| 1750 | node->parcel.writeInt32(p_cur->errorCode); |
| 1751 | return 0; |
| 1752 | } |
| 1753 | |
| 1754 | /*****mobiletek-end****/ |