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