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