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