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