ril_service.cpp revision e0d755c30b98b7eb37242b840b6c11b70bf43acd
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 android::Parcel p; // TODO: should delete this after translation of all commands is complete 463 pRI->pCI->responseFunction(p, (int) pRI->socket_id, pRI->pCI->requestNumber, 464 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0); 465} 466 467/** 468 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the 469 * request with error RIL_E_NO_MEMORY. 470 * Returns true on success, and false on failure. 471 */ 472bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) { 473 size_t len = src.size(); 474 if (len == 0) { 475 *dest = NULL; 476 return true; 477 } 478 *dest = (char *) calloc(len + 1, sizeof(char)); 479 if (*dest == NULL) { 480 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber)); 481 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 482 return false; 483 } 484 strncpy(*dest, src, len + 1); 485 return true; 486} 487 488hidl_string convertCharPtrToHidlString(const char *ptr) { 489 hidl_string ret; 490 if (ptr != NULL) { 491 // TODO: replace this with strnlen 492 ret.setToExternal(ptr, strlen(ptr)); 493 } 494 return ret; 495} 496 497bool dispatchVoid(int serial, int slotId, int request) { 498 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 499 if (pRI == NULL) { 500 return false; 501 } 502 s_vendorFunctions->onRequest(request, NULL, 0, pRI); 503 return true; 504} 505 506bool dispatchString(int serial, int slotId, int request, const char * str) { 507 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 508 if (pRI == NULL) { 509 return false; 510 } 511 512 char *pString; 513 if (!copyHidlStringToRil(&pString, str, pRI)) { 514 return false; 515 } 516 517 s_vendorFunctions->onRequest(request, pString, sizeof(char *), pRI); 518 519 memsetAndFreeStrings(1, pString); 520 return true; 521} 522 523bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) { 524 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 525 if (pRI == NULL) { 526 return false; 527 } 528 529 char **pStrings; 530 pStrings = (char **)calloc(countStrings, sizeof(char *)); 531 if (pStrings == NULL) { 532 RLOGE("Memory allocation failed for request %s", requestToString(request)); 533 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 534 return false; 535 } 536 va_list ap; 537 va_start(ap, countStrings); 538 for (int i = 0; i < countStrings; i++) { 539 const char* str = va_arg(ap, const char *); 540 if (!copyHidlStringToRil(&pStrings[i], str, pRI)) { 541 va_end(ap); 542 for (int j = 0; j < i; j++) { 543 memsetAndFreeStrings(1, pStrings[j]); 544 } 545 free(pStrings); 546 return false; 547 } 548 } 549 va_end(ap); 550 551 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI); 552 553 if (pStrings != NULL) { 554 for (int i = 0 ; i < countStrings ; i++) { 555 memsetAndFreeStrings(1, pStrings[i]); 556 } 557 558#ifdef MEMSET_FREED 559 memset(pStrings, 0, countStrings * sizeof(char *)); 560#endif 561 free(pStrings); 562 } 563 return true; 564} 565 566bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) { 567 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 568 if (pRI == NULL) { 569 return false; 570 } 571 572 int countStrings = data.size(); 573 char **pStrings; 574 pStrings = (char **)calloc(countStrings, sizeof(char *)); 575 if (pStrings == NULL) { 576 RLOGE("Memory allocation failed for request %s", requestToString(request)); 577 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 578 return false; 579 } 580 581 for (int i = 0; i < countStrings; i++) { 582 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) { 583 for (int j = 0; j < i; j++) { 584 memsetAndFreeStrings(1, pStrings[j]); 585 } 586 free(pStrings); 587 return false; 588 } 589 } 590 591 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI); 592 593 if (pStrings != NULL) { 594 for (int i = 0 ; i < countStrings ; i++) { 595 memsetAndFreeStrings(1, pStrings[i]); 596 } 597 598#ifdef MEMSET_FREED 599 memset(pStrings, 0, countStrings * sizeof(char *)); 600#endif 601 free(pStrings); 602 } 603 return true; 604} 605 606bool dispatchInts(int serial, int slotId, int request, int countInts, ...) { 607 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 608 if (pRI == NULL) { 609 return false; 610 } 611 612 int *pInts = (int *)calloc(countInts, sizeof(int)); 613 614 if (pInts == NULL) { 615 RLOGE("Memory allocation failed for request %s", requestToString(request)); 616 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 617 return false; 618 } 619 va_list ap; 620 va_start(ap, countInts); 621 for (int i = 0; i < countInts; i++) { 622 pInts[i] = va_arg(ap, int); 623 } 624 va_end(ap); 625 626 s_vendorFunctions->onRequest(request, pInts, countInts * sizeof(int), pRI); 627 628 if (pInts != NULL) { 629#ifdef MEMSET_FREED 630 memset(pInts, 0, countInts * sizeof(int)); 631#endif 632 free(pInts); 633 } 634 return true; 635} 636 637bool dispatchCallForwardStatus(int serial, int slotId, int request, 638 const CallForwardInfo& callInfo) { 639 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 640 if (pRI == NULL) { 641 return false; 642 } 643 644 RIL_CallForwardInfo cf; 645 cf.status = (int) callInfo.status; 646 cf.reason = callInfo.reason; 647 cf.serviceClass = callInfo.serviceClass; 648 cf.toa = callInfo.toa; 649 cf.timeSeconds = callInfo.timeSeconds; 650 651 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) { 652 return false; 653 } 654 655 s_vendorFunctions->onRequest(request, &cf, sizeof(cf), pRI); 656 657 memsetAndFreeStrings(1, cf.number); 658 659 return true; 660} 661 662bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) { 663 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 664 if (pRI == NULL) { 665 return false; 666 } 667 668 const uint8_t *uData = rawBytes.data(); 669 670 s_vendorFunctions->onRequest(request, (void *) uData, rawBytes.size(), pRI); 671 672 return true; 673} 674 675bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) { 676 RequestInfo *pRI = android::addRequestToList(serial, slotId, request); 677 if (pRI == NULL) { 678 return false; 679 } 680 681 RIL_SIM_APDU apdu; 682 memset (&apdu, 0, sizeof(RIL_SIM_APDU)); 683 684 apdu.sessionid = message.sessionId; 685 apdu.cla = message.cla; 686 apdu.instruction = message.instruction; 687 apdu.p1 = message.p1; 688 apdu.p2 = message.p2; 689 apdu.p3 = message.p3; 690 691 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) { 692 return false; 693 } 694 695 s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI); 696 697 memsetAndFreeStrings(1, apdu.data); 698 699 return true; 700} 701 702void checkReturnStatus(int32_t slotId, Return<void>& ret) { 703 if (ret.isOk() == false) { 704 RLOGE("checkReturnStatus: unable to call response/indication callback"); 705 // Remote process hosting the callbacks must be dead. Reset the callback objects; 706 // there's no other recovery to be done here. When the client process is back up, it will 707 // call setResponseFunctions() 708 709 // Caller should already hold rdlock, release that first 710 // note the current counter to avoid overwriting updates made by another thread before 711 // write lock is acquired. 712 int counter = mCounter[slotId]; 713 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId); 714 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr); 715 assert(ret == 0); 716 717 // acquire wrlock 718 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr); 719 assert(ret == 0); 720 721 // make sure the counter value has not changed 722 if (counter == mCounter[slotId]) { 723 radioService[slotId]->mRadioResponse = NULL; 724 radioService[slotId]->mRadioIndication = NULL; 725 oemHookService[slotId]->mOemHookResponse = NULL; 726 oemHookService[slotId]->mOemHookIndication = NULL; 727 mCounter[slotId]++; 728 } else { 729 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely " 730 "got updated on another thread"); 731 } 732 733 // release wrlock 734 ret = pthread_rwlock_unlock(radioServiceRwlockPtr); 735 assert(ret == 0); 736 737 // Reacquire rdlock 738 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr); 739 assert(ret == 0); 740 } 741} 742 743void RadioImpl::checkReturnStatus(Return<void>& ret) { 744 ::checkReturnStatus(mSlotId, ret); 745} 746 747Return<void> RadioImpl::setResponseFunctions( 748 const ::android::sp<IRadioResponse>& radioResponseParam, 749 const ::android::sp<IRadioIndication>& radioIndicationParam) { 750 RLOGD("RadioImpl::setResponseFunctions"); 751 752 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId); 753 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr); 754 assert(ret == 0); 755 756 mRadioResponse = radioResponseParam; 757 mRadioIndication = radioIndicationParam; 758 mCounter[mSlotId]++; 759 760 ret = pthread_rwlock_unlock(radioServiceRwlockPtr); 761 assert(ret == 0); 762 763 return Void(); 764} 765 766Return<void> RadioImpl::getIccCardStatus(int32_t serial) { 767 RLOGD("RadioImpl::getIccCardStatus: serial %d", serial); 768 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS); 769 return Void(); 770} 771 772Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin, 773 const hidl_string& aid) { 774 RLOGD("RadioImpl::supplyIccPinForApp: serial %d", serial); 775 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN, 776 2, (const char *)pin, (const char *)aid); 777 return Void(); 778} 779 780Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk, 781 const hidl_string& pin, const hidl_string& aid) { 782 RLOGD("RadioImpl::supplyIccPukForApp: serial %d", serial); 783 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK, 784 3, (const char *)puk, (const char *)pin, (const char *)aid); 785 return Void(); 786} 787 788Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2, 789 const hidl_string& aid) { 790 RLOGD("RadioImpl::supplyIccPin2ForApp: serial %d", serial); 791 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2, 792 2, (const char *)pin2, (const char *)aid); 793 return Void(); 794} 795 796Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2, 797 const hidl_string& pin2, const hidl_string& aid) { 798 RLOGD("RadioImpl::supplyIccPuk2ForApp: serial %d", serial); 799 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2, 800 3, (const char *)puk2, (const char *)pin2, (const char *)aid); 801 return Void(); 802} 803 804Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin, 805 const hidl_string& newPin, const hidl_string& aid) { 806 RLOGD("RadioImpl::changeIccPinForApp: serial %d", serial); 807 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN, 808 3, (const char *)oldPin, (const char *)newPin, (const char *)aid); 809 return Void(); 810} 811 812Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2, 813 const hidl_string& newPin2, const hidl_string& aid) { 814 RLOGD("RadioImpl::changeIccPin2ForApp: serial %d", serial); 815 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2, 816 3, (const char *)oldPin2, (const char *)newPin2, (const char *)aid); 817 return Void(); 818} 819 820Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial, 821 const hidl_string& netPin) { 822 RLOGD("RadioImpl::supplyNetworkDepersonalization: serial %d", serial); 823 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, 824 1, (const char *)netPin); 825 return Void(); 826} 827 828Return<void> RadioImpl::getCurrentCalls(int32_t serial) { 829 RLOGD("RadioImpl::getCurrentCalls: serial %d", serial); 830 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS); 831 return Void(); 832} 833 834Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) { 835 RLOGD("RadioImpl::dial: serial %d", serial); 836 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL); 837 if (pRI == NULL) { 838 return Void(); 839 } 840 RIL_Dial dial = {}; 841 RIL_UUS_Info uusInfo = {}; 842 int32_t sizeOfDial = sizeof(dial); 843 844 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) { 845 return Void(); 846 } 847 dial.clir = (int) dialInfo.clir; 848 849 if (dialInfo.uusInfo.size() != 0) { 850 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType; 851 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs; 852 853 if (dialInfo.uusInfo[0].uusData.size() == 0) { 854 uusInfo.uusData = NULL; 855 uusInfo.uusLength = 0; 856 } else { 857 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) { 858 memsetAndFreeStrings(1, dial.address); 859 return Void(); 860 } 861 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size(); 862 } 863 864 dial.uusInfo = &uusInfo; 865 } 866 867 s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI); 868 869 memsetAndFreeStrings(2, dial.address, uusInfo.uusData); 870 871 return Void(); 872} 873 874Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) { 875 RLOGD("RadioImpl::getImsiForApp: serial %d", serial); 876 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI, 877 1, (const char *) aid); 878 return Void(); 879} 880 881Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) { 882 RLOGD("RadioImpl::hangup: serial %d", serial); 883 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex); 884 return Void(); 885} 886 887Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) { 888 RLOGD("RadioImpl::hangupWaitingOrBackground: serial %d", serial); 889 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND); 890 return Void(); 891} 892 893Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) { 894 RLOGD("RadioImpl::hangupForegroundResumeBackground: serial %d", serial); 895 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND); 896 return Void(); 897} 898 899Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) { 900 RLOGD("RadioImpl::switchWaitingOrHoldingAndActive: serial %d", serial); 901 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE); 902 return Void(); 903} 904 905Return<void> RadioImpl::conference(int32_t serial) { 906 RLOGD("RadioImpl::conference: serial %d", serial); 907 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE); 908 return Void(); 909} 910 911Return<void> RadioImpl::rejectCall(int32_t serial) { 912 RLOGD("RadioImpl::rejectCall: serial %d", serial); 913 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB); 914 return Void(); 915} 916 917Return<void> RadioImpl::getLastCallFailCause(int32_t serial) { 918 RLOGD("RadioImpl::getLastCallFailCause: serial %d", serial); 919 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE); 920 return Void(); 921} 922 923Return<void> RadioImpl::getSignalStrength(int32_t serial) { 924 RLOGD("RadioImpl::getSignalStrength: serial %d", serial); 925 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH); 926 return Void(); 927} 928 929Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) { 930 RLOGD("RadioImpl::getVoiceRegistrationState: serial %d", serial); 931 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE); 932 return Void(); 933} 934 935Return<void> RadioImpl::getDataRegistrationState(int32_t serial) { 936 RLOGD("RadioImpl::getDataRegistrationState: serial %d", serial); 937 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE); 938 return Void(); 939} 940 941Return<void> RadioImpl::getOperator(int32_t serial) { 942 RLOGD("RadioImpl::getOperator: serial %d", serial); 943 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR); 944 return Void(); 945} 946 947Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) { 948 RLOGD("RadioImpl::setRadioPower: serial %d on %d", serial, on); 949 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on)); 950 return Void(); 951} 952 953Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) { 954 RLOGD("RadioImpl::sendDtmf: serial %d", serial); 955 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, (const char *) s); 956 return Void(); 957} 958 959Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) { 960 RLOGD("RadioImpl::sendSms: serial %d", serial); 961 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, 962 2, (const char *) message.smscPdu, (const char *) message.pdu); 963 return Void(); 964} 965 966Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) { 967 RLOGD("RadioImpl::sendSMSExpectMore: serial %d", serial); 968 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, 969 2, (const char *) message.smscPdu, (const char *) message.pdu); 970 return Void(); 971} 972 973const char *convertMvnoTypeToString(MvnoType type) { 974 switch (type) { 975 case MvnoType::IMSI: return "imsi"; 976 case MvnoType::GID: return "gid"; 977 case MvnoType::SPN: return "spn"; 978 default: return NULL; 979 } 980} 981 982Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology, 983 const DataProfileInfo& dataProfileInfo, bool modemCognitive, 984 bool roamingAllowed, bool isRoaming) { 985 986 RLOGD("RadioImpl::setupDataCall: serial %d", serial); 987 988 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) { 989 const hidl_string &protocol = 990 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol); 991 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7, 992 std::to_string((int) radioTechnology + 2).c_str(), 993 std::to_string((int) dataProfileInfo.profileId).c_str(), 994 dataProfileInfo.apn.c_str(), 995 dataProfileInfo.user.c_str(), 996 dataProfileInfo.password.c_str(), 997 std::to_string((int) dataProfileInfo.authType).c_str(), 998 protocol.c_str()); 999 } else if (s_vendorFunctions->version >= 15) { 1000 const char *mvnoTypeStr = convertMvnoTypeToString(dataProfileInfo.mvnoType); 1001 if (mvnoTypeStr == NULL) { 1002 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1003 RIL_REQUEST_SETUP_DATA_CALL); 1004 if (pRI != NULL) { 1005 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS); 1006 } 1007 return Void(); 1008 } 1009 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15, 1010 std::to_string((int) radioTechnology + 2).c_str(), 1011 std::to_string((int) dataProfileInfo.profileId).c_str(), 1012 dataProfileInfo.apn.c_str(), 1013 dataProfileInfo.user.c_str(), 1014 dataProfileInfo.password.c_str(), 1015 std::to_string((int) dataProfileInfo.authType).c_str(), 1016 dataProfileInfo.protocol.c_str(), 1017 dataProfileInfo.roamingProtocol.c_str(), 1018 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(), 1019 std::to_string(dataProfileInfo.bearerBitmap).c_str(), 1020 BOOL_TO_INT(modemCognitive), 1021 std::to_string(dataProfileInfo.mtu).c_str(), 1022 mvnoTypeStr, 1023 dataProfileInfo.mvnoMatchData.c_str(), 1024 BOOL_TO_INT(roamingAllowed)); 1025 } else { 1026 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version); 1027 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1028 RIL_REQUEST_SETUP_DATA_CALL); 1029 if (pRI != NULL) { 1030 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED); 1031 } 1032 } 1033 return Void(); 1034} 1035 1036Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) { 1037 RLOGD("RadioImpl::iccIOForApp: serial %d", serial); 1038 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO); 1039 if (pRI == NULL) { 1040 return Void(); 1041 } 1042 1043 RIL_SIM_IO_v6 rilIccIo; 1044 rilIccIo.command = iccIo.command; 1045 rilIccIo.fileid = iccIo.fileId; 1046 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) { 1047 return Void(); 1048 } 1049 1050 rilIccIo.p1 = iccIo.p1; 1051 rilIccIo.p2 = iccIo.p2; 1052 rilIccIo.p3 = iccIo.p3; 1053 1054 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) { 1055 memsetAndFreeStrings(1, rilIccIo.path); 1056 return Void(); 1057 } 1058 1059 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) { 1060 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data); 1061 return Void(); 1062 } 1063 1064 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) { 1065 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2); 1066 return Void(); 1067 } 1068 1069 s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI); 1070 1071 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr); 1072 1073 return Void(); 1074} 1075 1076Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) { 1077 RLOGD("RadioImpl::sendUssd: serial %d", serial); 1078 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, (const char *) ussd); 1079 return Void(); 1080} 1081 1082Return<void> RadioImpl::cancelPendingUssd(int32_t serial) { 1083 RLOGD("RadioImpl::cancelPendingUssd: serial %d", serial); 1084 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD); 1085 return Void(); 1086} 1087 1088Return<void> RadioImpl::getClir(int32_t serial) { 1089 RLOGD("RadioImpl::getClir: serial %d", serial); 1090 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR); 1091 return Void(); 1092} 1093 1094Return<void> RadioImpl::setClir(int32_t serial, int32_t status) { 1095 RLOGD("RadioImpl::setClir: serial %d", serial); 1096 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status); 1097 return Void(); 1098} 1099 1100Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) { 1101 RLOGD("RadioImpl::getCallForwardStatus: serial %d", serial); 1102 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS, 1103 callInfo); 1104 return Void(); 1105} 1106 1107Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) { 1108 RLOGD("RadioImpl::setCallForward: serial %d", serial); 1109 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD, 1110 callInfo); 1111 return Void(); 1112} 1113 1114Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) { 1115 RLOGD("RadioImpl::getCallWaiting: serial %d", serial); 1116 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass); 1117 return Void(); 1118} 1119 1120Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) { 1121 RLOGD("RadioImpl::setCallWaiting: serial %d", serial); 1122 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable), 1123 serviceClass); 1124 return Void(); 1125} 1126 1127Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial, 1128 bool success, SmsAcknowledgeFailCause cause) { 1129 RLOGD("RadioImpl::acknowledgeLastIncomingGsmSms: serial %d", serial); 1130 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success), 1131 cause); 1132 return Void(); 1133} 1134 1135Return<void> RadioImpl::acceptCall(int32_t serial) { 1136 RLOGD("RadioImpl::acceptCall: serial %d", serial); 1137 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER); 1138 return Void(); 1139} 1140 1141Return<void> RadioImpl::deactivateDataCall(int32_t serial, 1142 int32_t cid, bool reasonRadioShutDown) { 1143 RLOGD("RadioImpl::deactivateDataCall: serial %d", serial); 1144 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, 1145 2, (const char *) (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0"); 1146 return Void(); 1147} 1148 1149Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility, 1150 const hidl_string& password, int32_t serviceClass, 1151 const hidl_string& appId) { 1152 RLOGD("RadioImpl::getFacilityLockForApp: serial %d", serial); 1153 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK, 1154 4, (const char *) facility, (const char *) password, 1155 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId); 1156 return Void(); 1157} 1158 1159Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility, 1160 bool lockState, const hidl_string& password, 1161 int32_t serviceClass, const hidl_string& appId) { 1162 RLOGD("RadioImpl::setFacilityLockForApp: serial %d", serial); 1163 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK, 1164 5, (const char *) facility, lockState ? "1" : "0", (const char *) password, 1165 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId); 1166 return Void(); 1167} 1168 1169Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility, 1170 const hidl_string& oldPassword, 1171 const hidl_string& newPassword) { 1172 RLOGD("RadioImpl::setBarringPassword: serial %d", serial); 1173 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD, 1174 2, (const char *) oldPassword, (const char *) newPassword); 1175 return Void(); 1176} 1177 1178Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) { 1179 RLOGD("RadioImpl::getNetworkSelectionMode: serial %d", serial); 1180 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE); 1181 return Void(); 1182} 1183 1184Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) { 1185 RLOGD("RadioImpl::setNetworkSelectionModeAutomatic: serial %d", serial); 1186 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC); 1187 return Void(); 1188} 1189 1190Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial, 1191 const hidl_string& operatorNumeric) { 1192 RLOGD("RadioImpl::setNetworkSelectionModeManual: serial %d", serial); 1193 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL, 1194 (const char *) operatorNumeric); 1195 return Void(); 1196} 1197 1198Return<void> RadioImpl::getAvailableNetworks(int32_t serial) { 1199 RLOGD("RadioImpl::getAvailableNetworks: serial %d", serial); 1200 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS); 1201 return Void(); 1202} 1203 1204Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) { 1205 RLOGD("RadioImpl::startDtmf: serial %d", serial); 1206 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START, 1207 (const char *) s); 1208 return Void(); 1209} 1210 1211Return<void> RadioImpl::stopDtmf(int32_t serial) { 1212 RLOGD("RadioImpl::stopDtmf: serial %d", serial); 1213 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP); 1214 return Void(); 1215} 1216 1217Return<void> RadioImpl::getBasebandVersion(int32_t serial) { 1218 RLOGD("RadioImpl::getBasebandVersion: serial %d", serial); 1219 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION); 1220 return Void(); 1221} 1222 1223Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) { 1224 RLOGD("RadioImpl::separateConnection: serial %d", serial); 1225 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex); 1226 return Void(); 1227} 1228 1229Return<void> RadioImpl::setMute(int32_t serial, bool enable) { 1230 RLOGD("RadioImpl::setMute: serial %d", serial); 1231 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable)); 1232 return Void(); 1233} 1234 1235Return<void> RadioImpl::getMute(int32_t serial) { 1236 RLOGD("RadioImpl::getMute: serial %d", serial); 1237 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE); 1238 return Void(); 1239} 1240 1241Return<void> RadioImpl::getClip(int32_t serial) { 1242 RLOGD("RadioImpl::getClip: serial %d", serial); 1243 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP); 1244 return Void(); 1245} 1246 1247Return<void> RadioImpl::getDataCallList(int32_t serial) { 1248 RLOGD("RadioImpl::getDataCallList: serial %d", serial); 1249 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST); 1250 return Void(); 1251} 1252 1253Return<void> RadioImpl::sendScreenState(int32_t serial, bool enable) { 1254 RLOGD("RadioImpl::sendScreenState: serial %d", serial); 1255 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(enable)); 1256 return Void(); 1257} 1258 1259Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) { 1260 RLOGD("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::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("RadioImpl::getAllowedCarriers: serial %d", serial); 2314 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS); 2315 return Void(); 2316} 2317 2318Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) { 2319 RLOGD("RadioImpl::setSimCardPower: serial %d", serial); 2320 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp)); 2321 return Void(); 2322} 2323 2324Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state) {return Status::ok();} 2325 2326Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {return Status::ok();} 2327 2328Return<void> RadioImpl::responseAcknowledgement() { 2329 android::releaseWakeLock(); 2330 return Void(); 2331} 2332 2333Return<void> OemHookImpl::setResponseFunctions( 2334 const ::android::sp<IOemHookResponse>& oemHookResponseParam, 2335 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) { 2336 RLOGD("OemHookImpl::setResponseFunctions"); 2337 2338 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId); 2339 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr); 2340 assert(ret == 0); 2341 2342 mOemHookResponse = oemHookResponseParam; 2343 mOemHookIndication = oemHookIndicationParam; 2344 mCounter[mSlotId]++; 2345 2346 ret = pthread_rwlock_unlock(radioServiceRwlockPtr); 2347 assert(ret == 0); 2348 2349 return Void(); 2350} 2351 2352Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) { 2353 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial); 2354 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data); 2355 return Void(); 2356} 2357 2358Return<void> OemHookImpl::sendRequestStrings(int32_t serial, 2359 const hidl_vec<hidl_string>& data) { 2360 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial); 2361 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data); 2362 return Void(); 2363} 2364 2365/*************************************************************************************************** 2366 * RESPONSE FUNCTIONS 2367 * Functions above are used for requests going from framework to vendor code. The ones below are 2368 * responses for those requests coming back from the vendor code. 2369 **************************************************************************************************/ 2370 2371void radio::acknowledgeRequest(int slotId, int serial) { 2372 if (radioService[slotId]->mRadioResponse != NULL) { 2373 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial); 2374 radioService[slotId]->checkReturnStatus(retStatus); 2375 } else { 2376 RLOGE("radio::acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId); 2377 } 2378} 2379 2380void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType, 2381 RIL_Errno e) { 2382 responseInfo.serial = serial; 2383 switch (responseType) { 2384 case RESPONSE_SOLICITED: 2385 responseInfo.type = RadioResponseType::SOLICITED; 2386 break; 2387 case RESPONSE_SOLICITED_ACK_EXP: 2388 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP; 2389 break; 2390 } 2391 responseInfo.error = (RadioError) e; 2392} 2393 2394int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e, 2395 void *response, size_t responseLen) { 2396 populateResponseInfo(responseInfo, serial, responseType, e); 2397 int ret = -1; 2398 2399 if (response == NULL || responseLen != sizeof(int)) { 2400 RLOGE("responseInt: Invalid response"); 2401 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2402 } else { 2403 int *p_int = (int *) response; 2404 ret = p_int[0]; 2405 } 2406 return ret; 2407} 2408 2409int radio::getIccCardStatusResponse(android::Parcel &p, int slotId, int requestNumber, 2410 int responseType, int serial, RIL_Errno e, 2411 void *response, size_t responseLen) { 2412 if (radioService[slotId]->mRadioResponse != NULL) { 2413 RadioResponseInfo responseInfo = {}; 2414 populateResponseInfo(responseInfo, serial, responseType, e); 2415 CardStatus cardStatus = {}; 2416 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) { 2417 RLOGE("radio::getIccCardStatusResponse: Invalid response"); 2418 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2419 } else { 2420 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response); 2421 cardStatus.cardState = (CardState) p_cur->card_state; 2422 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state; 2423 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index; 2424 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index; 2425 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index; 2426 2427 RIL_AppStatus *rilAppStatus = p_cur->applications; 2428 cardStatus.applications.resize(p_cur->num_applications); 2429 AppStatus *appStatus = cardStatus.applications.data(); 2430 RLOGD("radio::getIccCardStatusResponse: num_applications %d", p_cur->num_applications); 2431 for (int i = 0; i < p_cur->num_applications; i++) { 2432 appStatus[i].appType = (AppType) rilAppStatus[i].app_type; 2433 appStatus[i].appState = (AppState) rilAppStatus[i].app_state; 2434 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate; 2435 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr); 2436 appStatus[i].appLabelPtr = convertCharPtrToHidlString( 2437 rilAppStatus[i].app_label_ptr); 2438 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced; 2439 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1; 2440 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2; 2441 } 2442 } 2443 2444 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2445 getIccCardStatusResponse(responseInfo, cardStatus); 2446 radioService[slotId]->checkReturnStatus(retStatus); 2447 } else { 2448 RLOGE("radio::getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2449 } 2450 2451 return 0; 2452} 2453 2454int radio::supplyIccPinForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2455 int responseType, int serial, RIL_Errno e, 2456 void *response, size_t responseLen) { 2457 RLOGD("radio::supplyIccPinForAppResponse: serial %d", serial); 2458 2459 if (radioService[slotId]->mRadioResponse != NULL) { 2460 RadioResponseInfo responseInfo = {}; 2461 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2462 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2463 supplyIccPinForAppResponse(responseInfo, ret); 2464 radioService[slotId]->checkReturnStatus(retStatus); 2465 } else { 2466 RLOGE("radio::supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL", 2467 slotId); 2468 } 2469 2470 return 0; 2471} 2472 2473int radio::supplyIccPukForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2474 int responseType, int serial, RIL_Errno e, 2475 void *response, size_t responseLen) { 2476 RLOGD("radio::supplyIccPukForAppResponse: serial %d", serial); 2477 2478 if (radioService[slotId]->mRadioResponse != NULL) { 2479 RadioResponseInfo responseInfo = {}; 2480 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2481 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse( 2482 responseInfo, ret); 2483 radioService[slotId]->checkReturnStatus(retStatus); 2484 } else { 2485 RLOGE("radio::supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL", 2486 slotId); 2487 } 2488 2489 return 0; 2490} 2491 2492int radio::supplyIccPin2ForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2493 int responseType, int serial, RIL_Errno e, 2494 void *response, size_t responseLen) { 2495 RLOGD("radio::supplyIccPin2ForAppResponse: serial %d", serial); 2496 2497 if (radioService[slotId]->mRadioResponse != NULL) { 2498 RadioResponseInfo responseInfo = {}; 2499 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2500 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2501 supplyIccPin2ForAppResponse(responseInfo, ret); 2502 radioService[slotId]->checkReturnStatus(retStatus); 2503 } else { 2504 RLOGE("radio::supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL", 2505 slotId); 2506 } 2507 2508 return 0; 2509} 2510 2511int radio::supplyIccPuk2ForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2512 int responseType, int serial, RIL_Errno e, 2513 void *response, size_t responseLen) { 2514 RLOGD("radio::supplyIccPuk2ForAppResponse: serial %d", serial); 2515 2516 if (radioService[slotId]->mRadioResponse != NULL) { 2517 RadioResponseInfo responseInfo = {}; 2518 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2519 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2520 supplyIccPuk2ForAppResponse(responseInfo, ret); 2521 radioService[slotId]->checkReturnStatus(retStatus); 2522 } else { 2523 RLOGE("radio::supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL", 2524 slotId); 2525 } 2526 2527 return 0; 2528} 2529 2530int radio::changeIccPinForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2531 int responseType, int serial, RIL_Errno e, 2532 void *response, size_t responseLen) { 2533 RLOGD("radio::changeIccPinForAppResponse: serial %d", serial); 2534 2535 if (radioService[slotId]->mRadioResponse != NULL) { 2536 RadioResponseInfo responseInfo = {}; 2537 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2538 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2539 changeIccPinForAppResponse(responseInfo, ret); 2540 radioService[slotId]->checkReturnStatus(retStatus); 2541 } else { 2542 RLOGE("radio::changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL", 2543 slotId); 2544 } 2545 2546 return 0; 2547} 2548 2549int radio::changeIccPin2ForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2550 int responseType, int serial, RIL_Errno e, 2551 void *response, size_t responseLen) { 2552 RLOGD("radio::changeIccPin2ForAppResponse: serial %d", serial); 2553 2554 if (radioService[slotId]->mRadioResponse != NULL) { 2555 RadioResponseInfo responseInfo = {}; 2556 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2557 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2558 changeIccPin2ForAppResponse(responseInfo, ret); 2559 radioService[slotId]->checkReturnStatus(retStatus); 2560 } else { 2561 RLOGE("radio::changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL", 2562 slotId); 2563 } 2564 2565 return 0; 2566} 2567 2568int radio::supplyNetworkDepersonalizationResponse(android::Parcel &p, int slotId, int requestNumber, 2569 int responseType, int serial, RIL_Errno e, 2570 void *response, size_t responseLen) { 2571 RLOGD("radio::supplyNetworkDepersonalizationResponse: serial %d", serial); 2572 2573 if (radioService[slotId]->mRadioResponse != NULL) { 2574 RadioResponseInfo responseInfo = {}; 2575 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 2576 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2577 supplyNetworkDepersonalizationResponse(responseInfo, ret); 2578 radioService[slotId]->checkReturnStatus(retStatus); 2579 } else { 2580 RLOGE("radio::supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == " 2581 "NULL", slotId); 2582 } 2583 2584 return 0; 2585} 2586 2587int radio::getCurrentCallsResponse(android::Parcel &p, int slotId, int requestNumber, 2588 int responseType, int serial, RIL_Errno e, 2589 void *response, size_t responseLen) { 2590 RLOGD("radio::getCurrentCallsResponse: serial %d", serial); 2591 2592 if (radioService[slotId]->mRadioResponse != NULL) { 2593 RadioResponseInfo responseInfo = {}; 2594 populateResponseInfo(responseInfo, serial, responseType, e); 2595 2596 hidl_vec<Call> calls; 2597 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) { 2598 RLOGE("radio::getCurrentCallsResponse: Invalid response"); 2599 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2600 } else { 2601 int num = responseLen / sizeof(RIL_Call *); 2602 calls.resize(num); 2603 2604 for (int i = 0 ; i < num ; i++) { 2605 RIL_Call *p_cur = ((RIL_Call **) response)[i]; 2606 /* each call info */ 2607 calls[i].state = (CallState) p_cur->state; 2608 calls[i].index = p_cur->index; 2609 calls[i].toa = p_cur->toa; 2610 calls[i].isMpty = p_cur->isMpty; 2611 calls[i].isMT = p_cur->isMT; 2612 calls[i].als = p_cur->als; 2613 calls[i].isVoice = p_cur->isVoice; 2614 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy; 2615 calls[i].number = convertCharPtrToHidlString(p_cur->number); 2616 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation; 2617 calls[i].name = convertCharPtrToHidlString(p_cur->name); 2618 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation; 2619 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) { 2620 RIL_UUS_Info *uusInfo = p_cur->uusInfo; 2621 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType; 2622 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs; 2623 // convert uusInfo->uusData to a null-terminated string 2624 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength); 2625 calls[i].uusInfo[0].uusData = nullTermStr; 2626 free(nullTermStr); 2627 } 2628 } 2629 } 2630 2631 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2632 getCurrentCallsResponse(responseInfo, calls); 2633 radioService[slotId]->checkReturnStatus(retStatus); 2634 } else { 2635 RLOGE("radio::getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2636 } 2637 2638 return 0; 2639} 2640 2641int radio::dialResponse(android::Parcel &p, int slotId, int requestNumber, 2642 int responseType, int serial, RIL_Errno e, void *response, 2643 size_t responseLen) { 2644 RLOGD("radio::dialResponse: serial %d", serial); 2645 2646 if (radioService[slotId]->mRadioResponse != NULL) { 2647 RadioResponseInfo responseInfo = {}; 2648 populateResponseInfo(responseInfo, serial, responseType, e); 2649 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo); 2650 radioService[slotId]->checkReturnStatus(retStatus); 2651 } else { 2652 RLOGE("radio::dialResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2653 } 2654 2655 return 0; 2656} 2657 2658int radio::getIMSIForAppResponse(android::Parcel &p, int slotId, int requestNumber, 2659 int responseType, int serial, RIL_Errno e, void *response, 2660 size_t responseLen) { 2661 RLOGD("radio::getIMSIForAppResponse: serial %d", serial); 2662 2663 if (radioService[slotId]->mRadioResponse != NULL) { 2664 RadioResponseInfo responseInfo = {}; 2665 populateResponseInfo(responseInfo, serial, responseType, e); 2666 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse( 2667 responseInfo, convertCharPtrToHidlString((char *) response)); 2668 radioService[slotId]->checkReturnStatus(retStatus); 2669 } else { 2670 RLOGE("radio::getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL", 2671 slotId); 2672 } 2673 2674 return 0; 2675} 2676 2677int radio::hangupConnectionResponse(android::Parcel &p, int slotId, int requestNumber, 2678 int responseType, int serial, RIL_Errno e, 2679 void *response, size_t responseLen) { 2680 RLOGD("radio::hangupConnectionResponse: serial %d", serial); 2681 2682 if (radioService[slotId]->mRadioResponse != NULL) { 2683 RadioResponseInfo responseInfo = {}; 2684 populateResponseInfo(responseInfo, serial, responseType, e); 2685 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse( 2686 responseInfo); 2687 radioService[slotId]->checkReturnStatus(retStatus); 2688 } else { 2689 RLOGE("radio::hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL", 2690 slotId); 2691 } 2692 2693 return 0; 2694} 2695 2696int radio::hangupWaitingOrBackgroundResponse(android::Parcel &p, int slotId, int requestNumber, 2697 int responseType, int serial, RIL_Errno e, 2698 void *response, size_t responseLen) { 2699 RLOGD("radio::hangupWaitingOrBackgroundResponse: serial %d", serial); 2700 2701 if (radioService[slotId]->mRadioResponse != NULL) { 2702 RadioResponseInfo responseInfo = {}; 2703 populateResponseInfo(responseInfo, serial, responseType, e); 2704 Return<void> retStatus = 2705 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse( 2706 responseInfo); 2707 radioService[slotId]->checkReturnStatus(retStatus); 2708 } else { 2709 RLOGE("radio::hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL", 2710 slotId); 2711 } 2712 2713 return 0; 2714} 2715 2716int radio::hangupForegroundResumeBackgroundResponse(android::Parcel &p, int slotId, 2717 int requestNumber, 2718 int responseType, int serial, RIL_Errno e, 2719 void *response, size_t responseLen) { 2720 RLOGD("radio::hangupWaitingOrBackgroundResponse: serial %d", serial); 2721 2722 if (radioService[slotId]->mRadioResponse != NULL) { 2723 RadioResponseInfo responseInfo = {}; 2724 populateResponseInfo(responseInfo, serial, responseType, e); 2725 Return<void> retStatus = 2726 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse( 2727 responseInfo); 2728 radioService[slotId]->checkReturnStatus(retStatus); 2729 } else { 2730 RLOGE("radio::hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL", 2731 slotId); 2732 } 2733 2734 return 0; 2735} 2736 2737int radio::switchWaitingOrHoldingAndActiveResponse(android::Parcel &p, int slotId, 2738 int requestNumber, 2739 int responseType, int serial, RIL_Errno e, 2740 void *response, size_t responseLen) { 2741 RLOGD("radio::switchWaitingOrHoldingAndActiveResponse: serial %d", serial); 2742 2743 if (radioService[slotId]->mRadioResponse != NULL) { 2744 RadioResponseInfo responseInfo = {}; 2745 populateResponseInfo(responseInfo, serial, responseType, e); 2746 Return<void> retStatus = 2747 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse( 2748 responseInfo); 2749 radioService[slotId]->checkReturnStatus(retStatus); 2750 } else { 2751 RLOGE("radio::switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse " 2752 "== NULL", slotId); 2753 } 2754 2755 return 0; 2756} 2757 2758int radio::conferenceResponse(android::Parcel &p, int slotId, int requestNumber, int responseType, 2759 int serial, RIL_Errno e, void *response, size_t responseLen) { 2760 RLOGD("radio::conferenceResponse: serial %d", serial); 2761 2762 if (radioService[slotId]->mRadioResponse != NULL) { 2763 RadioResponseInfo responseInfo = {}; 2764 populateResponseInfo(responseInfo, serial, responseType, e); 2765 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse( 2766 responseInfo); 2767 radioService[slotId]->checkReturnStatus(retStatus); 2768 } else { 2769 RLOGE("radio::conferenceResponse: radioService[%d]->mRadioResponse == NULL", 2770 slotId); 2771 } 2772 2773 return 0; 2774} 2775 2776int radio::rejectCallResponse(android::Parcel &p, int slotId, int requestNumber, int responseType, 2777 int serial, RIL_Errno e, void *response, size_t responseLen) { 2778 RLOGD("radio::rejectCallResponse: serial %d", serial); 2779 2780 if (radioService[slotId]->mRadioResponse != NULL) { 2781 RadioResponseInfo responseInfo = {}; 2782 populateResponseInfo(responseInfo, serial, responseType, e); 2783 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse( 2784 responseInfo); 2785 radioService[slotId]->checkReturnStatus(retStatus); 2786 } else { 2787 RLOGE("radio::rejectCallResponse: radioService[%d]->mRadioResponse == NULL", 2788 slotId); 2789 } 2790 2791 return 0; 2792} 2793 2794int radio::getLastCallFailCauseResponse(android::Parcel &p, int slotId, int requestNumber, 2795 int responseType, int serial, RIL_Errno e, void *response, 2796 size_t responseLen) { 2797 RLOGD("radio::getLastCallFailCauseResponse: serial %d", serial); 2798 2799 if (radioService[slotId]->mRadioResponse != NULL) { 2800 RadioResponseInfo responseInfo = {}; 2801 populateResponseInfo(responseInfo, serial, responseType, e); 2802 2803 LastCallFailCauseInfo info = {}; 2804 info.vendorCause = hidl_string(); 2805 if (response == NULL) { 2806 RLOGE("radio::getCurrentCallsResponse Invalid response: NULL"); 2807 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2808 } else if (responseLen == sizeof(int)) { 2809 int *pInt = (int *) response; 2810 info.causeCode = (LastCallFailCause) pInt[0]; 2811 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) { 2812 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response; 2813 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code; 2814 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause); 2815 } else { 2816 RLOGE("radio::getCurrentCallsResponse Invalid response: NULL"); 2817 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2818 } 2819 2820 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse( 2821 responseInfo, info); 2822 radioService[slotId]->checkReturnStatus(retStatus); 2823 } else { 2824 RLOGE("radio::getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL", 2825 slotId); 2826 } 2827 2828 return 0; 2829} 2830 2831int radio::getSignalStrengthResponse(android::Parcel &p, int slotId, int requestNumber, 2832 int responseType, int serial, RIL_Errno e, 2833 void *response, size_t responseLen) { 2834 RLOGD("radio::getSignalStrengthResponse: serial %d", serial); 2835 2836 if (radioService[slotId]->mRadioResponse != NULL) { 2837 RadioResponseInfo responseInfo = {}; 2838 populateResponseInfo(responseInfo, serial, responseType, e); 2839 SignalStrength signalStrength = {}; 2840 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) { 2841 RLOGE("radio::getSignalStrengthResponse: Invalid response"); 2842 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2843 } else { 2844 convertRilSignalStrengthToHal(response, responseLen, signalStrength); 2845 } 2846 2847 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse( 2848 responseInfo, signalStrength); 2849 radioService[slotId]->checkReturnStatus(retStatus); 2850 } else { 2851 RLOGE("radio::getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL", 2852 slotId); 2853 } 2854 2855 return 0; 2856} 2857 2858RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) { 2859 if (rat == NULL) { 2860 return RIL_CELL_INFO_TYPE_NONE; 2861 } 2862 2863 int radioTech = atoi(rat); 2864 2865 switch(radioTech) { 2866 2867 case RADIO_TECH_GPRS: 2868 case RADIO_TECH_EDGE: 2869 case RADIO_TECH_GSM: { 2870 return RIL_CELL_INFO_TYPE_GSM; 2871 } 2872 2873 case RADIO_TECH_UMTS: 2874 case RADIO_TECH_HSDPA: 2875 case RADIO_TECH_HSUPA: 2876 case RADIO_TECH_HSPA: 2877 case RADIO_TECH_HSPAP: { 2878 return RIL_CELL_INFO_TYPE_WCDMA; 2879 } 2880 2881 case RADIO_TECH_IS95A: 2882 case RADIO_TECH_IS95B: 2883 case RADIO_TECH_1xRTT: 2884 case RADIO_TECH_EVDO_0: 2885 case RADIO_TECH_EVDO_A: 2886 case RADIO_TECH_EVDO_B: 2887 case RADIO_TECH_EHRPD: { 2888 return RIL_CELL_INFO_TYPE_CDMA; 2889 } 2890 2891 case RADIO_TECH_LTE: 2892 case RADIO_TECH_LTE_CA: { 2893 return RIL_CELL_INFO_TYPE_LTE; 2894 } 2895 2896 case RADIO_TECH_TD_SCDMA: { 2897 return RIL_CELL_INFO_TYPE_TD_SCDMA; 2898 } 2899 2900 default: { 2901 break; 2902 } 2903 } 2904 2905 return RIL_CELL_INFO_TYPE_NONE; 2906 2907} 2908 2909void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) { 2910 2911 cellIdentity.cellIdentityGsm.resize(0); 2912 cellIdentity.cellIdentityWcdma.resize(0); 2913 cellIdentity.cellIdentityCdma.resize(0); 2914 cellIdentity.cellIdentityTdscdma.resize(0); 2915 cellIdentity.cellIdentityLte.resize(0); 2916 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType; 2917 switch(rilCellIdentity.cellInfoType) { 2918 2919 case RIL_CELL_INFO_TYPE_GSM: { 2920 cellIdentity.cellIdentityGsm.resize(1); 2921 cellIdentity.cellIdentityGsm[0].mcc = 2922 std::to_string(rilCellIdentity.cellIdentityGsm.mcc); 2923 cellIdentity.cellIdentityGsm[0].mnc = 2924 std::to_string(rilCellIdentity.cellIdentityGsm.mnc); 2925 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac; 2926 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid; 2927 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn; 2928 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic; 2929 break; 2930 } 2931 2932 case RIL_CELL_INFO_TYPE_WCDMA: { 2933 cellIdentity.cellIdentityWcdma.resize(1); 2934 cellIdentity.cellIdentityWcdma[0].mcc = 2935 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc); 2936 cellIdentity.cellIdentityWcdma[0].mnc = 2937 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc); 2938 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac; 2939 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid; 2940 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc; 2941 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn; 2942 break; 2943 } 2944 2945 case RIL_CELL_INFO_TYPE_CDMA: { 2946 cellIdentity.cellIdentityCdma.resize(1); 2947 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId; 2948 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId; 2949 cellIdentity.cellIdentityCdma[0].baseStationId = 2950 rilCellIdentity.cellIdentityCdma.basestationId; 2951 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude; 2952 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude; 2953 break; 2954 } 2955 2956 case RIL_CELL_INFO_TYPE_LTE: { 2957 cellIdentity.cellIdentityLte.resize(1); 2958 cellIdentity.cellIdentityLte[0].mcc = 2959 std::to_string(rilCellIdentity.cellIdentityLte.mcc); 2960 cellIdentity.cellIdentityLte[0].mnc = 2961 std::to_string(rilCellIdentity.cellIdentityLte.mnc); 2962 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci; 2963 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci; 2964 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac; 2965 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn; 2966 break; 2967 } 2968 2969 case RIL_CELL_INFO_TYPE_TD_SCDMA: { 2970 cellIdentity.cellIdentityTdscdma.resize(1); 2971 cellIdentity.cellIdentityTdscdma[0].mcc = 2972 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc); 2973 cellIdentity.cellIdentityTdscdma[0].mnc = 2974 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc); 2975 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac; 2976 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid; 2977 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid; 2978 break; 2979 } 2980 2981 default: { 2982 break; 2983 } 2984 } 2985} 2986 2987int convertResponseStringEntryToInt(char **response, int index, int numStrings) { 2988 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) { 2989 return atoi(response[index]); 2990 } 2991 2992 return -1; 2993} 2994 2995void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity, 2996 int numStrings, char** response) { 2997 2998 RIL_CellIdentity_v16 rilCellIdentity; 2999 int32_t *tmp = (int32_t*)&rilCellIdentity; 3000 3001 for (int i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) { 3002 tmp[i] = -1; 3003 } 3004 3005 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]); 3006 switch(rilCellIdentity.cellInfoType) { 3007 3008 case RIL_CELL_INFO_TYPE_GSM: { 3009 rilCellIdentity.cellIdentityGsm.lac = 3010 convertResponseStringEntryToInt(response, 1, numStrings); 3011 rilCellIdentity.cellIdentityGsm.cid = 3012 convertResponseStringEntryToInt(response, 2, numStrings); 3013 break; 3014 } 3015 3016 case RIL_CELL_INFO_TYPE_WCDMA: { 3017 rilCellIdentity.cellIdentityWcdma.lac = 3018 convertResponseStringEntryToInt(response, 1, numStrings); 3019 rilCellIdentity.cellIdentityWcdma.cid = 3020 convertResponseStringEntryToInt(response, 2, numStrings); 3021 rilCellIdentity.cellIdentityWcdma.psc = 3022 convertResponseStringEntryToInt(response, 14, numStrings); 3023 break; 3024 } 3025 3026 case RIL_CELL_INFO_TYPE_TD_SCDMA:{ 3027 rilCellIdentity.cellIdentityTdscdma.lac = 3028 convertResponseStringEntryToInt(response, 1, numStrings); 3029 rilCellIdentity.cellIdentityTdscdma.cid = 3030 convertResponseStringEntryToInt(response, 2, numStrings); 3031 break; 3032 } 3033 3034 case RIL_CELL_INFO_TYPE_CDMA:{ 3035 rilCellIdentity.cellIdentityCdma.basestationId = 3036 convertResponseStringEntryToInt(response, 4, numStrings); 3037 rilCellIdentity.cellIdentityCdma.longitude = 3038 convertResponseStringEntryToInt(response, 5, numStrings); 3039 rilCellIdentity.cellIdentityCdma.latitude = 3040 convertResponseStringEntryToInt(response, 6, numStrings); 3041 rilCellIdentity.cellIdentityCdma.systemId = 3042 convertResponseStringEntryToInt(response, 8, numStrings); 3043 rilCellIdentity.cellIdentityCdma.networkId = 3044 convertResponseStringEntryToInt(response, 9, numStrings); 3045 break; 3046 } 3047 3048 default: { 3049 break; 3050 } 3051 } 3052 3053 fillCellIdentityResponse(cellIdentity, rilCellIdentity); 3054} 3055 3056void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity, 3057 int numStrings, char** response) { 3058 3059 RIL_CellIdentity_v16 rilCellIdentity; 3060 int32_t *tmp = (int32_t*)&rilCellIdentity; 3061 3062 for (int i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) { 3063 tmp[i] = -1; 3064 } 3065 3066 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]); 3067 switch(rilCellIdentity.cellInfoType) { 3068 case RIL_CELL_INFO_TYPE_GSM: { 3069 rilCellIdentity.cellIdentityGsm.lac = 3070 convertResponseStringEntryToInt(response, 1, numStrings); 3071 rilCellIdentity.cellIdentityGsm.cid = 3072 convertResponseStringEntryToInt(response, 2, numStrings); 3073 break; 3074 } 3075 case RIL_CELL_INFO_TYPE_WCDMA: { 3076 rilCellIdentity.cellIdentityWcdma.lac = 3077 convertResponseStringEntryToInt(response, 1, numStrings); 3078 rilCellIdentity.cellIdentityWcdma.cid = 3079 convertResponseStringEntryToInt(response, 2, numStrings); 3080 break; 3081 } 3082 case RIL_CELL_INFO_TYPE_TD_SCDMA:{ 3083 rilCellIdentity.cellIdentityTdscdma.lac = 3084 convertResponseStringEntryToInt(response, 1, numStrings); 3085 rilCellIdentity.cellIdentityTdscdma.cid = 3086 convertResponseStringEntryToInt(response, 2, numStrings); 3087 break; 3088 } 3089 case RIL_CELL_INFO_TYPE_LTE: { 3090 rilCellIdentity.cellIdentityLte.tac = 3091 convertResponseStringEntryToInt(response, 6, numStrings); 3092 rilCellIdentity.cellIdentityLte.pci = 3093 convertResponseStringEntryToInt(response, 7, numStrings); 3094 rilCellIdentity.cellIdentityLte.ci = 3095 convertResponseStringEntryToInt(response, 8, numStrings); 3096 break; 3097 } 3098 default: { 3099 break; 3100 } 3101 } 3102 3103 fillCellIdentityResponse(cellIdentity, rilCellIdentity); 3104} 3105 3106int radio::getVoiceRegistrationStateResponse(android::Parcel &p, int slotId, int requestNumber, 3107 int responseType, int serial, RIL_Errno e, 3108 void *response, size_t responseLen) { 3109 RLOGD("radio::getVoiceRegistrationStateResponse: serial %d", serial); 3110 3111 if (radioService[slotId]->mRadioResponse != NULL) { 3112 RadioResponseInfo responseInfo = {}; 3113 populateResponseInfo(responseInfo, serial, responseType, e); 3114 3115 VoiceRegStateResult voiceRegResponse = {}; 3116 int numStrings = responseLen / sizeof(char *); 3117 if (response == NULL) { 3118 RLOGE("radio::getVoiceRegistrationStateResponse Invalid response: NULL"); 3119 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3120 } else if (s_vendorFunctions->version <= 14) { 3121 if (numStrings != 15) { 3122 RLOGE("radio::getVoiceRegistrationStateResponse Invalid response: NULL"); 3123 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3124 } else { 3125 char **resp = (char **) response; 3126 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4); 3127 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]); 3128 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0); 3129 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]); 3130 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0); 3131 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0); 3132 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0); 3133 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity, 3134 numStrings, resp); 3135 } 3136 } else { 3137 RIL_VoiceRegistrationStateResponse *voiceRegState = 3138 (RIL_VoiceRegistrationStateResponse *)response; 3139 3140 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) { 3141 RLOGE("radio::getVoiceRegistrationStateResponse Invalid response: NULL"); 3142 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3143 } else { 3144 voiceRegResponse.regState = (RegState) voiceRegState->regState; 3145 voiceRegResponse.rat = voiceRegState->rat;; 3146 voiceRegResponse.cssSupported = voiceRegState->cssSupported; 3147 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator; 3148 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl; 3149 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator; 3150 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial; 3151 fillCellIdentityResponse(voiceRegResponse.cellIdentity, 3152 voiceRegState->cellIdentity); 3153 } 3154 } 3155 3156 Return<void> retStatus = 3157 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse( 3158 responseInfo, voiceRegResponse); 3159 radioService[slotId]->checkReturnStatus(retStatus); 3160 } else { 3161 RLOGE("radio::getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL", 3162 slotId); 3163 } 3164 3165 return 0; 3166} 3167 3168int radio::getDataRegistrationStateResponse(android::Parcel &p, int slotId, int requestNumber, 3169 int responseType, int serial, RIL_Errno e, 3170 void *response, size_t responseLen) { 3171 RLOGD("radio::getDataRegistrationStateResponse: serial %d", serial); 3172 3173 if (radioService[slotId]->mRadioResponse != NULL) { 3174 RadioResponseInfo responseInfo = {}; 3175 populateResponseInfo(responseInfo, serial, responseType, e); 3176 DataRegStateResult dataRegResponse = {}; 3177 if (response == NULL) { 3178 RLOGE("radio::getDataRegistrationStateResponse Invalid response: NULL"); 3179 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3180 } else if (s_vendorFunctions->version <= 14) { 3181 int numStrings = responseLen / sizeof(char *); 3182 if ((numStrings != 6) && (numStrings != 11)) { 3183 RLOGE("radio::getDataRegistrationStateResponse Invalid response: NULL"); 3184 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3185 } else { 3186 char **resp = (char **) response; 3187 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4); 3188 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0); 3189 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]); 3190 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1); 3191 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity, 3192 numStrings, resp); 3193 } 3194 } else { 3195 RIL_DataRegistrationStateResponse *dataRegState = 3196 (RIL_DataRegistrationStateResponse *)response; 3197 3198 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) { 3199 RLOGE("radio::getDataRegistrationStateResponse Invalid response: NULL"); 3200 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3201 } else { 3202 dataRegResponse.regState = (RegState) dataRegState->regState; 3203 dataRegResponse.rat = dataRegState->rat;; 3204 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied; 3205 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls; 3206 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity); 3207 } 3208 } 3209 3210 Return<void> retStatus = 3211 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo, 3212 dataRegResponse); 3213 radioService[slotId]->checkReturnStatus(retStatus); 3214 } else { 3215 RLOGE("radio::getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL", 3216 slotId); 3217 } 3218 3219 return 0; 3220} 3221 3222int radio::getOperatorResponse(android::Parcel &p, int slotId, int requestNumber, 3223 int responseType, int serial, RIL_Errno e, void *response, 3224 size_t responseLen) { 3225 RLOGD("radio::getOperatorResponse: serial %d", serial); 3226 3227 if (radioService[slotId]->mRadioResponse != NULL) { 3228 RadioResponseInfo responseInfo = {}; 3229 populateResponseInfo(responseInfo, serial, responseType, e); 3230 hidl_string longName; 3231 hidl_string shortName; 3232 hidl_string numeric; 3233 int numStrings = responseLen / sizeof(char *); 3234 if (response == NULL || numStrings != 3) { 3235 RLOGE("radio::getOperatorResponse Invalid response: NULL"); 3236 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3237 3238 } else { 3239 char **resp = (char **) response; 3240 longName = convertCharPtrToHidlString(resp[0]); 3241 shortName = convertCharPtrToHidlString(resp[1]); 3242 numeric = convertCharPtrToHidlString(resp[2]); 3243 } 3244 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse( 3245 responseInfo, longName, shortName, numeric); 3246 radioService[slotId]->checkReturnStatus(retStatus); 3247 } else { 3248 RLOGE("radio::getOperatorResponse: radioService[%d]->mRadioResponse == NULL", 3249 slotId); 3250 } 3251 3252 return 0; 3253} 3254 3255int radio::setRadioPowerResponse(android::Parcel &p, int slotId, int requestNumber, 3256 int responseType, int serial, RIL_Errno e, void *response, 3257 size_t responseLen) { 3258 RLOGD("radio::setRadioPowerResponse: serial %d", serial); 3259 3260 if (radioService[slotId]->mRadioResponse != NULL) { 3261 RadioResponseInfo responseInfo = {}; 3262 populateResponseInfo(responseInfo, serial, responseType, e); 3263 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse( 3264 responseInfo); 3265 radioService[slotId]->checkReturnStatus(retStatus); 3266 } else { 3267 RLOGE("radio::setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL", 3268 slotId); 3269 } 3270 3271 return 0; 3272} 3273 3274int radio::sendDtmfResponse(android::Parcel &p, int slotId, int requestNumber, 3275 int responseType, int serial, RIL_Errno e, void *response, 3276 size_t responseLen) { 3277 RLOGD("radio::sendDtmfResponse: serial %d", serial); 3278 3279 if (radioService[slotId]->mRadioResponse != NULL) { 3280 RadioResponseInfo responseInfo = {}; 3281 populateResponseInfo(responseInfo, serial, responseType, e); 3282 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse( 3283 responseInfo); 3284 radioService[slotId]->checkReturnStatus(retStatus); 3285 } else { 3286 RLOGE("radio::sendDtmfResponse: radioService[%d]->mRadioResponse == NULL", 3287 slotId); 3288 } 3289 3290 return 0; 3291} 3292 3293SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType, 3294 RIL_Errno e, void *response, size_t responseLen) { 3295 populateResponseInfo(responseInfo, serial, responseType, e); 3296 SendSmsResult result = {}; 3297 3298 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) { 3299 RLOGE("Invalid response: NULL"); 3300 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3301 result.ackPDU = hidl_string(); 3302 } else { 3303 RIL_SMS_Response *resp = (RIL_SMS_Response *) response; 3304 result.messageRef = resp->messageRef; 3305 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU); 3306 result.errorCode = resp->errorCode; 3307 } 3308 return result; 3309} 3310 3311int radio::sendSmsResponse(android::Parcel &p, int slotId, int requestNumber, 3312 int responseType, int serial, RIL_Errno e, void *response, 3313 size_t responseLen) { 3314 RLOGD("radio::sendSmsResponse: serial %d", serial); 3315 3316 if (radioService[slotId]->mRadioResponse != NULL) { 3317 RadioResponseInfo responseInfo = {}; 3318 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response, 3319 responseLen); 3320 3321 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo, 3322 result); 3323 radioService[slotId]->checkReturnStatus(retStatus); 3324 } else { 3325 RLOGE("radio::sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3326 } 3327 3328 return 0; 3329} 3330 3331int radio::sendSMSExpectMoreResponse(android::Parcel &p, int slotId, int requestNumber, 3332 int responseType, int serial, RIL_Errno e, void *response, 3333 size_t responseLen) { 3334 RLOGD("radio::sendSMSExpectMoreResponse: serial %d", serial); 3335 3336 if (radioService[slotId]->mRadioResponse != NULL) { 3337 RadioResponseInfo responseInfo = {}; 3338 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response, 3339 responseLen); 3340 3341 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse( 3342 responseInfo, result); 3343 radioService[slotId]->checkReturnStatus(retStatus); 3344 } else { 3345 RLOGE("radio::sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3346 } 3347 3348 return 0; 3349} 3350 3351int radio::setupDataCallResponse(android::Parcel &p, int slotId, int requestNumber, 3352 int responseType, int serial, RIL_Errno e, void *response, 3353 size_t responseLen) { 3354 RLOGD("radio::setupDataCallResponse: serial %d", serial); 3355 3356 if (radioService[slotId]->mRadioResponse != NULL) { 3357 RadioResponseInfo responseInfo = {}; 3358 populateResponseInfo(responseInfo, serial, responseType, e); 3359 3360 SetupDataCallResult result = {}; 3361 if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) { 3362 RLOGE("radio::setupDataCallResponse: Invalid response"); 3363 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3364 result.status = DataCallFailCause::ERROR_UNSPECIFIED; 3365 result.type = hidl_string(); 3366 result.ifname = hidl_string(); 3367 result.addresses = hidl_string(); 3368 result.dnses = hidl_string(); 3369 result.gateways = hidl_string(); 3370 result.pcscf = hidl_string(); 3371 } else { 3372 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result); 3373 } 3374 3375 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse( 3376 responseInfo, result); 3377 radioService[slotId]->checkReturnStatus(retStatus); 3378 } else { 3379 RLOGE("radio::setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3380 } 3381 3382 return 0; 3383} 3384 3385IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType, 3386 RIL_Errno e, void *response, size_t responseLen) { 3387 populateResponseInfo(responseInfo, serial, responseType, e); 3388 IccIoResult result = {}; 3389 3390 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) { 3391 RLOGE("Invalid response: NULL"); 3392 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3393 result.simResponse = hidl_string(); 3394 } else { 3395 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response; 3396 result.sw1 = resp->sw1; 3397 result.sw2 = resp->sw2; 3398 result.simResponse = convertCharPtrToHidlString(resp->simResponse); 3399 } 3400 return result; 3401} 3402 3403int radio::iccIOForAppResponse(android::Parcel &p, int slotId, int requestNumber, 3404 int responseType, int serial, RIL_Errno e, void *response, 3405 size_t responseLen) { 3406 RLOGD("radio::radio::iccIOForAppResponse: serial %d", serial); 3407 3408 if (radioService[slotId]->mRadioResponse != NULL) { 3409 RadioResponseInfo responseInfo = {}; 3410 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response, 3411 responseLen); 3412 3413 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse( 3414 responseInfo, result); 3415 radioService[slotId]->checkReturnStatus(retStatus); 3416 } else { 3417 RLOGE("radio::iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3418 } 3419 3420 return 0; 3421} 3422 3423int radio::sendUssdResponse(android::Parcel &p, int slotId, int requestNumber, 3424 int responseType, int serial, RIL_Errno e, void *response, 3425 size_t responseLen) { 3426 RLOGD("radio::sendUssdResponse: serial %d", serial); 3427 3428 if (radioService[slotId]->mRadioResponse != NULL) { 3429 RadioResponseInfo responseInfo = {}; 3430 populateResponseInfo(responseInfo, serial, responseType, e); 3431 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse( 3432 responseInfo); 3433 radioService[slotId]->checkReturnStatus(retStatus); 3434 } else { 3435 RLOGE("radio::sendUssdResponse: radioService[%d]->mRadioResponse == NULL", 3436 slotId); 3437 } 3438 3439 return 0; 3440} 3441 3442int radio::cancelPendingUssdResponse(android::Parcel &p, int slotId, int requestNumber, 3443 int responseType, int serial, RIL_Errno e, void *response, 3444 size_t responseLen) { 3445 RLOGD("radio::cancelPendingUssdResponse: serial %d", serial); 3446 3447 if (radioService[slotId]->mRadioResponse != NULL) { 3448 RadioResponseInfo responseInfo = {}; 3449 populateResponseInfo(responseInfo, serial, responseType, e); 3450 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse( 3451 responseInfo); 3452 radioService[slotId]->checkReturnStatus(retStatus); 3453 } else { 3454 RLOGE("radio::cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL", 3455 slotId); 3456 } 3457 3458 return 0; 3459} 3460 3461int radio::getClirResponse(android::Parcel &p, int slotId, int requestNumber, 3462 int responseType, int serial, RIL_Errno e, void *response, 3463 size_t responseLen) { 3464 RLOGD("radio::getClirResponse: serial %d", serial); 3465 3466 if (radioService[slotId]->mRadioResponse != NULL) { 3467 RadioResponseInfo responseInfo = {}; 3468 populateResponseInfo(responseInfo, serial, responseType, e); 3469 int n = -1, m = -1; 3470 int numInts = responseLen / sizeof(int); 3471 if (response == NULL || numInts != 2) { 3472 RLOGE("radio::getClirResponse Invalid response: NULL"); 3473 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3474 } else { 3475 int *pInt = (int *) response; 3476 n = pInt[0]; 3477 m = pInt[1]; 3478 } 3479 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo, 3480 n, m); 3481 radioService[slotId]->checkReturnStatus(retStatus); 3482 } else { 3483 RLOGE("radio::getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3484 } 3485 3486 return 0; 3487} 3488 3489int radio::setClirResponse(android::Parcel &p, int slotId, int requestNumber, 3490 int responseType, int serial, RIL_Errno e, void *response, 3491 size_t responseLen) { 3492 RLOGD("radio::setClirResponse: serial %d", serial); 3493 3494 if (radioService[slotId]->mRadioResponse != NULL) { 3495 RadioResponseInfo responseInfo = {}; 3496 populateResponseInfo(responseInfo, serial, responseType, e); 3497 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse( 3498 responseInfo); 3499 radioService[slotId]->checkReturnStatus(retStatus); 3500 } else { 3501 RLOGE("radio::setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3502 } 3503 3504 return 0; 3505} 3506 3507int radio::getCallForwardStatusResponse(android::Parcel &p, int slotId, int requestNumber, 3508 int responseType, int serial, RIL_Errno e, 3509 void *response, size_t responseLen) { 3510 RLOGD("radio::getCallForwardStatusResponse: serial %d", serial); 3511 3512 if (radioService[slotId]->mRadioResponse != NULL) { 3513 RadioResponseInfo responseInfo = {}; 3514 populateResponseInfo(responseInfo, serial, responseType, e); 3515 hidl_vec<CallForwardInfo> callForwardInfos; 3516 3517 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) { 3518 RLOGE("radio::getCallForwardStatusResponse Invalid response: NULL"); 3519 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3520 } else { 3521 int num = responseLen / sizeof(RIL_CallForwardInfo *); 3522 callForwardInfos.resize(num); 3523 for (int i = 0 ; i < num; i++) { 3524 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i]; 3525 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status; 3526 callForwardInfos[i].reason = resp->reason; 3527 callForwardInfos[i].serviceClass = resp->serviceClass; 3528 callForwardInfos[i].toa = resp->toa; 3529 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number); 3530 callForwardInfos[i].timeSeconds = resp->timeSeconds; 3531 } 3532 } 3533 3534 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse( 3535 responseInfo, callForwardInfos); 3536 radioService[slotId]->checkReturnStatus(retStatus); 3537 } else { 3538 RLOGE("radio::getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL", 3539 slotId); 3540 } 3541 3542 return 0; 3543} 3544 3545int radio::setCallForwardResponse(android::Parcel &p, int slotId, int requestNumber, 3546 int responseType, int serial, RIL_Errno e, void *response, 3547 size_t responseLen) { 3548 RLOGD("radio::setCallForwardResponse: serial %d", serial); 3549 3550 if (radioService[slotId]->mRadioResponse != NULL) { 3551 RadioResponseInfo responseInfo = {}; 3552 populateResponseInfo(responseInfo, serial, responseType, e); 3553 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse( 3554 responseInfo); 3555 radioService[slotId]->checkReturnStatus(retStatus); 3556 } else { 3557 RLOGE("radio::setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3558 } 3559 3560 return 0; 3561} 3562 3563int radio::getCallWaitingResponse(android::Parcel &p, int slotId, int requestNumber, 3564 int responseType, int serial, RIL_Errno e, void *response, 3565 size_t responseLen) { 3566 RLOGD("radio::getCallWaitingResponse: serial %d", serial); 3567 3568 if (radioService[slotId]->mRadioResponse != NULL) { 3569 RadioResponseInfo responseInfo = {}; 3570 populateResponseInfo(responseInfo, serial, responseType, e); 3571 bool enable = false; 3572 int serviceClass = -1; 3573 int numInts = responseLen / sizeof(int); 3574 if (response == NULL || numInts != 2) { 3575 RLOGE("radio::getCallWaitingResponse Invalid response: NULL"); 3576 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3577 } else { 3578 int *pInt = (int *) response; 3579 enable = pInt[0] == 1 ? true : false; 3580 serviceClass = pInt[1]; 3581 } 3582 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo, 3583 enable, serviceClass); 3584 radioService[slotId]->checkReturnStatus(retStatus); 3585 } else { 3586 RLOGE("radio::getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3587 } 3588 3589 return 0; 3590} 3591 3592int radio::setCallWaitingResponse(android::Parcel &p, int slotId, int requestNumber, 3593 int responseType, int serial, RIL_Errno e, void *response, 3594 size_t responseLen) { 3595 RLOGD("radio::setCallWaitingResponse: serial %d", serial); 3596 3597 if (radioService[slotId]->mRadioResponse != NULL) { 3598 RadioResponseInfo responseInfo = {}; 3599 populateResponseInfo(responseInfo, serial, responseType, e); 3600 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse( 3601 responseInfo); 3602 radioService[slotId]->checkReturnStatus(retStatus); 3603 } else { 3604 RLOGE("radio::setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3605 } 3606 3607 return 0; 3608} 3609 3610int radio::acknowledgeLastIncomingGsmSmsResponse(android::Parcel &p, int slotId, int requestNumber, 3611 int responseType, int serial, RIL_Errno e, 3612 void *response, size_t responseLen) { 3613 RLOGD("radio::acknowledgeLastIncomingGsmSmsResponse: serial %d", serial); 3614 3615 if (radioService[slotId]->mRadioResponse != NULL) { 3616 RadioResponseInfo responseInfo = {}; 3617 populateResponseInfo(responseInfo, serial, responseType, e); 3618 Return<void> retStatus = 3619 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse( 3620 responseInfo); 3621 radioService[slotId]->checkReturnStatus(retStatus); 3622 } else { 3623 RLOGE("radio::acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse " 3624 "== NULL", slotId); 3625 } 3626 3627 return 0; 3628} 3629 3630int radio::acceptCallResponse(android::Parcel &p, int slotId, int requestNumber, 3631 int responseType, int serial, RIL_Errno e, 3632 void *response, size_t responseLen) { 3633 RLOGD("radio::acceptCallResponse: serial %d", serial); 3634 3635 if (radioService[slotId]->mRadioResponse != NULL) { 3636 RadioResponseInfo responseInfo = {}; 3637 populateResponseInfo(responseInfo, serial, responseType, e); 3638 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse( 3639 responseInfo); 3640 radioService[slotId]->checkReturnStatus(retStatus); 3641 } else { 3642 RLOGE("radio::acceptCallResponse: radioService[%d]->mRadioResponse == NULL", 3643 slotId); 3644 } 3645 3646 return 0; 3647} 3648 3649int radio::deactivateDataCallResponse(android::Parcel &p, int slotId, int requestNumber, 3650 int responseType, int serial, RIL_Errno e, 3651 void *response, size_t responseLen) { 3652 RLOGD("radio::deactivateDataCallResponse: serial %d", serial); 3653 3654 if (radioService[slotId]->mRadioResponse != NULL) { 3655 RadioResponseInfo responseInfo = {}; 3656 populateResponseInfo(responseInfo, serial, responseType, e); 3657 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse( 3658 responseInfo); 3659 radioService[slotId]->checkReturnStatus(retStatus); 3660 } else { 3661 RLOGE("radio::deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL", 3662 slotId); 3663 } 3664 3665 return 0; 3666} 3667 3668int radio::getFacilityLockForAppResponse(android::Parcel &p, int slotId, int requestNumber, 3669 int responseType, int serial, RIL_Errno e, 3670 void *response, size_t responseLen) { 3671 RLOGD("radio::getFacilityLockForAppResponse: serial %d", serial); 3672 3673 if (radioService[slotId]->mRadioResponse != NULL) { 3674 RadioResponseInfo responseInfo = {}; 3675 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 3676 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 3677 getFacilityLockForAppResponse(responseInfo, ret); 3678 radioService[slotId]->checkReturnStatus(retStatus); 3679 } else { 3680 RLOGE("radio::getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL", 3681 slotId); 3682 } 3683 3684 return 0; 3685} 3686 3687int radio::setFacilityLockForAppResponse(android::Parcel &p, int slotId, int requestNumber, 3688 int responseType, int serial, RIL_Errno e, 3689 void *response, size_t responseLen) { 3690 RLOGD("radio::setFacilityLockForAppResponse: serial %d", serial); 3691 3692 if (radioService[slotId]->mRadioResponse != NULL) { 3693 RadioResponseInfo responseInfo = {}; 3694 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 3695 Return<void> retStatus 3696 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo, 3697 ret); 3698 radioService[slotId]->checkReturnStatus(retStatus); 3699 } else { 3700 RLOGE("radio::setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL", 3701 slotId); 3702 } 3703 3704 return 0; 3705} 3706 3707int radio::setBarringPasswordResponse(android::Parcel &p, int slotId, int requestNumber, 3708 int responseType, int serial, RIL_Errno e, 3709 void *response, size_t responseLen) { 3710 RLOGD("radio::acceptCallResponse: serial %d", serial); 3711 3712 if (radioService[slotId]->mRadioResponse != NULL) { 3713 RadioResponseInfo responseInfo = {}; 3714 populateResponseInfo(responseInfo, serial, responseType, e); 3715 Return<void> retStatus 3716 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo); 3717 radioService[slotId]->checkReturnStatus(retStatus); 3718 } else { 3719 RLOGE("radio::setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL", 3720 slotId); 3721 } 3722 3723 return 0; 3724} 3725 3726int radio::getNetworkSelectionModeResponse(android::Parcel &p, int slotId, int requestNumber, 3727 int responseType, int serial, RIL_Errno e, void *response, 3728 size_t responseLen) { 3729 RLOGD("radio::getNetworkSelectionModeResponse: serial %d", serial); 3730 3731 if (radioService[slotId]->mRadioResponse != NULL) { 3732 RadioResponseInfo responseInfo = {}; 3733 populateResponseInfo(responseInfo, serial, responseType, e); 3734 bool manual = false; 3735 int serviceClass; 3736 if (response == NULL || responseLen != sizeof(int)) { 3737 RLOGE("radio::getNetworkSelectionModeResponse Invalid response: NULL"); 3738 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3739 } else { 3740 int *pInt = (int *) response; 3741 manual = pInt[0] == 1 ? true : false; 3742 } 3743 Return<void> retStatus 3744 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse( 3745 responseInfo, 3746 manual); 3747 radioService[slotId]->checkReturnStatus(retStatus); 3748 } else { 3749 RLOGE("radio::getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL", 3750 slotId); 3751 } 3752 3753 return 0; 3754} 3755 3756int radio::setNetworkSelectionModeAutomaticResponse(android::Parcel &p, int slotId, 3757 int requestNumber, 3758 int responseType, int serial, RIL_Errno e, 3759 void *response, size_t responseLen) { 3760 RLOGD("radio::setNetworkSelectionModeAutomaticResponse: serial %d", serial); 3761 3762 if (radioService[slotId]->mRadioResponse != NULL) { 3763 RadioResponseInfo responseInfo = {}; 3764 populateResponseInfo(responseInfo, serial, responseType, e); 3765 Return<void> retStatus 3766 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse( 3767 responseInfo); 3768 radioService[slotId]->checkReturnStatus(retStatus); 3769 } else { 3770 RLOGE("radio::setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse " 3771 "== NULL", slotId); 3772 } 3773 3774 return 0; 3775} 3776 3777int radio::setNetworkSelectionModeManualResponse(android::Parcel &p, int slotId, int requestNumber, 3778 int responseType, int serial, RIL_Errno e, 3779 void *response, size_t responseLen) { 3780 RLOGD("radio::setNetworkSelectionModeManualResponse: serial %d", serial); 3781 3782 if (radioService[slotId]->mRadioResponse != NULL) { 3783 RadioResponseInfo responseInfo = {}; 3784 populateResponseInfo(responseInfo, serial, responseType, e); 3785 Return<void> retStatus 3786 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse( 3787 responseInfo); 3788 radioService[slotId]->checkReturnStatus(retStatus); 3789 } else { 3790 RLOGE("radio::acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse " 3791 "== NULL", slotId); 3792 } 3793 3794 return 0; 3795} 3796 3797int convertOperatorStatusToInt(const char *str) { 3798 if (strncmp("unknown", str, 9) == 0) { 3799 return (int) OperatorStatus::UNKNOWN; 3800 } else if (strncmp("available", str, 9) == 0) { 3801 return (int) OperatorStatus::AVAILABLE; 3802 } else if (strncmp("current", str, 9) == 0) { 3803 return (int) OperatorStatus::CURRENT; 3804 } else if (strncmp("forbidden", str, 9) == 0) { 3805 return (int) OperatorStatus::FORBIDDEN; 3806 } else { 3807 return -1; 3808 } 3809} 3810 3811int radio::getAvailableNetworksResponse(android::Parcel &p, int slotId, int requestNumber, 3812 int responseType, int serial, RIL_Errno e, void *response, 3813 size_t responseLen) { 3814 RLOGD("radio::getAvailableNetworksResponse: serial %d", serial); 3815 3816 if (radioService[slotId]->mRadioResponse != NULL) { 3817 RadioResponseInfo responseInfo = {}; 3818 populateResponseInfo(responseInfo, serial, responseType, e); 3819 hidl_vec<OperatorInfo> networks; 3820 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) { 3821 RLOGE("radio::getAvailableNetworksResponse Invalid response: NULL"); 3822 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3823 } else { 3824 char **resp = (char **) response; 3825 int numStrings = responseLen / sizeof(char *); 3826 networks.resize(numStrings/4); 3827 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) { 3828 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]); 3829 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]); 3830 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]); 3831 int status = convertOperatorStatusToInt(resp[i + 3]); 3832 if (status == -1) { 3833 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3834 } else { 3835 networks[j].status = (OperatorStatus) status; 3836 } 3837 } 3838 } 3839 Return<void> retStatus 3840 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo, 3841 networks); 3842 radioService[slotId]->checkReturnStatus(retStatus); 3843 } else { 3844 RLOGE("radio::getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL", 3845 slotId); 3846 } 3847 3848 return 0; 3849} 3850 3851int radio::startDtmfResponse(android::Parcel &p, int slotId, int requestNumber, 3852 int responseType, int serial, RIL_Errno e, 3853 void *response, size_t responseLen) { 3854 RLOGD("radio::startDtmfResponse: serial %d", serial); 3855 3856 if (radioService[slotId]->mRadioResponse != NULL) { 3857 RadioResponseInfo responseInfo = {}; 3858 populateResponseInfo(responseInfo, serial, responseType, e); 3859 Return<void> retStatus 3860 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo); 3861 radioService[slotId]->checkReturnStatus(retStatus); 3862 } else { 3863 RLOGE("radio::startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3864 } 3865 3866 return 0; 3867} 3868 3869int radio::stopDtmfResponse(android::Parcel &p, int slotId, int requestNumber, 3870 int responseType, int serial, RIL_Errno e, 3871 void *response, size_t responseLen) { 3872 RLOGD("radio::stopDtmfResponse: serial %d", serial); 3873 3874 if (radioService[slotId]->mRadioResponse != NULL) { 3875 RadioResponseInfo responseInfo = {}; 3876 populateResponseInfo(responseInfo, serial, responseType, e); 3877 Return<void> retStatus 3878 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo); 3879 radioService[slotId]->checkReturnStatus(retStatus); 3880 } else { 3881 RLOGE("radio::stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3882 } 3883 3884 return 0; 3885} 3886 3887int radio::getBasebandVersionResponse(android::Parcel &p, int slotId, int requestNumber, 3888 int responseType, int serial, RIL_Errno e, 3889 void *response, size_t responseLen) { 3890 RLOGD("radio::getBasebandVersionResponse: serial %d", serial); 3891 3892 if (radioService[slotId]->mRadioResponse != NULL) { 3893 RadioResponseInfo responseInfo = {}; 3894 populateResponseInfo(responseInfo, serial, responseType, e); 3895 Return<void> retStatus 3896 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo, 3897 convertCharPtrToHidlString((char *) response)); 3898 radioService[slotId]->checkReturnStatus(retStatus); 3899 } else { 3900 RLOGE("radio::getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3901 } 3902 3903 return 0; 3904} 3905 3906int radio::separateConnectionResponse(android::Parcel &p, int slotId, int requestNumber, 3907 int responseType, int serial, RIL_Errno e, 3908 void *response, size_t responseLen) { 3909 RLOGD("radio::separateConnectionResponse: serial %d", serial); 3910 3911 if (radioService[slotId]->mRadioResponse != NULL) { 3912 RadioResponseInfo responseInfo = {}; 3913 populateResponseInfo(responseInfo, serial, responseType, e); 3914 Return<void> retStatus 3915 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo); 3916 radioService[slotId]->checkReturnStatus(retStatus); 3917 } else { 3918 RLOGE("radio::separateConnectionResponse: radioService[%d]->mRadioResponse == NULL", 3919 slotId); 3920 } 3921 3922 return 0; 3923} 3924 3925int radio::setMuteResponse(android::Parcel &p, int slotId, int requestNumber, 3926 int responseType, int serial, RIL_Errno e, 3927 void *response, size_t responseLen) { 3928 RLOGD("radio::setMuteResponse: serial %d", serial); 3929 3930 if (radioService[slotId]->mRadioResponse != NULL) { 3931 RadioResponseInfo responseInfo = {}; 3932 populateResponseInfo(responseInfo, serial, responseType, e); 3933 Return<void> retStatus 3934 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo); 3935 radioService[slotId]->checkReturnStatus(retStatus); 3936 } else { 3937 RLOGE("radio::setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3938 } 3939 3940 return 0; 3941} 3942 3943int radio::getMuteResponse(android::Parcel &p, int slotId, int requestNumber, 3944 int responseType, int serial, RIL_Errno e, void *response, 3945 size_t responseLen) { 3946 RLOGD("radio::getMuteResponse: serial %d", serial); 3947 3948 if (radioService[slotId]->mRadioResponse != NULL) { 3949 RadioResponseInfo responseInfo = {}; 3950 populateResponseInfo(responseInfo, serial, responseType, e); 3951 bool enable = false; 3952 int serviceClass; 3953 if (response == NULL || responseLen != sizeof(int)) { 3954 RLOGE("radio::getMuteResponse Invalid response: NULL"); 3955 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3956 } else { 3957 int *pInt = (int *) response; 3958 enable = pInt[0] == 1 ? true : false; 3959 } 3960 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo, 3961 enable); 3962 radioService[slotId]->checkReturnStatus(retStatus); 3963 } else { 3964 RLOGE("radio::getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3965 } 3966 3967 return 0; 3968} 3969 3970int radio::getClipResponse(android::Parcel &p, int slotId, int requestNumber, 3971 int responseType, int serial, RIL_Errno e, 3972 void *response, size_t responseLen) { 3973 RLOGD("radio::getClipResponse: serial %d", serial); 3974 3975 if (radioService[slotId]->mRadioResponse != NULL) { 3976 RadioResponseInfo responseInfo = {}; 3977 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 3978 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo, 3979 (ClipStatus) ret); 3980 radioService[slotId]->checkReturnStatus(retStatus); 3981 } else { 3982 RLOGE("radio::getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3983 } 3984 3985 return 0; 3986} 3987 3988int radio::getDataCallListResponse(android::Parcel &p, int slotId, int requestNumber, 3989 int responseType, int serial, RIL_Errno e, 3990 void *response, size_t responseLen) { 3991 RLOGD("radio::getDataCallListResponse: serial %d", serial); 3992 3993 if (radioService[slotId]->mRadioResponse != NULL) { 3994 RadioResponseInfo responseInfo = {}; 3995 populateResponseInfo(responseInfo, serial, responseType, e); 3996 3997 hidl_vec<SetupDataCallResult> ret; 3998 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) { 3999 RLOGE("radio::getDataCallListResponse: invalid response"); 4000 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4001 } else { 4002 convertRilDataCallListToHal(response, responseLen, ret); 4003 } 4004 4005 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse( 4006 responseInfo, ret); 4007 radioService[slotId]->checkReturnStatus(retStatus); 4008 } else { 4009 RLOGE("radio::getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4010 } 4011 4012 return 0; 4013} 4014 4015int radio::sendScreenStateResponse(android::Parcel &p, int slotId, int requestNumber, 4016 int responseType, int serial, RIL_Errno e, 4017 void *response, size_t responseLen) { 4018 RLOGD("radio::sendScreenStateResponse: serial %d", serial); 4019 4020 if (radioService[slotId]->mRadioResponse != NULL) { 4021 RadioResponseInfo responseInfo = {}; 4022 populateResponseInfo(responseInfo, serial, responseType, e); 4023 Return<void> retStatus 4024 = radioService[slotId]->mRadioResponse->sendScreenStateResponse(responseInfo); 4025 radioService[slotId]->checkReturnStatus(retStatus); 4026 } else { 4027 RLOGE("radio::sendScreenStateResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4028 } 4029 4030 return 0; 4031} 4032 4033int radio::setSuppServiceNotificationsResponse(android::Parcel &p, int slotId, int requestNumber, 4034 int responseType, int serial, RIL_Errno e, 4035 void *response, size_t responseLen) { 4036 RLOGD("radio::setSuppServiceNotificationsResponse: serial %d", serial); 4037 4038 if (radioService[slotId]->mRadioResponse != NULL) { 4039 RadioResponseInfo responseInfo = {}; 4040 populateResponseInfo(responseInfo, serial, responseType, e); 4041 Return<void> retStatus 4042 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse( 4043 responseInfo); 4044 radioService[slotId]->checkReturnStatus(retStatus); 4045 } else { 4046 RLOGE("radio::setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse " 4047 "== NULL", slotId); 4048 } 4049 4050 return 0; 4051} 4052 4053int radio::deleteSmsOnSimResponse(android::Parcel &p, int slotId, int requestNumber, 4054 int responseType, int serial, RIL_Errno e, 4055 void *response, size_t responseLen) { 4056 RLOGD("radio::deleteSmsOnSimResponse: serial %d", serial); 4057 4058 if (radioService[slotId]->mRadioResponse != NULL) { 4059 RadioResponseInfo responseInfo = {}; 4060 populateResponseInfo(responseInfo, serial, responseType, e); 4061 Return<void> retStatus 4062 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo); 4063 radioService[slotId]->checkReturnStatus(retStatus); 4064 } else { 4065 RLOGE("radio::deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4066 } 4067 4068 return 0; 4069} 4070 4071int radio::setBandModeResponse(android::Parcel &p, int slotId, int requestNumber, 4072 int responseType, int serial, RIL_Errno e, 4073 void *response, size_t responseLen) { 4074 RLOGD("radio::setBandModeResponse: serial %d", serial); 4075 4076 if (radioService[slotId]->mRadioResponse != NULL) { 4077 RadioResponseInfo responseInfo = {}; 4078 populateResponseInfo(responseInfo, serial, responseType, e); 4079 Return<void> retStatus 4080 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo); 4081 radioService[slotId]->checkReturnStatus(retStatus); 4082 } else { 4083 RLOGE("radio::setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4084 } 4085 4086 return 0; 4087} 4088 4089int radio::writeSmsToSimResponse(android::Parcel &p, int slotId, int requestNumber, 4090 int responseType, int serial, RIL_Errno e, 4091 void *response, size_t responseLen) { 4092 RLOGD("radio::writeSmsToSimResponse: serial %d", serial); 4093 4094 if (radioService[slotId]->mRadioResponse != NULL) { 4095 RadioResponseInfo responseInfo = {}; 4096 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4097 Return<void> retStatus 4098 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret); 4099 radioService[slotId]->checkReturnStatus(retStatus); 4100 } else { 4101 RLOGE("radio::writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4102 } 4103 4104 return 0; 4105} 4106 4107int radio::getAvailableBandModesResponse(android::Parcel &p, int slotId, int requestNumber, 4108 int responseType, int serial, RIL_Errno e, void *response, 4109 size_t responseLen) { 4110 RLOGD("radio::getAvailableBandModesResponse: serial %d", serial); 4111 4112 if (radioService[slotId]->mRadioResponse != NULL) { 4113 RadioResponseInfo responseInfo = {}; 4114 populateResponseInfo(responseInfo, serial, responseType, e); 4115 hidl_vec<RadioBandMode> modes; 4116 if (response == NULL || responseLen % sizeof(int) != 0) { 4117 RLOGE("radio::getAvailableBandModesResponse Invalid response: NULL"); 4118 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4119 } else { 4120 int *pInt = (int *) response; 4121 int numInts = responseLen / sizeof(int); 4122 modes.resize(numInts); 4123 for (int i = 0; i < numInts; i++) { 4124 modes[i] = (RadioBandMode) pInt[i]; 4125 } 4126 } 4127 Return<void> retStatus 4128 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo, 4129 modes); 4130 radioService[slotId]->checkReturnStatus(retStatus); 4131 } else { 4132 RLOGE("radio::getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL", 4133 slotId); 4134 } 4135 4136 return 0; 4137} 4138 4139int radio::sendEnvelopeResponse(android::Parcel &p, int slotId, int requestNumber, 4140 int responseType, int serial, RIL_Errno e, 4141 void *response, size_t responseLen) { 4142 RLOGD("radio::sendEnvelopeResponse: serial %d", serial); 4143 4144 if (radioService[slotId]->mRadioResponse != NULL) { 4145 RadioResponseInfo responseInfo = {}; 4146 populateResponseInfo(responseInfo, serial, responseType, e); 4147 Return<void> retStatus 4148 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo, 4149 convertCharPtrToHidlString((char *) response)); 4150 radioService[slotId]->checkReturnStatus(retStatus); 4151 } else { 4152 RLOGE("radio::sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4153 } 4154 4155 return 0; 4156} 4157 4158int radio::sendTerminalResponseToSimResponse(android::Parcel &p, int slotId, int requestNumber, 4159 int responseType, int serial, RIL_Errno e, 4160 void *response, size_t responseLen) { 4161 RLOGD("radio::sendTerminalResponseToSimResponse: serial %d", serial); 4162 4163 if (radioService[slotId]->mRadioResponse != NULL) { 4164 RadioResponseInfo responseInfo = {}; 4165 populateResponseInfo(responseInfo, serial, responseType, e); 4166 Return<void> retStatus 4167 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse( 4168 responseInfo); 4169 radioService[slotId]->checkReturnStatus(retStatus); 4170 } else { 4171 RLOGE("radio::sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL", 4172 slotId); 4173 } 4174 4175 return 0; 4176} 4177 4178int radio::handleStkCallSetupRequestFromSimResponse(android::Parcel &p, int slotId, 4179 int requestNumber, int responseType, int serial, 4180 RIL_Errno e, void *response, 4181 size_t responseLen) { 4182 RLOGD("radio::handleStkCallSetupRequestFromSimResponse: serial %d", serial); 4183 4184 if (radioService[slotId]->mRadioResponse != NULL) { 4185 RadioResponseInfo responseInfo = {}; 4186 populateResponseInfo(responseInfo, serial, responseType, e); 4187 Return<void> retStatus 4188 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse( 4189 responseInfo); 4190 radioService[slotId]->checkReturnStatus(retStatus); 4191 } else { 4192 RLOGE("radio::handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse " 4193 "== NULL", slotId); 4194 } 4195 4196 return 0; 4197} 4198 4199int radio::explicitCallTransferResponse(android::Parcel &p, int slotId, int requestNumber, 4200 int responseType, int serial, RIL_Errno e, 4201 void *response, size_t responseLen) { 4202 RLOGD("radio::explicitCallTransferResponse: serial %d", serial); 4203 4204 if (radioService[slotId]->mRadioResponse != NULL) { 4205 RadioResponseInfo responseInfo = {}; 4206 populateResponseInfo(responseInfo, serial, responseType, e); 4207 Return<void> retStatus 4208 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo); 4209 radioService[slotId]->checkReturnStatus(retStatus); 4210 } else { 4211 RLOGE("radio::explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL", 4212 slotId); 4213 } 4214 4215 return 0; 4216} 4217 4218int radio::setPreferredNetworkTypeResponse(android::Parcel &p, int slotId, int requestNumber, 4219 int responseType, int serial, RIL_Errno e, 4220 void *response, size_t responseLen) { 4221 RLOGD("radio::setPreferredNetworkTypeResponse: serial %d", serial); 4222 4223 if (radioService[slotId]->mRadioResponse != NULL) { 4224 RadioResponseInfo responseInfo = {}; 4225 populateResponseInfo(responseInfo, serial, responseType, e); 4226 Return<void> retStatus 4227 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse( 4228 responseInfo); 4229 radioService[slotId]->checkReturnStatus(retStatus); 4230 } else { 4231 RLOGE("radio::setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL", 4232 slotId); 4233 } 4234 4235 return 0; 4236} 4237 4238 4239int radio::getPreferredNetworkTypeResponse(android::Parcel &p, int slotId, int requestNumber, 4240 int responseType, int serial, RIL_Errno e, 4241 void *response, size_t responseLen) { 4242 RLOGD("radio::getPreferredNetworkTypeResponse: serial %d", serial); 4243 4244 if (radioService[slotId]->mRadioResponse != NULL) { 4245 RadioResponseInfo responseInfo = {}; 4246 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4247 Return<void> retStatus 4248 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse( 4249 responseInfo, (PreferredNetworkType) ret); 4250 radioService[slotId]->checkReturnStatus(retStatus); 4251 } else { 4252 RLOGE("radio::getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL", 4253 slotId); 4254 } 4255 4256 return 0; 4257} 4258 4259int radio::getNeighboringCidsResponse(android::Parcel &p, int slotId, int requestNumber, 4260 int responseType, int serial, RIL_Errno e, 4261 void *response, size_t responseLen) { 4262 RLOGD("radio::getNeighboringCidsResponse: serial %d", serial); 4263 4264 if (radioService[slotId]->mRadioResponse != NULL) { 4265 RadioResponseInfo responseInfo = {}; 4266 populateResponseInfo(responseInfo, serial, responseType, e); 4267 hidl_vec<NeighboringCell> cells; 4268 4269 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) { 4270 RLOGE("radio::getNeighboringCidsResponse Invalid response: NULL"); 4271 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4272 } else { 4273 int num = responseLen / sizeof(RIL_NeighboringCell *); 4274 cells.resize(num); 4275 for (int i = 0 ; i < num; i++) { 4276 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i]; 4277 cells[i].cid = convertCharPtrToHidlString(resp->cid); 4278 cells[i].rssi = resp->rssi; 4279 } 4280 } 4281 4282 Return<void> retStatus 4283 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo, 4284 cells); 4285 radioService[slotId]->checkReturnStatus(retStatus); 4286 } else { 4287 RLOGE("radio::getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL", 4288 slotId); 4289 } 4290 4291 return 0; 4292} 4293 4294int radio::setLocationUpdatesResponse(android::Parcel &p, int slotId, int requestNumber, 4295 int responseType, int serial, RIL_Errno e, 4296 void *response, size_t responseLen) { 4297 RLOGD("radio::setLocationUpdatesResponse: serial %d", serial); 4298 4299 if (radioService[slotId]->mRadioResponse != NULL) { 4300 RadioResponseInfo responseInfo = {}; 4301 populateResponseInfo(responseInfo, serial, responseType, e); 4302 Return<void> retStatus 4303 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo); 4304 radioService[slotId]->checkReturnStatus(retStatus); 4305 } else { 4306 RLOGE("radio::setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL", 4307 slotId); 4308 } 4309 4310 return 0; 4311} 4312 4313int radio::setCdmaSubscriptionSourceResponse(android::Parcel &p, int slotId, int requestNumber, 4314 int responseType, int serial, RIL_Errno e, 4315 void *response, size_t responseLen) { 4316 RLOGD("radio::setCdmaSubscriptionSourceResponse: serial %d", serial); 4317 4318 if (radioService[slotId]->mRadioResponse != NULL) { 4319 RadioResponseInfo responseInfo = {}; 4320 populateResponseInfo(responseInfo, serial, responseType, e); 4321 Return<void> retStatus 4322 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse( 4323 responseInfo); 4324 radioService[slotId]->checkReturnStatus(retStatus); 4325 } else { 4326 RLOGE("radio::setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL", 4327 slotId); 4328 } 4329 4330 return 0; 4331} 4332 4333int radio::setCdmaRoamingPreferenceResponse(android::Parcel &p, int slotId, int requestNumber, 4334 int responseType, int serial, RIL_Errno e, 4335 void *response, size_t responseLen) { 4336 RLOGD("radio::setCdmaRoamingPreferenceResponse: serial %d", serial); 4337 4338 if (radioService[slotId]->mRadioResponse != NULL) { 4339 RadioResponseInfo responseInfo = {}; 4340 populateResponseInfo(responseInfo, serial, responseType, e); 4341 Return<void> retStatus 4342 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse( 4343 responseInfo); 4344 radioService[slotId]->checkReturnStatus(retStatus); 4345 } else { 4346 RLOGE("radio::setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL", 4347 slotId); 4348 } 4349 4350 return 0; 4351} 4352 4353int radio::getCdmaRoamingPreferenceResponse(android::Parcel &p, int slotId, int requestNumber, 4354 int responseType, int serial, RIL_Errno e, 4355 void *response, size_t responseLen) { 4356 RLOGD("radio::getCdmaRoamingPreferenceResponse: serial %d", serial); 4357 4358 if (radioService[slotId]->mRadioResponse != NULL) { 4359 RadioResponseInfo responseInfo = {}; 4360 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4361 Return<void> retStatus 4362 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse( 4363 responseInfo, (CdmaRoamingType) ret); 4364 radioService[slotId]->checkReturnStatus(retStatus); 4365 } else { 4366 RLOGE("radio::getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL", 4367 slotId); 4368 } 4369 4370 return 0; 4371} 4372 4373int radio::setTTYModeResponse(android::Parcel &p, int slotId, int requestNumber, 4374 int responseType, int serial, RIL_Errno e, 4375 void *response, size_t responseLen) { 4376 RLOGD("radio::setTTYModeResponse: serial %d", serial); 4377 4378 if (radioService[slotId]->mRadioResponse != NULL) { 4379 RadioResponseInfo responseInfo = {}; 4380 populateResponseInfo(responseInfo, serial, responseType, e); 4381 Return<void> retStatus 4382 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo); 4383 radioService[slotId]->checkReturnStatus(retStatus); 4384 } else { 4385 RLOGE("radio::setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4386 } 4387 4388 return 0; 4389} 4390 4391int radio::getTTYModeResponse(android::Parcel &p, int slotId, int requestNumber, 4392 int responseType, int serial, RIL_Errno e, 4393 void *response, size_t responseLen) { 4394 RLOGD("radio::getTTYModeResponse: serial %d", serial); 4395 4396 if (radioService[slotId]->mRadioResponse != NULL) { 4397 RadioResponseInfo responseInfo = {}; 4398 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4399 Return<void> retStatus 4400 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo, 4401 (TtyMode) ret); 4402 radioService[slotId]->checkReturnStatus(retStatus); 4403 } else { 4404 RLOGE("radio::getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4405 } 4406 4407 return 0; 4408} 4409 4410int radio::setPreferredVoicePrivacyResponse(android::Parcel &p, int slotId, int requestNumber, 4411 int responseType, int serial, RIL_Errno e, 4412 void *response, size_t responseLen) { 4413 RLOGD("radio::setPreferredVoicePrivacyResponse: serial %d", serial); 4414 4415 if (radioService[slotId]->mRadioResponse != NULL) { 4416 RadioResponseInfo responseInfo = {}; 4417 populateResponseInfo(responseInfo, serial, responseType, e); 4418 Return<void> retStatus 4419 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse( 4420 responseInfo); 4421 radioService[slotId]->checkReturnStatus(retStatus); 4422 } else { 4423 RLOGE("radio::setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL", 4424 slotId); 4425 } 4426 4427 return 0; 4428} 4429 4430int radio::getPreferredVoicePrivacyResponse(android::Parcel &p, int slotId, int requestNumber, 4431 int responseType, int serial, RIL_Errno e, 4432 void *response, size_t responseLen) { 4433 RLOGD("radio::getPreferredVoicePrivacyResponse: serial %d", serial); 4434 4435 if (radioService[slotId]->mRadioResponse != NULL) { 4436 RadioResponseInfo responseInfo = {}; 4437 populateResponseInfo(responseInfo, serial, responseType, e); 4438 bool enable = false; 4439 int numInts = responseLen / sizeof(int); 4440 if (response == NULL || numInts != 1) { 4441 RLOGE("radio::getPreferredVoicePrivacyResponse Invalid response: NULL"); 4442 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4443 } else { 4444 int *pInt = (int *) response; 4445 enable = pInt[0] == 1 ? true : false; 4446 } 4447 Return<void> retStatus 4448 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse( 4449 responseInfo, enable); 4450 radioService[slotId]->checkReturnStatus(retStatus); 4451 } else { 4452 RLOGE("radio::getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL", 4453 slotId); 4454 } 4455 4456 return 0; 4457} 4458 4459int radio::sendCDMAFeatureCodeResponse(android::Parcel &p, int slotId, int requestNumber, 4460 int responseType, int serial, RIL_Errno e, 4461 void *response, size_t responseLen) { 4462 RLOGD("radio::sendCDMAFeatureCodeResponse: serial %d", serial); 4463 4464 if (radioService[slotId]->mRadioResponse != NULL) { 4465 RadioResponseInfo responseInfo = {}; 4466 populateResponseInfo(responseInfo, serial, responseType, e); 4467 Return<void> retStatus 4468 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo); 4469 radioService[slotId]->checkReturnStatus(retStatus); 4470 } else { 4471 RLOGE("radio::sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL", 4472 slotId); 4473 } 4474 4475 return 0; 4476} 4477 4478int radio::sendBurstDtmfResponse(android::Parcel &p, int slotId, int requestNumber, 4479 int responseType, int serial, RIL_Errno e, 4480 void *response, size_t responseLen) { 4481 RLOGD("radio::sendBurstDtmfResponse: serial %d", serial); 4482 4483 if (radioService[slotId]->mRadioResponse != NULL) { 4484 RadioResponseInfo responseInfo = {}; 4485 populateResponseInfo(responseInfo, serial, responseType, e); 4486 Return<void> retStatus 4487 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo); 4488 radioService[slotId]->checkReturnStatus(retStatus); 4489 } else { 4490 RLOGE("radio::sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4491 } 4492 4493 return 0; 4494} 4495 4496int radio::sendCdmaSmsResponse(android::Parcel &p, int slotId, int requestNumber, 4497 int responseType, int serial, RIL_Errno e, void *response, 4498 size_t responseLen) { 4499 RLOGD("radio::sendCdmaSmsResponse: serial %d", serial); 4500 4501 if (radioService[slotId]->mRadioResponse != NULL) { 4502 RadioResponseInfo responseInfo = {}; 4503 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response, 4504 responseLen); 4505 4506 Return<void> retStatus 4507 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result); 4508 radioService[slotId]->checkReturnStatus(retStatus); 4509 } else { 4510 RLOGE("radio::sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4511 } 4512 4513 return 0; 4514} 4515 4516int radio::acknowledgeLastIncomingCdmaSmsResponse(android::Parcel &p, int slotId, int requestNumber, 4517 int responseType, int serial, RIL_Errno e, 4518 void *response, size_t responseLen) { 4519 RLOGD("radio::acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial); 4520 4521 if (radioService[slotId]->mRadioResponse != NULL) { 4522 RadioResponseInfo responseInfo = {}; 4523 populateResponseInfo(responseInfo, serial, responseType, e); 4524 Return<void> retStatus 4525 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse( 4526 responseInfo); 4527 radioService[slotId]->checkReturnStatus(retStatus); 4528 } else { 4529 RLOGE("radio::acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse " 4530 "== NULL", slotId); 4531 } 4532 4533 return 0; 4534} 4535 4536int radio::getGsmBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber, 4537 int responseType, int serial, RIL_Errno e, 4538 void *response, size_t responseLen) { 4539 RLOGD("radio::getGsmBroadcastConfigResponse: serial %d", serial); 4540 4541 if (radioService[slotId]->mRadioResponse != NULL) { 4542 RadioResponseInfo responseInfo = {}; 4543 populateResponseInfo(responseInfo, serial, responseType, e); 4544 hidl_vec<GsmBroadcastSmsConfigInfo> configs; 4545 4546 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) { 4547 RLOGE("radio::getGsmBroadcastConfigResponse Invalid response: NULL"); 4548 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4549 } else { 4550 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *); 4551 configs.resize(num); 4552 for (int i = 0 ; i < num; i++) { 4553 RIL_GSM_BroadcastSmsConfigInfo *resp = 4554 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i]; 4555 configs[i].fromServiceId = resp->fromServiceId; 4556 configs[i].toServiceId = resp->toServiceId; 4557 configs[i].fromCodeScheme = resp->fromCodeScheme; 4558 configs[i].toCodeScheme = resp->toCodeScheme; 4559 configs[i].selected = resp->selected == 1 ? true : false; 4560 } 4561 } 4562 4563 Return<void> retStatus 4564 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo, 4565 configs); 4566 radioService[slotId]->checkReturnStatus(retStatus); 4567 } else { 4568 RLOGE("radio::getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL", 4569 slotId); 4570 } 4571 4572 return 0; 4573} 4574 4575int radio::setGsmBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber, 4576 int responseType, int serial, RIL_Errno e, 4577 void *response, size_t responseLen) { 4578 RLOGD("radio::setGsmBroadcastConfigResponse: serial %d", serial); 4579 4580 if (radioService[slotId]->mRadioResponse != NULL) { 4581 RadioResponseInfo responseInfo = {}; 4582 populateResponseInfo(responseInfo, serial, responseType, e); 4583 Return<void> retStatus 4584 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo); 4585 radioService[slotId]->checkReturnStatus(retStatus); 4586 } else { 4587 RLOGE("radio::setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL", 4588 slotId); 4589 } 4590 4591 return 0; 4592} 4593 4594int radio::setGsmBroadcastActivationResponse(android::Parcel &p, int slotId, int requestNumber, 4595 int responseType, int serial, RIL_Errno e, 4596 void *response, size_t responseLen) { 4597 RLOGD("radio::setGsmBroadcastActivationResponse: serial %d", serial); 4598 4599 if (radioService[slotId]->mRadioResponse != NULL) { 4600 RadioResponseInfo responseInfo = {}; 4601 populateResponseInfo(responseInfo, serial, responseType, e); 4602 Return<void> retStatus 4603 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse( 4604 responseInfo); 4605 radioService[slotId]->checkReturnStatus(retStatus); 4606 } else { 4607 RLOGE("radio::setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL", 4608 slotId); 4609 } 4610 4611 return 0; 4612} 4613 4614int radio::getCdmaBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber, 4615 int responseType, int serial, RIL_Errno e, 4616 void *response, size_t responseLen) { 4617 RLOGD("radio::getCdmaBroadcastConfigResponse: serial %d", serial); 4618 4619 if (radioService[slotId]->mRadioResponse != NULL) { 4620 RadioResponseInfo responseInfo = {}; 4621 populateResponseInfo(responseInfo, serial, responseType, e); 4622 hidl_vec<CdmaBroadcastSmsConfigInfo> configs; 4623 4624 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) { 4625 RLOGE("radio::getCdmaBroadcastConfigResponse Invalid response: NULL"); 4626 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4627 } else { 4628 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *); 4629 configs.resize(num); 4630 for (int i = 0 ; i < num; i++) { 4631 RIL_CDMA_BroadcastSmsConfigInfo *resp = 4632 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i]; 4633 configs[i].serviceCategory = resp->service_category; 4634 configs[i].language = resp->language; 4635 configs[i].selected = resp->selected == 1 ? true : false; 4636 } 4637 } 4638 4639 Return<void> retStatus 4640 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo, 4641 configs); 4642 radioService[slotId]->checkReturnStatus(retStatus); 4643 } else { 4644 RLOGE("radio::getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL", 4645 slotId); 4646 } 4647 4648 return 0; 4649} 4650 4651int radio::setCdmaBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber, 4652 int responseType, int serial, RIL_Errno e, 4653 void *response, size_t responseLen) { 4654 RLOGD("radio::setCdmaBroadcastConfigResponse: serial %d", serial); 4655 4656 if (radioService[slotId]->mRadioResponse != NULL) { 4657 RadioResponseInfo responseInfo = {}; 4658 populateResponseInfo(responseInfo, serial, responseType, e); 4659 Return<void> retStatus 4660 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse( 4661 responseInfo); 4662 radioService[slotId]->checkReturnStatus(retStatus); 4663 } else { 4664 RLOGE("radio::setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL", 4665 slotId); 4666 } 4667 4668 return 0; 4669} 4670 4671int radio::setCdmaBroadcastActivationResponse(android::Parcel &p, int slotId, int requestNumber, 4672 int responseType, int serial, RIL_Errno e, 4673 void *response, size_t responseLen) { 4674 RLOGD("radio::setCdmaBroadcastActivationResponse: serial %d", serial); 4675 4676 if (radioService[slotId]->mRadioResponse != NULL) { 4677 RadioResponseInfo responseInfo = {}; 4678 populateResponseInfo(responseInfo, serial, responseType, e); 4679 Return<void> retStatus 4680 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse( 4681 responseInfo); 4682 radioService[slotId]->checkReturnStatus(retStatus); 4683 } else { 4684 RLOGE("radio::setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL", 4685 slotId); 4686 } 4687 4688 return 0; 4689} 4690 4691int radio::getCDMASubscriptionResponse(android::Parcel &p, int slotId, int requestNumber, 4692 int responseType, int serial, RIL_Errno e, void *response, 4693 size_t responseLen) { 4694 RLOGD("radio::getCDMASubscriptionResponse: serial %d", serial); 4695 4696 if (radioService[slotId]->mRadioResponse != NULL) { 4697 RadioResponseInfo responseInfo = {}; 4698 populateResponseInfo(responseInfo, serial, responseType, e); 4699 4700 int numStrings = responseLen / sizeof(char *); 4701 hidl_string emptyString; 4702 if (response == NULL || numStrings != 5) { 4703 RLOGE("radio::getOperatorResponse Invalid response: NULL"); 4704 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4705 Return<void> retStatus 4706 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse( 4707 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString); 4708 radioService[slotId]->checkReturnStatus(retStatus); 4709 } else { 4710 char **resp = (char **) response; 4711 Return<void> retStatus 4712 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse( 4713 responseInfo, 4714 convertCharPtrToHidlString(resp[0]), 4715 convertCharPtrToHidlString(resp[1]), 4716 convertCharPtrToHidlString(resp[2]), 4717 convertCharPtrToHidlString(resp[3]), 4718 convertCharPtrToHidlString(resp[4])); 4719 radioService[slotId]->checkReturnStatus(retStatus); 4720 } 4721 } else { 4722 RLOGE("radio::getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL", 4723 slotId); 4724 } 4725 4726 return 0; 4727} 4728 4729int radio::writeSmsToRuimResponse(android::Parcel &p, int slotId, int requestNumber, 4730 int responseType, int serial, RIL_Errno e, 4731 void *response, size_t responseLen) { 4732 RLOGD("radio::writeSmsToRuimResponse: serial %d", serial); 4733 4734 if (radioService[slotId]->mRadioResponse != NULL) { 4735 RadioResponseInfo responseInfo = {}; 4736 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4737 Return<void> retStatus 4738 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret); 4739 radioService[slotId]->checkReturnStatus(retStatus); 4740 } else { 4741 RLOGE("radio::writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4742 } 4743 4744 return 0; 4745} 4746 4747int radio::deleteSmsOnRuimResponse(android::Parcel &p, int slotId, int requestNumber, 4748 int responseType, int serial, RIL_Errno e, 4749 void *response, size_t responseLen) { 4750 RLOGD("radio::deleteSmsOnRuimResponse: serial %d", serial); 4751 4752 if (radioService[slotId]->mRadioResponse != NULL) { 4753 RadioResponseInfo responseInfo = {}; 4754 populateResponseInfo(responseInfo, serial, responseType, e); 4755 Return<void> retStatus 4756 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo); 4757 radioService[slotId]->checkReturnStatus(retStatus); 4758 } else { 4759 RLOGE("radio::deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4760 } 4761 4762 return 0; 4763} 4764 4765int radio::getDeviceIdentityResponse(android::Parcel &p, int slotId, int requestNumber, 4766 int responseType, int serial, RIL_Errno e, void *response, 4767 size_t responseLen) { 4768 RLOGD("radio::getDeviceIdentityResponse: serial %d", serial); 4769 4770 if (radioService[slotId]->mRadioResponse != NULL) { 4771 RadioResponseInfo responseInfo = {}; 4772 populateResponseInfo(responseInfo, serial, responseType, e); 4773 4774 int numStrings = responseLen / sizeof(char *); 4775 hidl_string emptyString; 4776 if (response == NULL || numStrings != 4) { 4777 RLOGE("radio::getDeviceIdentityResponse Invalid response: NULL"); 4778 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4779 Return<void> retStatus 4780 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo, 4781 emptyString, emptyString, emptyString, emptyString); 4782 radioService[slotId]->checkReturnStatus(retStatus); 4783 } else { 4784 char **resp = (char **) response; 4785 Return<void> retStatus 4786 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo, 4787 convertCharPtrToHidlString(resp[0]), 4788 convertCharPtrToHidlString(resp[1]), 4789 convertCharPtrToHidlString(resp[2]), 4790 convertCharPtrToHidlString(resp[3])); 4791 radioService[slotId]->checkReturnStatus(retStatus); 4792 } 4793 } else { 4794 RLOGE("radio::getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL", 4795 slotId); 4796 } 4797 4798 return 0; 4799} 4800 4801int radio::exitEmergencyCallbackModeResponse(android::Parcel &p, int slotId, int requestNumber, 4802 int responseType, int serial, RIL_Errno e, 4803 void *response, size_t responseLen) { 4804 RLOGD("radio::exitEmergencyCallbackModeResponse: serial %d", serial); 4805 4806 if (radioService[slotId]->mRadioResponse != NULL) { 4807 RadioResponseInfo responseInfo = {}; 4808 populateResponseInfo(responseInfo, serial, responseType, e); 4809 Return<void> retStatus 4810 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse( 4811 responseInfo); 4812 radioService[slotId]->checkReturnStatus(retStatus); 4813 } else { 4814 RLOGE("radio::exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL", 4815 slotId); 4816 } 4817 4818 return 0; 4819} 4820 4821int radio::getSmscAddressResponse(android::Parcel &p, int slotId, int requestNumber, 4822 int responseType, int serial, RIL_Errno e, 4823 void *response, size_t responseLen) { 4824 RLOGD("radio::getSmscAddressResponse: serial %d", serial); 4825 4826 if (radioService[slotId]->mRadioResponse != NULL) { 4827 RadioResponseInfo responseInfo = {}; 4828 populateResponseInfo(responseInfo, serial, responseType, e); 4829 Return<void> retStatus 4830 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo, 4831 convertCharPtrToHidlString((char *) response)); 4832 radioService[slotId]->checkReturnStatus(retStatus); 4833 } else { 4834 RLOGE("radio::getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4835 } 4836 4837 return 0; 4838} 4839 4840int radio::setSmscAddressResponse(android::Parcel &p, int slotId, int requestNumber, 4841 int responseType, int serial, RIL_Errno e, 4842 void *response, size_t responseLen) { 4843 RLOGD("radio::setSmscAddressResponse: serial %d", serial); 4844 4845 if (radioService[slotId]->mRadioResponse != NULL) { 4846 RadioResponseInfo responseInfo = {}; 4847 populateResponseInfo(responseInfo, serial, responseType, e); 4848 Return<void> retStatus 4849 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo); 4850 radioService[slotId]->checkReturnStatus(retStatus); 4851 } else { 4852 RLOGE("radio::setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4853 } 4854 4855 return 0; 4856} 4857 4858int radio::reportSmsMemoryStatusResponse(android::Parcel &p, int slotId, int requestNumber, 4859 int responseType, int serial, RIL_Errno e, 4860 void *response, size_t responseLen) { 4861 RLOGD("radio::reportSmsMemoryStatusResponse: serial %d", serial); 4862 4863 if (radioService[slotId]->mRadioResponse != NULL) { 4864 RadioResponseInfo responseInfo = {}; 4865 populateResponseInfo(responseInfo, serial, responseType, e); 4866 Return<void> retStatus 4867 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo); 4868 radioService[slotId]->checkReturnStatus(retStatus); 4869 } else { 4870 RLOGE("radio::reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL", 4871 slotId); 4872 } 4873 4874 return 0; 4875} 4876 4877int radio::reportStkServiceIsRunningResponse(android::Parcel &p, int slotId, int requestNumber, 4878 int responseType, int serial, RIL_Errno e, 4879 void *response, size_t responseLen) { 4880 RLOGD("radio::reportStkServiceIsRunningResponse: serial %d", serial); 4881 4882 if (radioService[slotId]->mRadioResponse != NULL) { 4883 RadioResponseInfo responseInfo = {}; 4884 populateResponseInfo(responseInfo, serial, responseType, e); 4885 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 4886 reportStkServiceIsRunningResponse(responseInfo); 4887 radioService[slotId]->checkReturnStatus(retStatus); 4888 } else { 4889 RLOGE("radio::reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL", 4890 slotId); 4891 } 4892 4893 return 0; 4894} 4895 4896int radio::getCdmaSubscriptionSourceResponse(android::Parcel &p, int slotId, int requestNumber, 4897 int responseType, int serial, RIL_Errno e, 4898 void *response, size_t responseLen) { 4899 RLOGD("radio::getCdmaSubscriptionSourceResponse: serial %d", serial); 4900 4901 if (radioService[slotId]->mRadioResponse != NULL) { 4902 RadioResponseInfo responseInfo = {}; 4903 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4904 Return<void> retStatus 4905 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse( 4906 responseInfo, (CdmaSubscriptionSource) ret); 4907 radioService[slotId]->checkReturnStatus(retStatus); 4908 } else { 4909 RLOGE("radio::getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL", 4910 slotId); 4911 } 4912 4913 return 0; 4914} 4915 4916int radio::requestIsimAuthenticationResponse(android::Parcel &p, int slotId, int requestNumber, 4917 int responseType, int serial, RIL_Errno e, 4918 void *response, size_t responseLen) { 4919 RLOGD("radio::requestIsimAuthenticationResponse: serial %d", serial); 4920 4921 if (radioService[slotId]->mRadioResponse != NULL) { 4922 RadioResponseInfo responseInfo = {}; 4923 populateResponseInfo(responseInfo, serial, responseType, e); 4924 Return<void> retStatus 4925 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse( 4926 responseInfo, 4927 convertCharPtrToHidlString((char *) response)); 4928 radioService[slotId]->checkReturnStatus(retStatus); 4929 } else { 4930 RLOGE("radio::requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL", 4931 slotId); 4932 } 4933 4934 return 0; 4935} 4936 4937int radio::acknowledgeIncomingGsmSmsWithPduResponse(android::Parcel &p, int slotId, 4938 int requestNumber, int responseType, 4939 int serial, RIL_Errno e, void *response, 4940 size_t responseLen) { 4941 RLOGD("radio::acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial); 4942 4943 if (radioService[slotId]->mRadioResponse != NULL) { 4944 RadioResponseInfo responseInfo = {}; 4945 populateResponseInfo(responseInfo, serial, responseType, e); 4946 Return<void> retStatus 4947 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse( 4948 responseInfo); 4949 radioService[slotId]->checkReturnStatus(retStatus); 4950 } else { 4951 RLOGE("radio::acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse " 4952 "== NULL", slotId); 4953 } 4954 4955 return 0; 4956} 4957 4958int radio::sendEnvelopeWithStatusResponse(android::Parcel &p, int slotId, int requestNumber, 4959 int responseType, int serial, RIL_Errno e, void *response, 4960 size_t responseLen) { 4961 RLOGD("radio::sendEnvelopeWithStatusResponse: serial %d", serial); 4962 4963 if (radioService[slotId]->mRadioResponse != NULL) { 4964 RadioResponseInfo responseInfo = {}; 4965 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, 4966 response, responseLen); 4967 4968 Return<void> retStatus 4969 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo, 4970 result); 4971 radioService[slotId]->checkReturnStatus(retStatus); 4972 } else { 4973 RLOGE("radio::sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL", 4974 slotId); 4975 } 4976 4977 return 0; 4978} 4979 4980int radio::getVoiceRadioTechnologyResponse(android::Parcel &p, int slotId, int requestNumber, 4981 int responseType, int serial, RIL_Errno e, 4982 void *response, size_t responseLen) { 4983 RLOGD("radio::getVoiceRadioTechnologyResponse: serial %d", serial); 4984 4985 if (radioService[slotId]->mRadioResponse != NULL) { 4986 RadioResponseInfo responseInfo = {}; 4987 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4988 Return<void> retStatus 4989 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse( 4990 responseInfo, (RadioTechnology) ret); 4991 radioService[slotId]->checkReturnStatus(retStatus); 4992 } else { 4993 RLOGE("radio::getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL", 4994 slotId); 4995 } 4996 4997 return 0; 4998} 4999 5000int radio::getCellInfoListResponse(android::Parcel &p, int slotId, 5001 int requestNumber, int responseType, 5002 int serial, RIL_Errno e, void *response, 5003 size_t responseLen) { 5004 RLOGD("radio::getCellInfoListResponse: serial %d", serial); 5005 5006 if (radioService[slotId]->mRadioResponse != NULL) { 5007 RadioResponseInfo responseInfo = {}; 5008 populateResponseInfo(responseInfo, serial, responseType, e); 5009 5010 hidl_vec<CellInfo> ret; 5011 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) { 5012 RLOGE("radio::getCellInfoListResponse: Invalid response"); 5013 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 5014 } else { 5015 convertRilCellInfoListToHal(response, responseLen, ret); 5016 } 5017 5018 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse( 5019 responseInfo, ret); 5020 radioService[slotId]->checkReturnStatus(retStatus); 5021 } else { 5022 RLOGE("radio::getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5023 } 5024 5025 return 0; 5026} 5027 5028int radio::setCellInfoListRateResponse(android::Parcel &p, int slotId, 5029 int requestNumber, int responseType, 5030 int serial, RIL_Errno e, void *response, 5031 size_t responseLen) { 5032 RLOGD("radio::setCellInfoListRateResponse: serial %d", serial); 5033 5034 if (radioService[slotId]->mRadioResponse != NULL) { 5035 RadioResponseInfo responseInfo = {}; 5036 populateResponseInfo(responseInfo, serial, responseType, e); 5037 Return<void> retStatus 5038 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo); 5039 radioService[slotId]->checkReturnStatus(retStatus); 5040 } else { 5041 RLOGE("radio::setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL", 5042 slotId); 5043 } 5044 5045 return 0; 5046} 5047 5048int radio::setInitialAttachApnResponse(android::Parcel &p, int slotId, int requestNumber, 5049 int responseType, int serial, RIL_Errno e, 5050 void *response, size_t responseLen) { 5051 RLOGD("radio::setInitialAttachApnResponse: serial %d", serial); 5052 5053 if (radioService[slotId]->mRadioResponse != NULL) { 5054 RadioResponseInfo responseInfo = {}; 5055 populateResponseInfo(responseInfo, serial, responseType, e); 5056 Return<void> retStatus 5057 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo); 5058 radioService[slotId]->checkReturnStatus(retStatus); 5059 } else { 5060 RLOGE("radio::setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", 5061 slotId); 5062 } 5063 5064 return 0; 5065} 5066 5067int radio::getImsRegistrationStateResponse(android::Parcel &p, int slotId, int requestNumber, 5068 int responseType, int serial, RIL_Errno e, 5069 void *response, size_t responseLen) { 5070 RLOGD("radio::getImsRegistrationStateResponse: serial %d", serial); 5071 5072 if (radioService[slotId]->mRadioResponse != NULL) { 5073 RadioResponseInfo responseInfo = {}; 5074 populateResponseInfo(responseInfo, serial, responseType, e); 5075 bool isRegistered = false; 5076 int ratFamily = 0; 5077 int numInts = responseLen / sizeof(int); 5078 if (response == NULL || numInts != 2) { 5079 RLOGE("radio::getImsRegistrationStateResponse Invalid response: NULL"); 5080 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 5081 } else { 5082 int *pInt = (int *) response; 5083 isRegistered = pInt[0] == 1 ? true : false; 5084 ratFamily = pInt[1]; 5085 } 5086 Return<void> retStatus 5087 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse( 5088 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily); 5089 radioService[slotId]->checkReturnStatus(retStatus); 5090 } else { 5091 RLOGE("radio::getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL", 5092 slotId); 5093 } 5094 5095 return 0; 5096} 5097 5098int radio::sendImsSmsResponse(android::Parcel &p, int slotId, int requestNumber, 5099 int responseType, int serial, RIL_Errno e, void *response, 5100 size_t responseLen) { 5101 RLOGD("radio::sendImsSmsResponse: serial %d", serial); 5102 5103 if (radioService[slotId]->mRadioResponse != NULL) { 5104 RadioResponseInfo responseInfo = {}; 5105 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response, 5106 responseLen); 5107 5108 Return<void> retStatus 5109 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result); 5110 radioService[slotId]->checkReturnStatus(retStatus); 5111 } else { 5112 RLOGE("radio::sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5113 } 5114 5115 return 0; 5116} 5117 5118int radio::iccTransmitApduBasicChannelResponse(android::Parcel &p, int slotId, int requestNumber, 5119 int responseType, int serial, RIL_Errno e, 5120 void *response, size_t responseLen) { 5121 RLOGD("radio::iccTransmitApduBasicChannelResponse: serial %d", serial); 5122 5123 if (radioService[slotId]->mRadioResponse != NULL) { 5124 RadioResponseInfo responseInfo = {}; 5125 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response, 5126 responseLen); 5127 5128 Return<void> retStatus 5129 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse( 5130 responseInfo, result); 5131 radioService[slotId]->checkReturnStatus(retStatus); 5132 } else { 5133 RLOGE("radio::iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse " 5134 "== NULL", slotId); 5135 } 5136 5137 return 0; 5138} 5139 5140int radio::iccOpenLogicalChannelResponse(android::Parcel &p, int slotId, int requestNumber, 5141 int responseType, int serial, RIL_Errno e, void *response, 5142 size_t responseLen) { 5143 RLOGD("radio::iccOpenLogicalChannelResponse: serial %d", serial); 5144 5145 if (radioService[slotId]->mRadioResponse != NULL) { 5146 RadioResponseInfo responseInfo = {}; 5147 populateResponseInfo(responseInfo, serial, responseType, e); 5148 int channelId = -1; 5149 hidl_vec<int8_t> selectResponse; 5150 int numInts = responseLen / sizeof(int); 5151 if (response == NULL || responseLen % sizeof(int) != 0) { 5152 RLOGE("radio::iccOpenLogicalChannelResponse Invalid response: NULL"); 5153 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 5154 } else { 5155 int *pInt = (int *) response; 5156 channelId = pInt[0]; 5157 selectResponse.resize(numInts - 1); 5158 for (int i = 1; i < numInts; i++) { 5159 selectResponse[i - 1] = (int8_t) pInt[i]; 5160 } 5161 } 5162 Return<void> retStatus 5163 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo, 5164 channelId, selectResponse); 5165 radioService[slotId]->checkReturnStatus(retStatus); 5166 } else { 5167 RLOGE("radio::iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL", 5168 slotId); 5169 } 5170 5171 return 0; 5172} 5173 5174int radio::iccCloseLogicalChannelResponse(android::Parcel &p, int slotId, int requestNumber, 5175 int responseType, int serial, RIL_Errno e, 5176 void *response, size_t responseLen) { 5177 RLOGD("radio::iccCloseLogicalChannelResponse: serial %d", serial); 5178 5179 if (radioService[slotId]->mRadioResponse != NULL) { 5180 RadioResponseInfo responseInfo = {}; 5181 populateResponseInfo(responseInfo, serial, responseType, e); 5182 Return<void> retStatus 5183 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse( 5184 responseInfo); 5185 radioService[slotId]->checkReturnStatus(retStatus); 5186 } else { 5187 RLOGE("radio::iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL", 5188 slotId); 5189 } 5190 5191 return 0; 5192} 5193 5194int radio::iccTransmitApduLogicalChannelResponse(android::Parcel &p, int slotId, int requestNumber, 5195 int responseType, int serial, RIL_Errno e, 5196 void *response, size_t responseLen) { 5197 RLOGD("radio::iccTransmitApduLogicalChannelResponse: serial %d", serial); 5198 5199 if (radioService[slotId]->mRadioResponse != NULL) { 5200 RadioResponseInfo responseInfo = {}; 5201 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response, 5202 responseLen); 5203 5204 Return<void> retStatus 5205 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse( 5206 responseInfo, result); 5207 radioService[slotId]->checkReturnStatus(retStatus); 5208 } else { 5209 RLOGE("radio::iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse " 5210 "== NULL", slotId); 5211 } 5212 5213 return 0; 5214} 5215 5216int radio::nvReadItemResponse(android::Parcel &p, int slotId, int requestNumber, 5217 int responseType, int serial, RIL_Errno e, 5218 void *response, size_t responseLen) { 5219 RLOGD("radio::nvReadItemResponse: serial %d", serial); 5220 5221 if (radioService[slotId]->mRadioResponse != NULL) { 5222 RadioResponseInfo responseInfo = {}; 5223 populateResponseInfo(responseInfo, serial, responseType, e); 5224 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse( 5225 responseInfo, 5226 convertCharPtrToHidlString((char *) response)); 5227 radioService[slotId]->checkReturnStatus(retStatus); 5228 } else { 5229 RLOGE("radio::nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5230 } 5231 5232 return 0; 5233} 5234 5235int radio::nvWriteItemResponse(android::Parcel &p, int slotId, int requestNumber, 5236 int responseType, int serial, RIL_Errno e, 5237 void *response, size_t responseLen) { 5238 RLOGD("radio::nvWriteItemResponse: serial %d", serial); 5239 5240 if (radioService[slotId]->mRadioResponse != NULL) { 5241 RadioResponseInfo responseInfo = {}; 5242 populateResponseInfo(responseInfo, serial, responseType, e); 5243 Return<void> retStatus 5244 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo); 5245 radioService[slotId]->checkReturnStatus(retStatus); 5246 } else { 5247 RLOGE("radio::nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5248 } 5249 5250 return 0; 5251} 5252 5253int radio::nvWriteCdmaPrlResponse(android::Parcel &p, int slotId, int requestNumber, 5254 int responseType, int serial, RIL_Errno e, 5255 void *response, size_t responseLen) { 5256 RLOGD("radio::nvWriteCdmaPrlResponse: serial %d", serial); 5257 5258 if (radioService[slotId]->mRadioResponse != NULL) { 5259 RadioResponseInfo responseInfo = {}; 5260 populateResponseInfo(responseInfo, serial, responseType, e); 5261 Return<void> retStatus 5262 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo); 5263 radioService[slotId]->checkReturnStatus(retStatus); 5264 } else { 5265 RLOGE("radio::nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5266 } 5267 5268 return 0; 5269} 5270 5271int radio::nvResetConfigResponse(android::Parcel &p, int slotId, int requestNumber, 5272 int responseType, int serial, RIL_Errno e, 5273 void *response, size_t responseLen) { 5274 RLOGD("radio::nvResetConfigResponse: serial %d", serial); 5275 5276 if (radioService[slotId]->mRadioResponse != NULL) { 5277 RadioResponseInfo responseInfo = {}; 5278 populateResponseInfo(responseInfo, serial, responseType, e); 5279 Return<void> retStatus 5280 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo); 5281 radioService[slotId]->checkReturnStatus(retStatus); 5282 } else { 5283 RLOGE("radio::nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5284 } 5285 5286 return 0; 5287} 5288 5289int radio::setUiccSubscriptionResponse(android::Parcel &p, int slotId, int requestNumber, 5290 int responseType, int serial, RIL_Errno e, 5291 void *response, size_t responseLen) { 5292 RLOGD("radio::setUiccSubscriptionResponse: serial %d", serial); 5293 5294 if (radioService[slotId]->mRadioResponse != NULL) { 5295 RadioResponseInfo responseInfo = {}; 5296 populateResponseInfo(responseInfo, serial, responseType, e); 5297 Return<void> retStatus 5298 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo); 5299 radioService[slotId]->checkReturnStatus(retStatus); 5300 } else { 5301 RLOGE("radio::setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL", 5302 slotId); 5303 } 5304 5305 return 0; 5306} 5307 5308int radio::setDataAllowedResponse(android::Parcel &p, int slotId, int requestNumber, 5309 int responseType, int serial, RIL_Errno e, 5310 void *response, size_t responseLen) { 5311 RLOGD("radio::setDataAllowedResponse: serial %d", serial); 5312 5313 if (radioService[slotId]->mRadioResponse != NULL) { 5314 RadioResponseInfo responseInfo = {}; 5315 populateResponseInfo(responseInfo, serial, responseType, e); 5316 Return<void> retStatus 5317 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo); 5318 radioService[slotId]->checkReturnStatus(retStatus); 5319 } else { 5320 RLOGE("radio::setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5321 } 5322 5323 return 0; 5324} 5325 5326int radio::getHardwareConfigResponse(android::Parcel &p, int slotId, int requestNumber, 5327 int responseType, int serial, RIL_Errno e, 5328 void *response, size_t responseLen) { 5329 RLOGD("radio::getHardwareConfigResponse: serial %d", serial); 5330 5331 if (radioService[slotId]->mRadioResponse != NULL) { 5332 RadioResponseInfo responseInfo = {}; 5333 populateResponseInfo(responseInfo, serial, responseType, e); 5334 5335 hidl_vec<HardwareConfig> result; 5336 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) { 5337 RLOGE("radio::hardwareConfigChangedInd: invalid response"); 5338 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 5339 } else { 5340 convertRilHardwareConfigListToHal(response, responseLen, result); 5341 } 5342 5343 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse( 5344 responseInfo, result); 5345 radioService[slotId]->checkReturnStatus(retStatus); 5346 } else { 5347 RLOGE("radio::getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5348 } 5349 5350 return 0; 5351} 5352 5353int radio::requestIccSimAuthenticationResponse(android::Parcel &p, int slotId, int requestNumber, 5354 int responseType, int serial, RIL_Errno e, 5355 void *response, size_t responseLen) { 5356 RLOGD("radio::requestIccSimAuthenticationResponse: serial %d", serial); 5357 5358 if (radioService[slotId]->mRadioResponse != NULL) { 5359 RadioResponseInfo responseInfo = {}; 5360 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response, 5361 responseLen); 5362 5363 Return<void> retStatus 5364 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse( 5365 responseInfo, result); 5366 radioService[slotId]->checkReturnStatus(retStatus); 5367 } else { 5368 RLOGE("radio::requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse " 5369 "== NULL", slotId); 5370 } 5371 5372 return 0; 5373} 5374 5375int radio::setDataProfileResponse(android::Parcel &p, int slotId, int requestNumber, 5376 int responseType, int serial, RIL_Errno e, 5377 void *response, size_t responseLen) { 5378 RLOGD("radio::setDataProfileResponse: serial %d", serial); 5379 5380 if (radioService[slotId]->mRadioResponse != NULL) { 5381 RadioResponseInfo responseInfo = {}; 5382 populateResponseInfo(responseInfo, serial, responseType, e); 5383 Return<void> retStatus 5384 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo); 5385 radioService[slotId]->checkReturnStatus(retStatus); 5386 } else { 5387 RLOGE("radio::setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5388 } 5389 5390 return 0; 5391} 5392 5393int radio::requestShutdownResponse(android::Parcel &p, int slotId, int requestNumber, 5394 int responseType, int serial, RIL_Errno e, 5395 void *response, size_t responseLen) { 5396 RLOGD("radio::requestShutdownResponse: serial %d", serial); 5397 5398 if (radioService[slotId]->mRadioResponse != NULL) { 5399 RadioResponseInfo responseInfo = {}; 5400 populateResponseInfo(responseInfo, serial, responseType, e); 5401 Return<void> retStatus 5402 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo); 5403 radioService[slotId]->checkReturnStatus(retStatus); 5404 } else { 5405 RLOGE("radio::requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5406 } 5407 5408 return 0; 5409} 5410 5411void responseRadioCapability(RadioResponseInfo& responseInfo, int serial, 5412 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) { 5413 populateResponseInfo(responseInfo, serial, responseType, e); 5414 5415 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) { 5416 RLOGE("responseRadioCapability: Invalid response"); 5417 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 5418 rc.logicalModemUuid = hidl_string(); 5419 } else { 5420 convertRilRadioCapabilityToHal(response, responseLen, rc); 5421 } 5422} 5423 5424int radio::getRadioCapabilityResponse(android::Parcel &p, int slotId, int requestNumber, 5425 int responseType, int serial, RIL_Errno e, 5426 void *response, size_t responseLen) { 5427 RLOGD("radio::getRadioCapabilityResponse: serial %d", serial); 5428 5429 if (radioService[slotId]->mRadioResponse != NULL) { 5430 RadioResponseInfo responseInfo = {}; 5431 RadioCapability result = {}; 5432 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen, 5433 result); 5434 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse( 5435 responseInfo, result); 5436 radioService[slotId]->checkReturnStatus(retStatus); 5437 } else { 5438 RLOGE("radio::getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5439 } 5440 5441 return 0; 5442} 5443 5444int radio::setRadioCapabilityResponse(android::Parcel &p, int slotId, int requestNumber, 5445 int responseType, int serial, RIL_Errno e, 5446 void *response, size_t responseLen) { 5447 RLOGD("radio::setRadioCapabilityResponse: serial %d", serial); 5448 5449 if (radioService[slotId]->mRadioResponse != NULL) { 5450 RadioResponseInfo responseInfo = {}; 5451 RadioCapability result = {}; 5452 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen, 5453 result); 5454 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse( 5455 responseInfo, result); 5456 radioService[slotId]->checkReturnStatus(retStatus); 5457 } else { 5458 RLOGE("radio::setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5459 } 5460 5461 return 0; 5462} 5463 5464LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType, 5465 RIL_Errno e, void *response, size_t responseLen) { 5466 populateResponseInfo(responseInfo, serial, responseType, e); 5467 LceStatusInfo result = {}; 5468 5469 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) { 5470 RLOGE("Invalid response: NULL"); 5471 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 5472 } else { 5473 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response; 5474 result.lceStatus = (LceStatus) resp->lce_status; 5475 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms; 5476 } 5477 return result; 5478} 5479 5480int radio::startLceServiceResponse(android::Parcel &p, int slotId, int requestNumber, 5481 int responseType, int serial, RIL_Errno e, 5482 void *response, size_t responseLen) { 5483 RLOGD("radio::startLceServiceResponse: serial %d", serial); 5484 5485 if (radioService[slotId]->mRadioResponse != NULL) { 5486 RadioResponseInfo responseInfo = {}; 5487 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e, 5488 response, responseLen); 5489 5490 Return<void> retStatus 5491 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo, 5492 result); 5493 radioService[slotId]->checkReturnStatus(retStatus); 5494 } else { 5495 RLOGE("radio::startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5496 } 5497 5498 return 0; 5499} 5500 5501int radio::stopLceServiceResponse(android::Parcel &p, int slotId, int requestNumber, 5502 int responseType, int serial, RIL_Errno e, 5503 void *response, size_t responseLen) { 5504 RLOGD("radio::stopLceServiceResponse: serial %d", serial); 5505 5506 if (radioService[slotId]->mRadioResponse != NULL) { 5507 RadioResponseInfo responseInfo = {}; 5508 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e, 5509 response, responseLen); 5510 5511 Return<void> retStatus 5512 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo, 5513 result); 5514 radioService[slotId]->checkReturnStatus(retStatus); 5515 } else { 5516 RLOGE("radio::stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5517 } 5518 5519 return 0; 5520} 5521 5522int radio::pullLceDataResponse(android::Parcel &p, int slotId, int requestNumber, 5523 int responseType, int serial, RIL_Errno e, 5524 void *response, size_t responseLen) { 5525 RLOGD("radio::pullLceDataResponse: serial %d", serial); 5526 5527 if (radioService[slotId]->mRadioResponse != NULL) { 5528 RadioResponseInfo responseInfo = {}; 5529 populateResponseInfo(responseInfo, serial, responseType, e); 5530 5531 LceDataInfo result = {}; 5532 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) { 5533 RLOGE("radio::pullLceDataResponse: Invalid response"); 5534 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 5535 } else { 5536 convertRilLceDataInfoToHal(response, responseLen, result); 5537 } 5538 5539 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse( 5540 responseInfo, result); 5541 radioService[slotId]->checkReturnStatus(retStatus); 5542 } else { 5543 RLOGE("radio::pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5544 } 5545 5546 return 0; 5547} 5548 5549int radio::getModemActivityInfoResponse(android::Parcel &p, int slotId, int requestNumber, 5550 int responseType, int serial, RIL_Errno e, 5551 void *response, size_t responseLen) { 5552 RLOGD("radio::getModemActivityInfoResponse: serial %d", serial); 5553 5554 if (radioService[slotId]->mRadioResponse != NULL) { 5555 RadioResponseInfo responseInfo = {}; 5556 populateResponseInfo(responseInfo, serial, responseType, e); 5557 ActivityStatsInfo info; 5558 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) { 5559 RLOGE("radio::getModemActivityInfoResponse Invalid response: NULL"); 5560 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 5561 } else { 5562 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response; 5563 info.sleepModeTimeMs = resp->sleep_mode_time_ms; 5564 info.idleModeTimeMs = resp->idle_mode_time_ms; 5565 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) { 5566 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i]; 5567 } 5568 info.rxModeTimeMs = resp->rx_mode_time_ms; 5569 } 5570 5571 Return<void> retStatus 5572 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo, 5573 info); 5574 radioService[slotId]->checkReturnStatus(retStatus); 5575 } else { 5576 RLOGE("radio::getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL", 5577 slotId); 5578 } 5579 5580 return 0; 5581} 5582 5583int radio::setAllowedCarriersResponse(android::Parcel &p, int slotId, int requestNumber, 5584 int responseType, int serial, RIL_Errno e, 5585 void *response, size_t responseLen) { 5586 RLOGD("radio::setAllowedCarriersResponse: serial %d", serial); 5587 5588 if (radioService[slotId]->mRadioResponse != NULL) { 5589 RadioResponseInfo responseInfo = {}; 5590 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 5591 Return<void> retStatus 5592 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo, 5593 ret); 5594 radioService[slotId]->checkReturnStatus(retStatus); 5595 } else { 5596 RLOGE("radio::setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", 5597 slotId); 5598 } 5599 5600 return 0; 5601} 5602 5603int radio::getAllowedCarriersResponse(android::Parcel &p, int slotId, int requestNumber, 5604 int responseType, int serial, RIL_Errno e, 5605 void *response, size_t responseLen) { 5606 RLOGD("radio::getAllowedCarriersResponse: serial %d", serial); 5607 5608 if (radioService[slotId]->mRadioResponse != NULL) { 5609 RadioResponseInfo responseInfo = {}; 5610 populateResponseInfo(responseInfo, serial, responseType, e); 5611 CarrierRestrictions carrierInfo = {}; 5612 bool allAllowed = true; 5613 if (response == NULL || responseLen != sizeof(RIL_CarrierRestrictions)) { 5614 RLOGE("radio::getAllowedCarriersResponse Invalid response: NULL"); 5615 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 5616 } else { 5617 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response; 5618 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) { 5619 allAllowed = false; 5620 } 5621 5622 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers); 5623 for(int i = 0; i < pCr->len_allowed_carriers; i++) { 5624 RIL_Carrier *carrier = pCr->allowed_carriers + i; 5625 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc); 5626 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc); 5627 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type; 5628 carrierInfo.allowedCarriers[i].matchData = 5629 convertCharPtrToHidlString(carrier->match_data); 5630 } 5631 5632 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers); 5633 for(int i = 0; i < pCr->len_excluded_carriers; i++) { 5634 RIL_Carrier *carrier = pCr->excluded_carriers + i; 5635 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc); 5636 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc); 5637 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type; 5638 carrierInfo.excludedCarriers[i].matchData = 5639 convertCharPtrToHidlString(carrier->match_data); 5640 } 5641 } 5642 5643 Return<void> retStatus 5644 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo, 5645 allAllowed, carrierInfo); 5646 radioService[slotId]->checkReturnStatus(retStatus); 5647 } else { 5648 RLOGE("radio::getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", 5649 slotId); 5650 } 5651 5652 return 0; 5653} 5654 5655int radio::setSimCardPowerResponse(android::Parcel &p, int slotId, int requestNumber, 5656 int responseType, int serial, RIL_Errno e, 5657 void *response, size_t responseLen) { 5658 RLOGD("radio::setSimCardPowerResponse: serial %d", serial); 5659 5660 if (radioService[slotId]->mRadioResponse != NULL) { 5661 RadioResponseInfo responseInfo = {}; 5662 populateResponseInfo(responseInfo, serial, responseType, e); 5663 Return<void> retStatus 5664 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo); 5665 radioService[slotId]->checkReturnStatus(retStatus); 5666 } else { 5667 RLOGE("radio::setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId); 5668 } 5669 5670 return 0; 5671} 5672 5673int radio::sendRequestRawResponse(android::Parcel &p, int slotId, int requestNumber, 5674 int responseType, int serial, RIL_Errno e, 5675 void *response, size_t responseLen) { 5676 RLOGD("radio::sendRequestRawResponse: serial %d", serial); 5677 5678 if (oemHookService[slotId]->mOemHookResponse != NULL) { 5679 RadioResponseInfo responseInfo = {}; 5680 populateResponseInfo(responseInfo, serial, responseType, e); 5681 hidl_vec<uint8_t> data; 5682 5683 if (response == NULL) { 5684 RLOGE("radio::sendRequestRawResponse: Invalid response"); 5685 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 5686 } else { 5687 data.setToExternal((uint8_t *) response, responseLen); 5688 } 5689 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse-> 5690 sendRequestRawResponse(responseInfo, data); 5691 checkReturnStatus(slotId, retStatus); 5692 } else { 5693 RLOGE("radio::sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL", 5694 slotId); 5695 } 5696 5697 return 0; 5698} 5699 5700int radio::sendRequestStringsResponse(android::Parcel &p, int slotId, int requestNumber, 5701 int responseType, int serial, RIL_Errno e, 5702 void *response, size_t responseLen) { 5703 RLOGD("radio::sendRequestStringsResponse: serial %d", serial); 5704 5705 if (oemHookService[slotId]->mOemHookResponse != NULL) { 5706 RadioResponseInfo responseInfo = {}; 5707 populateResponseInfo(responseInfo, serial, responseType, e); 5708 hidl_vec<hidl_string> data; 5709 5710 if (response == NULL || responseLen % sizeof(char *) != 0) { 5711 RLOGE("radio::sendRequestStringsResponse Invalid response: NULL"); 5712 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 5713 } else { 5714 char **resp = (char **) response; 5715 int numStrings = responseLen / sizeof(char *); 5716 data.resize(numStrings); 5717 for (int i = 0; i < numStrings; i++) { 5718 data[i] = convertCharPtrToHidlString(resp[i]); 5719 } 5720 } 5721 Return<void> retStatus 5722 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse( 5723 responseInfo, data); 5724 checkReturnStatus(slotId, retStatus); 5725 } else { 5726 RLOGE("radio::sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == " 5727 "NULL", slotId); 5728 } 5729 5730 return 0; 5731} 5732 5733// Radio Indication functions 5734 5735RadioIndicationType convertIntToRadioIndicationType(int indicationType) { 5736 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) : 5737 (RadioIndicationType::UNSOLICITED_ACK_EXP); 5738} 5739 5740void radio::radioStateChangedInd(int slotId, int indicationType, RIL_RadioState radioState) { 5741 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5742 RLOGD("radio::radioStateChangedInd: radioState %d", radioState); 5743 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged( 5744 convertIntToRadioIndicationType(indicationType), (RadioState) radioState); 5745 radioService[slotId]->checkReturnStatus(retStatus); 5746 } else { 5747 RLOGE("radio::radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId); 5748 } 5749} 5750 5751int radio::callStateChangedInd(android::Parcel &p, int slotId, int requestNumber, 5752 int indicationType, int token, RIL_Errno e, void *response, 5753 size_t responseLen) { 5754 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5755 RLOGD("radio::callStateChangedInd"); 5756 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged( 5757 convertIntToRadioIndicationType(indicationType)); 5758 radioService[slotId]->checkReturnStatus(retStatus); 5759 } else { 5760 RLOGE("radio::callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId); 5761 } 5762 5763 return 0; 5764} 5765 5766int radio::networkStateChangedInd(android::Parcel &p, int slotId, int requestNumber, 5767 int indicationType, int token, RIL_Errno e, void *response, 5768 size_t responseLen) { 5769 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5770 RLOGD("radio::networkStateChangedInd"); 5771 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged( 5772 convertIntToRadioIndicationType(indicationType)); 5773 radioService[slotId]->checkReturnStatus(retStatus); 5774 } else { 5775 RLOGE("radio::networkStateChangedInd: radioService[%d]->mRadioIndication == NULL", 5776 slotId); 5777 } 5778 5779 return 0; 5780} 5781 5782uint8_t hexCharToInt(uint8_t c) { 5783 if (c >= '0' && c <= '9') return (c - '0'); 5784 if (c >= 'A' && c <= 'F') return (c - 'A' + 10); 5785 if (c >= 'a' && c <= 'f') return (c - 'a' + 10); 5786 5787 return INVALID_HEX_CHAR; 5788} 5789 5790uint8_t * convertHexStringToBytes(void *response, size_t responseLen) { 5791 if (responseLen % 2 != 0) { 5792 return NULL; 5793 } 5794 5795 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t)); 5796 if (bytes == NULL) { 5797 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string"); 5798 return NULL; 5799 } 5800 uint8_t *hexString = (uint8_t *)response; 5801 5802 for (size_t i = 0; i < responseLen; i += 2) { 5803 uint8_t hexChar1 = hexCharToInt(hexString[i]); 5804 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]); 5805 5806 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) { 5807 RLOGE("convertHexStringToBytes: invalid hex char %d %d", 5808 hexString[i], hexString[i + 1]); 5809 free(bytes); 5810 return NULL; 5811 } 5812 bytes[i/2] = ((hexChar1 << 4) | hexChar2); 5813 } 5814 5815 return bytes; 5816} 5817 5818int radio::newSmsInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 5819 int token, RIL_Errno e, void *response, size_t responseLen) { 5820 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5821 if (response == NULL || responseLen == 0) { 5822 RLOGE("radio::newSmsInd: invalid response"); 5823 return 0; 5824 } 5825 5826 uint8_t *bytes = convertHexStringToBytes(response, responseLen); 5827 if (bytes == NULL) { 5828 RLOGE("radio::newSmsInd: convertHexStringToBytes failed"); 5829 return 0; 5830 } 5831 5832 hidl_vec<uint8_t> pdu; 5833 pdu.setToExternal(bytes, responseLen/2); 5834 RLOGD("radio::newSmsInd"); 5835 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms( 5836 convertIntToRadioIndicationType(indicationType), pdu); 5837 radioService[slotId]->checkReturnStatus(retStatus); 5838 free(bytes); 5839 } else { 5840 RLOGE("radio::newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId); 5841 } 5842 5843 return 0; 5844} 5845 5846int radio::newSmsStatusReportInd(android::Parcel &p, int slotId, int requestNumber, 5847 int indicationType, int token, RIL_Errno e, void *response, 5848 size_t responseLen) { 5849 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5850 if (response == NULL || responseLen == 0) { 5851 RLOGE("radio::newSmsStatusReportInd: invalid response"); 5852 return 0; 5853 } 5854 5855 uint8_t *bytes = convertHexStringToBytes(response, responseLen); 5856 if (bytes == NULL) { 5857 RLOGE("radio::newSmsStatusReportInd: convertHexStringToBytes failed"); 5858 return 0; 5859 } 5860 5861 hidl_vec<uint8_t> pdu; 5862 pdu.setToExternal(bytes, responseLen/2); 5863 RLOGD("radio::newSmsStatusReportInd"); 5864 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport( 5865 convertIntToRadioIndicationType(indicationType), pdu); 5866 radioService[slotId]->checkReturnStatus(retStatus); 5867 free(bytes); 5868 } else { 5869 RLOGE("radio::newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId); 5870 } 5871 5872 return 0; 5873} 5874 5875int radio::newSmsOnSimInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 5876 int token, RIL_Errno e, void *response, size_t responseLen) { 5877 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5878 if (response == NULL || responseLen != sizeof(int)) { 5879 RLOGE("radio::newSmsOnSimInd: invalid response"); 5880 return 0; 5881 } 5882 int32_t recordNumber = ((int32_t *) response)[0]; 5883 RLOGD("radio::newSmsOnSimInd: slotIndex %d", recordNumber); 5884 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim( 5885 convertIntToRadioIndicationType(indicationType), recordNumber); 5886 radioService[slotId]->checkReturnStatus(retStatus); 5887 } else { 5888 RLOGE("radio::newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId); 5889 } 5890 5891 return 0; 5892} 5893 5894int radio::onUssdInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 5895 int token, RIL_Errno e, void *response, size_t responseLen) { 5896 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5897 if (response == NULL || responseLen != 2 * sizeof(char *)) { 5898 RLOGE("radio::onUssdInd: invalid response"); 5899 return 0; 5900 } 5901 char **strings = (char **) response; 5902 char *mode = strings[0]; 5903 hidl_string msg = convertCharPtrToHidlString(strings[1]); 5904 UssdModeType modeType = (UssdModeType) atoi(mode); 5905 RLOGD("radio::onUssdInd: mode %s", mode); 5906 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd( 5907 convertIntToRadioIndicationType(indicationType), modeType, msg); 5908 radioService[slotId]->checkReturnStatus(retStatus); 5909 } else { 5910 RLOGE("radio::onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId); 5911 } 5912 5913 return 0; 5914} 5915 5916int radio::nitzTimeReceivedInd(android::Parcel &p, int slotId, int requestNumber, 5917 int indicationType, int token, RIL_Errno e, void *response, 5918 size_t responseLen) { 5919 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5920 if (response == NULL || responseLen == 0) { 5921 RLOGE("radio::nitzTimeReceivedInd: invalid response"); 5922 return 0; 5923 } 5924 hidl_string nitzTime = convertCharPtrToHidlString((char *) response); 5925 int64_t timeReceived = android::elapsedRealtime(); 5926 RLOGD("radio::nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(), 5927 timeReceived); 5928 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived( 5929 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived); 5930 radioService[slotId]->checkReturnStatus(retStatus); 5931 } else { 5932 RLOGE("radio::nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId); 5933 return -1; 5934 } 5935 5936 return 0; 5937} 5938 5939void convertRilSignalStrengthToHal(void *response, size_t responseLen, 5940 SignalStrength& signalStrength) { 5941 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response; 5942 5943 // Fixup LTE for backwards compatibility 5944 // signalStrength: -1 -> 99 5945 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) { 5946 rilSignalStrength->LTE_SignalStrength.signalStrength = 99; 5947 } 5948 // rsrp: -1 -> INT_MAX all other negative value to positive. 5949 // So remap here 5950 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) { 5951 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX; 5952 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) { 5953 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp; 5954 } 5955 // rsrq: -1 -> INT_MAX 5956 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) { 5957 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX; 5958 } 5959 // Not remapping rssnr is already using INT_MAX 5960 // cqi: -1 -> INT_MAX 5961 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) { 5962 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX; 5963 } 5964 5965 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength; 5966 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate; 5967 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm; 5968 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio; 5969 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm; 5970 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio; 5971 signalStrength.evdo.signalNoiseRatio = 5972 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio; 5973 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength; 5974 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp; 5975 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq; 5976 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr; 5977 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi; 5978 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance; 5979 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp; 5980} 5981 5982int radio::currentSignalStrengthInd(android::Parcel &p, int slotId, int requestNumber, 5983 int indicationType, int token, RIL_Errno e, 5984 void *response, size_t responseLen) { 5985 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 5986 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) { 5987 RLOGE("radio::currentSignalStrengthInd: invalid response"); 5988 return 0; 5989 } 5990 5991 SignalStrength signalStrength = {}; 5992 convertRilSignalStrengthToHal(response, responseLen, signalStrength); 5993 5994 RLOGD("radio::currentSignalStrengthInd"); 5995 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength( 5996 convertIntToRadioIndicationType(indicationType), signalStrength); 5997 radioService[slotId]->checkReturnStatus(retStatus); 5998 } else { 5999 RLOGE("radio::currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL", 6000 slotId); 6001 } 6002 6003 return 0; 6004} 6005 6006void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse, 6007 SetupDataCallResult& dcResult) { 6008 dcResult.status = (DataCallFailCause) dcResponse->status; 6009 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime; 6010 dcResult.cid = dcResponse->cid; 6011 dcResult.active = dcResponse->active; 6012 dcResult.type = convertCharPtrToHidlString(dcResponse->type); 6013 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname); 6014 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses); 6015 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses); 6016 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways); 6017 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf); 6018 dcResult.mtu = dcResponse->mtu; 6019} 6020 6021void convertRilDataCallListToHal(void *response, size_t responseLen, 6022 hidl_vec<SetupDataCallResult>& dcResultList) { 6023 int num = responseLen / sizeof(RIL_Data_Call_Response_v11); 6024 6025 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response; 6026 dcResultList.resize(num); 6027 for (int i = 0; i < num; i++) { 6028 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]); 6029 } 6030} 6031 6032int radio::dataCallListChangedInd(android::Parcel &p, int slotId, int requestNumber, 6033 int indicationType, int token, RIL_Errno e, void *response, 6034 size_t responseLen) { 6035 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6036 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) { 6037 RLOGE("radio::dataCallListChangedInd: invalid response"); 6038 return 0; 6039 } 6040 hidl_vec<SetupDataCallResult> dcList; 6041 convertRilDataCallListToHal(response, responseLen, dcList); 6042 RLOGD("radio::dataCallListChangedInd"); 6043 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged( 6044 convertIntToRadioIndicationType(indicationType), dcList); 6045 radioService[slotId]->checkReturnStatus(retStatus); 6046 } else { 6047 RLOGE("radio::dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId); 6048 } 6049 6050 return 0; 6051} 6052 6053int radio::suppSvcNotifyInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 6054 int token, RIL_Errno e, void *response, size_t responseLen) { 6055 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6056 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) { 6057 RLOGE("radio::suppSvcNotifyInd: invalid response"); 6058 return 0; 6059 } 6060 6061 SuppSvcNotification suppSvc = {}; 6062 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response; 6063 suppSvc.isMT = ssn->notificationType; 6064 suppSvc.code = ssn->code; 6065 suppSvc.index = ssn->index; 6066 suppSvc.type = ssn->type; 6067 suppSvc.number = convertCharPtrToHidlString(ssn->number); 6068 6069 RLOGD("radio::suppSvcNotifyInd: isMT %d code %d index %d type %d", 6070 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type); 6071 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify( 6072 convertIntToRadioIndicationType(indicationType), suppSvc); 6073 radioService[slotId]->checkReturnStatus(retStatus); 6074 } else { 6075 RLOGE("radio::suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId); 6076 } 6077 6078 return 0; 6079} 6080 6081int radio::stkSessionEndInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 6082 int token, RIL_Errno e, void *response, size_t responseLen) { 6083 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6084 RLOGD("radio::stkSessionEndInd"); 6085 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd( 6086 convertIntToRadioIndicationType(indicationType)); 6087 radioService[slotId]->checkReturnStatus(retStatus); 6088 } else { 6089 RLOGE("radio::stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId); 6090 } 6091 6092 return 0; 6093} 6094 6095int radio::stkProactiveCommandInd(android::Parcel &p, int slotId, int requestNumber, 6096 int indicationType, int token, RIL_Errno e, void *response, 6097 size_t responseLen) { 6098 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6099 if (response == NULL || responseLen == 0) { 6100 RLOGE("radio::stkProactiveCommandInd: invalid response"); 6101 return 0; 6102 } 6103 RLOGD("radio::stkProactiveCommandInd"); 6104 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand( 6105 convertIntToRadioIndicationType(indicationType), 6106 convertCharPtrToHidlString((char *) response)); 6107 radioService[slotId]->checkReturnStatus(retStatus); 6108 } else { 6109 RLOGE("radio::stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId); 6110 } 6111 6112 return 0; 6113} 6114 6115int radio::stkEventNotifyInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 6116 int token, RIL_Errno e, void *response, size_t responseLen) { 6117 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6118 if (response == NULL || responseLen == 0) { 6119 RLOGE("radio::stkEventNotifyInd: invalid response"); 6120 return 0; 6121 } 6122 RLOGD("radio::stkEventNotifyInd"); 6123 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify( 6124 convertIntToRadioIndicationType(indicationType), 6125 convertCharPtrToHidlString((char *) response)); 6126 radioService[slotId]->checkReturnStatus(retStatus); 6127 } else { 6128 RLOGE("radio::stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId); 6129 } 6130 6131 return 0; 6132} 6133 6134int radio::stkCallSetupInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 6135 int token, RIL_Errno e, void *response, size_t responseLen) { 6136 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6137 if (response == NULL || responseLen != sizeof(int)) { 6138 RLOGE("radio::stkCallSetupInd: invalid response"); 6139 return 0; 6140 } 6141 int32_t timeout = ((int32_t *) response)[0]; 6142 RLOGD("radio::stkCallSetupInd: timeout %d", timeout); 6143 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup( 6144 convertIntToRadioIndicationType(indicationType), timeout); 6145 radioService[slotId]->checkReturnStatus(retStatus); 6146 } else { 6147 RLOGE("radio::stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId); 6148 } 6149 6150 return 0; 6151} 6152 6153int radio::simSmsStorageFullInd(android::Parcel &p, int slotId, int requestNumber, 6154 int indicationType, int token, RIL_Errno e, void *response, 6155 size_t responseLen) { 6156 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6157 RLOGD("radio::simSmsStorageFullInd"); 6158 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull( 6159 convertIntToRadioIndicationType(indicationType)); 6160 radioService[slotId]->checkReturnStatus(retStatus); 6161 } else { 6162 RLOGE("radio::simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId); 6163 } 6164 6165 return 0; 6166} 6167 6168int radio::simRefreshInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 6169 int token, RIL_Errno e, void *response, size_t responseLen) { 6170 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6171 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) { 6172 RLOGE("radio::simRefreshInd: invalid response"); 6173 return 0; 6174 } 6175 6176 SimRefreshResult refreshResult = {}; 6177 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response); 6178 refreshResult.type = 6179 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result; 6180 refreshResult.efId = simRefreshResponse->ef_id; 6181 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid); 6182 6183 RLOGD("radio::simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId); 6184 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh( 6185 convertIntToRadioIndicationType(indicationType), refreshResult); 6186 radioService[slotId]->checkReturnStatus(retStatus); 6187 } else { 6188 RLOGE("radio::simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId); 6189 } 6190 6191 return 0; 6192} 6193 6194void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord, 6195 CdmaSignalInfoRecord& record) { 6196 record.isPresent = signalInfoRecord->isPresent; 6197 record.signalType = signalInfoRecord->signalType; 6198 record.alertPitch = signalInfoRecord->alertPitch; 6199 record.signal = signalInfoRecord->signal; 6200} 6201 6202int radio::callRingInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 6203 int token, RIL_Errno e, void *response, size_t responseLen) { 6204 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6205 bool isGsm; 6206 CdmaSignalInfoRecord record = {}; 6207 if (response == NULL || responseLen == 0) { 6208 isGsm = true; 6209 } else { 6210 isGsm = false; 6211 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) { 6212 RLOGE("radio::callRingInd: invalid response"); 6213 return 0; 6214 } 6215 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record); 6216 } 6217 6218 RLOGD("radio::callRingInd: isGsm %d", isGsm); 6219 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing( 6220 convertIntToRadioIndicationType(indicationType), isGsm, record); 6221 radioService[slotId]->checkReturnStatus(retStatus); 6222 } else { 6223 RLOGE("radio::callRingInd: radioService[%d]->mRadioIndication == NULL", slotId); 6224 } 6225 6226 return 0; 6227} 6228 6229int radio::simStatusChangedInd(android::Parcel &p, int slotId, int requestNumber, 6230 int indicationType, int token, RIL_Errno e, void *response, 6231 size_t responseLen) { 6232 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6233 RLOGD("radio::simStatusChangedInd"); 6234 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged( 6235 convertIntToRadioIndicationType(indicationType)); 6236 radioService[slotId]->checkReturnStatus(retStatus); 6237 } else { 6238 RLOGE("radio::simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId); 6239 } 6240 6241 return 0; 6242} 6243 6244int radio::cdmaNewSmsInd(android::Parcel &p, int slotId, int requestNumber, int indicationType, 6245 int token, RIL_Errno e, void *response, size_t responseLen) { 6246 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6247 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) { 6248 RLOGE("radio::cdmaNewSmsInd: invalid response"); 6249 return 0; 6250 } 6251 6252 CdmaSmsMessage msg = {}; 6253 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response; 6254 msg.teleserviceId = rilMsg->uTeleserviceID; 6255 msg.isServicePresent = rilMsg->bIsServicePresent; 6256 msg.serviceCategory = rilMsg->uServicecategory; 6257 msg.address.digitMode = 6258 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode; 6259 msg.address.numberMode = 6260 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode; 6261 msg.address.numberType = 6262 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type; 6263 msg.address.numberPlan = 6264 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan; 6265 6266 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); 6267 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit); 6268 6269 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType) 6270 rilMsg->sSubAddress.subaddressType; 6271 msg.subAddress.odd = rilMsg->sSubAddress.odd; 6272 6273 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); 6274 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit); 6275 6276 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); 6277 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit); 6278 6279 RLOGD("radio::cdmaNewSmsInd"); 6280 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms( 6281 convertIntToRadioIndicationType(indicationType), msg); 6282 radioService[slotId]->checkReturnStatus(retStatus); 6283 } else { 6284 RLOGE("radio::cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId); 6285 } 6286 6287 return 0; 6288} 6289 6290int radio::newBroadcastSmsInd(android::Parcel &p, int slotId, int requestNumber, 6291 int indicationType, int token, RIL_Errno e, void *response, 6292 size_t responseLen) { 6293 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6294 if (response == NULL || responseLen == 0) { 6295 RLOGE("radio::newBroadcastSmsInd: invalid response"); 6296 return 0; 6297 } 6298 6299 hidl_vec<uint8_t> data; 6300 data.setToExternal((uint8_t *) response, responseLen); 6301 RLOGD("radio::newBroadcastSmsInd"); 6302 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms( 6303 convertIntToRadioIndicationType(indicationType), data); 6304 radioService[slotId]->checkReturnStatus(retStatus); 6305 } else { 6306 RLOGE("radio::newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId); 6307 } 6308 6309 return 0; 6310} 6311 6312int radio::cdmaRuimSmsStorageFullInd(android::Parcel &p, int slotId, int requestNumber, 6313 int indicationType, int token, RIL_Errno e, void *response, 6314 size_t responseLen) { 6315 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6316 RLOGD("radio::cdmaRuimSmsStorageFullInd"); 6317 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull( 6318 convertIntToRadioIndicationType(indicationType)); 6319 radioService[slotId]->checkReturnStatus(retStatus); 6320 } else { 6321 RLOGE("radio::cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", 6322 slotId); 6323 } 6324 6325 return 0; 6326} 6327 6328int radio::restrictedStateChangedInd(android::Parcel &p, int slotId, int requestNumber, 6329 int indicationType, int token, RIL_Errno e, void *response, 6330 size_t responseLen) { 6331 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6332 if (response == NULL || responseLen != sizeof(int)) { 6333 RLOGE("radio::restrictedStateChangedInd: invalid response"); 6334 return 0; 6335 } 6336 int32_t state = ((int32_t *) response)[0]; 6337 RLOGD("radio::restrictedStateChangedInd: state %d", state); 6338 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged( 6339 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state); 6340 radioService[slotId]->checkReturnStatus(retStatus); 6341 } else { 6342 RLOGE("radio::restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL", 6343 slotId); 6344 } 6345 6346 return 0; 6347} 6348 6349int radio::enterEmergencyCallbackModeInd(android::Parcel &p, int slotId, int requestNumber, 6350 int indicationType, int token, RIL_Errno e, void *response, 6351 size_t responseLen) { 6352 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6353 RLOGD("radio::enterEmergencyCallbackModeInd"); 6354 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode( 6355 convertIntToRadioIndicationType(indicationType)); 6356 radioService[slotId]->checkReturnStatus(retStatus); 6357 } else { 6358 RLOGE("radio::enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL", 6359 slotId); 6360 } 6361 6362 return 0; 6363} 6364 6365int radio::cdmaCallWaitingInd(android::Parcel &p, int slotId, int requestNumber, 6366 int indicationType, int token, RIL_Errno e, void *response, 6367 size_t responseLen) { 6368 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6369 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) { 6370 RLOGE("radio::cdmaCallWaitingInd: invalid response"); 6371 return 0; 6372 } 6373 6374 CdmaCallWaiting callWaitingRecord = {}; 6375 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response); 6376 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number); 6377 callWaitingRecord.numberPresentation = 6378 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation; 6379 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name); 6380 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord, 6381 callWaitingRecord.signalInfoRecord); 6382 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type; 6383 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan; 6384 6385 RLOGD("radio::cdmaCallWaitingInd"); 6386 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting( 6387 convertIntToRadioIndicationType(indicationType), callWaitingRecord); 6388 radioService[slotId]->checkReturnStatus(retStatus); 6389 } else { 6390 RLOGE("radio::cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId); 6391 } 6392 6393 return 0; 6394} 6395 6396int radio::cdmaOtaProvisionStatusInd(android::Parcel &p, int slotId, int requestNumber, 6397 int indicationType, int token, RIL_Errno e, void *response, 6398 size_t responseLen) { 6399 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6400 if (response == NULL || responseLen != sizeof(int)) { 6401 RLOGE("radio::cdmaOtaProvisionStatusInd: invalid response"); 6402 return 0; 6403 } 6404 int32_t status = ((int32_t *) response)[0]; 6405 RLOGD("radio::cdmaOtaProvisionStatusInd: status %d", status); 6406 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus( 6407 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status); 6408 radioService[slotId]->checkReturnStatus(retStatus); 6409 } else { 6410 RLOGE("radio::cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL", 6411 slotId); 6412 } 6413 6414 return 0; 6415} 6416 6417int radio::cdmaInfoRecInd(android::Parcel &p, int slotId, int requestNumber, 6418 int indicationType, int token, RIL_Errno e, void *response, 6419 size_t responseLen) { 6420 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6421 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) { 6422 RLOGE("radio::cdmaInfoRecInd: invalid response"); 6423 return 0; 6424 } 6425 6426 CdmaInformationRecords records = {}; 6427 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response; 6428 6429 char* string8 = NULL; 6430 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS); 6431 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) { 6432 RLOGE("radio::cdmaInfoRecInd: received %d recs which is more than %d, dropping " 6433 "additional ones", recordsRil->numberOfInfoRecs, 6434 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS); 6435 } 6436 records.infoRec.resize(num); 6437 for (int i = 0 ; i < num ; i++) { 6438 CdmaInformationRecord *record = &records.infoRec[i]; 6439 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i]; 6440 record->name = (CdmaInfoRecName) infoRec->name; 6441 // All vectors should be size 0 except one which will be size 1. Set everything to 6442 // size 0 initially. 6443 record->display.resize(0); 6444 record->number.resize(0); 6445 record->signal.resize(0); 6446 record->redir.resize(0); 6447 record->lineCtrl.resize(0); 6448 record->clir.resize(0); 6449 record->audioCtrl.resize(0); 6450 switch (infoRec->name) { 6451 case RIL_CDMA_DISPLAY_INFO_REC: 6452 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: { 6453 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) { 6454 RLOGE("radio::cdmaInfoRecInd: invalid display info response length %d " 6455 "expected not more than %d", (int) infoRec->rec.display.alpha_len, 6456 CDMA_ALPHA_INFO_BUFFER_LENGTH); 6457 return 0; 6458 } 6459 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char)); 6460 if (string8 == NULL) { 6461 RLOGE("radio::cdmaInfoRecInd: Memory allocation failed for " 6462 "responseCdmaInformationRecords"); 6463 return 0; 6464 } 6465 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len); 6466 string8[(int)infoRec->rec.display.alpha_len] = '\0'; 6467 6468 record->display.resize(1); 6469 record->display[0].alphaBuf = string8; 6470 free(string8); 6471 string8 = NULL; 6472 break; 6473 } 6474 6475 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC: 6476 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC: 6477 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: { 6478 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) { 6479 RLOGE("radio::cdmaInfoRecInd: invalid display info response length %d " 6480 "expected not more than %d", (int) infoRec->rec.number.len, 6481 CDMA_NUMBER_INFO_BUFFER_LENGTH); 6482 return 0; 6483 } 6484 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char)); 6485 if (string8 == NULL) { 6486 RLOGE("radio::cdmaInfoRecInd: Memory allocation failed for " 6487 "responseCdmaInformationRecords"); 6488 return 0; 6489 } 6490 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len); 6491 string8[(int)infoRec->rec.number.len] = '\0'; 6492 6493 record->number.resize(1); 6494 record->number[0].number = string8; 6495 free(string8); 6496 string8 = NULL; 6497 record->number[0].numberType = infoRec->rec.number.number_type; 6498 record->number[0].numberPlan = infoRec->rec.number.number_plan; 6499 record->number[0].pi = infoRec->rec.number.pi; 6500 record->number[0].si = infoRec->rec.number.si; 6501 break; 6502 } 6503 6504 case RIL_CDMA_SIGNAL_INFO_REC: { 6505 record->signal.resize(1); 6506 record->signal[0].isPresent = infoRec->rec.signal.isPresent; 6507 record->signal[0].signalType = infoRec->rec.signal.signalType; 6508 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch; 6509 record->signal[0].signal = infoRec->rec.signal.signal; 6510 break; 6511 } 6512 6513 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: { 6514 if (infoRec->rec.redir.redirectingNumber.len > 6515 CDMA_NUMBER_INFO_BUFFER_LENGTH) { 6516 RLOGE("radio::cdmaInfoRecInd: invalid display info response length %d " 6517 "expected not more than %d\n", 6518 (int)infoRec->rec.redir.redirectingNumber.len, 6519 CDMA_NUMBER_INFO_BUFFER_LENGTH); 6520 return 0; 6521 } 6522 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) * 6523 sizeof(char)); 6524 if (string8 == NULL) { 6525 RLOGE("radio::cdmaInfoRecInd: Memory allocation failed for " 6526 "responseCdmaInformationRecords"); 6527 return 0; 6528 } 6529 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf, 6530 infoRec->rec.redir.redirectingNumber.len); 6531 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0'; 6532 6533 record->redir.resize(1); 6534 record->redir[0].redirectingNumber.number = string8; 6535 free(string8); 6536 string8 = NULL; 6537 record->redir[0].redirectingNumber.numberType = 6538 infoRec->rec.redir.redirectingNumber.number_type; 6539 record->redir[0].redirectingNumber.numberPlan = 6540 infoRec->rec.redir.redirectingNumber.number_plan; 6541 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi; 6542 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si; 6543 record->redir[0].redirectingReason = 6544 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason; 6545 break; 6546 } 6547 6548 case RIL_CDMA_LINE_CONTROL_INFO_REC: { 6549 record->lineCtrl.resize(1); 6550 record->lineCtrl[0].lineCtrlPolarityIncluded = 6551 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded; 6552 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle; 6553 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse; 6554 record->lineCtrl[0].lineCtrlPowerDenial = 6555 infoRec->rec.lineCtrl.lineCtrlPowerDenial; 6556 break; 6557 } 6558 6559 case RIL_CDMA_T53_CLIR_INFO_REC: { 6560 record->clir.resize(1); 6561 record->clir[0].cause = infoRec->rec.clir.cause; 6562 break; 6563 } 6564 6565 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: { 6566 record->audioCtrl.resize(1); 6567 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink; 6568 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink; 6569 break; 6570 } 6571 6572 case RIL_CDMA_T53_RELEASE_INFO_REC: 6573 RLOGE("radio::cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID"); 6574 return 0; 6575 6576 default: 6577 RLOGE("radio::cdmaInfoRecInd: Incorrect name value"); 6578 return 0; 6579 } 6580 } 6581 6582 RLOGD("radio::cdmaInfoRecInd"); 6583 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec( 6584 convertIntToRadioIndicationType(indicationType), records); 6585 radioService[slotId]->checkReturnStatus(retStatus); 6586 } else { 6587 RLOGE("radio::cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId); 6588 } 6589 6590 return 0; 6591} 6592 6593int radio::indicateRingbackToneInd(android::Parcel &p, int slotId, int requestNumber, 6594 int indicationType, int token, RIL_Errno e, void *response, 6595 size_t responseLen) { 6596 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6597 if (response == NULL || responseLen != sizeof(int)) { 6598 RLOGE("radio::indicateRingbackToneInd: invalid response"); 6599 return 0; 6600 } 6601 bool start = ((int32_t *) response)[0]; 6602 RLOGD("radio::indicateRingbackToneInd: start %d", start); 6603 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone( 6604 convertIntToRadioIndicationType(indicationType), start); 6605 radioService[slotId]->checkReturnStatus(retStatus); 6606 } else { 6607 RLOGE("radio::indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId); 6608 } 6609 6610 return 0; 6611} 6612 6613int radio::resendIncallMuteInd(android::Parcel &p, int slotId, int requestNumber, 6614 int indicationType, int token, RIL_Errno e, void *response, 6615 size_t responseLen) { 6616 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6617 RLOGD("radio::resendIncallMuteInd"); 6618 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute( 6619 convertIntToRadioIndicationType(indicationType)); 6620 radioService[slotId]->checkReturnStatus(retStatus); 6621 } else { 6622 RLOGE("radio::resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId); 6623 } 6624 6625 return 0; 6626} 6627 6628int radio::cdmaSubscriptionSourceChangedInd(android::Parcel &p, int slotId, int requestNumber, 6629 int indicationType, int token, RIL_Errno e, 6630 void *response, size_t responseLen) { 6631 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6632 if (response == NULL || responseLen != sizeof(int)) { 6633 RLOGE("radio::cdmaSubscriptionSourceChangedInd: invalid response"); 6634 return 0; 6635 } 6636 int32_t cdmaSource = ((int32_t *) response)[0]; 6637 RLOGD("radio::cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource); 6638 Return<void> retStatus = radioService[slotId]->mRadioIndication-> 6639 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType), 6640 (CdmaSubscriptionSource) cdmaSource); 6641 radioService[slotId]->checkReturnStatus(retStatus); 6642 } else { 6643 RLOGE("radio::cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL", 6644 slotId); 6645 } 6646 6647 return 0; 6648} 6649 6650int radio::cdmaPrlChangedInd(android::Parcel &p, int slotId, int requestNumber, 6651 int indicationType, int token, RIL_Errno e, void *response, 6652 size_t responseLen) { 6653 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6654 if (response == NULL || responseLen != sizeof(int)) { 6655 RLOGE("radio::cdmaPrlChangedInd: invalid response"); 6656 return 0; 6657 } 6658 int32_t version = ((int32_t *) response)[0]; 6659 RLOGD("radio::cdmaPrlChangedInd: version %d", version); 6660 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged( 6661 convertIntToRadioIndicationType(indicationType), version); 6662 radioService[slotId]->checkReturnStatus(retStatus); 6663 } else { 6664 RLOGE("radio::cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId); 6665 } 6666 6667 return 0; 6668} 6669 6670int radio::exitEmergencyCallbackModeInd(android::Parcel &p, int slotId, int requestNumber, 6671 int indicationType, int token, RIL_Errno e, void *response, 6672 size_t responseLen) { 6673 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6674 RLOGD("radio::exitEmergencyCallbackModeInd"); 6675 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode( 6676 convertIntToRadioIndicationType(indicationType)); 6677 radioService[slotId]->checkReturnStatus(retStatus); 6678 } else { 6679 RLOGE("radio::exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL", 6680 slotId); 6681 } 6682 6683 return 0; 6684} 6685 6686int radio::rilConnectedInd(android::Parcel &p, int slotId, int requestNumber, 6687 int indicationType, int token, RIL_Errno e, void *response, 6688 size_t responseLen) { 6689 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6690 RLOGD("radio::rilConnectedInd"); 6691 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected( 6692 convertIntToRadioIndicationType(indicationType)); 6693 radioService[slotId]->checkReturnStatus(retStatus); 6694 } else { 6695 RLOGE("radio::rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId); 6696 } 6697 6698 return 0; 6699} 6700 6701int radio::voiceRadioTechChangedInd(android::Parcel &p, int slotId, int requestNumber, 6702 int indicationType, int token, RIL_Errno e, void *response, 6703 size_t responseLen) { 6704 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6705 if (response == NULL || responseLen != sizeof(int)) { 6706 RLOGE("radio::voiceRadioTechChangedInd: invalid response"); 6707 return 0; 6708 } 6709 int32_t rat = ((int32_t *) response)[0]; 6710 RLOGD("radio::voiceRadioTechChangedInd: rat %d", rat); 6711 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged( 6712 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat); 6713 radioService[slotId]->checkReturnStatus(retStatus); 6714 } else { 6715 RLOGE("radio::voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL", 6716 slotId); 6717 } 6718 6719 return 0; 6720} 6721 6722void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) { 6723 int num = responseLen / sizeof(RIL_CellInfo_v12); 6724 records.resize(num); 6725 6726 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response; 6727 for (int i = 0; i < num; i++) { 6728 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType; 6729 records[i].registered = rillCellInfo->registered; 6730 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType; 6731 records[i].timeStamp = rillCellInfo->timeStamp; 6732 // All vectors should be size 0 except one which will be size 1. Set everything to 6733 // size 0 initially. 6734 records[i].gsm.resize(0); 6735 records[i].wcdma.resize(0); 6736 records[i].cdma.resize(0); 6737 records[i].lte.resize(0); 6738 records[i].tdscdma.resize(0); 6739 switch(rillCellInfo->cellInfoType) { 6740 case RIL_CELL_INFO_TYPE_GSM: { 6741 records[i].gsm.resize(1); 6742 CellInfoGsm *cellInfoGsm = &records[i].gsm[0]; 6743 cellInfoGsm->cellIdentityGsm.mcc = 6744 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc); 6745 cellInfoGsm->cellIdentityGsm.mnc = 6746 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc); 6747 cellInfoGsm->cellIdentityGsm.lac = 6748 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac; 6749 cellInfoGsm->cellIdentityGsm.cid = 6750 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid; 6751 cellInfoGsm->cellIdentityGsm.arfcn = 6752 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn; 6753 cellInfoGsm->cellIdentityGsm.bsic = 6754 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic; 6755 cellInfoGsm->signalStrengthGsm.signalStrength = 6756 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength; 6757 cellInfoGsm->signalStrengthGsm.bitErrorRate = 6758 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate; 6759 cellInfoGsm->signalStrengthGsm.timingAdvance = 6760 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance; 6761 break; 6762 } 6763 6764 case RIL_CELL_INFO_TYPE_WCDMA: { 6765 records[i].wcdma.resize(1); 6766 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0]; 6767 cellInfoWcdma->cellIdentityWcdma.mcc = 6768 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc); 6769 cellInfoWcdma->cellIdentityWcdma.mnc = 6770 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc); 6771 cellInfoWcdma->cellIdentityWcdma.lac = 6772 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac; 6773 cellInfoWcdma->cellIdentityWcdma.cid = 6774 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid; 6775 cellInfoWcdma->cellIdentityWcdma.psc = 6776 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc; 6777 cellInfoWcdma->cellIdentityWcdma.uarfcn = 6778 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn; 6779 cellInfoWcdma->signalStrengthWcdma.signalStrength = 6780 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength; 6781 cellInfoWcdma->signalStrengthWcdma.bitErrorRate = 6782 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate; 6783 break; 6784 } 6785 6786 case RIL_CELL_INFO_TYPE_CDMA: { 6787 records[i].cdma.resize(1); 6788 CellInfoCdma *cellInfoCdma = &records[i].cdma[0]; 6789 cellInfoCdma->cellIdentityCdma.networkId = 6790 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId; 6791 cellInfoCdma->cellIdentityCdma.systemId = 6792 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId; 6793 cellInfoCdma->cellIdentityCdma.baseStationId = 6794 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId; 6795 cellInfoCdma->cellIdentityCdma.longitude = 6796 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude; 6797 cellInfoCdma->cellIdentityCdma.latitude = 6798 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude; 6799 cellInfoCdma->signalStrengthCdma.dbm = 6800 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm; 6801 cellInfoCdma->signalStrengthCdma.ecio = 6802 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio; 6803 cellInfoCdma->signalStrengthEvdo.dbm = 6804 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm; 6805 cellInfoCdma->signalStrengthEvdo.ecio = 6806 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio; 6807 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio = 6808 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio; 6809 break; 6810 } 6811 6812 case RIL_CELL_INFO_TYPE_LTE: { 6813 records[i].lte.resize(1); 6814 CellInfoLte *cellInfoLte = &records[i].lte[0]; 6815 cellInfoLte->cellIdentityLte.mcc = 6816 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc); 6817 cellInfoLte->cellIdentityLte.mnc = 6818 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc); 6819 cellInfoLte->cellIdentityLte.ci = 6820 rillCellInfo->CellInfo.lte.cellIdentityLte.ci; 6821 cellInfoLte->cellIdentityLte.pci = 6822 rillCellInfo->CellInfo.lte.cellIdentityLte.pci; 6823 cellInfoLte->cellIdentityLte.tac = 6824 rillCellInfo->CellInfo.lte.cellIdentityLte.tac; 6825 cellInfoLte->cellIdentityLte.earfcn = 6826 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn; 6827 cellInfoLte->signalStrengthLte.signalStrength = 6828 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength; 6829 cellInfoLte->signalStrengthLte.rsrp = 6830 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp; 6831 cellInfoLte->signalStrengthLte.rsrq = 6832 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq; 6833 cellInfoLte->signalStrengthLte.rssnr = 6834 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr; 6835 cellInfoLte->signalStrengthLte.cqi = 6836 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi; 6837 cellInfoLte->signalStrengthLte.timingAdvance = 6838 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance; 6839 break; 6840 } 6841 6842 case RIL_CELL_INFO_TYPE_TD_SCDMA: { 6843 records[i].tdscdma.resize(1); 6844 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0]; 6845 cellInfoTdscdma->cellIdentityTdscdma.mcc = 6846 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc); 6847 cellInfoTdscdma->cellIdentityTdscdma.mnc = 6848 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc); 6849 cellInfoTdscdma->cellIdentityTdscdma.lac = 6850 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac; 6851 cellInfoTdscdma->cellIdentityTdscdma.cid = 6852 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid; 6853 cellInfoTdscdma->cellIdentityTdscdma.cpid = 6854 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid; 6855 cellInfoTdscdma->signalStrengthTdscdma.rscp = 6856 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp; 6857 break; 6858 } 6859 default: { 6860 break; 6861 } 6862 } 6863 rillCellInfo += 1; 6864 } 6865} 6866 6867int radio::cellInfoListInd(android::Parcel &p, int slotId, int requestNumber, 6868 int indicationType, int token, RIL_Errno e, void *response, 6869 size_t responseLen) { 6870 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6871 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) { 6872 RLOGE("radio::cellInfoListInd: invalid response"); 6873 return 0; 6874 } 6875 6876 hidl_vec<CellInfo> records; 6877 convertRilCellInfoListToHal(response, responseLen, records); 6878 6879 RLOGD("radio::cellInfoListInd"); 6880 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList( 6881 convertIntToRadioIndicationType(indicationType), records); 6882 radioService[slotId]->checkReturnStatus(retStatus); 6883 } else { 6884 RLOGE("radio::cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId); 6885 } 6886 6887 return 0; 6888} 6889 6890int radio::imsNetworkStateChangedInd(android::Parcel &p, int slotId, int requestNumber, 6891 int indicationType, int token, RIL_Errno e, void *response, 6892 size_t responseLen) { 6893 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6894 RLOGD("radio::imsNetworkStateChangedInd"); 6895 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged( 6896 convertIntToRadioIndicationType(indicationType)); 6897 radioService[slotId]->checkReturnStatus(retStatus); 6898 } else { 6899 RLOGE("radio::imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL", 6900 slotId); 6901 } 6902 6903 return 0; 6904} 6905 6906int radio::subscriptionStatusChangedInd(android::Parcel &p, int slotId, int requestNumber, 6907 int indicationType, int token, RIL_Errno e, void *response, 6908 size_t responseLen) { 6909 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6910 if (response == NULL || responseLen != sizeof(int)) { 6911 RLOGE("radio::subscriptionStatusChangedInd: invalid response"); 6912 return 0; 6913 } 6914 bool activate = ((int32_t *) response)[0]; 6915 RLOGD("radio::subscriptionStatusChangedInd: activate %d", activate); 6916 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged( 6917 convertIntToRadioIndicationType(indicationType), activate); 6918 radioService[slotId]->checkReturnStatus(retStatus); 6919 } else { 6920 RLOGE("radio::subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL", 6921 slotId); 6922 } 6923 6924 return 0; 6925} 6926 6927int radio::srvccStateNotifyInd(android::Parcel &p, int slotId, int requestNumber, 6928 int indicationType, int token, RIL_Errno e, void *response, 6929 size_t responseLen) { 6930 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6931 if (response == NULL || responseLen != sizeof(int)) { 6932 RLOGE("radio::srvccStateNotifyInd: invalid response"); 6933 return 0; 6934 } 6935 int32_t state = ((int32_t *) response)[0]; 6936 RLOGD("radio::srvccStateNotifyInd: rat %d", state); 6937 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify( 6938 convertIntToRadioIndicationType(indicationType), (SrvccState) state); 6939 radioService[slotId]->checkReturnStatus(retStatus); 6940 } else { 6941 RLOGE("radio::srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId); 6942 } 6943 6944 return 0; 6945} 6946 6947void convertRilHardwareConfigListToHal(void *response, size_t responseLen, 6948 hidl_vec<HardwareConfig>& records) { 6949 int num = responseLen / sizeof(RIL_HardwareConfig); 6950 records.resize(num); 6951 6952 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response; 6953 for (int i = 0; i < num; i++) { 6954 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type; 6955 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid); 6956 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state; 6957 switch (rilHardwareConfig[i].type) { 6958 case RIL_HARDWARE_CONFIG_MODEM: { 6959 records[i].modem.resize(1); 6960 records[i].sim.resize(0); 6961 HardwareConfigModem *hwConfigModem = &records[i].modem[0]; 6962 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat; 6963 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice; 6964 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData; 6965 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby; 6966 break; 6967 } 6968 6969 case RIL_HARDWARE_CONFIG_SIM: { 6970 records[i].sim.resize(1); 6971 records[i].modem.resize(0); 6972 records[i].sim[0].modemUuid = 6973 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid); 6974 break; 6975 } 6976 } 6977 } 6978} 6979 6980int radio::hardwareConfigChangedInd(android::Parcel &p, int slotId, int requestNumber, 6981 int indicationType, int token, RIL_Errno e, void *response, 6982 size_t responseLen) { 6983 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 6984 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) { 6985 RLOGE("radio::hardwareConfigChangedInd: invalid response"); 6986 return 0; 6987 } 6988 6989 hidl_vec<HardwareConfig> configs; 6990 convertRilHardwareConfigListToHal(response, responseLen, configs); 6991 6992 RLOGD("radio::hardwareConfigChangedInd"); 6993 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged( 6994 convertIntToRadioIndicationType(indicationType), configs); 6995 radioService[slotId]->checkReturnStatus(retStatus); 6996 } else { 6997 RLOGE("radio::hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL", 6998 slotId); 6999 } 7000 7001 return 0; 7002} 7003 7004void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) { 7005 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response; 7006 rc.session = rilRadioCapability->session; 7007 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase; 7008 rc.raf = rilRadioCapability->rat; 7009 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid); 7010 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status; 7011} 7012 7013int radio::radioCapabilityIndicationInd(android::Parcel &p, int slotId, int requestNumber, 7014 int indicationType, int token, RIL_Errno e, void *response, 7015 size_t responseLen) { 7016 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 7017 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) { 7018 RLOGE("radio::radioCapabilityIndicationInd: invalid response"); 7019 return 0; 7020 } 7021 7022 RadioCapability rc = {}; 7023 convertRilRadioCapabilityToHal(response, responseLen, rc); 7024 7025 RLOGD("radio::radioCapabilityIndicationInd"); 7026 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication( 7027 convertIntToRadioIndicationType(indicationType), rc); 7028 radioService[slotId]->checkReturnStatus(retStatus); 7029 } else { 7030 RLOGE("radio::radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL", 7031 slotId); 7032 } 7033 7034 return 0; 7035} 7036 7037bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) { 7038 if ((reqType == SS_INTERROGATION) && 7039 (serType == SS_CFU || 7040 serType == SS_CF_BUSY || 7041 serType == SS_CF_NO_REPLY || 7042 serType == SS_CF_NOT_REACHABLE || 7043 serType == SS_CF_ALL || 7044 serType == SS_CF_ALL_CONDITIONAL)) { 7045 return true; 7046 } 7047 return false; 7048} 7049 7050int radio::onSupplementaryServiceIndicationInd(android::Parcel &p, int slotId, int requestNumber, 7051 int indicationType, int token, RIL_Errno e, 7052 void *response, size_t responseLen) { 7053 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 7054 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) { 7055 RLOGE("radio::onSupplementaryServiceIndicationInd: invalid response"); 7056 return 0; 7057 } 7058 7059 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response; 7060 StkCcUnsolSsResult ss = {}; 7061 ss.serviceType = (SsServiceType) rilSsResponse->serviceType; 7062 ss.requestType = (SsRequestType) rilSsResponse->requestType; 7063 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType; 7064 ss.serviceClass = rilSsResponse->serviceClass; 7065 ss.result = (RadioError) rilSsResponse->result; 7066 7067 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) { 7068 RLOGD("radio::onSupplementaryServiceIndicationInd CF type, num of Cf elements %d", 7069 rilSsResponse->cfData.numValidIndexes); 7070 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) { 7071 RLOGE("radio::onSupplementaryServiceIndicationInd numValidIndexes is greater than " 7072 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES); 7073 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES; 7074 } 7075 7076 ss.cfData.resize(1); 7077 ss.ssInfo.resize(0); 7078 7079 /* number of call info's */ 7080 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes); 7081 7082 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) { 7083 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i]; 7084 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i]; 7085 7086 cfInfo->status = (CallForwardInfoStatus) cf.status; 7087 cfInfo->reason = cf.reason; 7088 cfInfo->serviceClass = cf.serviceClass; 7089 cfInfo->toa = cf.toa; 7090 cfInfo->number = convertCharPtrToHidlString(cf.number); 7091 cfInfo->timeSeconds = cf.timeSeconds; 7092 RLOGD("radio::onSupplementaryServiceIndicationInd: " 7093 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status, 7094 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds); 7095 } 7096 } else { 7097 ss.ssInfo.resize(1); 7098 ss.cfData.resize(0); 7099 7100 /* each int */ 7101 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX); 7102 for (int i = 0; i < SS_INFO_MAX; i++) { 7103 RLOGD("radio::onSupplementaryServiceIndicationInd: Data: %d", 7104 rilSsResponse->ssInfo[i]); 7105 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i]; 7106 } 7107 } 7108 7109 RLOGD("radio::onSupplementaryServiceIndicationInd"); 7110 Return<void> retStatus = radioService[slotId]->mRadioIndication-> 7111 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType), 7112 ss); 7113 radioService[slotId]->checkReturnStatus(retStatus); 7114 } else { 7115 RLOGE("radio::onSupplementaryServiceIndicationInd: " 7116 "radioService[%d]->mRadioIndication == NULL", slotId); 7117 } 7118 7119 return 0; 7120} 7121 7122int radio::stkCallControlAlphaNotifyInd(android::Parcel &p, int slotId, int requestNumber, 7123 int indicationType, int token, RIL_Errno e, void *response, 7124 size_t responseLen) { 7125 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 7126 if (response == NULL || responseLen == 0) { 7127 RLOGE("radio::stkCallControlAlphaNotifyInd: invalid response"); 7128 return 0; 7129 } 7130 RLOGD("radio::stkCallControlAlphaNotifyInd"); 7131 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify( 7132 convertIntToRadioIndicationType(indicationType), 7133 convertCharPtrToHidlString((char *) response)); 7134 radioService[slotId]->checkReturnStatus(retStatus); 7135 } else { 7136 RLOGE("radio::stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL", 7137 slotId); 7138 } 7139 7140 return 0; 7141} 7142 7143void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) { 7144 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response; 7145 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps; 7146 lce.confidenceLevel = rilLceDataInfo->confidence_level; 7147 lce.lceSuspended = rilLceDataInfo->lce_suspended; 7148} 7149 7150int radio::lceDataInd(android::Parcel &p, int slotId, int requestNumber, 7151 int indicationType, int token, RIL_Errno e, void *response, 7152 size_t responseLen) { 7153 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 7154 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) { 7155 RLOGE("radio::lceDataInd: invalid response"); 7156 return 0; 7157 } 7158 7159 LceDataInfo lce = {}; 7160 convertRilLceDataInfoToHal(response, responseLen, lce); 7161 RLOGD("radio::lceDataInd"); 7162 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData( 7163 convertIntToRadioIndicationType(indicationType), lce); 7164 radioService[slotId]->checkReturnStatus(retStatus); 7165 } else { 7166 RLOGE("radio::lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId); 7167 } 7168 7169 return 0; 7170} 7171 7172int radio::pcoDataInd(android::Parcel &p, int slotId, int requestNumber, 7173 int indicationType, int token, RIL_Errno e, void *response, 7174 size_t responseLen) { 7175 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) { 7176 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) { 7177 RLOGE("radio::pcoDataInd: invalid response"); 7178 return 0; 7179 } 7180 7181 PcoDataInfo pco = {}; 7182 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response; 7183 pco.cid = rilPcoData->cid; 7184 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto); 7185 pco.pcoId = rilPcoData->pco_id; 7186 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length); 7187 7188 RLOGD("radio::pcoDataInd"); 7189 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData( 7190 convertIntToRadioIndicationType(indicationType), pco); 7191 radioService[slotId]->checkReturnStatus(retStatus); 7192 } else { 7193 RLOGE("radio::pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId); 7194 } 7195 7196 return 0; 7197} 7198 7199int radio::modemResetInd(android::Parcel &p, int slotId, int requestNumber, 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 == 0) { 7204 RLOGE("radio::modemResetInd: invalid response"); 7205 return 0; 7206 } 7207 RLOGD("radio::modemResetInd"); 7208 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset( 7209 convertIntToRadioIndicationType(indicationType), 7210 convertCharPtrToHidlString((char *) response)); 7211 radioService[slotId]->checkReturnStatus(retStatus); 7212 } else { 7213 RLOGE("radio::modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId); 7214 } 7215 7216 return 0; 7217} 7218 7219int radio::oemHookRawInd(android::Parcel &p, int slotId, int requestNumber, 7220 int indicationType, int token, RIL_Errno e, void *response, 7221 size_t responseLen) { 7222 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) { 7223 if (response == NULL || responseLen == 0) { 7224 RLOGE("radio::oemHookRawInd: invalid response"); 7225 return 0; 7226 } 7227 7228 hidl_vec<uint8_t> data; 7229 data.setToExternal((uint8_t *) response, responseLen); 7230 RLOGD("radio::oemHookRawInd"); 7231 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw( 7232 convertIntToRadioIndicationType(indicationType), data); 7233 checkReturnStatus(slotId, retStatus); 7234 } else { 7235 RLOGE("radio::oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId); 7236 } 7237 7238 return 0; 7239} 7240 7241void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) { 7242 using namespace android::hardware; 7243 int simCount = 1; 7244 const char *serviceNames[] = { 7245 android::RIL_getRilSocketName() 7246 #if (SIM_COUNT >= 2) 7247 , SOCKET2_NAME_RIL 7248 #if (SIM_COUNT >= 3) 7249 , SOCKET3_NAME_RIL 7250 #if (SIM_COUNT >= 4) 7251 , SOCKET4_NAME_RIL 7252 #endif 7253 #endif 7254 #endif 7255 }; 7256 7257 const char *oemHookServiceNames[] = { 7258 OEM_HOOK_SERVICE_NAME 7259 #if (SIM_COUNT >= 2) 7260 , OEM_HOOK2_SERVICE_NAME 7261 #if (SIM_COUNT >= 3) 7262 , OEM_HOOK3_SERVICE_NAME 7263 #if (SIM_COUNT >= 4) 7264 , OEM_HOOK4_SERVICE_NAME 7265 #endif 7266 #endif 7267 #endif 7268 }; 7269 7270 #if (SIM_COUNT >= 2) 7271 simCount = SIM_COUNT; 7272 #endif 7273 7274 configureRpcThreadpool(1, true /* callerWillJoin */); 7275 for (int i = 0; i < simCount; i++) { 7276 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i); 7277 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr); 7278 assert(ret == 0); 7279 7280 radioService[i] = new RadioImpl; 7281 radioService[i]->mSlotId = i; 7282 oemHookService[i] = new OemHookImpl; 7283 oemHookService[i]->mSlotId = i; 7284 RLOGD("radio::registerService: starting IRadio %s", serviceNames[i]); 7285 android::status_t status = radioService[i]->registerAsService(serviceNames[i]); 7286 status = oemHookService[i]->registerAsService(oemHookServiceNames[i]); 7287 7288 ret = pthread_rwlock_unlock(radioServiceRwlockPtr); 7289 assert(ret == 0); 7290 } 7291 7292 s_vendorFunctions = callbacks; 7293 s_commands = commands; 7294} 7295 7296void rilc_thread_pool() { 7297 joinRpcThreadpool(); 7298} 7299 7300pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) { 7301 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock; 7302 7303 #if (SIM_COUNT >= 2) 7304 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2; 7305 #if (SIM_COUNT >= 3) 7306 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3; 7307 #if (SIM_COUNT >= 4) 7308 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4; 7309 #endif 7310 #endif 7311 #endif 7312 7313 return radioServiceRwlockPtr; 7314} 7315