ril_service.cpp revision 0de29d1a7525a2d60f31794d22b6737d44e690c0
1/* 2 * Copyright (c) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include <android/hardware/radio/1.0/IRadio.h> 18 19#include <hwbinder/IPCThreadState.h> 20#include <hwbinder/ProcessState.h> 21#include <ril_service.h> 22#include <hidl/HidlTransportSupport.h> 23#include <utils/SystemClock.h> 24 25#define INVALID_HEX_CHAR 16 26 27using namespace android::hardware::radio::V1_0; 28using ::android::hardware::configureRpcThreadpool; 29using ::android::hardware::joinRpcThreadpool; 30using ::android::hardware::Return; 31using ::android::hardware::Status; 32using ::android::hardware::hidl_string; 33using ::android::hardware::hidl_vec; 34using ::android::hardware::hidl_array; 35using ::android::hardware::Void; 36using android::CommandInfo; 37using android::RequestInfo; 38using android::requestToString; 39using android::sp; 40 41#define BOOL_TO_INT(x) (x ? 1 : 0) 42#define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1) 43#define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal) 44 45RIL_RadioFunctions *s_vendorFunctions = NULL; 46static CommandInfo *s_commands; 47 48struct RadioImpl; 49 50#if (SIM_COUNT >= 2) 51sp<RadioImpl> radioService[SIM_COUNT]; 52#else 53sp<RadioImpl> radioService[1]; 54#endif 55 56static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER; 57 58#if (SIM_COUNT >= 2) 59static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER; 60#if (SIM_COUNT >= 3) 61static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER; 62#if (SIM_COUNT >= 4) 63static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER; 64#endif 65#endif 66#endif 67 68struct RadioImpl : public IRadio { 69 int32_t mSlotId; 70 // counter used for synchronization. It is incremented every time mRadioResponse or 71 // mRadioIndication value is updated. 72 volatile int32_t mCounter; 73 sp<IRadioResponse> mRadioResponse; 74 sp<IRadioIndication> mRadioIndication; 75 76 Return<void> setResponseFunctions( 77 const ::android::sp<IRadioResponse>& radioResponse, 78 const ::android::sp<IRadioIndication>& radioIndication); 79 80 Return<void> getIccCardStatus(int32_t serial); 81 82 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin, 83 const hidl_string& aid); 84 85 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk, 86 const hidl_string& pin, const hidl_string& aid); 87 88 Return<void> supplyIccPin2ForApp(int32_t serial, 89 const hidl_string& pin2, 90 const hidl_string& aid); 91 92 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2, 93 const hidl_string& pin2, const hidl_string& aid); 94 95 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin, 96 const hidl_string& newPin, const hidl_string& aid); 97 98 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2, 99 const hidl_string& newPin2, const hidl_string& aid); 100 101 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin); 102 103 Return<void> getCurrentCalls(int32_t serial); 104 105 Return<void> dial(int32_t serial, const Dial& dialInfo); 106 107 Return<void> getImsiForApp(int32_t serial, 108 const ::android::hardware::hidl_string& aid); 109 110 Return<void> hangup(int32_t serial, int32_t gsmIndex); 111 112 Return<void> hangupWaitingOrBackground(int32_t serial); 113 114 Return<void> hangupForegroundResumeBackground(int32_t serial); 115 116 Return<void> switchWaitingOrHoldingAndActive(int32_t serial); 117 118 Return<void> conference(int32_t serial); 119 120 Return<void> rejectCall(int32_t serial); 121 122 Return<void> getLastCallFailCause(int32_t serial); 123 124 Return<void> getSignalStrength(int32_t serial); 125 126 Return<void> getVoiceRegistrationState(int32_t serial); 127 128 Return<void> getDataRegistrationState(int32_t serial); 129 130 Return<void> getOperator(int32_t serial); 131 132 Return<void> setRadioPower(int32_t serial, bool on); 133 134 Return<void> sendDtmf(int32_t serial, 135 const ::android::hardware::hidl_string& s); 136 137 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message); 138 139 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message); 140 141 Return<void> setupDataCall(int32_t serial, 142 RadioTechnology radioTechnology, 143 const DataProfileInfo& profileInfo, 144 bool modemCognitive, 145 bool roamingAllowed); 146 147 Return<void> iccIOForApp(int32_t serial, 148 const IccIo& iccIo); 149 150 Return<void> sendUssd(int32_t serial, 151 const ::android::hardware::hidl_string& ussd); 152 153 Return<void> cancelPendingUssd(int32_t serial); 154 155 Return<void> getClir(int32_t serial); 156 157 Return<void> setClir(int32_t serial, int32_t status); 158 159 Return<void> getCallForwardStatus(int32_t serial, 160 const CallForwardInfo& callInfo); 161 162 Return<void> setCallForward(int32_t serial, 163 const CallForwardInfo& callInfo); 164 165 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass); 166 167 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass); 168 169 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial, 170 bool success, SmsAcknowledgeFailCause cause); 171 172 Return<void> acceptCall(int32_t serial); 173 174 Return<void> deactivateDataCall(int32_t serial, 175 int32_t cid, bool reasonRadioShutDown); 176 177 Return<void> getFacilityLockForApp(int32_t serial, 178 const ::android::hardware::hidl_string& facility, 179 const ::android::hardware::hidl_string& password, 180 int32_t serviceClass, 181 const ::android::hardware::hidl_string& appId); 182 183 Return<void> setFacilityLockForApp(int32_t serial, 184 const ::android::hardware::hidl_string& facility, 185 bool lockState, 186 const ::android::hardware::hidl_string& password, 187 int32_t serviceClass, 188 const ::android::hardware::hidl_string& appId); 189 190 Return<void> setBarringPassword(int32_t serial, 191 const ::android::hardware::hidl_string& facility, 192 const ::android::hardware::hidl_string& oldPassword, 193 const ::android::hardware::hidl_string& newPassword); 194 195 Return<void> getNetworkSelectionMode(int32_t serial); 196 197 Return<void> setNetworkSelectionModeAutomatic(int32_t serial); 198 199 Return<void> setNetworkSelectionModeManual(int32_t serial, 200 const ::android::hardware::hidl_string& operatorNumeric); 201 202 Return<void> getAvailableNetworks(int32_t serial); 203 204 Return<void> startDtmf(int32_t serial, 205 const ::android::hardware::hidl_string& s); 206 207 Return<void> stopDtmf(int32_t serial); 208 209 Return<void> getBasebandVersion(int32_t serial); 210 211 Return<void> separateConnection(int32_t serial, int32_t gsmIndex); 212 213 Return<void> setMute(int32_t serial, bool enable); 214 215 Return<void> getMute(int32_t serial); 216 217 Return<void> getClip(int32_t serial); 218 219 Return<void> getDataCallList(int32_t serial); 220 221 Return<void> sendOemRadioRequestRaw(int32_t serial, 222 const ::android::hardware::hidl_vec<uint8_t>& data); 223 224 Return<void> sendOemRadioRequestStrings(int32_t serial, 225 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data); 226 227 Return<void> sendScreenState(int32_t serial, bool enable); 228 229 Return<void> setSuppServiceNotifications(int32_t serial, bool enable); 230 231 Return<void> writeSmsToSim(int32_t serial, 232 const SmsWriteArgs& smsWriteArgs); 233 234 Return<void> deleteSmsOnSim(int32_t serial, int32_t index); 235 236 Return<void> setBandMode(int32_t serial, RadioBandMode mode); 237 238 Return<void> getAvailableBandModes(int32_t serial); 239 240 Return<void> sendEnvelope(int32_t serial, 241 const ::android::hardware::hidl_string& command); 242 243 Return<void> sendTerminalResponseToSim(int32_t serial, 244 const ::android::hardware::hidl_string& commandResponse); 245 246 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept); 247 248 Return<void> explicitCallTransfer(int32_t serial); 249 250 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType); 251 252 Return<void> getPreferredNetworkType(int32_t serial); 253 254 Return<void> getNeighboringCids(int32_t serial); 255 256 Return<void> setLocationUpdates(int32_t serial, bool enable); 257 258 Return<void> setCdmaSubscriptionSource(int32_t serial, 259 CdmaSubscriptionSource cdmaSub); 260 261 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type); 262 263 Return<void> getCdmaRoamingPreference(int32_t serial); 264 265 Return<void> setTTYMode(int32_t serial, TtyMode mode); 266 267 Return<void> getTTYMode(int32_t serial); 268 269 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable); 270 271 Return<void> getPreferredVoicePrivacy(int32_t serial); 272 273 Return<void> sendCDMAFeatureCode(int32_t serial, 274 const ::android::hardware::hidl_string& featureCode); 275 276 Return<void> sendBurstDtmf(int32_t serial, 277 const ::android::hardware::hidl_string& dtmf, 278 int32_t on, 279 int32_t off); 280 281 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms); 282 283 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial, 284 const CdmaSmsAck& smsAck); 285 286 Return<void> getGsmBroadcastConfig(int32_t serial); 287 288 Return<void> setGsmBroadcastConfig(int32_t serial, 289 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo); 290 291 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate); 292 293 Return<void> getCdmaBroadcastConfig(int32_t serial); 294 295 Return<void> setCdmaBroadcastConfig(int32_t serial, 296 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo); 297 298 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate); 299 300 Return<void> getCDMASubscription(int32_t serial); 301 302 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms); 303 304 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index); 305 306 Return<void> getDeviceIdentity(int32_t serial); 307 308 Return<void> exitEmergencyCallbackMode(int32_t serial); 309 310 Return<void> getSmscAddress(int32_t serial); 311 312 Return<void> setSmscAddress(int32_t serial, 313 const ::android::hardware::hidl_string& smsc); 314 315 Return<void> reportSmsMemoryStatus(int32_t serial, bool available); 316 317 Return<void> reportStkServiceIsRunning(int32_t serial); 318 319 Return<void> getCdmaSubscriptionSource(int32_t serial); 320 321 Return<void> requestIsimAuthentication(int32_t serial, 322 const ::android::hardware::hidl_string& challenge); 323 324 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial, 325 bool success, 326 const ::android::hardware::hidl_string& ackPdu); 327 328 Return<void> sendEnvelopeWithStatus(int32_t serial, 329 const ::android::hardware::hidl_string& contents); 330 331 Return<void> getVoiceRadioTechnology(int32_t serial); 332 333 Return<void> getCellInfoList(int32_t serial); 334 335 Return<void> setCellInfoListRate(int32_t serial, int32_t rate); 336 337 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo, 338 bool modemCognitive); 339 340 Return<void> getImsRegistrationState(int32_t serial); 341 342 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message); 343 344 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message); 345 346 Return<void> iccOpenLogicalChannel(int32_t serial, 347 const ::android::hardware::hidl_string& aid); 348 349 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId); 350 351 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message); 352 353 Return<void> nvReadItem(int32_t serial, NvItem itemId); 354 355 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item); 356 357 Return<void> nvWriteCdmaPrl(int32_t serial, 358 const ::android::hardware::hidl_vec<uint8_t>& prl); 359 360 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType); 361 362 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub); 363 364 Return<void> setDataAllowed(int32_t serial, bool allow); 365 366 Return<void> getHardwareConfig(int32_t serial); 367 368 Return<void> requestIccSimAuthentication(int32_t serial, 369 int32_t authContext, 370 const ::android::hardware::hidl_string& authData, 371 const ::android::hardware::hidl_string& aid); 372 373 Return<void> setDataProfile(int32_t serial, 374 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles); 375 376 Return<void> requestShutdown(int32_t serial); 377 378 Return<void> getRadioCapability(int32_t serial); 379 380 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc); 381 382 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode); 383 384 Return<void> stopLceService(int32_t serial); 385 386 Return<void> pullLceData(int32_t serial); 387 388 Return<void> getModemActivityInfo(int32_t serial); 389 390 Return<void> setAllowedCarriers(int32_t serial, 391 bool allAllowed, 392 const CarrierRestrictions& carriers); 393 394 Return<void> getAllowedCarriers(int32_t serial); 395 396 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state); 397 398 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter); 399 400 Return<void> responseAcknowledgement(); 401 402 void checkReturnStatus(Return<void>& ret); 403}; 404 405void memsetAndFreeStrings(int numPointers, ...) { 406 va_list ap; 407 va_start(ap, numPointers); 408 for (int i = 0; i < numPointers; i++) { 409 char *ptr = va_arg(ap, char *); 410 if (ptr) { 411#ifdef MEMSET_FREED 412 memsetString (ptr); 413#endif 414 free(ptr); 415 } 416 } 417 va_end(ap); 418} 419 420/** 421 * Copies over src to dest. If memory allocation failes, responseFunction() is called for the 422 * request with error RIL_E_NO_MEMORY. 423 * Returns true on success, and false on failure. 424 */ 425bool copyHidlStringToRil(char **dest, const char *src, RequestInfo *pRI) { 426 if (strcmp(src, "") == 0) { 427 *dest = NULL; 428 return true; 429 } 430 int len = strlen(src); 431 *dest = (char *) calloc(len + 1, sizeof(char)); 432 if (*dest == NULL) { 433 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber)); 434 android::Parcel p; // TODO: should delete this after translation of all commands is complete 435 pRI->pCI->responseFunction(p, (int) pRI->socket_id, pRI->pCI->requestNumber, 436 (int) RadioResponseType::SOLICITED, pRI->token, RIL_E_NO_MEMORY, NULL, 0); 437 return false; 438 } 439 strncpy(*dest, src, len + 1); 440 return true; 441} 442 443hidl_string convertCharPtrToHidlString(const char *ptr) { 444 hidl_string ret; 445 if (ptr != NULL) { 446 ret.setToExternal(ptr, strlen(ptr)); 447 } 448 return ret; 449} 450 451bool dispatchVoid(int serial, int slotId, int request) { 452 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 453 if (pRI == NULL) { 454 return false; 455 } 456 s_vendorFunctions->onRequest(request, NULL, 0, pRI); 457 return true; 458} 459 460bool dispatchString(int serial, int slotId, int request, const char * str) { 461 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 462 if (pRI == NULL) { 463 return false; 464 } 465 466 char *pString; 467 if (!copyHidlStringToRil(&pString, str, pRI)) { 468 return false; 469 } 470 471 s_vendorFunctions->onRequest(request, pString, sizeof(char *), pRI); 472 473 memsetAndFreeStrings(1, pString); 474 return true; 475} 476 477bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) { 478 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 479 if (pRI == NULL) { 480 return false; 481 } 482 483 char **pStrings; 484 android::Parcel p; // TODO: should delete this after translation of all commands is complete 485 pStrings = (char **)calloc(countStrings, sizeof(char *)); 486 if (pStrings == NULL) { 487 RLOGE("Memory allocation failed for request %s", requestToString(request)); 488 pRI->pCI->responseFunction(p, (int) pRI->socket_id, request, 489 (int) RadioResponseType::SOLICITED, pRI->token, RIL_E_NO_MEMORY, NULL, 0); 490 return false; 491 } 492 va_list ap; 493 va_start(ap, countStrings); 494 for (int i = 0; i < countStrings; i++) { 495 const char* str = va_arg(ap, const char *); 496 if (!copyHidlStringToRil(&pStrings[i], str, pRI)) { 497 va_end(ap); 498 for (int j = 0; j < i; j++) { 499 memsetAndFreeStrings(1, pStrings[j]); 500 } 501 free(pStrings); 502 return false; 503 } 504 } 505 va_end(ap); 506 507 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI); 508 509 if (pStrings != NULL) { 510 for (int i = 0 ; i < countStrings ; i++) { 511 memsetAndFreeStrings(1, pStrings[i]); 512 } 513 514#ifdef MEMSET_FREED 515 memset(pStrings, 0, countStrings * sizeof(char *)); 516#endif 517 free(pStrings); 518 } 519 return true; 520} 521 522bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) { 523 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 524 if (pRI == NULL) { 525 return false; 526 } 527 528 int countStrings = data.size(); 529 char **pStrings; 530 android::Parcel p; // TODO: should delete this after translation of all commands is complete 531 pStrings = (char **)calloc(countStrings, sizeof(char *)); 532 if (pStrings == NULL) { 533 RLOGE("Memory allocation failed for request %s", requestToString(request)); 534 pRI->pCI->responseFunction(p, (int) pRI->socket_id, request, 535 (int) RadioResponseType::SOLICITED, pRI->token, RIL_E_NO_MEMORY, NULL, 0); 536 return false; 537 } 538 539 for (int i = 0; i < countStrings; i++) { 540 const char* str = (const char *) data[i]; 541 if (!copyHidlStringToRil(&pStrings[i], str, pRI)) { 542 for (int j = 0; j < i; j++) { 543 memsetAndFreeStrings(1, pStrings[j]); 544 } 545 free(pStrings); 546 return false; 547 } 548 } 549 550 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI); 551 552 if (pStrings != NULL) { 553 for (int i = 0 ; i < countStrings ; i++) { 554 memsetAndFreeStrings(1, pStrings[i]); 555 } 556 557#ifdef MEMSET_FREED 558 memset(pStrings, 0, countStrings * sizeof(char *)); 559#endif 560 free(pStrings); 561 } 562 return true; 563} 564 565bool dispatchInts(int serial, int slotId, int request, int countInts, ...) { 566 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 567 if (pRI == NULL) { 568 return false; 569 } 570 571 android::Parcel p; // TODO: should delete this after translation of all commands is complete 572 573 int *pInts = (int *)calloc(countInts, sizeof(int)); 574 if (pInts == NULL) { 575 RLOGE("Memory allocation failed for request %s", requestToString(request)); 576 pRI->pCI->responseFunction(p, (int) pRI->socket_id, request, 577 (int) RadioResponseType::SOLICITED, pRI->token, RIL_E_NO_MEMORY, NULL, 0); 578 return false; 579 } 580 va_list ap; 581 va_start(ap, countInts); 582 for (int i = 0; i < countInts; i++) { 583 pInts[i] = va_arg(ap, int); 584 } 585 va_end(ap); 586 587 s_vendorFunctions->onRequest(request, pInts, countInts * sizeof(int), pRI); 588 589 if (pInts != NULL) { 590#ifdef MEMSET_FREED 591 memset(pInts, 0, countInts * sizeof(int)); 592#endif 593 free(pInts); 594 } 595 return true; 596} 597 598bool dispatchCallForwardStatus(int serial, int slotId, int request, 599 const CallForwardInfo& callInfo) { 600 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 601 if (pRI == NULL) { 602 return false; 603 } 604 605 RIL_CallForwardInfo cf; 606 cf.status = (int) callInfo.status; 607 cf.reason = callInfo.reason; 608 cf.serviceClass = callInfo.serviceClass; 609 cf.toa = callInfo.toa; 610 cf.timeSeconds = callInfo.timeSeconds; 611 612 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) { 613 return false; 614 } 615 616 s_vendorFunctions->onRequest(request, &cf, sizeof(cf), pRI); 617 618 memsetAndFreeStrings(1, cf.number); 619 620 return true; 621} 622 623bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) { 624 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 625 if (pRI == NULL) { 626 return false; 627 } 628 629 const uint8_t *uData = rawBytes.data(); 630 631 s_vendorFunctions->onRequest(request, (void *) uData, rawBytes.size(), pRI); 632 633 return true; 634} 635 636bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) { 637 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 638 if (pRI == NULL) { 639 return false; 640 } 641 642 RIL_SIM_APDU apdu; 643 memset (&apdu, 0, sizeof(RIL_SIM_APDU)); 644 645 apdu.sessionid = message.sessionId; 646 apdu.cla = message.cla; 647 apdu.instruction = message.instruction; 648 apdu.p1 = message.p1; 649 apdu.p2 = message.p2; 650 apdu.p3 = message.p3; 651 652 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) { 653 return false; 654 } 655 656 s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI); 657 658 memsetAndFreeStrings(1, apdu.data); 659 660 return true; 661} 662 663void RadioImpl::checkReturnStatus(Return<void>& ret) { 664 if (ret.isOk() == false) { 665 RLOGE("RadioImpl::checkReturnStatus: unable to call response/indication callback"); 666 // Remote process hosting the callbacks must be dead. Reset the callback objects; 667 // there's no other recovery to be done here. When the client process is back up, it will 668 // call setResponseFunctions() 669 670 // Caller should already hold rdlock, release that first 671 // note the current counter to avoid overwriting updates made by another thread before 672 // write lock is acquired. 673 int counter = mCounter; 674 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId); 675 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr); 676 assert(ret == 0); 677 678 // acquire wrlock 679 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr); 680 assert(ret == 0); 681 682 // make sure the counter value has not changed 683 if (counter == mCounter) { 684 mRadioResponse = NULL; 685 mRadioIndication = NULL; 686 mCounter++; 687 } else { 688 RLOGE("RadioImpl::checkReturnStatus: not resetting responseFunctions as they likely" 689 "got updated on another thread"); 690 } 691 692 // release wrlock 693 ret = pthread_rwlock_unlock(radioServiceRwlockPtr); 694 assert(ret == 0); 695 696 // Reacquire rdlock 697 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr); 698 assert(ret == 0); 699 } 700} 701 702Return<void> RadioImpl::setResponseFunctions( 703 const ::android::sp<IRadioResponse>& radioResponseParam, 704 const ::android::sp<IRadioIndication>& radioIndicationParam) { 705 RLOGD("RadioImpl::setResponseFunctions"); 706 707 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId); 708 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr); 709 assert(ret == 0); 710 711 mRadioResponse = radioResponseParam; 712 mRadioIndication = radioIndicationParam; 713 mCounter++; 714 715 ret = pthread_rwlock_unlock(radioServiceRwlockPtr); 716 assert(ret == 0); 717 718 return Void(); 719} 720 721Return<void> RadioImpl::getIccCardStatus(int32_t serial) { 722 RLOGD("RadioImpl::getIccCardStatus: serial %d", serial); 723 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS); 724 return Void(); 725} 726 727Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin, 728 const hidl_string& aid) { 729 RLOGD("RadioImpl::supplyIccPinForApp: serial %d", serial); 730 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN, 731 2, (const char *)pin, (const char *)aid); 732 return Void(); 733} 734 735Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk, 736 const hidl_string& pin, const hidl_string& aid) { 737 RLOGD("RadioImpl::supplyIccPukForApp: serial %d", serial); 738 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK, 739 3, (const char *)puk, (const char *)pin, (const char *)aid); 740 return Void(); 741} 742 743Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2, 744 const hidl_string& aid) { 745 RLOGD("RadioImpl::supplyIccPin2ForApp: serial %d", serial); 746 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2, 747 2, (const char *)pin2, (const char *)aid); 748 return Void(); 749} 750 751Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2, 752 const hidl_string& pin2, const hidl_string& aid) { 753 RLOGD("RadioImpl::supplyIccPuk2ForApp: serial %d", serial); 754 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2, 755 3, (const char *)puk2, (const char *)pin2, (const char *)aid); 756 return Void(); 757} 758 759Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin, 760 const hidl_string& newPin, const hidl_string& aid) { 761 RLOGD("RadioImpl::changeIccPinForApp: serial %d", serial); 762 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN, 763 3, (const char *)oldPin, (const char *)newPin, (const char *)aid); 764 return Void(); 765} 766 767Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2, 768 const hidl_string& newPin2, const hidl_string& aid) { 769 RLOGD("RadioImpl::changeIccPin2ForApp: serial %d", serial); 770 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2, 771 3, (const char *)oldPin2, (const char *)newPin2, (const char *)aid); 772 return Void(); 773} 774 775Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial, 776 const hidl_string& netPin) { 777 RLOGD("RadioImpl::supplyNetworkDepersonalization: serial %d", serial); 778 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, 779 1, (const char *)netPin); 780 return Void(); 781} 782 783Return<void> RadioImpl::getCurrentCalls(int32_t serial) { 784 RLOGD("RadioImpl::getCurrentCalls: serial %d", serial); 785 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS); 786 return Void(); 787} 788 789Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) { 790 RLOGD("RadioImpl::dial: serial %d", serial); 791 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL); 792 if (pRI == NULL) { 793 return Void(); 794 } 795 RIL_Dial dial; 796 RIL_UUS_Info uusInfo; 797 int32_t sizeOfDial = sizeof(dial); 798 799 memset (&dial, 0, sizeOfDial); 800 801 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) { 802 return Void(); 803 } 804 dial.clir = (int)dialInfo.clir; 805 806 memset(&uusInfo, 0, sizeof(RIL_UUS_Info)); 807 if (dialInfo.uusInfo.size() != 0) { 808 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType; 809 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs; 810 811 if (dialInfo.uusInfo[0].uusData.size() == 0) { 812 uusInfo.uusData = NULL; 813 uusInfo.uusLength = 0; 814 } else { 815 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) { 816 memsetAndFreeStrings(1, dial.address); 817 return Void(); 818 } 819 uusInfo.uusLength = strlen(dialInfo.uusInfo[0].uusData); 820 } 821 822 dial.uusInfo = &uusInfo; 823 } 824 825 s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI); 826 827 memsetAndFreeStrings(2, dial.address, uusInfo.uusData); 828 829 return Void(); 830} 831 832Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) { 833 RLOGD("RadioImpl::getImsiForApp: serial %d", serial); 834 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI, 835 1, (const char *) aid); 836 return Void(); 837} 838 839Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) { 840 RLOGD("RadioImpl::hangup: serial %d", serial); 841 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex); 842 return Void(); 843} 844 845Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) { 846 RLOGD("RadioImpl::hangupWaitingOrBackground: serial %d", serial); 847 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND); 848 return Void(); 849} 850 851Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) { 852 RLOGD("RadioImpl::hangupForegroundResumeBackground: serial %d", serial); 853 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND); 854 return Void(); 855} 856 857Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) { 858 RLOGD("RadioImpl::switchWaitingOrHoldingAndActive: serial %d", serial); 859 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE); 860 return Void(); 861} 862 863Return<void> RadioImpl::conference(int32_t serial) { 864 RLOGD("RadioImpl::conference: serial %d", serial); 865 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE); 866 return Void(); 867} 868 869Return<void> RadioImpl::rejectCall(int32_t serial) { 870 RLOGD("RadioImpl::rejectCall: serial %d", serial); 871 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB); 872 return Void(); 873} 874 875Return<void> RadioImpl::getLastCallFailCause(int32_t serial) { 876 RLOGD("RadioImpl::getLastCallFailCause: serial %d", serial); 877 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE); 878 return Void(); 879} 880 881Return<void> RadioImpl::getSignalStrength(int32_t serial) { 882 RLOGD("RadioImpl::getSignalStrength: serial %d", serial); 883 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH); 884 return Void(); 885} 886 887Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) { 888 RLOGD("RadioImpl::getVoiceRegistrationState: serial %d", serial); 889 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE); 890 return Void(); 891} 892 893Return<void> RadioImpl::getDataRegistrationState(int32_t serial) { 894 RLOGD("RadioImpl::getDataRegistrationState: serial %d", serial); 895 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE); 896 return Void(); 897} 898 899Return<void> RadioImpl::getOperator(int32_t serial) { 900 RLOGD("RadioImpl::getOperator: serial %d", serial); 901 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR); 902 return Void(); 903} 904 905Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) { 906 RLOGD("RadioImpl::setRadioPower: serial %d on %d", serial, on); 907 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on)); 908 return Void(); 909} 910 911Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) { 912 RLOGD("RadioImpl::sendDtmf: serial %d", serial); 913 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, (const char *) s); 914 return Void(); 915} 916 917Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) { 918 RLOGD("RadioImpl::sendSms: serial %d", serial); 919 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, 920 2, (const char *) message.smscPdu, (const char *) message.pdu); 921 return Void(); 922} 923 924Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) { 925 RLOGD("RadioImpl::sendSMSExpectMore: serial %d", serial); 926 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, 927 2, (const char *) message.smscPdu, (const char *) message.pdu); 928 return Void(); 929} 930 931Return<void> RadioImpl::setupDataCall(int32_t serial, 932 RadioTechnology radioTechnology, 933 const DataProfileInfo& profileInfo, 934 bool modemCognitive, 935 bool roamingAllowed) { 936 RLOGD("RadioImpl::setupDataCall: serial %d", serial); 937 938 // todo: dispatch request 939 940 return Void(); 941} 942 943Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) { 944 RLOGD("RadioImpl::iccIOForApp: serial %d", serial); 945 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO); 946 if (pRI == NULL) { 947 return Void(); 948 } 949 950 RIL_SIM_IO_v6 rilIccIo; 951 rilIccIo.command = iccIo.command; 952 rilIccIo.fileid = iccIo.fileId; 953 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) { 954 return Void(); 955 } 956 957 rilIccIo.p1 = iccIo.p1; 958 rilIccIo.p2 = iccIo.p2; 959 rilIccIo.p3 = iccIo.p3; 960 961 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) { 962 memsetAndFreeStrings(1, rilIccIo.path); 963 return Void(); 964 } 965 966 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) { 967 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data); 968 return Void(); 969 } 970 971 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) { 972 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2); 973 return Void(); 974 } 975 976 s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI); 977 978 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr); 979 980 return Void(); 981} 982 983Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) { 984 RLOGD("RadioImpl::sendUssd: serial %d", serial); 985 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, (const char *) ussd); 986 return Void(); 987} 988 989Return<void> RadioImpl::cancelPendingUssd(int32_t serial) { 990 RLOGD("RadioImpl::cancelPendingUssd: serial %d", serial); 991 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD); 992 return Void(); 993} 994 995Return<void> RadioImpl::getClir(int32_t serial) { 996 RLOGD("RadioImpl::getClir: serial %d", serial); 997 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR); 998 return Void(); 999} 1000 1001Return<void> RadioImpl::setClir(int32_t serial, int32_t status) { 1002 RLOGD("RadioImpl::setClir: serial %d", serial); 1003 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status); 1004 return Void(); 1005} 1006 1007Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) { 1008 RLOGD("RadioImpl::getCallForwardStatus: serial %d", serial); 1009 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS, 1010 callInfo); 1011 return Void(); 1012} 1013 1014Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) { 1015 RLOGD("RadioImpl::setCallForward: serial %d", serial); 1016 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD, 1017 callInfo); 1018 return Void(); 1019} 1020 1021Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) { 1022 RLOGD("RadioImpl::getCallWaiting: serial %d", serial); 1023 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass); 1024 return Void(); 1025} 1026 1027Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) { 1028 RLOGD("RadioImpl::setCallWaiting: serial %d", serial); 1029 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable), 1030 serviceClass); 1031 return Void(); 1032} 1033 1034Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial, 1035 bool success, SmsAcknowledgeFailCause cause) { 1036 RLOGD("RadioImpl::acknowledgeLastIncomingGsmSms: serial %d", serial); 1037 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success), 1038 cause); 1039 return Void(); 1040} 1041 1042Return<void> RadioImpl::acceptCall(int32_t serial) { 1043 RLOGD("RadioImpl::acceptCall: serial %d", serial); 1044 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER); 1045 return Void(); 1046} 1047 1048Return<void> RadioImpl::deactivateDataCall(int32_t serial, 1049 int32_t cid, bool reasonRadioShutDown) { 1050 RLOGD("RadioImpl::deactivateDataCall: serial %d", serial); 1051 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, 1052 2, (const char *) (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0"); 1053 return Void(); 1054} 1055 1056Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility, 1057 const hidl_string& password, int32_t serviceClass, 1058 const hidl_string& appId) { 1059 RLOGD("RadioImpl::getFacilityLockForApp: serial %d", serial); 1060 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK, 1061 4, (const char *) facility, (const char *) password, 1062 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId); 1063 return Void(); 1064} 1065 1066Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility, 1067 bool lockState, const hidl_string& password, 1068 int32_t serviceClass, const hidl_string& appId) { 1069 RLOGD("RadioImpl::setFacilityLockForApp: serial %d", serial); 1070 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK, 1071 5, (const char *) facility, lockState ? "1" : "0", (const char *) password, 1072 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId); 1073 return Void(); 1074} 1075 1076Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility, 1077 const hidl_string& oldPassword, 1078 const hidl_string& newPassword) { 1079 RLOGD("RadioImpl::setBarringPassword: serial %d", serial); 1080 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD, 1081 2, (const char *) oldPassword, (const char *) newPassword); 1082 return Void(); 1083} 1084 1085Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) { 1086 RLOGD("RadioImpl::getNetworkSelectionMode: serial %d", serial); 1087 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE); 1088 return Void(); 1089} 1090 1091Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) { 1092 RLOGD("RadioImpl::setNetworkSelectionModeAutomatic: serial %d", serial); 1093 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC); 1094 return Void(); 1095} 1096 1097Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial, 1098 const hidl_string& operatorNumeric) { 1099 RLOGD("RadioImpl::setNetworkSelectionModeManual: serial %d", serial); 1100 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL, 1101 (const char *) operatorNumeric); 1102 return Void(); 1103} 1104 1105Return<void> RadioImpl::getAvailableNetworks(int32_t serial) { 1106 RLOGD("RadioImpl::getAvailableNetworks: serial %d", serial); 1107 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS); 1108 return Void(); 1109} 1110 1111Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) { 1112 RLOGD("RadioImpl::startDtmf: serial %d", serial); 1113 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START, 1114 (const char *) s); 1115 return Void(); 1116} 1117 1118Return<void> RadioImpl::stopDtmf(int32_t serial) { 1119 RLOGD("RadioImpl::stopDtmf: serial %d", serial); 1120 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP); 1121 return Void(); 1122} 1123 1124Return<void> RadioImpl::getBasebandVersion(int32_t serial) { 1125 RLOGD("RadioImpl::getBasebandVersion: serial %d", serial); 1126 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION); 1127 return Void(); 1128} 1129 1130Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) { 1131 RLOGD("RadioImpl::separateConnection: serial %d", serial); 1132 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex); 1133 return Void(); 1134} 1135 1136Return<void> RadioImpl::setMute(int32_t serial, bool enable) { 1137 RLOGD("RadioImpl::setMute: serial %d", serial); 1138 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable)); 1139 return Void(); 1140} 1141 1142Return<void> RadioImpl::getMute(int32_t serial) { 1143 RLOGD("RadioImpl::getMute: serial %d", serial); 1144 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE); 1145 return Void(); 1146} 1147 1148Return<void> RadioImpl::getClip(int32_t serial) { 1149 RLOGD("RadioImpl::getClip: serial %d", serial); 1150 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP); 1151 return Void(); 1152} 1153 1154Return<void> RadioImpl::getDataCallList(int32_t serial) { 1155 RLOGD("RadioImpl::getDataCallList: serial %d", serial); 1156 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST); 1157 return Void(); 1158} 1159 1160Return<void> RadioImpl::sendOemRadioRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) { 1161 RLOGD("RadioImpl::sendOemRadioRequestRaw: serial %d", serial); 1162 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data); 1163 return Void(); 1164} 1165 1166Return<void> RadioImpl::sendOemRadioRequestStrings(int32_t serial, 1167 const hidl_vec<hidl_string>& data) { 1168 RLOGD("RadioImpl::sendOemRadioRequestStrings: serial %d", serial); 1169 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data); 1170 return Void(); 1171} 1172 1173Return<void> RadioImpl::sendScreenState(int32_t serial, bool enable) { 1174 RLOGD("RadioImpl::sendScreenState: serial %d", serial); 1175 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(enable)); 1176 return Void(); 1177} 1178 1179Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) { 1180 RLOGD("RadioImpl::setSuppServiceNotifications: serial %d", serial); 1181 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1, 1182 BOOL_TO_INT(enable)); 1183 return Void(); 1184} 1185 1186Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) { 1187 RLOGD("RadioImpl::writeSmsToSim: serial %d", serial); 1188 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM); 1189 if (pRI == NULL) { 1190 return Void(); 1191 } 1192 1193 RIL_SMS_WriteArgs args; 1194 args.status = (int) smsWriteArgs.status; 1195 1196 int len; 1197 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) { 1198 return Void(); 1199 } 1200 1201 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) { 1202 memsetAndFreeStrings(1, args.pdu); 1203 return Void(); 1204 } 1205 1206 s_vendorFunctions->onRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI); 1207 1208 memsetAndFreeStrings(2, args.smsc, args.pdu); 1209 1210 return Void(); 1211} 1212 1213Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) { 1214 RLOGD("RadioImpl::deleteSmsOnSim: serial %d", serial); 1215 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index); 1216 return Void(); 1217} 1218 1219Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) { 1220 RLOGD("RadioImpl::setBandMode: serial %d", serial); 1221 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode); 1222 return Void(); 1223} 1224 1225Return<void> RadioImpl::getAvailableBandModes(int32_t serial) { 1226 RLOGD("RadioImpl::getAvailableBandModes: serial %d", serial); 1227 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE); 1228 return Void(); 1229} 1230 1231Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) { 1232 RLOGD("RadioImpl::sendEnvelope: serial %d", serial); 1233 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND, 1234 (const char *) command); 1235 return Void(); 1236} 1237 1238Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial, 1239 const hidl_string& commandResponse) { 1240 RLOGD("RadioImpl::sendTerminalResponseToSim: serial %d", serial); 1241 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE, 1242 (const char *) commandResponse); 1243 return Void(); 1244} 1245 1246Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) { 1247 RLOGD("RadioImpl::handleStkCallSetupRequestFromSim: serial %d", serial); 1248 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM, 1249 1, BOOL_TO_INT(accept)); 1250 return Void(); 1251} 1252 1253Return<void> RadioImpl::explicitCallTransfer(int32_t serial) { 1254 RLOGD("RadioImpl::explicitCallTransfer: serial %d", serial); 1255 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER); 1256 return Void(); 1257} 1258 1259Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) { 1260 RLOGD("RadioImpl::setPreferredNetworkType: serial %d", serial); 1261 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType); 1262 return Void(); 1263} 1264 1265Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) { 1266 RLOGD("RadioImpl::getPreferredNetworkType: serial %d", serial); 1267 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE); 1268 return Void(); 1269} 1270 1271Return<void> RadioImpl::getNeighboringCids(int32_t serial) { 1272 RLOGD("RadioImpl::getNeighboringCids: serial %d", serial); 1273 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS); 1274 return Void(); 1275} 1276 1277Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) { 1278 RLOGD("RadioImpl::setLocationUpdates: serial %d", serial); 1279 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable)); 1280 return Void(); 1281} 1282 1283Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) { 1284 RLOGD("RadioImpl::setCdmaSubscriptionSource: serial %d", serial); 1285 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub); 1286 return Void(); 1287} 1288 1289Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) { 1290 RLOGD("RadioImpl::setCdmaRoamingPreference: serial %d", serial); 1291 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type); 1292 return Void(); 1293} 1294 1295Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) { 1296 RLOGD("RadioImpl::getCdmaRoamingPreference: serial %d", serial); 1297 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE); 1298 return Void(); 1299} 1300 1301Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) { 1302 RLOGD("RadioImpl::setTTYMode: serial %d", serial); 1303 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode); 1304 return Void(); 1305} 1306 1307Return<void> RadioImpl::getTTYMode(int32_t serial) { 1308 RLOGD("RadioImpl::getTTYMode: serial %d", serial); 1309 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE); 1310 return Void(); 1311} 1312 1313Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) { 1314 RLOGD("RadioImpl::setPreferredVoicePrivacy: serial %d", serial); 1315 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE, 1316 1, BOOL_TO_INT(enable)); 1317 return Void(); 1318} 1319 1320Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) { 1321 RLOGD("RadioImpl::getPreferredVoicePrivacy: serial %d", serial); 1322 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE); 1323 return Void(); 1324} 1325 1326Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) { 1327 RLOGD("RadioImpl::sendCDMAFeatureCode: serial %d", serial); 1328 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH, 1329 (const char *) featureCode); 1330 return Void(); 1331} 1332 1333Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on, 1334 int32_t off) { 1335 RLOGD("RadioImpl::sendBurstDtmf: serial %d", serial); 1336 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF, 1337 3, (const char *) dtmf, (const char *) (std::to_string(on)).c_str(), 1338 (const char *) (std::to_string(off)).c_str()); 1339 return Void(); 1340} 1341 1342void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) { 1343 memset(&rcsm, 0, sizeof(rcsm)); 1344 1345 rcsm.uTeleserviceID = sms.teleserviceId; 1346 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent); 1347 rcsm.uServicecategory = sms.serviceCategory; 1348 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode; 1349 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode; 1350 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType; 1351 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan; 1352 1353 rcsm.sAddress.number_of_digits = sms.address.digits.size(); 1354 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); 1355 for (int i = 0; i < digitLimit; i++) { 1356 rcsm.sAddress.digits[i] = sms.address.digits[i]; 1357 } 1358 1359 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType; 1360 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd); 1361 1362 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size(); 1363 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); 1364 for (int i = 0; i < digitLimit; i++) { 1365 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i]; 1366 } 1367 1368 rcsm.uBearerDataLen = sms.bearerData.size(); 1369 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); 1370 for (int i = 0; i < digitLimit; i++) { 1371 rcsm.aBearerData[i] = sms.bearerData[i]; 1372 } 1373} 1374 1375Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) { 1376 RLOGD("RadioImpl::sendCdmaSms: serial %d", serial); 1377 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS); 1378 if (pRI == NULL) { 1379 return Void(); 1380 } 1381 1382 RIL_CDMA_SMS_Message rcsm; 1383 constructCdmaSms(rcsm, sms); 1384 1385 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI); 1386 return Void(); 1387} 1388 1389Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) { 1390 RLOGD("RadioImpl::acknowledgeLastIncomingCdmaSms: serial %d", serial); 1391 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE); 1392 if (pRI == NULL) { 1393 return Void(); 1394 } 1395 1396 RIL_CDMA_SMS_Ack rcsa; 1397 memset(&rcsa, 0, sizeof(rcsa)); 1398 1399 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass; 1400 rcsa.uSMSCauseCode = smsAck.smsCauseCode; 1401 1402 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI); 1403 return Void(); 1404} 1405 1406Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) { 1407 RLOGD("RadioImpl::getGsmBroadcastConfig: serial %d", serial); 1408 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG); 1409 return Void(); 1410} 1411 1412Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial, 1413 const hidl_vec<GsmBroadcastSmsConfigInfo>& 1414 configInfo) { 1415 RLOGD("RadioImpl::setGsmBroadcastConfig: serial %d", serial); 1416 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1417 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG); 1418 if (pRI == NULL) { 1419 return Void(); 1420 } 1421 1422 int num = configInfo.size(); 1423 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num]; 1424 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num]; 1425 1426 for (int i = 0 ; i < num ; i++ ) { 1427 gsmBciPtrs[i] = &gsmBci[i]; 1428 gsmBci[i].fromServiceId = configInfo[i].fromServiceId; 1429 gsmBci[i].toServiceId = configInfo[i].toServiceId; 1430 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme; 1431 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme; 1432 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected); 1433 } 1434 1435 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, gsmBciPtrs, 1436 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI); 1437 return Void(); 1438} 1439 1440Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) { 1441 RLOGD("RadioImpl::setGsmBroadcastActivation: serial %d", serial); 1442 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION, 1443 1, BOOL_TO_INT(!activate)); 1444 return Void(); 1445} 1446 1447Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) { 1448 RLOGD("RadioImpl::getCdmaBroadcastConfig: serial %d", serial); 1449 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG); 1450 return Void(); 1451} 1452 1453Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial, 1454 const hidl_vec<CdmaBroadcastSmsConfigInfo>& 1455 configInfo) { 1456 RLOGD("RadioImpl::setCdmaBroadcastConfig: serial %d", serial); 1457 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1458 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG); 1459 if (pRI == NULL) { 1460 return Void(); 1461 } 1462 1463 int num = configInfo.size(); 1464 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num]; 1465 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num]; 1466 1467 for (int i = 0 ; i < num ; i++ ) { 1468 cdmaBciPtrs[i] = &cdmaBci[i]; 1469 cdmaBci[i].service_category = configInfo[i].serviceCategory; 1470 cdmaBci[i].language = configInfo[i].language; 1471 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected); 1472 } 1473 1474 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, cdmaBciPtrs, 1475 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI); 1476 return Void(); 1477} 1478 1479Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) { 1480 RLOGD("RadioImpl::setCdmaBroadcastActivation: serial %d", serial); 1481 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION, 1482 1, BOOL_TO_INT(!activate)); 1483 return Void(); 1484} 1485 1486Return<void> RadioImpl::getCDMASubscription(int32_t serial) { 1487 RLOGD("RadioImpl::getCDMASubscription: serial %d", serial); 1488 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION); 1489 return Void(); 1490} 1491 1492Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) { 1493 RLOGD("RadioImpl::writeSmsToRuim: serial %d", serial); 1494 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1495 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM); 1496 if (pRI == NULL) { 1497 return Void(); 1498 } 1499 1500 RIL_CDMA_SMS_WriteArgs rcsw; 1501 memset(&rcsw, 0, sizeof(rcsw)); 1502 rcsw.status = (int) cdmaSms.status; 1503 constructCdmaSms(rcsw.message, cdmaSms.message); 1504 1505 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI); 1506 return Void(); 1507} 1508 1509Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) { 1510 RLOGD("RadioImpl::deleteSmsOnRuim: serial %d", serial); 1511 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index); 1512 return Void(); 1513} 1514 1515Return<void> RadioImpl::getDeviceIdentity(int32_t serial) { 1516 RLOGD("RadioImpl::getDeviceIdentity: serial %d", serial); 1517 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY); 1518 return Void(); 1519} 1520 1521Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) { 1522 RLOGD("RadioImpl::exitEmergencyCallbackMode: serial %d", serial); 1523 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE); 1524 return Void(); 1525} 1526 1527Return<void> RadioImpl::getSmscAddress(int32_t serial) { 1528 RLOGD("RadioImpl::getSmscAddress: serial %d", serial); 1529 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS); 1530 return Void(); 1531} 1532 1533Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) { 1534 RLOGD("RadioImpl::setSmscAddress: serial %d", serial); 1535 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS, 1536 (const char *) smsc); 1537 return Void(); 1538} 1539 1540Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) { 1541 RLOGD("RadioImpl::reportSmsMemoryStatus: serial %d", serial); 1542 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1, 1543 BOOL_TO_INT(available)); 1544 return Void(); 1545} 1546 1547Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) { 1548 RLOGD("RadioImpl::reportStkServiceIsRunning: serial %d", serial); 1549 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING); 1550 return Void(); 1551} 1552 1553Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) { 1554 RLOGD("RadioImpl::getCdmaSubscriptionSource: serial %d", serial); 1555 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE); 1556 return Void(); 1557} 1558 1559Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) { 1560 RLOGD("RadioImpl::requestIsimAuthentication: serial %d", serial); 1561 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION, 1562 (const char *) challenge); 1563 return Void(); 1564} 1565 1566Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success, 1567 const hidl_string& ackPdu) { 1568 RLOGD("RadioImpl::acknowledgeIncomingGsmSmsWithPdu: serial %d", serial); 1569 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, 1570 2, success ? "1" : "0", (const char *) ackPdu); 1571 return Void(); 1572} 1573 1574Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) { 1575 RLOGD("RadioImpl::sendEnvelopeWithStatus: serial %d", serial); 1576 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS, 1577 (const char *) contents); 1578 return Void(); 1579} 1580 1581Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) { 1582 RLOGD("RadioImpl::getVoiceRadioTechnology: serial %d", serial); 1583 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH); 1584 return Void(); 1585} 1586 1587Return<void> RadioImpl::getCellInfoList(int32_t serial) { 1588 RLOGD("RadioImpl::getCellInfoList: serial %d", serial); 1589 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST); 1590 return Void(); 1591} 1592 1593Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) { 1594 RLOGD("RadioImpl::setCellInfoListRate: serial %d", serial); 1595 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate); 1596 return Void(); 1597} 1598 1599Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo, 1600 bool modemCognitive) { 1601 RLOGD("RadioImpl::setInitialAttachApn: serial %d", serial); 1602 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1603 RIL_REQUEST_SET_INITIAL_ATTACH_APN); 1604 if (pRI == NULL) { 1605 return Void(); 1606 } 1607 1608 RIL_InitialAttachApn pf; 1609 memset(&pf, 0, sizeof(pf)); 1610 1611 // todo: populate pf 1612 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI); 1613 1614 return Void(); 1615} 1616 1617Return<void> RadioImpl::getImsRegistrationState(int32_t serial) { 1618 RLOGD("RadioImpl::getImsRegistrationState: serial %d", serial); 1619 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE); 1620 return Void(); 1621} 1622 1623bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) { 1624 RIL_IMS_SMS_Message rism; 1625 char **pStrings; 1626 int countStrings = 2; 1627 int dataLen = sizeof(char *) * countStrings; 1628 1629 memset(&rism, 0, sizeof(rism)); 1630 1631 rism.tech = RADIO_TECH_3GPP; 1632 rism.retry = BOOL_TO_INT(message.retry); 1633 rism.messageRef = message.messageRef; 1634 1635 if (message.gsmMessage.size() != 1) { 1636 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber)); 1637 android::Parcel p; 1638 pRI->pCI->responseFunction(p, (int) pRI->socket_id, pRI->pCI->requestNumber, 1639 (int) RadioResponseType::SOLICITED, pRI->token, RIL_E_INVALID_ARGUMENTS, NULL, 0); 1640 return false; 1641 } 1642 1643 pStrings = (char **)calloc(countStrings, sizeof(char *)); 1644 if (pStrings == NULL) { 1645 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s", 1646 requestToString(pRI->pCI->requestNumber)); 1647 android::Parcel p; 1648 pRI->pCI->responseFunction(p, (int) pRI->socket_id, pRI->pCI->requestNumber, 1649 (int) RadioResponseType::SOLICITED, pRI->token, RIL_E_NO_MEMORY, NULL, 0); 1650 return false; 1651 } 1652 1653 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) { 1654#ifdef MEMSET_FREED 1655 memset(pStrings, 0, datalen); 1656#endif 1657 free(pStrings); 1658 return false; 1659 } 1660 1661 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) { 1662 memsetAndFreeStrings(1, pStrings[0]); 1663#ifdef MEMSET_FREED 1664 memset(pStrings, 0, datalen); 1665#endif 1666 free(pStrings); 1667 return false; 1668 } 1669 1670 rism.message.gsmMessage = pStrings; 1671 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + 1672 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI); 1673 1674 for (int i = 0 ; i < countStrings ; i++) { 1675 memsetAndFreeStrings(1, pStrings[i]); 1676 } 1677 1678#ifdef MEMSET_FREED 1679 memset(pStrings, 0, datalen); 1680#endif 1681 free(pStrings); 1682 1683 return true; 1684} 1685 1686bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) { 1687 RIL_IMS_SMS_Message rism; 1688 RIL_CDMA_SMS_Message rcsm; 1689 1690 if (message.cdmaMessage.size() != 1) { 1691 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber)); 1692 android::Parcel p; 1693 pRI->pCI->responseFunction(p, (int) pRI->socket_id, pRI->pCI->requestNumber, 1694 (int) RadioResponseType::SOLICITED, pRI->token, RIL_E_INVALID_ARGUMENTS, NULL, 0); 1695 return false; 1696 } 1697 1698 rism.tech = RADIO_TECH_3GPP2; 1699 rism.retry = BOOL_TO_INT(message.retry); 1700 rism.messageRef = message.messageRef; 1701 rism.message.cdmaMessage = &rcsm; 1702 1703 constructCdmaSms(rcsm, message.cdmaMessage[0]); 1704 1705 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + 1706 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI); 1707 1708 return true; 1709} 1710 1711Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) { 1712 RLOGD("RadioImpl::sendImsSms: serial %d", serial); 1713 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS); 1714 if (pRI == NULL) { 1715 return Void(); 1716 } 1717 1718 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech; 1719 1720 if (RADIO_TECH_3GPP == format) { 1721 dispatchImsGsmSms(message, pRI); 1722 } else if (RADIO_TECH_3GPP2 == format) { 1723 dispatchImsCdmaSms(message, pRI); 1724 } else { 1725 RLOGE("RadioImpl::sendImsSms: Invalid radio tech %s", 1726 requestToString(pRI->pCI->requestNumber)); 1727 android::Parcel p; 1728 pRI->pCI->responseFunction(p, (int) pRI->socket_id, pRI->pCI->requestNumber, 1729 (int) RadioResponseType::SOLICITED, pRI->token, RIL_E_INVALID_ARGUMENTS, NULL, 0); 1730 } 1731 return Void(); 1732} 1733 1734Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) { 1735 RLOGD("RadioImpl::iccTransmitApduBasicChannel: serial %d", serial); 1736 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message); 1737 return Void(); 1738} 1739 1740Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid) { 1741 RLOGD("RadioImpl::iccOpenLogicalChannel: serial %d", serial); 1742 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, 1743 (const char *) aid); 1744 return Void(); 1745} 1746 1747Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) { 1748 RLOGD("RadioImpl::iccCloseLogicalChannel: serial %d", serial); 1749 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId); 1750 return Void(); 1751} 1752 1753Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) { 1754 RLOGD("RadioImpl::iccTransmitApduLogicalChannel: serial %d", serial); 1755 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message); 1756 return Void(); 1757} 1758 1759Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) { 1760 RLOGD("RadioImpl::nvReadItem: serial %d", serial); 1761 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM); 1762 if (pRI == NULL) { 1763 return Void(); 1764 } 1765 1766 RIL_NV_ReadItem nvri; 1767 memset (&nvri, 0, sizeof(nvri)); 1768 nvri.itemID = (RIL_NV_Item) itemId; 1769 1770 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI); 1771 return Void(); 1772} 1773 1774Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) { 1775 RLOGD("RadioImpl::nvWriteItem: serial %d", serial); 1776 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM); 1777 if (pRI == NULL) { 1778 return Void(); 1779 } 1780 1781 RIL_NV_WriteItem nvwi; 1782 memset (&nvwi, 0, sizeof(nvwi)); 1783 1784 nvwi.itemID = (RIL_NV_Item) item.itemId; 1785 1786 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) { 1787 return Void(); 1788 } 1789 1790 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI); 1791 1792 memsetAndFreeStrings(1, nvwi.value); 1793 return Void(); 1794} 1795 1796Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) { 1797 RLOGD("RadioImpl::nvWriteCdmaPrl: serial %d", serial); 1798 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl); 1799 return Void(); 1800} 1801 1802Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) { 1803 RLOGD("RadioImpl::nvResetConfig: serial %d", serial); 1804 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, (int) resetType); 1805 return Void(); 1806} 1807 1808Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) { 1809 RLOGD("RadioImpl::setUiccSubscription: serial %d", serial); 1810 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1811 RIL_REQUEST_SET_UICC_SUBSCRIPTION); 1812 if (pRI == NULL) { 1813 return Void(); 1814 } 1815 1816 RIL_SelectUiccSub rilUiccSub; 1817 memset(&rilUiccSub, 0, sizeof(rilUiccSub)); 1818 1819 rilUiccSub.slot = uiccSub.slot; 1820 rilUiccSub.app_index = uiccSub.appIndex; 1821 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType; 1822 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus; 1823 1824 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI); 1825 return Void(); 1826} 1827 1828Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) { 1829 RLOGD("RadioImpl::setDataAllowed: serial %d", serial); 1830 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow)); 1831 return Void(); 1832} 1833 1834Return<void> RadioImpl::getHardwareConfig(int32_t serial) { 1835 RLOGD("RadioImpl::getHardwareConfig: serial %d", serial); 1836 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG); 1837 return Void(); 1838} 1839 1840Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext, 1841 const hidl_string& authData, const hidl_string& aid) { 1842 RLOGD("RadioImpl::requestIccSimAuthentication: serial %d", serial); 1843 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION); 1844 if (pRI == NULL) { 1845 return Void(); 1846 } 1847 1848 RIL_SimAuthentication pf; 1849 memset (&pf, 0, sizeof(pf)); 1850 1851 pf.authContext = authContext; 1852 1853 int len; 1854 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) { 1855 return Void(); 1856 } 1857 1858 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) { 1859 memsetAndFreeStrings(1, pf.authData); 1860 return Void(); 1861 } 1862 1863 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI); 1864 1865 memsetAndFreeStrings(2, pf.authData, pf.aid); 1866 return Void(); 1867} 1868 1869/** 1870 * dataProfilePtrs are contained in dataProfiles (dataProfilePtrs[i] = &dataProfiles[i]) 1871 **/ 1872void freeSetDataProfileData(int num, RIL_DataProfileInfo *dataProfiles, 1873 RIL_DataProfileInfo **dataProfilePtrs, int freeNumProfiles) { 1874 for (int i = 0; i < freeNumProfiles; i++) { 1875 memsetAndFreeStrings(4, dataProfiles[i].apn, dataProfiles[i].protocol, dataProfiles[i].user, 1876 dataProfiles[i].password); 1877 } 1878 1879#ifdef MEMSET_FREED 1880 memset(dataProfiles, 0, num * sizeof(RIL_DataProfileInfo)); 1881 memset(dataProfilePtrs, 0, num * sizeof(RIL_DataProfileInfo *)); 1882#endif 1883 free(dataProfiles); 1884 free(dataProfilePtrs); 1885} 1886 1887Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles) { 1888 RLOGD("RadioImpl::setDataProfile: serial %d", serial); 1889 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE); 1890 if (pRI == NULL) { 1891 return Void(); 1892 } 1893 1894 // todo - dispatch request 1895 1896 return Void(); 1897} 1898 1899Return<void> RadioImpl::requestShutdown(int32_t serial) { 1900 RLOGD("RadioImpl::requestShutdown: serial %d", serial); 1901 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN); 1902 return Void(); 1903} 1904 1905Return<void> RadioImpl::getRadioCapability(int32_t serial) { 1906 RLOGD("RadioImpl::getRadioCapability: serial %d", serial); 1907 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY); 1908 return Void(); 1909} 1910 1911Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) { 1912 RLOGD("RadioImpl::setRadioCapability: serial %d", serial); 1913 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY); 1914 if (pRI == NULL) { 1915 return Void(); 1916 } 1917 1918 RIL_RadioCapability rilRc; 1919 memset (&rilRc, 0, sizeof(rilRc)); 1920 1921 // TODO : set rilRc.version using HIDL version ? 1922 rilRc.session = rc.session; 1923 rilRc.phase = (int) rc.phase; 1924 rilRc.rat = (int) rc.raf; 1925 rilRc.status = (int) rc.status; 1926 strncpy(rilRc.logicalModemUuid, (const char *) rc.logicalModemUuid, MAX_UUID_LENGTH); 1927 1928 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI); 1929 1930 return Void(); 1931} 1932 1933Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) { 1934 RLOGD("RadioImpl::startLceService: serial %d", serial); 1935 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval, 1936 BOOL_TO_INT(pullMode)); 1937 return Void(); 1938} 1939 1940Return<void> RadioImpl::stopLceService(int32_t serial) { 1941 RLOGD("RadioImpl::stopLceService: serial %d", serial); 1942 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE); 1943 return Void(); 1944} 1945 1946Return<void> RadioImpl::pullLceData(int32_t serial) { 1947 RLOGD("RadioImpl::pullLceData: serial %d", serial); 1948 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA); 1949 return Void(); 1950} 1951 1952Return<void> RadioImpl::getModemActivityInfo(int32_t serial) { 1953 RLOGD("RadioImpl::getModemActivityInfo: serial %d", serial); 1954 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO); 1955 return Void(); 1956} 1957 1958Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed, 1959 const CarrierRestrictions& carriers) { 1960 RLOGD("RadioImpl::setAllowedCarriers: serial %d", serial); 1961 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1962 RIL_REQUEST_SET_CARRIER_RESTRICTIONS); 1963 if (pRI == NULL) { 1964 return Void(); 1965 } 1966 1967 RIL_CarrierRestrictions cr; 1968 RIL_Carrier * allowedCarriers = NULL; 1969 RIL_Carrier * excludedCarriers = NULL; 1970 1971 memset(&cr, 0, sizeof(RIL_CarrierRestrictions)); 1972 1973 cr.len_allowed_carriers = carriers.allowedCarriers.size(); 1974 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier)); 1975 if (allowedCarriers == NULL) { 1976 RLOGE("RadioImpl::setAllowedCarriers: Memory allocation failed for request %s", 1977 requestToString(pRI->pCI->requestNumber)); 1978 android::Parcel p; 1979 pRI->pCI->responseFunction(p, (int) pRI->socket_id, pRI->pCI->requestNumber, 1980 (int) RadioResponseType::SOLICITED, pRI->token, RIL_E_NO_MEMORY, NULL, 0); 1981 return Void(); 1982 } 1983 cr.allowed_carriers = allowedCarriers; 1984 1985 cr.len_excluded_carriers = carriers.excludedCarriers.size(); 1986 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier)); 1987 if (excludedCarriers == NULL) { 1988 RLOGE("RadioImpl::setAllowedCarriers: Memory allocation failed for request %s", 1989 requestToString(pRI->pCI->requestNumber)); 1990 android::Parcel p; 1991 pRI->pCI->responseFunction(p, (int) pRI->socket_id, pRI->pCI->requestNumber, 1992 (int) RadioResponseType::SOLICITED, pRI->token, RIL_E_NO_MEMORY, NULL, 0); 1993#ifdef MEMSET_FREED 1994 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier)); 1995#endif 1996 free(allowedCarriers); 1997 return Void(); 1998 } 1999 cr.excluded_carriers = excludedCarriers; 2000 2001 for (int i = 0; i < cr.len_allowed_carriers; i++) { 2002 allowedCarriers[i].mcc = (const char *) carriers.allowedCarriers[i].mcc; 2003 allowedCarriers[i].mnc = (const char *) carriers.allowedCarriers[i].mnc; 2004 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType; 2005 allowedCarriers[i].match_data = (const char *) carriers.allowedCarriers[i].matchData; 2006 } 2007 2008 for (int i = 0; i < cr.len_allowed_carriers; i++) { 2009 excludedCarriers[i].mcc = (const char *) carriers.excludedCarriers[i].mcc; 2010 excludedCarriers[i].mnc = (const char *) carriers.excludedCarriers[i].mnc; 2011 excludedCarriers[i].match_type = 2012 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType; 2013 excludedCarriers[i].match_data = (const char *) carriers.excludedCarriers[i].matchData; 2014 } 2015 2016 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI); 2017 2018#ifdef MEMSET_FREED 2019 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier)); 2020 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier)); 2021#endif 2022 free(allowedCarriers); 2023 free(excludedCarriers); 2024 return Void(); 2025} 2026 2027Return<void> RadioImpl::getAllowedCarriers(int32_t serial) { 2028 RLOGD("RadioImpl::getAllowedCarriers: serial %d", serial); 2029 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS); 2030 return Void(); 2031} 2032 2033Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state) {return Status::ok();} 2034 2035Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {return Status::ok();} 2036 2037Return<void> RadioImpl::responseAcknowledgement() { 2038 android::releaseWakeLock(); 2039 return Void(); 2040} 2041 2042/*************************************************************************************************** 2043 * RESPONSE FUNCTIONS 2044 * Functions above are used for requests going from framework to vendor code. The ones below are 2045 * responses for those requests coming back from the vendor code. 2046 **************************************************************************************************/ 2047 2048void radio::acknowledgeRequest(int slotId, int serial) { 2049 if (radioService[slotId]->mRadioResponse != NULL) { 2050 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial); 2051 radioService[slotId]->checkReturnStatus(retStatus); 2052 } else { 2053 RLOGE("radio::acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId); 2054 } 2055} 2056 2057void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType, 2058 RIL_Errno e) { 2059 responseInfo.serial = serial; 2060 switch (responseType) { 2061 case RESPONSE_SOLICITED: 2062 responseInfo.type = RadioResponseType::SOLICITED; 2063 break; 2064 case RESPONSE_SOLICITED_ACK_EXP: 2065 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP; 2066 break; 2067 } 2068 responseInfo.error = (RadioError) e; 2069} 2070 2071int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e, 2072 void *response, size_t responseLen) { 2073 populateResponseInfo(responseInfo, serial, responseType, e); 2074 int ret = -1; 2075 2076 if (response == NULL || responseLen != sizeof(int)) { 2077 RLOGE("responseInt: Invalid response"); 2078 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2079 } else { 2080 int *p_int = (int *) response; 2081 ret = p_int[0]; 2082 } 2083 return ret; 2084} 2085 2086int radio::getIccCardStatusResponse(android::Parcel &p, int slotId, int requestNumber, 2087 int responseType, int serial, RIL_Errno e, 2088 void *response, size_t responseLen) { 2089 if (radioService[slotId]->mRadioResponse != NULL) { 2090 RadioResponseInfo responseInfo; 2091 populateResponseInfo(responseInfo, serial, responseType, e); 2092 CardStatus cardStatus; 2093 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) { 2094 RLOGE("radio::getIccCardStatusResponse: Invalid response"); 2095 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2096 memset(&cardStatus, 0, sizeof(cardStatus)); 2097 } else { 2098 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response); 2099 cardStatus.cardState = (CardState) p_cur->card_state; 2100 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state; 2101 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index; 2102 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index; 2103 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index; 2104 2105 RIL_AppStatus *rilAppStatus = p_cur->applications; 2106 cardStatus.applications.resize(p_cur->num_applications); 2107 AppStatus *appStatus = cardStatus.applications.data(); 2108 RLOGD("radio::getIccCardStatusResponse: num_applications %d", p_cur->num_applications); 2109 for (int i = 0; i < p_cur->num_applications; i++) { 2110 appStatus[i].appType = (AppType) rilAppStatus[i].app_type; 2111 appStatus[i].appState = (AppState) rilAppStatus[i].app_state; 2112 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate; 2113 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr); 2114 appStatus[i].appLabelPtr = convertCharPtrToHidlString( 2115 rilAppStatus[i].app_label_ptr); 2116 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced; 2117 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1; 2118 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2; 2119 } 2120 } 2121 2122 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2123 getIccCardStatusResponse(responseInfo, cardStatus); 2124 radioService[slotId]->checkReturnStatus(retStatus); 2125 } else { 2126 RLOGE("radio::getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2127 } 2128 2129 return 0; 2130} 2131 2132int radio::supplyIccPinForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2133 int responseType, int serial, RIL_Errno e, 2134 void *response, size_t responseLen) { 2135 RLOGD("radio::supplyIccPinForAppResponse: serial %d", serial); 2136 2137 if (radioService[slotId]->mRadioResponse != NULL) { 2138 RadioResponseInfo responseInfo; 2139 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2140 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2141 supplyIccPinForAppResponse(responseInfo, ret); 2142 radioService[slotId]->checkReturnStatus(retStatus); 2143 } else { 2144 RLOGE("radio::supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL", 2145 slotId); 2146 } 2147 2148 return 0; 2149} 2150 2151int radio::supplyIccPukForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2152 int responseType, int serial, RIL_Errno e, 2153 void *response, size_t responseLen) { 2154 RLOGD("radio::supplyIccPukForAppResponse: serial %d", serial); 2155 2156 if (radioService[slotId]->mRadioResponse != NULL) { 2157 RadioResponseInfo responseInfo; 2158 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2159 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse( 2160 responseInfo, ret); 2161 radioService[slotId]->checkReturnStatus(retStatus); 2162 } else { 2163 RLOGE("radio::supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL", 2164 slotId); 2165 } 2166 2167 return 0; 2168} 2169 2170int radio::supplyIccPin2ForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2171 int responseType, int serial, RIL_Errno e, 2172 void *response, size_t responseLen) { 2173 RLOGD("radio::supplyIccPin2ForAppResponse: serial %d", serial); 2174 2175 if (radioService[slotId]->mRadioResponse != NULL) { 2176 RadioResponseInfo responseInfo; 2177 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2178 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2179 supplyIccPin2ForAppResponse(responseInfo, ret); 2180 radioService[slotId]->checkReturnStatus(retStatus); 2181 } else { 2182 RLOGE("radio::supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL", 2183 slotId); 2184 } 2185 2186 return 0; 2187} 2188 2189int radio::supplyIccPuk2ForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2190 int responseType, int serial, RIL_Errno e, 2191 void *response, size_t responseLen) { 2192 RLOGD("radio::supplyIccPuk2ForAppResponse: serial %d", serial); 2193 2194 if (radioService[slotId]->mRadioResponse != NULL) { 2195 RadioResponseInfo responseInfo; 2196 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2197 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2198 supplyIccPuk2ForAppResponse(responseInfo, ret); 2199 radioService[slotId]->checkReturnStatus(retStatus); 2200 } else { 2201 RLOGE("radio::supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL", 2202 slotId); 2203 } 2204 2205 return 0; 2206} 2207 2208int radio::changeIccPinForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2209 int responseType, int serial, RIL_Errno e, 2210 void *response, size_t responseLen) { 2211 RLOGD("radio::changeIccPinForAppResponse: serial %d", serial); 2212 2213 if (radioService[slotId]->mRadioResponse != NULL) { 2214 RadioResponseInfo responseInfo; 2215 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2216 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2217 changeIccPinForAppResponse(responseInfo, ret); 2218 radioService[slotId]->checkReturnStatus(retStatus); 2219 } else { 2220 RLOGE("radio::changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL", 2221 slotId); 2222 } 2223 2224 return 0; 2225} 2226 2227int radio::changeIccPin2ForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2228 int responseType, int serial, RIL_Errno e, 2229 void *response, size_t responseLen) { 2230 RLOGD("radio::changeIccPin2ForAppResponse: serial %d", serial); 2231 2232 if (radioService[slotId]->mRadioResponse != NULL) { 2233 RadioResponseInfo responseInfo; 2234 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2235 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2236 changeIccPin2ForAppResponse(responseInfo, ret); 2237 radioService[slotId]->checkReturnStatus(retStatus); 2238 } else { 2239 RLOGE("radio::changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL", 2240 slotId); 2241 } 2242 2243 return 0; 2244} 2245 2246int radio::supplyNetworkDepersonalizationResponse(android::Parcel &p, int slotId, int requestNumber, 2247 int responseType, int serial, RIL_Errno e, 2248 void *response, size_t responseLen) { 2249 RLOGD("radio::supplyNetworkDepersonalizationResponse: serial %d", serial); 2250 2251 if (radioService[slotId]->mRadioResponse != NULL) { 2252 RadioResponseInfo responseInfo; 2253 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2254 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2255 supplyNetworkDepersonalizationResponse(responseInfo, ret); 2256 radioService[slotId]->checkReturnStatus(retStatus); 2257 } else { 2258 RLOGE("radio::supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == " 2259 "NULL", slotId); 2260 } 2261 2262 return 0; 2263} 2264 2265int radio::getCurrentCallsResponse(android::Parcel &p, int slotId, int requestNumber, 2266 int responseType, int serial, RIL_Errno e, 2267 void *response, size_t responseLen) { 2268 RLOGD("radio::getCurrentCallsResponse: serial %d", serial); 2269 2270 if (radioService[slotId]->mRadioResponse != NULL) { 2271 RadioResponseInfo responseInfo; 2272 populateResponseInfo(responseInfo, serial, responseType, e); 2273 2274 hidl_vec<Call> calls; 2275 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) { 2276 RLOGE("radio::getCurrentCallsResponse: Invalid response"); 2277 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2278 } else { 2279 int num = responseLen / sizeof(RIL_Call *); 2280 calls.resize(num); 2281 2282 for (int i = 0 ; i < num ; i++) { 2283 RIL_Call *p_cur = ((RIL_Call **) response)[i]; 2284 /* each call info */ 2285 calls[i].state = (CallState) p_cur->state; 2286 calls[i].index = p_cur->index; 2287 calls[i].toa = p_cur->toa; 2288 calls[i].isMpty = p_cur->isMpty; 2289 calls[i].isMT = p_cur->isMT; 2290 calls[i].als = p_cur->als; 2291 calls[i].isVoice = p_cur->isVoice; 2292 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy; 2293 calls[i].number = convertCharPtrToHidlString(p_cur->number); 2294 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation; 2295 calls[i].name = convertCharPtrToHidlString(p_cur->name); 2296 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation; 2297 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) { 2298 RIL_UUS_Info *uusInfo = p_cur->uusInfo; 2299 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType; 2300 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs; 2301 // convert uusInfo->uusData to a null-terminated string 2302 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength); 2303 calls[i].uusInfo[0].uusData = nullTermStr; 2304 free(nullTermStr); 2305 } 2306 } 2307 } 2308 2309 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2310 getCurrentCallsResponse(responseInfo, calls); 2311 radioService[slotId]->checkReturnStatus(retStatus); 2312 } else { 2313 RLOGE("radio::getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2314 } 2315 2316 return 0; 2317} 2318 2319int radio::dialResponse(android::Parcel &p, int slotId, int requestNumber, 2320 int responseType, int serial, RIL_Errno e, void *response, 2321 size_t responseLen) { 2322 RLOGD("radio::dialResponse: serial %d", serial); 2323 2324 if (radioService[slotId]->mRadioResponse != NULL) { 2325 RadioResponseInfo responseInfo; 2326 populateResponseInfo(responseInfo, serial, responseType, e); 2327 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo); 2328 radioService[slotId]->checkReturnStatus(retStatus); 2329 } else { 2330 RLOGE("radio::dialResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2331 } 2332 2333 return 0; 2334} 2335 2336int radio::getIMSIForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2337 int responseType, int serial, RIL_Errno e, void *response, 2338 size_t responseLen) { 2339 RLOGD("radio::getIMSIForAppResponse: serial %d", serial); 2340 2341 if (radioService[slotId]->mRadioResponse != NULL) { 2342 RadioResponseInfo responseInfo; 2343 populateResponseInfo(responseInfo, serial, responseType, e); 2344 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse( 2345 responseInfo, convertCharPtrToHidlString((char *) response)); 2346 radioService[slotId]->checkReturnStatus(retStatus); 2347 } else { 2348 RLOGE("radio::getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL", 2349 slotId); 2350 } 2351 2352 return 0; 2353} 2354 2355int radio::hangupConnectionResponse(android::Parcel &p, int slotId, int requestNumber, 2356 int responseType, int serial, RIL_Errno e, 2357 void *response, size_t responseLen) { 2358 RLOGD("radio::hangupConnectionResponse: serial %d", serial); 2359 2360 if (radioService[slotId]->mRadioResponse != NULL) { 2361 RadioResponseInfo responseInfo; 2362 populateResponseInfo(responseInfo, serial, responseType, e); 2363 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse( 2364 responseInfo); 2365 radioService[slotId]->checkReturnStatus(retStatus); 2366 } else { 2367 RLOGE("radio::hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL", 2368 slotId); 2369 } 2370 2371 return 0; 2372} 2373 2374int radio::hangupWaitingOrBackgroundResponse(android::Parcel &p, int slotId, int requestNumber, 2375 int responseType, int serial, RIL_Errno e, 2376 void *response, size_t responseLen) { 2377 RLOGD("radio::hangupWaitingOrBackgroundResponse: serial %d", serial); 2378 2379 if (radioService[slotId]->mRadioResponse != NULL) { 2380 RadioResponseInfo responseInfo; 2381 populateResponseInfo(responseInfo, serial, responseType, e); 2382 Return<void> retStatus = 2383 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse( 2384 responseInfo); 2385 radioService[slotId]->checkReturnStatus(retStatus); 2386 } else { 2387 RLOGE("radio::hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL", 2388 slotId); 2389 } 2390 2391 return 0; 2392} 2393 2394int radio::hangupForegroundResumeBackgroundResponse(android::Parcel &p, int slotId, 2395 int requestNumber, 2396 int responseType, int serial, RIL_Errno e, 2397 void *response, size_t responseLen) { 2398 RLOGD("radio::hangupWaitingOrBackgroundResponse: serial %d", serial); 2399 2400 if (radioService[slotId]->mRadioResponse != NULL) { 2401 RadioResponseInfo responseInfo; 2402 populateResponseInfo(responseInfo, serial, responseType, e); 2403 Return<void> retStatus = 2404 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse( 2405 responseInfo); 2406 radioService[slotId]->checkReturnStatus(retStatus); 2407 } else { 2408 RLOGE("radio::hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL", 2409 slotId); 2410 } 2411 2412 return 0; 2413} 2414 2415int radio::switchWaitingOrHoldingAndActiveResponse(android::Parcel &p, int slotId, 2416 int requestNumber, 2417 int responseType, int serial, RIL_Errno e, 2418 void *response, size_t responseLen) { 2419 RLOGD("radio::switchWaitingOrHoldingAndActiveResponse: serial %d", serial); 2420 2421 if (radioService[slotId]->mRadioResponse != NULL) { 2422 RadioResponseInfo responseInfo; 2423 populateResponseInfo(responseInfo, serial, responseType, e); 2424 Return<void> retStatus = 2425 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse( 2426 responseInfo); 2427 radioService[slotId]->checkReturnStatus(retStatus); 2428 } else { 2429 RLOGE("radio::switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse " 2430 "== NULL", slotId); 2431 } 2432 2433 return 0; 2434} 2435 2436int radio::conferenceResponse(android::Parcel &p, int slotId, int requestNumber, int responseType, 2437 int serial, RIL_Errno e, void *response, size_t responseLen) { 2438 RLOGD("radio::conferenceResponse: serial %d", serial); 2439 2440 if (radioService[slotId]->mRadioResponse != NULL) { 2441 RadioResponseInfo responseInfo; 2442 populateResponseInfo(responseInfo, serial, responseType, e); 2443 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse( 2444 responseInfo); 2445 radioService[slotId]->checkReturnStatus(retStatus); 2446 } else { 2447 RLOGE("radio::conferenceResponse: radioService[%d]->mRadioResponse == NULL", 2448 slotId); 2449 } 2450 2451 return 0; 2452} 2453 2454int radio::rejectCallResponse(android::Parcel &p, int slotId, int requestNumber, int responseType, 2455 int serial, RIL_Errno e, void *response, size_t responseLen) { 2456 RLOGD("radio::rejectCallResponse: serial %d", serial); 2457 2458 if (radioService[slotId]->mRadioResponse != NULL) { 2459 RadioResponseInfo responseInfo; 2460 populateResponseInfo(responseInfo, serial, responseType, e); 2461 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse( 2462 responseInfo); 2463 radioService[slotId]->checkReturnStatus(retStatus); 2464 } else { 2465 RLOGE("radio::rejectCallResponse: radioService[%d]->mRadioResponse == NULL", 2466 slotId); 2467 } 2468 2469 return 0; 2470} 2471 2472int radio::getLastCallFailCauseResponse(android::Parcel &p, int slotId, int requestNumber, 2473 int responseType, int serial, RIL_Errno e, void *response, 2474 size_t responseLen) { 2475 RLOGD("radio::getLastCallFailCauseResponse: serial %d", serial); 2476 2477 if (radioService[slotId]->mRadioResponse != NULL) { 2478 RadioResponseInfo responseInfo; 2479 populateResponseInfo(responseInfo, serial, responseType, e); 2480 LastCallFailCauseInfo info; 2481 memset(&info, 0, sizeof(info)); 2482 info.vendorCause = hidl_string(); 2483 if (response == NULL) { 2484 RLOGE("radio::getCurrentCallsResponse Invalid response: NULL"); 2485 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2486 } else if (responseLen == sizeof(int)) { 2487 int *pInt = (int *) response; 2488 info.causeCode = (LastCallFailCause) pInt[0]; 2489 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) { 2490 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response; 2491 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code; 2492 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause); 2493 } else { 2494 RLOGE("radio::getCurrentCallsResponse Invalid response: NULL"); 2495 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2496 } 2497 2498 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse( 2499 responseInfo, info); 2500 radioService[slotId]->checkReturnStatus(retStatus); 2501 } else { 2502 RLOGE("radio::getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL", 2503 slotId); 2504 } 2505 2506 return 0; 2507} 2508 2509int radio::getVoiceRegistrationStateResponse(android::Parcel &p, int slotId, int requestNumber, 2510 int responseType, int serial, RIL_Errno e, 2511 void *response, size_t responseLen) { 2512 RLOGD("radio::getVoiceRegistrationStateResponse: serial %d", serial); 2513 2514 if (radioService[slotId]->mRadioResponse != NULL) { 2515 RadioResponseInfo responseInfo; 2516 populateResponseInfo(responseInfo, serial, responseType, e); 2517 2518 VoiceRegStateResult voiceRegResponse; 2519 memset(&voiceRegResponse, 0, sizeof(voiceRegResponse)); 2520 2521 int numStrings = responseLen / sizeof(char *); 2522 2523 if (response == NULL || numStrings != 15) { 2524 RLOGE("radio::getVoiceRegistrationStateResponse Invalid response: NULL"); 2525 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2526 } else { 2527 char **resp = (char **) response; 2528 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4); 2529 voiceRegResponse.lac = ATOI_NULL_HANDLED(resp[1]); 2530 voiceRegResponse.cid = ATOI_NULL_HANDLED(resp[2]); 2531 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]); 2532 voiceRegResponse.baseStationId = ATOI_NULL_HANDLED(resp[4]); 2533 voiceRegResponse.baseStationLatitude = ATOI_NULL_HANDLED_DEF(resp[5], INT_MAX); 2534 voiceRegResponse.baseStationLongitude = ATOI_NULL_HANDLED_DEF(resp[6], INT_MAX); 2535 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0); 2536 voiceRegResponse.systemId = ATOI_NULL_HANDLED_DEF(resp[8], 0); 2537 voiceRegResponse.networkId = ATOI_NULL_HANDLED_DEF(resp[9], 0); 2538 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]); 2539 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0); 2540 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0); 2541 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0); 2542 voiceRegResponse.psc = ATOI_NULL_HANDLED(resp[14]); 2543 } 2544 2545 Return<void> retStatus = 2546 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse( 2547 responseInfo, voiceRegResponse); 2548 radioService[slotId]->checkReturnStatus(retStatus); 2549 } else { 2550 RLOGE("radio::getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL", 2551 slotId); 2552 } 2553 2554 return 0; 2555} 2556 2557int radio::getDataRegistrationStateResponse(android::Parcel &p, int slotId, int requestNumber, 2558 int responseType, int serial, RIL_Errno e, 2559 void *response, size_t responseLen) { 2560 RLOGD("radio::getDataRegistrationStateResponse: serial %d", serial); 2561 2562 if (radioService[slotId]->mRadioResponse != NULL) { 2563 RadioResponseInfo responseInfo; 2564 populateResponseInfo(responseInfo, serial, responseType, e); 2565 DataRegStateResult dataRegResponse; 2566 memset(&dataRegResponse, 0, sizeof(dataRegResponse)); 2567 int numStrings = responseLen / sizeof(char *); 2568 if (response == NULL || (numStrings != 6 && numStrings != 11)) { 2569 RLOGE("radio::getDataRegistrationStateResponse Invalid response: NULL"); 2570 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2571 } else { 2572 char **resp = (char **) response; 2573 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4); 2574 dataRegResponse.lac = ATOI_NULL_HANDLED(resp[1]); 2575 dataRegResponse.cid = ATOI_NULL_HANDLED(resp[2]); 2576 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0); 2577 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]); 2578 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1); 2579 if (numStrings == 11) { 2580 dataRegResponse.tac = ATOI_NULL_HANDLED(resp[6]); 2581 dataRegResponse.phyCid = ATOI_NULL_HANDLED(resp[7]); 2582 dataRegResponse.eci = ATOI_NULL_HANDLED(resp[8]); 2583 dataRegResponse.csgid = ATOI_NULL_HANDLED(resp[9]); 2584 dataRegResponse.tadv = ATOI_NULL_HANDLED(resp[10]); 2585 } 2586 } 2587 2588 Return<void> retStatus = 2589 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo, 2590 dataRegResponse); 2591 radioService[slotId]->checkReturnStatus(retStatus); 2592 } else { 2593 RLOGE("radio::getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL", 2594 slotId); 2595 } 2596 2597 return 0; 2598} 2599 2600int radio::getOperatorResponse(android::Parcel &p, int slotId, int requestNumber, 2601 int responseType, int serial, RIL_Errno e, void *response, 2602 size_t responseLen) { 2603 RLOGD("radio::getOperatorResponse: serial %d", serial); 2604 2605 if (radioService[slotId]->mRadioResponse != NULL) { 2606 RadioResponseInfo responseInfo; 2607 populateResponseInfo(responseInfo, serial, responseType, e); 2608 hidl_string longName; 2609 hidl_string shortName; 2610 hidl_string numeric; 2611 int numStrings = responseLen / sizeof(char *); 2612 if (response == NULL || numStrings != 3) { 2613 RLOGE("radio::getOperatorResponse Invalid response: NULL"); 2614 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2615 2616 } else { 2617 char **resp = (char **) response; 2618 longName = convertCharPtrToHidlString(resp[0]); 2619 shortName = convertCharPtrToHidlString(resp[1]); 2620 numeric = convertCharPtrToHidlString(resp[2]); 2621 } 2622 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse( 2623 responseInfo, longName, shortName, numeric); 2624 radioService[slotId]->checkReturnStatus(retStatus); 2625 } else { 2626 RLOGE("radio::getOperatorResponse: radioService[%d]->mRadioResponse == NULL", 2627 slotId); 2628 } 2629 2630 return 0; 2631} 2632 2633int radio::setRadioPowerResponse(android::Parcel &p, int slotId, int requestNumber, 2634 int responseType, int serial, RIL_Errno e, void *response, 2635 size_t responseLen) { 2636 RLOGD("radio::setRadioPowerResponse: serial %d", serial); 2637 2638 if (radioService[slotId]->mRadioResponse != NULL) { 2639 RadioResponseInfo responseInfo; 2640 populateResponseInfo(responseInfo, serial, responseType, e); 2641 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse( 2642 responseInfo); 2643 radioService[slotId]->checkReturnStatus(retStatus); 2644 } else { 2645 RLOGE("radio::setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL", 2646 slotId); 2647 } 2648 2649 return 0; 2650} 2651 2652int radio::sendDtmfResponse(android::Parcel &p, int slotId, int requestNumber, 2653 int responseType, int serial, RIL_Errno e, void *response, 2654 size_t responseLen) { 2655 RLOGD("radio::sendDtmfResponse: serial %d", serial); 2656 2657 if (radioService[slotId]->mRadioResponse != NULL) { 2658 RadioResponseInfo responseInfo; 2659 populateResponseInfo(responseInfo, serial, responseType, e); 2660 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse( 2661 responseInfo); 2662 radioService[slotId]->checkReturnStatus(retStatus); 2663 } else { 2664 RLOGE("radio::sendDtmfResponse: radioService[%d]->mRadioResponse == NULL", 2665 slotId); 2666 } 2667 2668 return 0; 2669} 2670 2671SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType, 2672 RIL_Errno e, void *response, size_t responseLen) { 2673 populateResponseInfo(responseInfo, serial, responseType, e); 2674 SendSmsResult result; 2675 2676 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) { 2677 RLOGE("Invalid response: NULL"); 2678 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2679 memset(&result, 0, sizeof(result)); 2680 result.ackPDU = hidl_string(); 2681 } else { 2682 RIL_SMS_Response *resp = (RIL_SMS_Response *) response; 2683 result.messageRef = resp->messageRef; 2684 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU); 2685 result.errorCode = resp->errorCode; 2686 } 2687 return result; 2688} 2689 2690int radio::sendSmsResponse(android::Parcel &p, int slotId, int requestNumber, 2691 int responseType, int serial, RIL_Errno e, void *response, 2692 size_t responseLen) { 2693 RLOGD("radio::sendSmsResponse: serial %d", serial); 2694 2695 if (radioService[slotId]->mRadioResponse != NULL) { 2696 RadioResponseInfo responseInfo; 2697 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response, 2698 responseLen); 2699 2700 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo, 2701 result); 2702 radioService[slotId]->checkReturnStatus(retStatus); 2703 } else { 2704 RLOGE("radio::sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2705 } 2706 2707 return 0; 2708} 2709 2710int radio::sendSMSExpectMoreResponse(android::Parcel &p, int slotId, int requestNumber, 2711 int responseType, int serial, RIL_Errno e, void *response, 2712 size_t responseLen) { 2713 RLOGD("radio::sendSMSExpectMoreResponse: serial %d", serial); 2714 2715 if (radioService[slotId]->mRadioResponse != NULL) { 2716 RadioResponseInfo responseInfo; 2717 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response, 2718 responseLen); 2719 2720 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse( 2721 responseInfo, result); 2722 radioService[slotId]->checkReturnStatus(retStatus); 2723 } else { 2724 RLOGE("radio::sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2725 } 2726 2727 return 0; 2728} 2729 2730IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType, 2731 RIL_Errno e, void *response, size_t responseLen) { 2732 populateResponseInfo(responseInfo, serial, responseType, e); 2733 IccIoResult result; 2734 2735 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) { 2736 RLOGE("Invalid response: NULL"); 2737 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2738 memset(&result, 0, sizeof(result)); 2739 result.simResponse = hidl_string(); 2740 } else { 2741 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response; 2742 result.sw1 = resp->sw1; 2743 result.sw2 = resp->sw2; 2744 result.simResponse = convertCharPtrToHidlString(resp->simResponse); 2745 } 2746 return result; 2747} 2748 2749int radio::iccIOForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2750 int responseType, int serial, RIL_Errno e, void *response, 2751 size_t responseLen) { 2752 RLOGD("radio::radio::iccIOForAppResponse: serial %d", serial); 2753 2754 if (radioService[slotId]->mRadioResponse != NULL) { 2755 RadioResponseInfo responseInfo; 2756 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response, 2757 responseLen); 2758 2759 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse( 2760 responseInfo, result); 2761 radioService[slotId]->checkReturnStatus(retStatus); 2762 } else { 2763 RLOGE("radio::iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2764 } 2765 2766 return 0; 2767} 2768 2769int radio::sendUssdResponse(android::Parcel &p, int slotId, int requestNumber, 2770 int responseType, int serial, RIL_Errno e, void *response, 2771 size_t responseLen) { 2772 RLOGD("radio::sendUssdResponse: serial %d", serial); 2773 2774 if (radioService[slotId]->mRadioResponse != NULL) { 2775 RadioResponseInfo responseInfo; 2776 populateResponseInfo(responseInfo, serial, responseType, e); 2777 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse( 2778 responseInfo); 2779 radioService[slotId]->checkReturnStatus(retStatus); 2780 } else { 2781 RLOGE("radio::sendUssdResponse: radioService[%d]->mRadioResponse == NULL", 2782 slotId); 2783 } 2784 2785 return 0; 2786} 2787 2788int radio::cancelPendingUssdResponse(android::Parcel &p, int slotId, int requestNumber, 2789 int responseType, int serial, RIL_Errno e, void *response, 2790 size_t responseLen) { 2791 RLOGD("radio::cancelPendingUssdResponse: serial %d", serial); 2792 2793 if (radioService[slotId]->mRadioResponse != NULL) { 2794 RadioResponseInfo responseInfo; 2795 populateResponseInfo(responseInfo, serial, responseType, e); 2796 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse( 2797 responseInfo); 2798 radioService[slotId]->checkReturnStatus(retStatus); 2799 } else { 2800 RLOGE("radio::cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL", 2801 slotId); 2802 } 2803 2804 return 0; 2805} 2806 2807int radio::getClirResponse(android::Parcel &p, int slotId, int requestNumber, 2808 int responseType, int serial, RIL_Errno e, void *response, 2809 size_t responseLen) { 2810 RLOGD("radio::getClirResponse: serial %d", serial); 2811 2812 if (radioService[slotId]->mRadioResponse != NULL) { 2813 RadioResponseInfo responseInfo; 2814 populateResponseInfo(responseInfo, serial, responseType, e); 2815 int n = -1, m = -1; 2816 int numInts = responseLen / sizeof(int); 2817 if (response == NULL || numInts != 2) { 2818 RLOGE("radio::getClirResponse Invalid response: NULL"); 2819 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2820 } else { 2821 int *pInt = (int *) response; 2822 n = pInt[0]; 2823 m = pInt[1]; 2824 } 2825 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo, 2826 n, m); 2827 radioService[slotId]->checkReturnStatus(retStatus); 2828 } else { 2829 RLOGE("radio::getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2830 } 2831 2832 return 0; 2833} 2834 2835int radio::setClirResponse(android::Parcel &p, int slotId, int requestNumber, 2836 int responseType, int serial, RIL_Errno e, void *response, 2837 size_t responseLen) { 2838 RLOGD("radio::setClirResponse: serial %d", serial); 2839 2840 if (radioService[slotId]->mRadioResponse != NULL) { 2841 RadioResponseInfo responseInfo; 2842 populateResponseInfo(responseInfo, serial, responseType, e); 2843 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse( 2844 responseInfo); 2845 radioService[slotId]->checkReturnStatus(retStatus); 2846 } else { 2847 RLOGE("radio::setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2848 } 2849 2850 return 0; 2851} 2852 2853int radio::getCallForwardStatusResponse(android::Parcel &p, int slotId, int requestNumber, 2854 int responseType, int serial, RIL_Errno e, 2855 void *response, size_t responseLen) { 2856 RLOGD("radio::getCallForwardStatusResponse: serial %d", serial); 2857 2858 if (radioService[slotId]->mRadioResponse != NULL) { 2859 RadioResponseInfo responseInfo; 2860 populateResponseInfo(responseInfo, serial, responseType, e); 2861 hidl_vec<CallForwardInfo> callForwardInfos; 2862 2863 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) { 2864 RLOGE("radio::getCallForwardStatusResponse Invalid response: NULL"); 2865 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2866 } else { 2867 int num = responseLen / sizeof(RIL_CallForwardInfo *); 2868 callForwardInfos.resize(num); 2869 for (int i = 0 ; i < num; i++) { 2870 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i]; 2871 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status; 2872 callForwardInfos[i].reason = resp->reason; 2873 callForwardInfos[i].serviceClass = resp->serviceClass; 2874 callForwardInfos[i].toa = resp->toa; 2875 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number); 2876 callForwardInfos[i].timeSeconds = resp->timeSeconds; 2877 } 2878 } 2879 2880 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse( 2881 responseInfo, callForwardInfos); 2882 radioService[slotId]->checkReturnStatus(retStatus); 2883 } else { 2884 RLOGE("radio::getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL", 2885 slotId); 2886 } 2887 2888 return 0; 2889} 2890 2891int radio::setCallForwardResponse(android::Parcel &p, int slotId, int requestNumber, 2892 int responseType, int serial, RIL_Errno e, void *response, 2893 size_t responseLen) { 2894 RLOGD("radio::setCallForwardResponse: serial %d", serial); 2895 2896 if (radioService[slotId]->mRadioResponse != NULL) { 2897 RadioResponseInfo responseInfo; 2898 populateResponseInfo(responseInfo, serial, responseType, e); 2899 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse( 2900 responseInfo); 2901 radioService[slotId]->checkReturnStatus(retStatus); 2902 } else { 2903 RLOGE("radio::setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2904 } 2905 2906 return 0; 2907} 2908 2909int radio::getCallWaitingResponse(android::Parcel &p, int slotId, int requestNumber, 2910 int responseType, int serial, RIL_Errno e, void *response, 2911 size_t responseLen) { 2912 RLOGD("radio::getCallWaitingResponse: serial %d", serial); 2913 2914 if (radioService[slotId]->mRadioResponse != NULL) { 2915 RadioResponseInfo responseInfo; 2916 populateResponseInfo(responseInfo, serial, responseType, e); 2917 bool enable = false; 2918 int serviceClass = -1; 2919 int numInts = responseLen / sizeof(int); 2920 if (response == NULL || numInts != 2) { 2921 RLOGE("radio::getCallWaitingResponse Invalid response: NULL"); 2922 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2923 } else { 2924 int *pInt = (int *) response; 2925 enable = pInt[0] == 1 ? true : false; 2926 serviceClass = pInt[1]; 2927 } 2928 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo, 2929 enable, serviceClass); 2930 radioService[slotId]->checkReturnStatus(retStatus); 2931 } else { 2932 RLOGE("radio::getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2933 } 2934 2935 return 0; 2936} 2937 2938int radio::setCallWaitingResponse(android::Parcel &p, int slotId, int requestNumber, 2939 int responseType, int serial, RIL_Errno e, void *response, 2940 size_t responseLen) { 2941 RLOGD("radio::setCallWaitingResponse: serial %d", serial); 2942 2943 if (radioService[slotId]->mRadioResponse != NULL) { 2944 RadioResponseInfo responseInfo; 2945 populateResponseInfo(responseInfo, serial, responseType, e); 2946 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse( 2947 responseInfo); 2948 radioService[slotId]->checkReturnStatus(retStatus); 2949 } else { 2950 RLOGE("radio::setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2951 } 2952 2953 return 0; 2954} 2955 2956int radio::acknowledgeLastIncomingGsmSmsResponse(android::Parcel &p, int slotId, int requestNumber, 2957 int responseType, int serial, RIL_Errno e, 2958 void *response, size_t responseLen) { 2959 RLOGD("radio::acknowledgeLastIncomingGsmSmsResponse: serial %d", serial); 2960 2961 if (radioService[slotId]->mRadioResponse != NULL) { 2962 RadioResponseInfo responseInfo; 2963 populateResponseInfo(responseInfo, serial, responseType, e); 2964 Return<void> retStatus = 2965 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse( 2966 responseInfo); 2967 radioService[slotId]->checkReturnStatus(retStatus); 2968 } else { 2969 RLOGE("radio::acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse " 2970 "== NULL", slotId); 2971 } 2972 2973 return 0; 2974} 2975 2976int radio::acceptCallResponse(android::Parcel &p, int slotId, int requestNumber, 2977 int responseType, int serial, RIL_Errno e, 2978 void *response, size_t responseLen) { 2979 RLOGD("radio::acceptCallResponse: serial %d", serial); 2980 2981 if (radioService[slotId]->mRadioResponse != NULL) { 2982 RadioResponseInfo responseInfo; 2983 populateResponseInfo(responseInfo, serial, responseType, e); 2984 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse( 2985 responseInfo); 2986 radioService[slotId]->checkReturnStatus(retStatus); 2987 } else { 2988 RLOGE("radio::acceptCallResponse: radioService[%d]->mRadioResponse == NULL", 2989 slotId); 2990 } 2991 2992 return 0; 2993} 2994 2995int radio::deactivateDataCallResponse(android::Parcel &p, int slotId, int requestNumber, 2996 int responseType, int serial, RIL_Errno e, 2997 void *response, size_t responseLen) { 2998 RLOGD("radio::deactivateDataCallResponse: serial %d", serial); 2999 3000 if (radioService[slotId]->mRadioResponse != NULL) { 3001 RadioResponseInfo responseInfo; 3002 populateResponseInfo(responseInfo, serial, responseType, e); 3003 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse( 3004 responseInfo); 3005 radioService[slotId]->checkReturnStatus(retStatus); 3006 } else { 3007 RLOGE("radio::deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL", 3008 slotId); 3009 } 3010 3011 return 0; 3012} 3013 3014int radio::getFacilityLockForAppResponse(android::Parcel &p, int slotId, int requestNumber, 3015 int responseType, int serial, RIL_Errno e, 3016 void *response, size_t responseLen) { 3017 RLOGD("radio::getFacilityLockForAppResponse: serial %d", serial); 3018 3019 if (radioService[slotId]->mRadioResponse != NULL) { 3020 RadioResponseInfo responseInfo; 3021 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 3022 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 3023 getFacilityLockForAppResponse(responseInfo, ret); 3024 radioService[slotId]->checkReturnStatus(retStatus); 3025 } else { 3026 RLOGE("radio::getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL", 3027 slotId); 3028 } 3029 3030 return 0; 3031} 3032 3033int radio::setFacilityLockForAppResponse(android::Parcel &p, int slotId, int requestNumber, 3034 int responseType, int serial, RIL_Errno e, 3035 void *response, size_t responseLen) { 3036 RLOGD("radio::setFacilityLockForAppResponse: serial %d", serial); 3037 3038 if (radioService[slotId]->mRadioResponse != NULL) { 3039 RadioResponseInfo responseInfo; 3040 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 3041 Return<void> retStatus 3042 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo, 3043 ret); 3044 radioService[slotId]->checkReturnStatus(retStatus); 3045 } else { 3046 RLOGE("radio::setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL", 3047 slotId); 3048 } 3049 3050 return 0; 3051} 3052 3053int radio::setBarringPasswordResponse(android::Parcel &p, int slotId, int requestNumber, 3054 int responseType, int serial, RIL_Errno e, 3055 void *response, size_t responseLen) { 3056 RLOGD("radio::acceptCallResponse: serial %d", serial); 3057 3058 if (radioService[slotId]->mRadioResponse != NULL) { 3059 RadioResponseInfo responseInfo; 3060 populateResponseInfo(responseInfo, serial, responseType, e); 3061 Return<void> retStatus 3062 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo); 3063 radioService[slotId]->checkReturnStatus(retStatus); 3064 } else { 3065 RLOGE("radio::setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL", 3066 slotId); 3067 } 3068 3069 return 0; 3070} 3071 3072int radio::getNetworkSelectionModeResponse(android::Parcel &p, int slotId, int requestNumber, 3073 int responseType, int serial, RIL_Errno e, void *response, 3074 size_t responseLen) { 3075 RLOGD("radio::getNetworkSelectionModeResponse: serial %d", serial); 3076 3077 if (radioService[slotId]->mRadioResponse != NULL) { 3078 RadioResponseInfo responseInfo; 3079 populateResponseInfo(responseInfo, serial, responseType, e); 3080 bool manual = false; 3081 int serviceClass; 3082 if (response == NULL || responseLen != sizeof(int)) { 3083 RLOGE("radio::getNetworkSelectionModeResponse Invalid response: NULL"); 3084 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3085 } else { 3086 int *pInt = (int *) response; 3087 manual = pInt[0] == 1 ? true : false; 3088 } 3089 Return<void> retStatus 3090 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse( 3091 responseInfo, 3092 manual); 3093 radioService[slotId]->checkReturnStatus(retStatus); 3094 } else { 3095 RLOGE("radio::getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL", 3096 slotId); 3097 } 3098 3099 return 0; 3100} 3101 3102int radio::setNetworkSelectionModeAutomaticResponse(android::Parcel &p, int slotId, 3103 int requestNumber, 3104 int responseType, int serial, RIL_Errno e, 3105 void *response, size_t responseLen) { 3106 RLOGD("radio::setNetworkSelectionModeAutomaticResponse: serial %d", serial); 3107 3108 if (radioService[slotId]->mRadioResponse != NULL) { 3109 RadioResponseInfo responseInfo; 3110 populateResponseInfo(responseInfo, serial, responseType, e); 3111 Return<void> retStatus 3112 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse( 3113 responseInfo); 3114 radioService[slotId]->checkReturnStatus(retStatus); 3115 } else { 3116 RLOGE("radio::setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse " 3117 "== NULL", slotId); 3118 } 3119 3120 return 0; 3121} 3122 3123int radio::setNetworkSelectionModeManualResponse(android::Parcel &p, int slotId, int requestNumber, 3124 int responseType, int serial, RIL_Errno e, 3125 void *response, size_t responseLen) { 3126 RLOGD("radio::setNetworkSelectionModeManualResponse: serial %d", serial); 3127 3128 if (radioService[slotId]->mRadioResponse != NULL) { 3129 RadioResponseInfo responseInfo; 3130 populateResponseInfo(responseInfo, serial, responseType, e); 3131 Return<void> retStatus 3132 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse( 3133 responseInfo); 3134 radioService[slotId]->checkReturnStatus(retStatus); 3135 } else { 3136 RLOGE("radio::acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse " 3137 "== NULL", slotId); 3138 } 3139 3140 return 0; 3141} 3142 3143int convertOperatorStatusToInt(char * str) { 3144 if (strcmp("unknown", str) == 0) { 3145 return (int) OperatorStatus::UNKNOWN; 3146 } else if (strcmp("available", str) == 0) { 3147 return (int) OperatorStatus::AVAILABLE; 3148 } else if (strcmp("current", str) == 0) { 3149 return (int) OperatorStatus::CURRENT; 3150 } else if (strcmp("forbidden", str) == 0) { 3151 return (int) OperatorStatus::FORBIDDEN; 3152 } else { 3153 return -1; 3154 } 3155} 3156 3157int radio::getAvailableNetworksResponse(android::Parcel &p, int slotId, int requestNumber, 3158 int responseType, int serial, RIL_Errno e, void *response, 3159 size_t responseLen) { 3160 RLOGD("radio::getAvailableNetworksResponse: serial %d", serial); 3161 3162 if (radioService[slotId]->mRadioResponse != NULL) { 3163 RadioResponseInfo responseInfo; 3164 populateResponseInfo(responseInfo, serial, responseType, e); 3165 hidl_vec<OperatorInfo> networks; 3166 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) { 3167 RLOGE("radio::getAvailableNetworksResponse Invalid response: NULL"); 3168 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3169 } else { 3170 char **resp = (char **) response; 3171 int numStrings = responseLen / sizeof(char *); 3172 networks.resize(numStrings/4); 3173 for (int i = 0; i < numStrings; i = i + 4) { 3174 networks[i].alphaLong = convertCharPtrToHidlString(resp[i]); 3175 networks[i].alphaShort = convertCharPtrToHidlString(resp[i + 1]); 3176 networks[i].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]); 3177 int status = convertOperatorStatusToInt(resp[i + 3]); 3178 if (status == -1) { 3179 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3180 } else { 3181 networks[i].status = (OperatorStatus) status; 3182 } 3183 } 3184 } 3185 Return<void> retStatus 3186 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo, 3187 networks); 3188 radioService[slotId]->checkReturnStatus(retStatus); 3189 } else { 3190 RLOGE("radio::getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL", 3191 slotId); 3192 } 3193 3194 return 0; 3195} 3196 3197int radio::startDtmfResponse(android::Parcel &p, int slotId, int requestNumber, 3198 int responseType, int serial, RIL_Errno e, 3199 void *response, size_t responseLen) { 3200 RLOGD("radio::startDtmfResponse: serial %d", serial); 3201 3202 if (radioService[slotId]->mRadioResponse != NULL) { 3203 RadioResponseInfo responseInfo; 3204 populateResponseInfo(responseInfo, serial, responseType, e); 3205 Return<void> retStatus 3206 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo); 3207 radioService[slotId]->checkReturnStatus(retStatus); 3208 } else { 3209 RLOGE("radio::startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3210 } 3211 3212 return 0; 3213} 3214 3215int radio::stopDtmfResponse(android::Parcel &p, int slotId, int requestNumber, 3216 int responseType, int serial, RIL_Errno e, 3217 void *response, size_t responseLen) { 3218 RLOGD("radio::stopDtmfResponse: serial %d", serial); 3219 3220 if (radioService[slotId]->mRadioResponse != NULL) { 3221 RadioResponseInfo responseInfo; 3222 populateResponseInfo(responseInfo, serial, responseType, e); 3223 Return<void> retStatus 3224 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo); 3225 radioService[slotId]->checkReturnStatus(retStatus); 3226 } else { 3227 RLOGE("radio::stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3228 } 3229 3230 return 0; 3231} 3232 3233int radio::getBasebandVersionResponse(android::Parcel &p, int slotId, int requestNumber, 3234 int responseType, int serial, RIL_Errno e, 3235 void *response, size_t responseLen) { 3236 RLOGD("radio::getBasebandVersionResponse: serial %d", serial); 3237 3238 if (radioService[slotId]->mRadioResponse != NULL) { 3239 RadioResponseInfo responseInfo; 3240 populateResponseInfo(responseInfo, serial, responseType, e); 3241 Return<void> retStatus 3242 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo, 3243 convertCharPtrToHidlString((char *) response)); 3244 radioService[slotId]->checkReturnStatus(retStatus); 3245 } else { 3246 RLOGE("radio::getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3247 } 3248 3249 return 0; 3250} 3251 3252int radio::separateConnectionResponse(android::Parcel &p, int slotId, int requestNumber, 3253 int responseType, int serial, RIL_Errno e, 3254 void *response, size_t responseLen) { 3255 RLOGD("radio::separateConnectionResponse: serial %d", serial); 3256 3257 if (radioService[slotId]->mRadioResponse != NULL) { 3258 RadioResponseInfo responseInfo; 3259 populateResponseInfo(responseInfo, serial, responseType, e); 3260 Return<void> retStatus 3261 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo); 3262 radioService[slotId]->checkReturnStatus(retStatus); 3263 } else { 3264 RLOGE("radio::separateConnectionResponse: radioService[%d]->mRadioResponse == NULL", 3265 slotId); 3266 } 3267 3268 return 0; 3269} 3270 3271int radio::setMuteResponse(android::Parcel &p, int slotId, int requestNumber, 3272 int responseType, int serial, RIL_Errno e, 3273 void *response, size_t responseLen) { 3274 RLOGD("radio::setMuteResponse: serial %d", serial); 3275 3276 if (radioService[slotId]->mRadioResponse != NULL) { 3277 RadioResponseInfo responseInfo; 3278 populateResponseInfo(responseInfo, serial, responseType, e); 3279 Return<void> retStatus 3280 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo); 3281 radioService[slotId]->checkReturnStatus(retStatus); 3282 } else { 3283 RLOGE("radio::setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3284 } 3285 3286 return 0; 3287} 3288 3289int radio::getMuteResponse(android::Parcel &p, int slotId, int requestNumber, 3290 int responseType, int serial, RIL_Errno e, void *response, 3291 size_t responseLen) { 3292 RLOGD("radio::getMuteResponse: serial %d", serial); 3293 3294 if (radioService[slotId]->mRadioResponse != NULL) { 3295 RadioResponseInfo responseInfo; 3296 populateResponseInfo(responseInfo, serial, responseType, e); 3297 bool enable = false; 3298 int serviceClass; 3299 if (response == NULL || responseLen != sizeof(int)) { 3300 RLOGE("radio::getMuteResponse Invalid response: NULL"); 3301 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3302 } else { 3303 int *pInt = (int *) response; 3304 enable = pInt[0] == 1 ? true : false; 3305 } 3306 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo, 3307 enable); 3308 radioService[slotId]->checkReturnStatus(retStatus); 3309 } else { 3310 RLOGE("radio::getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3311 } 3312 3313 return 0; 3314} 3315 3316int radio::getClipResponse(android::Parcel &p, int slotId, int requestNumber, 3317 int responseType, int serial, RIL_Errno e, 3318 void *response, size_t responseLen) { 3319 RLOGD("radio::getClipResponse: serial %d", serial); 3320 3321 if (radioService[slotId]->mRadioResponse != NULL) { 3322 RadioResponseInfo responseInfo; 3323 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 3324 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo, 3325 (ClipStatus) ret); 3326 radioService[slotId]->checkReturnStatus(retStatus); 3327 } else { 3328 RLOGE("radio::getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3329 } 3330 3331 return 0; 3332} 3333 3334int radio::sendOemRilRequestStringsResponse(android::Parcel &p, int slotId, int requestNumber, 3335 int responseType, int serial, RIL_Errno e, 3336 void *response, size_t responseLen) { 3337 RLOGD("radio::sendOemRilRequestStringsResponse: serial %d", serial); 3338 3339 if (radioService[slotId]->mRadioResponse != NULL) { 3340 RadioResponseInfo responseInfo; 3341 populateResponseInfo(responseInfo, serial, responseType, e); 3342 hidl_vec<hidl_string> data; 3343 3344 if (response == NULL || responseLen % sizeof(char *) != 0) { 3345 RLOGE("radio::sendOemRilRequestStringsResponse Invalid response: NULL"); 3346 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3347 } else { 3348 char **resp = (char **) response; 3349 int numStrings = responseLen / sizeof(char *); 3350 data.resize(numStrings); 3351 for (int i = 0; i < numStrings; i++) { 3352 data[i] = convertCharPtrToHidlString(resp[i]); 3353 } 3354 } 3355 Return<void> retStatus 3356 = radioService[slotId]->mRadioResponse->sendOemRilRequestStringsResponse( 3357 responseInfo, data); 3358 radioService[slotId]->checkReturnStatus(retStatus); 3359 } else { 3360 RLOGE("radio::sendOemRilRequestStringsResponse: radioService[%d]->mRadioResponse == NULL", 3361 slotId); 3362 } 3363 3364 return 0; 3365} 3366 3367int radio::sendScreenStateResponse(android::Parcel &p, int slotId, int requestNumber, 3368 int responseType, int serial, RIL_Errno e, 3369 void *response, size_t responseLen) { 3370 RLOGD("radio::sendScreenStateResponse: serial %d", serial); 3371 3372 if (radioService[slotId]->mRadioResponse != NULL) { 3373 RadioResponseInfo responseInfo; 3374 populateResponseInfo(responseInfo, serial, responseType, e); 3375 Return<void> retStatus 3376 = radioService[slotId]->mRadioResponse->sendScreenStateResponse(responseInfo); 3377 radioService[slotId]->checkReturnStatus(retStatus); 3378 } else { 3379 RLOGE("radio::sendScreenStateResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3380 } 3381 3382 return 0; 3383} 3384 3385int radio::setSuppServiceNotificationsResponse(android::Parcel &p, int slotId, int requestNumber, 3386 int responseType, int serial, RIL_Errno e, 3387 void *response, size_t responseLen) { 3388 RLOGD("radio::setSuppServiceNotificationsResponse: serial %d", serial); 3389 3390 if (radioService[slotId]->mRadioResponse != NULL) { 3391 RadioResponseInfo responseInfo; 3392 populateResponseInfo(responseInfo, serial, responseType, e); 3393 Return<void> retStatus 3394 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse( 3395 responseInfo); 3396 radioService[slotId]->checkReturnStatus(retStatus); 3397 } else { 3398 RLOGE("radio::setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse " 3399 "== NULL", slotId); 3400 } 3401 3402 return 0; 3403} 3404 3405int radio::deleteSmsOnSimResponse(android::Parcel &p, int slotId, int requestNumber, 3406 int responseType, int serial, RIL_Errno e, 3407 void *response, size_t responseLen) { 3408 RLOGD("radio::deleteSmsOnSimResponse: serial %d", serial); 3409 3410 if (radioService[slotId]->mRadioResponse != NULL) { 3411 RadioResponseInfo responseInfo; 3412 populateResponseInfo(responseInfo, serial, responseType, e); 3413 Return<void> retStatus 3414 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo); 3415 radioService[slotId]->checkReturnStatus(retStatus); 3416 } else { 3417 RLOGE("radio::deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3418 } 3419 3420 return 0; 3421} 3422 3423int radio::setBandModeResponse(android::Parcel &p, int slotId, int requestNumber, 3424 int responseType, int serial, RIL_Errno e, 3425 void *response, size_t responseLen) { 3426 RLOGD("radio::setBandModeResponse: serial %d", serial); 3427 3428 if (radioService[slotId]->mRadioResponse != NULL) { 3429 RadioResponseInfo responseInfo; 3430 populateResponseInfo(responseInfo, serial, responseType, e); 3431 Return<void> retStatus 3432 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo); 3433 radioService[slotId]->checkReturnStatus(retStatus); 3434 } else { 3435 RLOGE("radio::setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3436 } 3437 3438 return 0; 3439} 3440 3441int radio::writeSmsToSimResponse(android::Parcel &p, int slotId, int requestNumber, 3442 int responseType, int serial, RIL_Errno e, 3443 void *response, size_t responseLen) { 3444 RLOGD("radio::writeSmsToSimResponse: serial %d", serial); 3445 3446 if (radioService[slotId]->mRadioResponse != NULL) { 3447 RadioResponseInfo responseInfo; 3448 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 3449 Return<void> retStatus 3450 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret); 3451 radioService[slotId]->checkReturnStatus(retStatus); 3452 } else { 3453 RLOGE("radio::writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3454 } 3455 3456 return 0; 3457} 3458 3459int radio::getAvailableBandModesResponse(android::Parcel &p, int slotId, int requestNumber, 3460 int responseType, int serial, RIL_Errno e, void *response, 3461 size_t responseLen) { 3462 RLOGD("radio::getAvailableBandModesResponse: serial %d", serial); 3463 3464 if (radioService[slotId]->mRadioResponse != NULL) { 3465 RadioResponseInfo responseInfo; 3466 populateResponseInfo(responseInfo, serial, responseType, e); 3467 hidl_vec<RadioBandMode> modes; 3468 if (response == NULL || responseLen % sizeof(int) != 0) { 3469 RLOGE("radio::getAvailableBandModesResponse Invalid response: NULL"); 3470 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3471 } else { 3472 int *pInt = (int *) response; 3473 int numInts = responseLen / sizeof(int); 3474 modes.resize(numInts); 3475 for (int i = 0; i < numInts; i++) { 3476 modes[i] = (RadioBandMode) pInt[i]; 3477 } 3478 } 3479 Return<void> retStatus 3480 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo, 3481 modes); 3482 radioService[slotId]->checkReturnStatus(retStatus); 3483 } else { 3484 RLOGE("radio::getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL", 3485 slotId); 3486 } 3487 3488 return 0; 3489} 3490 3491int radio::sendEnvelopeResponse(android::Parcel &p, int slotId, int requestNumber, 3492 int responseType, int serial, RIL_Errno e, 3493 void *response, size_t responseLen) { 3494 RLOGD("radio::sendEnvelopeResponse: serial %d", serial); 3495 3496 if (radioService[slotId]->mRadioResponse != NULL) { 3497 RadioResponseInfo responseInfo; 3498 populateResponseInfo(responseInfo, serial, responseType, e); 3499 Return<void> retStatus 3500 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo, 3501 convertCharPtrToHidlString((char *) response)); 3502 radioService[slotId]->checkReturnStatus(retStatus); 3503 } else { 3504 RLOGE("radio::sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3505 } 3506 3507 return 0; 3508} 3509 3510int radio::sendTerminalResponseToSimResponse(android::Parcel &p, int slotId, int requestNumber, 3511 int responseType, int serial, RIL_Errno e, 3512 void *response, size_t responseLen) { 3513 RLOGD("radio::sendTerminalResponseToSimResponse: serial %d", serial); 3514 3515 if (radioService[slotId]->mRadioResponse != NULL) { 3516 RadioResponseInfo responseInfo; 3517 populateResponseInfo(responseInfo, serial, responseType, e); 3518 Return<void> retStatus 3519 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse( 3520 responseInfo); 3521 radioService[slotId]->checkReturnStatus(retStatus); 3522 } else { 3523 RLOGE("radio::sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL", 3524 slotId); 3525 } 3526 3527 return 0; 3528} 3529 3530int radio::handleStkCallSetupRequestFromSimResponse(android::Parcel &p, int slotId, 3531 int requestNumber, int responseType, int serial, 3532 RIL_Errno e, void *response, 3533 size_t responseLen) { 3534 RLOGD("radio::handleStkCallSetupRequestFromSimResponse: serial %d", serial); 3535 3536 if (radioService[slotId]->mRadioResponse != NULL) { 3537 RadioResponseInfo responseInfo; 3538 populateResponseInfo(responseInfo, serial, responseType, e); 3539 Return<void> retStatus 3540 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse( 3541 responseInfo); 3542 radioService[slotId]->checkReturnStatus(retStatus); 3543 } else { 3544 RLOGE("radio::handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse " 3545 "== NULL", slotId); 3546 } 3547 3548 return 0; 3549} 3550 3551int radio::explicitCallTransferResponse(android::Parcel &p, int slotId, int requestNumber, 3552 int responseType, int serial, RIL_Errno e, 3553 void *response, size_t responseLen) { 3554 RLOGD("radio::explicitCallTransferResponse: serial %d", serial); 3555 3556 if (radioService[slotId]->mRadioResponse != NULL) { 3557 RadioResponseInfo responseInfo; 3558 populateResponseInfo(responseInfo, serial, responseType, e); 3559 Return<void> retStatus 3560 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo); 3561 radioService[slotId]->checkReturnStatus(retStatus); 3562 } else { 3563 RLOGE("radio::explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL", 3564 slotId); 3565 } 3566 3567 return 0; 3568} 3569 3570int radio::setPreferredNetworkTypeResponse(android::Parcel &p, int slotId, int requestNumber, 3571 int responseType, int serial, RIL_Errno e, 3572 void *response, size_t responseLen) { 3573 RLOGD("radio::setPreferredNetworkTypeResponse: serial %d", serial); 3574 3575 if (radioService[slotId]->mRadioResponse != NULL) { 3576 RadioResponseInfo responseInfo; 3577 populateResponseInfo(responseInfo, serial, responseType, e); 3578 Return<void> retStatus 3579 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse( 3580 responseInfo); 3581 radioService[slotId]->checkReturnStatus(retStatus); 3582 } else { 3583 RLOGE("radio::setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL", 3584 slotId); 3585 } 3586 3587 return 0; 3588} 3589 3590 3591int radio::getPreferredNetworkTypeResponse(android::Parcel &p, int slotId, int requestNumber, 3592 int responseType, int serial, RIL_Errno e, 3593 void *response, size_t responseLen) { 3594 RLOGD("radio::getPreferredNetworkTypeResponse: serial %d", serial); 3595 3596 if (radioService[slotId]->mRadioResponse != NULL) { 3597 RadioResponseInfo responseInfo; 3598 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 3599 Return<void> retStatus 3600 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse( 3601 responseInfo, (PreferredNetworkType) ret); 3602 radioService[slotId]->checkReturnStatus(retStatus); 3603 } else { 3604 RLOGE("radio::getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL", 3605 slotId); 3606 } 3607 3608 return 0; 3609} 3610 3611int radio::getNeighboringCidsResponse(android::Parcel &p, int slotId, int requestNumber, 3612 int responseType, int serial, RIL_Errno e, 3613 void *response, size_t responseLen) { 3614 RLOGD("radio::getNeighboringCidsResponse: serial %d", serial); 3615 3616 if (radioService[slotId]->mRadioResponse != NULL) { 3617 RadioResponseInfo responseInfo; 3618 populateResponseInfo(responseInfo, serial, responseType, e); 3619 hidl_vec<NeighboringCell> cells; 3620 3621 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) { 3622 RLOGE("radio::getNeighboringCidsResponse Invalid response: NULL"); 3623 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3624 } else { 3625 int num = responseLen / sizeof(RIL_NeighboringCell *); 3626 cells.resize(num); 3627 for (int i = 0 ; i < num; i++) { 3628 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i]; 3629 cells[i].cid = convertCharPtrToHidlString(resp->cid); 3630 cells[i].rssi = resp->rssi; 3631 } 3632 } 3633 3634 Return<void> retStatus 3635 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo, 3636 cells); 3637 radioService[slotId]->checkReturnStatus(retStatus); 3638 } else { 3639 RLOGE("radio::getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL", 3640 slotId); 3641 } 3642 3643 return 0; 3644} 3645 3646int radio::setLocationUpdatesResponse(android::Parcel &p, int slotId, int requestNumber, 3647 int responseType, int serial, RIL_Errno e, 3648 void *response, size_t responseLen) { 3649 RLOGD("radio::setLocationUpdatesResponse: serial %d", serial); 3650 3651 if (radioService[slotId]->mRadioResponse != NULL) { 3652 RadioResponseInfo responseInfo; 3653 populateResponseInfo(responseInfo, serial, responseType, e); 3654 Return<void> retStatus 3655 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo); 3656 radioService[slotId]->checkReturnStatus(retStatus); 3657 } else { 3658 RLOGE("radio::setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL", 3659 slotId); 3660 } 3661 3662 return 0; 3663} 3664 3665int radio::setCdmaSubscriptionSourceResponse(android::Parcel &p, int slotId, int requestNumber, 3666 int responseType, int serial, RIL_Errno e, 3667 void *response, size_t responseLen) { 3668 RLOGD("radio::setCdmaSubscriptionSourceResponse: serial %d", serial); 3669 3670 if (radioService[slotId]->mRadioResponse != NULL) { 3671 RadioResponseInfo responseInfo; 3672 populateResponseInfo(responseInfo, serial, responseType, e); 3673 Return<void> retStatus 3674 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse( 3675 responseInfo); 3676 radioService[slotId]->checkReturnStatus(retStatus); 3677 } else { 3678 RLOGE("radio::setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL", 3679 slotId); 3680 } 3681 3682 return 0; 3683} 3684 3685int radio::setCdmaRoamingPreferenceResponse(android::Parcel &p, int slotId, int requestNumber, 3686 int responseType, int serial, RIL_Errno e, 3687 void *response, size_t responseLen) { 3688 RLOGD("radio::setCdmaRoamingPreferenceResponse: serial %d", serial); 3689 3690 if (radioService[slotId]->mRadioResponse != NULL) { 3691 RadioResponseInfo responseInfo; 3692 populateResponseInfo(responseInfo, serial, responseType, e); 3693 Return<void> retStatus 3694 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse( 3695 responseInfo); 3696 radioService[slotId]->checkReturnStatus(retStatus); 3697 } else { 3698 RLOGE("radio::setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL", 3699 slotId); 3700 } 3701 3702 return 0; 3703} 3704 3705int radio::getCdmaRoamingPreferenceResponse(android::Parcel &p, int slotId, int requestNumber, 3706 int responseType, int serial, RIL_Errno e, 3707 void *response, size_t responseLen) { 3708 RLOGD("radio::getCdmaRoamingPreferenceResponse: serial %d", serial); 3709 3710 if (radioService[slotId]->mRadioResponse != NULL) { 3711 RadioResponseInfo responseInfo; 3712 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 3713 Return<void> retStatus 3714 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse( 3715 responseInfo, (CdmaRoamingType) ret); 3716 radioService[slotId]->checkReturnStatus(retStatus); 3717 } else { 3718 RLOGE("radio::getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL", 3719 slotId); 3720 } 3721 3722 return 0; 3723} 3724 3725int radio::setTTYModeResponse(android::Parcel &p, int slotId, int requestNumber, 3726 int responseType, int serial, RIL_Errno e, 3727 void *response, size_t responseLen) { 3728 RLOGD("radio::setTTYModeResponse: serial %d", serial); 3729 3730 if (radioService[slotId]->mRadioResponse != NULL) { 3731 RadioResponseInfo responseInfo; 3732 populateResponseInfo(responseInfo, serial, responseType, e); 3733 Return<void> retStatus 3734 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo); 3735 radioService[slotId]->checkReturnStatus(retStatus); 3736 } else { 3737 RLOGE("radio::setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3738 } 3739 3740 return 0; 3741} 3742 3743int radio::getTTYModeResponse(android::Parcel &p, int slotId, int requestNumber, 3744 int responseType, int serial, RIL_Errno e, 3745 void *response, size_t responseLen) { 3746 RLOGD("radio::getTTYModeResponse: serial %d", serial); 3747 3748 if (radioService[slotId]->mRadioResponse != NULL) { 3749 RadioResponseInfo responseInfo; 3750 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 3751 Return<void> retStatus 3752 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo, 3753 (TtyMode) ret); 3754 radioService[slotId]->checkReturnStatus(retStatus); 3755 } else { 3756 RLOGE("radio::getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3757 } 3758 3759 return 0; 3760} 3761 3762int radio::setPreferredVoicePrivacyResponse(android::Parcel &p, int slotId, int requestNumber, 3763 int responseType, int serial, RIL_Errno e, 3764 void *response, size_t responseLen) { 3765 RLOGD("radio::setPreferredVoicePrivacyResponse: serial %d", serial); 3766 3767 if (radioService[slotId]->mRadioResponse != NULL) { 3768 RadioResponseInfo responseInfo; 3769 populateResponseInfo(responseInfo, serial, responseType, e); 3770 Return<void> retStatus 3771 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse( 3772 responseInfo); 3773 radioService[slotId]->checkReturnStatus(retStatus); 3774 } else { 3775 RLOGE("radio::setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL", 3776 slotId); 3777 } 3778 3779 return 0; 3780} 3781 3782int radio::getPreferredVoicePrivacyResponse(android::Parcel &p, int slotId, int requestNumber, 3783 int responseType, int serial, RIL_Errno e, 3784 void *response, size_t responseLen) { 3785 RLOGD("radio::getPreferredVoicePrivacyResponse: serial %d", serial); 3786 3787 if (radioService[slotId]->mRadioResponse != NULL) { 3788 RadioResponseInfo responseInfo; 3789 populateResponseInfo(responseInfo, serial, responseType, e); 3790 bool enable = false; 3791 int numInts = responseLen / sizeof(int); 3792 if (response == NULL || numInts != 1) { 3793 RLOGE("radio::getPreferredVoicePrivacyResponse Invalid response: NULL"); 3794 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3795 } else { 3796 int *pInt = (int *) response; 3797 enable = pInt[0] == 1 ? true : false; 3798 } 3799 Return<void> retStatus 3800 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse( 3801 responseInfo, enable); 3802 radioService[slotId]->checkReturnStatus(retStatus); 3803 } else { 3804 RLOGE("radio::getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL", 3805 slotId); 3806 } 3807 3808 return 0; 3809} 3810 3811int radio::sendCDMAFeatureCodeResponse(android::Parcel &p, int slotId, int requestNumber, 3812 int responseType, int serial, RIL_Errno e, 3813 void *response, size_t responseLen) { 3814 RLOGD("radio::sendCDMAFeatureCodeResponse: serial %d", serial); 3815 3816 if (radioService[slotId]->mRadioResponse != NULL) { 3817 RadioResponseInfo responseInfo; 3818 populateResponseInfo(responseInfo, serial, responseType, e); 3819 Return<void> retStatus 3820 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo); 3821 radioService[slotId]->checkReturnStatus(retStatus); 3822 } else { 3823 RLOGE("radio::sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL", 3824 slotId); 3825 } 3826 3827 return 0; 3828} 3829 3830int radio::sendBurstDtmfResponse(android::Parcel &p, int slotId, int requestNumber, 3831 int responseType, int serial, RIL_Errno e, 3832 void *response, size_t responseLen) { 3833 RLOGD("radio::sendBurstDtmfResponse: serial %d", serial); 3834 3835 if (radioService[slotId]->mRadioResponse != NULL) { 3836 RadioResponseInfo responseInfo; 3837 populateResponseInfo(responseInfo, serial, responseType, e); 3838 Return<void> retStatus 3839 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo); 3840 radioService[slotId]->checkReturnStatus(retStatus); 3841 } else { 3842 RLOGE("radio::sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3843 } 3844 3845 return 0; 3846} 3847 3848int radio::sendCdmaSmsResponse(android::Parcel &p, int slotId, int requestNumber, 3849 int responseType, int serial, RIL_Errno e, void *response, 3850 size_t responseLen) { 3851 RLOGD("radio::sendCdmaSmsResponse: serial %d", serial); 3852 3853 if (radioService[slotId]->mRadioResponse != NULL) { 3854 RadioResponseInfo responseInfo; 3855 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response, 3856 responseLen); 3857 3858 Return<void> retStatus 3859 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result); 3860 radioService[slotId]->checkReturnStatus(retStatus); 3861 } else { 3862 RLOGE("radio::sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3863 } 3864 3865 return 0; 3866} 3867 3868int radio::acknowledgeLastIncomingCdmaSmsResponse(android::Parcel &p, int slotId, int requestNumber, 3869 int responseType, int serial, RIL_Errno e, 3870 void *response, size_t responseLen) { 3871 RLOGD("radio::acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial); 3872 3873 if (radioService[slotId]->mRadioResponse != NULL) { 3874 RadioResponseInfo responseInfo; 3875 populateResponseInfo(responseInfo, serial, responseType, e); 3876 Return<void> retStatus 3877 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse( 3878 responseInfo); 3879 radioService[slotId]->checkReturnStatus(retStatus); 3880 } else { 3881 RLOGE("radio::acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse " 3882 "== NULL", slotId); 3883 } 3884 3885 return 0; 3886} 3887 3888int radio::getGsmBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber, 3889 int responseType, int serial, RIL_Errno e, 3890 void *response, size_t responseLen) { 3891 RLOGD("radio::getGsmBroadcastConfigResponse: serial %d", serial); 3892 3893 if (radioService[slotId]->mRadioResponse != NULL) { 3894 RadioResponseInfo responseInfo; 3895 populateResponseInfo(responseInfo, serial, responseType, e); 3896 hidl_vec<GsmBroadcastSmsConfigInfo> configs; 3897 3898 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) { 3899 RLOGE("radio::getGsmBroadcastConfigResponse Invalid response: NULL"); 3900 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3901 } else { 3902 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *); 3903 configs.resize(num); 3904 for (int i = 0 ; i < num; i++) { 3905 RIL_GSM_BroadcastSmsConfigInfo *resp = 3906 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i]; 3907 configs[i].fromServiceId = resp->fromServiceId; 3908 configs[i].toServiceId = resp->toServiceId; 3909 configs[i].fromCodeScheme = resp->fromCodeScheme; 3910 configs[i].toCodeScheme = resp->toCodeScheme; 3911 configs[i].selected = resp->selected == 1 ? true : false; 3912 } 3913 } 3914 3915 Return<void> retStatus 3916 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo, 3917 configs); 3918 radioService[slotId]->checkReturnStatus(retStatus); 3919 } else { 3920 RLOGE("radio::getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL", 3921 slotId); 3922 } 3923 3924 return 0; 3925} 3926 3927int radio::setGsmBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber, 3928 int responseType, int serial, RIL_Errno e, 3929 void *response, size_t responseLen) { 3930 RLOGD("radio::setGsmBroadcastConfigResponse: serial %d", serial); 3931 3932 if (radioService[slotId]->mRadioResponse != NULL) { 3933 RadioResponseInfo responseInfo; 3934 populateResponseInfo(responseInfo, serial, responseType, e); 3935 Return<void> retStatus 3936 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo); 3937 radioService[slotId]->checkReturnStatus(retStatus); 3938 } else { 3939 RLOGE("radio::setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL", 3940 slotId); 3941 } 3942 3943 return 0; 3944} 3945 3946int radio::setGsmBroadcastActivationResponse(android::Parcel &p, int slotId, int requestNumber, 3947 int responseType, int serial, RIL_Errno e, 3948 void *response, size_t responseLen) { 3949 RLOGD("radio::setGsmBroadcastActivationResponse: serial %d", serial); 3950 3951 if (radioService[slotId]->mRadioResponse != NULL) { 3952 RadioResponseInfo responseInfo; 3953 populateResponseInfo(responseInfo, serial, responseType, e); 3954 Return<void> retStatus 3955 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse( 3956 responseInfo); 3957 radioService[slotId]->checkReturnStatus(retStatus); 3958 } else { 3959 RLOGE("radio::setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL", 3960 slotId); 3961 } 3962 3963 return 0; 3964} 3965 3966int radio::getCdmaBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber, 3967 int responseType, int serial, RIL_Errno e, 3968 void *response, size_t responseLen) { 3969 RLOGD("radio::getCdmaBroadcastConfigResponse: serial %d", serial); 3970 3971 if (radioService[slotId]->mRadioResponse != NULL) { 3972 RadioResponseInfo responseInfo; 3973 populateResponseInfo(responseInfo, serial, responseType, e); 3974 hidl_vec<CdmaBroadcastSmsConfigInfo> configs; 3975 3976 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) { 3977 RLOGE("radio::getCdmaBroadcastConfigResponse Invalid response: NULL"); 3978 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3979 } else { 3980 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *); 3981 configs.resize(num); 3982 for (int i = 0 ; i < num; i++) { 3983 RIL_CDMA_BroadcastSmsConfigInfo *resp = 3984 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i]; 3985 configs[i].serviceCategory = resp->service_category; 3986 configs[i].language = resp->language; 3987 configs[i].selected = resp->selected == 1 ? true : false; 3988 } 3989 } 3990 3991 Return<void> retStatus 3992 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo, 3993 configs); 3994 radioService[slotId]->checkReturnStatus(retStatus); 3995 } else { 3996 RLOGE("radio::getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL", 3997 slotId); 3998 } 3999 4000 return 0; 4001} 4002 4003int radio::setCdmaBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber, 4004 int responseType, int serial, RIL_Errno e, 4005 void *response, size_t responseLen) { 4006 RLOGD("radio::setCdmaBroadcastConfigResponse: serial %d", serial); 4007 4008 if (radioService[slotId]->mRadioResponse != NULL) { 4009 RadioResponseInfo responseInfo; 4010 populateResponseInfo(responseInfo, serial, responseType, e); 4011 Return<void> retStatus 4012 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse( 4013 responseInfo); 4014 radioService[slotId]->checkReturnStatus(retStatus); 4015 } else { 4016 RLOGE("radio::setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL", 4017 slotId); 4018 } 4019 4020 return 0; 4021} 4022 4023int radio::setCdmaBroadcastActivationResponse(android::Parcel &p, int slotId, int requestNumber, 4024 int responseType, int serial, RIL_Errno e, 4025 void *response, size_t responseLen) { 4026 RLOGD("radio::setCdmaBroadcastActivationResponse: serial %d", serial); 4027 4028 if (radioService[slotId]->mRadioResponse != NULL) { 4029 RadioResponseInfo responseInfo; 4030 populateResponseInfo(responseInfo, serial, responseType, e); 4031 Return<void> retStatus 4032 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse( 4033 responseInfo); 4034 radioService[slotId]->checkReturnStatus(retStatus); 4035 } else { 4036 RLOGE("radio::setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL", 4037 slotId); 4038 } 4039 4040 return 0; 4041} 4042 4043int radio::getCDMASubscriptionResponse(android::Parcel &p, int slotId, int requestNumber, 4044 int responseType, int serial, RIL_Errno e, void *response, 4045 size_t responseLen) { 4046 RLOGD("radio::getCDMASubscriptionResponse: serial %d", serial); 4047 4048 if (radioService[slotId]->mRadioResponse != NULL) { 4049 RadioResponseInfo responseInfo; 4050 populateResponseInfo(responseInfo, serial, responseType, e); 4051 4052 int numStrings = responseLen / sizeof(char *); 4053 hidl_string emptyString; 4054 if (response == NULL || numStrings != 5) { 4055 RLOGE("radio::getOperatorResponse Invalid response: NULL"); 4056 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4057 Return<void> retStatus 4058 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse( 4059 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString); 4060 radioService[slotId]->checkReturnStatus(retStatus); 4061 } else { 4062 char **resp = (char **) response; 4063 Return<void> retStatus 4064 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse( 4065 responseInfo, 4066 convertCharPtrToHidlString(resp[0]), 4067 convertCharPtrToHidlString(resp[1]), 4068 convertCharPtrToHidlString(resp[2]), 4069 convertCharPtrToHidlString(resp[3]), 4070 convertCharPtrToHidlString(resp[4])); 4071 radioService[slotId]->checkReturnStatus(retStatus); 4072 } 4073 } else { 4074 RLOGE("radio::getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL", 4075 slotId); 4076 } 4077 4078 return 0; 4079} 4080 4081int radio::writeSmsToRuimResponse(android::Parcel &p, int slotId, int requestNumber, 4082 int responseType, int serial, RIL_Errno e, 4083 void *response, size_t responseLen) { 4084 RLOGD("radio::writeSmsToRuimResponse: serial %d", serial); 4085 4086 if (radioService[slotId]->mRadioResponse != NULL) { 4087 RadioResponseInfo responseInfo; 4088 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4089 Return<void> retStatus 4090 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret); 4091 radioService[slotId]->checkReturnStatus(retStatus); 4092 } else { 4093 RLOGE("radio::writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4094 } 4095 4096 return 0; 4097} 4098 4099int radio::deleteSmsOnRuimResponse(android::Parcel &p, int slotId, int requestNumber, 4100 int responseType, int serial, RIL_Errno e, 4101 void *response, size_t responseLen) { 4102 RLOGD("radio::deleteSmsOnRuimResponse: serial %d", serial); 4103 4104 if (radioService[slotId]->mRadioResponse != NULL) { 4105 RadioResponseInfo responseInfo; 4106 populateResponseInfo(responseInfo, serial, responseType, e); 4107 Return<void> retStatus 4108 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo); 4109 radioService[slotId]->checkReturnStatus(retStatus); 4110 } else { 4111 RLOGE("radio::deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4112 } 4113 4114 return 0; 4115} 4116 4117int radio::getDeviceIdentityResponse(android::Parcel &p, int slotId, int requestNumber, 4118 int responseType, int serial, RIL_Errno e, void *response, 4119 size_t responseLen) { 4120 RLOGD("radio::getDeviceIdentityResponse: serial %d", serial); 4121 4122 if (radioService[slotId]->mRadioResponse != NULL) { 4123 RadioResponseInfo responseInfo; 4124 populateResponseInfo(responseInfo, serial, responseType, e); 4125 4126 int numStrings = responseLen / sizeof(char *); 4127 hidl_string emptyString; 4128 if (response == NULL || numStrings != 4) { 4129 RLOGE("radio::getDeviceIdentityResponse Invalid response: NULL"); 4130 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4131 Return<void> retStatus 4132 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo, 4133 emptyString, emptyString, emptyString, emptyString); 4134 radioService[slotId]->checkReturnStatus(retStatus); 4135 } else { 4136 char **resp = (char **) response; 4137 Return<void> retStatus 4138 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo, 4139 convertCharPtrToHidlString(resp[0]), 4140 convertCharPtrToHidlString(resp[1]), 4141 convertCharPtrToHidlString(resp[2]), 4142 convertCharPtrToHidlString(resp[3])); 4143 radioService[slotId]->checkReturnStatus(retStatus); 4144 } 4145 } else { 4146 RLOGE("radio::getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL", 4147 slotId); 4148 } 4149 4150 return 0; 4151} 4152 4153int radio::exitEmergencyCallbackModeResponse(android::Parcel &p, int slotId, int requestNumber, 4154 int responseType, int serial, RIL_Errno e, 4155 void *response, size_t responseLen) { 4156 RLOGD("radio::exitEmergencyCallbackModeResponse: serial %d", serial); 4157 4158 if (radioService[slotId]->mRadioResponse != NULL) { 4159 RadioResponseInfo responseInfo; 4160 populateResponseInfo(responseInfo, serial, responseType, e); 4161 Return<void> retStatus 4162 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse( 4163 responseInfo); 4164 radioService[slotId]->checkReturnStatus(retStatus); 4165 } else { 4166 RLOGE("radio::exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL", 4167 slotId); 4168 } 4169 4170 return 0; 4171} 4172 4173int radio::getSmscAddressResponse(android::Parcel &p, int slotId, int requestNumber, 4174 int responseType, int serial, RIL_Errno e, 4175 void *response, size_t responseLen) { 4176 RLOGD("radio::getSmscAddressResponse: serial %d", serial); 4177 4178 if (radioService[slotId]->mRadioResponse != NULL) { 4179 RadioResponseInfo responseInfo; 4180 populateResponseInfo(responseInfo, serial, responseType, e); 4181 Return<void> retStatus 4182 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo, 4183 convertCharPtrToHidlString((char *) response)); 4184 radioService[slotId]->checkReturnStatus(retStatus); 4185 } else { 4186 RLOGE("radio::getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4187 } 4188 4189 return 0; 4190} 4191 4192int radio::setSmscAddressResponse(android::Parcel &p, int slotId, int requestNumber, 4193 int responseType, int serial, RIL_Errno e, 4194 void *response, size_t responseLen) { 4195 RLOGD("radio::setSmscAddressResponse: serial %d", serial); 4196 4197 if (radioService[slotId]->mRadioResponse != NULL) { 4198 RadioResponseInfo responseInfo; 4199 populateResponseInfo(responseInfo, serial, responseType, e); 4200 Return<void> retStatus 4201 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo); 4202 radioService[slotId]->checkReturnStatus(retStatus); 4203 } else { 4204 RLOGE("radio::setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4205 } 4206 4207 return 0; 4208} 4209 4210int radio::reportSmsMemoryStatusResponse(android::Parcel &p, int slotId, int requestNumber, 4211 int responseType, int serial, RIL_Errno e, 4212 void *response, size_t responseLen) { 4213 RLOGD("radio::reportSmsMemoryStatusResponse: serial %d", serial); 4214 4215 if (radioService[slotId]->mRadioResponse != NULL) { 4216 RadioResponseInfo responseInfo; 4217 populateResponseInfo(responseInfo, serial, responseType, e); 4218 Return<void> retStatus 4219 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo); 4220 radioService[slotId]->checkReturnStatus(retStatus); 4221 } else { 4222 RLOGE("radio::reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL", 4223 slotId); 4224 } 4225 4226 return 0; 4227} 4228 4229int radio::getCdmaSubscriptionSourceResponse(android::Parcel &p, int slotId, int requestNumber, 4230 int responseType, int serial, RIL_Errno e, 4231 void *response, size_t responseLen) { 4232 RLOGD("radio::getCdmaSubscriptionSourceResponse: serial %d", serial); 4233 4234 if (radioService[slotId]->mRadioResponse != NULL) { 4235 RadioResponseInfo responseInfo; 4236 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4237 Return<void> retStatus 4238 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse( 4239 responseInfo, (CdmaSubscriptionSource) ret); 4240 radioService[slotId]->checkReturnStatus(retStatus); 4241 } else { 4242 RLOGE("radio::getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL", 4243 slotId); 4244 } 4245 4246 return 0; 4247} 4248 4249int radio::requestIsimAuthenticationResponse(android::Parcel &p, int slotId, int requestNumber, 4250 int responseType, int serial, RIL_Errno e, 4251 void *response, size_t responseLen) { 4252 RLOGD("radio::requestIsimAuthenticationResponse: serial %d", serial); 4253 4254 if (radioService[slotId]->mRadioResponse != NULL) { 4255 RadioResponseInfo responseInfo; 4256 populateResponseInfo(responseInfo, serial, responseType, e); 4257 Return<void> retStatus 4258 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse( 4259 responseInfo, 4260 convertCharPtrToHidlString((char *) response)); 4261 radioService[slotId]->checkReturnStatus(retStatus); 4262 } else { 4263 RLOGE("radio::requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL", 4264 slotId); 4265 } 4266 4267 return 0; 4268} 4269 4270int radio::acknowledgeIncomingGsmSmsWithPduResponse(android::Parcel &p, int slotId, 4271 int requestNumber, int responseType, 4272 int serial, RIL_Errno e, void *response, 4273 size_t responseLen) { 4274 RLOGD("radio::acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial); 4275 4276 if (radioService[slotId]->mRadioResponse != NULL) { 4277 RadioResponseInfo responseInfo; 4278 populateResponseInfo(responseInfo, serial, responseType, e); 4279 Return<void> retStatus 4280 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse( 4281 responseInfo); 4282 radioService[slotId]->checkReturnStatus(retStatus); 4283 } else { 4284 RLOGE("radio::acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse " 4285 "== NULL", slotId); 4286 } 4287 4288 return 0; 4289} 4290 4291int radio::sendEnvelopeWithStatusResponse(android::Parcel &p, int slotId, int requestNumber, 4292 int responseType, int serial, RIL_Errno e, void *response, 4293 size_t responseLen) { 4294 RLOGD("radio::sendEnvelopeWithStatusResponse: serial %d", serial); 4295 4296 if (radioService[slotId]->mRadioResponse != NULL) { 4297 RadioResponseInfo responseInfo; 4298 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, 4299 response, responseLen); 4300 4301 Return<void> retStatus 4302 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo, 4303 result); 4304 radioService[slotId]->checkReturnStatus(retStatus); 4305 } else { 4306 RLOGE("radio::sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL", 4307 slotId); 4308 } 4309 4310 return 0; 4311} 4312 4313int radio::getVoiceRadioTechnologyResponse(android::Parcel &p, int slotId, int requestNumber, 4314 int responseType, int serial, RIL_Errno e, 4315 void *response, size_t responseLen) { 4316 RLOGD("radio::getVoiceRadioTechnologyResponse: serial %d", serial); 4317 4318 if (radioService[slotId]->mRadioResponse != NULL) { 4319 RadioResponseInfo responseInfo; 4320 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4321 Return<void> retStatus 4322 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse( 4323 responseInfo, (RadioTechnology) ret); 4324 radioService[slotId]->checkReturnStatus(retStatus); 4325 } else { 4326 RLOGE("radio::getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL", 4327 slotId); 4328 } 4329 4330 return 0; 4331} 4332 4333int radio::setCellInfoListRateResponse(android::Parcel &p, int slotId, 4334 int requestNumber, int responseType, 4335 int serial, RIL_Errno e, void *response, 4336 size_t responseLen) { 4337 RLOGD("radio::setCellInfoListRateResponse: serial %d", serial); 4338 4339 if (radioService[slotId]->mRadioResponse != NULL) { 4340 RadioResponseInfo responseInfo; 4341 populateResponseInfo(responseInfo, serial, responseType, e); 4342 Return<void> retStatus 4343 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo); 4344 radioService[slotId]->checkReturnStatus(retStatus); 4345 } else { 4346 RLOGE("radio::setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL", 4347 slotId); 4348 } 4349 4350 return 0; 4351} 4352 4353int radio::setInitialAttachApnResponse(android::Parcel &p, int slotId, int requestNumber, 4354 int responseType, int serial, RIL_Errno e, 4355 void *response, size_t responseLen) { 4356 RLOGD("radio::setInitialAttachApnResponse: serial %d", serial); 4357 4358 if (radioService[slotId]->mRadioResponse != NULL) { 4359 RadioResponseInfo responseInfo; 4360 populateResponseInfo(responseInfo, serial, responseType, e); 4361 Return<void> retStatus 4362 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo); 4363 radioService[slotId]->checkReturnStatus(retStatus); 4364 } else { 4365 RLOGE("radio::setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", 4366 slotId); 4367 } 4368 4369 return 0; 4370} 4371 4372int radio::getImsRegistrationStateResponse(android::Parcel &p, int slotId, int requestNumber, 4373 int responseType, int serial, RIL_Errno e, 4374 void *response, size_t responseLen) { 4375 RLOGD("radio::getImsRegistrationStateResponse: serial %d", serial); 4376 4377 if (radioService[slotId]->mRadioResponse != NULL) { 4378 RadioResponseInfo responseInfo; 4379 populateResponseInfo(responseInfo, serial, responseType, e); 4380 bool isRegistered = false; 4381 int ratFamily = 0; 4382 int numInts = responseLen / sizeof(int); 4383 if (response == NULL || numInts != 2) { 4384 RLOGE("radio::getImsRegistrationStateResponse Invalid response: NULL"); 4385 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4386 } else { 4387 int *pInt = (int *) response; 4388 isRegistered = pInt[0] == 1 ? true : false; 4389 ratFamily = pInt[1]; 4390 } 4391 Return<void> retStatus 4392 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse( 4393 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily); 4394 radioService[slotId]->checkReturnStatus(retStatus); 4395 } else { 4396 RLOGE("radio::getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL", 4397 slotId); 4398 } 4399 4400 return 0; 4401} 4402 4403int radio::sendImsSmsResponse(android::Parcel &p, int slotId, int requestNumber, 4404 int responseType, int serial, RIL_Errno e, void *response, 4405 size_t responseLen) { 4406 RLOGD("radio::sendImsSmsResponse: serial %d", serial); 4407 4408 if (radioService[slotId]->mRadioResponse != NULL) { 4409 RadioResponseInfo responseInfo; 4410 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response, 4411 responseLen); 4412 4413 Return<void> retStatus 4414 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result); 4415 radioService[slotId]->checkReturnStatus(retStatus); 4416 } else { 4417 RLOGE("radio::sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4418 } 4419 4420 return 0; 4421} 4422 4423int radio::iccTransmitApduBasicChannelResponse(android::Parcel &p, int slotId, int requestNumber, 4424 int responseType, int serial, RIL_Errno e, 4425 void *response, size_t responseLen) { 4426 RLOGD("radio::iccTransmitApduBasicChannelResponse: serial %d", serial); 4427 4428 if (radioService[slotId]->mRadioResponse != NULL) { 4429 RadioResponseInfo responseInfo; 4430 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response, 4431 responseLen); 4432 4433 Return<void> retStatus 4434 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse( 4435 responseInfo, result); 4436 radioService[slotId]->checkReturnStatus(retStatus); 4437 } else { 4438 RLOGE("radio::iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse " 4439 "== NULL", slotId); 4440 } 4441 4442 return 0; 4443} 4444 4445int radio::iccOpenLogicalChannelResponse(android::Parcel &p, int slotId, int requestNumber, 4446 int responseType, int serial, RIL_Errno e, void *response, 4447 size_t responseLen) { 4448 RLOGD("radio::iccOpenLogicalChannelResponse: serial %d", serial); 4449 4450 if (radioService[slotId]->mRadioResponse != NULL) { 4451 RadioResponseInfo responseInfo; 4452 populateResponseInfo(responseInfo, serial, responseType, e); 4453 int channelId = -1; 4454 hidl_vec<int8_t> selectResponse; 4455 int numInts = responseLen / sizeof(int); 4456 if (response == NULL || responseLen % sizeof(int) != 0) { 4457 RLOGE("radio::iccOpenLogicalChannelResponse Invalid response: NULL"); 4458 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4459 } else { 4460 int *pInt = (int *) response; 4461 channelId = pInt[0]; 4462 selectResponse.resize(numInts - 1); 4463 for (int i = 1; i < numInts; i++) { 4464 selectResponse[i - 1] = (int8_t) pInt[i]; 4465 } 4466 } 4467 Return<void> retStatus 4468 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo, 4469 channelId, selectResponse); 4470 radioService[slotId]->checkReturnStatus(retStatus); 4471 } else { 4472 RLOGE("radio::iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL", 4473 slotId); 4474 } 4475 4476 return 0; 4477} 4478 4479int radio::iccCloseLogicalChannelResponse(android::Parcel &p, int slotId, int requestNumber, 4480 int responseType, int serial, RIL_Errno e, 4481 void *response, size_t responseLen) { 4482 RLOGD("radio::iccCloseLogicalChannelResponse: serial %d", serial); 4483 4484 if (radioService[slotId]->mRadioResponse != NULL) { 4485 RadioResponseInfo responseInfo; 4486 populateResponseInfo(responseInfo, serial, responseType, e); 4487 Return<void> retStatus 4488 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse( 4489 responseInfo); 4490 radioService[slotId]->checkReturnStatus(retStatus); 4491 } else { 4492 RLOGE("radio::iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL", 4493 slotId); 4494 } 4495 4496 return 0; 4497} 4498 4499int radio::iccTransmitApduLogicalChannelResponse(android::Parcel &p, int slotId, int requestNumber, 4500 int responseType, int serial, RIL_Errno e, 4501 void *response, size_t responseLen) { 4502 RLOGD("radio::iccTransmitApduLogicalChannelResponse: serial %d", serial); 4503 4504 if (radioService[slotId]->mRadioResponse != NULL) { 4505 RadioResponseInfo responseInfo; 4506 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response, 4507 responseLen); 4508 4509 Return<void> retStatus 4510 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse( 4511 responseInfo, result); 4512 radioService[slotId]->checkReturnStatus(retStatus); 4513 } else { 4514 RLOGE("radio::iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse " 4515 "== NULL", slotId); 4516 } 4517 4518 return 0; 4519} 4520 4521int radio::nvReadItemResponse(android::Parcel &p, int slotId, int requestNumber, 4522 int responseType, int serial, RIL_Errno e, 4523 void *response, size_t responseLen) { 4524 RLOGD("radio::nvReadItemResponse: serial %d", serial); 4525 4526 if (radioService[slotId]->mRadioResponse != NULL) { 4527 RadioResponseInfo responseInfo; 4528 populateResponseInfo(responseInfo, serial, responseType, e); 4529 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse( 4530 responseInfo, 4531 convertCharPtrToHidlString((char *) response)); 4532 radioService[slotId]->checkReturnStatus(retStatus); 4533 } else { 4534 RLOGE("radio::nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4535 } 4536 4537 return 0; 4538} 4539 4540int radio::nvWriteItemResponse(android::Parcel &p, int slotId, int requestNumber, 4541 int responseType, int serial, RIL_Errno e, 4542 void *response, size_t responseLen) { 4543 RLOGD("radio::nvWriteItemResponse: serial %d", serial); 4544 4545 if (radioService[slotId]->mRadioResponse != NULL) { 4546 RadioResponseInfo responseInfo; 4547 populateResponseInfo(responseInfo, serial, responseType, e); 4548 Return<void> retStatus 4549 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo); 4550 radioService[slotId]->checkReturnStatus(retStatus); 4551 } else { 4552 RLOGE("radio::nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4553 } 4554 4555 return 0; 4556} 4557 4558int radio::nvWriteCdmaPrlResponse(android::Parcel &p, int slotId, int requestNumber, 4559 int responseType, int serial, RIL_Errno e, 4560 void *response, size_t responseLen) { 4561 RLOGD("radio::nvWriteCdmaPrlResponse: serial %d", serial); 4562 4563 if (radioService[slotId]->mRadioResponse != NULL) { 4564 RadioResponseInfo responseInfo; 4565 populateResponseInfo(responseInfo, serial, responseType, e); 4566 Return<void> retStatus 4567 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo); 4568 radioService[slotId]->checkReturnStatus(retStatus); 4569 } else { 4570 RLOGE("radio::nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4571 } 4572 4573 return 0; 4574} 4575 4576int radio::nvResetConfigResponse(android::Parcel &p, int slotId, int requestNumber, 4577 int responseType, int serial, RIL_Errno e, 4578 void *response, size_t responseLen) { 4579 RLOGD("radio::nvResetConfigResponse: serial %d", serial); 4580 4581 if (radioService[slotId]->mRadioResponse != NULL) { 4582 RadioResponseInfo responseInfo; 4583 populateResponseInfo(responseInfo, serial, responseType, e); 4584 Return<void> retStatus 4585 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo); 4586 radioService[slotId]->checkReturnStatus(retStatus); 4587 } else { 4588 RLOGE("radio::nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4589 } 4590 4591 return 0; 4592} 4593 4594int radio::setUiccSubscriptionResponse(android::Parcel &p, int slotId, int requestNumber, 4595 int responseType, int serial, RIL_Errno e, 4596 void *response, size_t responseLen) { 4597 RLOGD("radio::setUiccSubscriptionResponse: serial %d", serial); 4598 4599 if (radioService[slotId]->mRadioResponse != NULL) { 4600 RadioResponseInfo responseInfo; 4601 populateResponseInfo(responseInfo, serial, responseType, e); 4602 Return<void> retStatus 4603 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo); 4604 radioService[slotId]->checkReturnStatus(retStatus); 4605 } else { 4606 RLOGE("radio::setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL", 4607 slotId); 4608 } 4609 4610 return 0; 4611} 4612 4613int radio::setDataAllowedResponse(android::Parcel &p, int slotId, int requestNumber, 4614 int responseType, int serial, RIL_Errno e, 4615 void *response, size_t responseLen) { 4616 RLOGD("radio::setDataAllowedResponse: serial %d", serial); 4617 4618 if (radioService[slotId]->mRadioResponse != NULL) { 4619 RadioResponseInfo responseInfo; 4620 populateResponseInfo(responseInfo, serial, responseType, e); 4621 Return<void> retStatus 4622 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo); 4623 radioService[slotId]->checkReturnStatus(retStatus); 4624 } else { 4625 RLOGE("radio::setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4626 } 4627 4628 return 0; 4629} 4630 4631int radio::requestIccSimAuthenticationResponse(android::Parcel &p, int slotId, int requestNumber, 4632 int responseType, int serial, RIL_Errno e, 4633 void *response, size_t responseLen) { 4634 RLOGD("radio::requestIccSimAuthenticationResponse: serial %d", serial); 4635 4636 if (radioService[slotId]->mRadioResponse != NULL) { 4637 RadioResponseInfo responseInfo; 4638 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response, 4639 responseLen); 4640 4641 Return<void> retStatus 4642 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse( 4643 responseInfo, result); 4644 radioService[slotId]->checkReturnStatus(retStatus); 4645 } else { 4646 RLOGE("radio::requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse " 4647 "== NULL", slotId); 4648 } 4649 4650 return 0; 4651} 4652 4653int radio::setDataProfileResponse(android::Parcel &p, int slotId, int requestNumber, 4654 int responseType, int serial, RIL_Errno e, 4655 void *response, size_t responseLen) { 4656 RLOGD("radio::setDataProfileResponse: serial %d", serial); 4657 4658 if (radioService[slotId]->mRadioResponse != NULL) { 4659 RadioResponseInfo responseInfo; 4660 populateResponseInfo(responseInfo, serial, responseType, e); 4661 Return<void> retStatus 4662 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo); 4663 radioService[slotId]->checkReturnStatus(retStatus); 4664 } else { 4665 RLOGE("radio::setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4666 } 4667 4668 return 0; 4669} 4670 4671int radio::requestShutdownResponse(android::Parcel &p, int slotId, int requestNumber, 4672 int responseType, int serial, RIL_Errno e, 4673 void *response, size_t responseLen) { 4674 RLOGD("radio::requestShutdownResponse: serial %d", serial); 4675 4676 if (radioService[slotId]->mRadioResponse != NULL) { 4677 RadioResponseInfo responseInfo; 4678 populateResponseInfo(responseInfo, serial, responseType, e); 4679 Return<void> retStatus 4680 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo); 4681 radioService[slotId]->checkReturnStatus(retStatus); 4682 } else { 4683 RLOGE("radio::requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4684 } 4685 4686 return 0; 4687} 4688 4689LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType, 4690 RIL_Errno e, void *response, size_t responseLen) { 4691 populateResponseInfo(responseInfo, serial, responseType, e); 4692 LceStatusInfo result; 4693 4694 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) { 4695 RLOGE("Invalid response: NULL"); 4696 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4697 memset(&result, 0, sizeof(result)); 4698 } else { 4699 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response; 4700 result.lceStatus = (LceStatus) resp->lce_status; 4701 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms; 4702 } 4703 return result; 4704} 4705 4706int radio::startLceServiceResponse(android::Parcel &p, int slotId, int requestNumber, 4707 int responseType, int serial, RIL_Errno e, 4708 void *response, size_t responseLen) { 4709 RLOGD("radio::startLceServiceResponse: serial %d", serial); 4710 4711 if (radioService[slotId]->mRadioResponse != NULL) { 4712 RadioResponseInfo responseInfo; 4713 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e, 4714 response, responseLen); 4715 4716 Return<void> retStatus 4717 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo, 4718 result); 4719 radioService[slotId]->checkReturnStatus(retStatus); 4720 } else { 4721 RLOGE("radio::startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4722 } 4723 4724 return 0; 4725} 4726 4727int radio::stopLceServiceResponse(android::Parcel &p, int slotId, int requestNumber, 4728 int responseType, int serial, RIL_Errno e, 4729 void *response, size_t responseLen) { 4730 RLOGD("radio::stopLceServiceResponse: serial %d", serial); 4731 4732 if (radioService[slotId]->mRadioResponse != NULL) { 4733 RadioResponseInfo responseInfo; 4734 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e, 4735 response, responseLen); 4736 4737 Return<void> retStatus 4738 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo, 4739 result); 4740 radioService[slotId]->checkReturnStatus(retStatus); 4741 } else { 4742 RLOGE("radio::stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4743 } 4744 4745 return 0; 4746} 4747 4748int radio::getModemActivityInfoResponse(android::Parcel &p, int slotId, int requestNumber, 4749 int responseType, int serial, RIL_Errno e, 4750 void *response, size_t responseLen) { 4751 RLOGD("radio::getModemActivityInfoResponse: serial %d", serial); 4752 4753 if (radioService[slotId]->mRadioResponse != NULL) { 4754 RadioResponseInfo responseInfo; 4755 populateResponseInfo(responseInfo, serial, responseType, e); 4756 ActivityStatsInfo info; 4757 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) { 4758 RLOGE("radio::getModemActivityInfoResponse Invalid response: NULL"); 4759 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4760 memset(&info, 0, sizeof(info)); 4761 } else { 4762 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response; 4763 info.sleepModeTimeMs = resp->sleep_mode_time_ms; 4764 info.idleModeTimeMs = resp->idle_mode_time_ms; 4765 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) { 4766 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i]; 4767 } 4768 info.rxModeTimeMs = resp->rx_mode_time_ms; 4769 } 4770 4771 Return<void> retStatus 4772 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo, 4773 info); 4774 radioService[slotId]->checkReturnStatus(retStatus); 4775 } else { 4776 RLOGE("radio::getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL", 4777 slotId); 4778 } 4779 4780 return 0; 4781} 4782 4783int radio::setAllowedCarriersResponse(android::Parcel &p, int slotId, int requestNumber, 4784 int responseType, int serial, RIL_Errno e, 4785 void *response, size_t responseLen) { 4786 RLOGD("radio::setAllowedCarriersResponse: serial %d", serial); 4787 4788 if (radioService[slotId]->mRadioResponse != NULL) { 4789 RadioResponseInfo responseInfo; 4790 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4791 Return<void> retStatus 4792 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo, 4793 ret); 4794 radioService[slotId]->checkReturnStatus(retStatus); 4795 } else { 4796 RLOGE("radio::setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", 4797 slotId); 4798 } 4799 4800 return 0; 4801} 4802 4803int radio::getAllowedCarriersResponse(android::Parcel &p, int slotId, int requestNumber, 4804 int responseType, int serial, RIL_Errno e, 4805 void *response, size_t responseLen) { 4806 RLOGD("radio::getAllowedCarriersResponse: serial %d", serial); 4807 4808 if (radioService[slotId]->mRadioResponse != NULL) { 4809 RadioResponseInfo responseInfo; 4810 populateResponseInfo(responseInfo, serial, responseType, e); 4811 CarrierRestrictions carrierInfo; 4812 bool allAllowed = true; 4813 memset(&carrierInfo, 0, sizeof(carrierInfo)); 4814 if (response == NULL || responseLen != sizeof(RIL_CarrierRestrictions)) { 4815 RLOGE("radio::getAllowedCarriersResponse Invalid response: NULL"); 4816 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4817 } else { 4818 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response; 4819 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) { 4820 allAllowed = false; 4821 } 4822 4823 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers); 4824 for(int i = 0; i < pCr->len_allowed_carriers; i++) { 4825 RIL_Carrier *carrier = pCr->allowed_carriers + i; 4826 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc); 4827 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc); 4828 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type; 4829 carrierInfo.allowedCarriers[i].matchData = 4830 convertCharPtrToHidlString(carrier->match_data); 4831 } 4832 4833 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers); 4834 for(int i = 0; i < pCr->len_excluded_carriers; i++) { 4835 RIL_Carrier *carrier = pCr->excluded_carriers + i; 4836 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc); 4837 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc); 4838 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type; 4839 carrierInfo.excludedCarriers[i].matchData = 4840 convertCharPtrToHidlString(carrier->match_data); 4841 } 4842 } 4843 4844 Return<void> retStatus 4845 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo, 4846 allAllowed, carrierInfo); 4847 radioService[slotId]->checkReturnStatus(retStatus); 4848 } else { 4849 RLOGE("radio::getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", 4850 slotId); 4851 } 4852 4853 return 0; 4854} 4855 4856// Radio Indication functions 4857 4858RadioIndicationType convertIntToRadioIndicationType(int indicationType) { 4859 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) : 4860 (RadioIndicationType::UNSOLICITED_ACK_EXP); 4861} 4862 4863void radio::radioStateChangedInd(int slotId, int indicationType, RIL_RadioState radioState) { 4864 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 4865 RLOGD("radio::radioStateChangedInd: radioState %d", radioState); 4866 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged( 4867 convertIntToRadioIndicationType(indicationType), (RadioState) radioState); 4868 radioService[slotId]->checkReturnStatus(retStatus); 4869 } else { 4870 RLOGE("radio::radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId); 4871 } 4872} 4873 4874int radio::callStateChangedInd(android::Parcel &p, int slotId, int requestNumber, 4875 int indicationType, int token, RIL_Errno e, void *response, 4876 size_t responseLen) { 4877 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 4878 RLOGD("radio::callStateChangedInd"); 4879 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged( 4880 convertIntToRadioIndicationType(indicationType)); 4881 radioService[slotId]->checkReturnStatus(retStatus); 4882 } else { 4883 RLOGE("radio::callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId); 4884 } 4885 4886 return 0; 4887} 4888 4889int radio::networkStateChangedInd(android::Parcel &p, int slotId, int requestNumber, 4890 int indicationType, int token, RIL_Errno e, void *response, 4891 size_t responseLen) { 4892 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 4893 RLOGD("radio::networkStateChangedInd"); 4894 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged( 4895 convertIntToRadioIndicationType(indicationType)); 4896 radioService[slotId]->checkReturnStatus(retStatus); 4897 } else { 4898 RLOGE("radio::networkStateChangedInd: radioService[%d]->mRadioIndication == NULL", 4899 slotId); 4900 } 4901 4902 return 0; 4903} 4904 4905uint8_t hexCharToInt(uint8_t c) { 4906 if (c >= '0' && c <= '9') return (c - '0'); 4907 if (c >= 'A' && c <= 'F') return (c - 'A' + 10); 4908 if (c >= 'a' && c <= 'f') return (c - 'a' + 10); 4909 4910 return INVALID_HEX_CHAR; 4911} 4912 4913uint8_t * convertHexStringToBytes(void *response, size_t responseLen) { 4914 if (responseLen % 2 != 0) { 4915 return NULL; 4916 } 4917 4918 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t)); 4919 if (bytes == NULL) { 4920 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string"); 4921 return NULL; 4922 } 4923 uint8_t *hexString = (uint8_t *)response; 4924 4925 for (int i = 0; i < responseLen; i += 2) { 4926 uint8_t hexChar1 = hexCharToInt(hexString[i]); 4927 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]); 4928 4929 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) { 4930 RLOGE("convertHexStringToBytes: invalid hex char %d %d", 4931 hexString[i], hexString[i + 1]); 4932 free(bytes); 4933 return NULL; 4934 } 4935 bytes[i/2] = ((hexChar1 << 4) | hexChar2); 4936 } 4937 4938 return bytes; 4939} 4940 4941int radio::newSmsInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 4942 int token, RIL_Errno e, void *response, size_t responseLen) { 4943 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 4944 if (response == NULL || responseLen == 0) { 4945 RLOGE("radio::newSmsInd: invalid response"); 4946 return 0; 4947 } 4948 4949 uint8_t *bytes = convertHexStringToBytes(response, responseLen); 4950 if (bytes == NULL) { 4951 RLOGE("radio::newSmsInd: convertHexStringToBytes failed"); 4952 return 0; 4953 } 4954 4955 hidl_vec<uint8_t> pdu; 4956 pdu.setToExternal(bytes, responseLen/2); 4957 RLOGD("radio::newSmsInd"); 4958 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms( 4959 convertIntToRadioIndicationType(indicationType), pdu); 4960 radioService[slotId]->checkReturnStatus(retStatus); 4961 free(bytes); 4962 } else { 4963 RLOGE("radio::newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId); 4964 } 4965 4966 return 0; 4967} 4968 4969int radio::newSmsStatusReportInd(android::Parcel &p, int slotId, int requestNumber, 4970 int indicationType, int token, RIL_Errno e, void *response, 4971 size_t responseLen) { 4972 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 4973 if (response == NULL || responseLen == 0) { 4974 RLOGE("radio::newSmsStatusReportInd: invalid response"); 4975 return 0; 4976 } 4977 4978 uint8_t *bytes = convertHexStringToBytes(response, responseLen); 4979 if (bytes == NULL) { 4980 RLOGE("radio::newSmsStatusReportInd: convertHexStringToBytes failed"); 4981 return 0; 4982 } 4983 4984 hidl_vec<uint8_t> pdu; 4985 pdu.setToExternal(bytes, responseLen/2); 4986 RLOGD("radio::newSmsStatusReportInd"); 4987 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport( 4988 convertIntToRadioIndicationType(indicationType), pdu); 4989 radioService[slotId]->checkReturnStatus(retStatus); 4990 free(bytes); 4991 } else { 4992 RLOGE("radio::newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId); 4993 } 4994 4995 return 0; 4996} 4997 4998int radio::newSmsOnSimInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 4999 int token, RIL_Errno e, void *response, size_t responseLen) { 5000 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5001 if (response == NULL || responseLen != sizeof(int)) { 5002 RLOGE("radio::newSmsOnSimInd: invalid response"); 5003 return 0; 5004 } 5005 int32_t recordNumber = ((int32_t *) response)[0]; 5006 RLOGD("radio::newSmsOnSimInd: slotIndex %d", recordNumber); 5007 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim( 5008 convertIntToRadioIndicationType(indicationType), recordNumber); 5009 radioService[slotId]->checkReturnStatus(retStatus); 5010 } else { 5011 RLOGE("radio::newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId); 5012 } 5013 5014 return 0; 5015} 5016 5017int radio::onUssdInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 5018 int token, RIL_Errno e, void *response, size_t responseLen) { 5019 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5020 if (response == NULL || responseLen != 2 * sizeof(char *)) { 5021 RLOGE("radio::onUssdInd: invalid response"); 5022 return 0; 5023 } 5024 char **strings = (char **) response; 5025 char *mode = strings[0]; 5026 hidl_string msg = convertCharPtrToHidlString(strings[1]); 5027 UssdModeType modeType = (UssdModeType) atoi(mode); 5028 RLOGD("radio::onUssdInd: mode %s", mode); 5029 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd( 5030 convertIntToRadioIndicationType(indicationType), modeType, msg); 5031 radioService[slotId]->checkReturnStatus(retStatus); 5032 } else { 5033 RLOGE("radio::onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId); 5034 } 5035 5036 return 0; 5037} 5038 5039int radio::nitzTimeReceivedInd(android::Parcel &p, int slotId, int requestNumber, 5040 int indicationType, int token, RIL_Errno e, void *response, 5041 size_t responseLen) { 5042 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5043 if (response == NULL || responseLen == 0) { 5044 RLOGE("radio::nitzTimeReceivedInd: invalid response"); 5045 return 0; 5046 } 5047 hidl_string nitzTime = convertCharPtrToHidlString((char *) response); 5048 int64_t timeReceived = android::elapsedRealtime(); 5049 RLOGD("radio::nitzTimeReceivedInd: nitzTime %s receivedTime %ld", nitzTime.c_str(), 5050 timeReceived); 5051 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived( 5052 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived); 5053 radioService[slotId]->checkReturnStatus(retStatus); 5054 } else { 5055 RLOGE("radio::nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId); 5056 return -1; 5057 } 5058 5059 return 0; 5060} 5061 5062void convertRilSignalStrengthToHal(void *response, size_t responseLen, 5063 SignalStrength& signalStrength) { 5064 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response; 5065 5066 // Fixup LTE for backwards compatibility 5067 // signalStrength: -1 -> 99 5068 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) { 5069 rilSignalStrength->LTE_SignalStrength.signalStrength = 99; 5070 } 5071 // rsrp: -1 -> INT_MAX all other negative value to positive. 5072 // So remap here 5073 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) { 5074 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX; 5075 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) { 5076 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp; 5077 } 5078 // rsrq: -1 -> INT_MAX 5079 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) { 5080 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX; 5081 } 5082 // Not remapping rssnr is already using INT_MAX 5083 // cqi: -1 -> INT_MAX 5084 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) { 5085 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX; 5086 } 5087 5088 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength; 5089 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate; 5090 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm; 5091 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio; 5092 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm; 5093 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio; 5094 signalStrength.evdo.signalNoiseRatio = 5095 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio; 5096 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength; 5097 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp; 5098 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq; 5099 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr; 5100 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi; 5101 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance; 5102 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp; 5103} 5104 5105int radio::currentSignalStrengthInd(android::Parcel &p, int slotId, int requestNumber, 5106 int indicationType, int token, RIL_Errno e, 5107 void *response, size_t responseLen) { 5108 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5109 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) { 5110 RLOGE("radio::currentSignalStrengthInd: invalid response"); 5111 return 0; 5112 } 5113 5114 SignalStrength signalStrength; 5115 convertRilSignalStrengthToHal(response, responseLen, signalStrength); 5116 5117 RLOGD("radio::currentSignalStrengthInd"); 5118 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength( 5119 convertIntToRadioIndicationType(indicationType), signalStrength); 5120 radioService[slotId]->checkReturnStatus(retStatus); 5121 } else { 5122 RLOGE("radio::currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL", 5123 slotId); 5124 } 5125 5126 return 0; 5127} 5128 5129void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse, 5130 SetupDataCallResult& dcResult) { 5131 dcResult.status = dcResponse->status; 5132 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime; 5133 dcResult.cid = dcResponse->cid; 5134 dcResult.active = dcResponse->active; 5135 dcResult.type = convertCharPtrToHidlString(dcResponse->type); 5136 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname); 5137 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses); 5138 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses); 5139 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways); 5140 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf); 5141 dcResult.mtu = dcResponse->mtu; 5142} 5143 5144void convertRilDataCallListToHal(void *response, size_t responseLen, 5145 hidl_vec<SetupDataCallResult>& dcResultList) { 5146 int num = responseLen / sizeof(RIL_Data_Call_Response_v11); 5147 5148 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response; 5149 dcResultList.resize(num); 5150 for (int i = 0; i < num; i++) { 5151 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]); 5152 } 5153} 5154 5155int radio::dataCallListChangedInd(android::Parcel &p, int slotId, int requestNumber, 5156 int indicationType, int token, RIL_Errno e, void *response, 5157 size_t responseLen) { 5158 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5159 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) { 5160 RLOGE("radio::dataCallListChangedInd: invalid response"); 5161 return 0; 5162 } 5163 hidl_vec<SetupDataCallResult> dcList; 5164 convertRilDataCallListToHal(response, responseLen, dcList); 5165 RLOGD("radio::dataCallListChangedInd"); 5166 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged( 5167 convertIntToRadioIndicationType(indicationType), dcList); 5168 radioService[slotId]->checkReturnStatus(retStatus); 5169 } else { 5170 RLOGE("radio::dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId); 5171 } 5172 5173 return 0; 5174} 5175 5176int radio::suppSvcNotifyInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 5177 int token, RIL_Errno e, void *response, size_t responseLen) { 5178 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5179 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) { 5180 RLOGE("radio::suppSvcNotifyInd: invalid response"); 5181 return 0; 5182 } 5183 5184 SuppSvcNotification suppSvc; 5185 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response; 5186 suppSvc.isMT = ssn->notificationType; 5187 suppSvc.code = ssn->code; 5188 suppSvc.index = ssn->index; 5189 suppSvc.type = ssn->type; 5190 suppSvc.number = convertCharPtrToHidlString(ssn->number); 5191 5192 RLOGD("radio::suppSvcNotifyInd: isMT %d code %d index %d type %d", 5193 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type); 5194 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify( 5195 convertIntToRadioIndicationType(indicationType), suppSvc); 5196 radioService[slotId]->checkReturnStatus(retStatus); 5197 } else { 5198 RLOGE("radio::suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId); 5199 } 5200 5201 return 0; 5202} 5203 5204int radio::stkSessionEndInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 5205 int token, RIL_Errno e, void *response, size_t responseLen) { 5206 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5207 RLOGD("radio::stkSessionEndInd"); 5208 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd( 5209 convertIntToRadioIndicationType(indicationType)); 5210 radioService[slotId]->checkReturnStatus(retStatus); 5211 } else { 5212 RLOGE("radio::stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId); 5213 } 5214 5215 return 0; 5216} 5217 5218int radio::stkProactiveCommandInd(android::Parcel &p, int slotId, int requestNumber, 5219 int indicationType, int token, RIL_Errno e, void *response, 5220 size_t responseLen) { 5221 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5222 if (response == NULL || responseLen == 0) { 5223 RLOGE("radio::stkProactiveCommandInd: invalid response"); 5224 return 0; 5225 } 5226 RLOGD("radio::stkProactiveCommandInd"); 5227 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand( 5228 convertIntToRadioIndicationType(indicationType), 5229 convertCharPtrToHidlString((char *) response)); 5230 radioService[slotId]->checkReturnStatus(retStatus); 5231 } else { 5232 RLOGE("radio::stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId); 5233 } 5234 5235 return 0; 5236} 5237 5238int radio::stkEventNotifyInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 5239 int token, RIL_Errno e, void *response, size_t responseLen) { 5240 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5241 if (response == NULL || responseLen == 0) { 5242 RLOGE("radio::stkEventNotifyInd: invalid response"); 5243 return 0; 5244 } 5245 RLOGD("radio::stkEventNotifyInd"); 5246 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify( 5247 convertIntToRadioIndicationType(indicationType), 5248 convertCharPtrToHidlString((char *) response)); 5249 radioService[slotId]->checkReturnStatus(retStatus); 5250 } else { 5251 RLOGE("radio::stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId); 5252 } 5253 5254 return 0; 5255} 5256 5257int radio::stkCallSetupInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 5258 int token, RIL_Errno e, void *response, size_t responseLen) { 5259 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5260 if (response == NULL || responseLen != sizeof(int)) { 5261 RLOGE("radio::stkCallSetupInd: invalid response"); 5262 return 0; 5263 } 5264 int32_t timeout = ((int32_t *) response)[0]; 5265 RLOGD("radio::stkCallSetupInd: timeout %d", timeout); 5266 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup( 5267 convertIntToRadioIndicationType(indicationType), timeout); 5268 radioService[slotId]->checkReturnStatus(retStatus); 5269 } else { 5270 RLOGE("radio::stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId); 5271 } 5272 5273 return 0; 5274} 5275 5276int radio::simSmsStorageFullInd(android::Parcel &p, int slotId, int requestNumber, 5277 int indicationType, int token, RIL_Errno e, void *response, 5278 size_t responseLen) { 5279 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5280 RLOGD("radio::simSmsStorageFullInd"); 5281 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull( 5282 convertIntToRadioIndicationType(indicationType)); 5283 radioService[slotId]->checkReturnStatus(retStatus); 5284 } else { 5285 RLOGE("radio::simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId); 5286 } 5287 5288 return 0; 5289} 5290 5291int radio::simRefreshInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 5292 int token, RIL_Errno e, void *response, size_t responseLen) { 5293 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5294 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) { 5295 RLOGE("radio::simRefreshInd: invalid response"); 5296 return 0; 5297 } 5298 5299 SimRefreshResult refreshResult; 5300 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response); 5301 refreshResult.type = 5302 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result; 5303 refreshResult.efId = simRefreshResponse->ef_id; 5304 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid); 5305 5306 RLOGD("radio::simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId); 5307 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh( 5308 convertIntToRadioIndicationType(indicationType), refreshResult); 5309 radioService[slotId]->checkReturnStatus(retStatus); 5310 } else { 5311 RLOGE("radio::simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId); 5312 } 5313 5314 return 0; 5315} 5316 5317void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord, 5318 CdmaSignalInfoRecord& record) { 5319 record.isPresent = signalInfoRecord->isPresent; 5320 record.signalType = signalInfoRecord->signalType; 5321 record.alertPitch = signalInfoRecord->alertPitch; 5322 record.signal = signalInfoRecord->signal; 5323} 5324 5325int radio::callRingInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 5326 int token, RIL_Errno e, void *response, size_t responseLen) { 5327 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5328 bool isGsm; 5329 CdmaSignalInfoRecord record; 5330 if (response == NULL || responseLen == 0) { 5331 isGsm = true; 5332 } else { 5333 isGsm = false; 5334 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) { 5335 RLOGE("radio::callRingInd: invalid response"); 5336 return 0; 5337 } 5338 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record); 5339 } 5340 5341 RLOGD("radio::callRingInd: isGsm %d", isGsm); 5342 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing( 5343 convertIntToRadioIndicationType(indicationType), isGsm, record); 5344 radioService[slotId]->checkReturnStatus(retStatus); 5345 } else { 5346 RLOGE("radio::callRingInd: radioService[%d]->mRadioIndication == NULL", slotId); 5347 } 5348 5349 return 0; 5350} 5351 5352int radio::simStatusChangedInd(android::Parcel &p, int slotId, int requestNumber, 5353 int indicationType, int token, RIL_Errno e, void *response, 5354 size_t responseLen) { 5355 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5356 RLOGD("radio::simStatusChangedInd"); 5357 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged( 5358 convertIntToRadioIndicationType(indicationType)); 5359 radioService[slotId]->checkReturnStatus(retStatus); 5360 } else { 5361 RLOGE("radio::simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId); 5362 } 5363 5364 return 0; 5365} 5366 5367int radio::cdmaNewSmsInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 5368 int token, RIL_Errno e, void *response, size_t responseLen) { 5369 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5370 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) { 5371 RLOGE("radio::cdmaNewSmsInd: invalid response"); 5372 return 0; 5373 } 5374 5375 CdmaSmsMessage msg; 5376 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response; 5377 msg.teleserviceId = rilMsg->uTeleserviceID; 5378 msg.isServicePresent = rilMsg->bIsServicePresent; 5379 msg.serviceCategory = rilMsg->uServicecategory; 5380 msg.address.digitMode = 5381 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode; 5382 msg.address.numberMode = 5383 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode; 5384 msg.address.numberType = 5385 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type; 5386 msg.address.numberPlan = 5387 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan; 5388 5389 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); 5390 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit); 5391 5392 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType) 5393 rilMsg->sSubAddress.subaddressType; 5394 msg.subAddress.odd = rilMsg->sSubAddress.odd; 5395 5396 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); 5397 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit); 5398 5399 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); 5400 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit); 5401 5402 RLOGD("radio::cdmaNewSmsInd"); 5403 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms( 5404 convertIntToRadioIndicationType(indicationType), msg); 5405 radioService[slotId]->checkReturnStatus(retStatus); 5406 } else { 5407 RLOGE("radio::cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId); 5408 } 5409 5410 return 0; 5411} 5412 5413int radio::newBroadcastSmsInd(android::Parcel &p, int slotId, int requestNumber, 5414 int indicationType, int token, RIL_Errno e, void *response, 5415 size_t responseLen) { 5416 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5417 if (response == NULL || responseLen == 0) { 5418 RLOGE("radio::newBroadcastSmsInd: invalid response"); 5419 return 0; 5420 } 5421 5422 hidl_vec<uint8_t> data; 5423 data.setToExternal((uint8_t *) response, responseLen); 5424 RLOGD("radio::newBroadcastSmsInd"); 5425 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms( 5426 convertIntToRadioIndicationType(indicationType), data); 5427 radioService[slotId]->checkReturnStatus(retStatus); 5428 } else { 5429 RLOGE("radio::newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId); 5430 } 5431 5432 return 0; 5433} 5434 5435int radio::cdmaRuimSmsStorageFullInd(android::Parcel &p, int slotId, int requestNumber, 5436 int indicationType, int token, RIL_Errno e, void *response, 5437 size_t responseLen) { 5438 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5439 RLOGD("radio::cdmaRuimSmsStorageFullInd"); 5440 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull( 5441 convertIntToRadioIndicationType(indicationType)); 5442 radioService[slotId]->checkReturnStatus(retStatus); 5443 } else { 5444 RLOGE("radio::cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", 5445 slotId); 5446 } 5447 5448 return 0; 5449} 5450 5451int radio::restrictedStateChangedInd(android::Parcel &p, int slotId, int requestNumber, 5452 int indicationType, int token, RIL_Errno e, void *response, 5453 size_t responseLen) { 5454 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5455 if (response == NULL || responseLen != sizeof(int)) { 5456 RLOGE("radio::restrictedStateChangedInd: invalid response"); 5457 return 0; 5458 } 5459 int32_t state = ((int32_t *) response)[0]; 5460 RLOGD("radio::restrictedStateChangedInd: state %d", state); 5461 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged( 5462 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state); 5463 radioService[slotId]->checkReturnStatus(retStatus); 5464 } else { 5465 RLOGE("radio::restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL", 5466 slotId); 5467 } 5468 5469 return 0; 5470} 5471 5472int radio::enterEmergencyCallbackModeInd(android::Parcel &p, int slotId, int requestNumber, 5473 int indicationType, int token, RIL_Errno e, void *response, 5474 size_t responseLen) { 5475 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5476 RLOGD("radio::enterEmergencyCallbackModeInd"); 5477 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode( 5478 convertIntToRadioIndicationType(indicationType)); 5479 radioService[slotId]->checkReturnStatus(retStatus); 5480 } else { 5481 RLOGE("radio::enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL", 5482 slotId); 5483 } 5484 5485 return 0; 5486} 5487 5488int radio::cdmaCallWaitingInd(android::Parcel &p, int slotId, int requestNumber, 5489 int indicationType, int token, RIL_Errno e, void *response, 5490 size_t responseLen) { 5491 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5492 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) { 5493 RLOGE("radio::cdmaCallWaitingInd: invalid response"); 5494 return 0; 5495 } 5496 5497 CdmaCallWaiting callWaitingRecord; 5498 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response); 5499 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number); 5500 callWaitingRecord.numberPresentation = 5501 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation; 5502 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name); 5503 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord, 5504 callWaitingRecord.signalInfoRecord); 5505 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type; 5506 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan; 5507 5508 RLOGD("radio::cdmaCallWaitingInd"); 5509 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting( 5510 convertIntToRadioIndicationType(indicationType), callWaitingRecord); 5511 radioService[slotId]->checkReturnStatus(retStatus); 5512 } else { 5513 RLOGE("radio::cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId); 5514 } 5515 5516 return 0; 5517} 5518 5519int radio::cdmaOtaProvisionStatusInd(android::Parcel &p, int slotId, int requestNumber, 5520 int indicationType, int token, RIL_Errno e, void *response, 5521 size_t responseLen) { 5522 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5523 if (response == NULL || responseLen != sizeof(int)) { 5524 RLOGE("radio::cdmaOtaProvisionStatusInd: invalid response"); 5525 return 0; 5526 } 5527 int32_t status = ((int32_t *) response)[0]; 5528 RLOGD("radio::cdmaOtaProvisionStatusInd: status %d", status); 5529 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus( 5530 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status); 5531 radioService[slotId]->checkReturnStatus(retStatus); 5532 } else { 5533 RLOGE("radio::cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL", 5534 slotId); 5535 } 5536 5537 return 0; 5538} 5539 5540int radio::cdmaInfoRecInd(android::Parcel &p, int slotId, int requestNumber, 5541 int indicationType, int token, RIL_Errno e, void *response, 5542 size_t responseLen) { 5543 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5544 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) { 5545 RLOGE("radio::cdmaInfoRecInd: invalid response"); 5546 return 0; 5547 } 5548 5549 CdmaInformationRecords records; 5550 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response; 5551 5552 char* string8 = NULL; 5553 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS); 5554 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) { 5555 RLOGE("radio::cdmaInfoRecInd: received %d recs which is more than %d, dropping " 5556 "additional ones", recordsRil->numberOfInfoRecs, 5557 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS); 5558 } 5559 records.infoRec.resize(num); 5560 for (int i = 0 ; i < num ; i++) { 5561 CdmaInformationRecord *record = &records.infoRec[i]; 5562 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i]; 5563 record->name = (CdmaInfoRecName) infoRec->name; 5564 // All vectors should be size 0 except one which will be size 1. Set everything to 5565 // size 0 initially. 5566 record->display.resize(0); 5567 record->number.resize(0); 5568 record->signal.resize(0); 5569 record->redir.resize(0); 5570 record->lineCtrl.resize(0); 5571 record->clir.resize(0); 5572 record->audioCtrl.resize(0); 5573 switch (infoRec->name) { 5574 case RIL_CDMA_DISPLAY_INFO_REC: 5575 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: { 5576 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) { 5577 RLOGE("radio::cdmaInfoRecInd: invalid display info response length %d " 5578 "expected not more than %d", (int) infoRec->rec.display.alpha_len, 5579 CDMA_ALPHA_INFO_BUFFER_LENGTH); 5580 return 0; 5581 } 5582 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char)); 5583 if (string8 == NULL) { 5584 RLOGE("radio::cdmaInfoRecInd: Memory allocation failed for " 5585 "responseCdmaInformationRecords"); 5586 return 0; 5587 } 5588 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len); 5589 string8[(int)infoRec->rec.display.alpha_len] = '\0'; 5590 5591 record->display.resize(1); 5592 record->display[0].alphaBuf = string8; 5593 free(string8); 5594 string8 = NULL; 5595 break; 5596 } 5597 5598 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC: 5599 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC: 5600 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: { 5601 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) { 5602 RLOGE("radio::cdmaInfoRecInd: invalid display info response length %d " 5603 "expected not more than %d", (int) infoRec->rec.number.len, 5604 CDMA_NUMBER_INFO_BUFFER_LENGTH); 5605 return 0; 5606 } 5607 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char)); 5608 if (string8 == NULL) { 5609 RLOGE("radio::cdmaInfoRecInd: Memory allocation failed for " 5610 "responseCdmaInformationRecords"); 5611 return 0; 5612 } 5613 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len); 5614 string8[(int)infoRec->rec.number.len] = '\0'; 5615 5616 record->number.resize(1); 5617 record->number[0].number = string8; 5618 free(string8); 5619 string8 = NULL; 5620 record->number[0].numberType = infoRec->rec.number.number_type; 5621 record->number[0].numberPlan = infoRec->rec.number.number_plan; 5622 record->number[0].pi = infoRec->rec.number.pi; 5623 record->number[0].si = infoRec->rec.number.si; 5624 break; 5625 } 5626 5627 case RIL_CDMA_SIGNAL_INFO_REC: { 5628 record->signal.resize(1); 5629 record->signal[0].isPresent = infoRec->rec.signal.isPresent; 5630 record->signal[0].signalType = infoRec->rec.signal.signalType; 5631 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch; 5632 record->signal[0].signal = infoRec->rec.signal.signal; 5633 break; 5634 } 5635 5636 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: { 5637 if (infoRec->rec.redir.redirectingNumber.len > 5638 CDMA_NUMBER_INFO_BUFFER_LENGTH) { 5639 RLOGE("radio::cdmaInfoRecInd: invalid display info response length %d " 5640 "expected not more than %d\n", 5641 (int)infoRec->rec.redir.redirectingNumber.len, 5642 CDMA_NUMBER_INFO_BUFFER_LENGTH); 5643 return 0; 5644 } 5645 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) * 5646 sizeof(char)); 5647 if (string8 == NULL) { 5648 RLOGE("radio::cdmaInfoRecInd: Memory allocation failed for " 5649 "responseCdmaInformationRecords"); 5650 return 0; 5651 } 5652 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf, 5653 infoRec->rec.redir.redirectingNumber.len); 5654 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0'; 5655 5656 record->redir.resize(1); 5657 record->redir[0].redirectingNumber.number = string8; 5658 free(string8); 5659 string8 = NULL; 5660 record->redir[0].redirectingNumber.numberType = 5661 infoRec->rec.redir.redirectingNumber.number_type; 5662 record->redir[0].redirectingNumber.numberPlan = 5663 infoRec->rec.redir.redirectingNumber.number_plan; 5664 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi; 5665 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si; 5666 record->redir[0].redirectingReason = 5667 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason; 5668 break; 5669 } 5670 5671 case RIL_CDMA_LINE_CONTROL_INFO_REC: { 5672 record->lineCtrl.resize(1); 5673 record->lineCtrl[0].lineCtrlPolarityIncluded = 5674 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded; 5675 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle; 5676 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse; 5677 record->lineCtrl[0].lineCtrlPowerDenial = 5678 infoRec->rec.lineCtrl.lineCtrlPowerDenial; 5679 break; 5680 } 5681 5682 case RIL_CDMA_T53_CLIR_INFO_REC: { 5683 record->clir.resize(1); 5684 record->clir[0].cause = infoRec->rec.clir.cause; 5685 break; 5686 } 5687 5688 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: { 5689 record->audioCtrl.resize(1); 5690 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink; 5691 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink; 5692 break; 5693 } 5694 5695 case RIL_CDMA_T53_RELEASE_INFO_REC: 5696 RLOGE("radio::cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID"); 5697 return 0; 5698 5699 default: 5700 RLOGE("radio::cdmaInfoRecInd: Incorrect name value"); 5701 return 0; 5702 } 5703 } 5704 5705 RLOGD("radio::cdmaInfoRecInd"); 5706 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec( 5707 convertIntToRadioIndicationType(indicationType), records); 5708 radioService[slotId]->checkReturnStatus(retStatus); 5709 } else { 5710 RLOGE("radio::cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId); 5711 } 5712 5713 return 0; 5714} 5715 5716int radio::oemHookRawInd(android::Parcel &p, int slotId, int requestNumber, 5717 int indicationType, int token, RIL_Errno e, void *response, 5718 size_t responseLen) { 5719 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5720 if (response == NULL || responseLen == 0) { 5721 RLOGE("radio::oemHookRawInd: invalid response"); 5722 return 0; 5723 } 5724 5725 hidl_vec<uint8_t> data; 5726 data.setToExternal((uint8_t *) response, responseLen); 5727 RLOGD("radio::oemHookRawInd"); 5728 Return<void> retStatus = radioService[slotId]->mRadioIndication->oemHookRaw( 5729 convertIntToRadioIndicationType(indicationType), data); 5730 radioService[slotId]->checkReturnStatus(retStatus); 5731 } else { 5732 RLOGE("radio::oemHookRawInd: radioService[%d]->mRadioIndication == NULL", slotId); 5733 } 5734 5735 return 0; 5736} 5737 5738int radio::indicateRingbackToneInd(android::Parcel &p, int slotId, int requestNumber, 5739 int indicationType, int token, RIL_Errno e, void *response, 5740 size_t responseLen) { 5741 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5742 if (response == NULL || responseLen != sizeof(int)) { 5743 RLOGE("radio::indicateRingbackToneInd: invalid response"); 5744 return 0; 5745 } 5746 bool start = ((int32_t *) response)[0]; 5747 RLOGD("radio::indicateRingbackToneInd: start %d", start); 5748 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone( 5749 convertIntToRadioIndicationType(indicationType), start); 5750 radioService[slotId]->checkReturnStatus(retStatus); 5751 } else { 5752 RLOGE("radio::indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId); 5753 } 5754 5755 return 0; 5756} 5757 5758int radio::resendIncallMuteInd(android::Parcel &p, int slotId, int requestNumber, 5759 int indicationType, int token, RIL_Errno e, void *response, 5760 size_t responseLen) { 5761 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5762 RLOGD("radio::resendIncallMuteInd"); 5763 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute( 5764 convertIntToRadioIndicationType(indicationType)); 5765 radioService[slotId]->checkReturnStatus(retStatus); 5766 } else { 5767 RLOGE("radio::resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId); 5768 } 5769 5770 return 0; 5771} 5772 5773int radio::cdmaSubscriptionSourceChangedInd(android::Parcel &p, int slotId, int requestNumber, 5774 int indicationType, int token, RIL_Errno e, 5775 void *response, size_t responseLen) { 5776 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5777 if (response == NULL || responseLen != sizeof(int)) { 5778 RLOGE("radio::cdmaSubscriptionSourceChangedInd: invalid response"); 5779 return 0; 5780 } 5781 int32_t cdmaSource = ((int32_t *) response)[0]; 5782 RLOGD("radio::cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource); 5783 Return<void> retStatus = radioService[slotId]->mRadioIndication-> 5784 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType), 5785 (CdmaSubscriptionSource) cdmaSource); 5786 radioService[slotId]->checkReturnStatus(retStatus); 5787 } else { 5788 RLOGE("radio::cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL", 5789 slotId); 5790 } 5791 5792 return 0; 5793} 5794 5795int radio::cdmaPrlChangedInd(android::Parcel &p, int slotId, int requestNumber, 5796 int indicationType, int token, RIL_Errno e, void *response, 5797 size_t responseLen) { 5798 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5799 if (response == NULL || responseLen != sizeof(int)) { 5800 RLOGE("radio::cdmaPrlChangedInd: invalid response"); 5801 return 0; 5802 } 5803 int32_t version = ((int32_t *) response)[0]; 5804 RLOGD("radio::cdmaPrlChangedInd: version %d", version); 5805 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged( 5806 convertIntToRadioIndicationType(indicationType), version); 5807 radioService[slotId]->checkReturnStatus(retStatus); 5808 } else { 5809 RLOGE("radio::cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId); 5810 } 5811 5812 return 0; 5813} 5814 5815int radio::exitEmergencyCallbackModeInd(android::Parcel &p, int slotId, int requestNumber, 5816 int indicationType, int token, RIL_Errno e, void *response, 5817 size_t responseLen) { 5818 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5819 RLOGD("radio::exitEmergencyCallbackModeInd"); 5820 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode( 5821 convertIntToRadioIndicationType(indicationType)); 5822 radioService[slotId]->checkReturnStatus(retStatus); 5823 } else { 5824 RLOGE("radio::exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL", 5825 slotId); 5826 } 5827 5828 return 0; 5829} 5830 5831int radio::rilConnectedInd(android::Parcel &p, int slotId, int requestNumber, 5832 int indicationType, int token, RIL_Errno e, void *response, 5833 size_t responseLen) { 5834 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5835 RLOGD("radio::rilConnectedInd"); 5836 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected( 5837 convertIntToRadioIndicationType(indicationType)); 5838 radioService[slotId]->checkReturnStatus(retStatus); 5839 } else { 5840 RLOGE("radio::rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId); 5841 } 5842 5843 return 0; 5844} 5845 5846int radio::voiceRadioTechChangedInd(android::Parcel &p, int slotId, int requestNumber, 5847 int indicationType, int token, RIL_Errno e, void *response, 5848 size_t responseLen) { 5849 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5850 if (response == NULL || responseLen != sizeof(int)) { 5851 RLOGE("radio::voiceRadioTechChangedInd: invalid response"); 5852 return 0; 5853 } 5854 int32_t rat = ((int32_t *) response)[0]; 5855 RLOGD("radio::voiceRadioTechChangedInd: rat %d", rat); 5856 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged( 5857 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat); 5858 radioService[slotId]->checkReturnStatus(retStatus); 5859 } else { 5860 RLOGE("radio::voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL", 5861 slotId); 5862 } 5863 5864 return 0; 5865} 5866 5867void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) { 5868 int num = responseLen / sizeof(RIL_CellInfo_v12); 5869 records.resize(num); 5870 5871 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response; 5872 for (int i = 0; i < num; i++) { 5873 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType; 5874 records[i].registered = rillCellInfo->registered; 5875 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType; 5876 records[i].timeStamp = rillCellInfo->timeStamp; 5877 // All vectors should be size 0 except one which will be size 1. Set everything to 5878 // size 0 initially. 5879 records[i].gsm.resize(0); 5880 records[i].wcdma.resize(0); 5881 records[i].cdma.resize(0); 5882 records[i].lte.resize(0); 5883 records[i].tdscdma.resize(0); 5884 switch(rillCellInfo->cellInfoType) { 5885 case RIL_CELL_INFO_TYPE_GSM: { 5886 records[i].gsm.resize(1); 5887 CellInfoGsm *cellInfoGsm = &records[i].gsm[0]; 5888 cellInfoGsm->cellIdentityGsm.mcc = 5889 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc); 5890 cellInfoGsm->cellIdentityGsm.mnc = 5891 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc); 5892 cellInfoGsm->cellIdentityGsm.lac = 5893 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac; 5894 cellInfoGsm->cellIdentityGsm.cid = 5895 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid; 5896 cellInfoGsm->cellIdentityGsm.arfcn = 5897 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn; 5898 cellInfoGsm->cellIdentityGsm.bsic = 5899 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic; 5900 cellInfoGsm->signalStrengthGsm.signalStrength = 5901 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength; 5902 cellInfoGsm->signalStrengthGsm.bitErrorRate = 5903 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate; 5904 cellInfoGsm->signalStrengthGsm.timingAdvance = 5905 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance; 5906 break; 5907 } 5908 5909 case RIL_CELL_INFO_TYPE_WCDMA: { 5910 records[i].wcdma.resize(1); 5911 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0]; 5912 cellInfoWcdma->cellIdentityWcdma.mcc = 5913 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc); 5914 cellInfoWcdma->cellIdentityWcdma.mnc = 5915 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc); 5916 cellInfoWcdma->cellIdentityWcdma.lac = 5917 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac; 5918 cellInfoWcdma->cellIdentityWcdma.cid = 5919 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid; 5920 cellInfoWcdma->cellIdentityWcdma.psc = 5921 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc; 5922 cellInfoWcdma->cellIdentityWcdma.uarfcn = 5923 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn; 5924 cellInfoWcdma->signalStrengthWcdma.signalStrength = 5925 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength; 5926 cellInfoWcdma->signalStrengthWcdma.bitErrorRate = 5927 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate; 5928 break; 5929 } 5930 5931 case RIL_CELL_INFO_TYPE_CDMA: { 5932 records[i].cdma.resize(1); 5933 CellInfoCdma *cellInfoCdma = &records[i].cdma[0]; 5934 cellInfoCdma->cellIdentityCdma.networkId = 5935 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId; 5936 cellInfoCdma->cellIdentityCdma.systemId = 5937 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId; 5938 cellInfoCdma->cellIdentityCdma.baseStationId = 5939 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId; 5940 cellInfoCdma->cellIdentityCdma.longitude = 5941 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude; 5942 cellInfoCdma->cellIdentityCdma.latitude = 5943 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude; 5944 cellInfoCdma->signalStrengthCdma.dbm = 5945 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm; 5946 cellInfoCdma->signalStrengthCdma.ecio = 5947 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio; 5948 cellInfoCdma->signalStrengthEvdo.dbm = 5949 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm; 5950 cellInfoCdma->signalStrengthEvdo.ecio = 5951 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio; 5952 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio = 5953 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio; 5954 break; 5955 } 5956 5957 case RIL_CELL_INFO_TYPE_LTE: { 5958 records[i].lte.resize(1); 5959 CellInfoLte *cellInfoLte = &records[i].lte[0]; 5960 cellInfoLte->cellIdentityLte.mcc = 5961 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc); 5962 cellInfoLte->cellIdentityLte.mnc = 5963 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc); 5964 cellInfoLte->cellIdentityLte.ci = 5965 rillCellInfo->CellInfo.lte.cellIdentityLte.ci; 5966 cellInfoLte->cellIdentityLte.pci = 5967 rillCellInfo->CellInfo.lte.cellIdentityLte.pci; 5968 cellInfoLte->cellIdentityLte.tac = 5969 rillCellInfo->CellInfo.lte.cellIdentityLte.tac; 5970 cellInfoLte->cellIdentityLte.earfcn = 5971 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn; 5972 cellInfoLte->signalStrengthLte.signalStrength = 5973 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength; 5974 cellInfoLte->signalStrengthLte.rsrp = 5975 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp; 5976 cellInfoLte->signalStrengthLte.rsrq = 5977 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq; 5978 cellInfoLte->signalStrengthLte.rssnr = 5979 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr; 5980 cellInfoLte->signalStrengthLte.cqi = 5981 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi; 5982 cellInfoLte->signalStrengthLte.timingAdvance = 5983 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance; 5984 break; 5985 } 5986 5987 case RIL_CELL_INFO_TYPE_TD_SCDMA: { 5988 records[i].tdscdma.resize(1); 5989 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0]; 5990 cellInfoTdscdma->cellIdentityTdscdma.mcc = 5991 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc); 5992 cellInfoTdscdma->cellIdentityTdscdma.mnc = 5993 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc); 5994 cellInfoTdscdma->cellIdentityTdscdma.lac = 5995 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac; 5996 cellInfoTdscdma->cellIdentityTdscdma.cid = 5997 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid; 5998 cellInfoTdscdma->cellIdentityTdscdma.cpid = 5999 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid; 6000 cellInfoTdscdma->signalStrengthTdscdma.rscp = 6001 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp; 6002 break; 6003 } 6004 } 6005 rillCellInfo += 1; 6006 } 6007} 6008 6009int radio::cellInfoListInd(android::Parcel &p, int slotId, int requestNumber, 6010 int indicationType, int token, RIL_Errno e, void *response, 6011 size_t responseLen) { 6012 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6013 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) { 6014 RLOGE("radio::cellInfoListInd: invalid response"); 6015 return 0; 6016 } 6017 6018 hidl_vec<CellInfo> records; 6019 convertRilCellInfoListToHal(response, responseLen, records); 6020 6021 RLOGD("radio::cellInfoListInd"); 6022 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList( 6023 convertIntToRadioIndicationType(indicationType), records); 6024 radioService[slotId]->checkReturnStatus(retStatus); 6025 } else { 6026 RLOGE("radio::cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId); 6027 } 6028 6029 return 0; 6030} 6031 6032int radio::imsNetworkStateChangedInd(android::Parcel &p, int slotId, int requestNumber, 6033 int indicationType, int token, RIL_Errno e, void *response, 6034 size_t responseLen) { 6035 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6036 RLOGD("radio::imsNetworkStateChangedInd"); 6037 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged( 6038 convertIntToRadioIndicationType(indicationType)); 6039 radioService[slotId]->checkReturnStatus(retStatus); 6040 } else { 6041 RLOGE("radio::imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL", 6042 slotId); 6043 } 6044 6045 return 0; 6046} 6047 6048int radio::subscriptionStatusChangedInd(android::Parcel &p, int slotId, int requestNumber, 6049 int indicationType, int token, RIL_Errno e, void *response, 6050 size_t responseLen) { 6051 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6052 if (response == NULL || responseLen != sizeof(int)) { 6053 RLOGE("radio::subscriptionStatusChangedInd: invalid response"); 6054 return 0; 6055 } 6056 bool activate = ((int32_t *) response)[0]; 6057 RLOGD("radio::subscriptionStatusChangedInd: activate %d", activate); 6058 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged( 6059 convertIntToRadioIndicationType(indicationType), activate); 6060 radioService[slotId]->checkReturnStatus(retStatus); 6061 } else { 6062 RLOGE("radio::subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL", 6063 slotId); 6064 } 6065 6066 return 0; 6067} 6068 6069int radio::srvccStateNotifyInd(android::Parcel &p, int slotId, int requestNumber, 6070 int indicationType, int token, RIL_Errno e, void *response, 6071 size_t responseLen) { 6072 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6073 if (response == NULL || responseLen != sizeof(int)) { 6074 RLOGE("radio::srvccStateNotifyInd: invalid response"); 6075 return 0; 6076 } 6077 int32_t state = ((int32_t *) response)[0]; 6078 RLOGD("radio::srvccStateNotifyInd: rat %d", state); 6079 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify( 6080 convertIntToRadioIndicationType(indicationType), (SrvccState) state); 6081 radioService[slotId]->checkReturnStatus(retStatus); 6082 } else { 6083 RLOGE("radio::srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId); 6084 } 6085 6086 return 0; 6087} 6088 6089void convertRilHardwareConfigListToHal(void *response, size_t responseLen, 6090 hidl_vec<HardwareConfig>& records) { 6091 int num = responseLen / sizeof(RIL_HardwareConfig); 6092 records.resize(num); 6093 6094 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response; 6095 for (int i = 0; i < num; i++) { 6096 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type; 6097 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid); 6098 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state; 6099 switch (rilHardwareConfig[i].type) { 6100 case RIL_HARDWARE_CONFIG_MODEM: { 6101 records[i].modem.resize(1); 6102 records[i].sim.resize(0); 6103 HardwareConfigModem *hwConfigModem = &records[i].modem[0]; 6104 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat; 6105 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice; 6106 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData; 6107 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby; 6108 break; 6109 } 6110 6111 case RIL_HARDWARE_CONFIG_SIM: { 6112 records[i].sim.resize(1); 6113 records[i].modem.resize(0); 6114 records[i].sim[0].modemUuid = 6115 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid); 6116 break; 6117 } 6118 } 6119 } 6120} 6121 6122int radio::hardwareConfigChangedInd(android::Parcel &p, int slotId, int requestNumber, 6123 int indicationType, int token, RIL_Errno e, void *response, 6124 size_t responseLen) { 6125 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6126 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) { 6127 RLOGE("radio::hardwareConfigChangedInd: invalid response"); 6128 return 0; 6129 } 6130 6131 hidl_vec<HardwareConfig> configs; 6132 convertRilHardwareConfigListToHal(response, responseLen, configs); 6133 6134 RLOGD("radio::hardwareConfigChangedInd"); 6135 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged( 6136 convertIntToRadioIndicationType(indicationType), configs); 6137 radioService[slotId]->checkReturnStatus(retStatus); 6138 } else { 6139 RLOGE("radio::hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL", 6140 slotId); 6141 } 6142 6143 return 0; 6144} 6145 6146void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) { 6147 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response; 6148 rc.session = rilRadioCapability->session; 6149 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase; 6150 rc.raf = rilRadioCapability->rat; 6151 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid); 6152 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status; 6153} 6154 6155int radio::radioCapabilityIndicationInd(android::Parcel &p, int slotId, int requestNumber, 6156 int indicationType, int token, RIL_Errno e, void *response, 6157 size_t responseLen) { 6158 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6159 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) { 6160 RLOGE("radio::radioCapabilityIndicationInd: invalid response"); 6161 return 0; 6162 } 6163 6164 RadioCapability rc; 6165 convertRilRadioCapabilityToHal(response, responseLen, rc); 6166 6167 RLOGD("radio::radioCapabilityIndicationInd"); 6168 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication( 6169 convertIntToRadioIndicationType(indicationType), rc); 6170 radioService[slotId]->checkReturnStatus(retStatus); 6171 } else { 6172 RLOGE("radio::radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL", 6173 slotId); 6174 } 6175 6176 return 0; 6177} 6178 6179bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) { 6180 if ((reqType == SS_INTERROGATION) && 6181 (serType == SS_CFU || 6182 serType == SS_CF_BUSY || 6183 serType == SS_CF_NO_REPLY || 6184 serType == SS_CF_NOT_REACHABLE || 6185 serType == SS_CF_ALL || 6186 serType == SS_CF_ALL_CONDITIONAL)) { 6187 return true; 6188 } 6189 return false; 6190} 6191 6192int radio::onSupplementaryServiceIndicationInd(android::Parcel &p, int slotId, int requestNumber, 6193 int indicationType, int token, RIL_Errno e, 6194 void *response, size_t responseLen) { 6195 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6196 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) { 6197 RLOGE("radio::onSupplementaryServiceIndicationInd: invalid response"); 6198 return 0; 6199 } 6200 6201 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response; 6202 StkCcUnsolSsResult ss; 6203 ss.serviceType = (SsServiceType) rilSsResponse->serviceType; 6204 ss.requestType = (SsRequestType) rilSsResponse->requestType; 6205 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType; 6206 ss.serviceClass = rilSsResponse->serviceClass; 6207 ss.result = (RadioError) rilSsResponse->result; 6208 6209 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) { 6210 RLOGD("radio::onSupplementaryServiceIndicationInd CF type, num of Cf elements %d", 6211 rilSsResponse->cfData.numValidIndexes); 6212 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) { 6213 RLOGE("radio::onSupplementaryServiceIndicationInd numValidIndexes is greater than " 6214 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES); 6215 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES; 6216 } 6217 6218 ss.cfData.resize(1); 6219 ss.ssInfo.resize(0); 6220 6221 /* number of call info's */ 6222 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes); 6223 6224 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) { 6225 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i]; 6226 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i]; 6227 6228 cfInfo->status = (CallForwardInfoStatus) cf.status; 6229 cfInfo->reason = cf.reason; 6230 cfInfo->serviceClass = cf.serviceClass; 6231 cfInfo->toa = cf.toa; 6232 cfInfo->number = convertCharPtrToHidlString(cf.number); 6233 cfInfo->timeSeconds = cf.timeSeconds; 6234 RLOGD("radio::onSupplementaryServiceIndicationInd: " 6235 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status, 6236 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds); 6237 } 6238 } else { 6239 ss.ssInfo.resize(1); 6240 ss.cfData.resize(0); 6241 6242 /* each int */ 6243 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX); 6244 for (int i = 0; i < SS_INFO_MAX; i++) { 6245 RLOGD("radio::onSupplementaryServiceIndicationInd: Data: %d", 6246 rilSsResponse->ssInfo[i]); 6247 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i]; 6248 } 6249 } 6250 6251 RLOGD("radio::onSupplementaryServiceIndicationInd"); 6252 Return<void> retStatus = radioService[slotId]->mRadioIndication-> 6253 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType), 6254 ss); 6255 radioService[slotId]->checkReturnStatus(retStatus); 6256 } else { 6257 RLOGE("radio::onSupplementaryServiceIndicationInd: " 6258 "radioService[%d]->mRadioIndication == NULL", slotId); 6259 } 6260 6261 return 0; 6262} 6263 6264int radio::stkCallControlAlphaNotifyInd(android::Parcel &p, int slotId, int requestNumber, 6265 int indicationType, int token, RIL_Errno e, void *response, 6266 size_t responseLen) { 6267 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6268 if (response == NULL || responseLen == 0) { 6269 RLOGE("radio::stkCallControlAlphaNotifyInd: invalid response"); 6270 return 0; 6271 } 6272 RLOGD("radio::stkCallControlAlphaNotifyInd"); 6273 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify( 6274 convertIntToRadioIndicationType(indicationType), 6275 convertCharPtrToHidlString((char *) response)); 6276 radioService[slotId]->checkReturnStatus(retStatus); 6277 } else { 6278 RLOGE("radio::stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL", 6279 slotId); 6280 } 6281 6282 return 0; 6283} 6284 6285void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) { 6286 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response; 6287 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps; 6288 lce.confidenceLevel = rilLceDataInfo->confidence_level; 6289 lce.lceSuspended = rilLceDataInfo->lce_suspended; 6290} 6291 6292int radio::lceDataInd(android::Parcel &p, int slotId, int requestNumber, 6293 int indicationType, int token, RIL_Errno e, void *response, 6294 size_t responseLen) { 6295 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6296 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) { 6297 RLOGE("radio::lceDataInd: invalid response"); 6298 return 0; 6299 } 6300 6301 LceDataInfo lce; 6302 convertRilLceDataInfoToHal(response, responseLen, lce); 6303 RLOGD("radio::lceDataInd"); 6304 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData( 6305 convertIntToRadioIndicationType(indicationType), lce); 6306 radioService[slotId]->checkReturnStatus(retStatus); 6307 } else { 6308 RLOGE("radio::lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId); 6309 } 6310 6311 return 0; 6312} 6313 6314int radio::pcoDataInd(android::Parcel &p, int slotId, int requestNumber, 6315 int indicationType, int token, RIL_Errno e, void *response, 6316 size_t responseLen) { 6317 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6318 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) { 6319 RLOGE("radio::pcoDataInd: invalid response"); 6320 return 0; 6321 } 6322 6323 PcoDataInfo pco; 6324 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response; 6325 pco.cid = rilPcoData->cid; 6326 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto); 6327 pco.pcoId = rilPcoData->pco_id; 6328 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length); 6329 6330 RLOGD("radio::pcoDataInd"); 6331 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData( 6332 convertIntToRadioIndicationType(indicationType), pco); 6333 radioService[slotId]->checkReturnStatus(retStatus); 6334 } else { 6335 RLOGE("radio::pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId); 6336 } 6337 6338 return 0; 6339} 6340 6341int radio::modemResetInd(android::Parcel &p, int slotId, int requestNumber, 6342 int indicationType, int token, RIL_Errno e, void *response, 6343 size_t responseLen) { 6344 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6345 if (response == NULL || responseLen == 0) { 6346 RLOGE("radio::modemResetInd: invalid response"); 6347 return 0; 6348 } 6349 RLOGD("radio::modemResetInd"); 6350 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset( 6351 convertIntToRadioIndicationType(indicationType), 6352 convertCharPtrToHidlString((char *) response)); 6353 radioService[slotId]->checkReturnStatus(retStatus); 6354 } else { 6355 RLOGE("radio::modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId); 6356 } 6357 6358 return 0; 6359} 6360 6361void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) { 6362 using namespace android::hardware; 6363 int simCount = 1; 6364 char *serviceNames[] = { 6365 android::RIL_getRilSocketName() 6366 #if (SIM_COUNT >= 2) 6367 , SOCKET2_NAME_RIL 6368 #if (SIM_COUNT >= 3) 6369 , SOCKET3_NAME_RIL 6370 #if (SIM_COUNT >= 4) 6371 , SOCKET4_NAME_RIL 6372 #endif 6373 #endif 6374 #endif 6375 }; 6376 6377 #if (SIM_COUNT >= 2) 6378 simCount = SIM_COUNT; 6379 #endif 6380 6381 configureRpcThreadpool(1, true /* callerWillJoin */); 6382 for (int i = 0; i < simCount; i++) { 6383 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i); 6384 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr); 6385 assert(ret == 0); 6386 6387 radioService[i] = new RadioImpl; 6388 radioService[i]->mSlotId = i; 6389 RLOGD("radio::registerService: starting IRadio %s", serviceNames[i]); 6390 android::status_t status = radioService[i]->registerAsService(serviceNames[i]); 6391 6392 ret = pthread_rwlock_unlock(radioServiceRwlockPtr); 6393 assert(ret == 0); 6394 } 6395 6396 s_vendorFunctions = callbacks; 6397 s_commands = commands; 6398} 6399 6400void rilc_thread_pool() { 6401 joinRpcThreadpool(); 6402} 6403 6404pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) { 6405 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock; 6406 6407 #if (SIM_COUNT >= 2) 6408 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2; 6409 #if (SIM_COUNT >= 3) 6410 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3; 6411 #if (SIM_COUNT >= 4) 6412 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4; 6413 #endif 6414 #endif 6415 #endif 6416 6417 return radioServiceRwlockPtr; 6418} 6419