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