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