ril_service.cpp revision 83e7acd605373167f08578175b9cfa7e0c3d2d42
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 s_vendorFunctions->onRequest( 1407 RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI); 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 int len; 1507 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) { 1508 return Void(); 1509 } 1510 1511 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) { 1512 memsetAndFreeStrings(1, args.pdu); 1513 return Void(); 1514 } 1515 1516 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId); 1517 1518 memsetAndFreeStrings(2, args.smsc, args.pdu); 1519 1520 return Void(); 1521} 1522 1523Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) { 1524#if VDBG 1525 RLOGD("deleteSmsOnSim: serial %d", serial); 1526#endif 1527 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index); 1528 return Void(); 1529} 1530 1531Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) { 1532#if VDBG 1533 RLOGD("setBandMode: serial %d", serial); 1534#endif 1535 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode); 1536 return Void(); 1537} 1538 1539Return<void> RadioImpl::getAvailableBandModes(int32_t serial) { 1540#if VDBG 1541 RLOGD("getAvailableBandModes: serial %d", serial); 1542#endif 1543 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE); 1544 return Void(); 1545} 1546 1547Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) { 1548#if VDBG 1549 RLOGD("sendEnvelope: serial %d", serial); 1550#endif 1551 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND, 1552 command.c_str()); 1553 return Void(); 1554} 1555 1556Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial, 1557 const hidl_string& commandResponse) { 1558#if VDBG 1559 RLOGD("sendTerminalResponseToSim: serial %d", serial); 1560#endif 1561 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE, 1562 commandResponse.c_str()); 1563 return Void(); 1564} 1565 1566Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) { 1567#if VDBG 1568 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial); 1569#endif 1570 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM, 1571 1, BOOL_TO_INT(accept)); 1572 return Void(); 1573} 1574 1575Return<void> RadioImpl::explicitCallTransfer(int32_t serial) { 1576#if VDBG 1577 RLOGD("explicitCallTransfer: serial %d", serial); 1578#endif 1579 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER); 1580 return Void(); 1581} 1582 1583Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) { 1584#if VDBG 1585 RLOGD("setPreferredNetworkType: serial %d", serial); 1586#endif 1587 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType); 1588 return Void(); 1589} 1590 1591Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) { 1592#if VDBG 1593 RLOGD("getPreferredNetworkType: serial %d", serial); 1594#endif 1595 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE); 1596 return Void(); 1597} 1598 1599Return<void> RadioImpl::getNeighboringCids(int32_t serial) { 1600#if VDBG 1601 RLOGD("getNeighboringCids: serial %d", serial); 1602#endif 1603 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS); 1604 return Void(); 1605} 1606 1607Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) { 1608#if VDBG 1609 RLOGD("setLocationUpdates: serial %d", serial); 1610#endif 1611 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable)); 1612 return Void(); 1613} 1614 1615Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) { 1616#if VDBG 1617 RLOGD("setCdmaSubscriptionSource: serial %d", serial); 1618#endif 1619 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub); 1620 return Void(); 1621} 1622 1623Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) { 1624#if VDBG 1625 RLOGD("setCdmaRoamingPreference: serial %d", serial); 1626#endif 1627 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type); 1628 return Void(); 1629} 1630 1631Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) { 1632#if VDBG 1633 RLOGD("getCdmaRoamingPreference: serial %d", serial); 1634#endif 1635 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE); 1636 return Void(); 1637} 1638 1639Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) { 1640#if VDBG 1641 RLOGD("setTTYMode: serial %d", serial); 1642#endif 1643 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode); 1644 return Void(); 1645} 1646 1647Return<void> RadioImpl::getTTYMode(int32_t serial) { 1648#if VDBG 1649 RLOGD("getTTYMode: serial %d", serial); 1650#endif 1651 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE); 1652 return Void(); 1653} 1654 1655Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) { 1656#if VDBG 1657 RLOGD("setPreferredVoicePrivacy: serial %d", serial); 1658#endif 1659 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE, 1660 1, BOOL_TO_INT(enable)); 1661 return Void(); 1662} 1663 1664Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) { 1665#if VDBG 1666 RLOGD("getPreferredVoicePrivacy: serial %d", serial); 1667#endif 1668 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE); 1669 return Void(); 1670} 1671 1672Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) { 1673#if VDBG 1674 RLOGD("sendCDMAFeatureCode: serial %d", serial); 1675#endif 1676 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH, 1677 featureCode.c_str()); 1678 return Void(); 1679} 1680 1681Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on, 1682 int32_t off) { 1683#if VDBG 1684 RLOGD("sendBurstDtmf: serial %d", serial); 1685#endif 1686 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF, 1687 3, dtmf.c_str(), (std::to_string(on)).c_str(), 1688 (std::to_string(off)).c_str()); 1689 return Void(); 1690} 1691 1692void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) { 1693 rcsm.uTeleserviceID = sms.teleserviceId; 1694 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent); 1695 rcsm.uServicecategory = sms.serviceCategory; 1696 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode; 1697 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode; 1698 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType; 1699 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan; 1700 1701 rcsm.sAddress.number_of_digits = sms.address.digits.size(); 1702 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX); 1703 for (int i = 0; i < digitLimit; i++) { 1704 rcsm.sAddress.digits[i] = sms.address.digits[i]; 1705 } 1706 1707 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType; 1708 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd); 1709 1710 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size(); 1711 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX); 1712 for (int i = 0; i < digitLimit; i++) { 1713 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i]; 1714 } 1715 1716 rcsm.uBearerDataLen = sms.bearerData.size(); 1717 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX); 1718 for (int i = 0; i < digitLimit; i++) { 1719 rcsm.aBearerData[i] = sms.bearerData[i]; 1720 } 1721} 1722 1723Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) { 1724#if VDBG 1725 RLOGD("sendCdmaSms: serial %d", serial); 1726#endif 1727 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS); 1728 if (pRI == NULL) { 1729 return Void(); 1730 } 1731 1732 RIL_CDMA_SMS_Message rcsm = {}; 1733 constructCdmaSms(rcsm, sms); 1734 1735 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId); 1736 return Void(); 1737} 1738 1739Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) { 1740#if VDBG 1741 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial); 1742#endif 1743 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE); 1744 if (pRI == NULL) { 1745 return Void(); 1746 } 1747 1748 RIL_CDMA_SMS_Ack rcsa = {}; 1749 1750 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass; 1751 rcsa.uSMSCauseCode = smsAck.smsCauseCode; 1752 1753 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId); 1754 return Void(); 1755} 1756 1757Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) { 1758#if VDBG 1759 RLOGD("getGsmBroadcastConfig: serial %d", serial); 1760#endif 1761 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG); 1762 return Void(); 1763} 1764 1765Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial, 1766 const hidl_vec<GsmBroadcastSmsConfigInfo>& 1767 configInfo) { 1768#if VDBG 1769 RLOGD("setGsmBroadcastConfig: serial %d", serial); 1770#endif 1771 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1772 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG); 1773 if (pRI == NULL) { 1774 return Void(); 1775 } 1776 1777 int num = configInfo.size(); 1778 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num]; 1779 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num]; 1780 1781 for (int i = 0 ; i < num ; i++ ) { 1782 gsmBciPtrs[i] = &gsmBci[i]; 1783 gsmBci[i].fromServiceId = configInfo[i].fromServiceId; 1784 gsmBci[i].toServiceId = configInfo[i].toServiceId; 1785 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme; 1786 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme; 1787 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected); 1788 } 1789 1790 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs, 1791 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId); 1792 return Void(); 1793} 1794 1795Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) { 1796#if VDBG 1797 RLOGD("setGsmBroadcastActivation: serial %d", serial); 1798#endif 1799 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION, 1800 1, BOOL_TO_INT(!activate)); 1801 return Void(); 1802} 1803 1804Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) { 1805#if VDBG 1806 RLOGD("getCdmaBroadcastConfig: serial %d", serial); 1807#endif 1808 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG); 1809 return Void(); 1810} 1811 1812Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial, 1813 const hidl_vec<CdmaBroadcastSmsConfigInfo>& 1814 configInfo) { 1815#if VDBG 1816 RLOGD("setCdmaBroadcastConfig: serial %d", serial); 1817#endif 1818 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1819 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG); 1820 if (pRI == NULL) { 1821 return Void(); 1822 } 1823 1824 int num = configInfo.size(); 1825 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num]; 1826 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num]; 1827 1828 for (int i = 0 ; i < num ; i++ ) { 1829 cdmaBciPtrs[i] = &cdmaBci[i]; 1830 cdmaBci[i].service_category = configInfo[i].serviceCategory; 1831 cdmaBci[i].language = configInfo[i].language; 1832 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected); 1833 } 1834 1835 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs, 1836 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId); 1837 return Void(); 1838} 1839 1840Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) { 1841#if VDBG 1842 RLOGD("setCdmaBroadcastActivation: serial %d", serial); 1843#endif 1844 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION, 1845 1, BOOL_TO_INT(!activate)); 1846 return Void(); 1847} 1848 1849Return<void> RadioImpl::getCDMASubscription(int32_t serial) { 1850#if VDBG 1851 RLOGD("getCDMASubscription: serial %d", serial); 1852#endif 1853 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION); 1854 return Void(); 1855} 1856 1857Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) { 1858#if VDBG 1859 RLOGD("writeSmsToRuim: serial %d", serial); 1860#endif 1861 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1862 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM); 1863 if (pRI == NULL) { 1864 return Void(); 1865 } 1866 1867 RIL_CDMA_SMS_WriteArgs rcsw = {}; 1868 rcsw.status = (int) cdmaSms.status; 1869 constructCdmaSms(rcsw.message, cdmaSms.message); 1870 1871 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId); 1872 return Void(); 1873} 1874 1875Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) { 1876#if VDBG 1877 RLOGD("deleteSmsOnRuim: serial %d", serial); 1878#endif 1879 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index); 1880 return Void(); 1881} 1882 1883Return<void> RadioImpl::getDeviceIdentity(int32_t serial) { 1884#if VDBG 1885 RLOGD("getDeviceIdentity: serial %d", serial); 1886#endif 1887 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY); 1888 return Void(); 1889} 1890 1891Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) { 1892#if VDBG 1893 RLOGD("exitEmergencyCallbackMode: serial %d", serial); 1894#endif 1895 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE); 1896 return Void(); 1897} 1898 1899Return<void> RadioImpl::getSmscAddress(int32_t serial) { 1900#if VDBG 1901 RLOGD("getSmscAddress: serial %d", serial); 1902#endif 1903 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS); 1904 return Void(); 1905} 1906 1907Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) { 1908#if VDBG 1909 RLOGD("setSmscAddress: serial %d", serial); 1910#endif 1911 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS, 1912 smsc.c_str()); 1913 return Void(); 1914} 1915 1916Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) { 1917#if VDBG 1918 RLOGD("reportSmsMemoryStatus: serial %d", serial); 1919#endif 1920 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1, 1921 BOOL_TO_INT(available)); 1922 return Void(); 1923} 1924 1925Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) { 1926#if VDBG 1927 RLOGD("reportStkServiceIsRunning: serial %d", serial); 1928#endif 1929 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING); 1930 return Void(); 1931} 1932 1933Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) { 1934#if VDBG 1935 RLOGD("getCdmaSubscriptionSource: serial %d", serial); 1936#endif 1937 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE); 1938 return Void(); 1939} 1940 1941Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) { 1942#if VDBG 1943 RLOGD("requestIsimAuthentication: serial %d", serial); 1944#endif 1945 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION, 1946 challenge.c_str()); 1947 return Void(); 1948} 1949 1950Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success, 1951 const hidl_string& ackPdu) { 1952#if VDBG 1953 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial); 1954#endif 1955 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, 1956 2, success ? "1" : "0", ackPdu.c_str()); 1957 return Void(); 1958} 1959 1960Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) { 1961#if VDBG 1962 RLOGD("sendEnvelopeWithStatus: serial %d", serial); 1963#endif 1964 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS, 1965 contents.c_str()); 1966 return Void(); 1967} 1968 1969Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) { 1970#if VDBG 1971 RLOGD("getVoiceRadioTechnology: serial %d", serial); 1972#endif 1973 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH); 1974 return Void(); 1975} 1976 1977Return<void> RadioImpl::getCellInfoList(int32_t serial) { 1978#if VDBG 1979 RLOGD("getCellInfoList: serial %d", serial); 1980#endif 1981 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST); 1982 return Void(); 1983} 1984 1985Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) { 1986#if VDBG 1987 RLOGD("setCellInfoListRate: serial %d", serial); 1988#endif 1989 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate); 1990 return Void(); 1991} 1992 1993Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo, 1994 bool modemCognitive, bool isRoaming) { 1995#if VDBG 1996 RLOGD("setInitialAttachApn: serial %d", serial); 1997#endif 1998 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 1999 RIL_REQUEST_SET_INITIAL_ATTACH_APN); 2000 if (pRI == NULL) { 2001 return Void(); 2002 } 2003 2004 if (s_vendorFunctions->version <= 14) { 2005 RIL_InitialAttachApn iaa = {}; 2006 2007 if (dataProfileInfo.apn.size() == 0) { 2008 iaa.apn = (char *) calloc(1, sizeof(char)); 2009 if (iaa.apn == NULL) { 2010 RLOGE("Memory allocation failed for request %s", 2011 requestToString(pRI->pCI->requestNumber)); 2012 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 2013 return Void(); 2014 } 2015 iaa.apn[0] = '\0'; 2016 } else { 2017 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) { 2018 return Void(); 2019 } 2020 } 2021 2022 const hidl_string &protocol = 2023 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol); 2024 2025 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) { 2026 memsetAndFreeStrings(1, iaa.apn); 2027 return Void(); 2028 } 2029 iaa.authtype = (int) dataProfileInfo.authType; 2030 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) { 2031 memsetAndFreeStrings(2, iaa.apn, iaa.protocol); 2032 return Void(); 2033 } 2034 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) { 2035 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username); 2036 return Void(); 2037 } 2038 2039 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId); 2040 2041 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password); 2042 } else { 2043 RIL_InitialAttachApn_v15 iaa = {}; 2044 2045 if (dataProfileInfo.apn.size() == 0) { 2046 iaa.apn = (char *) calloc(1, sizeof(char)); 2047 if (iaa.apn == NULL) { 2048 RLOGE("Memory allocation failed for request %s", 2049 requestToString(pRI->pCI->requestNumber)); 2050 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 2051 return Void(); 2052 } 2053 iaa.apn[0] = '\0'; 2054 } else { 2055 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) { 2056 return Void(); 2057 } 2058 } 2059 2060 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) { 2061 memsetAndFreeStrings(1, iaa.apn); 2062 return Void(); 2063 } 2064 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) { 2065 memsetAndFreeStrings(2, iaa.apn, iaa.protocol); 2066 return Void(); 2067 } 2068 iaa.authtype = (int) dataProfileInfo.authType; 2069 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) { 2070 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol); 2071 return Void(); 2072 } 2073 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) { 2074 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username); 2075 return Void(); 2076 } 2077 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap; 2078 iaa.bearerBitmask = dataProfileInfo.bearerBitmap; 2079 iaa.modemCognitive = BOOL_TO_INT(modemCognitive); 2080 iaa.mtu = dataProfileInfo.mtu; 2081 2082 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) { 2083 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS); 2084 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username, 2085 iaa.password); 2086 return Void(); 2087 } 2088 2089 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) { 2090 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username, 2091 iaa.password); 2092 return Void(); 2093 } 2094 2095 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId); 2096 2097 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username, 2098 iaa.password, iaa.mvnoMatchData); 2099 } 2100 2101 return Void(); 2102} 2103 2104Return<void> RadioImpl::getImsRegistrationState(int32_t serial) { 2105#if VDBG 2106 RLOGD("getImsRegistrationState: serial %d", serial); 2107#endif 2108 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE); 2109 return Void(); 2110} 2111 2112bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) { 2113 RIL_IMS_SMS_Message rism = {}; 2114 char **pStrings; 2115 int countStrings = 2; 2116 int dataLen = sizeof(char *) * countStrings; 2117 2118 rism.tech = RADIO_TECH_3GPP; 2119 rism.retry = BOOL_TO_INT(message.retry); 2120 rism.messageRef = message.messageRef; 2121 2122 if (message.gsmMessage.size() != 1) { 2123 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber)); 2124 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS); 2125 return false; 2126 } 2127 2128 pStrings = (char **)calloc(countStrings, sizeof(char *)); 2129 if (pStrings == NULL) { 2130 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s", 2131 requestToString(pRI->pCI->requestNumber)); 2132 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 2133 return false; 2134 } 2135 2136 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) { 2137#ifdef MEMSET_FREED 2138 memset(pStrings, 0, dataLen); 2139#endif 2140 free(pStrings); 2141 return false; 2142 } 2143 2144 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) { 2145 memsetAndFreeStrings(1, pStrings[0]); 2146#ifdef MEMSET_FREED 2147 memset(pStrings, 0, dataLen); 2148#endif 2149 free(pStrings); 2150 return false; 2151 } 2152 2153 rism.message.gsmMessage = pStrings; 2154 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + 2155 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id); 2156 2157 for (int i = 0 ; i < countStrings ; i++) { 2158 memsetAndFreeStrings(1, pStrings[i]); 2159 } 2160 2161#ifdef MEMSET_FREED 2162 memset(pStrings, 0, dataLen); 2163#endif 2164 free(pStrings); 2165 2166 return true; 2167} 2168 2169bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) { 2170 RIL_IMS_SMS_Message rism = {}; 2171 RIL_CDMA_SMS_Message rcsm = {}; 2172 2173 if (message.cdmaMessage.size() != 1) { 2174 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber)); 2175 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS); 2176 return false; 2177 } 2178 2179 rism.tech = RADIO_TECH_3GPP2; 2180 rism.retry = BOOL_TO_INT(message.retry); 2181 rism.messageRef = message.messageRef; 2182 rism.message.cdmaMessage = &rcsm; 2183 2184 constructCdmaSms(rcsm, message.cdmaMessage[0]); 2185 2186 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) + 2187 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI, pRI->socket_id); 2188 2189 return true; 2190} 2191 2192Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) { 2193#if VDBG 2194 RLOGD("sendImsSms: serial %d", serial); 2195#endif 2196 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS); 2197 if (pRI == NULL) { 2198 return Void(); 2199 } 2200 2201 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech; 2202 2203 if (RADIO_TECH_3GPP == format) { 2204 dispatchImsGsmSms(message, pRI); 2205 } else if (RADIO_TECH_3GPP2 == format) { 2206 dispatchImsCdmaSms(message, pRI); 2207 } else { 2208 RLOGE("sendImsSms: Invalid radio tech %s", 2209 requestToString(pRI->pCI->requestNumber)); 2210 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS); 2211 } 2212 return Void(); 2213} 2214 2215Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) { 2216#if VDBG 2217 RLOGD("iccTransmitApduBasicChannel: serial %d", serial); 2218#endif 2219 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message); 2220 return Void(); 2221} 2222 2223Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) { 2224#if VDBG 2225 RLOGD("iccOpenLogicalChannel: serial %d", serial); 2226#endif 2227 if (s_vendorFunctions->version < 15) { 2228 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str()); 2229 } else { 2230 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL); 2231 if (pRI == NULL) { 2232 return Void(); 2233 } 2234 2235 RIL_OpenChannelParams params = {}; 2236 2237 params.p2 = p2; 2238 2239 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) { 2240 return Void(); 2241 } 2242 2243 CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId); 2244 2245 memsetAndFreeStrings(1, params.aidPtr); 2246 } 2247 return Void(); 2248} 2249 2250Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) { 2251#if VDBG 2252 RLOGD("iccCloseLogicalChannel: serial %d", serial); 2253#endif 2254 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId); 2255 return Void(); 2256} 2257 2258Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) { 2259#if VDBG 2260 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial); 2261#endif 2262 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message); 2263 return Void(); 2264} 2265 2266Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) { 2267#if VDBG 2268 RLOGD("nvReadItem: serial %d", serial); 2269#endif 2270 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM); 2271 if (pRI == NULL) { 2272 return Void(); 2273 } 2274 2275 RIL_NV_ReadItem nvri = {}; 2276 nvri.itemID = (RIL_NV_Item) itemId; 2277 2278 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId); 2279 return Void(); 2280} 2281 2282Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) { 2283#if VDBG 2284 RLOGD("nvWriteItem: serial %d", serial); 2285#endif 2286 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM); 2287 if (pRI == NULL) { 2288 return Void(); 2289 } 2290 2291 RIL_NV_WriteItem nvwi = {}; 2292 2293 nvwi.itemID = (RIL_NV_Item) item.itemId; 2294 2295 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) { 2296 return Void(); 2297 } 2298 2299 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId); 2300 2301 memsetAndFreeStrings(1, nvwi.value); 2302 return Void(); 2303} 2304 2305Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) { 2306#if VDBG 2307 RLOGD("nvWriteCdmaPrl: serial %d", serial); 2308#endif 2309 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl); 2310 return Void(); 2311} 2312 2313Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) { 2314 int rilResetType = -1; 2315#if VDBG 2316 RLOGD("nvResetConfig: serial %d", serial); 2317#endif 2318 /* Convert ResetNvType to RIL.h values 2319 * RIL_REQUEST_NV_RESET_CONFIG 2320 * 1 - reload all NV items 2321 * 2 - erase NV reset (SCRTN) 2322 * 3 - factory reset (RTN) 2323 */ 2324 switch(resetType) { 2325 case ResetNvType::RELOAD: 2326 rilResetType = 1; 2327 break; 2328 case ResetNvType::ERASE: 2329 rilResetType = 2; 2330 break; 2331 case ResetNvType::FACTORY_RESET: 2332 rilResetType = 3; 2333 break; 2334 } 2335 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType); 2336 return Void(); 2337} 2338 2339Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) { 2340#if VDBG 2341 RLOGD("setUiccSubscription: serial %d", serial); 2342#endif 2343 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 2344 RIL_REQUEST_SET_UICC_SUBSCRIPTION); 2345 if (pRI == NULL) { 2346 return Void(); 2347 } 2348 2349 RIL_SelectUiccSub rilUiccSub = {}; 2350 2351 rilUiccSub.slot = uiccSub.slot; 2352 rilUiccSub.app_index = uiccSub.appIndex; 2353 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType; 2354 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus; 2355 2356 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId); 2357 return Void(); 2358} 2359 2360Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) { 2361#if VDBG 2362 RLOGD("setDataAllowed: serial %d", serial); 2363#endif 2364 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow)); 2365 return Void(); 2366} 2367 2368Return<void> RadioImpl::getHardwareConfig(int32_t serial) { 2369#if VDBG 2370 RLOGD("getHardwareConfig: serial %d", serial); 2371#endif 2372 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG); 2373 return Void(); 2374} 2375 2376Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext, 2377 const hidl_string& authData, const hidl_string& aid) { 2378#if VDBG 2379 RLOGD("requestIccSimAuthentication: serial %d", serial); 2380#endif 2381 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION); 2382 if (pRI == NULL) { 2383 return Void(); 2384 } 2385 2386 RIL_SimAuthentication pf = {}; 2387 2388 pf.authContext = authContext; 2389 2390 int len; 2391 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) { 2392 return Void(); 2393 } 2394 2395 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) { 2396 memsetAndFreeStrings(1, pf.authData); 2397 return Void(); 2398 } 2399 2400 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId); 2401 2402 memsetAndFreeStrings(2, pf.authData, pf.aid); 2403 return Void(); 2404} 2405 2406/** 2407 * @param numProfiles number of data profile 2408 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is 2409 RIL_DataProfileInfo or RIL_DataProfileInfo_v15. 2410 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure 2411 * @param numfields number of string-type member in the data profile structure 2412 * @param ... the variadic parameters are pointers to each string-type member 2413 **/ 2414template <typename T> 2415void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs, 2416 int numfields, ...) { 2417 va_list args; 2418 va_start(args, numfields); 2419 2420 // Iterate through each string-type field that need to be free. 2421 for (int i = 0; i < numfields; i++) { 2422 // Iterate through each data profile and free that specific string-type field. 2423 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure. 2424 char *T::*ptr = va_arg(args, char *T::*); 2425 for (int j = 0; j < numProfiles; j++) { 2426 memsetAndFreeStrings(1, dataProfiles[j].*ptr); 2427 } 2428 } 2429 2430 va_end(args); 2431 2432#ifdef MEMSET_FREED 2433 memset(dataProfiles, 0, numProfiles * sizeof(T)); 2434 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *)); 2435#endif 2436 free(dataProfiles); 2437 free(dataProfilePtrs); 2438} 2439 2440Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles, 2441 bool isRoaming) { 2442#if VDBG 2443 RLOGD("setDataProfile: serial %d", serial); 2444#endif 2445 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE); 2446 if (pRI == NULL) { 2447 return Void(); 2448 } 2449 2450 size_t num = profiles.size(); 2451 bool success = false; 2452 2453 if (s_vendorFunctions->version <= 14) { 2454 2455 RIL_DataProfileInfo *dataProfiles = 2456 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo)); 2457 2458 if (dataProfiles == NULL) { 2459 RLOGE("Memory allocation failed for request %s", 2460 requestToString(pRI->pCI->requestNumber)); 2461 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 2462 return Void(); 2463 } 2464 2465 RIL_DataProfileInfo **dataProfilePtrs = 2466 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *)); 2467 if (dataProfilePtrs == NULL) { 2468 RLOGE("Memory allocation failed for request %s", 2469 requestToString(pRI->pCI->requestNumber)); 2470 free(dataProfiles); 2471 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 2472 return Void(); 2473 } 2474 2475 for (size_t i = 0; i < num; i++) { 2476 dataProfilePtrs[i] = &dataProfiles[i]; 2477 2478 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI); 2479 2480 const hidl_string &protocol = 2481 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol); 2482 2483 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) { 2484 success = false; 2485 } 2486 2487 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) { 2488 success = false; 2489 } 2490 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password, 2491 pRI)) { 2492 success = false; 2493 } 2494 2495 if (!success) { 2496 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4, 2497 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol, 2498 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password); 2499 return Void(); 2500 } 2501 2502 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId; 2503 dataProfiles[i].authType = (int) profiles[i].authType; 2504 dataProfiles[i].type = (int) profiles[i].type; 2505 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime; 2506 dataProfiles[i].maxConns = profiles[i].maxConns; 2507 dataProfiles[i].waitTime = profiles[i].waitTime; 2508 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled); 2509 } 2510 2511 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs, 2512 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId); 2513 2514 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4, 2515 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol, 2516 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password); 2517 } else { 2518 RIL_DataProfileInfo_v15 *dataProfiles = 2519 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15)); 2520 2521 if (dataProfiles == NULL) { 2522 RLOGE("Memory allocation failed for request %s", 2523 requestToString(pRI->pCI->requestNumber)); 2524 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 2525 return Void(); 2526 } 2527 2528 RIL_DataProfileInfo_v15 **dataProfilePtrs = 2529 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *)); 2530 if (dataProfilePtrs == NULL) { 2531 RLOGE("Memory allocation failed for request %s", 2532 requestToString(pRI->pCI->requestNumber)); 2533 free(dataProfiles); 2534 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 2535 return Void(); 2536 } 2537 2538 for (size_t i = 0; i < num; i++) { 2539 dataProfilePtrs[i] = &dataProfiles[i]; 2540 2541 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI); 2542 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol, 2543 pRI)) { 2544 success = false; 2545 } 2546 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol, 2547 profiles[i].roamingProtocol, pRI)) { 2548 success = false; 2549 } 2550 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) { 2551 success = false; 2552 } 2553 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password, 2554 pRI)) { 2555 success = false; 2556 } 2557 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData, 2558 profiles[i].mvnoMatchData, pRI)) { 2559 success = false; 2560 } 2561 2562 if (success && !convertMvnoTypeToString(profiles[i].mvnoType, 2563 dataProfiles[i].mvnoType)) { 2564 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS); 2565 success = false; 2566 } 2567 2568 if (!success) { 2569 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6, 2570 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol, 2571 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user, 2572 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData); 2573 return Void(); 2574 } 2575 2576 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId; 2577 dataProfiles[i].authType = (int) profiles[i].authType; 2578 dataProfiles[i].type = (int) profiles[i].type; 2579 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime; 2580 dataProfiles[i].maxConns = profiles[i].maxConns; 2581 dataProfiles[i].waitTime = profiles[i].waitTime; 2582 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled); 2583 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap; 2584 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap; 2585 dataProfiles[i].mtu = profiles[i].mtu; 2586 } 2587 2588 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs, 2589 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId); 2590 2591 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6, 2592 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol, 2593 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user, 2594 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData); 2595 } 2596 2597 return Void(); 2598} 2599 2600Return<void> RadioImpl::requestShutdown(int32_t serial) { 2601#if VDBG 2602 RLOGD("requestShutdown: serial %d", serial); 2603#endif 2604 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN); 2605 return Void(); 2606} 2607 2608Return<void> RadioImpl::getRadioCapability(int32_t serial) { 2609#if VDBG 2610 RLOGD("getRadioCapability: serial %d", serial); 2611#endif 2612 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY); 2613 return Void(); 2614} 2615 2616Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) { 2617#if VDBG 2618 RLOGD("setRadioCapability: serial %d", serial); 2619#endif 2620 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY); 2621 if (pRI == NULL) { 2622 return Void(); 2623 } 2624 2625 RIL_RadioCapability rilRc = {}; 2626 2627 // TODO : set rilRc.version using HIDL version ? 2628 rilRc.session = rc.session; 2629 rilRc.phase = (int) rc.phase; 2630 rilRc.rat = (int) rc.raf; 2631 rilRc.status = (int) rc.status; 2632 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH); 2633 2634 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId); 2635 2636 return Void(); 2637} 2638 2639Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) { 2640#if VDBG 2641 RLOGD("startLceService: serial %d", serial); 2642#endif 2643 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval, 2644 BOOL_TO_INT(pullMode)); 2645 return Void(); 2646} 2647 2648Return<void> RadioImpl::stopLceService(int32_t serial) { 2649#if VDBG 2650 RLOGD("stopLceService: serial %d", serial); 2651#endif 2652 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE); 2653 return Void(); 2654} 2655 2656Return<void> RadioImpl::pullLceData(int32_t serial) { 2657#if VDBG 2658 RLOGD("pullLceData: serial %d", serial); 2659#endif 2660 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA); 2661 return Void(); 2662} 2663 2664Return<void> RadioImpl::getModemActivityInfo(int32_t serial) { 2665#if VDBG 2666 RLOGD("getModemActivityInfo: serial %d", serial); 2667#endif 2668 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO); 2669 return Void(); 2670} 2671 2672Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed, 2673 const CarrierRestrictions& carriers) { 2674#if VDBG 2675 RLOGD("setAllowedCarriers: serial %d", serial); 2676#endif 2677 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 2678 RIL_REQUEST_SET_CARRIER_RESTRICTIONS); 2679 if (pRI == NULL) { 2680 return Void(); 2681 } 2682 2683 RIL_CarrierRestrictions cr = {}; 2684 RIL_Carrier *allowedCarriers = NULL; 2685 RIL_Carrier *excludedCarriers = NULL; 2686 2687 cr.len_allowed_carriers = carriers.allowedCarriers.size(); 2688 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier)); 2689 if (allowedCarriers == NULL) { 2690 RLOGE("setAllowedCarriers: Memory allocation failed for request %s", 2691 requestToString(pRI->pCI->requestNumber)); 2692 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 2693 return Void(); 2694 } 2695 cr.allowed_carriers = allowedCarriers; 2696 2697 cr.len_excluded_carriers = carriers.excludedCarriers.size(); 2698 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier)); 2699 if (excludedCarriers == NULL) { 2700 RLOGE("setAllowedCarriers: Memory allocation failed for request %s", 2701 requestToString(pRI->pCI->requestNumber)); 2702 sendErrorResponse(pRI, RIL_E_NO_MEMORY); 2703#ifdef MEMSET_FREED 2704 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier)); 2705#endif 2706 free(allowedCarriers); 2707 return Void(); 2708 } 2709 cr.excluded_carriers = excludedCarriers; 2710 2711 for (int i = 0; i < cr.len_allowed_carriers; i++) { 2712 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str(); 2713 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str(); 2714 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType; 2715 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str(); 2716 } 2717 2718 for (int i = 0; i < cr.len_excluded_carriers; i++) { 2719 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str(); 2720 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str(); 2721 excludedCarriers[i].match_type = 2722 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType; 2723 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str(); 2724 } 2725 2726 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId); 2727 2728#ifdef MEMSET_FREED 2729 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier)); 2730 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier)); 2731#endif 2732 free(allowedCarriers); 2733 free(excludedCarriers); 2734 return Void(); 2735} 2736 2737Return<void> RadioImpl::getAllowedCarriers(int32_t serial) { 2738#if VDBG 2739 RLOGD("getAllowedCarriers: serial %d", serial); 2740#endif 2741 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS); 2742 return Void(); 2743} 2744 2745Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType, 2746 bool state) { 2747#if VDBG 2748 RLOGD("sendDeviceState: serial %d", serial); 2749#endif 2750 if (s_vendorFunctions->version < 15) { 2751 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) { 2752 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state)); 2753 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state)); 2754 } else { 2755 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 2756 RIL_REQUEST_SEND_DEVICE_STATE); 2757 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED); 2758 } 2759 return Void(); 2760 } 2761 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType, 2762 BOOL_TO_INT(state)); 2763 return Void(); 2764} 2765 2766Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) { 2767#if VDBG 2768 RLOGD("setIndicationFilter: serial %d", serial); 2769#endif 2770 if (s_vendorFunctions->version < 15) { 2771 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, 2772 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER); 2773 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED); 2774 return Void(); 2775 } 2776 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter); 2777 return Void(); 2778} 2779 2780Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) { 2781#if VDBG 2782 RLOGD("setSimCardPower: serial %d", serial); 2783#endif 2784 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp)); 2785 return Void(); 2786} 2787 2788Return<void> RadioImpl::setSimCardPower_1_1(int32_t serial, const V1_1::CardPowerState state) { 2789#if VDBG 2790 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state); 2791#endif 2792 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state); 2793 return Void(); 2794} 2795 2796Return<void> RadioImpl::responseAcknowledgement() { 2797 android::releaseWakeLock(); 2798 return Void(); 2799} 2800 2801Return<void> OemHookImpl::setResponseFunctions( 2802 const ::android::sp<IOemHookResponse>& oemHookResponseParam, 2803 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) { 2804#if VDBG 2805 RLOGD("OemHookImpl::setResponseFunctions"); 2806#endif 2807 2808 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId); 2809 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr); 2810 assert(ret == 0); 2811 2812 mOemHookResponse = oemHookResponseParam; 2813 mOemHookIndication = oemHookIndicationParam; 2814 mCounterOemHook[mSlotId]++; 2815 2816 ret = pthread_rwlock_unlock(radioServiceRwlockPtr); 2817 assert(ret == 0); 2818 2819 return Void(); 2820} 2821 2822Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) { 2823#if VDBG 2824 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial); 2825#endif 2826 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data); 2827 return Void(); 2828} 2829 2830Return<void> OemHookImpl::sendRequestStrings(int32_t serial, 2831 const hidl_vec<hidl_string>& data) { 2832#if VDBG 2833 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial); 2834#endif 2835 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data); 2836 return Void(); 2837} 2838 2839Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial, 2840 const ::android::hardware::radio::V1_1::ImsiEncryptionInfo& data) { 2841 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial); 2842 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION); 2843 RIL_CarrierInfoForImsiEncryption imsiEncryption = {}; 2844 2845 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) { 2846 return Void(); 2847 } 2848 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) { 2849 memsetAndFreeStrings(1, imsiEncryption.mnc); 2850 return Void(); 2851 } 2852 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) { 2853 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc); 2854 return Void(); 2855 } 2856 int32_t lSize = data.carrierKey.size(); 2857 imsiEncryption.carrierKey = new uint8_t[lSize]; 2858 memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), lSize); 2859 imsiEncryption.expirationTime = data.expirationTime; 2860 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &imsiEncryption, sizeof(RIL_CarrierInfoForImsiEncryption), pRI); 2861 delete(imsiEncryption.carrierKey); 2862 return Void(); 2863} 2864 2865Return<void> RadioImpl::startKeepalive(int32_t serial, const KeepaliveRequest& keepalive) { 2866 RLOGD("startKeepalive: serial %d", serial); 2867 return Void(); 2868} 2869 2870Return<void> RadioImpl::stopKeepalive(int32_t serial, int32_t sessionHandle) { 2871 RLOGD("stopKeepalive: serial %d", serial); 2872 return Void(); 2873} 2874 2875 2876/*************************************************************************************************** 2877 * RESPONSE FUNCTIONS 2878 * Functions above are used for requests going from framework to vendor code. The ones below are 2879 * responses for those requests coming back from the vendor code. 2880 **************************************************************************************************/ 2881 2882void radio::acknowledgeRequest(int slotId, int serial) { 2883 if (radioService[slotId]->mRadioResponse != NULL) { 2884 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial); 2885 radioService[slotId]->checkReturnStatus(retStatus); 2886 } else { 2887 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId); 2888 } 2889} 2890 2891void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType, 2892 RIL_Errno e) { 2893 responseInfo.serial = serial; 2894 switch (responseType) { 2895 case RESPONSE_SOLICITED: 2896 responseInfo.type = RadioResponseType::SOLICITED; 2897 break; 2898 case RESPONSE_SOLICITED_ACK_EXP: 2899 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP; 2900 break; 2901 } 2902 responseInfo.error = (RadioError) e; 2903} 2904 2905int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e, 2906 void *response, size_t responseLen) { 2907 populateResponseInfo(responseInfo, serial, responseType, e); 2908 int ret = -1; 2909 2910 if (response == NULL && responseLen == 0) { 2911 // Earlier RILs did not send a response for some cases although the interface 2912 // expected an integer as response. Do not return error if response is empty. Instead 2913 // Return -1 in those cases to maintain backward compatibility. 2914 } else if (response == NULL || responseLen != sizeof(int)) { 2915 RLOGE("responseIntOrEmpty: Invalid response"); 2916 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2917 } else { 2918 int *p_int = (int *) response; 2919 ret = p_int[0]; 2920 } 2921 return ret; 2922} 2923 2924int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e, 2925 void *response, size_t responseLen) { 2926 populateResponseInfo(responseInfo, serial, responseType, e); 2927 int ret = -1; 2928 2929 if (response == NULL || responseLen != sizeof(int)) { 2930 RLOGE("responseInt: Invalid response"); 2931 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2932 } else { 2933 int *p_int = (int *) response; 2934 ret = p_int[0]; 2935 } 2936 return ret; 2937} 2938 2939int radio::getIccCardStatusResponse(int slotId, 2940 int responseType, int serial, RIL_Errno e, 2941 void *response, size_t responseLen) { 2942 if (radioService[slotId]->mRadioResponse != NULL) { 2943 RadioResponseInfo responseInfo = {}; 2944 populateResponseInfo(responseInfo, serial, responseType, e); 2945 CardStatus cardStatus = {}; 2946 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response); 2947 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6) 2948 || p_cur->gsm_umts_subscription_app_index >= p_cur->num_applications 2949 || p_cur->cdma_subscription_app_index >= p_cur->num_applications 2950 || p_cur->ims_subscription_app_index >= p_cur->num_applications) { 2951 RLOGE("getIccCardStatusResponse: Invalid response"); 2952 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 2953 } else { 2954 cardStatus.cardState = (CardState) p_cur->card_state; 2955 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state; 2956 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index; 2957 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index; 2958 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index; 2959 2960 RIL_AppStatus *rilAppStatus = p_cur->applications; 2961 cardStatus.applications.resize(p_cur->num_applications); 2962 AppStatus *appStatus = cardStatus.applications.data(); 2963#if VDBG 2964 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications); 2965#endif 2966 for (int i = 0; i < p_cur->num_applications; i++) { 2967 appStatus[i].appType = (AppType) rilAppStatus[i].app_type; 2968 appStatus[i].appState = (AppState) rilAppStatus[i].app_state; 2969 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate; 2970 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr); 2971 appStatus[i].appLabelPtr = convertCharPtrToHidlString( 2972 rilAppStatus[i].app_label_ptr); 2973 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced; 2974 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1; 2975 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2; 2976 } 2977 } 2978 2979 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 2980 getIccCardStatusResponse(responseInfo, cardStatus); 2981 radioService[slotId]->checkReturnStatus(retStatus); 2982 } else { 2983 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId); 2984 } 2985 2986 return 0; 2987} 2988 2989int radio::supplyIccPinForAppResponse(int slotId, 2990 int responseType, int serial, RIL_Errno e, 2991 void *response, size_t responseLen) { 2992#if VDBG 2993 RLOGD("supplyIccPinForAppResponse: serial %d", serial); 2994#endif 2995 2996 if (radioService[slotId]->mRadioResponse != NULL) { 2997 RadioResponseInfo responseInfo = {}; 2998 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen); 2999 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 3000 supplyIccPinForAppResponse(responseInfo, ret); 3001 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret); 3002 radioService[slotId]->checkReturnStatus(retStatus); 3003 } else { 3004 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL", 3005 slotId); 3006 } 3007 3008 return 0; 3009} 3010 3011int radio::supplyIccPukForAppResponse(int slotId, 3012 int responseType, int serial, RIL_Errno e, 3013 void *response, size_t responseLen) { 3014#if VDBG 3015 RLOGD("supplyIccPukForAppResponse: serial %d", serial); 3016#endif 3017 3018 if (radioService[slotId]->mRadioResponse != NULL) { 3019 RadioResponseInfo responseInfo = {}; 3020 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen); 3021 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse( 3022 responseInfo, ret); 3023 radioService[slotId]->checkReturnStatus(retStatus); 3024 } else { 3025 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL", 3026 slotId); 3027 } 3028 3029 return 0; 3030} 3031 3032int radio::supplyIccPin2ForAppResponse(int slotId, 3033 int responseType, int serial, RIL_Errno e, 3034 void *response, size_t responseLen) { 3035#if VDBG 3036 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial); 3037#endif 3038 3039 if (radioService[slotId]->mRadioResponse != NULL) { 3040 RadioResponseInfo responseInfo = {}; 3041 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen); 3042 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 3043 supplyIccPin2ForAppResponse(responseInfo, ret); 3044 radioService[slotId]->checkReturnStatus(retStatus); 3045 } else { 3046 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL", 3047 slotId); 3048 } 3049 3050 return 0; 3051} 3052 3053int radio::supplyIccPuk2ForAppResponse(int slotId, 3054 int responseType, int serial, RIL_Errno e, 3055 void *response, size_t responseLen) { 3056#if VDBG 3057 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial); 3058#endif 3059 3060 if (radioService[slotId]->mRadioResponse != NULL) { 3061 RadioResponseInfo responseInfo = {}; 3062 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen); 3063 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 3064 supplyIccPuk2ForAppResponse(responseInfo, ret); 3065 radioService[slotId]->checkReturnStatus(retStatus); 3066 } else { 3067 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL", 3068 slotId); 3069 } 3070 3071 return 0; 3072} 3073 3074int radio::changeIccPinForAppResponse(int slotId, 3075 int responseType, int serial, RIL_Errno e, 3076 void *response, size_t responseLen) { 3077#if VDBG 3078 RLOGD("changeIccPinForAppResponse: serial %d", serial); 3079#endif 3080 3081 if (radioService[slotId]->mRadioResponse != NULL) { 3082 RadioResponseInfo responseInfo = {}; 3083 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen); 3084 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 3085 changeIccPinForAppResponse(responseInfo, ret); 3086 radioService[slotId]->checkReturnStatus(retStatus); 3087 } else { 3088 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL", 3089 slotId); 3090 } 3091 3092 return 0; 3093} 3094 3095int radio::changeIccPin2ForAppResponse(int slotId, 3096 int responseType, int serial, RIL_Errno e, 3097 void *response, size_t responseLen) { 3098#if VDBG 3099 RLOGD("changeIccPin2ForAppResponse: serial %d", serial); 3100#endif 3101 3102 if (radioService[slotId]->mRadioResponse != NULL) { 3103 RadioResponseInfo responseInfo = {}; 3104 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen); 3105 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 3106 changeIccPin2ForAppResponse(responseInfo, ret); 3107 radioService[slotId]->checkReturnStatus(retStatus); 3108 } else { 3109 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL", 3110 slotId); 3111 } 3112 3113 return 0; 3114} 3115 3116int radio::supplyNetworkDepersonalizationResponse(int slotId, 3117 int responseType, int serial, RIL_Errno e, 3118 void *response, size_t responseLen) { 3119#if VDBG 3120 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial); 3121#endif 3122 3123 if (radioService[slotId]->mRadioResponse != NULL) { 3124 RadioResponseInfo responseInfo = {}; 3125 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen); 3126 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 3127 supplyNetworkDepersonalizationResponse(responseInfo, ret); 3128 radioService[slotId]->checkReturnStatus(retStatus); 3129 } else { 3130 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == " 3131 "NULL", slotId); 3132 } 3133 3134 return 0; 3135} 3136 3137int radio::getCurrentCallsResponse(int slotId, 3138 int responseType, int serial, RIL_Errno e, 3139 void *response, size_t responseLen) { 3140#if VDBG 3141 RLOGD("getCurrentCallsResponse: serial %d", serial); 3142#endif 3143 3144 if (radioService[slotId]->mRadioResponse != NULL) { 3145 RadioResponseInfo responseInfo = {}; 3146 populateResponseInfo(responseInfo, serial, responseType, e); 3147 3148 hidl_vec<Call> calls; 3149 if ((response == NULL && responseLen != 0) 3150 || (responseLen % sizeof(RIL_Call *)) != 0) { 3151 RLOGE("getCurrentCallsResponse: Invalid response"); 3152 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3153 } else { 3154 int num = responseLen / sizeof(RIL_Call *); 3155 calls.resize(num); 3156 3157 for (int i = 0 ; i < num ; i++) { 3158 RIL_Call *p_cur = ((RIL_Call **) response)[i]; 3159 /* each call info */ 3160 calls[i].state = (CallState) p_cur->state; 3161 calls[i].index = p_cur->index; 3162 calls[i].toa = p_cur->toa; 3163 calls[i].isMpty = p_cur->isMpty; 3164 calls[i].isMT = p_cur->isMT; 3165 calls[i].als = p_cur->als; 3166 calls[i].isVoice = p_cur->isVoice; 3167 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy; 3168 calls[i].number = convertCharPtrToHidlString(p_cur->number); 3169 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation; 3170 calls[i].name = convertCharPtrToHidlString(p_cur->name); 3171 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation; 3172 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) { 3173 RIL_UUS_Info *uusInfo = p_cur->uusInfo; 3174 calls[i].uusInfo.resize(1); 3175 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType; 3176 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs; 3177 // convert uusInfo->uusData to a null-terminated string 3178 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength); 3179 calls[i].uusInfo[0].uusData = nullTermStr; 3180 free(nullTermStr); 3181 } 3182 } 3183 } 3184 3185 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 3186 getCurrentCallsResponse(responseInfo, calls); 3187 radioService[slotId]->checkReturnStatus(retStatus); 3188 } else { 3189 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3190 } 3191 3192 return 0; 3193} 3194 3195int radio::dialResponse(int slotId, 3196 int responseType, int serial, RIL_Errno e, void *response, 3197 size_t responseLen) { 3198#if VDBG 3199 RLOGD("dialResponse: serial %d", serial); 3200#endif 3201 3202 if (radioService[slotId]->mRadioResponse != NULL) { 3203 RadioResponseInfo responseInfo = {}; 3204 populateResponseInfo(responseInfo, serial, responseType, e); 3205 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo); 3206 radioService[slotId]->checkReturnStatus(retStatus); 3207 } else { 3208 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3209 } 3210 3211 return 0; 3212} 3213 3214int radio::getIMSIForAppResponse(int slotId, 3215 int responseType, int serial, RIL_Errno e, void *response, 3216 size_t responseLen) { 3217#if VDBG 3218 RLOGD("getIMSIForAppResponse: serial %d", serial); 3219#endif 3220 3221 if (radioService[slotId]->mRadioResponse != NULL) { 3222 RadioResponseInfo responseInfo = {}; 3223 populateResponseInfo(responseInfo, serial, responseType, e); 3224 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse( 3225 responseInfo, convertCharPtrToHidlString((char *) response)); 3226 radioService[slotId]->checkReturnStatus(retStatus); 3227 } else { 3228 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL", 3229 slotId); 3230 } 3231 3232 return 0; 3233} 3234 3235int radio::hangupConnectionResponse(int slotId, 3236 int responseType, int serial, RIL_Errno e, 3237 void *response, size_t responseLen) { 3238#if VDBG 3239 RLOGD("hangupConnectionResponse: serial %d", serial); 3240#endif 3241 3242 if (radioService[slotId]->mRadioResponse != NULL) { 3243 RadioResponseInfo responseInfo = {}; 3244 populateResponseInfo(responseInfo, serial, responseType, e); 3245 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse( 3246 responseInfo); 3247 radioService[slotId]->checkReturnStatus(retStatus); 3248 } else { 3249 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL", 3250 slotId); 3251 } 3252 3253 return 0; 3254} 3255 3256int radio::hangupWaitingOrBackgroundResponse(int slotId, 3257 int responseType, int serial, RIL_Errno e, 3258 void *response, size_t responseLen) { 3259#if VDBG 3260 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial); 3261#endif 3262 3263 if (radioService[slotId]->mRadioResponse != NULL) { 3264 RadioResponseInfo responseInfo = {}; 3265 populateResponseInfo(responseInfo, serial, responseType, e); 3266 Return<void> retStatus = 3267 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse( 3268 responseInfo); 3269 radioService[slotId]->checkReturnStatus(retStatus); 3270 } else { 3271 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL", 3272 slotId); 3273 } 3274 3275 return 0; 3276} 3277 3278int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial, 3279 RIL_Errno e, void *response, 3280 size_t responseLen) { 3281#if VDBG 3282 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial); 3283#endif 3284 3285 if (radioService[slotId]->mRadioResponse != NULL) { 3286 RadioResponseInfo responseInfo = {}; 3287 populateResponseInfo(responseInfo, serial, responseType, e); 3288 Return<void> retStatus = 3289 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse( 3290 responseInfo); 3291 radioService[slotId]->checkReturnStatus(retStatus); 3292 } else { 3293 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL", 3294 slotId); 3295 } 3296 3297 return 0; 3298} 3299 3300int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial, 3301 RIL_Errno e, void *response, 3302 size_t responseLen) { 3303#if VDBG 3304 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial); 3305#endif 3306 3307 if (radioService[slotId]->mRadioResponse != NULL) { 3308 RadioResponseInfo responseInfo = {}; 3309 populateResponseInfo(responseInfo, serial, responseType, e); 3310 Return<void> retStatus = 3311 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse( 3312 responseInfo); 3313 radioService[slotId]->checkReturnStatus(retStatus); 3314 } else { 3315 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse " 3316 "== NULL", slotId); 3317 } 3318 3319 return 0; 3320} 3321 3322int radio::conferenceResponse(int slotId, int responseType, 3323 int serial, RIL_Errno e, void *response, size_t responseLen) { 3324#if VDBG 3325 RLOGD("conferenceResponse: serial %d", serial); 3326#endif 3327 3328 if (radioService[slotId]->mRadioResponse != NULL) { 3329 RadioResponseInfo responseInfo = {}; 3330 populateResponseInfo(responseInfo, serial, responseType, e); 3331 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse( 3332 responseInfo); 3333 radioService[slotId]->checkReturnStatus(retStatus); 3334 } else { 3335 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL", 3336 slotId); 3337 } 3338 3339 return 0; 3340} 3341 3342int radio::rejectCallResponse(int slotId, int responseType, 3343 int serial, RIL_Errno e, void *response, size_t responseLen) { 3344#if VDBG 3345 RLOGD("rejectCallResponse: serial %d", serial); 3346#endif 3347 3348 if (radioService[slotId]->mRadioResponse != NULL) { 3349 RadioResponseInfo responseInfo = {}; 3350 populateResponseInfo(responseInfo, serial, responseType, e); 3351 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse( 3352 responseInfo); 3353 radioService[slotId]->checkReturnStatus(retStatus); 3354 } else { 3355 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL", 3356 slotId); 3357 } 3358 3359 return 0; 3360} 3361 3362int radio::getLastCallFailCauseResponse(int slotId, 3363 int responseType, int serial, RIL_Errno e, void *response, 3364 size_t responseLen) { 3365#if VDBG 3366 RLOGD("getLastCallFailCauseResponse: serial %d", serial); 3367#endif 3368 3369 if (radioService[slotId]->mRadioResponse != NULL) { 3370 RadioResponseInfo responseInfo = {}; 3371 populateResponseInfo(responseInfo, serial, responseType, e); 3372 3373 LastCallFailCauseInfo info = {}; 3374 info.vendorCause = hidl_string(); 3375 if (response == NULL) { 3376 RLOGE("getCurrentCallsResponse Invalid response: NULL"); 3377 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3378 } else if (responseLen == sizeof(int)) { 3379 int *pInt = (int *) response; 3380 info.causeCode = (LastCallFailCause) pInt[0]; 3381 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) { 3382 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response; 3383 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code; 3384 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause); 3385 } else { 3386 RLOGE("getCurrentCallsResponse Invalid response: NULL"); 3387 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3388 } 3389 3390 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse( 3391 responseInfo, info); 3392 radioService[slotId]->checkReturnStatus(retStatus); 3393 } else { 3394 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL", 3395 slotId); 3396 } 3397 3398 return 0; 3399} 3400 3401int radio::getSignalStrengthResponse(int slotId, 3402 int responseType, int serial, RIL_Errno e, 3403 void *response, size_t responseLen) { 3404#if VDBG 3405 RLOGD("getSignalStrengthResponse: serial %d", serial); 3406#endif 3407 3408 if (radioService[slotId]->mRadioResponse != NULL) { 3409 RadioResponseInfo responseInfo = {}; 3410 populateResponseInfo(responseInfo, serial, responseType, e); 3411 SignalStrength signalStrength = {}; 3412 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) { 3413 RLOGE("getSignalStrengthResponse: Invalid response"); 3414 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3415 } else { 3416 convertRilSignalStrengthToHal(response, responseLen, signalStrength); 3417 } 3418 3419 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse( 3420 responseInfo, signalStrength); 3421 radioService[slotId]->checkReturnStatus(retStatus); 3422 } else { 3423 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL", 3424 slotId); 3425 } 3426 3427 return 0; 3428} 3429 3430RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) { 3431 if (rat == NULL) { 3432 return RIL_CELL_INFO_TYPE_NONE; 3433 } 3434 3435 int radioTech = atoi(rat); 3436 3437 switch(radioTech) { 3438 3439 case RADIO_TECH_GPRS: 3440 case RADIO_TECH_EDGE: 3441 case RADIO_TECH_GSM: { 3442 return RIL_CELL_INFO_TYPE_GSM; 3443 } 3444 3445 case RADIO_TECH_UMTS: 3446 case RADIO_TECH_HSDPA: 3447 case RADIO_TECH_HSUPA: 3448 case RADIO_TECH_HSPA: 3449 case RADIO_TECH_HSPAP: { 3450 return RIL_CELL_INFO_TYPE_WCDMA; 3451 } 3452 3453 case RADIO_TECH_IS95A: 3454 case RADIO_TECH_IS95B: 3455 case RADIO_TECH_1xRTT: 3456 case RADIO_TECH_EVDO_0: 3457 case RADIO_TECH_EVDO_A: 3458 case RADIO_TECH_EVDO_B: 3459 case RADIO_TECH_EHRPD: { 3460 return RIL_CELL_INFO_TYPE_CDMA; 3461 } 3462 3463 case RADIO_TECH_LTE: 3464 case RADIO_TECH_LTE_CA: { 3465 return RIL_CELL_INFO_TYPE_LTE; 3466 } 3467 3468 case RADIO_TECH_TD_SCDMA: { 3469 return RIL_CELL_INFO_TYPE_TD_SCDMA; 3470 } 3471 3472 default: { 3473 break; 3474 } 3475 } 3476 3477 return RIL_CELL_INFO_TYPE_NONE; 3478 3479} 3480 3481void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) { 3482 3483 cellIdentity.cellIdentityGsm.resize(0); 3484 cellIdentity.cellIdentityWcdma.resize(0); 3485 cellIdentity.cellIdentityCdma.resize(0); 3486 cellIdentity.cellIdentityTdscdma.resize(0); 3487 cellIdentity.cellIdentityLte.resize(0); 3488 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType; 3489 switch(rilCellIdentity.cellInfoType) { 3490 3491 case RIL_CELL_INFO_TYPE_GSM: { 3492 cellIdentity.cellIdentityGsm.resize(1); 3493 cellIdentity.cellIdentityGsm[0].mcc = 3494 std::to_string(rilCellIdentity.cellIdentityGsm.mcc); 3495 cellIdentity.cellIdentityGsm[0].mnc = 3496 std::to_string(rilCellIdentity.cellIdentityGsm.mnc); 3497 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac; 3498 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid; 3499 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn; 3500 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic; 3501 break; 3502 } 3503 3504 case RIL_CELL_INFO_TYPE_WCDMA: { 3505 cellIdentity.cellIdentityWcdma.resize(1); 3506 cellIdentity.cellIdentityWcdma[0].mcc = 3507 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc); 3508 cellIdentity.cellIdentityWcdma[0].mnc = 3509 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc); 3510 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac; 3511 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid; 3512 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc; 3513 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn; 3514 break; 3515 } 3516 3517 case RIL_CELL_INFO_TYPE_CDMA: { 3518 cellIdentity.cellIdentityCdma.resize(1); 3519 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId; 3520 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId; 3521 cellIdentity.cellIdentityCdma[0].baseStationId = 3522 rilCellIdentity.cellIdentityCdma.basestationId; 3523 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude; 3524 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude; 3525 break; 3526 } 3527 3528 case RIL_CELL_INFO_TYPE_LTE: { 3529 cellIdentity.cellIdentityLte.resize(1); 3530 cellIdentity.cellIdentityLte[0].mcc = 3531 std::to_string(rilCellIdentity.cellIdentityLte.mcc); 3532 cellIdentity.cellIdentityLte[0].mnc = 3533 std::to_string(rilCellIdentity.cellIdentityLte.mnc); 3534 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci; 3535 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci; 3536 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac; 3537 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn; 3538 break; 3539 } 3540 3541 case RIL_CELL_INFO_TYPE_TD_SCDMA: { 3542 cellIdentity.cellIdentityTdscdma.resize(1); 3543 cellIdentity.cellIdentityTdscdma[0].mcc = 3544 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc); 3545 cellIdentity.cellIdentityTdscdma[0].mnc = 3546 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc); 3547 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac; 3548 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid; 3549 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid; 3550 break; 3551 } 3552 3553 default: { 3554 break; 3555 } 3556 } 3557} 3558 3559int convertResponseStringEntryToInt(char **response, int index, int numStrings) { 3560 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) { 3561 return atoi(response[index]); 3562 } 3563 3564 return -1; 3565} 3566 3567int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) { 3568 const int hexBase = 16; 3569 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) { 3570 return strtol(response[index], NULL, hexBase); 3571 } 3572 3573 return -1; 3574} 3575 3576/* Fill Cell Identity info from Voice Registration State Response. 3577 * This fucntion is applicable only for RIL Version < 15. 3578 * Response is a "char **". 3579 * First and Second entries are in hex string format 3580 * and rest are integers represented in ascii format. */ 3581void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity, 3582 int numStrings, char** response) { 3583 3584 RIL_CellIdentity_v16 rilCellIdentity; 3585 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16)); 3586 3587 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]); 3588 switch(rilCellIdentity.cellInfoType) { 3589 3590 case RIL_CELL_INFO_TYPE_GSM: { 3591 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */ 3592 rilCellIdentity.cellIdentityGsm.lac = 3593 convertResponseHexStringEntryToInt(response, 1, numStrings); 3594 3595 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */ 3596 rilCellIdentity.cellIdentityGsm.cid = 3597 convertResponseHexStringEntryToInt(response, 2, numStrings); 3598 break; 3599 } 3600 3601 case RIL_CELL_INFO_TYPE_WCDMA: { 3602 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */ 3603 rilCellIdentity.cellIdentityWcdma.lac = 3604 convertResponseHexStringEntryToInt(response, 1, numStrings); 3605 3606 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */ 3607 rilCellIdentity.cellIdentityWcdma.cid = 3608 convertResponseHexStringEntryToInt(response, 2, numStrings); 3609 rilCellIdentity.cellIdentityWcdma.psc = 3610 convertResponseStringEntryToInt(response, 14, numStrings); 3611 break; 3612 } 3613 3614 case RIL_CELL_INFO_TYPE_TD_SCDMA:{ 3615 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */ 3616 rilCellIdentity.cellIdentityTdscdma.lac = 3617 convertResponseHexStringEntryToInt(response, 1, numStrings); 3618 3619 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */ 3620 rilCellIdentity.cellIdentityTdscdma.cid = 3621 convertResponseHexStringEntryToInt(response, 2, numStrings); 3622 break; 3623 } 3624 3625 case RIL_CELL_INFO_TYPE_CDMA:{ 3626 rilCellIdentity.cellIdentityCdma.basestationId = 3627 convertResponseStringEntryToInt(response, 4, numStrings); 3628 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */ 3629 rilCellIdentity.cellIdentityCdma.latitude = 3630 convertResponseStringEntryToInt(response, 5, numStrings); 3631 rilCellIdentity.cellIdentityCdma.longitude = 3632 convertResponseStringEntryToInt(response, 6, numStrings); 3633 rilCellIdentity.cellIdentityCdma.systemId = 3634 convertResponseStringEntryToInt(response, 8, numStrings); 3635 rilCellIdentity.cellIdentityCdma.networkId = 3636 convertResponseStringEntryToInt(response, 9, numStrings); 3637 break; 3638 } 3639 3640 case RIL_CELL_INFO_TYPE_LTE:{ 3641 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */ 3642 rilCellIdentity.cellIdentityLte.tac = 3643 convertResponseHexStringEntryToInt(response, 1, numStrings); 3644 3645 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */ 3646 rilCellIdentity.cellIdentityLte.ci = 3647 convertResponseHexStringEntryToInt(response, 2, numStrings); 3648 break; 3649 } 3650 3651 default: { 3652 break; 3653 } 3654 } 3655 3656 fillCellIdentityResponse(cellIdentity, rilCellIdentity); 3657} 3658 3659/* Fill Cell Identity info from Data Registration State Response. 3660 * This fucntion is applicable only for RIL Version < 15. 3661 * Response is a "char **". 3662 * First and Second entries are in hex string format 3663 * and rest are integers represented in ascii format. */ 3664void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity, 3665 int numStrings, char** response) { 3666 3667 RIL_CellIdentity_v16 rilCellIdentity; 3668 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16)); 3669 3670 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]); 3671 switch(rilCellIdentity.cellInfoType) { 3672 case RIL_CELL_INFO_TYPE_GSM: { 3673 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */ 3674 rilCellIdentity.cellIdentityGsm.lac = 3675 convertResponseHexStringEntryToInt(response, 1, numStrings); 3676 3677 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */ 3678 rilCellIdentity.cellIdentityGsm.cid = 3679 convertResponseHexStringEntryToInt(response, 2, numStrings); 3680 break; 3681 } 3682 case RIL_CELL_INFO_TYPE_WCDMA: { 3683 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */ 3684 rilCellIdentity.cellIdentityWcdma.lac = 3685 convertResponseHexStringEntryToInt(response, 1, numStrings); 3686 3687 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */ 3688 rilCellIdentity.cellIdentityWcdma.cid = 3689 convertResponseHexStringEntryToInt(response, 2, numStrings); 3690 break; 3691 } 3692 case RIL_CELL_INFO_TYPE_TD_SCDMA:{ 3693 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */ 3694 rilCellIdentity.cellIdentityTdscdma.lac = 3695 convertResponseHexStringEntryToInt(response, 1, numStrings); 3696 3697 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */ 3698 rilCellIdentity.cellIdentityTdscdma.cid = 3699 convertResponseHexStringEntryToInt(response, 2, numStrings); 3700 break; 3701 } 3702 case RIL_CELL_INFO_TYPE_LTE: { 3703 rilCellIdentity.cellIdentityLte.tac = 3704 convertResponseStringEntryToInt(response, 6, numStrings); 3705 rilCellIdentity.cellIdentityLte.pci = 3706 convertResponseStringEntryToInt(response, 7, numStrings); 3707 rilCellIdentity.cellIdentityLte.ci = 3708 convertResponseStringEntryToInt(response, 8, numStrings); 3709 break; 3710 } 3711 default: { 3712 break; 3713 } 3714 } 3715 3716 fillCellIdentityResponse(cellIdentity, rilCellIdentity); 3717} 3718 3719int radio::getVoiceRegistrationStateResponse(int slotId, 3720 int responseType, int serial, RIL_Errno e, 3721 void *response, size_t responseLen) { 3722#if VDBG 3723 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial); 3724#endif 3725 3726 if (radioService[slotId]->mRadioResponse != NULL) { 3727 RadioResponseInfo responseInfo = {}; 3728 populateResponseInfo(responseInfo, serial, responseType, e); 3729 3730 VoiceRegStateResult voiceRegResponse = {}; 3731 int numStrings = responseLen / sizeof(char *); 3732 if (response == NULL) { 3733 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL"); 3734 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3735 } else if (s_vendorFunctions->version <= 14) { 3736 if (numStrings != 15) { 3737 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL"); 3738 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3739 } else { 3740 char **resp = (char **) response; 3741 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4); 3742 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]); 3743 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0); 3744 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]); 3745 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0); 3746 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0); 3747 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0); 3748 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity, 3749 numStrings, resp); 3750 } 3751 } else { 3752 RIL_VoiceRegistrationStateResponse *voiceRegState = 3753 (RIL_VoiceRegistrationStateResponse *)response; 3754 3755 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) { 3756 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL"); 3757 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3758 } else { 3759 voiceRegResponse.regState = (RegState) voiceRegState->regState; 3760 voiceRegResponse.rat = voiceRegState->rat;; 3761 voiceRegResponse.cssSupported = voiceRegState->cssSupported; 3762 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator; 3763 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl; 3764 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator; 3765 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial; 3766 fillCellIdentityResponse(voiceRegResponse.cellIdentity, 3767 voiceRegState->cellIdentity); 3768 } 3769 } 3770 3771 Return<void> retStatus = 3772 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse( 3773 responseInfo, voiceRegResponse); 3774 radioService[slotId]->checkReturnStatus(retStatus); 3775 } else { 3776 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL", 3777 slotId); 3778 } 3779 3780 return 0; 3781} 3782 3783int radio::getDataRegistrationStateResponse(int slotId, 3784 int responseType, int serial, RIL_Errno e, 3785 void *response, size_t responseLen) { 3786#if VDBG 3787 RLOGD("getDataRegistrationStateResponse: serial %d", serial); 3788#endif 3789 3790 if (radioService[slotId]->mRadioResponse != NULL) { 3791 RadioResponseInfo responseInfo = {}; 3792 populateResponseInfo(responseInfo, serial, responseType, e); 3793 DataRegStateResult dataRegResponse = {}; 3794 if (response == NULL) { 3795 RLOGE("getDataRegistrationStateResponse Invalid response: NULL"); 3796 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3797 } else if (s_vendorFunctions->version <= 14) { 3798 int numStrings = responseLen / sizeof(char *); 3799 if ((numStrings != 6) && (numStrings != 11)) { 3800 RLOGE("getDataRegistrationStateResponse Invalid response: NULL"); 3801 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3802 } else { 3803 char **resp = (char **) response; 3804 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4); 3805 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0); 3806 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]); 3807 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1); 3808 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity, 3809 numStrings, resp); 3810 } 3811 } else { 3812 RIL_DataRegistrationStateResponse *dataRegState = 3813 (RIL_DataRegistrationStateResponse *)response; 3814 3815 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) { 3816 RLOGE("getDataRegistrationStateResponse Invalid response: NULL"); 3817 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3818 } else { 3819 dataRegResponse.regState = (RegState) dataRegState->regState; 3820 dataRegResponse.rat = dataRegState->rat;; 3821 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied; 3822 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls; 3823 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity); 3824 } 3825 } 3826 3827 Return<void> retStatus = 3828 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo, 3829 dataRegResponse); 3830 radioService[slotId]->checkReturnStatus(retStatus); 3831 } else { 3832 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL", 3833 slotId); 3834 } 3835 3836 return 0; 3837} 3838 3839int radio::getOperatorResponse(int slotId, 3840 int responseType, int serial, RIL_Errno e, void *response, 3841 size_t responseLen) { 3842#if VDBG 3843 RLOGD("getOperatorResponse: serial %d", serial); 3844#endif 3845 3846 if (radioService[slotId]->mRadioResponse != NULL) { 3847 RadioResponseInfo responseInfo = {}; 3848 populateResponseInfo(responseInfo, serial, responseType, e); 3849 hidl_string longName; 3850 hidl_string shortName; 3851 hidl_string numeric; 3852 int numStrings = responseLen / sizeof(char *); 3853 if (response == NULL || numStrings != 3) { 3854 RLOGE("getOperatorResponse Invalid response: NULL"); 3855 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3856 3857 } else { 3858 char **resp = (char **) response; 3859 longName = convertCharPtrToHidlString(resp[0]); 3860 shortName = convertCharPtrToHidlString(resp[1]); 3861 numeric = convertCharPtrToHidlString(resp[2]); 3862 } 3863 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse( 3864 responseInfo, longName, shortName, numeric); 3865 radioService[slotId]->checkReturnStatus(retStatus); 3866 } else { 3867 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL", 3868 slotId); 3869 } 3870 3871 return 0; 3872} 3873 3874int radio::setRadioPowerResponse(int slotId, 3875 int responseType, int serial, RIL_Errno e, void *response, 3876 size_t responseLen) { 3877 RLOGD("setRadioPowerResponse: serial %d", serial); 3878 3879 if (radioService[slotId]->mRadioResponse != NULL) { 3880 RadioResponseInfo responseInfo = {}; 3881 populateResponseInfo(responseInfo, serial, responseType, e); 3882 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse( 3883 responseInfo); 3884 radioService[slotId]->checkReturnStatus(retStatus); 3885 } else { 3886 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL", 3887 slotId); 3888 } 3889 3890 return 0; 3891} 3892 3893int radio::sendDtmfResponse(int slotId, 3894 int responseType, int serial, RIL_Errno e, void *response, 3895 size_t responseLen) { 3896#if VDBG 3897 RLOGD("sendDtmfResponse: serial %d", serial); 3898#endif 3899 3900 if (radioService[slotId]->mRadioResponse != NULL) { 3901 RadioResponseInfo responseInfo = {}; 3902 populateResponseInfo(responseInfo, serial, responseType, e); 3903 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse( 3904 responseInfo); 3905 radioService[slotId]->checkReturnStatus(retStatus); 3906 } else { 3907 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL", 3908 slotId); 3909 } 3910 3911 return 0; 3912} 3913 3914SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType, 3915 RIL_Errno e, void *response, size_t responseLen) { 3916 populateResponseInfo(responseInfo, serial, responseType, e); 3917 SendSmsResult result = {}; 3918 3919 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) { 3920 RLOGE("Invalid response: NULL"); 3921 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3922 result.ackPDU = hidl_string(); 3923 } else { 3924 RIL_SMS_Response *resp = (RIL_SMS_Response *) response; 3925 result.messageRef = resp->messageRef; 3926 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU); 3927 result.errorCode = resp->errorCode; 3928 } 3929 return result; 3930} 3931 3932int radio::sendSmsResponse(int slotId, 3933 int responseType, int serial, RIL_Errno e, void *response, 3934 size_t responseLen) { 3935#if VDBG 3936 RLOGD("sendSmsResponse: serial %d", serial); 3937#endif 3938 3939 if (radioService[slotId]->mRadioResponse != NULL) { 3940 RadioResponseInfo responseInfo = {}; 3941 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response, 3942 responseLen); 3943 3944 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo, 3945 result); 3946 radioService[slotId]->checkReturnStatus(retStatus); 3947 } else { 3948 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3949 } 3950 3951 return 0; 3952} 3953 3954int radio::sendSMSExpectMoreResponse(int slotId, 3955 int responseType, int serial, RIL_Errno e, void *response, 3956 size_t responseLen) { 3957#if VDBG 3958 RLOGD("sendSMSExpectMoreResponse: serial %d", serial); 3959#endif 3960 3961 if (radioService[slotId]->mRadioResponse != NULL) { 3962 RadioResponseInfo responseInfo = {}; 3963 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response, 3964 responseLen); 3965 3966 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse( 3967 responseInfo, result); 3968 radioService[slotId]->checkReturnStatus(retStatus); 3969 } else { 3970 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId); 3971 } 3972 3973 return 0; 3974} 3975 3976int radio::setupDataCallResponse(int slotId, 3977 int responseType, int serial, RIL_Errno e, void *response, 3978 size_t responseLen) { 3979#if VDBG 3980 RLOGD("setupDataCallResponse: serial %d", serial); 3981#endif 3982 3983 if (radioService[slotId]->mRadioResponse != NULL) { 3984 RadioResponseInfo responseInfo = {}; 3985 populateResponseInfo(responseInfo, serial, responseType, e); 3986 3987 SetupDataCallResult result = {}; 3988 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) { 3989 if (response != NULL) { 3990 RLOGE("setupDataCallResponse: Invalid response"); 3991 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 3992 } 3993 result.status = DataCallFailCause::ERROR_UNSPECIFIED; 3994 result.type = hidl_string(); 3995 result.ifname = hidl_string(); 3996 result.addresses = hidl_string(); 3997 result.dnses = hidl_string(); 3998 result.gateways = hidl_string(); 3999 result.pcscf = hidl_string(); 4000 } else { 4001 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result); 4002 } 4003 4004 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse( 4005 responseInfo, result); 4006 radioService[slotId]->checkReturnStatus(retStatus); 4007 } else { 4008 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4009 } 4010 4011 return 0; 4012} 4013 4014IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType, 4015 RIL_Errno e, void *response, size_t responseLen) { 4016 populateResponseInfo(responseInfo, serial, responseType, e); 4017 IccIoResult result = {}; 4018 4019 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) { 4020 RLOGE("Invalid response: NULL"); 4021 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4022 result.simResponse = hidl_string(); 4023 } else { 4024 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response; 4025 result.sw1 = resp->sw1; 4026 result.sw2 = resp->sw2; 4027 result.simResponse = convertCharPtrToHidlString(resp->simResponse); 4028 } 4029 return result; 4030} 4031 4032int radio::iccIOForAppResponse(int slotId, 4033 int responseType, int serial, RIL_Errno e, void *response, 4034 size_t responseLen) { 4035#if VDBG 4036 RLOGD("iccIOForAppResponse: serial %d", serial); 4037#endif 4038 4039 if (radioService[slotId]->mRadioResponse != NULL) { 4040 RadioResponseInfo responseInfo = {}; 4041 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response, 4042 responseLen); 4043 4044 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse( 4045 responseInfo, result); 4046 radioService[slotId]->checkReturnStatus(retStatus); 4047 } else { 4048 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4049 } 4050 4051 return 0; 4052} 4053 4054int radio::sendUssdResponse(int slotId, 4055 int responseType, int serial, RIL_Errno e, void *response, 4056 size_t responseLen) { 4057#if VDBG 4058 RLOGD("sendUssdResponse: serial %d", serial); 4059#endif 4060 4061 if (radioService[slotId]->mRadioResponse != NULL) { 4062 RadioResponseInfo responseInfo = {}; 4063 populateResponseInfo(responseInfo, serial, responseType, e); 4064 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse( 4065 responseInfo); 4066 radioService[slotId]->checkReturnStatus(retStatus); 4067 } else { 4068 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL", 4069 slotId); 4070 } 4071 4072 return 0; 4073} 4074 4075int radio::cancelPendingUssdResponse(int slotId, 4076 int responseType, int serial, RIL_Errno e, void *response, 4077 size_t responseLen) { 4078#if VDBG 4079 RLOGD("cancelPendingUssdResponse: serial %d", serial); 4080#endif 4081 4082 if (radioService[slotId]->mRadioResponse != NULL) { 4083 RadioResponseInfo responseInfo = {}; 4084 populateResponseInfo(responseInfo, serial, responseType, e); 4085 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse( 4086 responseInfo); 4087 radioService[slotId]->checkReturnStatus(retStatus); 4088 } else { 4089 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL", 4090 slotId); 4091 } 4092 4093 return 0; 4094} 4095 4096int radio::getClirResponse(int slotId, 4097 int responseType, int serial, RIL_Errno e, void *response, 4098 size_t responseLen) { 4099#if VDBG 4100 RLOGD("getClirResponse: serial %d", serial); 4101#endif 4102 4103 if (radioService[slotId]->mRadioResponse != NULL) { 4104 RadioResponseInfo responseInfo = {}; 4105 populateResponseInfo(responseInfo, serial, responseType, e); 4106 int n = -1, m = -1; 4107 int numInts = responseLen / sizeof(int); 4108 if (response == NULL || numInts != 2) { 4109 RLOGE("getClirResponse Invalid response: NULL"); 4110 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4111 } else { 4112 int *pInt = (int *) response; 4113 n = pInt[0]; 4114 m = pInt[1]; 4115 } 4116 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo, 4117 n, m); 4118 radioService[slotId]->checkReturnStatus(retStatus); 4119 } else { 4120 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4121 } 4122 4123 return 0; 4124} 4125 4126int radio::setClirResponse(int slotId, 4127 int responseType, int serial, RIL_Errno e, void *response, 4128 size_t responseLen) { 4129#if VDBG 4130 RLOGD("setClirResponse: serial %d", serial); 4131#endif 4132 4133 if (radioService[slotId]->mRadioResponse != NULL) { 4134 RadioResponseInfo responseInfo = {}; 4135 populateResponseInfo(responseInfo, serial, responseType, e); 4136 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse( 4137 responseInfo); 4138 radioService[slotId]->checkReturnStatus(retStatus); 4139 } else { 4140 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4141 } 4142 4143 return 0; 4144} 4145 4146int radio::getCallForwardStatusResponse(int slotId, 4147 int responseType, int serial, RIL_Errno e, 4148 void *response, size_t responseLen) { 4149#if VDBG 4150 RLOGD("getCallForwardStatusResponse: serial %d", serial); 4151#endif 4152 4153 if (radioService[slotId]->mRadioResponse != NULL) { 4154 RadioResponseInfo responseInfo = {}; 4155 populateResponseInfo(responseInfo, serial, responseType, e); 4156 hidl_vec<CallForwardInfo> callForwardInfos; 4157 4158 if ((response == NULL && responseLen != 0) 4159 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) { 4160 RLOGE("getCallForwardStatusResponse Invalid response: NULL"); 4161 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4162 } else { 4163 int num = responseLen / sizeof(RIL_CallForwardInfo *); 4164 callForwardInfos.resize(num); 4165 for (int i = 0 ; i < num; i++) { 4166 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i]; 4167 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status; 4168 callForwardInfos[i].reason = resp->reason; 4169 callForwardInfos[i].serviceClass = resp->serviceClass; 4170 callForwardInfos[i].toa = resp->toa; 4171 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number); 4172 callForwardInfos[i].timeSeconds = resp->timeSeconds; 4173 } 4174 } 4175 4176 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse( 4177 responseInfo, callForwardInfos); 4178 radioService[slotId]->checkReturnStatus(retStatus); 4179 } else { 4180 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL", 4181 slotId); 4182 } 4183 4184 return 0; 4185} 4186 4187int radio::setCallForwardResponse(int slotId, 4188 int responseType, int serial, RIL_Errno e, void *response, 4189 size_t responseLen) { 4190#if VDBG 4191 RLOGD("setCallForwardResponse: serial %d", serial); 4192#endif 4193 4194 if (radioService[slotId]->mRadioResponse != NULL) { 4195 RadioResponseInfo responseInfo = {}; 4196 populateResponseInfo(responseInfo, serial, responseType, e); 4197 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse( 4198 responseInfo); 4199 radioService[slotId]->checkReturnStatus(retStatus); 4200 } else { 4201 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4202 } 4203 4204 return 0; 4205} 4206 4207int radio::getCallWaitingResponse(int slotId, 4208 int responseType, int serial, RIL_Errno e, void *response, 4209 size_t responseLen) { 4210#if VDBG 4211 RLOGD("getCallWaitingResponse: serial %d", serial); 4212#endif 4213 4214 if (radioService[slotId]->mRadioResponse != NULL) { 4215 RadioResponseInfo responseInfo = {}; 4216 populateResponseInfo(responseInfo, serial, responseType, e); 4217 bool enable = false; 4218 int serviceClass = -1; 4219 int numInts = responseLen / sizeof(int); 4220 if (response == NULL || numInts != 2) { 4221 RLOGE("getCallWaitingResponse Invalid response: NULL"); 4222 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4223 } else { 4224 int *pInt = (int *) response; 4225 enable = pInt[0] == 1 ? true : false; 4226 serviceClass = pInt[1]; 4227 } 4228 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse( 4229 responseInfo, enable, serviceClass); 4230 radioService[slotId]->checkReturnStatus(retStatus); 4231 } else { 4232 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4233 } 4234 4235 return 0; 4236} 4237 4238int radio::setCallWaitingResponse(int slotId, 4239 int responseType, int serial, RIL_Errno e, void *response, 4240 size_t responseLen) { 4241#if VDBG 4242 RLOGD("setCallWaitingResponse: serial %d", serial); 4243#endif 4244 4245 if (radioService[slotId]->mRadioResponse != NULL) { 4246 RadioResponseInfo responseInfo = {}; 4247 populateResponseInfo(responseInfo, serial, responseType, e); 4248 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse( 4249 responseInfo); 4250 radioService[slotId]->checkReturnStatus(retStatus); 4251 } else { 4252 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4253 } 4254 4255 return 0; 4256} 4257 4258int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId, 4259 int responseType, int serial, RIL_Errno e, 4260 void *response, size_t responseLen) { 4261#if VDBG 4262 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial); 4263#endif 4264 4265 if (radioService[slotId]->mRadioResponse != NULL) { 4266 RadioResponseInfo responseInfo = {}; 4267 populateResponseInfo(responseInfo, serial, responseType, e); 4268 Return<void> retStatus = 4269 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse( 4270 responseInfo); 4271 radioService[slotId]->checkReturnStatus(retStatus); 4272 } else { 4273 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse " 4274 "== NULL", slotId); 4275 } 4276 4277 return 0; 4278} 4279 4280int radio::acceptCallResponse(int slotId, 4281 int responseType, int serial, RIL_Errno e, 4282 void *response, size_t responseLen) { 4283#if VDBG 4284 RLOGD("acceptCallResponse: serial %d", serial); 4285#endif 4286 4287 if (radioService[slotId]->mRadioResponse != NULL) { 4288 RadioResponseInfo responseInfo = {}; 4289 populateResponseInfo(responseInfo, serial, responseType, e); 4290 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse( 4291 responseInfo); 4292 radioService[slotId]->checkReturnStatus(retStatus); 4293 } else { 4294 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL", 4295 slotId); 4296 } 4297 4298 return 0; 4299} 4300 4301int radio::deactivateDataCallResponse(int slotId, 4302 int responseType, int serial, RIL_Errno e, 4303 void *response, size_t responseLen) { 4304#if VDBG 4305 RLOGD("deactivateDataCallResponse: serial %d", serial); 4306#endif 4307 4308 if (radioService[slotId]->mRadioResponse != NULL) { 4309 RadioResponseInfo responseInfo = {}; 4310 populateResponseInfo(responseInfo, serial, responseType, e); 4311 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse( 4312 responseInfo); 4313 radioService[slotId]->checkReturnStatus(retStatus); 4314 } else { 4315 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL", 4316 slotId); 4317 } 4318 4319 return 0; 4320} 4321 4322int radio::getFacilityLockForAppResponse(int slotId, 4323 int responseType, int serial, RIL_Errno e, 4324 void *response, size_t responseLen) { 4325#if VDBG 4326 RLOGD("getFacilityLockForAppResponse: serial %d", serial); 4327#endif 4328 4329 if (radioService[slotId]->mRadioResponse != NULL) { 4330 RadioResponseInfo responseInfo = {}; 4331 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen); 4332 Return<void> retStatus = radioService[slotId]->mRadioResponse-> 4333 getFacilityLockForAppResponse(responseInfo, ret); 4334 radioService[slotId]->checkReturnStatus(retStatus); 4335 } else { 4336 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL", 4337 slotId); 4338 } 4339 4340 return 0; 4341} 4342 4343int radio::setFacilityLockForAppResponse(int slotId, 4344 int responseType, int serial, RIL_Errno e, 4345 void *response, size_t responseLen) { 4346#if VDBG 4347 RLOGD("setFacilityLockForAppResponse: serial %d", serial); 4348#endif 4349 4350 if (radioService[slotId]->mRadioResponse != NULL) { 4351 RadioResponseInfo responseInfo = {}; 4352 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen); 4353 Return<void> retStatus 4354 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo, 4355 ret); 4356 radioService[slotId]->checkReturnStatus(retStatus); 4357 } else { 4358 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL", 4359 slotId); 4360 } 4361 4362 return 0; 4363} 4364 4365int radio::setBarringPasswordResponse(int slotId, 4366 int responseType, int serial, RIL_Errno e, 4367 void *response, size_t responseLen) { 4368#if VDBG 4369 RLOGD("acceptCallResponse: serial %d", serial); 4370#endif 4371 4372 if (radioService[slotId]->mRadioResponse != NULL) { 4373 RadioResponseInfo responseInfo = {}; 4374 populateResponseInfo(responseInfo, serial, responseType, e); 4375 Return<void> retStatus 4376 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo); 4377 radioService[slotId]->checkReturnStatus(retStatus); 4378 } else { 4379 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL", 4380 slotId); 4381 } 4382 4383 return 0; 4384} 4385 4386int radio::getNetworkSelectionModeResponse(int slotId, 4387 int responseType, int serial, RIL_Errno e, void *response, 4388 size_t responseLen) { 4389#if VDBG 4390 RLOGD("getNetworkSelectionModeResponse: serial %d", serial); 4391#endif 4392 4393 if (radioService[slotId]->mRadioResponse != NULL) { 4394 RadioResponseInfo responseInfo = {}; 4395 populateResponseInfo(responseInfo, serial, responseType, e); 4396 bool manual = false; 4397 int serviceClass; 4398 if (response == NULL || responseLen != sizeof(int)) { 4399 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL"); 4400 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4401 } else { 4402 int *pInt = (int *) response; 4403 manual = pInt[0] == 1 ? true : false; 4404 } 4405 Return<void> retStatus 4406 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse( 4407 responseInfo, 4408 manual); 4409 radioService[slotId]->checkReturnStatus(retStatus); 4410 } else { 4411 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL", 4412 slotId); 4413 } 4414 4415 return 0; 4416} 4417 4418int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial, 4419 RIL_Errno e, void *response, 4420 size_t responseLen) { 4421#if VDBG 4422 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial); 4423#endif 4424 4425 if (radioService[slotId]->mRadioResponse != NULL) { 4426 RadioResponseInfo responseInfo = {}; 4427 populateResponseInfo(responseInfo, serial, responseType, e); 4428 Return<void> retStatus 4429 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse( 4430 responseInfo); 4431 radioService[slotId]->checkReturnStatus(retStatus); 4432 } else { 4433 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse " 4434 "== NULL", slotId); 4435 } 4436 4437 return 0; 4438} 4439 4440int radio::setNetworkSelectionModeManualResponse(int slotId, 4441 int responseType, int serial, RIL_Errno e, 4442 void *response, size_t responseLen) { 4443#if VDBG 4444 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial); 4445#endif 4446 4447 if (radioService[slotId]->mRadioResponse != NULL) { 4448 RadioResponseInfo responseInfo = {}; 4449 populateResponseInfo(responseInfo, serial, responseType, e); 4450 Return<void> retStatus 4451 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse( 4452 responseInfo); 4453 radioService[slotId]->checkReturnStatus(retStatus); 4454 } else { 4455 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse " 4456 "== NULL", slotId); 4457 } 4458 4459 return 0; 4460} 4461 4462int convertOperatorStatusToInt(const char *str) { 4463 if (strncmp("unknown", str, 9) == 0) { 4464 return (int) OperatorStatus::UNKNOWN; 4465 } else if (strncmp("available", str, 9) == 0) { 4466 return (int) OperatorStatus::AVAILABLE; 4467 } else if (strncmp("current", str, 9) == 0) { 4468 return (int) OperatorStatus::CURRENT; 4469 } else if (strncmp("forbidden", str, 9) == 0) { 4470 return (int) OperatorStatus::FORBIDDEN; 4471 } else { 4472 return -1; 4473 } 4474} 4475 4476int radio::getAvailableNetworksResponse(int slotId, 4477 int responseType, int serial, RIL_Errno e, void *response, 4478 size_t responseLen) { 4479#if VDBG 4480 RLOGD("getAvailableNetworksResponse: serial %d", serial); 4481#endif 4482 4483 if (radioService[slotId]->mRadioResponse != NULL) { 4484 RadioResponseInfo responseInfo = {}; 4485 populateResponseInfo(responseInfo, serial, responseType, e); 4486 hidl_vec<OperatorInfo> networks; 4487 if ((response == NULL && responseLen != 0) 4488 || responseLen % (4 * sizeof(char *))!= 0) { 4489 RLOGE("getAvailableNetworksResponse Invalid response: NULL"); 4490 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4491 } else { 4492 char **resp = (char **) response; 4493 int numStrings = responseLen / sizeof(char *); 4494 networks.resize(numStrings/4); 4495 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) { 4496 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]); 4497 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]); 4498 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]); 4499 int status = convertOperatorStatusToInt(resp[i + 3]); 4500 if (status == -1) { 4501 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE; 4502 } else { 4503 networks[j].status = (OperatorStatus) status; 4504 } 4505 } 4506 } 4507 Return<void> retStatus 4508 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo, 4509 networks); 4510 radioService[slotId]->checkReturnStatus(retStatus); 4511 } else { 4512 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL", 4513 slotId); 4514 } 4515 4516 return 0; 4517} 4518 4519int radio::startDtmfResponse(int slotId, 4520 int responseType, int serial, RIL_Errno e, 4521 void *response, size_t responseLen) { 4522#if VDBG 4523 RLOGD("startDtmfResponse: serial %d", serial); 4524#endif 4525 4526 if (radioService[slotId]->mRadioResponse != NULL) { 4527 RadioResponseInfo responseInfo = {}; 4528 populateResponseInfo(responseInfo, serial, responseType, e); 4529 Return<void> retStatus 4530 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo); 4531 radioService[slotId]->checkReturnStatus(retStatus); 4532 } else { 4533 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4534 } 4535 4536 return 0; 4537} 4538 4539int radio::stopDtmfResponse(int slotId, 4540 int responseType, int serial, RIL_Errno e, 4541 void *response, size_t responseLen) { 4542#if VDBG 4543 RLOGD("stopDtmfResponse: serial %d", serial); 4544#endif 4545 4546 if (radioService[slotId]->mRadioResponse != NULL) { 4547 RadioResponseInfo responseInfo = {}; 4548 populateResponseInfo(responseInfo, serial, responseType, e); 4549 Return<void> retStatus 4550 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo); 4551 radioService[slotId]->checkReturnStatus(retStatus); 4552 } else { 4553 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4554 } 4555 4556 return 0; 4557} 4558 4559int radio::getBasebandVersionResponse(int slotId, 4560 int responseType, int serial, RIL_Errno e, 4561 void *response, size_t responseLen) { 4562#if VDBG 4563 RLOGD("getBasebandVersionResponse: serial %d", serial); 4564#endif 4565 4566 if (radioService[slotId]->mRadioResponse != NULL) { 4567 RadioResponseInfo responseInfo = {}; 4568 populateResponseInfo(responseInfo, serial, responseType, e); 4569 Return<void> retStatus 4570 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo, 4571 convertCharPtrToHidlString((char *) response)); 4572 radioService[slotId]->checkReturnStatus(retStatus); 4573 } else { 4574 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4575 } 4576 4577 return 0; 4578} 4579 4580int radio::separateConnectionResponse(int slotId, 4581 int responseType, int serial, RIL_Errno e, 4582 void *response, size_t responseLen) { 4583#if VDBG 4584 RLOGD("separateConnectionResponse: serial %d", serial); 4585#endif 4586 4587 if (radioService[slotId]->mRadioResponse != NULL) { 4588 RadioResponseInfo responseInfo = {}; 4589 populateResponseInfo(responseInfo, serial, responseType, e); 4590 Return<void> retStatus 4591 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo); 4592 radioService[slotId]->checkReturnStatus(retStatus); 4593 } else { 4594 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL", 4595 slotId); 4596 } 4597 4598 return 0; 4599} 4600 4601int radio::setMuteResponse(int slotId, 4602 int responseType, int serial, RIL_Errno e, 4603 void *response, size_t responseLen) { 4604#if VDBG 4605 RLOGD("setMuteResponse: serial %d", serial); 4606#endif 4607 4608 if (radioService[slotId]->mRadioResponse != NULL) { 4609 RadioResponseInfo responseInfo = {}; 4610 populateResponseInfo(responseInfo, serial, responseType, e); 4611 Return<void> retStatus 4612 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo); 4613 radioService[slotId]->checkReturnStatus(retStatus); 4614 } else { 4615 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId); 4616 } 4617 4618 return 0; 4619} 4620 4621int radio::getMuteResponse(int slotId, 4622 int responseType, int serial, RIL_Errno e, void *response, 4623 size_t responseLen) { 4624#if VDBG 4625 RLOGD("getMuteResponse: serial %d", serial); 4626#endif 4627 4628 if (radioService[slotId]->mRadioResponse != NULL) { 4629 RadioResponseInfo responseInfo = {}; 4630 populateResponseInfo(responseInfo, serial, responseType, e); 4631 bool enable = false; 4632 int serviceClass; 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