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