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