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