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