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 "RefImsMedia.h"
20 #include "RefRadioIms.h"
21 #include "RefRadioModem.h"
22 #include "RefRadioNetwork.h"
23 #include "RefRadioSim.h"
24
25 #include <android-base/logging.h>
26 #include <android/binder_manager.h>
27 #include <android/binder_process.h>
28
29 #pragma clang diagnostic push
30 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
31 #include <android/hardware/radio/1.6/IRadio.h>
32 #include <android/hardware/radio/1.6/IRadioIndication.h>
33 #include <android/hardware/radio/1.6/IRadioResponse.h>
34 #include <android/hardware/radio/1.6/types.h>
35 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
36 #include <libradiocompat/CallbackManager.h>
37 #include <libradiocompat/RadioData.h>
38 #include <libradiocompat/RadioIms.h>
39 #include <libradiocompat/RadioImsMedia.h>
40 #include <libradiocompat/RadioMessaging.h>
41 #include <libradiocompat/RadioModem.h>
42 #include <libradiocompat/RadioSim.h>
43 #include <libradiocompat/RadioVoice.h>
44 #pragma clang diagnostic pop
45
46 #include <hwbinder/IPCThreadState.h>
47 #include <hwbinder/ProcessState.h>
48 #include <guest/hals/ril/reference-libril/ril.h>
49 #include <telephony/ril_mnc.h>
50 #include <guest/hals/ril/reference-libril/ril_service.h>
51 #include <hidl/HidlTransportSupport.h>
52 #include <utils/SystemClock.h>
53 #include <inttypes.h>
54
55 #define INVALID_HEX_CHAR 16
56
57 using namespace android::hardware::radio;
58 using namespace android::hardware::radio::V1_0;
59 using namespace android::hardware::radio::deprecated::V1_0;
60 using namespace std::string_literals;
61 namespace compat = android::hardware::radio::compat;
62 using ::android::hardware::Return;
63 using ::android::hardware::hidl_bitfield;
64 using ::android::hardware::hidl_string;
65 using ::android::hardware::hidl_vec;
66 using ::android::hardware::hidl_array;
67 using ::android::hardware::Void;
68 using android::CommandInfo;
69 using android::RequestInfo;
70 using android::requestToString;
71 using android::sp;
72
73 using RegStateResultV1_6 = android::hardware::radio::V1_6::RegStateResult;
74 using RegStateResultV1_5 = android::hardware::radio::V1_5::RegStateResult;
75 using PhysicalChannelConfigV1_4 =
76 android::hardware::radio::V1_4::PhysicalChannelConfig;
77 using RadioTechnologyV1_4 = android::hardware::radio::V1_4::RadioTechnology;
78
79 namespace aidl_radio = ::aidl::android::hardware::radio;
80
81 #define BOOL_TO_INT(x) (x ? 1 : 0)
82 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
83 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
84
85 #if defined(ANDROID_MULTI_SIM)
86 #define CALL_ONREQUEST(a, b, c, d, e) \
87 s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e)))
88 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a))
89 #else
90 #define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d))
91 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
92 #endif
93
94 #ifdef OEM_HOOK_DISABLED
95 constexpr bool kOemHookEnabled = false;
96 #else
97 constexpr bool kOemHookEnabled = true;
98 #endif
99
100 RIL_RadioFunctions *s_vendorFunctions = NULL;
101 static CommandInfo *s_commands;
102
103 struct RadioImpl_1_6;
104 struct OemHookImpl;
105
106 #if (SIM_COUNT >= 2)
107 sp<RadioImpl_1_6> radioService[SIM_COUNT];
108 sp<OemHookImpl> oemHookService[SIM_COUNT];
109 int64_t nitzTimeReceived[SIM_COUNT];
110 // counter used for synchronization. It is incremented every time response callbacks are updated.
111 std::atomic_int32_t mCounterRadio[SIM_COUNT];
112 std::atomic_int32_t mCounterOemHook[SIM_COUNT];
113 #else
114 sp<RadioImpl_1_6> radioService[1];
115 sp<OemHookImpl> oemHookService[1];
116 int64_t nitzTimeReceived[1];
117 // counter used for synchronization. It is incremented every time response callbacks are updated.
118 std::atomic_int32_t mCounterRadio[1];
119 std::atomic_int32_t mCounterOemHook[1];
120 hidl_vec<uint8_t> osAppIdVec;
121 #endif
122
123 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
124
125 #if (SIM_COUNT >= 2)
126 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
127 #if (SIM_COUNT >= 3)
128 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
129 #if (SIM_COUNT >= 4)
130 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
131 #endif
132 #endif
133 #endif
134
135 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
136 hidl_vec<HardwareConfig>& records);
137
138 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
139
140 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
141
142 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
143 SignalStrength& signalStrength);
144
145 void convertRilSignalStrengthToHal_1_2(void* response, size_t responseLen,
146 V1_2::SignalStrength& signalStrength);
147
148 void convertRilSignalStrengthToHal_1_4(void *response, size_t responseLen,
149 V1_4::SignalStrength& signalStrength);
150
151 void convertRilSignalStrengthToHal_1_6(void* response, size_t responseLen,
152 V1_6::SignalStrength& signalStrength);
153
154 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse, SetupDataCallResult& dcResult);
155
156 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
157 V1_4::SetupDataCallResult& dcResult);
158
159 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
160 V1_5::SetupDataCallResult& dcResult);
161
162 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
163 V1_6::SetupDataCallResult& dcResult);
164
165 void convertRilDataCallListToHal(void *response, size_t responseLen,
166 hidl_vec<SetupDataCallResult>& dcResultList);
167
168 void convertRilDataCallListToHal_1_4(void* response, size_t responseLen,
169 hidl_vec<V1_4::SetupDataCallResult>& dcResultList);
170
171 void convertRilDataCallListToHal_1_5(void* response, size_t responseLen,
172 hidl_vec<V1_5::SetupDataCallResult>& dcResultList);
173
174 void convertRilDataCallListToHal_1_6(void* response, size_t responseLen,
175 hidl_vec<V1_6::SetupDataCallResult>& dcResultList);
176
177 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
178 void convertRilCellInfoListToHal_1_2(void *response, size_t responseLen, hidl_vec<V1_2::CellInfo>& records);
179 void convertRilCellInfoListToHal_1_4(void* response, size_t responseLen,
180 hidl_vec<V1_4::CellInfo>& records);
181 void convertRilCellInfoListToHal_1_5(void* response, size_t responseLen,
182 hidl_vec<V1_5::CellInfo>& records);
183 void convertRilCellInfoListToHal_1_6(void* response, size_t responseLen,
184 hidl_vec<V1_6::CellInfo>& records);
185
186 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
187 RIL_Errno e);
188
189 void populateResponseInfo_1_6(
190 ::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo,
191 int serial, int responseType, RIL_Errno e);
192
193 struct RadioImpl_1_6 : public V1_6::IRadio {
194 int32_t mSlotId;
195 V1_1::CardPowerState mSimCardPowerState;
196 sp<IRadioResponse> mRadioResponse;
197 sp<IRadioIndication> mRadioIndication;
198 sp<V1_1::IRadioResponse> mRadioResponseV1_1;
199 sp<V1_1::IRadioIndication> mRadioIndicationV1_1;
200 sp<V1_2::IRadioResponse> mRadioResponseV1_2;
201 sp<V1_2::IRadioIndication> mRadioIndicationV1_2;
202 sp<V1_3::IRadioResponse> mRadioResponseV1_3;
203 sp<V1_3::IRadioIndication> mRadioIndicationV1_3;
204 sp<V1_4::IRadioResponse> mRadioResponseV1_4;
205 sp<V1_4::IRadioIndication> mRadioIndicationV1_4;
206 sp<V1_5::IRadioResponse> mRadioResponseV1_5;
207 sp<V1_5::IRadioIndication> mRadioIndicationV1_5;
208 sp<V1_6::IRadioResponse> mRadioResponseV1_6;
209 sp<V1_6::IRadioIndication> mRadioIndicationV1_6;
210 std::shared_ptr<compat::CallbackManager> mCallbackManager;
211
212 Return<void> setResponseFunctions(
213 const ::android::sp<IRadioResponse>& radioResponse,
214 const ::android::sp<IRadioIndication>& radioIndication);
215
216 Return<void> getIccCardStatus(int32_t serial);
217
218 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
219 const hidl_string& aid);
220
221 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
222 const hidl_string& pin, const hidl_string& aid);
223
224 Return<void> supplyIccPin2ForApp(int32_t serial,
225 const hidl_string& pin2,
226 const hidl_string& aid);
227
228 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
229 const hidl_string& pin2, const hidl_string& aid);
230
231 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
232 const hidl_string& newPin, const hidl_string& aid);
233
234 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
235 const hidl_string& newPin2, const hidl_string& aid);
236
237 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
238
239 Return<void> getCurrentCalls(int32_t serial);
240
241 Return<void> getCurrentCalls_1_6(int32_t serial);
242
243 Return<void> dial(int32_t serial, const Dial& dialInfo);
244
245 Return<void> getImsiForApp(int32_t serial,
246 const ::android::hardware::hidl_string& aid);
247
248 Return<void> hangup(int32_t serial, int32_t gsmIndex);
249
250 Return<void> hangupWaitingOrBackground(int32_t serial);
251
252 Return<void> hangupForegroundResumeBackground(int32_t serial);
253
254 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
255
256 Return<void> conference(int32_t serial);
257
258 Return<void> rejectCall(int32_t serial);
259
260 Return<void> getLastCallFailCause(int32_t serial);
261
262 Return<void> getSignalStrength(int32_t serial);
263
264 Return<void> getSignalStrength_1_6(int32_t serial);
265
266 Return<void> getVoiceRegistrationState(int32_t serial);
267
268 Return<void> getDataRegistrationState(int32_t serial);
269
270 Return<void> getOperator(int32_t serial);
271
272 Return<void> setRadioPower(int32_t serial, bool on);
273
274 Return<void> sendDtmf(int32_t serial,
275 const ::android::hardware::hidl_string& s);
276
277 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
278
279 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
280
281 Return<void> setupDataCall(int32_t serial,
282 RadioTechnology radioTechnology,
283 const DataProfileInfo& profileInfo,
284 bool modemCognitive,
285 bool roamingAllowed,
286 bool isRoaming);
287
288 Return<void> iccIOForApp(int32_t serial,
289 const IccIo& iccIo);
290
291 Return<void> sendUssd(int32_t serial,
292 const ::android::hardware::hidl_string& ussd);
293
294 Return<void> cancelPendingUssd(int32_t serial);
295
296 Return<void> getClir(int32_t serial);
297
298 Return<void> setClir(int32_t serial, int32_t status);
299
300 Return<void> getCallForwardStatus(int32_t serial,
301 const CallForwardInfo& callInfo);
302
303 Return<void> setCallForward(int32_t serial,
304 const CallForwardInfo& callInfo);
305
306 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
307
308 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
309
310 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
311 bool success, SmsAcknowledgeFailCause cause);
312
313 Return<void> acceptCall(int32_t serial);
314
315 Return<void> deactivateDataCall(int32_t serial,
316 int32_t cid, bool reasonRadioShutDown);
317
318 Return<void> getFacilityLockForApp(int32_t serial,
319 const ::android::hardware::hidl_string& facility,
320 const ::android::hardware::hidl_string& password,
321 int32_t serviceClass,
322 const ::android::hardware::hidl_string& appId);
323
324 Return<void> setFacilityLockForApp(int32_t serial,
325 const ::android::hardware::hidl_string& facility,
326 bool lockState,
327 const ::android::hardware::hidl_string& password,
328 int32_t serviceClass,
329 const ::android::hardware::hidl_string& appId);
330
331 Return<void> setBarringPassword(int32_t serial,
332 const ::android::hardware::hidl_string& facility,
333 const ::android::hardware::hidl_string& oldPassword,
334 const ::android::hardware::hidl_string& newPassword);
335
336 Return<void> getNetworkSelectionMode(int32_t serial);
337
338 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
339
340 Return<void> setNetworkSelectionModeManual(int32_t serial,
341 const ::android::hardware::hidl_string& operatorNumeric);
342
343 Return<void> getAvailableNetworks(int32_t serial);
344
345 Return<void> startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request);
346
347 Return<void> stopNetworkScan(int32_t serial);
348
349 Return<void> startDtmf(int32_t serial,
350 const ::android::hardware::hidl_string& s);
351
352 Return<void> stopDtmf(int32_t serial);
353
354 Return<void> getBasebandVersion(int32_t serial);
355
356 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
357
358 Return<void> setMute(int32_t serial, bool enable);
359
360 Return<void> getMute(int32_t serial);
361
362 Return<void> getClip(int32_t serial);
363
364 Return<void> getDataCallList(int32_t serial);
365
366 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
367
368 Return<void> writeSmsToSim(int32_t serial,
369 const SmsWriteArgs& smsWriteArgs);
370
371 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
372
373 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
374
375 Return<void> getAvailableBandModes(int32_t serial);
376
377 Return<void> sendEnvelope(int32_t serial,
378 const ::android::hardware::hidl_string& command);
379
380 Return<void> sendTerminalResponseToSim(int32_t serial,
381 const ::android::hardware::hidl_string& commandResponse);
382
383 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
384
385 Return<void> explicitCallTransfer(int32_t serial);
386
387 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
388
389 Return<void> getPreferredNetworkType(int32_t serial);
390
391 Return<void> getNeighboringCids(int32_t serial);
392
393 Return<void> setLocationUpdates(int32_t serial, bool enable);
394
395 Return<void> setCdmaSubscriptionSource(int32_t serial,
396 CdmaSubscriptionSource cdmaSub);
397
398 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
399
400 Return<void> getCdmaRoamingPreference(int32_t serial);
401
402 Return<void> setTTYMode(int32_t serial, TtyMode mode);
403
404 Return<void> getTTYMode(int32_t serial);
405
406 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
407
408 Return<void> getPreferredVoicePrivacy(int32_t serial);
409
410 Return<void> sendCDMAFeatureCode(int32_t serial,
411 const ::android::hardware::hidl_string& featureCode);
412
413 Return<void> sendBurstDtmf(int32_t serial,
414 const ::android::hardware::hidl_string& dtmf,
415 int32_t on,
416 int32_t off);
417
418 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
419
420 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
421 const CdmaSmsAck& smsAck);
422
423 Return<void> getGsmBroadcastConfig(int32_t serial);
424
425 Return<void> setGsmBroadcastConfig(int32_t serial,
426 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
427
428 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
429
430 Return<void> getCdmaBroadcastConfig(int32_t serial);
431
432 Return<void> setCdmaBroadcastConfig(int32_t serial,
433 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
434
435 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
436
437 Return<void> getCDMASubscription(int32_t serial);
438
439 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
440
441 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
442
443 Return<void> getDeviceIdentity(int32_t serial);
444
445 Return<void> exitEmergencyCallbackMode(int32_t serial);
446
447 Return<void> getSmscAddress(int32_t serial);
448
449 Return<void> setSmscAddress(int32_t serial,
450 const ::android::hardware::hidl_string& smsc);
451
452 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
453
454 Return<void> reportStkServiceIsRunning(int32_t serial);
455
456 Return<void> getCdmaSubscriptionSource(int32_t serial);
457
458 Return<void> requestIsimAuthentication(int32_t serial,
459 const ::android::hardware::hidl_string& challenge);
460
461 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
462 bool success,
463 const ::android::hardware::hidl_string& ackPdu);
464
465 Return<void> sendEnvelopeWithStatus(int32_t serial,
466 const ::android::hardware::hidl_string& contents);
467
468 Return<void> getVoiceRadioTechnology(int32_t serial);
469
470 Return<void> getCellInfoList(int32_t serial);
471
472 Return<void> getCellInfoList_1_6(int32_t serial);
473
474 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
475
476 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
477 bool modemCognitive, bool isRoaming);
478
479 Return<void> getImsRegistrationState(int32_t serial);
480
481 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
482
483 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
484
485 Return<void> iccOpenLogicalChannel(int32_t serial,
486 const ::android::hardware::hidl_string& aid, int32_t p2);
487
488 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
489
490 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
491
492 Return<void> nvReadItem(int32_t serial, NvItem itemId);
493
494 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
495
496 Return<void> nvWriteCdmaPrl(int32_t serial,
497 const ::android::hardware::hidl_vec<uint8_t>& prl);
498
499 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
500
501 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
502
503 Return<void> setDataAllowed(int32_t serial, bool allow);
504
505 Return<void> getHardwareConfig(int32_t serial);
506
507 Return<void> requestIccSimAuthentication(int32_t serial,
508 int32_t authContext,
509 const ::android::hardware::hidl_string& authData,
510 const ::android::hardware::hidl_string& aid);
511
512 Return<void> setDataProfile(int32_t serial,
513 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
514
515 Return<void> requestShutdown(int32_t serial);
516
517 Return<void> getRadioCapability(int32_t serial);
518
519 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
520
521 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
522
523 Return<void> stopLceService(int32_t serial);
524
525 Return<void> pullLceData(int32_t serial);
526
527 Return<void> getModemActivityInfo(int32_t serial);
528
529 Return<void> setAllowedCarriers(int32_t serial,
530 bool allAllowed,
531 const CarrierRestrictions& carriers);
532
533 Return<void> getAllowedCarriers(int32_t serial);
534
535 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
536
537 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
538
539 Return<void> startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive);
540
541 Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
542
543 Return<void> setSimCardPower(int32_t serial, bool powerUp);
544 Return<void> setSimCardPower_1_1(int32_t serial,
545 const V1_1::CardPowerState state);
546 Return<void> setSimCardPower_1_6(int32_t serial,
547 const V1_1::CardPowerState state);
548
549 Return<void> responseAcknowledgement();
550
551 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
552 const V1_1::ImsiEncryptionInfo& message);
553
554 void checkReturnStatus(Return<void>& ret);
555
556 // Methods from ::android::hardware::radio::V1_2::IRadio follow.
557 Return<void> startNetworkScan_1_2(int32_t serial,
558 const ::android::hardware::radio::V1_2::NetworkScanRequest& request);
559 Return<void> setIndicationFilter_1_2(int32_t serial,
560 hidl_bitfield<::android::hardware::radio::V1_2::IndicationFilter> indicationFilter);
561 Return<void> setSignalStrengthReportingCriteria(int32_t serial, int32_t hysteresisMs,
562 int32_t hysteresisDb, const hidl_vec<int32_t>& thresholdsDbm,
563 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork);
564 Return<void> setLinkCapacityReportingCriteria(int32_t serial, int32_t hysteresisMs,
565 int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
566 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
567 const hidl_vec<int32_t>& thresholdsUplinkKbps,
568 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork);
569 Return<void> setupDataCall_1_2(int32_t serial,
570 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork,
571 const ::android::hardware::radio::V1_0::DataProfileInfo& dataProfileInfo,
572 bool modemCognitive, bool roamingAllowed, bool isRoaming,
573 ::android::hardware::radio::V1_2::DataRequestReason reason,
574 const hidl_vec<hidl_string>& addresses, const hidl_vec<hidl_string>& dnses);
575 Return<void> deactivateDataCall_1_2(int32_t serial, int32_t cid,
576 ::android::hardware::radio::V1_2::DataRequestReason reason);
577
578 // Methods from ::android::hardware::radio::V1_3::IRadio follow.
579 Return<void> setSystemSelectionChannels(int32_t serial, bool specifyChannels,
580 const hidl_vec<::android::hardware::radio::V1_1::RadioAccessSpecifier>& specifiers);
581 Return<void> enableModem(int32_t serial, bool on);
582 Return<void> getModemStackStatus(int32_t serial);
583
584 // Methods from ::android::hardware::radio::V1_4::IRadio follow.
585 Return<void> setupDataCall_1_4(int32_t serial,
586 ::android::hardware::radio::V1_4::AccessNetwork accessNetwork,
587 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo,
588 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason reason,
589 const hidl_vec<hidl_string>& addresses, const hidl_vec<hidl_string>& dnses);
590 Return<void> setInitialAttachApn_1_4(int32_t serial,
591 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo);
592 Return<void> setDataProfile_1_4(int32_t serial,
593 const hidl_vec<::android::hardware::radio::V1_4::DataProfileInfo>& profiles);
594 Return<void> emergencyDial(int32_t serial,
595 const ::android::hardware::radio::V1_0::Dial& dialInfo,
596 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
597 const hidl_vec<hidl_string>& urns,
598 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
599 bool fromEmergencyDialer, bool isTesting);
600 Return<void> emergencyDial_1_6(int32_t serial,
601 const ::android::hardware::radio::V1_0::Dial& dialInfo,
602 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
603 const hidl_vec<hidl_string>& urns,
604 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
605 bool fromEmergencyDialer, bool isTesting);
606 Return<void> startNetworkScan_1_4(int32_t serial,
607 const ::android::hardware::radio::V1_2::NetworkScanRequest& request);
608 Return<void> getPreferredNetworkTypeBitmap(int32_t serial);
609 Return<void> setPreferredNetworkTypeBitmap(
610 int32_t serial, hidl_bitfield<RadioAccessFamily> networkTypeBitmap);
611 Return<void> setAllowedCarriers_1_4(int32_t serial,
612 const ::android::hardware::radio::V1_4::CarrierRestrictionsWithPriority& carriers,
613 ::android::hardware::radio::V1_4::SimLockMultiSimPolicy multiSimPolicy);
614 Return<void> getAllowedCarriers_1_4(int32_t serial);
615 Return<void> getSignalStrength_1_4(int32_t serial);
616
617 // Methods from ::android::hardware::radio::V1_5::IRadio follow.
618 Return<void> setSignalStrengthReportingCriteria_1_5(int32_t serial,
619 const ::android::hardware::radio::V1_5::SignalThresholdInfo& signalThresholdInfo,
620 const ::android::hardware::radio::V1_5::AccessNetwork accessNetwork);
621 Return<void> setLinkCapacityReportingCriteria_1_5(int32_t serial, int32_t hysteresisMs,
622 int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
623 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
624 const hidl_vec<int32_t>& thresholdsUplinkKbps,
625 V1_5::AccessNetwork accessNetwork);
626 Return<void> enableUiccApplications(int32_t serial, bool detach);
627 Return<void> areUiccApplicationsEnabled(int32_t serial);
628 Return<void> setSystemSelectionChannels_1_5(int32_t serial, bool specifyChannels,
629 const hidl_vec<::android::hardware::radio::V1_5::RadioAccessSpecifier>& specifiers);
630 Return<void> startNetworkScan_1_5(int32_t serial,
631 const ::android::hardware::radio::V1_5::NetworkScanRequest& request);
632 Return<void> setupDataCall_1_5(int32_t serial,
633 ::android::hardware::radio::V1_5::AccessNetwork accessNetwork,
634 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
635 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason reason,
636 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& addresses,
637 const hidl_vec<hidl_string>& dnses);
638 Return<void> setInitialAttachApn_1_5(int32_t serial,
639 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo);
640 Return<void> setDataProfile_1_5(int32_t serial,
641 const hidl_vec<::android::hardware::radio::V1_5::DataProfileInfo>& profiles);
642 Return<void> setRadioPower_1_5(int32_t serial, bool powerOn, bool forEmergencyCall,
643 bool preferredForEmergencyCall);
644 Return<void> setIndicationFilter_1_5(int32_t serial,
645 hidl_bitfield<::android::hardware::radio::V1_5::IndicationFilter> indicationFilter);
646 Return<void> getBarringInfo(int32_t serial);
647 Return<void> getVoiceRegistrationState_1_5(int32_t serial);
648 Return<void> getDataRegistrationState_1_5(int32_t serial);
649 Return<void> setNetworkSelectionModeManual_1_5(int32_t serial,
650 const hidl_string& operatorNumeric, V1_5::RadioAccessNetworks ran);
651 Return<void> sendCdmaSmsExpectMore(int32_t serial, const CdmaSmsMessage& sms);
652 Return<void> supplySimDepersonalization(int32_t serial, V1_5::PersoSubstate persoType,
653 const hidl_string& controlKey);
654 Return<void> setNrDualConnectivityState(int32_t serial,
655 V1_6::NrDualConnectivityState nrDualConnectivityState);
656 Return<void> isNrDualConnectivityEnabled(int32_t serial);
657
658 // Methods from ::android::hardware::radio::V1_6::IRadio follow.
659 Return<void> getDataCallList_1_6(int32_t serial);
660 Return<void> setupDataCall_1_6(int32_t serial,
661 ::android::hardware::radio::V1_5::AccessNetwork accessNetwork,
662 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
663 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason reason,
664 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& addresses,
665 const hidl_vec<hidl_string>& dnses,
666 int32_t pduSessionId,
667 const ::android::hardware::radio::V1_6::OptionalSliceInfo& sliceInfo,
668 const ::android::hardware::radio::V1_6::OptionalTrafficDescriptor& trafficDescriptor,
669 bool matchAllRuleAllowed);
670 Return<void> sendSms_1_6(int32_t serial, const GsmSmsMessage& message);
671 Return<void> sendSmsExpectMore_1_6(int32_t serial, const GsmSmsMessage& message);
672 Return<void> sendCdmaSms_1_6(int32_t serial, const CdmaSmsMessage& sms);
673 Return<void> sendCdmaSmsExpectMore_1_6(int32_t serial, const CdmaSmsMessage& sms);
674 Return<void> setRadioPower_1_6(int32_t serial, bool powerOn, bool forEmergencyCall,
675 bool preferredForEmergencyCall);
676 Return<void> allocatePduSessionId(int32_t serial);
677 Return<void> releasePduSessionId(int32_t serial, int32_t id);
678 Return<void> startHandover(int32_t serial, int32_t callId);
679 Return<void> cancelHandover(int32_t serial, int32_t callId);
680 Return<void> setAllowedNetworkTypesBitmap(uint32_t serial,
681 hidl_bitfield<::android::hardware::radio::V1_4::RadioAccessFamily> networkTypeBitmap);
682 Return<void> setDataThrottling(int32_t serial,
683 V1_6::DataThrottlingAction dataThrottlingAction,
684 int64_t completionDurationMillis);
685 Return<void> getSystemSelectionChannels(int32_t serial);
686 Return<void> getVoiceRegistrationState_1_6(int32_t serial);
687 Return<void> getDataRegistrationState_1_6(int32_t serial);
688 Return<void> getAllowedNetworkTypesBitmap(int32_t serial);
689 Return<void> getSlicingConfig(int32_t serial);
690 Return<void> setCarrierInfoForImsiEncryption_1_6(
691 int32_t serial,
692 const ::android::hardware::radio::V1_6::ImsiEncryptionInfo& imsiEncryptionInfo);
693 Return<void> getSimPhonebookRecords(int32_t serial);
694 Return<void> getSimPhonebookCapacity(int32_t serial);
695 Return<void> updateSimPhonebookRecords(
696 int32_t serial,
697 const ::android::hardware::radio::V1_6::PhonebookRecordInfo& recordInfo);
698 };
699
700 struct OemHookImpl : public IOemHook {
701 int32_t mSlotId;
702 sp<IOemHookResponse> mOemHookResponse;
703 sp<IOemHookIndication> mOemHookIndication;
704
705 Return<void> setResponseFunctions(
706 const ::android::sp<IOemHookResponse>& oemHookResponse,
707 const ::android::sp<IOemHookIndication>& oemHookIndication);
708
709 Return<void> sendRequestRaw(int32_t serial,
710 const ::android::hardware::hidl_vec<uint8_t>& data);
711
712 Return<void> sendRequestStrings(int32_t serial,
713 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
714 };
715
memsetAndFreeStrings(int numPointers,...)716 void memsetAndFreeStrings(int numPointers, ...) {
717 va_list ap;
718 va_start(ap, numPointers);
719 for (int i = 0; i < numPointers; i++) {
720 char *ptr = va_arg(ap, char *);
721 if (ptr) {
722 #ifdef MEMSET_FREED
723 #define MAX_STRING_LENGTH 4096
724 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
725 #endif
726 free(ptr);
727 }
728 }
729 va_end(ap);
730 }
731
sendErrorResponse(RequestInfo * pRI,RIL_Errno err)732 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
733 pRI->pCI->responseFunction((int) pRI->socket_id,
734 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
735 }
736
737 /**
738 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
739 * request with error RIL_E_NO_MEMORY. The size() method is used to determine the size of the
740 * destination buffer into which the HIDL string is copied. If there is a discrepancy between
741 * the string length reported by the size() method, and the length of the string returned by
742 * the c_str() method, the function will return false indicating a failure.
743 *
744 * Returns true on success, and false on failure.
745 */
copyHidlStringToRil(char ** dest,const hidl_string & src,RequestInfo * pRI,bool allowEmpty)746 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI, bool allowEmpty) {
747 size_t len = src.size();
748 if (len == 0 && !allowEmpty) {
749 *dest = NULL;
750 return true;
751 }
752 *dest = (char *) calloc(len + 1, sizeof(char));
753 if (*dest == NULL) {
754 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
755 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
756 return false;
757 }
758 if (strlcpy(*dest, src.c_str(), len + 1) >= (len + 1)) {
759 RLOGE("Copy of the HIDL string has been truncated, as "
760 "the string length reported by size() does not "
761 "match the length of string returned by c_str().");
762 free(*dest);
763 *dest = NULL;
764 sendErrorResponse(pRI, RIL_E_INTERNAL_ERR);
765 return false;
766 }
767 return true;
768 }
769
copyHidlStringToRil(char ** dest,const hidl_string & src,RequestInfo * pRI)770 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
771 return copyHidlStringToRil(dest, src, pRI, false);
772 }
773
convertCharPtrToHidlString(const char * ptr)774 hidl_string convertCharPtrToHidlString(const char *ptr) {
775 hidl_string ret;
776 if (ptr != NULL) {
777 // TODO: replace this with strnlen
778 ret.setToExternal(ptr, strlen(ptr));
779 }
780 return ret;
781 }
782
dispatchVoid(int serial,int slotId,int request)783 bool dispatchVoid(int serial, int slotId, int request) {
784 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
785 if (pRI == NULL) {
786 return false;
787 }
788 CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
789 return true;
790 }
791
dispatchString(int serial,int slotId,int request,const char * str)792 bool dispatchString(int serial, int slotId, int request, const char * str) {
793 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
794 if (pRI == NULL) {
795 return false;
796 }
797
798 char *pString;
799 if (!copyHidlStringToRil(&pString, str, pRI)) {
800 return false;
801 }
802
803 CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
804
805 memsetAndFreeStrings(1, pString);
806 return true;
807 }
808
dispatchStrings(int serial,int slotId,int request,bool allowEmpty,int countStrings,...)809 bool dispatchStrings(int serial, int slotId, int request, bool allowEmpty, int countStrings, ...) {
810 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
811 if (pRI == NULL) {
812 return false;
813 }
814
815 char **pStrings;
816 pStrings = (char **)calloc(countStrings, sizeof(char *));
817 if (pStrings == NULL) {
818 RLOGE("Memory allocation failed for request %s", requestToString(request));
819 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
820 return false;
821 }
822 va_list ap;
823 va_start(ap, countStrings);
824 for (int i = 0; i < countStrings; i++) {
825 const char* str = va_arg(ap, const char *);
826 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI, allowEmpty)) {
827 va_end(ap);
828 for (int j = 0; j < i; j++) {
829 memsetAndFreeStrings(1, pStrings[j]);
830 }
831 free(pStrings);
832 return false;
833 }
834 }
835 va_end(ap);
836
837 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
838
839 if (pStrings != NULL) {
840 for (int i = 0 ; i < countStrings ; i++) {
841 memsetAndFreeStrings(1, pStrings[i]);
842 }
843
844 #ifdef MEMSET_FREED
845 memset(pStrings, 0, countStrings * sizeof(char *));
846 #endif
847 free(pStrings);
848 }
849 return true;
850 }
851
dispatchStrings(int serial,int slotId,int request,const hidl_vec<hidl_string> & data)852 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
853 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
854 if (pRI == NULL) {
855 return false;
856 }
857
858 int countStrings = data.size();
859 char **pStrings;
860 pStrings = (char **)calloc(countStrings, sizeof(char *));
861 if (pStrings == NULL) {
862 RLOGE("Memory allocation failed for request %s", requestToString(request));
863 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
864 return false;
865 }
866
867 for (int i = 0; i < countStrings; i++) {
868 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
869 for (int j = 0; j < i; j++) {
870 memsetAndFreeStrings(1, pStrings[j]);
871 }
872 free(pStrings);
873 return false;
874 }
875 }
876
877 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
878
879 if (pStrings != NULL) {
880 for (int i = 0 ; i < countStrings ; i++) {
881 memsetAndFreeStrings(1, pStrings[i]);
882 }
883
884 #ifdef MEMSET_FREED
885 memset(pStrings, 0, countStrings * sizeof(char *));
886 #endif
887 free(pStrings);
888 }
889 return true;
890 }
891
dispatchInts(int serial,int slotId,int request,int countInts,...)892 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
893 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
894 if (pRI == NULL) {
895 return false;
896 }
897
898 int *pInts = (int *)calloc(countInts, sizeof(int));
899
900 if (pInts == NULL) {
901 RLOGE("Memory allocation failed for request %s", requestToString(request));
902 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
903 return false;
904 }
905 va_list ap;
906 va_start(ap, countInts);
907 for (int i = 0; i < countInts; i++) {
908 pInts[i] = va_arg(ap, int);
909 }
910 va_end(ap);
911
912 CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
913
914 if (pInts != NULL) {
915 #ifdef MEMSET_FREED
916 memset(pInts, 0, countInts * sizeof(int));
917 #endif
918 free(pInts);
919 }
920 return true;
921 }
922
dispatchCallForwardStatus(int serial,int slotId,int request,const CallForwardInfo & callInfo)923 bool dispatchCallForwardStatus(int serial, int slotId, int request,
924 const CallForwardInfo& callInfo) {
925 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
926 if (pRI == NULL) {
927 return false;
928 }
929
930 RIL_CallForwardInfo cf;
931 cf.status = (int) callInfo.status;
932 cf.reason = callInfo.reason;
933 cf.serviceClass = callInfo.serviceClass;
934 cf.toa = callInfo.toa;
935 cf.timeSeconds = callInfo.timeSeconds;
936
937 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
938 return false;
939 }
940
941 CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
942
943 memsetAndFreeStrings(1, cf.number);
944
945 return true;
946 }
947
dispatchRaw(int serial,int slotId,int request,const hidl_vec<uint8_t> & rawBytes)948 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
949 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
950 if (pRI == NULL) {
951 return false;
952 }
953
954 const uint8_t *uData = rawBytes.data();
955
956 CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
957
958 return true;
959 }
960
dispatchIccApdu(int serial,int slotId,int request,const SimApdu & message)961 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
962 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
963 if (pRI == NULL) {
964 return false;
965 }
966
967 RIL_SIM_APDU apdu = {};
968
969 apdu.sessionid = message.sessionId;
970 apdu.cla = message.cla;
971 apdu.instruction = message.instruction;
972 apdu.p1 = message.p1;
973 apdu.p2 = message.p2;
974 apdu.p3 = message.p3;
975
976 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
977 return false;
978 }
979
980 CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
981
982 memsetAndFreeStrings(1, apdu.data);
983
984 return true;
985 }
986
checkReturnStatus(int32_t slotId,Return<void> & ret,bool isRadioService)987 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
988 if (ret.isOk() == false) {
989 RLOGE("checkReturnStatus: unable to call response/indication callback");
990 // Remote process hosting the callbacks must be dead. Reset the callback objects;
991 // there's no other recovery to be done here. When the client process is back up, it will
992 // call setResponseFunctions()
993
994 // Caller should already hold rdlock, release that first
995 // note the current counter to avoid overwriting updates made by another thread before
996 // write lock is acquired.
997 auto counter =
998 isRadioService ? mCounterRadio[slotId].load() : mCounterOemHook[slotId].load();
999 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_6::getRadioServiceRwlock(slotId);
1000 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
1001 CHECK_EQ(ret, 0);
1002
1003 // acquire wrlock
1004 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
1005 CHECK_EQ(ret, 0);
1006
1007 // make sure the counter value has not changed
1008 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
1009 if (isRadioService) {
1010 radioService[slotId]->mRadioResponse = NULL;
1011 radioService[slotId]->mRadioIndication = NULL;
1012 radioService[slotId]->mRadioResponseV1_2 = NULL;
1013 radioService[slotId]->mRadioIndicationV1_2 = NULL;
1014 radioService[slotId]->mRadioResponseV1_3 = NULL;
1015 radioService[slotId]->mRadioIndicationV1_3 = NULL;
1016 radioService[slotId]->mRadioResponseV1_4 = NULL;
1017 radioService[slotId]->mRadioIndicationV1_4 = NULL;
1018 radioService[slotId]->mRadioResponseV1_5 = NULL;
1019 radioService[slotId]->mRadioIndicationV1_5 = NULL;
1020 radioService[slotId]->mRadioResponseV1_6 = NULL;
1021 radioService[slotId]->mRadioIndicationV1_6 = NULL;
1022 } else {
1023 oemHookService[slotId]->mOemHookResponse = NULL;
1024 oemHookService[slotId]->mOemHookIndication = NULL;
1025 }
1026 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
1027 } else {
1028 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
1029 "got updated on another thread");
1030 }
1031
1032 // release wrlock
1033 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
1034 CHECK_EQ(ret, 0);
1035
1036 // Reacquire rdlock
1037 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
1038 CHECK_EQ(ret, 0);
1039 }
1040 }
1041
1042 // Function to verify if the channels are valid for any of the given bands
areEutranChannelsInsideBands(const RIL_EutranBands bands[],const uint32_t bands_length,const uint32_t channels[],const uint32_t channels_length)1043 bool areEutranChannelsInsideBands(const RIL_EutranBands bands[], const uint32_t bands_length,
1044 const uint32_t channels[], const uint32_t channels_length) {
1045 // Map values:{band,{ndl_min, ndl_max}}
1046 // Values from ETSI TS 136 101 V17.6.0 Table 5.7.3-1
1047 std::unordered_map<int, std::pair<uint32_t, uint32_t>> band_info = {
1048 {1, {0, 599}}, {2, {600, 1199}}, {3, {1200, 1949}}, {4, {1950, 2399}},
1049 {5, {2400, 2649}}, {6, {2650, 2749}}, {7, {2750, 3449}}, {8, {3450, 3799}},
1050 {9, {3800, 4149}}, {10, {4150, 4749}}, {11, {4750, 4949}}, {12, {5010, 5179}},
1051 {13, {5180, 5279}}, {14, {5280, 5379}}, {17, {5730, 5849}}, {18, {5850, 5999}},
1052 {19, {6000, 6149}}, {20, {6150, 6449}}, {21, {6450, 6599}}, {22, {6600, 7399}},
1053 {23, {7500, 7699}}, {24, {7700, 8039}}, {25, {8040, 8689}}, {26, {8690, 9039}},
1054 {27, {9040, 9209}}, {28, {9210, 9659}}, {29, {9660, 9769}}, {30, {9770, 9869}},
1055 {31, {9870, 9919}}, {32, {9920, 10359}}, {33, {36000, 36199}}, {34, {36200, 36349}},
1056 {35, {36350, 36949}}, {36, {36950, 37549}}, {37, {37550, 37749}}, {38, {37750, 38249}},
1057 {39, {38250, 38649}}, {40, {38650, 39649}}, {41, {39650, 41589}}, {42, {41590, 43589}},
1058 {43, {43590, 45589}}, {44, {45590, 46589}}, {45, {46590, 46789}}, {46, {46790, 54539}},
1059 {47, {54540, 55239}}, {48, {55240, 56739}}, {49, {56740, 58239}}, {50, {58240, 59089}},
1060 {51, {59090, 59139}}, {52, {59140, 60139}}, {53, {60140, 60254}}, {65, {65536, 66435}},
1061 {66, {66436, 67335}}, {67, {67336, 67535}}, {68, {67536, 67835}}, {69, {67836, 68335}},
1062 {70, {68336, 68585}}, {71, {68586, 68935}}, {72, {68936, 68985}}, {73, {68986, 69035}},
1063 {74, {69036, 69465}}, {75, {69466, 70315}}, {76, {70316, 70365}}, {85, {70366, 70545}},
1064 {87, {70546, 70595}}, {88, {70596, 70645}}, {103, {70646, 70655}}};
1065
1066 bool invalidValueFound = false;
1067 // Check if every provided band is a valid band.
1068 for (uint32_t j = 0; j < bands_length; ++j) {
1069 if (band_info.find(static_cast<int>(bands[j])) == band_info.end()) {
1070 RLOGE("areEutranChannelsInsideBands: band '%d' is not a valid band.", bands[j]);
1071 invalidValueFound = true;
1072 }
1073 }
1074
1075 // Iterate through the channels and check if they belong to any bands.
1076 for (uint32_t i = 0; i < channels_length; ++i) {
1077 bool found = false;
1078 for (uint32_t j = 0; j < bands_length; ++j) {
1079 auto band_it = band_info.find(static_cast<int>(bands[j]));
1080 if (band_info.find(static_cast<int>(bands[j])) != band_info.end() &&
1081 channels[i] >= band_it->second.first && channels[i] <= band_it->second.second) {
1082 found = true;
1083 break;
1084 }
1085 }
1086 if (!found) {
1087 std::stringstream bands_str;
1088 for (uint32_t k = 0; k < bands_length; ++k) {
1089 bands_str << bands[k] << " ";
1090 }
1091 RLOGE("areEutranChannelsInsideBands: channel '%d' doesn't belong to any bands: '%s'",
1092 channels[i], bands_str.str().c_str());
1093 invalidValueFound = true;
1094 }
1095 }
1096
1097 return !invalidValueFound;
1098 }
1099
checkReturnStatus(Return<void> & ret)1100 void RadioImpl_1_6::checkReturnStatus(Return<void>& ret) {
1101 ::checkReturnStatus(mSlotId, ret, true);
1102 }
1103
setResponseFunctions(const::android::sp<IRadioResponse> & radioResponseParam,const::android::sp<IRadioIndication> & radioIndicationParam)1104 Return<void> RadioImpl_1_6::setResponseFunctions(
1105 const ::android::sp<IRadioResponse>& radioResponseParam,
1106 const ::android::sp<IRadioIndication>& radioIndicationParam) {
1107 RLOGD("setResponseFunctions");
1108
1109 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_6::getRadioServiceRwlock(mSlotId);
1110 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
1111 CHECK_EQ(ret, 0);
1112
1113 mRadioResponse = radioResponseParam;
1114 mRadioIndication = radioIndicationParam;
1115
1116 mRadioResponseV1_6 = V1_6::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1117 mRadioIndicationV1_6 = V1_6::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1118 if (mRadioResponseV1_6 == nullptr || mRadioIndicationV1_6 == nullptr) {
1119 mRadioResponseV1_6 = nullptr;
1120 mRadioIndicationV1_6 = nullptr;
1121 }
1122
1123 mRadioResponseV1_5 = V1_5::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1124 mRadioIndicationV1_5 = V1_5::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1125 if (mRadioResponseV1_5 == nullptr || mRadioIndicationV1_5 == nullptr) {
1126 mRadioResponseV1_5 = nullptr;
1127 mRadioIndicationV1_5 = nullptr;
1128 }
1129
1130 mRadioResponseV1_4 = V1_4::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1131 mRadioIndicationV1_4 = V1_4::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1132 if (mRadioResponseV1_4 == nullptr || mRadioIndicationV1_4 == nullptr) {
1133 mRadioResponseV1_4 = nullptr;
1134 mRadioIndicationV1_4 = nullptr;
1135 }
1136
1137 mRadioResponseV1_3 = V1_3::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1138 mRadioIndicationV1_3 = V1_3::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1139 if (mRadioResponseV1_3 == nullptr || mRadioIndicationV1_3 == nullptr) {
1140 mRadioResponseV1_3 = nullptr;
1141 mRadioIndicationV1_3 = nullptr;
1142 }
1143
1144 mRadioResponseV1_2 = V1_2::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1145 mRadioIndicationV1_2 = V1_2::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1146 if (mRadioResponseV1_2 == nullptr || mRadioIndicationV1_2 == nullptr) {
1147 mRadioResponseV1_2 = nullptr;
1148 mRadioIndicationV1_2 = nullptr;
1149 }
1150
1151 mRadioResponseV1_1 = V1_1::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1152 mRadioIndicationV1_1 = V1_1::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1153 if (mRadioResponseV1_1 == nullptr || mRadioIndicationV1_1 == nullptr) {
1154 mRadioResponseV1_1 = nullptr;
1155 mRadioIndicationV1_1 = nullptr;
1156 }
1157
1158 mCounterRadio[mSlotId]++;
1159
1160 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
1161 CHECK_EQ(ret, 0);
1162
1163 // client is connected. Send initial indications.
1164 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
1165
1166 return Void();
1167 }
1168
getIccCardStatus(int32_t serial)1169 Return<void> RadioImpl_1_6::getIccCardStatus(int32_t serial) {
1170 #if VDBG
1171 RLOGD("getIccCardStatus: serial %d", serial);
1172 #endif
1173 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
1174 return Void();
1175 }
1176
supplyIccPinForApp(int32_t serial,const hidl_string & pin,const hidl_string & aid)1177 Return<void> RadioImpl_1_6::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
1178 const hidl_string& aid) {
1179 #if VDBG
1180 RLOGD("supplyIccPinForApp: serial %d", serial);
1181 #endif
1182 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN, true,
1183 2, pin.c_str(), aid.c_str());
1184 return Void();
1185 }
1186
supplyIccPukForApp(int32_t serial,const hidl_string & puk,const hidl_string & pin,const hidl_string & aid)1187 Return<void> RadioImpl_1_6::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
1188 const hidl_string& pin, const hidl_string& aid) {
1189 #if VDBG
1190 RLOGD("supplyIccPukForApp: serial %d", serial);
1191 #endif
1192 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK, true,
1193 3, puk.c_str(), pin.c_str(), aid.c_str());
1194 return Void();
1195 }
1196
supplyIccPin2ForApp(int32_t serial,const hidl_string & pin2,const hidl_string & aid)1197 Return<void> RadioImpl_1_6::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
1198 const hidl_string& aid) {
1199 #if VDBG
1200 RLOGD("supplyIccPin2ForApp: serial %d", serial);
1201 #endif
1202 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2, true,
1203 2, pin2.c_str(), aid.c_str());
1204 return Void();
1205 }
1206
supplyIccPuk2ForApp(int32_t serial,const hidl_string & puk2,const hidl_string & pin2,const hidl_string & aid)1207 Return<void> RadioImpl_1_6::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
1208 const hidl_string& pin2, const hidl_string& aid) {
1209 #if VDBG
1210 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
1211 #endif
1212 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2, true,
1213 3, puk2.c_str(), pin2.c_str(), aid.c_str());
1214 return Void();
1215 }
1216
changeIccPinForApp(int32_t serial,const hidl_string & oldPin,const hidl_string & newPin,const hidl_string & aid)1217 Return<void> RadioImpl_1_6::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
1218 const hidl_string& newPin, const hidl_string& aid) {
1219 #if VDBG
1220 RLOGD("changeIccPinForApp: serial %d", serial);
1221 #endif
1222 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN, true,
1223 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
1224 return Void();
1225 }
1226
changeIccPin2ForApp(int32_t serial,const hidl_string & oldPin2,const hidl_string & newPin2,const hidl_string & aid)1227 Return<void> RadioImpl_1_6::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
1228 const hidl_string& newPin2, const hidl_string& aid) {
1229 #if VDBG
1230 RLOGD("changeIccPin2ForApp: serial %d", serial);
1231 #endif
1232 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2, true,
1233 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
1234 return Void();
1235 }
1236
supplyNetworkDepersonalization(int32_t serial,const hidl_string & netPin)1237 Return<void> RadioImpl_1_6::supplyNetworkDepersonalization(int32_t serial,
1238 const hidl_string& netPin) {
1239 #if VDBG
1240 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
1241 #endif
1242 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, true,
1243 1, netPin.c_str());
1244 return Void();
1245 }
1246
getCurrentCalls(int32_t serial)1247 Return<void> RadioImpl_1_6::getCurrentCalls(int32_t serial) {
1248 #if VDBG
1249 RLOGD("getCurrentCalls: serial %d", serial);
1250 #endif
1251 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
1252 return Void();
1253 }
1254
getCurrentCalls_1_6(int32_t serial)1255 Return<void> RadioImpl_1_6::getCurrentCalls_1_6(int32_t serial) {
1256 #if VDBG
1257 RLOGD("getCurrentCalls_1_6: serial %d", serial);
1258 #endif
1259 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
1260 return Void();
1261 }
1262
dial(int32_t serial,const Dial & dialInfo)1263 Return<void> RadioImpl_1_6::dial(int32_t serial, const Dial& dialInfo) {
1264 #if VDBG
1265 RLOGD("dial: serial %d", serial);
1266 #endif
1267 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
1268 if (pRI == NULL) {
1269 return Void();
1270 }
1271 RIL_Dial dial = {};
1272 RIL_UUS_Info uusInfo = {};
1273 int32_t sizeOfDial = sizeof(dial);
1274
1275 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
1276 return Void();
1277 }
1278 dial.clir = (int) dialInfo.clir;
1279
1280 if (dialInfo.uusInfo.size() != 0) {
1281 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
1282 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
1283
1284 if (dialInfo.uusInfo[0].uusData.size() == 0) {
1285 uusInfo.uusData = NULL;
1286 uusInfo.uusLength = 0;
1287 } else {
1288 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
1289 memsetAndFreeStrings(1, dial.address);
1290 return Void();
1291 }
1292 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
1293 }
1294
1295 dial.uusInfo = &uusInfo;
1296 }
1297
1298 CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
1299
1300 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1301
1302 return Void();
1303 }
1304
getImsiForApp(int32_t serial,const hidl_string & aid)1305 Return<void> RadioImpl_1_6::getImsiForApp(int32_t serial, const hidl_string& aid) {
1306 #if VDBG
1307 RLOGD("getImsiForApp: serial %d", serial);
1308 #endif
1309 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI, false,
1310 1, aid.c_str());
1311 return Void();
1312 }
1313
hangup(int32_t serial,int32_t gsmIndex)1314 Return<void> RadioImpl_1_6::hangup(int32_t serial, int32_t gsmIndex) {
1315 #if VDBG
1316 RLOGD("hangup: serial %d", serial);
1317 #endif
1318 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
1319 return Void();
1320 }
1321
hangupWaitingOrBackground(int32_t serial)1322 Return<void> RadioImpl_1_6::hangupWaitingOrBackground(int32_t serial) {
1323 #if VDBG
1324 RLOGD("hangupWaitingOrBackground: serial %d", serial);
1325 #endif
1326 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
1327 return Void();
1328 }
1329
hangupForegroundResumeBackground(int32_t serial)1330 Return<void> RadioImpl_1_6::hangupForegroundResumeBackground(int32_t serial) {
1331 #if VDBG
1332 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
1333 #endif
1334 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
1335 return Void();
1336 }
1337
switchWaitingOrHoldingAndActive(int32_t serial)1338 Return<void> RadioImpl_1_6::switchWaitingOrHoldingAndActive(int32_t serial) {
1339 #if VDBG
1340 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
1341 #endif
1342 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
1343 return Void();
1344 }
1345
conference(int32_t serial)1346 Return<void> RadioImpl_1_6::conference(int32_t serial) {
1347 #if VDBG
1348 RLOGD("conference: serial %d", serial);
1349 #endif
1350 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
1351 return Void();
1352 }
1353
rejectCall(int32_t serial)1354 Return<void> RadioImpl_1_6::rejectCall(int32_t serial) {
1355 #if VDBG
1356 RLOGD("rejectCall: serial %d", serial);
1357 #endif
1358 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
1359 return Void();
1360 }
1361
getLastCallFailCause(int32_t serial)1362 Return<void> RadioImpl_1_6::getLastCallFailCause(int32_t serial) {
1363 #if VDBG
1364 RLOGD("getLastCallFailCause: serial %d", serial);
1365 #endif
1366 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
1367 return Void();
1368 }
1369
getSignalStrength(int32_t serial)1370 Return<void> RadioImpl_1_6::getSignalStrength(int32_t serial) {
1371 #if VDBG
1372 RLOGD("getSignalStrength: serial %d", serial);
1373 #endif
1374 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
1375 return Void();
1376 }
1377
getVoiceRegistrationState(int32_t serial)1378 Return<void> RadioImpl_1_6::getVoiceRegistrationState(int32_t serial) {
1379 #if VDBG
1380 RLOGD("getVoiceRegistrationState: serial %d", serial);
1381 #endif
1382 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
1383 return Void();
1384 }
1385
getDataRegistrationState(int32_t serial)1386 Return<void> RadioImpl_1_6::getDataRegistrationState(int32_t serial) {
1387 #if VDBG
1388 RLOGD("getDataRegistrationState: serial %d", serial);
1389 #endif
1390 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1391 return Void();
1392 }
1393
getOperator(int32_t serial)1394 Return<void> RadioImpl_1_6::getOperator(int32_t serial) {
1395 #if VDBG
1396 RLOGD("getOperator: serial %d", serial);
1397 #endif
1398 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1399 return Void();
1400 }
1401
setRadioPower(int32_t serial,bool on)1402 Return<void> RadioImpl_1_6::setRadioPower(int32_t serial, bool on) {
1403 #if VDBG
1404 RLOGD("setRadioPower: serial %d on %d", serial, on);
1405 #endif
1406 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1407 return Void();
1408 }
1409
sendDtmf(int32_t serial,const hidl_string & s)1410 Return<void> RadioImpl_1_6::sendDtmf(int32_t serial, const hidl_string& s) {
1411 #if VDBG
1412 RLOGD("sendDtmf: serial %d", serial);
1413 #endif
1414 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1415 return Void();
1416 }
1417
sendSms(int32_t serial,const GsmSmsMessage & message)1418 Return<void> RadioImpl_1_6::sendSms(int32_t serial, const GsmSmsMessage& message) {
1419 #if VDBG
1420 RLOGD("sendSms: serial %d", serial);
1421 #endif
1422 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, false,
1423 2, message.smscPdu.c_str(), message.pdu.c_str());
1424 return Void();
1425 }
1426
sendSms_1_6(int32_t serial,const GsmSmsMessage & message)1427 Return<void> RadioImpl_1_6::sendSms_1_6(int32_t serial, const GsmSmsMessage& message) {
1428 #if VDBG
1429 RLOGD("sendSms: serial %d", serial);
1430 #endif
1431 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, false,
1432 2, message.smscPdu.c_str(), message.pdu.c_str());
1433 return Void();
1434 }
1435
sendSMSExpectMore(int32_t serial,const GsmSmsMessage & message)1436 Return<void> RadioImpl_1_6::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1437 #if VDBG
1438 RLOGD("sendSmsExpectMore: serial %d", serial);
1439 #endif
1440 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, false,
1441 2, message.smscPdu.c_str(), message.pdu.c_str());
1442 return Void();
1443 }
1444
sendSmsExpectMore_1_6(int32_t serial,const GsmSmsMessage & message)1445 Return<void> RadioImpl_1_6::sendSmsExpectMore_1_6(int32_t serial, const GsmSmsMessage& message) {
1446 #if VDBG
1447 RLOGD("sendSmsExpectMore: serial %d", serial);
1448 #endif
1449 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, false,
1450 2, message.smscPdu.c_str(), message.pdu.c_str());
1451 return Void();
1452 }
1453
convertMvnoTypeToString(MvnoType type,char * & str)1454 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1455 switch (type) {
1456 case MvnoType::IMSI:
1457 str = (char *)"imsi";
1458 return true;
1459 case MvnoType::GID:
1460 str = (char *)"gid";
1461 return true;
1462 case MvnoType::SPN:
1463 str = (char *)"spn";
1464 return true;
1465 case MvnoType::NONE:
1466 str = (char *)"";
1467 return true;
1468 }
1469 return false;
1470 }
1471
setupDataCall(int32_t serial,RadioTechnology radioTechnology,const DataProfileInfo & dataProfileInfo,bool modemCognitive,bool roamingAllowed,bool isRoaming)1472 Return<void> RadioImpl_1_6::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1473 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1474 bool roamingAllowed, bool isRoaming) {
1475
1476 #if VDBG
1477 RLOGD("setupDataCall: serial %d", serial);
1478 #endif
1479
1480 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1481 const hidl_string &protocol =
1482 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1483 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 7,
1484 std::to_string((int) radioTechnology + 2).c_str(),
1485 std::to_string((int) dataProfileInfo.profileId).c_str(),
1486 dataProfileInfo.apn.c_str(),
1487 dataProfileInfo.user.c_str(),
1488 dataProfileInfo.password.c_str(),
1489 std::to_string((int) dataProfileInfo.authType).c_str(),
1490 protocol.c_str());
1491 } else if (s_vendorFunctions->version == 15) {
1492 char *mvnoTypeStr = NULL;
1493 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1494 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1495 RIL_REQUEST_SETUP_DATA_CALL);
1496 if (pRI != NULL) {
1497 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1498 }
1499 return Void();
1500 }
1501 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
1502 std::to_string((int) radioTechnology + 2).c_str(),
1503 std::to_string((int) dataProfileInfo.profileId).c_str(),
1504 dataProfileInfo.apn.c_str(),
1505 dataProfileInfo.user.c_str(),
1506 dataProfileInfo.password.c_str(),
1507 std::to_string((int) dataProfileInfo.authType).c_str(),
1508 dataProfileInfo.protocol.c_str(),
1509 dataProfileInfo.roamingProtocol.c_str(),
1510 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1511 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1512 modemCognitive ? "1" : "0",
1513 std::to_string(dataProfileInfo.mtu).c_str(),
1514 mvnoTypeStr,
1515 dataProfileInfo.mvnoMatchData.c_str(),
1516 roamingAllowed ? "1" : "0");
1517 } else if (s_vendorFunctions->version >= 16) {
1518 char *mvnoTypeStr = NULL;
1519 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1520 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1521 RIL_REQUEST_SETUP_DATA_CALL);
1522 if (pRI != NULL) {
1523 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1524 }
1525 return Void();
1526 }
1527 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 16,
1528 std::to_string((int) radioTechnology + 2).c_str(),
1529 std::to_string((int) dataProfileInfo.profileId).c_str(),
1530 dataProfileInfo.apn.c_str(),
1531 dataProfileInfo.user.c_str(),
1532 dataProfileInfo.password.c_str(),
1533 std::to_string((int) dataProfileInfo.authType).c_str(),
1534 dataProfileInfo.protocol.c_str(),
1535 dataProfileInfo.roamingProtocol.c_str(),
1536 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1537 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1538 modemCognitive ? "1" : "0",
1539 std::to_string(dataProfileInfo.mtu).c_str(),
1540 mvnoTypeStr,
1541 dataProfileInfo.mvnoMatchData.c_str(),
1542 roamingAllowed ? "1" : "0",
1543 "-1",
1544 "");
1545 } else {
1546 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1547 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1548 RIL_REQUEST_SETUP_DATA_CALL);
1549 if (pRI != NULL) {
1550 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1551 }
1552 }
1553 return Void();
1554 }
1555
iccIOForApp(int32_t serial,const IccIo & iccIo)1556 Return<void> RadioImpl_1_6::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1557 #if VDBG
1558 RLOGD("iccIOForApp: serial %d", serial);
1559 #endif
1560 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1561 if (pRI == NULL) {
1562 return Void();
1563 }
1564
1565 RIL_SIM_IO_v6 rilIccIo = {};
1566 rilIccIo.command = iccIo.command;
1567 rilIccIo.fileid = iccIo.fileId;
1568 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1569 return Void();
1570 }
1571
1572 rilIccIo.p1 = iccIo.p1;
1573 rilIccIo.p2 = iccIo.p2;
1574 rilIccIo.p3 = iccIo.p3;
1575
1576 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1577 memsetAndFreeStrings(1, rilIccIo.path);
1578 return Void();
1579 }
1580
1581 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1582 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1583 return Void();
1584 }
1585
1586 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1587 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1588 return Void();
1589 }
1590
1591 CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1592
1593 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1594
1595 return Void();
1596 }
1597
sendUssd(int32_t serial,const hidl_string & ussd)1598 Return<void> RadioImpl_1_6::sendUssd(int32_t serial, const hidl_string& ussd) {
1599 #if VDBG
1600 RLOGD("sendUssd: serial %d", serial);
1601 #endif
1602 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1603 return Void();
1604 }
1605
cancelPendingUssd(int32_t serial)1606 Return<void> RadioImpl_1_6::cancelPendingUssd(int32_t serial) {
1607 #if VDBG
1608 RLOGD("cancelPendingUssd: serial %d", serial);
1609 #endif
1610 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1611 return Void();
1612 }
1613
getClir(int32_t serial)1614 Return<void> RadioImpl_1_6::getClir(int32_t serial) {
1615 #if VDBG
1616 RLOGD("getClir: serial %d", serial);
1617 #endif
1618 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1619 return Void();
1620 }
1621
setClir(int32_t serial,int32_t status)1622 Return<void> RadioImpl_1_6::setClir(int32_t serial, int32_t status) {
1623 #if VDBG
1624 RLOGD("setClir: serial %d", serial);
1625 #endif
1626 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1627 return Void();
1628 }
1629
getCallForwardStatus(int32_t serial,const CallForwardInfo & callInfo)1630 Return<void> RadioImpl_1_6::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1631 #if VDBG
1632 RLOGD("getCallForwardStatus: serial %d", serial);
1633 #endif
1634 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1635 callInfo);
1636 return Void();
1637 }
1638
setCallForward(int32_t serial,const CallForwardInfo & callInfo)1639 Return<void> RadioImpl_1_6::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1640 #if VDBG
1641 RLOGD("setCallForward: serial %d", serial);
1642 #endif
1643 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1644 callInfo);
1645 return Void();
1646 }
1647
getCallWaiting(int32_t serial,int32_t serviceClass)1648 Return<void> RadioImpl_1_6::getCallWaiting(int32_t serial, int32_t serviceClass) {
1649 #if VDBG
1650 RLOGD("getCallWaiting: serial %d", serial);
1651 #endif
1652 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1653 return Void();
1654 }
1655
setCallWaiting(int32_t serial,bool enable,int32_t serviceClass)1656 Return<void> RadioImpl_1_6::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1657 #if VDBG
1658 RLOGD("setCallWaiting: serial %d", serial);
1659 #endif
1660 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1661 serviceClass);
1662 return Void();
1663 }
1664
acknowledgeLastIncomingGsmSms(int32_t serial,bool success,SmsAcknowledgeFailCause cause)1665 Return<void> RadioImpl_1_6::acknowledgeLastIncomingGsmSms(int32_t serial,
1666 bool success, SmsAcknowledgeFailCause cause) {
1667 #if VDBG
1668 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1669 #endif
1670 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1671 cause);
1672 return Void();
1673 }
1674
acceptCall(int32_t serial)1675 Return<void> RadioImpl_1_6::acceptCall(int32_t serial) {
1676 #if VDBG
1677 RLOGD("acceptCall: serial %d", serial);
1678 #endif
1679 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1680 return Void();
1681 }
1682
deactivateDataCall(int32_t serial,int32_t cid,bool reasonRadioShutDown)1683 Return<void> RadioImpl_1_6::deactivateDataCall(int32_t serial,
1684 int32_t cid, bool reasonRadioShutDown) {
1685 #if VDBG
1686 RLOGD("deactivateDataCall: serial %d", serial);
1687 #endif
1688 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, false,
1689 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1690 return Void();
1691 }
1692
getFacilityLockForApp(int32_t serial,const hidl_string & facility,const hidl_string & password,int32_t serviceClass,const hidl_string & appId)1693 Return<void> RadioImpl_1_6::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1694 const hidl_string& password, int32_t serviceClass,
1695 const hidl_string& appId) {
1696 #if VDBG
1697 RLOGD("getFacilityLockForApp: serial %d", serial);
1698 #endif
1699 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK, true,
1700 4, facility.c_str(), password.c_str(),
1701 (std::to_string(serviceClass)).c_str(), appId.c_str());
1702 return Void();
1703 }
1704
setFacilityLockForApp(int32_t serial,const hidl_string & facility,bool lockState,const hidl_string & password,int32_t serviceClass,const hidl_string & appId)1705 Return<void> RadioImpl_1_6::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1706 bool lockState, const hidl_string& password,
1707 int32_t serviceClass, const hidl_string& appId) {
1708 #if VDBG
1709 RLOGD("setFacilityLockForApp: serial %d", serial);
1710 #endif
1711 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK, true,
1712 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1713 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1714 return Void();
1715 }
1716
setBarringPassword(int32_t serial,const hidl_string & facility,const hidl_string & oldPassword,const hidl_string & newPassword)1717 Return<void> RadioImpl_1_6::setBarringPassword(int32_t serial, const hidl_string& facility,
1718 const hidl_string& oldPassword,
1719 const hidl_string& newPassword) {
1720 #if VDBG
1721 RLOGD("setBarringPassword: serial %d", serial);
1722 #endif
1723 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD, true,
1724 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1725 return Void();
1726 }
1727
getNetworkSelectionMode(int32_t serial)1728 Return<void> RadioImpl_1_6::getNetworkSelectionMode(int32_t serial) {
1729 #if VDBG
1730 RLOGD("getNetworkSelectionMode: serial %d", serial);
1731 #endif
1732 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1733 return Void();
1734 }
1735
setNetworkSelectionModeAutomatic(int32_t serial)1736 Return<void> RadioImpl_1_6::setNetworkSelectionModeAutomatic(int32_t serial) {
1737 #if VDBG
1738 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1739 #endif
1740 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1741 return Void();
1742 }
1743
setNetworkSelectionModeManual(int32_t serial,const hidl_string & operatorNumeric)1744 Return<void> RadioImpl_1_6::setNetworkSelectionModeManual(int32_t serial,
1745 const hidl_string& operatorNumeric) {
1746 #if VDBG
1747 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1748 #endif
1749 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1750 RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL);
1751 if (pRI == NULL) {
1752 return Void();
1753 }
1754
1755 RIL_NetworkOperator networkOperator = {};
1756
1757 networkOperator.act = UNKNOWN;
1758 if (!copyHidlStringToRil(&networkOperator.operatorNumeric, operatorNumeric, pRI)) {
1759 return Void();
1760 }
1761 CALL_ONREQUEST(pRI->pCI->requestNumber, &networkOperator,
1762 sizeof(networkOperator), pRI, mSlotId);
1763
1764 return Void();
1765 }
1766
getAvailableNetworks(int32_t serial)1767 Return<void> RadioImpl_1_6::getAvailableNetworks(int32_t serial) {
1768 #if VDBG
1769 RLOGD("getAvailableNetworks: serial %d", serial);
1770 #endif
1771 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1772 return Void();
1773 }
1774
startNetworkScan(int32_t serial,const V1_1::NetworkScanRequest & request)1775 Return<void> RadioImpl_1_6::startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request) {
1776 #if VDBG
1777 RLOGD("startNetworkScan: serial %d", serial);
1778 #endif
1779
1780 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1781 if (pRI == NULL) {
1782 return Void();
1783 }
1784
1785 if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
1786 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1787 return Void();
1788 }
1789
1790 RIL_NetworkScanRequest scan_request = {};
1791
1792 scan_request.type = (RIL_ScanType) request.type;
1793 scan_request.interval = request.interval;
1794 scan_request.specifiers_length = request.specifiers.size();
1795 for (size_t i = 0; i < request.specifiers.size(); ++i) {
1796 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
1797 request.specifiers[i].utranBands.size() > MAX_BANDS ||
1798 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
1799 request.specifiers[i].channels.size() > MAX_CHANNELS) {
1800 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1801 return Void();
1802 }
1803 const V1_1::RadioAccessSpecifier& ras_from =
1804 request.specifiers[i];
1805 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
1806
1807 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
1808 ras_to.channels_length = ras_from.channels.size();
1809
1810 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
1811 const std::vector<uint32_t> * bands = nullptr;
1812 switch (request.specifiers[i].radioAccessNetwork) {
1813 case V1_1::RadioAccessNetworks::GERAN:
1814 ras_to.bands_length = ras_from.geranBands.size();
1815 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
1816 break;
1817 case V1_1::RadioAccessNetworks::UTRAN:
1818 ras_to.bands_length = ras_from.utranBands.size();
1819 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
1820 break;
1821 case V1_1::RadioAccessNetworks::EUTRAN:
1822 ras_to.bands_length = ras_from.eutranBands.size();
1823 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
1824 break;
1825 default:
1826 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1827 return Void();
1828 }
1829 // safe to copy to geran_bands because it's a union member
1830 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
1831 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
1832 }
1833 }
1834
1835 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
1836 mSlotId);
1837
1838 return Void();
1839 }
1840
stopNetworkScan(int32_t serial)1841 Return<void> RadioImpl_1_6::stopNetworkScan(int32_t serial) {
1842 #if VDBG
1843 RLOGD("stopNetworkScan: serial %d", serial);
1844 #endif
1845 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1846 return Void();
1847 }
1848
startDtmf(int32_t serial,const hidl_string & s)1849 Return<void> RadioImpl_1_6::startDtmf(int32_t serial, const hidl_string& s) {
1850 #if VDBG
1851 RLOGD("startDtmf: serial %d", serial);
1852 #endif
1853 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1854 s.c_str());
1855 return Void();
1856 }
1857
stopDtmf(int32_t serial)1858 Return<void> RadioImpl_1_6::stopDtmf(int32_t serial) {
1859 #if VDBG
1860 RLOGD("stopDtmf: serial %d", serial);
1861 #endif
1862 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1863 return Void();
1864 }
1865
getBasebandVersion(int32_t serial)1866 Return<void> RadioImpl_1_6::getBasebandVersion(int32_t serial) {
1867 #if VDBG
1868 RLOGD("getBasebandVersion: serial %d", serial);
1869 #endif
1870 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1871 return Void();
1872 }
1873
separateConnection(int32_t serial,int32_t gsmIndex)1874 Return<void> RadioImpl_1_6::separateConnection(int32_t serial, int32_t gsmIndex) {
1875 #if VDBG
1876 RLOGD("separateConnection: serial %d", serial);
1877 #endif
1878 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1879 return Void();
1880 }
1881
setMute(int32_t serial,bool enable)1882 Return<void> RadioImpl_1_6::setMute(int32_t serial, bool enable) {
1883 #if VDBG
1884 RLOGD("setMute: serial %d", serial);
1885 #endif
1886 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1887 return Void();
1888 }
1889
getMute(int32_t serial)1890 Return<void> RadioImpl_1_6::getMute(int32_t serial) {
1891 #if VDBG
1892 RLOGD("getMute: serial %d", serial);
1893 #endif
1894 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1895 return Void();
1896 }
1897
getClip(int32_t serial)1898 Return<void> RadioImpl_1_6::getClip(int32_t serial) {
1899 #if VDBG
1900 RLOGD("getClip: serial %d", serial);
1901 #endif
1902 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1903 return Void();
1904 }
1905
getDataCallList(int32_t serial)1906 Return<void> RadioImpl_1_6::getDataCallList(int32_t serial) {
1907 #if VDBG
1908 RLOGD("getDataCallList: serial %d", serial);
1909 #endif
1910 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1911 return Void();
1912 }
1913
getDataCallList_1_6(int32_t serial)1914 Return<void> RadioImpl_1_6::getDataCallList_1_6(int32_t serial) {
1915 #if VDBG
1916 RLOGD("getDataCallList_1_6: serial %d", serial);
1917 #endif
1918 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1919 return Void();
1920 }
1921
emergencyDial_1_6(int32_t serial,const::android::hardware::radio::V1_0::Dial & dialInfo,hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,const hidl_vec<hidl_string> & urns,::android::hardware::radio::V1_4::EmergencyCallRouting routing,bool fromEmergencyDialer,bool)1922 Return<void> RadioImpl_1_6::emergencyDial_1_6(int32_t serial,
1923 const ::android::hardware::radio::V1_0::Dial& dialInfo,
1924 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
1925 const hidl_vec<hidl_string>& urns ,
1926 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
1927 bool fromEmergencyDialer, bool /* isTesting */) {
1928 #if VDBG
1929 RLOGD("emergencyDial: serial %d", serial);
1930 #endif
1931
1932 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_EMERGENCY_DIAL);
1933 if (pRI == NULL) {
1934 return Void();
1935 }
1936
1937 RIL_EmergencyDial eccDial = {};
1938 RIL_Dial& dial = eccDial.dialInfo;
1939 RIL_UUS_Info uusInfo = {};
1940
1941 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
1942 return Void();
1943 }
1944 dial.clir = (int) dialInfo.clir;
1945
1946 if (dialInfo.uusInfo.size() != 0) {
1947 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
1948 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
1949
1950 if (dialInfo.uusInfo[0].uusData.size() == 0) {
1951 uusInfo.uusData = NULL;
1952 uusInfo.uusLength = 0;
1953 } else {
1954 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
1955 memsetAndFreeStrings(1, dial.address);
1956 return Void();
1957 }
1958 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
1959 }
1960
1961 dial.uusInfo = &uusInfo;
1962 }
1963
1964 eccDial.urnsNumber = urns.size();
1965 if (eccDial.urnsNumber != 0) {
1966 char **ppUrns = (char **)calloc(eccDial.urnsNumber, sizeof(char *));
1967 if (ppUrns == NULL) {
1968 RLOGE("Memory allocation failed for request %s",
1969 requestToString(pRI->pCI->requestNumber));
1970 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1971 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1972 return Void();
1973 }
1974 for (uint32_t i = 0; i < eccDial.urnsNumber; i++) {
1975 if (!copyHidlStringToRil(&ppUrns[i], hidl_string(urns[i]), pRI)) {
1976 for (uint32_t j = 0; j < i; j++) {
1977 memsetAndFreeStrings(1, ppUrns[j]);
1978 }
1979 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1980 free(ppUrns);
1981 return Void();
1982 }
1983 }
1984 eccDial.urns = ppUrns;
1985 }
1986
1987 eccDial.categories = (RIL_EmergencyServiceCategory)categories;
1988 eccDial.routing = (RIL_EmergencyCallRouting)routing;
1989 eccDial.fromEmergencyDialer = fromEmergencyDialer;
1990
1991 CALL_ONREQUEST(RIL_REQUEST_EMERGENCY_DIAL, &eccDial, sizeof(RIL_EmergencyDial), pRI, mSlotId);
1992
1993 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1994 if (eccDial.urns != NULL) {
1995 for (size_t i = 0; i < eccDial.urnsNumber; i++) {
1996 memsetAndFreeStrings(1, eccDial.urns[i]);
1997 }
1998 free(eccDial.urns);
1999 }
2000 return Void();
2001 }
2002
setSuppServiceNotifications(int32_t serial,bool enable)2003 Return<void> RadioImpl_1_6::setSuppServiceNotifications(int32_t serial, bool enable) {
2004 #if VDBG
2005 RLOGD("setSuppServiceNotifications: serial %d", serial);
2006 #endif
2007 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
2008 BOOL_TO_INT(enable));
2009 return Void();
2010 }
2011
writeSmsToSim(int32_t serial,const SmsWriteArgs & smsWriteArgs)2012 Return<void> RadioImpl_1_6::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
2013 #if VDBG
2014 RLOGD("writeSmsToSim: serial %d", serial);
2015 #endif
2016 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
2017 if (pRI == NULL) {
2018 return Void();
2019 }
2020
2021 RIL_SMS_WriteArgs args;
2022 args.status = (int) smsWriteArgs.status;
2023
2024 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
2025 return Void();
2026 }
2027
2028 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
2029 memsetAndFreeStrings(1, args.pdu);
2030 return Void();
2031 }
2032
2033 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
2034
2035 memsetAndFreeStrings(2, args.smsc, args.pdu);
2036
2037 return Void();
2038 }
2039
deleteSmsOnSim(int32_t serial,int32_t index)2040 Return<void> RadioImpl_1_6::deleteSmsOnSim(int32_t serial, int32_t index) {
2041 #if VDBG
2042 RLOGD("deleteSmsOnSim: serial %d", serial);
2043 #endif
2044 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
2045 return Void();
2046 }
2047
setBandMode(int32_t serial,RadioBandMode mode)2048 Return<void> RadioImpl_1_6::setBandMode(int32_t serial, RadioBandMode mode) {
2049 #if VDBG
2050 RLOGD("setBandMode: serial %d", serial);
2051 #endif
2052 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
2053 return Void();
2054 }
2055
getAvailableBandModes(int32_t serial)2056 Return<void> RadioImpl_1_6::getAvailableBandModes(int32_t serial) {
2057 #if VDBG
2058 RLOGD("getAvailableBandModes: serial %d", serial);
2059 #endif
2060 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
2061 return Void();
2062 }
2063
sendEnvelope(int32_t serial,const hidl_string & command)2064 Return<void> RadioImpl_1_6::sendEnvelope(int32_t serial, const hidl_string& command) {
2065 #if VDBG
2066 RLOGD("sendEnvelope: serial %d", serial);
2067 #endif
2068 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
2069 command.c_str());
2070 return Void();
2071 }
2072
sendTerminalResponseToSim(int32_t serial,const hidl_string & commandResponse)2073 Return<void> RadioImpl_1_6::sendTerminalResponseToSim(int32_t serial,
2074 const hidl_string& commandResponse) {
2075 #if VDBG
2076 RLOGD("sendTerminalResponseToSim: serial %d", serial);
2077 #endif
2078 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
2079 commandResponse.c_str());
2080 return Void();
2081 }
2082
handleStkCallSetupRequestFromSim(int32_t serial,bool accept)2083 Return<void> RadioImpl_1_6::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
2084 #if VDBG
2085 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
2086 #endif
2087 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
2088 1, BOOL_TO_INT(accept));
2089 return Void();
2090 }
2091
explicitCallTransfer(int32_t serial)2092 Return<void> RadioImpl_1_6::explicitCallTransfer(int32_t serial) {
2093 #if VDBG
2094 RLOGD("explicitCallTransfer: serial %d", serial);
2095 #endif
2096 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
2097 return Void();
2098 }
2099
setPreferredNetworkType(int32_t serial,PreferredNetworkType nwType)2100 Return<void> RadioImpl_1_6::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
2101 #if VDBG
2102 RLOGD("setPreferredNetworkType: serial %d", serial);
2103 #endif
2104 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
2105 return Void();
2106 }
2107
getPreferredNetworkType(int32_t serial)2108 Return<void> RadioImpl_1_6::getPreferredNetworkType(int32_t serial) {
2109 #if VDBG
2110 RLOGD("getPreferredNetworkType: serial %d", serial);
2111 #endif
2112 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
2113 return Void();
2114 }
2115
getNeighboringCids(int32_t serial)2116 Return<void> RadioImpl_1_6::getNeighboringCids(int32_t serial) {
2117 #if VDBG
2118 RLOGD("getNeighboringCids: serial %d", serial);
2119 #endif
2120 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
2121 return Void();
2122 }
2123
setLocationUpdates(int32_t serial,bool enable)2124 Return<void> RadioImpl_1_6::setLocationUpdates(int32_t serial, bool enable) {
2125 #if VDBG
2126 RLOGD("setLocationUpdates: serial %d", serial);
2127 #endif
2128 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
2129 return Void();
2130 }
2131
setCdmaSubscriptionSource(int32_t serial,CdmaSubscriptionSource cdmaSub)2132 Return<void> RadioImpl_1_6::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
2133 #if VDBG
2134 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
2135 #endif
2136 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
2137 return Void();
2138 }
2139
setCdmaRoamingPreference(int32_t serial,CdmaRoamingType type)2140 Return<void> RadioImpl_1_6::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
2141 #if VDBG
2142 RLOGD("setCdmaRoamingPreference: serial %d", serial);
2143 #endif
2144 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
2145 return Void();
2146 }
2147
getCdmaRoamingPreference(int32_t serial)2148 Return<void> RadioImpl_1_6::getCdmaRoamingPreference(int32_t serial) {
2149 #if VDBG
2150 RLOGD("getCdmaRoamingPreference: serial %d", serial);
2151 #endif
2152 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
2153 return Void();
2154 }
2155
setTTYMode(int32_t serial,TtyMode mode)2156 Return<void> RadioImpl_1_6::setTTYMode(int32_t serial, TtyMode mode) {
2157 #if VDBG
2158 RLOGD("setTTYMode: serial %d", serial);
2159 #endif
2160 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
2161 return Void();
2162 }
2163
getTTYMode(int32_t serial)2164 Return<void> RadioImpl_1_6::getTTYMode(int32_t serial) {
2165 #if VDBG
2166 RLOGD("getTTYMode: serial %d", serial);
2167 #endif
2168 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
2169 return Void();
2170 }
2171
setPreferredVoicePrivacy(int32_t serial,bool enable)2172 Return<void> RadioImpl_1_6::setPreferredVoicePrivacy(int32_t serial, bool enable) {
2173 #if VDBG
2174 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
2175 #endif
2176 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
2177 1, BOOL_TO_INT(enable));
2178 return Void();
2179 }
2180
getPreferredVoicePrivacy(int32_t serial)2181 Return<void> RadioImpl_1_6::getPreferredVoicePrivacy(int32_t serial) {
2182 #if VDBG
2183 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
2184 #endif
2185 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
2186 return Void();
2187 }
2188
sendCDMAFeatureCode(int32_t serial,const hidl_string & featureCode)2189 Return<void> RadioImpl_1_6::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
2190 #if VDBG
2191 RLOGD("sendCDMAFeatureCode: serial %d", serial);
2192 #endif
2193 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
2194 featureCode.c_str());
2195 return Void();
2196 }
2197
sendBurstDtmf(int32_t serial,const hidl_string & dtmf,int32_t on,int32_t off)2198 Return<void> RadioImpl_1_6::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
2199 int32_t off) {
2200 #if VDBG
2201 RLOGD("sendBurstDtmf: serial %d", serial);
2202 #endif
2203 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF, false,
2204 3, dtmf.c_str(), (std::to_string(on)).c_str(),
2205 (std::to_string(off)).c_str());
2206 return Void();
2207 }
2208
constructCdmaSms(RIL_CDMA_SMS_Message & rcsm,const CdmaSmsMessage & sms)2209 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
2210 rcsm.uTeleserviceID = sms.teleserviceId;
2211 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
2212 rcsm.uServicecategory = sms.serviceCategory;
2213 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
2214 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
2215 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
2216 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
2217
2218 rcsm.sAddress.number_of_digits = sms.address.digits.size();
2219 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
2220 for (int i = 0; i < digitLimit; i++) {
2221 rcsm.sAddress.digits[i] = sms.address.digits[i];
2222 }
2223
2224 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
2225 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
2226
2227 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
2228 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
2229 for (int i = 0; i < digitLimit; i++) {
2230 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
2231 }
2232
2233 rcsm.uBearerDataLen = sms.bearerData.size();
2234 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
2235 for (int i = 0; i < digitLimit; i++) {
2236 rcsm.aBearerData[i] = sms.bearerData[i];
2237 }
2238 }
2239
sendCdmaSms(int32_t serial,const CdmaSmsMessage & sms)2240 Return<void> RadioImpl_1_6::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
2241 #if VDBG
2242 RLOGD("sendCdmaSms: serial %d", serial);
2243 #endif
2244 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
2245 if (pRI == NULL) {
2246 return Void();
2247 }
2248
2249 RIL_CDMA_SMS_Message rcsm = {};
2250 constructCdmaSms(rcsm, sms);
2251
2252 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
2253 return Void();
2254 }
2255
sendCdmaSms_1_6(int32_t serial,const CdmaSmsMessage & sms)2256 Return<void> RadioImpl_1_6::sendCdmaSms_1_6(int32_t serial, const CdmaSmsMessage& sms) {
2257 #if VDBG
2258 RLOGD("sendCdmaSms: serial %d", serial);
2259 #endif
2260 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
2261 if (pRI == NULL) {
2262 return Void();
2263 }
2264
2265 RIL_CDMA_SMS_Message rcsm = {};
2266 constructCdmaSms(rcsm, sms);
2267
2268 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
2269 return Void();
2270 }
2271
acknowledgeLastIncomingCdmaSms(int32_t serial,const CdmaSmsAck & smsAck)2272 Return<void> RadioImpl_1_6::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
2273 #if VDBG
2274 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
2275 #endif
2276 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
2277 if (pRI == NULL) {
2278 return Void();
2279 }
2280
2281 RIL_CDMA_SMS_Ack rcsa = {};
2282
2283 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
2284 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
2285
2286 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
2287 return Void();
2288 }
2289
getGsmBroadcastConfig(int32_t serial)2290 Return<void> RadioImpl_1_6::getGsmBroadcastConfig(int32_t serial) {
2291 #if VDBG
2292 RLOGD("getGsmBroadcastConfig: serial %d", serial);
2293 #endif
2294 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
2295 return Void();
2296 }
2297
setGsmBroadcastConfig(int32_t serial,const hidl_vec<GsmBroadcastSmsConfigInfo> & configInfo)2298 Return<void> RadioImpl_1_6::setGsmBroadcastConfig(int32_t serial,
2299 const hidl_vec<GsmBroadcastSmsConfigInfo>&
2300 configInfo) {
2301 #if VDBG
2302 RLOGD("setGsmBroadcastConfig: serial %d", serial);
2303 #endif
2304 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2305 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
2306 if (pRI == NULL) {
2307 return Void();
2308 }
2309
2310 int num = configInfo.size();
2311 if (num > MAX_BROADCAST_SMS_CONFIG_INFO) {
2312 RLOGE("setGsmBroadcastConfig: Invalid configInfo length %s",
2313 requestToString(pRI->pCI->requestNumber));
2314 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2315 return Void();
2316 }
2317 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
2318 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
2319
2320 for (int i = 0 ; i < num ; i++ ) {
2321 gsmBciPtrs[i] = &gsmBci[i];
2322 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
2323 gsmBci[i].toServiceId = configInfo[i].toServiceId;
2324 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
2325 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
2326 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
2327 }
2328
2329 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs,
2330 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
2331 return Void();
2332 }
2333
setGsmBroadcastActivation(int32_t serial,bool activate)2334 Return<void> RadioImpl_1_6::setGsmBroadcastActivation(int32_t serial, bool activate) {
2335 #if VDBG
2336 RLOGD("setGsmBroadcastActivation: serial %d", serial);
2337 #endif
2338 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
2339 1, BOOL_TO_INT(!activate));
2340 return Void();
2341 }
2342
getCdmaBroadcastConfig(int32_t serial)2343 Return<void> RadioImpl_1_6::getCdmaBroadcastConfig(int32_t serial) {
2344 #if VDBG
2345 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
2346 #endif
2347 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
2348 return Void();
2349 }
2350
setCdmaBroadcastConfig(int32_t serial,const hidl_vec<CdmaBroadcastSmsConfigInfo> & configInfo)2351 Return<void> RadioImpl_1_6::setCdmaBroadcastConfig(int32_t serial,
2352 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
2353 configInfo) {
2354 #if VDBG
2355 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
2356 #endif
2357 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2358 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
2359 if (pRI == NULL) {
2360 return Void();
2361 }
2362
2363 int num = configInfo.size();
2364 if (num > MAX_BROADCAST_SMS_CONFIG_INFO) {
2365 RLOGE("setCdmaBroadcastConfig: Invalid configInfo length %s",
2366 requestToString(pRI->pCI->requestNumber));
2367 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2368 return Void();
2369 }
2370 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
2371 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
2372
2373 for (int i = 0 ; i < num ; i++ ) {
2374 cdmaBciPtrs[i] = &cdmaBci[i];
2375 cdmaBci[i].service_category = configInfo[i].serviceCategory;
2376 cdmaBci[i].language = configInfo[i].language;
2377 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
2378 }
2379
2380 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs,
2381 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
2382 return Void();
2383 }
2384
setCdmaBroadcastActivation(int32_t serial,bool activate)2385 Return<void> RadioImpl_1_6::setCdmaBroadcastActivation(int32_t serial, bool activate) {
2386 #if VDBG
2387 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
2388 #endif
2389 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
2390 1, BOOL_TO_INT(!activate));
2391 return Void();
2392 }
2393
getCDMASubscription(int32_t serial)2394 Return<void> RadioImpl_1_6::getCDMASubscription(int32_t serial) {
2395 #if VDBG
2396 RLOGD("getCDMASubscription: serial %d", serial);
2397 #endif
2398 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
2399 return Void();
2400 }
2401
writeSmsToRuim(int32_t serial,const CdmaSmsWriteArgs & cdmaSms)2402 Return<void> RadioImpl_1_6::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
2403 #if VDBG
2404 RLOGD("writeSmsToRuim: serial %d", serial);
2405 #endif
2406 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2407 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
2408 if (pRI == NULL) {
2409 return Void();
2410 }
2411
2412 RIL_CDMA_SMS_WriteArgs rcsw = {};
2413 rcsw.status = (int) cdmaSms.status;
2414 constructCdmaSms(rcsw.message, cdmaSms.message);
2415
2416 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
2417 return Void();
2418 }
2419
deleteSmsOnRuim(int32_t serial,int32_t index)2420 Return<void> RadioImpl_1_6::deleteSmsOnRuim(int32_t serial, int32_t index) {
2421 #if VDBG
2422 RLOGD("deleteSmsOnRuim: serial %d", serial);
2423 #endif
2424 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
2425 return Void();
2426 }
2427
getDeviceIdentity(int32_t serial)2428 Return<void> RadioImpl_1_6::getDeviceIdentity(int32_t serial) {
2429 #if VDBG
2430 RLOGD("getDeviceIdentity: serial %d", serial);
2431 #endif
2432 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
2433 return Void();
2434 }
2435
exitEmergencyCallbackMode(int32_t serial)2436 Return<void> RadioImpl_1_6::exitEmergencyCallbackMode(int32_t serial) {
2437 #if VDBG
2438 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
2439 #endif
2440 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
2441 return Void();
2442 }
2443
getSmscAddress(int32_t serial)2444 Return<void> RadioImpl_1_6::getSmscAddress(int32_t serial) {
2445 #if VDBG
2446 RLOGD("getSmscAddress: serial %d", serial);
2447 #endif
2448 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
2449 return Void();
2450 }
2451
setSmscAddress(int32_t serial,const hidl_string & smsc)2452 Return<void> RadioImpl_1_6::setSmscAddress(int32_t serial, const hidl_string& smsc) {
2453 #if VDBG
2454 RLOGD("setSmscAddress: serial %d", serial);
2455 #endif
2456 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
2457 smsc.c_str());
2458 return Void();
2459 }
2460
reportSmsMemoryStatus(int32_t serial,bool available)2461 Return<void> RadioImpl_1_6::reportSmsMemoryStatus(int32_t serial, bool available) {
2462 #if VDBG
2463 RLOGD("reportSmsMemoryStatus: serial %d", serial);
2464 #endif
2465 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
2466 BOOL_TO_INT(available));
2467 return Void();
2468 }
2469
reportStkServiceIsRunning(int32_t serial)2470 Return<void> RadioImpl_1_6::reportStkServiceIsRunning(int32_t serial) {
2471 #if VDBG
2472 RLOGD("reportStkServiceIsRunning: serial %d", serial);
2473 #endif
2474 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
2475 return Void();
2476 }
2477
getCdmaSubscriptionSource(int32_t serial)2478 Return<void> RadioImpl_1_6::getCdmaSubscriptionSource(int32_t serial) {
2479 #if VDBG
2480 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
2481 #endif
2482 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
2483 return Void();
2484 }
2485
requestIsimAuthentication(int32_t serial,const hidl_string & challenge)2486 Return<void> RadioImpl_1_6::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
2487 #if VDBG
2488 RLOGD("requestIsimAuthentication: serial %d", serial);
2489 #endif
2490 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
2491 challenge.c_str());
2492 return Void();
2493 }
2494
acknowledgeIncomingGsmSmsWithPdu(int32_t serial,bool success,const hidl_string & ackPdu)2495 Return<void> RadioImpl_1_6::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
2496 const hidl_string& ackPdu) {
2497 #if VDBG
2498 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
2499 #endif
2500 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, false,
2501 2, success ? "1" : "0", ackPdu.c_str());
2502 return Void();
2503 }
2504
sendEnvelopeWithStatus(int32_t serial,const hidl_string & contents)2505 Return<void> RadioImpl_1_6::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
2506 #if VDBG
2507 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
2508 #endif
2509 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
2510 contents.c_str());
2511 return Void();
2512 }
2513
getVoiceRadioTechnology(int32_t serial)2514 Return<void> RadioImpl_1_6::getVoiceRadioTechnology(int32_t serial) {
2515 #if VDBG
2516 RLOGD("getVoiceRadioTechnology: serial %d", serial);
2517 #endif
2518 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
2519 return Void();
2520 }
2521
getCellInfoList(int32_t serial)2522 Return<void> RadioImpl_1_6::getCellInfoList(int32_t serial) {
2523 #if VDBG
2524 RLOGD("getCellInfoList: serial %d", serial);
2525 #endif
2526 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
2527 return Void();
2528 }
2529
getCellInfoList_1_6(int32_t serial)2530 Return<void> RadioImpl_1_6::getCellInfoList_1_6(int32_t serial) {
2531 #if VDBG
2532 RLOGD("getCellInfoList_1_6: serial %d", serial);
2533 #endif
2534 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST_1_6);
2535 return Void();
2536 }
2537
setCellInfoListRate(int32_t serial,int32_t rate)2538 Return<void> RadioImpl_1_6::setCellInfoListRate(int32_t serial, int32_t rate) {
2539 #if VDBG
2540 RLOGD("setCellInfoListRate: serial %d", serial);
2541 #endif
2542 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
2543 return Void();
2544 }
2545
setInitialAttachApn(int32_t serial,const DataProfileInfo & dataProfileInfo,bool modemCognitive,bool isRoaming)2546 Return<void> RadioImpl_1_6::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
2547 bool modemCognitive, bool isRoaming) {
2548 #if VDBG
2549 RLOGD("setInitialAttachApn: serial %d", serial);
2550 #endif
2551 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2552 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
2553 if (pRI == NULL) {
2554 return Void();
2555 }
2556
2557 if (s_vendorFunctions->version <= 14) {
2558 RIL_InitialAttachApn iaa = {};
2559
2560 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2561 return Void();
2562 }
2563
2564 const hidl_string &protocol =
2565 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
2566
2567 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
2568 memsetAndFreeStrings(1, iaa.apn);
2569 return Void();
2570 }
2571 iaa.authtype = (int) dataProfileInfo.authType;
2572 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2573 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2574 return Void();
2575 }
2576 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2577 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
2578 return Void();
2579 }
2580
2581 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2582
2583 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
2584 } else {
2585 RIL_InitialAttachApn_v15 iaa = {};
2586
2587 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2588 return Void();
2589 }
2590
2591 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
2592 memsetAndFreeStrings(1, iaa.apn);
2593 return Void();
2594 }
2595 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
2596 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2597 return Void();
2598 }
2599 iaa.authtype = (int) dataProfileInfo.authType;
2600 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2601 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
2602 return Void();
2603 }
2604 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2605 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
2606 return Void();
2607 }
2608 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
2609 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
2610 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
2611 iaa.mtu = dataProfileInfo.mtu;
2612
2613 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
2614 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2615 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2616 iaa.password);
2617 return Void();
2618 }
2619
2620 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
2621 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2622 iaa.password);
2623 return Void();
2624 }
2625
2626 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2627
2628 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2629 iaa.password, iaa.mvnoMatchData);
2630 }
2631
2632 return Void();
2633 }
2634
getImsRegistrationState(int32_t serial)2635 Return<void> RadioImpl_1_6::getImsRegistrationState(int32_t serial) {
2636 #if VDBG
2637 RLOGD("getImsRegistrationState: serial %d", serial);
2638 #endif
2639 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2640 return Void();
2641 }
2642
dispatchImsGsmSms(const ImsSmsMessage & message,RequestInfo * pRI)2643 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2644 RIL_IMS_SMS_Message rism = {};
2645 char **pStrings;
2646 int countStrings = 2;
2647 int dataLen = sizeof(char *) * countStrings;
2648
2649 rism.tech = RADIO_TECH_3GPP;
2650 rism.retry = BOOL_TO_INT(message.retry);
2651 rism.messageRef = message.messageRef;
2652
2653 if (message.gsmMessage.size() != 1) {
2654 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2655 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2656 return false;
2657 }
2658
2659 pStrings = (char **)calloc(countStrings, sizeof(char *));
2660 if (pStrings == NULL) {
2661 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2662 requestToString(pRI->pCI->requestNumber));
2663 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2664 return false;
2665 }
2666
2667 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2668 #ifdef MEMSET_FREED
2669 memset(pStrings, 0, dataLen);
2670 #endif
2671 free(pStrings);
2672 return false;
2673 }
2674
2675 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2676 memsetAndFreeStrings(1, pStrings[0]);
2677 #ifdef MEMSET_FREED
2678 memset(pStrings, 0, dataLen);
2679 #endif
2680 free(pStrings);
2681 return false;
2682 }
2683
2684 rism.message.gsmMessage = pStrings;
2685 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2686 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2687
2688 for (int i = 0 ; i < countStrings ; i++) {
2689 memsetAndFreeStrings(1, pStrings[i]);
2690 }
2691
2692 #ifdef MEMSET_FREED
2693 memset(pStrings, 0, dataLen);
2694 #endif
2695 free(pStrings);
2696
2697 return true;
2698 }
2699
2700 struct ImsCdmaSms {
2701 RIL_IMS_SMS_Message imsSms;
2702 RIL_CDMA_SMS_Message cdmaSms;
2703 };
2704
dispatchImsCdmaSms(const ImsSmsMessage & message,RequestInfo * pRI)2705 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2706 ImsCdmaSms temp = {};
2707
2708 if (message.cdmaMessage.size() != 1) {
2709 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2710 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2711 return false;
2712 }
2713
2714 temp.imsSms.tech = RADIO_TECH_3GPP2;
2715 temp.imsSms.retry = BOOL_TO_INT(message.retry);
2716 temp.imsSms.messageRef = message.messageRef;
2717 temp.imsSms.message.cdmaMessage = &temp.cdmaSms;
2718
2719 constructCdmaSms(temp.cdmaSms, message.cdmaMessage[0]);
2720
2721 // Vendor code expects payload length to include actual msg payload
2722 // (sizeof(RIL_CDMA_SMS_Message)) instead of (RIL_CDMA_SMS_Message *) + size of other fields in
2723 // RIL_IMS_SMS_Message
2724 int payloadLen = sizeof(RIL_RadioTechnologyFamily) + sizeof(uint8_t) + sizeof(int32_t)
2725 + sizeof(RIL_CDMA_SMS_Message);
2726
2727 CALL_ONREQUEST(pRI->pCI->requestNumber, &temp.imsSms, payloadLen, pRI, pRI->socket_id);
2728
2729 return true;
2730 }
2731
sendImsSms(int32_t serial,const ImsSmsMessage & message)2732 Return<void> RadioImpl_1_6::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2733 #if VDBG
2734 RLOGD("sendImsSms: serial %d", serial);
2735 #endif
2736 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2737 if (pRI == NULL) {
2738 return Void();
2739 }
2740
2741 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2742
2743 if (RADIO_TECH_3GPP == format) {
2744 dispatchImsGsmSms(message, pRI);
2745 } else if (RADIO_TECH_3GPP2 == format) {
2746 dispatchImsCdmaSms(message, pRI);
2747 } else {
2748 RLOGE("sendImsSms: Invalid radio tech %s",
2749 requestToString(pRI->pCI->requestNumber));
2750 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2751 }
2752 return Void();
2753 }
2754
iccTransmitApduBasicChannel(int32_t serial,const SimApdu & message)2755 Return<void> RadioImpl_1_6::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2756 #if VDBG
2757 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2758 #endif
2759 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2760 return Void();
2761 }
2762
iccOpenLogicalChannel(int32_t serial,const hidl_string & aid,int32_t p2)2763 Return<void> RadioImpl_1_6::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2764 #if VDBG
2765 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2766 #endif
2767 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2768 if (pRI == NULL) {
2769 return Void();
2770 }
2771
2772 RIL_OpenChannelParams params = {};
2773
2774 params.p2 = p2;
2775
2776 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2777 return Void();
2778 }
2779
2780 CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId);
2781
2782 memsetAndFreeStrings(1, params.aidPtr);
2783 return Void();
2784 }
2785
iccCloseLogicalChannel(int32_t serial,int32_t channelId)2786 Return<void> RadioImpl_1_6::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2787 #if VDBG
2788 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2789 #endif
2790 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2791 return Void();
2792 }
2793
iccTransmitApduLogicalChannel(int32_t serial,const SimApdu & message)2794 Return<void> RadioImpl_1_6::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2795 #if VDBG
2796 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2797 #endif
2798 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2799 return Void();
2800 }
2801
nvReadItem(int32_t serial,NvItem itemId)2802 Return<void> RadioImpl_1_6::nvReadItem(int32_t serial, NvItem itemId) {
2803 #if VDBG
2804 RLOGD("nvReadItem: serial %d", serial);
2805 #endif
2806 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2807 if (pRI == NULL) {
2808 return Void();
2809 }
2810
2811 RIL_NV_ReadItem nvri = {};
2812 nvri.itemID = (RIL_NV_Item) itemId;
2813
2814 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2815 return Void();
2816 }
2817
nvWriteItem(int32_t serial,const NvWriteItem & item)2818 Return<void> RadioImpl_1_6::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2819 #if VDBG
2820 RLOGD("nvWriteItem: serial %d", serial);
2821 #endif
2822 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2823 if (pRI == NULL) {
2824 return Void();
2825 }
2826
2827 RIL_NV_WriteItem nvwi = {};
2828
2829 nvwi.itemID = (RIL_NV_Item) item.itemId;
2830
2831 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2832 return Void();
2833 }
2834
2835 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2836
2837 memsetAndFreeStrings(1, nvwi.value);
2838 return Void();
2839 }
2840
nvWriteCdmaPrl(int32_t serial,const hidl_vec<uint8_t> & prl)2841 Return<void> RadioImpl_1_6::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2842 #if VDBG
2843 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2844 #endif
2845 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2846 return Void();
2847 }
2848
nvResetConfig(int32_t serial,ResetNvType resetType)2849 Return<void> RadioImpl_1_6::nvResetConfig(int32_t serial, ResetNvType resetType) {
2850 int rilResetType = -1;
2851 #if VDBG
2852 RLOGD("nvResetConfig: serial %d", serial);
2853 #endif
2854 /* Convert ResetNvType to RIL.h values
2855 * RIL_REQUEST_NV_RESET_CONFIG
2856 * 1 - reload all NV items
2857 * 2 - erase NV reset (SCRTN)
2858 * 3 - factory reset (RTN)
2859 */
2860 switch(resetType) {
2861 case ResetNvType::RELOAD:
2862 rilResetType = 1;
2863 break;
2864 case ResetNvType::ERASE:
2865 rilResetType = 2;
2866 break;
2867 case ResetNvType::FACTORY_RESET:
2868 rilResetType = 3;
2869 break;
2870 }
2871 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2872 return Void();
2873 }
2874
setUiccSubscription(int32_t serial,const SelectUiccSub & uiccSub)2875 Return<void> RadioImpl_1_6::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2876 #if VDBG
2877 RLOGD("setUiccSubscription: serial %d", serial);
2878 #endif
2879 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2880 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2881 if (pRI == NULL) {
2882 return Void();
2883 }
2884
2885 RIL_SelectUiccSub rilUiccSub = {};
2886
2887 rilUiccSub.slot = uiccSub.slot;
2888 rilUiccSub.app_index = uiccSub.appIndex;
2889 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2890 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2891
2892 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2893 return Void();
2894 }
2895
setDataAllowed(int32_t serial,bool allow)2896 Return<void> RadioImpl_1_6::setDataAllowed(int32_t serial, bool allow) {
2897 #if VDBG
2898 RLOGD("setDataAllowed: serial %d", serial);
2899 #endif
2900 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2901 return Void();
2902 }
2903
getHardwareConfig(int32_t serial)2904 Return<void> RadioImpl_1_6::getHardwareConfig(int32_t serial) {
2905 #if VDBG
2906 RLOGD("getHardwareConfig: serial %d", serial);
2907 #endif
2908 RLOGD("getHardwareConfig: serial %d, mSlotId = %d", serial, mSlotId);
2909 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2910 return Void();
2911 }
2912
requestIccSimAuthentication(int32_t serial,int32_t authContext,const hidl_string & authData,const hidl_string & aid)2913 Return<void> RadioImpl_1_6::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2914 const hidl_string& authData, const hidl_string& aid) {
2915 #if VDBG
2916 RLOGD("requestIccSimAuthentication: serial %d", serial);
2917 #endif
2918 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2919 if (pRI == NULL) {
2920 return Void();
2921 }
2922
2923 RIL_SimAuthentication pf = {};
2924
2925 pf.authContext = authContext;
2926
2927 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2928 return Void();
2929 }
2930
2931 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2932 memsetAndFreeStrings(1, pf.authData);
2933 return Void();
2934 }
2935
2936 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2937
2938 memsetAndFreeStrings(2, pf.authData, pf.aid);
2939 return Void();
2940 }
2941
2942 /**
2943 * @param numProfiles number of data profile
2944 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2945 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2946 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2947 * @param numfields number of string-type member in the data profile structure
2948 * @param ... the variadic parameters are pointers to each string-type member
2949 **/
2950 template <typename T>
freeSetDataProfileData(int numProfiles,T * dataProfiles,T ** dataProfilePtrs,int numfields,...)2951 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2952 int numfields, ...) {
2953 va_list args;
2954 va_start(args, numfields);
2955
2956 // Iterate through each string-type field that need to be free.
2957 for (int i = 0; i < numfields; i++) {
2958 // Iterate through each data profile and free that specific string-type field.
2959 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2960 char *T::*ptr = va_arg(args, char *T::*);
2961 for (int j = 0; j < numProfiles; j++) {
2962 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2963 }
2964 }
2965
2966 va_end(args);
2967
2968 #ifdef MEMSET_FREED
2969 memset(dataProfiles, 0, numProfiles * sizeof(T));
2970 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2971 #endif
2972 free(dataProfiles);
2973 free(dataProfilePtrs);
2974 }
2975
setDataProfile(int32_t serial,const hidl_vec<DataProfileInfo> & profiles,bool isRoaming)2976 Return<void> RadioImpl_1_6::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2977 bool isRoaming) {
2978 #if VDBG
2979 RLOGD("setDataProfile: serial %d", serial);
2980 #endif
2981 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2982 if (pRI == NULL) {
2983 return Void();
2984 }
2985
2986 size_t num = profiles.size();
2987 bool success = false;
2988
2989 if (s_vendorFunctions->version <= 14) {
2990
2991 RIL_DataProfileInfo *dataProfiles =
2992 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2993
2994 if (dataProfiles == NULL) {
2995 RLOGE("Memory allocation failed for request %s",
2996 requestToString(pRI->pCI->requestNumber));
2997 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2998 return Void();
2999 }
3000
3001 RIL_DataProfileInfo **dataProfilePtrs =
3002 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
3003 if (dataProfilePtrs == NULL) {
3004 RLOGE("Memory allocation failed for request %s",
3005 requestToString(pRI->pCI->requestNumber));
3006 free(dataProfiles);
3007 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3008 return Void();
3009 }
3010
3011 for (size_t i = 0; i < num; i++) {
3012 dataProfilePtrs[i] = &dataProfiles[i];
3013
3014 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
3015
3016 const hidl_string &protocol =
3017 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
3018
3019 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI, true)) {
3020 success = false;
3021 }
3022
3023 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
3024 true)) {
3025 success = false;
3026 }
3027 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
3028 pRI, true)) {
3029 success = false;
3030 }
3031
3032 if (!success) {
3033 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
3034 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
3035 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
3036 return Void();
3037 }
3038
3039 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
3040 dataProfiles[i].authType = (int) profiles[i].authType;
3041 dataProfiles[i].type = (int) profiles[i].type;
3042 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
3043 dataProfiles[i].maxConns = profiles[i].maxConns;
3044 dataProfiles[i].waitTime = profiles[i].waitTime;
3045 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
3046 }
3047
3048 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
3049 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
3050
3051 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
3052 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
3053 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
3054 } else {
3055 RIL_DataProfileInfo_v15 *dataProfiles =
3056 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
3057
3058 if (dataProfiles == NULL) {
3059 RLOGE("Memory allocation failed for request %s",
3060 requestToString(pRI->pCI->requestNumber));
3061 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3062 return Void();
3063 }
3064
3065 RIL_DataProfileInfo_v15 **dataProfilePtrs =
3066 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
3067 if (dataProfilePtrs == NULL) {
3068 RLOGE("Memory allocation failed for request %s",
3069 requestToString(pRI->pCI->requestNumber));
3070 free(dataProfiles);
3071 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3072 return Void();
3073 }
3074
3075 for (size_t i = 0; i < num; i++) {
3076 dataProfilePtrs[i] = &dataProfiles[i];
3077
3078 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
3079 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
3080 pRI)) {
3081 success = false;
3082 }
3083 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
3084 profiles[i].roamingProtocol, pRI, true)) {
3085 success = false;
3086 }
3087 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
3088 true)) {
3089 success = false;
3090 }
3091 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
3092 pRI, true)) {
3093 success = false;
3094 }
3095 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
3096 profiles[i].mvnoMatchData, pRI, true)) {
3097 success = false;
3098 }
3099
3100 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
3101 dataProfiles[i].mvnoType)) {
3102 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3103 success = false;
3104 }
3105
3106 if (!success) {
3107 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
3108 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
3109 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
3110 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
3111 return Void();
3112 }
3113
3114 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
3115 dataProfiles[i].authType = (int) profiles[i].authType;
3116 dataProfiles[i].type = (int) profiles[i].type;
3117 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
3118 dataProfiles[i].maxConns = profiles[i].maxConns;
3119 dataProfiles[i].waitTime = profiles[i].waitTime;
3120 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
3121 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
3122 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
3123 dataProfiles[i].mtu = profiles[i].mtu;
3124 }
3125
3126 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
3127 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
3128
3129 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
3130 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
3131 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
3132 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
3133 }
3134
3135 return Void();
3136 }
3137
requestShutdown(int32_t serial)3138 Return<void> RadioImpl_1_6::requestShutdown(int32_t serial) {
3139 #if VDBG
3140 RLOGD("requestShutdown: serial %d", serial);
3141 #endif
3142 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
3143 return Void();
3144 }
3145
getRadioCapability(int32_t serial)3146 Return<void> RadioImpl_1_6::getRadioCapability(int32_t serial) {
3147 #if VDBG
3148 RLOGD("getRadioCapability: serial %d", serial);
3149 #endif
3150 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
3151 return Void();
3152 }
3153
setRadioCapability(int32_t serial,const RadioCapability & rc)3154 Return<void> RadioImpl_1_6::setRadioCapability(int32_t serial, const RadioCapability& rc) {
3155 #if VDBG
3156 RLOGD("setRadioCapability: serial %d", serial);
3157 #endif
3158 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
3159 if (pRI == NULL) {
3160 return Void();
3161 }
3162
3163 RIL_RadioCapability rilRc = {};
3164
3165 // TODO : set rilRc.version using HIDL version ?
3166 rilRc.session = rc.session;
3167 rilRc.phase = (int) rc.phase;
3168 rilRc.rat = (int) rc.raf;
3169 rilRc.status = (int) rc.status;
3170 strlcpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), sizeof(rilRc.logicalModemUuid));
3171
3172 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
3173
3174 return Void();
3175 }
3176
startLceService(int32_t serial,int32_t reportInterval,bool pullMode)3177 Return<void> RadioImpl_1_6::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
3178 #if VDBG
3179 RLOGD("startLceService: serial %d", serial);
3180 #endif
3181 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
3182 BOOL_TO_INT(pullMode));
3183 return Void();
3184 }
3185
stopLceService(int32_t serial)3186 Return<void> RadioImpl_1_6::stopLceService(int32_t serial) {
3187 #if VDBG
3188 RLOGD("stopLceService: serial %d", serial);
3189 #endif
3190 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
3191 return Void();
3192 }
3193
pullLceData(int32_t serial)3194 Return<void> RadioImpl_1_6::pullLceData(int32_t serial) {
3195 #if VDBG
3196 RLOGD("pullLceData: serial %d", serial);
3197 #endif
3198 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
3199 return Void();
3200 }
3201
getModemActivityInfo(int32_t serial)3202 Return<void> RadioImpl_1_6::getModemActivityInfo(int32_t serial) {
3203 #if VDBG
3204 RLOGD("getModemActivityInfo: serial %d", serial);
3205 #endif
3206 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
3207 return Void();
3208 }
3209
prepareCarrierRestrictions(RIL_CarrierRestrictions & request,bool allAllowed,const hidl_vec<Carrier> & allowedList,const hidl_vec<Carrier> & excludedList,RequestInfo * pRI)3210 int prepareCarrierRestrictions(RIL_CarrierRestrictions &request, bool allAllowed,
3211 const hidl_vec<Carrier>& allowedList,
3212 const hidl_vec<Carrier>& excludedList,
3213 RequestInfo *pRI) {
3214 RIL_Carrier *allowedCarriers = NULL;
3215 RIL_Carrier *excludedCarriers = NULL;
3216
3217 request.len_allowed_carriers = allowedList.size();
3218 allowedCarriers = (RIL_Carrier *)calloc(request.len_allowed_carriers, sizeof(RIL_Carrier));
3219 if (allowedCarriers == NULL) {
3220 RLOGE("prepareCarrierRestrictions: Memory allocation failed for request %s",
3221 requestToString(pRI->pCI->requestNumber));
3222 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3223 return -1;
3224 }
3225 request.allowed_carriers = allowedCarriers;
3226
3227 request.len_excluded_carriers = excludedList.size();
3228 excludedCarriers = (RIL_Carrier *)calloc(request.len_excluded_carriers, sizeof(RIL_Carrier));
3229 if (excludedCarriers == NULL) {
3230 RLOGE("prepareCarrierRestrictions: Memory allocation failed for request %s",
3231 requestToString(pRI->pCI->requestNumber));
3232 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3233 #ifdef MEMSET_FREED
3234 memset(allowedCarriers, 0, request.len_allowed_carriers * sizeof(RIL_Carrier));
3235 #endif
3236 free(allowedCarriers);
3237 return -1;
3238 }
3239 request.excluded_carriers = excludedCarriers;
3240
3241 for (int i = 0; i < request.len_allowed_carriers; i++) {
3242 allowedCarriers[i].mcc = allowedList[i].mcc.c_str();
3243 allowedCarriers[i].mnc = allowedList[i].mnc.c_str();
3244 allowedCarriers[i].match_type = (RIL_CarrierMatchType) allowedList[i].matchType;
3245 allowedCarriers[i].match_data = allowedList[i].matchData.c_str();
3246 }
3247
3248 for (int i = 0; i < request.len_excluded_carriers; i++) {
3249 excludedCarriers[i].mcc = excludedList[i].mcc.c_str();
3250 excludedCarriers[i].mnc = excludedList[i].mnc.c_str();
3251 excludedCarriers[i].match_type =
3252 (RIL_CarrierMatchType) excludedList[i].matchType;
3253 excludedCarriers[i].match_data = excludedList[i].matchData.c_str();
3254 }
3255
3256 return 0;
3257 }
3258
freeCarrierRestrictions(RIL_CarrierRestrictions & request)3259 void freeCarrierRestrictions(RIL_CarrierRestrictions &request) {
3260 if (request.allowed_carriers != NULL) {
3261 #ifdef MEMSET_FREED
3262 memset(request.allowed_carriers, 0, request.len_allowed_carriers * sizeof(RIL_Carrier));
3263 #endif
3264 free(request.allowed_carriers);
3265 }
3266 if (request.excluded_carriers != NULL) {
3267 #ifdef MEMSET_FREED
3268 memset(request.excluded_carriers, 0, request.len_excluded_carriers * sizeof(RIL_Carrier));
3269 #endif
3270 free(request.excluded_carriers);
3271 }
3272 }
3273
setAllowedCarriers(int32_t serial,bool allAllowed,const CarrierRestrictions & carriers)3274 Return<void> RadioImpl_1_6::setAllowedCarriers(int32_t serial, bool allAllowed,
3275 const CarrierRestrictions& carriers) {
3276 #if VDBG
3277 RLOGD("setAllowedCarriers: serial %d", serial);
3278 #endif
3279 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3280 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
3281 if (pRI == NULL) {
3282 return Void();
3283 }
3284
3285 RIL_CarrierRestrictions cr = {};
3286 if (prepareCarrierRestrictions(cr, allAllowed, carriers.allowedCarriers,
3287 carriers.excludedCarriers, pRI) < 0) {
3288 return Void();
3289 }
3290
3291 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
3292
3293 freeCarrierRestrictions(cr);
3294
3295 return Void();
3296 }
3297
getAllowedCarriers(int32_t serial)3298 Return<void> RadioImpl_1_6::getAllowedCarriers(int32_t serial) {
3299 #if VDBG
3300 RLOGD("getAllowedCarriers: serial %d", serial);
3301 #endif
3302 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
3303 return Void();
3304 }
3305
sendDeviceState(int32_t serial,DeviceStateType deviceStateType,bool state)3306 Return<void> RadioImpl_1_6::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
3307 bool state) {
3308 #if VDBG
3309 RLOGD("sendDeviceState: serial %d", serial);
3310 #endif
3311 if (s_vendorFunctions->version < 15) {
3312 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
3313 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
3314 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
3315 } else {
3316 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3317 RIL_REQUEST_SEND_DEVICE_STATE);
3318 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
3319 }
3320 return Void();
3321 }
3322 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
3323 BOOL_TO_INT(state));
3324 return Void();
3325 }
3326
setIndicationFilter(int32_t serial,int32_t indicationFilter)3327 Return<void> RadioImpl_1_6::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
3328 #if VDBG
3329 RLOGD("setIndicationFilter: serial %d", serial);
3330 #endif
3331 if (s_vendorFunctions->version < 15) {
3332 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3333 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
3334 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
3335 return Void();
3336 }
3337 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
3338 return Void();
3339 }
3340
setSimCardPower(int32_t serial,bool powerUp)3341 Return<void> RadioImpl_1_6::setSimCardPower(int32_t serial, bool powerUp) {
3342 #if VDBG
3343 RLOGD("setSimCardPower: serial %d", serial);
3344 #endif
3345 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
3346 return Void();
3347 }
3348
setSimCardPower_1_1(int32_t serial,const V1_1::CardPowerState state)3349 Return<void> RadioImpl_1_6::setSimCardPower_1_1(int32_t serial, const V1_1::CardPowerState state) {
3350 #if VDBG
3351 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
3352 #endif
3353 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
3354 return Void();
3355 }
3356
setSimCardPower_1_6(int32_t serial,const V1_1::CardPowerState state)3357 Return<void> RadioImpl_1_6::setSimCardPower_1_6(int32_t serial, const V1_1::CardPowerState state) {
3358 #if VDBG
3359 RLOGD("setSimCardPower_1_6: serial %d state %d", serial, state);
3360 #endif
3361 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
3362 mSimCardPowerState = state;
3363 return Void();
3364 }
3365
setCarrierInfoForImsiEncryption(int32_t serial,const V1_1::ImsiEncryptionInfo & data)3366 Return<void> RadioImpl_1_6::setCarrierInfoForImsiEncryption(int32_t serial,
3367 const V1_1::ImsiEncryptionInfo& data) {
3368 #if VDBG
3369 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
3370 #endif
3371 RequestInfo *pRI = android::addRequestToList(
3372 serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
3373 if (pRI == NULL) {
3374 return Void();
3375 }
3376
3377 RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
3378
3379 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
3380 return Void();
3381 }
3382 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
3383 memsetAndFreeStrings(1, imsiEncryption.mnc);
3384 return Void();
3385 }
3386 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
3387 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
3388 return Void();
3389 }
3390 imsiEncryption.carrierKeyLength = data.carrierKey.size();
3391 imsiEncryption.carrierKey = new uint8_t[imsiEncryption.carrierKeyLength];
3392 memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), imsiEncryption.carrierKeyLength);
3393 imsiEncryption.expirationTime = data.expirationTime;
3394 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
3395 sizeof(RIL_CarrierInfoForImsiEncryption), pRI, mSlotId);
3396 delete(imsiEncryption.carrierKey);
3397 return Void();
3398 }
3399
startKeepalive(int32_t serial,const V1_1::KeepaliveRequest & keepalive)3400 Return<void> RadioImpl_1_6::startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive) {
3401 #if VDBG
3402 RLOGD("%s(): %d", __FUNCTION__, serial);
3403 #endif
3404 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_KEEPALIVE);
3405 if (pRI == NULL) {
3406 return Void();
3407 }
3408
3409 RIL_KeepaliveRequest kaReq = {};
3410
3411 kaReq.type = static_cast<RIL_KeepaliveType>(keepalive.type);
3412 switch(kaReq.type) {
3413 case NATT_IPV4:
3414 if (keepalive.sourceAddress.size() != 4 ||
3415 keepalive.destinationAddress.size() != 4) {
3416 RLOGE("Invalid address for keepalive!");
3417 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3418 return Void();
3419 }
3420 break;
3421 case NATT_IPV6:
3422 if (keepalive.sourceAddress.size() != 16 ||
3423 keepalive.destinationAddress.size() != 16) {
3424 RLOGE("Invalid address for keepalive!");
3425 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3426 return Void();
3427 }
3428 break;
3429 default:
3430 RLOGE("Unknown packet keepalive type!");
3431 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3432 return Void();
3433 }
3434
3435 ::memcpy(kaReq.sourceAddress, keepalive.sourceAddress.data(), keepalive.sourceAddress.size());
3436 kaReq.sourcePort = keepalive.sourcePort;
3437
3438 ::memcpy(kaReq.destinationAddress,
3439 keepalive.destinationAddress.data(), keepalive.destinationAddress.size());
3440 kaReq.destinationPort = keepalive.destinationPort;
3441
3442 kaReq.maxKeepaliveIntervalMillis = keepalive.maxKeepaliveIntervalMillis;
3443 kaReq.cid = keepalive.cid; // This is the context ID of the data call
3444
3445 CALL_ONREQUEST(pRI->pCI->requestNumber, &kaReq, sizeof(RIL_KeepaliveRequest), pRI, mSlotId);
3446 return Void();
3447 }
3448
stopKeepalive(int32_t serial,int32_t sessionHandle)3449 Return<void> RadioImpl_1_6::stopKeepalive(int32_t serial, int32_t sessionHandle) {
3450 #if VDBG
3451 RLOGD("%s(): %d", __FUNCTION__, serial);
3452 #endif
3453 dispatchInts(serial, mSlotId, RIL_REQUEST_STOP_KEEPALIVE, 1, sessionHandle);
3454 return Void();
3455 }
3456
responseAcknowledgement()3457 Return<void> RadioImpl_1_6::responseAcknowledgement() {
3458 android::releaseWakeLock();
3459 return Void();
3460 }
3461
3462 // Methods from ::android::hardware::radio::V1_2::IRadio follow.
prepareNetworkScanRequest_1_2(RIL_NetworkScanRequest & scan_request,const::android::hardware::radio::V1_2::NetworkScanRequest & request,RequestInfo * pRI)3463 int prepareNetworkScanRequest_1_2(RIL_NetworkScanRequest &scan_request,
3464 const ::android::hardware::radio::V1_2::NetworkScanRequest& request,
3465 RequestInfo *pRI) {
3466
3467 scan_request.type = (RIL_ScanType) request.type;
3468 scan_request.interval = request.interval;
3469 scan_request.specifiers_length = request.specifiers.size();
3470
3471 int intervalLow = static_cast<int>(::android::hardware::radio::V1_2::ScanIntervalRange::MIN);
3472 int intervalHigh = static_cast<int>(::android::hardware::radio::V1_2::ScanIntervalRange::MAX);
3473 int maxSearchTimeLow =
3474 static_cast<int>(::android::hardware::radio::V1_2::MaxSearchTimeRange::MIN);
3475 int maxSearchTimeHigh =
3476 static_cast<int>(::android::hardware::radio::V1_2::MaxSearchTimeRange::MAX);
3477 int incrementalResultsPeriodicityRangeLow =
3478 static_cast<int>(::android::hardware::radio::V1_2::IncrementalResultsPeriodicityRange::MIN);
3479 int incrementalResultsPeriodicityRangeHigh =
3480 static_cast<int>(::android::hardware::radio::V1_2::IncrementalResultsPeriodicityRange::MAX);
3481 uint maxSpecifierSize =
3482 static_cast<uint>(::android::hardware::radio::V1_2::RadioConst
3483 ::RADIO_ACCESS_SPECIFIER_MAX_SIZE);
3484
3485 if (request.interval < intervalLow || request.interval > intervalHigh) {
3486 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3487 return -1;
3488 }
3489 // If defined, must fall in correct range.
3490 if (request.maxSearchTime != 0
3491 && (request.maxSearchTime < maxSearchTimeLow
3492 || request.maxSearchTime > maxSearchTimeHigh)) {
3493 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3494 return -1;
3495 }
3496 if (request.maxSearchTime != 0
3497 && (request.incrementalResultsPeriodicity < incrementalResultsPeriodicityRangeLow
3498 || request.incrementalResultsPeriodicity > incrementalResultsPeriodicityRangeHigh
3499 || request.incrementalResultsPeriodicity > request.maxSearchTime)) {
3500 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3501 return -1;
3502 }
3503 if (request.specifiers.size() == 0 || request.specifiers.size() > maxSpecifierSize) {
3504 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3505 return -1;
3506 }
3507
3508 for (size_t i = 0; i < request.specifiers.size(); ++i) {
3509 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
3510 request.specifiers[i].utranBands.size() > MAX_BANDS ||
3511 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
3512 request.specifiers[i].channels.size() > MAX_CHANNELS) {
3513 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3514 return -1;
3515 }
3516 const V1_1::RadioAccessSpecifier& ras_from =
3517 request.specifiers[i];
3518 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
3519
3520 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
3521 ras_to.channels_length = ras_from.channels.size();
3522
3523 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
3524 const std::vector<uint32_t> * bands = nullptr;
3525 switch (request.specifiers[i].radioAccessNetwork) {
3526 case V1_1::RadioAccessNetworks::GERAN:
3527 ras_to.bands_length = ras_from.geranBands.size();
3528 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
3529 break;
3530 case V1_1::RadioAccessNetworks::UTRAN:
3531 ras_to.bands_length = ras_from.utranBands.size();
3532 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
3533 break;
3534 case V1_1::RadioAccessNetworks::EUTRAN:
3535 ras_to.bands_length = ras_from.eutranBands.size();
3536 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
3537 break;
3538 default:
3539 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3540 return -1;
3541 }
3542 // safe to copy to geran_bands because it's a union member
3543 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
3544 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
3545 }
3546 }
3547
3548 return 0;
3549 }
3550
startNetworkScan_1_2(int32_t serial,const::android::hardware::radio::V1_2::NetworkScanRequest & request)3551 Return<void> RadioImpl_1_6::startNetworkScan_1_2(int32_t serial,
3552 const ::android::hardware::radio::V1_2::NetworkScanRequest& request) {
3553 #if VDBG
3554 RLOGD("startNetworkScan_1_2: serial %d", serial);
3555 #endif
3556
3557 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
3558 if (pRI == NULL) {
3559 return Void();
3560 }
3561
3562 RIL_NetworkScanRequest scan_request = {};
3563
3564 if (prepareNetworkScanRequest_1_2(scan_request, request, pRI) < 0) {
3565 return Void();
3566 }
3567
3568 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
3569 mSlotId);
3570
3571 return Void();
3572 }
3573
setIndicationFilter_1_2(int32_t serial,::android::hardware::hidl_bitfield<V1_2::IndicationFilter> indicationFilter)3574 Return<void> RadioImpl_1_6::setIndicationFilter_1_2(int32_t serial,
3575 ::android::hardware::hidl_bitfield<V1_2::IndicationFilter> indicationFilter) {
3576 #if VDBG
3577 RLOGD("setIndicationFilter_1_2: serial %d", serial);
3578 #endif
3579
3580 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3581 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
3582 sendErrorResponse(pRI, RIL_E_SUCCESS); // TODO: for vts
3583 return Void();
3584 }
3585
setSignalStrengthReportingCriteria(int32_t serial,int32_t hysteresisMs,int32_t hysteresisDb,const hidl_vec<int32_t> & thresholdsDbm,::android::hardware::radio::V1_2::AccessNetwork accessNetwork)3586 Return<void> RadioImpl_1_6::setSignalStrengthReportingCriteria(int32_t serial,
3587 int32_t hysteresisMs, int32_t hysteresisDb,
3588 const hidl_vec<int32_t>& thresholdsDbm,
3589 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork) {
3590 #if VDBG
3591 RLOGD("setSignalStrengthReportingCriteria: %d", serial);
3592 #endif
3593 RIL_Errno e;
3594 if (radioService[mSlotId]->mRadioResponseV1_2 != NULL) {
3595 RadioResponseInfo responseInfo = {};
3596 if (hysteresisDb >= 10) {
3597 e = RIL_E_INVALID_ARGUMENTS;
3598 } else {
3599 e = RIL_E_SUCCESS;
3600 }
3601 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, e);
3602 Return<void> retStatus =
3603 radioService[mSlotId]
3604 ->mRadioResponseV1_2->setSignalStrengthReportingCriteriaResponse(
3605 responseInfo);
3606 radioService[mSlotId]->checkReturnStatus(retStatus);
3607 } else {
3608 RLOGE("setSignalStrengthReportingCriteria: radioService[%d]->mRadioResponse == NULL",
3609 mSlotId);
3610 }
3611 return Void();
3612 }
3613
setLinkCapacityReportingCriteria(int32_t serial,int32_t hysteresisMs,int32_t hysteresisDlKbps,int32_t hysteresisUlKbps,const hidl_vec<int32_t> & thresholdsDownlinkKbps,const hidl_vec<int32_t> & thresholdsUplinkKbps,V1_2::AccessNetwork accessNetwork)3614 Return<void> RadioImpl_1_6::setLinkCapacityReportingCriteria(int32_t serial,
3615 int32_t hysteresisMs, int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
3616 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
3617 const hidl_vec<int32_t>& thresholdsUplinkKbps,
3618 V1_2::AccessNetwork accessNetwork) {
3619 #if VDBG
3620 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3621 RLOGD("setLinkCapacityReportingCriteria: %d", serial);
3622 #endif
3623
3624 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3625 RIL_REQUEST_SET_LINK_CAPACITY_REPORTING_CRITERIA);
3626 if (pRI == NULL) {
3627 return Void();
3628 }
3629 // TODO: for vts. hysteresisDlKbps and hysteresisUlKbps range not confirmed
3630 if (hysteresisDlKbps >= 5000 || hysteresisUlKbps >= 1000) {
3631 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3632 return Void();
3633 } else {
3634 sendErrorResponse(pRI, RIL_E_SUCCESS);
3635 }
3636 return Void();
3637 }
3638
setupDataCall_1_2(int32_t serial,V1_2::AccessNetwork accessNetwork,const V1_0::DataProfileInfo & dataProfileInfo,bool modemCognitive,bool roamingAllowed,bool isRoaming,V1_2::DataRequestReason reason,const hidl_vec<hidl_string> & addresses,const hidl_vec<hidl_string> & dnses)3639 Return<void> RadioImpl_1_6::setupDataCall_1_2(int32_t serial, V1_2::AccessNetwork accessNetwork,
3640 const V1_0::DataProfileInfo& dataProfileInfo, bool modemCognitive,
3641 bool roamingAllowed, bool isRoaming, V1_2::DataRequestReason reason,
3642 const hidl_vec<hidl_string>& addresses, const hidl_vec<hidl_string>& dnses) {
3643 #if VDBG
3644 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3645 RLOGD("setupDataCall_1_2: serial %d", serial);
3646 #endif
3647
3648 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
3649 const hidl_string &protocol =
3650 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
3651 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 7,
3652 std::to_string((int)accessNetwork).c_str(),
3653 std::to_string((int)dataProfileInfo.profileId).c_str(),
3654 dataProfileInfo.apn.c_str(),
3655 dataProfileInfo.user.c_str(),
3656 dataProfileInfo.password.c_str(),
3657 std::to_string((int)dataProfileInfo.authType).c_str(),
3658 protocol.c_str());
3659 } else if (s_vendorFunctions->version >= 15) {
3660 char *mvnoTypeStr = NULL;
3661 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
3662 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3663 RIL_REQUEST_SETUP_DATA_CALL);
3664 if (pRI != NULL) {
3665 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3666 }
3667 return Void();
3668 }
3669 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
3670 std::to_string((int)accessNetwork).c_str(),
3671 std::to_string((int)dataProfileInfo.profileId).c_str(),
3672 dataProfileInfo.apn.c_str(),
3673 dataProfileInfo.user.c_str(),
3674 dataProfileInfo.password.c_str(),
3675 std::to_string((int) dataProfileInfo.authType).c_str(),
3676 dataProfileInfo.protocol.c_str(),
3677 dataProfileInfo.roamingProtocol.c_str(),
3678 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
3679 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
3680 modemCognitive ? "1" : "0",
3681 std::to_string(dataProfileInfo.mtu).c_str(),
3682 mvnoTypeStr,
3683 dataProfileInfo.mvnoMatchData.c_str(),
3684 roamingAllowed ? "1" : "0");
3685 } else {
3686 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
3687 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3688 RIL_REQUEST_SETUP_DATA_CALL);
3689 if (pRI != NULL) {
3690 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
3691 }
3692 }
3693 return Void();
3694 }
3695
deactivateDataCall_1_2(int32_t serial,int32_t cid,::android::hardware::radio::V1_2::DataRequestReason reason)3696 Return<void> RadioImpl_1_6::deactivateDataCall_1_2(int32_t serial, int32_t cid,
3697 ::android::hardware::radio::V1_2::DataRequestReason reason) {
3698 #if VDBG
3699 RLOGD("deactivateDataCall_1_2: serial %d", serial);
3700 #endif
3701
3702 RIL_DataRequestReason dataRequestReason = (RIL_DataRequestReason)reason;
3703 const char *reasonStr = NULL;
3704 switch (dataRequestReason) {
3705 case DATA_REQ_REASOPN_NORMAL:
3706 reasonStr = "normal";
3707 break;
3708 case DATA_REQ_REASOPN_SHUTDOWN:
3709 reasonStr = "shutdown";
3710 break;
3711 case DATA_REQ_REASOPN_HANDOVER:
3712 reasonStr = "handover";
3713 break;
3714 default:
3715 reasonStr = "unknown";
3716 break;
3717 }
3718
3719 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, false,
3720 2, (std::to_string(cid)).c_str(), reasonStr);
3721 return Void();
3722 }
3723
3724 // Methods from ::android::hardware::radio::V1_3::IRadio follow.
setSystemSelectionChannels(int32_t serial,bool,const hidl_vec<::android::hardware::radio::V1_1::RadioAccessSpecifier> &)3725 Return<void> RadioImpl_1_6::setSystemSelectionChannels(int32_t serial, bool /* specifyChannels */,
3726 const hidl_vec<::android::hardware::radio::V1_1::RadioAccessSpecifier>& /* specifiers */) {
3727 #if VDBG
3728 RLOGD("setSystemSelectionChannels: serial %d", serial);
3729 #endif
3730 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS);
3731 return Void();
3732 }
3733
enableModem(int32_t serial,bool)3734 Return<void> RadioImpl_1_6::enableModem(int32_t serial, bool /* on */) {
3735 #if VDBG
3736 RLOGE("enableModem: serial = %d", serial);
3737 #endif
3738 dispatchVoid(serial, mSlotId, RIL_REQUEST_ENABLE_MODEM);
3739 return Void();
3740 }
3741
getModemStackStatus(int32_t serial)3742 Return<void> RadioImpl_1_6::getModemStackStatus(int32_t serial) {
3743 #if VDBG
3744 RLOGD("getModemStackStatus: serial %d", serial);
3745 #endif
3746 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MODEM_STACK_STATUS);
3747 return Void();
3748 }
3749
getProtocolString(const::android::hardware::radio::V1_4::PdpProtocolType protocolVal)3750 const char * getProtocolString(const ::android::hardware::radio::V1_4::PdpProtocolType protocolVal) {
3751 switch(protocolVal) {
3752 case ::android::hardware::radio::V1_4::PdpProtocolType::IP:
3753 return "IP";
3754 case ::android::hardware::radio::V1_4::PdpProtocolType::IPV6:
3755 return "IPV6";
3756 case ::android::hardware::radio::V1_4::PdpProtocolType::IPV4V6:
3757 return "IPV4V6";
3758 case ::android::hardware::radio::V1_4::PdpProtocolType::PPP:
3759 return "PPP";
3760 case ::android::hardware::radio::V1_4::PdpProtocolType::NON_IP:
3761 return "NON_IP";
3762 case ::android::hardware::radio::V1_4::PdpProtocolType::UNSTRUCTURED:
3763 return "UNSTRUCTURED";
3764 default:
3765 return "UNKNOWN";
3766 }
3767 }
3768
3769 // Methods from ::android::hardware::radio::V1_4::IRadio follow.
setAllowedCarriers_1_4(int32_t serial,const V1_4::CarrierRestrictionsWithPriority & carriers,V1_4::SimLockMultiSimPolicy multiSimPolicy)3770 Return<void> RadioImpl_1_6::setAllowedCarriers_1_4(int32_t serial,
3771 const V1_4::CarrierRestrictionsWithPriority& carriers,
3772 V1_4::SimLockMultiSimPolicy multiSimPolicy) {
3773 #if VDBG
3774 RLOGD("setAllowedCarriers_1_4: serial %d", serial);
3775 #endif
3776
3777 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3778 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
3779 if (pRI == NULL) {
3780 return Void();
3781 }
3782
3783 // Prepare legacy structure (defined in IRadio 1.0) to reuse existing code.
3784 RIL_CarrierRestrictions cr = {};
3785 if (prepareCarrierRestrictions(cr, false, carriers.allowedCarriers, carriers.excludedCarriers,
3786 pRI) < 0) {
3787 return Void();
3788 }
3789 // Copy the legacy structure into the new structure (defined in IRadio 1.4)
3790 RIL_CarrierRestrictionsWithPriority crExt = {};
3791 crExt.len_allowed_carriers = cr.len_allowed_carriers;
3792 crExt.allowed_carriers = cr.allowed_carriers;
3793 crExt.len_excluded_carriers = cr.len_excluded_carriers;
3794 crExt.excluded_carriers = cr.excluded_carriers;
3795 crExt.allowedCarriersPrioritized = BOOL_TO_INT(carriers.allowedCarriersPrioritized);
3796 crExt.multiSimPolicy = (RIL_SimLockMultiSimPolicy)multiSimPolicy;
3797
3798 CALL_ONREQUEST(pRI->pCI->requestNumber, &crExt, sizeof(RIL_CarrierRestrictionsWithPriority),
3799 pRI, mSlotId);
3800
3801 freeCarrierRestrictions(cr);
3802
3803 return Void();
3804 }
3805
getAllowedCarriers_1_4(int32_t serial)3806 Return<void> RadioImpl_1_6::getAllowedCarriers_1_4(int32_t serial) {
3807 #if VDBG
3808 RLOGD("getAllowedCarriers_1_4: serial %d", serial);
3809 #endif
3810 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
3811 return Void();
3812 }
3813
setupDataCall_1_4(int32_t serial,::android::hardware::radio::V1_4::AccessNetwork,const::android::hardware::radio::V1_4::DataProfileInfo & dataProfileInfo,bool roamingAllowed,::android::hardware::radio::V1_2::DataRequestReason,const hidl_vec<hidl_string> &,const hidl_vec<hidl_string> &)3814 Return<void> RadioImpl_1_6::setupDataCall_1_4(int32_t serial ,
3815 ::android::hardware::radio::V1_4::AccessNetwork /* accessNetwork */,
3816 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo,
3817 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
3818 const hidl_vec<hidl_string>& /* addresses */, const hidl_vec<hidl_string>& /* dnses */) {
3819
3820 #if VDBG
3821 RLOGD("setupDataCall_1_4: serial %d", serial);
3822 #endif
3823
3824 char *mvnoTypeStr = NULL;
3825 if (!convertMvnoTypeToString(MvnoType::IMSI, mvnoTypeStr)) {
3826 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3827 RIL_REQUEST_SETUP_DATA_CALL);
3828 if (pRI != NULL) {
3829 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3830 }
3831 return Void();
3832 }
3833 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 16,
3834 std::to_string((int) RadioTechnology::UNKNOWN + 2).c_str(),
3835 std::to_string((int) dataProfileInfo.profileId).c_str(),
3836 dataProfileInfo.apn.c_str(),
3837 dataProfileInfo.user.c_str(),
3838 dataProfileInfo.password.c_str(),
3839 std::to_string((int) dataProfileInfo.authType).c_str(),
3840 getProtocolString(dataProfileInfo.protocol),
3841 getProtocolString(dataProfileInfo.roamingProtocol),
3842 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
3843 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
3844 dataProfileInfo.persistent ? "1" : "0",
3845 std::to_string(dataProfileInfo.mtu).c_str(),
3846 mvnoTypeStr,
3847 "302720x94",
3848 roamingAllowed ? "1" : "0",
3849 "-1");
3850 return Void();
3851 }
3852
setInitialAttachApn_1_4(int32_t serial,const::android::hardware::radio::V1_4::DataProfileInfo & dataProfileInfo)3853 Return<void> RadioImpl_1_6::setInitialAttachApn_1_4(int32_t serial ,
3854 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo) {
3855 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3856 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
3857 if (pRI == NULL) {
3858 return Void();
3859 }
3860
3861 RadioResponseInfo responseInfo = {};
3862 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
3863
3864 if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
3865 Return<void> retStatus
3866 = radioService[mSlotId]->mRadioResponseV1_4->setInitialAttachApnResponse(responseInfo);
3867 radioService[mSlotId]->checkReturnStatus(retStatus);
3868 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
3869 Return<void> retStatus
3870 = radioService[mSlotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
3871 radioService[mSlotId]->checkReturnStatus(retStatus);
3872 } else {
3873 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
3874 }
3875
3876 return Void();
3877 }
3878
setDataProfile_1_4(int32_t serial,const hidl_vec<::android::hardware::radio::V1_4::DataProfileInfo> &)3879 Return<void> RadioImpl_1_6::setDataProfile_1_4(int32_t serial ,
3880 const hidl_vec<::android::hardware::radio::V1_4::DataProfileInfo>& /* profiles */) {
3881 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3882 RIL_REQUEST_SET_DATA_PROFILE);
3883 if (pRI == NULL) {
3884 return Void();
3885 }
3886
3887 RadioResponseInfo responseInfo = {};
3888 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
3889
3890 if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
3891 Return<void> retStatus
3892 = radioService[mSlotId]->mRadioResponseV1_4->setDataProfileResponse(responseInfo);
3893 radioService[mSlotId]->checkReturnStatus(retStatus);
3894 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
3895 Return<void> retStatus
3896 = radioService[mSlotId]->mRadioResponse->setDataProfileResponse(responseInfo);
3897 radioService[mSlotId]->checkReturnStatus(retStatus);
3898 } else {
3899 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
3900 }
3901
3902 return Void();
3903 }
3904
emergencyDial(int32_t serial,const::android::hardware::radio::V1_0::Dial & dialInfo,hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,const hidl_vec<hidl_string> & urns,::android::hardware::radio::V1_4::EmergencyCallRouting routing,bool fromEmergencyDialer,bool)3905 Return<void> RadioImpl_1_6::emergencyDial(int32_t serial,
3906 const ::android::hardware::radio::V1_0::Dial& dialInfo,
3907 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
3908 const hidl_vec<hidl_string>& urns ,
3909 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
3910 bool fromEmergencyDialer, bool /* isTesting */) {
3911 #if VDBG
3912 RLOGD("emergencyDial: serial %d", serial);
3913 #endif
3914
3915 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_EMERGENCY_DIAL);
3916 if (pRI == NULL) {
3917 return Void();
3918 }
3919
3920 RIL_EmergencyDial eccDial = {};
3921 RIL_Dial& dial = eccDial.dialInfo;
3922 RIL_UUS_Info uusInfo = {};
3923
3924 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
3925 return Void();
3926 }
3927 dial.clir = (int) dialInfo.clir;
3928
3929 if (dialInfo.uusInfo.size() != 0) {
3930 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
3931 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
3932
3933 if (dialInfo.uusInfo[0].uusData.size() == 0) {
3934 uusInfo.uusData = NULL;
3935 uusInfo.uusLength = 0;
3936 } else {
3937 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
3938 memsetAndFreeStrings(1, dial.address);
3939 return Void();
3940 }
3941 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
3942 }
3943
3944 dial.uusInfo = &uusInfo;
3945 }
3946
3947 eccDial.urnsNumber = urns.size();
3948 if (eccDial.urnsNumber != 0) {
3949 char **ppUrns = (char **)calloc(eccDial.urnsNumber, sizeof(char *));
3950 if (ppUrns == NULL) {
3951 RLOGE("Memory allocation failed for request %s",
3952 requestToString(pRI->pCI->requestNumber));
3953 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3954 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
3955 return Void();
3956 }
3957 for (uint32_t i = 0; i < eccDial.urnsNumber; i++) {
3958 if (!copyHidlStringToRil(&ppUrns[i], hidl_string(urns[i]), pRI)) {
3959 for (uint32_t j = 0; j < i; j++) {
3960 memsetAndFreeStrings(1, ppUrns[j]);
3961 }
3962 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
3963 free(ppUrns);
3964 return Void();
3965 }
3966 }
3967 eccDial.urns = ppUrns;
3968 }
3969
3970 eccDial.categories = (RIL_EmergencyServiceCategory)categories;
3971 eccDial.routing = (RIL_EmergencyCallRouting)routing;
3972 eccDial.fromEmergencyDialer = fromEmergencyDialer;
3973
3974 CALL_ONREQUEST(RIL_REQUEST_EMERGENCY_DIAL, &eccDial, sizeof(RIL_EmergencyDial), pRI, mSlotId);
3975
3976 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
3977 if (eccDial.urns != NULL) {
3978 for (size_t i = 0; i < eccDial.urnsNumber; i++) {
3979 memsetAndFreeStrings(1, eccDial.urns[i]);
3980 }
3981 free(eccDial.urns);
3982 }
3983 return Void();
3984 }
3985
startNetworkScan_1_4(int32_t serial,const::android::hardware::radio::V1_2::NetworkScanRequest & request)3986 Return<void> RadioImpl_1_6::startNetworkScan_1_4(int32_t serial,
3987 const ::android::hardware::radio::V1_2::NetworkScanRequest& request) {
3988 #if VDBG
3989 RLOGD("startNetworkScan_1_4: serial %d", serial);
3990 #endif
3991
3992 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
3993 if (pRI == NULL) {
3994 return Void();
3995 }
3996
3997 RIL_NetworkScanRequest scan_request = {};
3998
3999 if (prepareNetworkScanRequest_1_2(scan_request, request, pRI) < 0) {
4000 return Void();
4001 }
4002
4003 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
4004 mSlotId);
4005
4006 return Void();
4007 }
4008
getPreferredNetworkTypeBitmap(int32_t serial)4009 Return<void> RadioImpl_1_6::getPreferredNetworkTypeBitmap(int32_t serial ) {
4010 #if VDBG
4011 RLOGD("getPreferredNetworkTypeBitmap: serial %d", serial);
4012 #endif
4013 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE_BITMAP);
4014 return Void();
4015 }
4016
setPreferredNetworkTypeBitmap(int32_t serial,hidl_bitfield<RadioAccessFamily> networkTypeBitmap)4017 Return<void> RadioImpl_1_6::setPreferredNetworkTypeBitmap(
4018 int32_t serial, hidl_bitfield<RadioAccessFamily> networkTypeBitmap) {
4019 #if VDBG
4020 RLOGD("setPreferredNetworkTypeBitmap: serial %d", serial);
4021 #endif
4022 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE_BITMAP, 1, networkTypeBitmap);
4023 return Void();
4024 }
4025
setAllowedNetworkTypesBitmap(uint32_t serial,hidl_bitfield<RadioAccessFamily> networkTypeBitmap)4026 Return<void> RadioImpl_1_6::setAllowedNetworkTypesBitmap(
4027 uint32_t serial, hidl_bitfield<RadioAccessFamily> networkTypeBitmap) {
4028 #if VDBG
4029 RLOGD("setAllowedNetworkTypesBitmap: serial %d", serial);
4030 #endif
4031 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_ALLOWED_NETWORK_TYPES_BITMAP, 1, networkTypeBitmap);
4032 return Void();
4033 }
4034
getAllowedNetworkTypesBitmap(int32_t serial)4035 Return<void> RadioImpl_1_6::getAllowedNetworkTypesBitmap(int32_t serial) {
4036 #if VDBG
4037 RLOGD("getAllowedNetworkTypesBitmap: serial %d", serial);
4038 #endif
4039 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ALLOWED_NETWORK_TYPES_BITMAP);
4040 return Void();
4041 }
4042
getSignalStrength_1_4(int32_t serial)4043 Return<void> RadioImpl_1_6::getSignalStrength_1_4(int32_t serial) {
4044 #if VDBG
4045 RLOGD("getSignalStrength_1_4: serial %d", serial);
4046 #endif
4047 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
4048 return Void();
4049 }
4050
getSignalStrength_1_6(int32_t serial)4051 Return<void> RadioImpl_1_6::getSignalStrength_1_6(int32_t serial) {
4052 #if VDBG
4053 RLOGD("getSignalStrength_1_6: serial %d", serial);
4054 #endif
4055 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
4056 return Void();
4057 }
4058
4059 // Methods from ::android::hardware::radio::V1_5::IRadio follow.
setSignalStrengthReportingCriteria_1_5(int32_t serial,const V1_5::SignalThresholdInfo & signalThresholdInfo,V1_5::AccessNetwork accessNetwork)4060 Return<void> RadioImpl_1_6::setSignalStrengthReportingCriteria_1_5(int32_t serial,
4061 const V1_5::SignalThresholdInfo& signalThresholdInfo,
4062 V1_5::AccessNetwork accessNetwork) {
4063 #if VDBG
4064 RLOGD("setSignalStrengthReportingCriteria_1_5: %d", serial);
4065 #endif
4066
4067 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4068 RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA);
4069 if (pRI == NULL) {
4070 return Void();
4071 }
4072
4073 if (signalThresholdInfo.hysteresisDb >= 10) { // TODO: for vts. hysteresisDb range not checked
4074 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4075 return Void();
4076 }
4077
4078 RIL_SignalStrengthReportingCriteria_v1_5 *criteria = (RIL_SignalStrengthReportingCriteria_v1_5 *)
4079 calloc(1, sizeof(RIL_SignalStrengthReportingCriteria_v1_5));
4080 if (criteria == NULL) {
4081 RLOGE("Memory allocation failed for request %s",
4082 requestToString(pRI->pCI->requestNumber));
4083 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4084 return Void();
4085 }
4086
4087 criteria->signalMeasurement = (SignalMeasurementType)signalThresholdInfo.signalMeasurement;
4088 criteria->isEnabled = signalThresholdInfo.isEnabled;
4089 criteria->hysteresisMs = signalThresholdInfo.hysteresisMs;
4090 criteria->hysteresisDb = signalThresholdInfo.hysteresisDb;
4091 criteria->thresholdsDbmNumber = signalThresholdInfo.thresholds.size();
4092 criteria->thresholdsDbm = new int32_t[criteria->thresholdsDbmNumber];
4093 memcpy(criteria->thresholdsDbm, signalThresholdInfo.thresholds.data(),
4094 criteria->thresholdsDbmNumber * sizeof(int32_t));
4095 criteria->accessNetwork = (RIL_RadioAccessNetworks_v1_5)accessNetwork;
4096
4097 CALL_ONREQUEST(pRI->pCI->requestNumber, criteria,
4098 sizeof(RIL_SignalStrengthReportingCriteria_v1_5), pRI, mSlotId);
4099
4100 return Void();
4101 }
4102
setLinkCapacityReportingCriteria_1_5(int32_t serial,int32_t hysteresisMs,int32_t hysteresisDlKbps,int32_t hysteresisUlKbps,const hidl_vec<int32_t> & thresholdsDownlinkKbps,const hidl_vec<int32_t> & thresholdsUplinkKbps,V1_5::AccessNetwork accessNetwork)4103 Return<void> RadioImpl_1_6::setLinkCapacityReportingCriteria_1_5(int32_t serial,
4104 int32_t hysteresisMs, int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
4105 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
4106 const hidl_vec<int32_t>& thresholdsUplinkKbps,
4107 V1_5::AccessNetwork accessNetwork) {
4108 #if VDBG
4109 RLOGD("setLinkCapacityReportingCriteria_1_5: %d", serial);
4110 #endif
4111
4112 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4113 RIL_REQUEST_SET_LINK_CAPACITY_REPORTING_CRITERIA);
4114 if (pRI == NULL) {
4115 return Void();
4116 }
4117 // TODO: for vts. hysteresisDlKbps and hysteresisUlKbps range not confirmed
4118 if (hysteresisDlKbps >= 5000 || hysteresisUlKbps >= 1000) {
4119 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4120 return Void();
4121 }
4122
4123 RIL_LinkCapacityReportingCriteria *criteria = (RIL_LinkCapacityReportingCriteria *)
4124 calloc(1, sizeof(RIL_LinkCapacityReportingCriteria));
4125 if (criteria == NULL) {
4126 RLOGE("Memory allocation failed for request %s",
4127 requestToString(pRI->pCI->requestNumber));
4128 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4129 return Void();
4130 }
4131
4132 criteria->hysteresisMs = hysteresisMs;
4133 criteria->hysteresisDlKbps = hysteresisDlKbps;
4134 criteria->hysteresisUlKbps = hysteresisUlKbps;
4135 criteria->thresholdsDownlinkKbpsLength = thresholdsDownlinkKbps.size();
4136 criteria->thresholdsUplinkKbpsLength = thresholdsUplinkKbps.size();
4137 criteria->thresholdsDownlinkKbps = new int32_t[criteria->thresholdsDownlinkKbpsLength];
4138 criteria->thresholdsUplinkKbps = new int32_t[criteria->thresholdsUplinkKbpsLength];
4139 memcpy(criteria->thresholdsDownlinkKbps, thresholdsDownlinkKbps.data(),
4140 criteria->thresholdsDownlinkKbpsLength * sizeof(int32_t));
4141 memcpy(criteria->thresholdsUplinkKbps, thresholdsUplinkKbps.data(),
4142 criteria->thresholdsUplinkKbpsLength * sizeof(int32_t));
4143 criteria->accessNetwork = (RIL_RadioAccessNetworks_v1_5)accessNetwork;
4144
4145 CALL_ONREQUEST(pRI->pCI->requestNumber, criteria,
4146 sizeof(RIL_LinkCapacityReportingCriteria), pRI, pRI->socket_id);
4147
4148 return Void();
4149 }
4150
enableUiccApplications(int32_t serial,bool enable)4151 Return<void> RadioImpl_1_6::enableUiccApplications(int32_t serial, bool enable) {
4152 #if VDBG
4153 RLOGD("enableUiccApplications: serial %d enable %d", serial, enable);
4154 #endif
4155 dispatchInts(serial, mSlotId, RIL_REQUEST_ENABLE_UICC_APPLICATIONS, 1, BOOL_TO_INT(enable));
4156 return Void();
4157 }
4158
setRadioPower_1_5(int32_t serial,bool powerOn,bool forEmergencyCall,bool preferredForEmergencyCall)4159 Return<void> RadioImpl_1_6::setRadioPower_1_5(int32_t serial, bool powerOn, bool forEmergencyCall,
4160 bool preferredForEmergencyCall) {
4161 #if VDBG
4162 RLOGD("setRadioPower_1_6: serial %d powerOn %d forEmergency %d preferredForEmergencyCall %d",
4163 serial, powerOn, forEmergencyCall, preferredForEmergencyCall);
4164 #endif
4165 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(powerOn));
4166 return Void();
4167 }
4168
setRadioPower_1_6(int32_t serial,bool powerOn,bool forEmergencyCall,bool preferredForEmergencyCall)4169 Return<void> RadioImpl_1_6::setRadioPower_1_6(int32_t serial, bool powerOn, bool forEmergencyCall,
4170 bool preferredForEmergencyCall) {
4171 #if VDBG
4172 RLOGD("setRadioPower_1_6: serial %d powerOn %d forEmergency %d preferredForEmergencyCall %d",
4173 serial, powerOn, forEmergencyCall, preferredForEmergencyCall);
4174 #endif
4175 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(powerOn));
4176 return Void();
4177 }
4178
areUiccApplicationsEnabled(int32_t serial)4179 Return<void> RadioImpl_1_6::areUiccApplicationsEnabled(int32_t serial) {
4180 #if VDBG
4181 RLOGD("areUiccApplicationsEnabled: serial %d", serial);
4182 #endif
4183 dispatchVoid(serial, mSlotId, RIL_REQUEST_ARE_UICC_APPLICATIONS_ENABLED);
4184 return Void();
4185 }
4186
getVoiceRegistrationState_1_5(int32_t serial)4187 Return<void> RadioImpl_1_6::getVoiceRegistrationState_1_5(int32_t serial) {
4188 #if VDBG
4189 RLOGD("getVoiceRegistrationState_1_5: serial %d", serial);
4190 #endif
4191 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
4192 return Void();
4193 }
4194
getDataRegistrationState_1_5(int32_t serial)4195 Return<void> RadioImpl_1_6::getDataRegistrationState_1_5(int32_t serial) {
4196 #if VDBG
4197 RLOGD("getDataRegistrationState_1_5: serial %d", serial);
4198 #endif
4199 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
4200 return Void();
4201 }
4202
getVoiceRegistrationState_1_6(int32_t serial)4203 Return<void> RadioImpl_1_6::getVoiceRegistrationState_1_6(int32_t serial) {
4204 #if VDBG
4205 RLOGD("getVoiceRegistrationState_1_6: serial %d", serial);
4206 #endif
4207 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
4208 return Void();
4209 }
4210
getDataRegistrationState_1_6(int32_t serial)4211 Return<void> RadioImpl_1_6::getDataRegistrationState_1_6(int32_t serial) {
4212 #if VDBG
4213 RLOGD("getDataRegistrationState_1_6: serial %d", serial);
4214 #endif
4215 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
4216 return Void();
4217 }
4218
setSystemSelectionChannels_1_5(int32_t serial,bool specifyChannels,const hidl_vec<V1_5::RadioAccessSpecifier> & specifiers)4219 Return<void> RadioImpl_1_6::setSystemSelectionChannels_1_5(int32_t serial,
4220 bool specifyChannels, const hidl_vec<V1_5::RadioAccessSpecifier>& specifiers) {
4221
4222 #if VDBG
4223 RLOGD("setSystemSelectionChannels_1_5: %d", serial);
4224 #endif
4225
4226 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4227 RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS);
4228 if (pRI == NULL) {
4229 return Void();
4230 }
4231
4232 if (specifiers.size() > RIL_RADIO_ACCESS_SPECIFIER_MAX_SIZE) {
4233 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4234 return Void();
4235 }
4236
4237 RIL_SystemSelectionChannels_v1_5 *sysSelectionChannels =
4238 (RIL_SystemSelectionChannels_v1_5 *)calloc(1, sizeof(RIL_SystemSelectionChannels_v1_5));
4239 if (sysSelectionChannels == NULL) {
4240 RLOGE("Memory allocation failed for request %s",
4241 requestToString(pRI->pCI->requestNumber));
4242 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4243 return Void();
4244 }
4245 sysSelectionChannels->specifyChannels = specifyChannels;
4246 sysSelectionChannels->specifiers_length = specifiers.size();
4247 for (size_t i = 0; i < specifiers.size(); ++i) {
4248 const V1_5::RadioAccessSpecifier& ras_from = specifiers[i];
4249 RIL_RadioAccessSpecifier_v1_5 &ras_to = sysSelectionChannels->specifiers[i];
4250
4251 ras_to.radio_access_network = (RIL_RadioAccessNetworks_v1_5)ras_from.radioAccessNetwork;
4252 ras_to.channels_length = ras_from.channels.size();
4253
4254 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
4255 const std::vector<uint32_t> * bands = nullptr;
4256 switch (specifiers[i].radioAccessNetwork) {
4257 case V1_5::RadioAccessNetworks::GERAN:
4258 ras_to.bands_length = ras_from.bands.geranBands().size();
4259 bands = (std::vector<uint32_t> *) &ras_from.bands.geranBands();
4260 break;
4261 case V1_5::RadioAccessNetworks::UTRAN:
4262 ras_to.bands_length = ras_from.bands.utranBands().size();
4263 bands = (std::vector<uint32_t> *) &ras_from.bands.utranBands();
4264 break;
4265 case V1_5::RadioAccessNetworks::EUTRAN:
4266 ras_to.bands_length = ras_from.bands.eutranBands().size();
4267 bands = (std::vector<uint32_t> *) &ras_from.bands.eutranBands();
4268 break;
4269 case V1_5::RadioAccessNetworks::NGRAN:
4270 ras_to.bands_length = ras_from.bands.ngranBands().size();
4271 bands = (std::vector<uint32_t> *) &ras_from.bands.ngranBands();
4272 break;
4273 default: {
4274 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4275 free(sysSelectionChannels);
4276 return Void();
4277 }
4278 }
4279 // safe to copy to geran_bands because it's a union member
4280 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4281 ras_to.bands.geran_bands[idx] = (RIL_GeranBands)(*bands)[idx];
4282 }
4283 }
4284
4285 CALL_ONREQUEST(RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS, sysSelectionChannels,
4286 sizeof(RIL_SystemSelectionChannels_v1_5), pRI, mSlotId);
4287
4288 return Void();
4289 }
4290
prepareNetworkScanRequest_1_5(RIL_NetworkScanRequest_v1_5 & scan_request,const V1_5::NetworkScanRequest & request,RequestInfo * pRI)4291 int prepareNetworkScanRequest_1_5(RIL_NetworkScanRequest_v1_5 &scan_request,
4292 const V1_5::NetworkScanRequest& request, RequestInfo *pRI) {
4293 scan_request.type = (RIL_ScanType) request.type;
4294 scan_request.interval = request.interval;
4295 scan_request.specifiers_length = request.specifiers.size();
4296 scan_request.maxSearchTime = request.maxSearchTime;
4297 scan_request.incrementalResults = request.incrementalResults;
4298 scan_request.incrementalResultsPeriodicity = request.incrementalResultsPeriodicity;
4299 scan_request.mccMncsNumbers = request.mccMncs.size();
4300
4301 int intervalLow = static_cast<int>(V1_2::ScanIntervalRange::MIN);
4302 int intervalHigh = static_cast<int>(V1_2::ScanIntervalRange::MAX);
4303 int maxSearchTimeLow = static_cast<int>(V1_2::MaxSearchTimeRange::MIN);
4304 int maxSearchTimeHigh = static_cast<int>(V1_2::MaxSearchTimeRange::MAX);
4305 int incrementalResultsPeriodicityRangeLow =
4306 static_cast<int>(V1_2::IncrementalResultsPeriodicityRange::MIN);
4307 int incrementalResultsPeriodicityRangeHigh =
4308 static_cast<int>(V1_2::IncrementalResultsPeriodicityRange::MAX);
4309 uint maxSpecifierSize = static_cast<uint>(V1_2::RadioConst::RADIO_ACCESS_SPECIFIER_MAX_SIZE);
4310
4311 if (request.interval < intervalLow || request.interval > intervalHigh) {
4312 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4313 return -1;
4314 }
4315 // If defined, must fall in correct range.
4316 if (request.maxSearchTime != 0 && (request.maxSearchTime < maxSearchTimeLow
4317 || request.maxSearchTime > maxSearchTimeHigh)) {
4318 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4319 return -1;
4320 }
4321 if (request.maxSearchTime != 0
4322 && (request.incrementalResultsPeriodicity < incrementalResultsPeriodicityRangeLow
4323 || request.incrementalResultsPeriodicity > incrementalResultsPeriodicityRangeHigh
4324 || request.incrementalResultsPeriodicity > request.maxSearchTime)) {
4325 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4326 return -1;
4327 }
4328 if (request.specifiers.size() == 0 || request.specifiers.size() > maxSpecifierSize) {
4329 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4330 return -1;
4331 }
4332
4333 for (size_t i = 0; i < request.specifiers.size(); ++i) {
4334 if (request.specifiers[i].channels.size() > MAX_CHANNELS) {
4335 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4336 return -1;
4337 }
4338 switch (request.specifiers[i].bands.getDiscriminator()) {
4339 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::geranBands:
4340 if (request.specifiers[i].bands.geranBands().size() > MAX_BANDS) {
4341 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4342 return -1;
4343 }
4344 break;
4345 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::utranBands:
4346 if (request.specifiers[i].bands.utranBands().size() > MAX_BANDS) {
4347 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4348 return -1;
4349 }
4350 break;
4351 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::eutranBands:
4352 if (request.specifiers[i].bands.eutranBands().size() > MAX_BANDS) {
4353 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4354 return -1;
4355 }
4356 break;
4357 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::ngranBands:
4358 if (request.specifiers[i].bands.ngranBands().size() > MAX_BANDS) {
4359 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4360 return -1;
4361 }
4362 break;
4363 default:
4364 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4365 return -1;
4366 }
4367
4368 if (request.specifiers[i].channels.size() > MAX_CHANNELS) {
4369 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4370 return -1;
4371 }
4372
4373 const V1_5::RadioAccessSpecifier& ras_from = request.specifiers[i];
4374 RIL_RadioAccessSpecifier_v1_5& ras_to = scan_request.specifiers[i];
4375
4376 ras_to.radio_access_network = (RIL_RadioAccessNetworks_v1_5) ras_from.radioAccessNetwork;
4377 ras_to.channels_length = ras_from.channels.size();
4378
4379 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
4380 switch (request.specifiers[i].radioAccessNetwork) {
4381 case V1_5::RadioAccessNetworks::GERAN: {
4382 hidl_vec<V1_1::GeranBands> geranBands = ras_from.bands.geranBands();
4383 ras_to.bands_length = MIN(geranBands.size(), MAX_BANDS);
4384 // safe to copy to geran_bands because it's a union member
4385 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4386 ras_to.bands.geran_bands[idx] =
4387 static_cast<RIL_GeranBands>(geranBands[idx]);
4388 }
4389 // TODO(b/400453288): check that channels correspond to bands
4390 break;
4391 }
4392 case V1_5::RadioAccessNetworks::UTRAN: {
4393 hidl_vec<V1_5::UtranBands> utranBands = ras_from.bands.utranBands();
4394 ras_to.bands_length = MIN(utranBands.size(), MAX_BANDS);
4395 // safe to copy to utran_bands because it's a union member
4396 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4397 ras_to.bands.utran_bands[idx] =
4398 static_cast<RIL_UtranBands>(utranBands[idx]);
4399 }
4400 // TODO(b/400453288): check that channels correspond to bands
4401 break;
4402 }
4403 case V1_5::RadioAccessNetworks::EUTRAN: {
4404 hidl_vec<V1_5::EutranBands> eutranBands = ras_from.bands.eutranBands();
4405 ras_to.bands_length = MIN(eutranBands.size(), MAX_BANDS);
4406 // safe to copy to eutran_bands because it's a union member
4407 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4408 ras_to.bands.eutran_bands[idx] =
4409 static_cast<RIL_EutranBands>(eutranBands[idx]);
4410 }
4411 if (!areEutranChannelsInsideBands(ras_to.bands.eutran_bands, ras_to.bands_length,
4412 ras_to.channels, ras_to.channels_length)) {
4413 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4414 return -1;
4415 }
4416
4417 break;
4418 }
4419 case V1_5::RadioAccessNetworks::NGRAN: {
4420 hidl_vec<V1_5::NgranBands> ngranBands = ras_from.bands.ngranBands();
4421 ras_to.bands_length = MIN(ngranBands.size(), MAX_BANDS);
4422 // safe to copy to ngran_bands because it's a union member
4423 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4424 ras_to.bands.ngran_bands[idx] =
4425 static_cast<RIL_NgranBands>(ngranBands[idx]);
4426 }
4427 // TODO(b/400453288): check that channels correspond to bands
4428 break;
4429 }
4430 default:
4431 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4432 return -1;
4433 }
4434 }
4435 if (scan_request.mccMncsNumbers != 0) {
4436 char **pStrings = (char **)calloc(scan_request.mccMncsNumbers, sizeof(char *));
4437 if (pStrings == NULL) {
4438 RLOGE("Memory allocation failed for request %s",
4439 requestToString(pRI->pCI->requestNumber));
4440 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4441 return -1;
4442 }
4443 for (size_t i = 0; i < request.mccMncs.size(); ++i) {
4444 if (!copyHidlStringToRil(&pStrings[i], hidl_string(request.mccMncs[i]), pRI)) {
4445 for (size_t j = 0; j < i; j++) {
4446 memsetAndFreeStrings(1, pStrings[j]);
4447 }
4448 free(pStrings);
4449 return -1;
4450 }
4451 }
4452 scan_request.mccMncs = pStrings;
4453 }
4454 return 0;
4455 }
4456
startNetworkScan_1_5(int32_t serial,const::android::hardware::radio::V1_5::NetworkScanRequest & request)4457 Return<void> RadioImpl_1_6::startNetworkScan_1_5(int32_t serial,
4458 const ::android::hardware::radio::V1_5::NetworkScanRequest& request) {
4459 #if VDBG
4460 RLOGD("startNetworkScan_1_5: serial %d", serial);
4461 #endif
4462
4463 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
4464 if (pRI == NULL) {
4465 return Void();
4466 }
4467
4468 RIL_NetworkScanRequest_v1_5 scan_request = {};
4469
4470 if (prepareNetworkScanRequest_1_5(scan_request, request, pRI) < 0) {
4471 return Void();
4472 }
4473
4474 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
4475 mSlotId);
4476
4477 return Void();
4478 }
4479
setupDataCall_1_5(int32_t serial,::android::hardware::radio::V1_5::AccessNetwork,const::android::hardware::radio::V1_5::DataProfileInfo & dataProfileInfo,bool roamingAllowed,::android::hardware::radio::V1_2::DataRequestReason,const hidl_vec<::android::hardware::radio::V1_5::LinkAddress> &,const hidl_vec<hidl_string> &)4480 Return<void> RadioImpl_1_6::setupDataCall_1_5(int32_t serial ,
4481 ::android::hardware::radio::V1_5::AccessNetwork /* accessNetwork */,
4482 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
4483 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
4484 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& /* addresses */,
4485 const hidl_vec<hidl_string>& /* dnses */) {
4486
4487 #if VDBG
4488 RLOGD("setupDataCall_1_5: serial %d", serial);
4489 #endif
4490
4491 char *mvnoTypeStr = NULL;
4492 if (!convertMvnoTypeToString(MvnoType::IMSI, mvnoTypeStr)) {
4493 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4494 RIL_REQUEST_SETUP_DATA_CALL);
4495 if (pRI != NULL) {
4496 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4497 }
4498 return Void();
4499 }
4500 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
4501 std::to_string((int) RadioTechnology::UNKNOWN + 2).c_str(),
4502 std::to_string((int) dataProfileInfo.profileId).c_str(),
4503 dataProfileInfo.apn.c_str(),
4504 dataProfileInfo.user.c_str(),
4505 dataProfileInfo.password.c_str(),
4506 std::to_string((int) dataProfileInfo.authType).c_str(),
4507 getProtocolString(dataProfileInfo.protocol),
4508 getProtocolString(dataProfileInfo.roamingProtocol),
4509 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
4510 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
4511 dataProfileInfo.persistent ? "1" : "0",
4512 std::to_string(dataProfileInfo.mtuV4).c_str(),
4513 std::to_string(dataProfileInfo.mtuV6).c_str(),
4514 mvnoTypeStr,
4515 "302720x94",
4516 roamingAllowed ? "1" : "0");
4517 return Void();
4518 }
4519
setupDataCall_1_6(int32_t serial,::android::hardware::radio::V1_5::AccessNetwork,const::android::hardware::radio::V1_5::DataProfileInfo & dataProfileInfo,bool roamingAllowed,::android::hardware::radio::V1_2::DataRequestReason,const hidl_vec<::android::hardware::radio::V1_5::LinkAddress> &,const hidl_vec<hidl_string> &,int32_t,const::android::hardware::radio::V1_6::OptionalSliceInfo &,const::android::hardware::radio::V1_6::OptionalTrafficDescriptor & trafficDescriptor,bool matchAllRuleAllowed)4520 Return<void> RadioImpl_1_6::setupDataCall_1_6(
4521 int32_t serial, ::android::hardware::radio::V1_5::AccessNetwork /* accessNetwork */,
4522 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
4523 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
4524 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& /* addresses */,
4525 const hidl_vec<hidl_string>& /* dnses */, int32_t /* pduSessionId */,
4526 const ::android::hardware::radio::V1_6::OptionalSliceInfo& /* sliceInfo */,
4527 const ::android::hardware::radio::V1_6::OptionalTrafficDescriptor& trafficDescriptor,
4528 bool matchAllRuleAllowed) {
4529 #if VDBG
4530 RLOGD("setupDataCall_1_6: serial %d", serial);
4531 #endif
4532
4533 char *mvnoTypeStr = NULL;
4534 if (!convertMvnoTypeToString(MvnoType::IMSI, mvnoTypeStr)) {
4535 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4536 RIL_REQUEST_SETUP_DATA_CALL);
4537 if (pRI != NULL) {
4538 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4539 }
4540 return Void();
4541 }
4542
4543 if (trafficDescriptor.getDiscriminator() ==
4544 V1_6::OptionalTrafficDescriptor::hidl_discriminator::value &&
4545 trafficDescriptor.value().osAppId.getDiscriminator() ==
4546 V1_6::OptionalOsAppId::hidl_discriminator::value) {
4547 osAppIdVec = trafficDescriptor.value().osAppId.value().osAppId;
4548 } else {
4549 osAppIdVec = {};
4550 }
4551
4552 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 16,
4553 std::to_string((int) RadioTechnology::UNKNOWN + 2).c_str(),
4554 std::to_string((int) dataProfileInfo.profileId).c_str(),
4555 dataProfileInfo.apn.c_str(),
4556 dataProfileInfo.user.c_str(),
4557 dataProfileInfo.password.c_str(),
4558 std::to_string((int) dataProfileInfo.authType).c_str(),
4559 getProtocolString(dataProfileInfo.protocol),
4560 getProtocolString(dataProfileInfo.roamingProtocol),
4561 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
4562 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
4563 dataProfileInfo.persistent ? "1" : "0",
4564 std::to_string(dataProfileInfo.mtuV4).c_str(),
4565 std::to_string(dataProfileInfo.mtuV6).c_str(),
4566 mvnoTypeStr,
4567 "302720x94",
4568 roamingAllowed ? "1" : "0");
4569 return Void();
4570 }
4571
setInitialAttachApn_1_5(int32_t serial,const::android::hardware::radio::V1_5::DataProfileInfo & dataProfileInfo)4572 Return<void> RadioImpl_1_6::setInitialAttachApn_1_5(int32_t serial ,
4573 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo) {
4574 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4575 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
4576 if (pRI == NULL) {
4577 return Void();
4578 }
4579
4580 RadioResponseInfo responseInfo = {};
4581 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
4582
4583 if (radioService[mSlotId]->mRadioResponseV1_5 != NULL) {
4584 Return<void> retStatus =
4585 radioService[mSlotId]->mRadioResponseV1_5->setInitialAttachApnResponse_1_5(
4586 responseInfo);
4587 } else if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
4588 Return<void> retStatus
4589 = radioService[mSlotId]->mRadioResponseV1_4->setInitialAttachApnResponse(responseInfo);
4590 radioService[mSlotId]->checkReturnStatus(retStatus);
4591 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
4592 Return<void> retStatus
4593 = radioService[mSlotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
4594 radioService[mSlotId]->checkReturnStatus(retStatus);
4595 } else {
4596 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
4597 }
4598
4599 return Void();
4600 }
4601
setDataProfile_1_5(int32_t serial,const hidl_vec<::android::hardware::radio::V1_5::DataProfileInfo> &)4602 Return<void> RadioImpl_1_6::setDataProfile_1_5(int32_t serial ,
4603 const hidl_vec<::android::hardware::radio::V1_5::DataProfileInfo>& /* profiles */) {
4604 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4605 RIL_REQUEST_SET_DATA_PROFILE);
4606 if (pRI == NULL) {
4607 return Void();
4608 }
4609
4610 RadioResponseInfo responseInfo = {};
4611 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
4612
4613 if (radioService[mSlotId]->mRadioResponseV1_5 != NULL) {
4614 Return<void> retStatus =
4615 radioService[mSlotId]->mRadioResponseV1_5->setDataProfileResponse_1_5(responseInfo);
4616 } else if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
4617 Return<void> retStatus
4618 = radioService[mSlotId]->mRadioResponseV1_4->setDataProfileResponse(responseInfo);
4619 radioService[mSlotId]->checkReturnStatus(retStatus);
4620 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
4621 Return<void> retStatus
4622 = radioService[mSlotId]->mRadioResponse->setDataProfileResponse(responseInfo);
4623 radioService[mSlotId]->checkReturnStatus(retStatus);
4624 } else {
4625 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
4626 }
4627
4628 return Void();
4629 }
4630
setIndicationFilter_1_5(int32_t serial,hidl_bitfield<::android::hardware::radio::V1_5::IndicationFilter> indicationFilter)4631 Return<void> RadioImpl_1_6::setIndicationFilter_1_5(
4632 int32_t serial,
4633 hidl_bitfield<::android::hardware::radio::V1_5::IndicationFilter> indicationFilter) {
4634 #if VDBG
4635 RLOGE("setIndicationFilter_1_5: serial %d", serial);
4636 #endif
4637 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
4638 return Void();
4639 }
4640
getBarringInfo(int32_t serial)4641 Return<void> RadioImpl_1_6::getBarringInfo(int32_t serial) {
4642 #if VDBG
4643 RLOGD("getBarringInfo: serial %d", serial);
4644 #endif
4645 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_BARRING_INFO);
4646 return Void();
4647 }
4648
setNetworkSelectionModeManual_1_5(int32_t serial,const hidl_string & operatorNumeric,V1_5::RadioAccessNetworks ran)4649 Return<void> RadioImpl_1_6::setNetworkSelectionModeManual_1_5(int32_t serial,
4650 const hidl_string& operatorNumeric, V1_5::RadioAccessNetworks ran) {
4651 #if VDBG
4652 RLOGD("setNetworkSelectionModeManual_1_6: serial %d", serial);
4653 #endif
4654 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4655 RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL);
4656 if (pRI == NULL) {
4657 return Void();
4658 }
4659
4660 RIL_NetworkOperator networkOperator = {};
4661
4662 networkOperator.act = (RIL_RadioAccessNetworks)ran;
4663 if (!copyHidlStringToRil(&networkOperator.operatorNumeric, operatorNumeric, pRI)) {
4664 return Void();
4665 }
4666 CALL_ONREQUEST(pRI->pCI->requestNumber, &networkOperator,
4667 sizeof(networkOperator), pRI, mSlotId);
4668
4669 return Void();
4670 }
4671
sendCdmaSmsExpectMore(int32_t serial,const CdmaSmsMessage & sms)4672 Return<void> RadioImpl_1_6::sendCdmaSmsExpectMore(int32_t serial, const CdmaSmsMessage& sms) {
4673 #if VDBG
4674 RLOGD("sendCdmaSmsExpectMore: serial %d", serial);
4675 #endif
4676 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4677 RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE);
4678 if (pRI == NULL) {
4679 return Void();
4680 }
4681
4682 RIL_CDMA_SMS_Message rcsm = {};
4683 constructCdmaSms(rcsm, sms);
4684
4685 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
4686 return Void();
4687 }
4688
4689 // Methods from ::android::hardware::radio::V1_6::IRadio follow.
sendCdmaSmsExpectMore_1_6(int32_t serial,const CdmaSmsMessage & sms)4690 Return<void> RadioImpl_1_6::sendCdmaSmsExpectMore_1_6(int32_t serial, const CdmaSmsMessage& sms) {
4691 #if VDBG
4692 RLOGD("sendCdmaSmsExpectMore: serial %d", serial);
4693 #endif
4694 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4695 RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE);
4696 if (pRI == NULL) {
4697 return Void();
4698 }
4699
4700 RIL_CDMA_SMS_Message rcsm = {};
4701 constructCdmaSms(rcsm, sms);
4702
4703 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
4704 return Void();
4705 }
4706
supplySimDepersonalization(int32_t serial,V1_5::PersoSubstate persoType,const hidl_string & controlKey)4707 Return<void> RadioImpl_1_6::supplySimDepersonalization(int32_t serial,
4708 V1_5::PersoSubstate persoType, const hidl_string& controlKey) {
4709 #if VDBG
4710 RLOGD("supplySimDepersonalization: serial %d", serial);
4711 #endif
4712 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_DEPERSONALIZATION, true, 1,
4713 controlKey.c_str());
4714 return Void();
4715 }
4716
setNrDualConnectivityState(int32_t serial,V1_6::NrDualConnectivityState nrDualConnectivityState)4717 Return<void> RadioImpl_1_6::setNrDualConnectivityState(int32_t serial,
4718 V1_6::NrDualConnectivityState nrDualConnectivityState) {
4719 #if VDBG
4720 RLOGD("setNrDualConnectivityState: serial %d", serial);
4721 #endif
4722 dispatchInts(serial, mSlotId, RIL_REQUEST_ENABLE_NR_DUAL_CONNECTIVITY, 1,
4723 nrDualConnectivityState);
4724 return Void();
4725 }
4726
isNrDualConnectivityEnabled(int32_t serial)4727 Return<void> RadioImpl_1_6::isNrDualConnectivityEnabled(int32_t serial) {
4728 #if VDBG
4729 RLOGD("isNrDualConnectivityEnabled: serial %d", serial);
4730 #endif
4731 dispatchVoid(serial, mSlotId, RIL_REQUEST_IS_NR_DUAL_CONNECTIVITY_ENABLED);
4732 return Void();
4733 }
4734
allocatePduSessionId(int32_t serial)4735 Return<void> RadioImpl_1_6::allocatePduSessionId(int32_t serial) {
4736 #if VDBG
4737 RLOGD("allocatePduSessionId: serial %d", serial);
4738 #endif
4739 dispatchVoid(serial, mSlotId, RIL_REQUEST_ALLOCATE_PDU_SESSION_ID);
4740 return Void();
4741 }
4742
releasePduSessionId(int32_t serial,int32_t id)4743 Return<void> RadioImpl_1_6::releasePduSessionId(int32_t serial, int32_t id) {
4744 #if VDBG
4745 RLOGD("releasePduSessionId: serial %d, pduSessionId: %d", serial, id);
4746 #endif
4747 dispatchVoid(serial, mSlotId, RIL_REQUEST_RELEASE_PDU_SESSION_ID);
4748 return Void();
4749 }
4750
startHandover(int32_t serial,int32_t callId)4751 Return<void> RadioImpl_1_6::startHandover(int32_t serial, int32_t callId) {
4752 #if VDBG
4753 RLOGD("startHandover: serial %d, callId: %d", serial, callId);
4754 #endif
4755 dispatchVoid(serial, mSlotId, RIL_REQUEST_START_HANDOVER);
4756 return Void();
4757 }
4758
cancelHandover(int32_t serial,int32_t callId)4759 Return<void> RadioImpl_1_6::cancelHandover(int32_t serial, int32_t callId) {
4760 #if VDBG
4761 RLOGD("cancelHandover: serial %d, callId: %d", serial, callId);
4762 #endif
4763 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_HANDOVER);
4764 return Void();
4765 }
4766
4767
setDataThrottling(int32_t serial,V1_6::DataThrottlingAction dataThrottlingAction,int64_t completionDurationMillis)4768 Return<void> RadioImpl_1_6::setDataThrottling(int32_t serial, V1_6::DataThrottlingAction dataThrottlingAction, int64_t completionDurationMillis) {
4769 #if VDBG
4770 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
4771 #endif
4772 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_DATA_THROTTLING, 2,
4773 dataThrottlingAction, completionDurationMillis);
4774 return Void();
4775 }
4776
getSystemSelectionChannels(int32_t serial)4777 Return<void> RadioImpl_1_6::getSystemSelectionChannels(int32_t serial) {
4778 #if VDBG
4779 RLOGD("getSystemSelectionChannels: serial %d", serial);
4780 #endif
4781 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SYSTEM_SELECTION_CHANNELS);
4782 return Void();
4783 }
4784
getSlicingConfig(int32_t serial)4785 Return<void> RadioImpl_1_6::getSlicingConfig(int32_t serial) {
4786 #if VDBG
4787 RLOGD("getSlicingConfig: serial %d", serial);
4788 #endif
4789 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SLICING_CONFIG);
4790 return Void();
4791 }
4792
setCarrierInfoForImsiEncryption_1_6(int32_t serial,const V1_6::ImsiEncryptionInfo & data)4793 Return<void> RadioImpl_1_6::setCarrierInfoForImsiEncryption_1_6(
4794 int32_t serial, const V1_6::ImsiEncryptionInfo& data) {
4795 #if VDBG
4796 RLOGD("setCarrierInfoForImsiEncryption_1_6: serial %d", serial);
4797 #endif
4798 RequestInfo* pRI = android::addRequestToList(serial, mSlotId,
4799 RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
4800 if (pRI == NULL) {
4801 return Void();
4802 }
4803
4804 RIL_CarrierInfoForImsiEncryption_v16 imsiEncryption = {};
4805
4806 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.base.mnc, pRI)) {
4807 return Void();
4808 }
4809 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.base.mcc, pRI)) {
4810 memsetAndFreeStrings(1, imsiEncryption.mnc);
4811 return Void();
4812 }
4813 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.base.keyIdentifier, pRI)) {
4814 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
4815 return Void();
4816 }
4817 imsiEncryption.carrierKeyLength = data.base.carrierKey.size();
4818 imsiEncryption.carrierKey = new uint8_t[imsiEncryption.carrierKeyLength];
4819 memcpy(imsiEncryption.carrierKey, data.base.carrierKey.data(), imsiEncryption.carrierKeyLength);
4820 imsiEncryption.expirationTime = data.base.expirationTime;
4821 imsiEncryption.keyType = (RIL_PublicKeyType)data.keyType;
4822
4823 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
4824 sizeof(RIL_CarrierInfoForImsiEncryption_v16), pRI, mSlotId);
4825 delete (imsiEncryption.carrierKey);
4826 return Void();
4827 }
4828
4829
getSimPhonebookRecords(int32_t serial)4830 Return<void> RadioImpl_1_6::getSimPhonebookRecords(int32_t serial) {
4831 #if VDBG
4832 RLOGD("getSimPhonebookRecords: serial %d", serial);
4833 #endif
4834 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_PHONEBOOK_RECORDS);
4835 return Void();
4836 }
4837
getSimPhonebookCapacity(int32_t serial)4838 Return<void> RadioImpl_1_6::getSimPhonebookCapacity(int32_t serial) {
4839 #if VDBG
4840 RLOGD("getSimPhonebookCapacity: serial %d", serial);
4841 #endif
4842 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_PHONEBOOK_CAPACITY);
4843 return Void();
4844 }
4845
updateSimPhonebookRecords(int32_t serial,const::android::hardware::radio::V1_6::PhonebookRecordInfo & recordInfo)4846 Return<void> RadioImpl_1_6::updateSimPhonebookRecords(
4847 int32_t serial,
4848 const ::android::hardware::radio::V1_6::PhonebookRecordInfo& recordInfo) {
4849 #if VDBG
4850 RLOGD("updateSimPhonebookRecords: serial %d", serial);
4851 #endif
4852 dispatchVoid(serial, mSlotId, RIL_REQUEST_UPDATE_SIM_PHONEBOOK_RECORDS);
4853 return Void();
4854 }
4855
4856
4857 // OEM hook methods:
setResponseFunctions(const::android::sp<IOemHookResponse> & oemHookResponseParam,const::android::sp<IOemHookIndication> & oemHookIndicationParam)4858 Return<void> OemHookImpl::setResponseFunctions(
4859 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
4860 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
4861 #if VDBG
4862 RLOGD("OemHookImpl::setResponseFunctions");
4863 #endif
4864
4865 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_6::getRadioServiceRwlock(mSlotId);
4866 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
4867 CHECK_EQ(ret, 0);
4868
4869 mOemHookResponse = oemHookResponseParam;
4870 mOemHookIndication = oemHookIndicationParam;
4871 mCounterOemHook[mSlotId]++;
4872
4873 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
4874 CHECK_EQ(ret, 0);
4875
4876 return Void();
4877 }
4878
sendRequestRaw(int32_t serial,const hidl_vec<uint8_t> & data)4879 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
4880 #if VDBG
4881 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
4882 #endif
4883 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
4884 return Void();
4885 }
4886
sendRequestStrings(int32_t serial,const hidl_vec<hidl_string> & data)4887 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
4888 const hidl_vec<hidl_string>& data) {
4889 #if VDBG
4890 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
4891 #endif
4892 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
4893 return Void();
4894 }
4895
4896 /***************************************************************************************************
4897 * RESPONSE FUNCTIONS
4898 * Functions above are used for requests going from framework to vendor code. The ones below are
4899 * responses for those requests coming back from the vendor code.
4900 **************************************************************************************************/
4901
acknowledgeRequest(int slotId,int serial)4902 void radio_1_6::acknowledgeRequest(int slotId, int serial) {
4903 if (radioService[slotId]->mRadioResponse != NULL) {
4904 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
4905 radioService[slotId]->checkReturnStatus(retStatus);
4906 } else {
4907 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
4908 }
4909 }
4910
populateResponseInfo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e)4911 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
4912 RIL_Errno e) {
4913 responseInfo.serial = serial;
4914 switch (responseType) {
4915 case RESPONSE_SOLICITED:
4916 responseInfo.type = RadioResponseType::SOLICITED;
4917 break;
4918 case RESPONSE_SOLICITED_ACK_EXP:
4919 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
4920 break;
4921 }
4922 responseInfo.error = (RadioError) e;
4923 }
4924
populateResponseInfo_1_6(::android::hardware::radio::V1_6::RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e)4925 void populateResponseInfo_1_6(
4926 ::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo,
4927 int serial, int responseType, RIL_Errno e) {
4928 responseInfo.serial = serial;
4929 switch (responseType) {
4930 case RESPONSE_SOLICITED:
4931 responseInfo.type = RadioResponseType::SOLICITED;
4932 break;
4933 case RESPONSE_SOLICITED_ACK_EXP:
4934 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
4935 break;
4936 }
4937 responseInfo.error = (::android::hardware::radio::V1_6::RadioError)e;
4938 }
4939
responseIntOrEmpty(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)4940 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
4941 void *response, size_t responseLen) {
4942 populateResponseInfo(responseInfo, serial, responseType, e);
4943 int ret = -1;
4944
4945 if (response == NULL && responseLen == 0) {
4946 // Earlier RILs did not send a response for some cases although the interface
4947 // expected an integer as response. Do not return error if response is empty. Instead
4948 // Return -1 in those cases to maintain backward compatibility.
4949 } else if (response == NULL || responseLen != sizeof(int)) {
4950 RLOGE("responseIntOrEmpty: Invalid response");
4951 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4952 } else {
4953 int *p_int = (int *) response;
4954 ret = p_int[0];
4955 }
4956 return ret;
4957 }
4958
responseInt(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)4959 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
4960 void *response, size_t responseLen) {
4961 populateResponseInfo(responseInfo, serial, responseType, e);
4962 int ret = -1;
4963
4964 if (response == NULL || responseLen != sizeof(int)) {
4965 RLOGE("responseInt: Invalid response");
4966 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4967 } else {
4968 int *p_int = (int *) response;
4969 ret = p_int[0];
4970 }
4971 return ret;
4972 }
4973
responseInt_1_6(::android::hardware::radio::V1_6::RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)4974 int responseInt_1_6(::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo, int serial, int responseType, RIL_Errno e,
4975 void *response, size_t responseLen) {
4976 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
4977 int ret = -1;
4978
4979 if (response == NULL || responseLen != sizeof(int)) {
4980 RLOGE("responseInt_1_6: Invalid response");
4981 if (e == RIL_E_SUCCESS) responseInfo.error = ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
4982 } else {
4983 int *p_int = (int *) response;
4984 ret = p_int[0];
4985 }
4986 return ret;
4987 }
4988
getIccCardStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4989 int radio_1_6::getIccCardStatusResponse(int slotId,
4990 int responseType, int serial, RIL_Errno e,
4991 void *response, size_t responseLen) {
4992 #if VDBG
4993 RLOGD("getIccCardStatusResponse: serial %d", serial);
4994 #endif
4995 if (radioService[slotId]->mRadioResponseV1_5 != NULL
4996 || radioService[slotId]->mRadioResponseV1_4 != NULL
4997 || radioService[slotId]->mRadioResponseV1_2 != NULL
4998 || radioService[slotId]->mRadioResponse != NULL) {
4999 RadioResponseInfo responseInfo = {};
5000 populateResponseInfo(responseInfo, serial, responseType, e);
5001 CardStatus cardStatus = {CardState::ABSENT, PinState::UNKNOWN, -1, -1, -1, {}};
5002 RIL_AppStatus *rilAppStatus = NULL;
5003 RIL_CardStatus_v1_5 *p_cur = ((RIL_CardStatus_v1_5 *) response);
5004 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v1_5)
5005 || p_cur->base.base.base.gsm_umts_subscription_app_index >= p_cur->base.base.base.num_applications
5006 || p_cur->base.base.base.cdma_subscription_app_index >= p_cur->base.base.base.num_applications
5007 || p_cur->base.base.base.ims_subscription_app_index >= p_cur->base.base.base.num_applications) {
5008 RLOGE("getIccCardStatusResponse: Invalid response");
5009 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5010 } else {
5011 cardStatus.cardState = (CardState) p_cur->base.base.base.card_state;
5012 cardStatus.universalPinState = (PinState) p_cur->base.base.base.universal_pin_state;
5013 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->base.base.base.gsm_umts_subscription_app_index;
5014 cardStatus.cdmaSubscriptionAppIndex = p_cur->base.base.base.cdma_subscription_app_index;
5015 cardStatus.imsSubscriptionAppIndex = p_cur->base.base.base.ims_subscription_app_index;
5016 rilAppStatus = p_cur->base.base.base.applications;
5017 cardStatus.applications.resize(p_cur->base.base.base.num_applications);
5018 AppStatus *appStatus = cardStatus.applications.data();
5019 #if VDBG
5020 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->base.base.base.num_applications);
5021 #endif
5022 for (int i = 0; i < p_cur->base.base.base.num_applications; i++) {
5023 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
5024 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
5025 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
5026 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
5027 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
5028 rilAppStatus[i].app_label_ptr);
5029 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
5030 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
5031 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
5032 }
5033 }
5034 if (p_cur && radioService[slotId]->mRadioResponseV1_5 != NULL) {
5035 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
5036 ::android::hardware::radio::V1_4::CardStatus cardStatusV1_4;
5037 ::android::hardware::radio::V1_5::CardStatus cardStatusV1_5;
5038 cardStatusV1_2.base = cardStatus;
5039 cardStatusV1_2.physicalSlotId = -1;
5040 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
5041 cardStatusV1_4.base = cardStatusV1_2;
5042 cardStatusV1_5.base = cardStatusV1_4;
5043 cardStatusV1_5.applications.resize(p_cur->base.base.base.num_applications);
5044 for (int i = 0; i < p_cur->base.base.base.num_applications; i++) {
5045 cardStatusV1_5.applications[i].base.appType = (AppType) rilAppStatus[i].app_type;
5046 cardStatusV1_5.applications[i].base.appState = (AppState) rilAppStatus[i].app_state;
5047 cardStatusV1_5.applications[i].base.persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
5048 cardStatusV1_5.applications[i].base.aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
5049 cardStatusV1_5.applications[i].base.appLabelPtr = convertCharPtrToHidlString(
5050 rilAppStatus[i].app_label_ptr);
5051 cardStatusV1_5.applications[i].base.pin1Replaced = rilAppStatus[i].pin1_replaced;
5052 cardStatusV1_5.applications[i].base.pin1 = (PinState) rilAppStatus[i].pin1;
5053 cardStatusV1_5.applications[i].base.pin2 = (PinState) rilAppStatus[i].pin2;
5054 cardStatusV1_5.applications[i].persoSubstate = (V1_5::PersoSubstate)rilAppStatus[i].perso_substate;
5055 }
5056
5057 // If POWER_DOWN then set applications to empty
5058 if (radioService[slotId]->mSimCardPowerState == V1_1::CardPowerState::POWER_DOWN) {
5059 RLOGD("getIccCardStatusResponse: state is POWER_DOWN so clearing apps");
5060 cardStatusV1_5.applications = {};
5061 }
5062 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5->
5063 getIccCardStatusResponse_1_5(responseInfo, cardStatusV1_5);
5064 radioService[slotId]->checkReturnStatus(retStatus);
5065 } else if (p_cur && radioService[slotId]->mRadioResponseV1_4 != NULL) {
5066 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
5067 ::android::hardware::radio::V1_4::CardStatus cardStatusV1_4;
5068 cardStatusV1_2.base = cardStatus;
5069 cardStatusV1_2.physicalSlotId = -1;
5070 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
5071 cardStatusV1_4.base = cardStatusV1_2;
5072 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4->
5073 getIccCardStatusResponse_1_4(responseInfo, cardStatusV1_4);
5074 radioService[slotId]->checkReturnStatus(retStatus);
5075 } else if (p_cur && radioService[slotId]->mRadioResponseV1_3 != NULL) {
5076 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
5077 cardStatusV1_2.base = cardStatus;
5078 cardStatusV1_2.physicalSlotId = -1;
5079 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
5080 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_3->
5081 getIccCardStatusResponse_1_2(responseInfo, cardStatusV1_2);
5082 radioService[slotId]->checkReturnStatus(retStatus);
5083 } else if (p_cur && radioService[slotId]->mRadioResponseV1_2 != NULL) {
5084 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
5085 cardStatusV1_2.base = cardStatus;
5086 cardStatusV1_2.physicalSlotId = -1;
5087 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
5088 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2->
5089 getIccCardStatusResponse_1_2(responseInfo, cardStatusV1_2);
5090 radioService[slotId]->checkReturnStatus(retStatus);
5091 // TODO: add 1.1 if needed.
5092 } else {
5093 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5094 getIccCardStatusResponse(responseInfo, cardStatus);
5095 radioService[slotId]->checkReturnStatus(retStatus);
5096 }
5097 } else {
5098 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5099 }
5100 return 0;
5101 }
5102
supplyIccPinForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5103 int radio_1_6::supplyIccPinForAppResponse(int slotId,
5104 int responseType, int serial, RIL_Errno e,
5105 void *response, size_t responseLen) {
5106 #if VDBG
5107 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
5108 #endif
5109
5110 if (radioService[slotId]->mRadioResponse != NULL) {
5111 RadioResponseInfo responseInfo = {};
5112 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5113 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5114 supplyIccPinForAppResponse(responseInfo, ret);
5115 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
5116 radioService[slotId]->checkReturnStatus(retStatus);
5117 } else {
5118 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
5119 slotId);
5120 }
5121
5122 return 0;
5123 }
5124
supplyIccPukForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5125 int radio_1_6::supplyIccPukForAppResponse(int slotId,
5126 int responseType, int serial, RIL_Errno e,
5127 void *response, size_t responseLen) {
5128 #if VDBG
5129 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
5130 #endif
5131
5132 if (radioService[slotId]->mRadioResponse != NULL) {
5133 RadioResponseInfo responseInfo = {};
5134 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5135 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
5136 responseInfo, ret);
5137 radioService[slotId]->checkReturnStatus(retStatus);
5138 } else {
5139 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
5140 slotId);
5141 }
5142
5143 return 0;
5144 }
5145
supplyIccPin2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5146 int radio_1_6::supplyIccPin2ForAppResponse(int slotId,
5147 int responseType, int serial, RIL_Errno e,
5148 void *response, size_t responseLen) {
5149 #if VDBG
5150 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
5151 #endif
5152
5153 if (radioService[slotId]->mRadioResponse != NULL) {
5154 RadioResponseInfo responseInfo = {};
5155 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5156 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5157 supplyIccPin2ForAppResponse(responseInfo, ret);
5158 radioService[slotId]->checkReturnStatus(retStatus);
5159 } else {
5160 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
5161 slotId);
5162 }
5163
5164 return 0;
5165 }
5166
supplyIccPuk2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5167 int radio_1_6::supplyIccPuk2ForAppResponse(int slotId,
5168 int responseType, int serial, RIL_Errno e,
5169 void *response, size_t responseLen) {
5170 #if VDBG
5171 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
5172 #endif
5173
5174 if (radioService[slotId]->mRadioResponse != NULL) {
5175 RadioResponseInfo responseInfo = {};
5176 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5177 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5178 supplyIccPuk2ForAppResponse(responseInfo, ret);
5179 radioService[slotId]->checkReturnStatus(retStatus);
5180 } else {
5181 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
5182 slotId);
5183 }
5184
5185 return 0;
5186 }
5187
changeIccPinForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5188 int radio_1_6::changeIccPinForAppResponse(int slotId,
5189 int responseType, int serial, RIL_Errno e,
5190 void *response, size_t responseLen) {
5191 #if VDBG
5192 RLOGD("changeIccPinForAppResponse: serial %d", serial);
5193 #endif
5194
5195 if (radioService[slotId]->mRadioResponse != NULL) {
5196 RadioResponseInfo responseInfo = {};
5197 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5198 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5199 changeIccPinForAppResponse(responseInfo, ret);
5200 radioService[slotId]->checkReturnStatus(retStatus);
5201 } else {
5202 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
5203 slotId);
5204 }
5205
5206 return 0;
5207 }
5208
changeIccPin2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5209 int radio_1_6::changeIccPin2ForAppResponse(int slotId,
5210 int responseType, int serial, RIL_Errno e,
5211 void *response, size_t responseLen) {
5212 #if VDBG
5213 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
5214 #endif
5215
5216 if (radioService[slotId]->mRadioResponse != NULL) {
5217 RadioResponseInfo responseInfo = {};
5218 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5219 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5220 changeIccPin2ForAppResponse(responseInfo, ret);
5221 radioService[slotId]->checkReturnStatus(retStatus);
5222 } else {
5223 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
5224 slotId);
5225 }
5226
5227 return 0;
5228 }
5229
supplyNetworkDepersonalizationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5230 int radio_1_6::supplyNetworkDepersonalizationResponse(int slotId,
5231 int responseType, int serial, RIL_Errno e,
5232 void *response, size_t responseLen) {
5233 #if VDBG
5234 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
5235 #endif
5236
5237 if (radioService[slotId]->mRadioResponse != NULL) {
5238 RadioResponseInfo responseInfo = {};
5239 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5240 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5241 supplyNetworkDepersonalizationResponse(responseInfo, ret);
5242 radioService[slotId]->checkReturnStatus(retStatus);
5243 } else {
5244 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
5245 "NULL", slotId);
5246 }
5247
5248 return 0;
5249 }
5250
getCurrentCallsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5251 int radio_1_6::getCurrentCallsResponse(int slotId, int responseType, int serial, RIL_Errno e,
5252 void* response, size_t responseLen) {
5253 #if VDBG
5254 RLOGD("getCurrentCallsResponse: serial %d", serial);
5255 #endif
5256
5257 if (radioService[slotId]->mRadioResponseV1_6 != NULL ||
5258 radioService[slotId]->mRadioResponseV1_2 != NULL ||
5259 radioService[slotId]->mRadioResponse != NULL) {
5260 V1_6::RadioResponseInfo responseInfo16 = {};
5261 RadioResponseInfo responseInfo = {};
5262 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5263 populateResponseInfo_1_6(responseInfo16, serial, responseType, e);
5264 } else {
5265 populateResponseInfo(responseInfo, serial, responseType, e);
5266 }
5267 if ((response == NULL && responseLen != 0) || (responseLen % sizeof(RIL_Call*)) != 0) {
5268 RLOGE("getCurrentCallsResponse: Invalid response");
5269 if (e == RIL_E_SUCCESS) {
5270 responseInfo16.error = V1_6::RadioError::INVALID_RESPONSE;
5271 responseInfo.error = RadioError::INVALID_RESPONSE;
5272 }
5273 return 0;
5274 } else {
5275 Return<void> retStatus;
5276 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5277 hidl_vec<V1_6::Call> calls;
5278 int num = responseLen / sizeof(RIL_Call*);
5279 calls.resize(num);
5280
5281 for (int i = 0; i < num; i++) {
5282 RIL_Call* p_cur = ((RIL_Call**)response)[i];
5283 /* each call info */
5284 calls[i].base.base.state = (CallState)p_cur->state;
5285 calls[i].base.base.index = p_cur->index;
5286 calls[i].base.base.toa = p_cur->toa;
5287 calls[i].base.base.isMpty = p_cur->isMpty;
5288 calls[i].base.base.isMT = p_cur->isMT;
5289 calls[i].base.base.als = p_cur->als;
5290 calls[i].base.base.isVoice = p_cur->isVoice;
5291 calls[i].base.base.isVoicePrivacy = p_cur->isVoicePrivacy;
5292 calls[i].base.base.number = convertCharPtrToHidlString(p_cur->number);
5293 calls[i].base.base.numberPresentation =
5294 (CallPresentation)p_cur->numberPresentation;
5295 calls[i].base.base.name = convertCharPtrToHidlString(p_cur->name);
5296 calls[i].base.base.namePresentation = (CallPresentation)p_cur->namePresentation;
5297 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
5298 RIL_UUS_Info* uusInfo = p_cur->uusInfo;
5299 calls[i].base.base.uusInfo.resize(1);
5300 calls[i].base.base.uusInfo[0].uusType = (UusType)uusInfo->uusType;
5301 calls[i].base.base.uusInfo[0].uusDcs = (UusDcs)uusInfo->uusDcs;
5302 // convert uusInfo->uusData to a null-terminated string
5303 char* nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
5304 calls[i].base.base.uusInfo[0].uusData = nullTermStr;
5305 free(nullTermStr);
5306 }
5307 }
5308 retStatus = radioService[slotId]->mRadioResponseV1_6->getCurrentCallsResponse_1_6(
5309 responseInfo16, calls);
5310 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
5311 hidl_vec<V1_2::Call> calls;
5312 int num = responseLen / sizeof(RIL_Call*);
5313 calls.resize(num);
5314
5315 for (int i = 0; i < num; i++) {
5316 RIL_Call* p_cur = ((RIL_Call**)response)[i];
5317 /* each call info */
5318 calls[i].base.state = (CallState)p_cur->state;
5319 calls[i].base.index = p_cur->index;
5320 calls[i].base.toa = p_cur->toa;
5321 calls[i].base.isMpty = p_cur->isMpty;
5322 calls[i].base.isMT = p_cur->isMT;
5323 calls[i].base.als = p_cur->als;
5324 calls[i].base.isVoice = p_cur->isVoice;
5325 calls[i].base.isVoicePrivacy = p_cur->isVoicePrivacy;
5326 calls[i].base.number = convertCharPtrToHidlString(p_cur->number);
5327 calls[i].base.numberPresentation = (CallPresentation)p_cur->numberPresentation;
5328 calls[i].base.name = convertCharPtrToHidlString(p_cur->name);
5329 calls[i].base.namePresentation = (CallPresentation)p_cur->namePresentation;
5330 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
5331 RIL_UUS_Info* uusInfo = p_cur->uusInfo;
5332 calls[i].base.uusInfo.resize(1);
5333 calls[i].base.uusInfo[0].uusType = (UusType)uusInfo->uusType;
5334 calls[i].base.uusInfo[0].uusDcs = (UusDcs)uusInfo->uusDcs;
5335 // convert uusInfo->uusData to a null-terminated string
5336 char* nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
5337 calls[i].base.uusInfo[0].uusData = nullTermStr;
5338 free(nullTermStr);
5339 }
5340 }
5341 retStatus = radioService[slotId]->mRadioResponseV1_2->getCurrentCallsResponse_1_2(
5342 responseInfo, calls);
5343 } else {
5344 hidl_vec<Call> calls;
5345 int num = responseLen / sizeof(RIL_Call*);
5346 calls.resize(num);
5347
5348 for (int i = 0; i < num; i++) {
5349 RIL_Call* p_cur = ((RIL_Call**)response)[i];
5350 /* each call info */
5351 calls[i].state = (CallState)p_cur->state;
5352 calls[i].index = p_cur->index;
5353 calls[i].toa = p_cur->toa;
5354 calls[i].isMpty = p_cur->isMpty;
5355 calls[i].isMT = p_cur->isMT;
5356 calls[i].als = p_cur->als;
5357 calls[i].isVoice = p_cur->isVoice;
5358 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
5359 calls[i].number = convertCharPtrToHidlString(p_cur->number);
5360 calls[i].numberPresentation = (CallPresentation)p_cur->numberPresentation;
5361 calls[i].name = convertCharPtrToHidlString(p_cur->name);
5362 calls[i].namePresentation = (CallPresentation)p_cur->namePresentation;
5363 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
5364 RIL_UUS_Info* uusInfo = p_cur->uusInfo;
5365 calls[i].uusInfo.resize(1);
5366 calls[i].uusInfo[0].uusType = (UusType)uusInfo->uusType;
5367 calls[i].uusInfo[0].uusDcs = (UusDcs)uusInfo->uusDcs;
5368 // convert uusInfo->uusData to a null-terminated string
5369 char* nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
5370 calls[i].uusInfo[0].uusData = nullTermStr;
5371 free(nullTermStr);
5372 }
5373 }
5374 retStatus = radioService[slotId]->mRadioResponse->getCurrentCallsResponse(
5375 responseInfo, calls);
5376 }
5377 radioService[slotId]->checkReturnStatus(retStatus);
5378 }
5379 } else {
5380 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5381 }
5382
5383 return 0;
5384 }
5385
dialResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5386 int radio_1_6::dialResponse(int slotId,
5387 int responseType, int serial, RIL_Errno e, void *response,
5388 size_t responseLen) {
5389 #if VDBG
5390 RLOGD("dialResponse: serial %d", serial);
5391 #endif
5392
5393 if (radioService[slotId]->mRadioResponse != NULL) {
5394 RadioResponseInfo responseInfo = {};
5395 populateResponseInfo(responseInfo, serial, responseType, e);
5396 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
5397 radioService[slotId]->checkReturnStatus(retStatus);
5398 } else {
5399 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5400 }
5401
5402 return 0;
5403 }
5404
getIMSIForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5405 int radio_1_6::getIMSIForAppResponse(int slotId,
5406 int responseType, int serial, RIL_Errno e, void *response,
5407 size_t responseLen) {
5408 #if VDBG
5409 RLOGD("getIMSIForAppResponse: serial %d", serial);
5410 #endif
5411
5412 if (radioService[slotId]->mRadioResponse != NULL) {
5413 RadioResponseInfo responseInfo = {};
5414 populateResponseInfo(responseInfo, serial, responseType, e);
5415 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
5416 responseInfo, convertCharPtrToHidlString((char *) response));
5417 radioService[slotId]->checkReturnStatus(retStatus);
5418 } else {
5419 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
5420 slotId);
5421 }
5422
5423 return 0;
5424 }
5425
hangupConnectionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5426 int radio_1_6::hangupConnectionResponse(int slotId,
5427 int responseType, int serial, RIL_Errno e,
5428 void *response, size_t responseLen) {
5429 #if VDBG
5430 RLOGD("hangupConnectionResponse: serial %d", serial);
5431 #endif
5432
5433 if (radioService[slotId]->mRadioResponse != NULL) {
5434 RadioResponseInfo responseInfo = {};
5435 populateResponseInfo(responseInfo, serial, responseType, e);
5436 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
5437 responseInfo);
5438 radioService[slotId]->checkReturnStatus(retStatus);
5439 } else {
5440 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
5441 slotId);
5442 }
5443
5444 return 0;
5445 }
5446
hangupWaitingOrBackgroundResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5447 int radio_1_6::hangupWaitingOrBackgroundResponse(int slotId,
5448 int responseType, int serial, RIL_Errno e,
5449 void *response, size_t responseLen) {
5450 #if VDBG
5451 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
5452 #endif
5453
5454 if (radioService[slotId]->mRadioResponse != NULL) {
5455 RadioResponseInfo responseInfo = {};
5456 populateResponseInfo(responseInfo, serial, responseType, e);
5457 Return<void> retStatus =
5458 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
5459 responseInfo);
5460 radioService[slotId]->checkReturnStatus(retStatus);
5461 } else {
5462 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
5463 slotId);
5464 }
5465
5466 return 0;
5467 }
5468
hangupForegroundResumeBackgroundResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5469 int radio_1_6::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
5470 RIL_Errno e, void *response,
5471 size_t responseLen) {
5472 #if VDBG
5473 RLOGD("hangupForegroundResumeBackgroundResponse: 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->hangupForegroundResumeBackgroundResponse(
5481 responseInfo);
5482 radioService[slotId]->checkReturnStatus(retStatus);
5483 } else {
5484 RLOGE("hangupForegroundResumeBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
5485 slotId);
5486 }
5487
5488 return 0;
5489 }
5490
switchWaitingOrHoldingAndActiveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5491 int radio_1_6::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
5492 RIL_Errno e, void *response,
5493 size_t responseLen) {
5494 #if VDBG
5495 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
5496 #endif
5497
5498 if (radioService[slotId]->mRadioResponse != NULL) {
5499 RadioResponseInfo responseInfo = {};
5500 populateResponseInfo(responseInfo, serial, responseType, e);
5501 Return<void> retStatus =
5502 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
5503 responseInfo);
5504 radioService[slotId]->checkReturnStatus(retStatus);
5505 } else {
5506 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
5507 "== NULL", slotId);
5508 }
5509
5510 return 0;
5511 }
5512
conferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5513 int radio_1_6::conferenceResponse(int slotId, int responseType,
5514 int serial, RIL_Errno e, void *response, size_t responseLen) {
5515 #if VDBG
5516 RLOGD("conferenceResponse: serial %d", serial);
5517 #endif
5518
5519 if (radioService[slotId]->mRadioResponse != NULL) {
5520 RadioResponseInfo responseInfo = {};
5521 populateResponseInfo(responseInfo, serial, responseType, e);
5522 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
5523 responseInfo);
5524 radioService[slotId]->checkReturnStatus(retStatus);
5525 } else {
5526 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
5527 slotId);
5528 }
5529
5530 return 0;
5531 }
5532
rejectCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5533 int radio_1_6::rejectCallResponse(int slotId, int responseType,
5534 int serial, RIL_Errno e, void *response, size_t responseLen) {
5535 #if VDBG
5536 RLOGD("rejectCallResponse: serial %d", serial);
5537 #endif
5538
5539 if (radioService[slotId]->mRadioResponse != NULL) {
5540 RadioResponseInfo responseInfo = {};
5541 populateResponseInfo(responseInfo, serial, responseType, e);
5542 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
5543 responseInfo);
5544 radioService[slotId]->checkReturnStatus(retStatus);
5545 } else {
5546 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
5547 slotId);
5548 }
5549
5550 return 0;
5551 }
5552
getLastCallFailCauseResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5553 int radio_1_6::getLastCallFailCauseResponse(int slotId,
5554 int responseType, int serial, RIL_Errno e, void *response,
5555 size_t responseLen) {
5556 #if VDBG
5557 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
5558 #endif
5559
5560 if (radioService[slotId]->mRadioResponse != NULL) {
5561 RadioResponseInfo responseInfo = {};
5562 populateResponseInfo(responseInfo, serial, responseType, e);
5563
5564 LastCallFailCauseInfo info = {};
5565 info.vendorCause = hidl_string();
5566 if (response == NULL) {
5567 RLOGE("getLastCallFailCauseResponse Invalid response: NULL");
5568 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5569 } else if (responseLen == sizeof(int)) {
5570 int *pInt = (int *) response;
5571 info.causeCode = (LastCallFailCause) pInt[0];
5572 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
5573 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
5574 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
5575 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
5576 } else {
5577 RLOGE("getLastCallFailCauseResponse Invalid response: NULL");
5578 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5579 }
5580
5581 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
5582 responseInfo, info);
5583 radioService[slotId]->checkReturnStatus(retStatus);
5584 } else {
5585 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
5586 slotId);
5587 }
5588
5589 return 0;
5590 }
5591
getSignalStrengthResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5592 int radio_1_6::getSignalStrengthResponse(int slotId, int responseType, int serial, RIL_Errno e,
5593 void* response, size_t responseLen) {
5594 #if VDBG
5595 RLOGD("getSignalStrengthResponse: serial %d", serial);
5596 #endif
5597
5598 V1_6::RadioResponseInfo responseInfo16 = {};
5599 RadioResponseInfo responseInfo = {};
5600 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5601 populateResponseInfo_1_6(responseInfo16, serial, responseType, e);
5602 } else {
5603 populateResponseInfo(responseInfo, serial, responseType, e);
5604 }
5605
5606 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v12)) {
5607 RLOGE("getSignalStrengthResponse: Invalid response");
5608 if (e == RIL_E_SUCCESS) {
5609 responseInfo16.error = V1_6::RadioError::INVALID_RESPONSE;
5610 responseInfo.error = RadioError::INVALID_RESPONSE;
5611 }
5612 } else {
5613 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5614 V1_6::SignalStrength signalStrength_1_6 = {};
5615 convertRilSignalStrengthToHal_1_6(response, responseLen, signalStrength_1_6);
5616 Return<void> retStatus =
5617 radioService[slotId]->mRadioResponseV1_6->getSignalStrengthResponse_1_6(
5618 responseInfo16, signalStrength_1_6);
5619 radioService[slotId]->checkReturnStatus(retStatus);
5620 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
5621 V1_4::SignalStrength signalStrength_1_4 = {};
5622 convertRilSignalStrengthToHal_1_4(response, responseLen, signalStrength_1_4);
5623 // TODO: future implementation needs to fill tdScdma, wcdma and nr signal strength.
5624 Return<void> retStatus =
5625 radioService[slotId]->mRadioResponseV1_4->getSignalStrengthResponse_1_4(
5626 responseInfo, signalStrength_1_4);
5627 radioService[slotId]->checkReturnStatus(retStatus);
5628 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
5629 V1_2::SignalStrength signalStrength_1_2 = {};
5630 convertRilSignalStrengthToHal_1_2(response, responseLen, signalStrength_1_2);
5631 Return<void> retStatus =
5632 radioService[slotId]->mRadioResponseV1_2->getSignalStrengthResponse_1_2(
5633 responseInfo, signalStrength_1_2);
5634 radioService[slotId]->checkReturnStatus(retStatus);
5635 } else if (radioService[slotId]->mRadioResponse != NULL) {
5636 SignalStrength signalStrength = {};
5637 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
5638 Return<void> retStatus =
5639 radioService[slotId]->mRadioResponse->getSignalStrengthResponse(responseInfo,
5640 signalStrength);
5641 radioService[slotId]->checkReturnStatus(retStatus);
5642 } else {
5643 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5644 }
5645 }
5646
5647 return 0;
5648 }
5649
getCellInfoTypeRadioTechnology(char * rat)5650 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
5651 if (rat == NULL) {
5652 return RIL_CELL_INFO_TYPE_NONE;
5653 }
5654
5655 int radioTech = atoi(rat);
5656
5657 switch(radioTech) {
5658
5659 case RADIO_TECH_GPRS:
5660 case RADIO_TECH_EDGE:
5661 case RADIO_TECH_GSM: {
5662 return RIL_CELL_INFO_TYPE_GSM;
5663 }
5664
5665 case RADIO_TECH_UMTS:
5666 case RADIO_TECH_HSDPA:
5667 case RADIO_TECH_HSUPA:
5668 case RADIO_TECH_HSPA:
5669 case RADIO_TECH_HSPAP: {
5670 return RIL_CELL_INFO_TYPE_WCDMA;
5671 }
5672
5673 case RADIO_TECH_IS95A:
5674 case RADIO_TECH_IS95B:
5675 case RADIO_TECH_1xRTT:
5676 case RADIO_TECH_EVDO_0:
5677 case RADIO_TECH_EVDO_A:
5678 case RADIO_TECH_EVDO_B:
5679 case RADIO_TECH_EHRPD: {
5680 return RIL_CELL_INFO_TYPE_CDMA;
5681 }
5682
5683 case RADIO_TECH_LTE:
5684 case RADIO_TECH_LTE_CA: {
5685 return RIL_CELL_INFO_TYPE_LTE;
5686 }
5687
5688 case RADIO_TECH_TD_SCDMA: {
5689 return RIL_CELL_INFO_TYPE_TD_SCDMA;
5690 }
5691
5692 default: {
5693 break;
5694 }
5695 }
5696
5697 return RIL_CELL_INFO_TYPE_NONE;
5698
5699 }
5700
fillCellIdentityResponse(CellIdentity & cellIdentity,RIL_CellIdentity_v16 & rilCellIdentity)5701 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
5702
5703 cellIdentity.cellIdentityGsm.resize(0);
5704 cellIdentity.cellIdentityWcdma.resize(0);
5705 cellIdentity.cellIdentityCdma.resize(0);
5706 cellIdentity.cellIdentityTdscdma.resize(0);
5707 cellIdentity.cellIdentityLte.resize(0);
5708 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
5709 switch(rilCellIdentity.cellInfoType) {
5710
5711 case RIL_CELL_INFO_TYPE_GSM: {
5712 cellIdentity.cellIdentityGsm.resize(1);
5713 cellIdentity.cellIdentityGsm[0].mcc =
5714 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5715 cellIdentity.cellIdentityGsm[0].mnc =
5716 ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
5717 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
5718 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
5719 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
5720 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
5721 break;
5722 }
5723
5724 case RIL_CELL_INFO_TYPE_WCDMA: {
5725 cellIdentity.cellIdentityWcdma.resize(1);
5726 cellIdentity.cellIdentityWcdma[0].mcc =
5727 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
5728 cellIdentity.cellIdentityWcdma[0].mnc =
5729 ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
5730 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
5731 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
5732 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
5733 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
5734 break;
5735 }
5736
5737 case RIL_CELL_INFO_TYPE_CDMA: {
5738 cellIdentity.cellIdentityCdma.resize(1);
5739 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
5740 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
5741 cellIdentity.cellIdentityCdma[0].baseStationId =
5742 rilCellIdentity.cellIdentityCdma.basestationId;
5743 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
5744 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
5745 break;
5746 }
5747
5748 case RIL_CELL_INFO_TYPE_LTE: {
5749 cellIdentity.cellIdentityLte.resize(1);
5750 cellIdentity.cellIdentityLte[0].mcc =
5751 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
5752 cellIdentity.cellIdentityLte[0].mnc =
5753 ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
5754 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
5755 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
5756 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
5757 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
5758 break;
5759 }
5760
5761 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
5762 cellIdentity.cellIdentityTdscdma.resize(1);
5763 cellIdentity.cellIdentityTdscdma[0].mcc =
5764 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
5765 cellIdentity.cellIdentityTdscdma[0].mnc =
5766 ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
5767 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
5768 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
5769 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
5770 break;
5771 }
5772
5773 default: {
5774 break;
5775 }
5776 }
5777 }
5778
fillCellIdentityResponse_1_5(V1_5::CellIdentity & cellIdentity,RIL_CellIdentity_v16 & rilCellIdentity)5779 void fillCellIdentityResponse_1_5(V1_5::CellIdentity &cellIdentity,
5780 RIL_CellIdentity_v16 &rilCellIdentity) {
5781
5782 switch (rilCellIdentity.cellInfoType) {
5783 case RIL_CELL_INFO_TYPE_GSM: {
5784 V1_5::CellIdentityGsm gsm;
5785 gsm.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5786 gsm.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
5787 if (gsm.base.base.mcc == "-1") {
5788 gsm.base.base.mcc = "";
5789 }
5790 gsm.base.base.lac = rilCellIdentity.cellIdentityGsm.lac;
5791 gsm.base.base.cid = rilCellIdentity.cellIdentityGsm.cid;
5792 gsm.base.base.arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
5793 gsm.base.base.bsic = rilCellIdentity.cellIdentityGsm.bsic;
5794 cellIdentity.gsm(gsm);
5795 break;
5796 }
5797
5798 case RIL_CELL_INFO_TYPE_WCDMA: {
5799 V1_5::CellIdentityWcdma wcdma;
5800 wcdma.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5801 wcdma.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
5802 if (wcdma.base.base.mcc == "-1") {
5803 wcdma.base.base.mcc = "";
5804 }
5805 wcdma.base.base.lac = rilCellIdentity.cellIdentityWcdma.lac;
5806 wcdma.base.base.cid = rilCellIdentity.cellIdentityWcdma.cid;
5807 wcdma.base.base.psc = rilCellIdentity.cellIdentityWcdma.psc;
5808 wcdma.base.base.uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
5809 cellIdentity.wcdma(wcdma);
5810 break;
5811 }
5812
5813 case RIL_CELL_INFO_TYPE_CDMA: {
5814 V1_2::CellIdentityCdma cdma;
5815 cdma.base.networkId = rilCellIdentity.cellIdentityCdma.networkId;
5816 cdma.base.systemId = rilCellIdentity.cellIdentityCdma.systemId;
5817 cdma.base.baseStationId =
5818 rilCellIdentity.cellIdentityCdma.basestationId;
5819 cdma.base.longitude = rilCellIdentity.cellIdentityCdma.longitude;
5820 cdma.base.latitude = rilCellIdentity.cellIdentityCdma.latitude;
5821 cellIdentity.cdma(cdma);
5822 break;
5823 }
5824
5825 case RIL_CELL_INFO_TYPE_LTE: {
5826 V1_5::CellIdentityLte lte;
5827 lte.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5828 lte.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
5829 if (lte.base.base.mcc == "-1") {
5830 lte.base.base.mcc = "";
5831 }
5832 lte.base.base.ci = rilCellIdentity.cellIdentityLte.ci;
5833 lte.base.base.pci = rilCellIdentity.cellIdentityLte.pci;
5834 lte.base.base.tac = rilCellIdentity.cellIdentityLte.tac;
5835 lte.base.base.earfcn = rilCellIdentity.cellIdentityLte.earfcn;
5836 cellIdentity.lte(lte);
5837 break;
5838 }
5839
5840 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
5841 V1_5::CellIdentityTdscdma tdscdma;
5842 tdscdma.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5843 tdscdma.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
5844 if (tdscdma.base.base.mcc == "-1") {
5845 tdscdma.base.base.mcc = "";
5846 }
5847 tdscdma.base.base.lac = rilCellIdentity.cellIdentityTdscdma.lac;
5848 tdscdma.base.base.cid = rilCellIdentity.cellIdentityTdscdma.cid;
5849 tdscdma.base.base.cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
5850 cellIdentity.tdscdma(tdscdma);
5851 break;
5852 }
5853
5854 default: {
5855 break;
5856 }
5857 }
5858 }
5859
fillCellIdentityResponse_1_2(V1_2::CellIdentity & cellIdentity,RIL_CellIdentity_v1_2 & rilCellIdentity)5860 void fillCellIdentityResponse_1_2(V1_2::CellIdentity &cellIdentity,
5861 RIL_CellIdentity_v1_2 &rilCellIdentity) {
5862 cellIdentity.cellIdentityGsm.resize(0);
5863 cellIdentity.cellIdentityWcdma.resize(0);
5864 cellIdentity.cellIdentityCdma.resize(0);
5865 cellIdentity.cellIdentityTdscdma.resize(0);
5866 cellIdentity.cellIdentityLte.resize(0);
5867 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
5868 switch(rilCellIdentity.cellInfoType) {
5869
5870 case RIL_CELL_INFO_TYPE_GSM: {
5871 cellIdentity.cellIdentityGsm.resize(1);
5872 cellIdentity.cellIdentityGsm[0].base.mcc =
5873 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5874 cellIdentity.cellIdentityGsm[0].base.mnc =
5875 ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
5876
5877 if (cellIdentity.cellIdentityGsm[0].base.mcc == "-1") {
5878 cellIdentity.cellIdentityGsm[0].base.mcc = "";
5879 }
5880
5881 cellIdentity.cellIdentityGsm[0].base.lac = rilCellIdentity.cellIdentityGsm.lac;
5882 cellIdentity.cellIdentityGsm[0].base.cid = rilCellIdentity.cellIdentityGsm.cid;
5883 cellIdentity.cellIdentityGsm[0].base.arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
5884 cellIdentity.cellIdentityGsm[0].base.bsic = rilCellIdentity.cellIdentityGsm.bsic;
5885 break;
5886 }
5887
5888 case RIL_CELL_INFO_TYPE_WCDMA: {
5889 cellIdentity.cellIdentityWcdma.resize(1);
5890 cellIdentity.cellIdentityWcdma[0].base.mcc =
5891 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
5892 cellIdentity.cellIdentityWcdma[0].base.mnc =
5893 ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
5894
5895 if (cellIdentity.cellIdentityWcdma[0].base.mcc == "-1") {
5896 cellIdentity.cellIdentityWcdma[0].base.mcc = "";
5897 }
5898
5899 cellIdentity.cellIdentityWcdma[0].base.lac = rilCellIdentity.cellIdentityWcdma.lac;
5900 cellIdentity.cellIdentityWcdma[0].base.cid = rilCellIdentity.cellIdentityWcdma.cid;
5901 cellIdentity.cellIdentityWcdma[0].base.psc = rilCellIdentity.cellIdentityWcdma.psc;
5902 cellIdentity.cellIdentityWcdma[0].base.uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
5903 break;
5904 }
5905
5906 case RIL_CELL_INFO_TYPE_CDMA: {
5907 cellIdentity.cellIdentityCdma.resize(1);
5908 cellIdentity.cellIdentityCdma[0].base.networkId = rilCellIdentity.cellIdentityCdma.networkId;
5909 cellIdentity.cellIdentityCdma[0].base.systemId = rilCellIdentity.cellIdentityCdma.systemId;
5910 cellIdentity.cellIdentityCdma[0].base.baseStationId =
5911 rilCellIdentity.cellIdentityCdma.basestationId;
5912 cellIdentity.cellIdentityCdma[0].base.longitude = rilCellIdentity.cellIdentityCdma.longitude;
5913 cellIdentity.cellIdentityCdma[0].base.latitude = rilCellIdentity.cellIdentityCdma.latitude;
5914 break;
5915 }
5916
5917 case RIL_CELL_INFO_TYPE_LTE: {
5918 cellIdentity.cellIdentityLte.resize(1);
5919 cellIdentity.cellIdentityLte[0].base.mcc =
5920 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
5921 cellIdentity.cellIdentityLte[0].base.mnc =
5922 ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
5923
5924 if (cellIdentity.cellIdentityLte[0].base.mcc == "-1") {
5925 cellIdentity.cellIdentityLte[0].base.mcc = "";
5926 }
5927
5928 cellIdentity.cellIdentityLte[0].base.ci = rilCellIdentity.cellIdentityLte.ci;
5929 cellIdentity.cellIdentityLte[0].base.pci = rilCellIdentity.cellIdentityLte.pci;
5930 cellIdentity.cellIdentityLte[0].base.tac = rilCellIdentity.cellIdentityLte.tac;
5931 cellIdentity.cellIdentityLte[0].base.earfcn = rilCellIdentity.cellIdentityLte.earfcn;
5932 cellIdentity.cellIdentityLte[0].bandwidth = rilCellIdentity.cellIdentityLte.bandwidth;
5933 break;
5934 }
5935
5936 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
5937 cellIdentity.cellIdentityTdscdma.resize(1);
5938 cellIdentity.cellIdentityTdscdma[0].base.mcc =
5939 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
5940 cellIdentity.cellIdentityTdscdma[0].base.mnc =
5941 ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
5942
5943 if (cellIdentity.cellIdentityTdscdma[0].base.mcc == "-1") {
5944 cellIdentity.cellIdentityTdscdma[0].base.mcc = "";
5945 }
5946
5947 cellIdentity.cellIdentityTdscdma[0].base.lac = rilCellIdentity.cellIdentityTdscdma.lac;
5948 cellIdentity.cellIdentityTdscdma[0].base.cid = rilCellIdentity.cellIdentityTdscdma.cid;
5949 cellIdentity.cellIdentityTdscdma[0].base.cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
5950 cellIdentity.cellIdentityTdscdma[0].uarfcn = rilCellIdentity.cellIdentityTdscdma.uarfcn;
5951 break;
5952 }
5953
5954 default: {
5955 break;
5956 }
5957 }
5958 }
5959
convertResponseStringEntryToInt(char ** response,int index,int numStrings)5960 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
5961 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
5962 return atoi(response[index]);
5963 }
5964
5965 return -1;
5966 }
5967
convertResponseHexStringEntryToInt(char ** response,int index,int numStrings)5968 int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
5969 const int hexBase = 16;
5970 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
5971 return strtol(response[index], NULL, hexBase);
5972 }
5973
5974 return -1;
5975 }
5976
5977 /* Fill Cell Identity info from Voice Registration State Response.
5978 * This function is applicable only for RIL Version < 15.
5979 * Response is a "char **".
5980 * First and Second entries are in hex string format
5981 * and rest are integers represented in ascii format. */
fillCellIdentityFromVoiceRegStateResponseString(V1_5::CellIdentity & cellIdentity,int numStrings,char ** response)5982 void fillCellIdentityFromVoiceRegStateResponseString(V1_5::CellIdentity &cellIdentity,
5983 int numStrings, char** response) {
5984
5985 RIL_CellIdentity_v16 rilCellIdentity;
5986 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
5987
5988 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
5989 switch(rilCellIdentity.cellInfoType) {
5990
5991 case RIL_CELL_INFO_TYPE_GSM: {
5992 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
5993 rilCellIdentity.cellIdentityGsm.lac =
5994 convertResponseHexStringEntryToInt(response, 1, numStrings);
5995
5996 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
5997 rilCellIdentity.cellIdentityGsm.cid =
5998 convertResponseHexStringEntryToInt(response, 2, numStrings);
5999
6000 if (numStrings > 15) {
6001 rilCellIdentity.cellIdentityGsm.mcc =
6002 convertResponseStringEntryToInt(response, 15, numStrings);
6003
6004 rilCellIdentity.cellIdentityGsm.mnc =
6005 convertResponseStringEntryToInt(response, 16, numStrings);
6006 }
6007 break;
6008 }
6009
6010 case RIL_CELL_INFO_TYPE_WCDMA: {
6011 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6012 rilCellIdentity.cellIdentityWcdma.lac =
6013 convertResponseHexStringEntryToInt(response, 1, numStrings);
6014
6015 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6016 rilCellIdentity.cellIdentityWcdma.cid =
6017 convertResponseHexStringEntryToInt(response, 2, numStrings);
6018 rilCellIdentity.cellIdentityWcdma.psc =
6019 convertResponseStringEntryToInt(response, 14, numStrings);
6020
6021 if (numStrings > 15) {
6022 rilCellIdentity.cellIdentityGsm.mcc =
6023 convertResponseStringEntryToInt(response, 15, numStrings);
6024
6025 rilCellIdentity.cellIdentityGsm.mnc =
6026 convertResponseStringEntryToInt(response, 16, numStrings);
6027 }
6028 break;
6029 }
6030
6031 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
6032 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6033 rilCellIdentity.cellIdentityTdscdma.lac =
6034 convertResponseHexStringEntryToInt(response, 1, numStrings);
6035
6036 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6037 rilCellIdentity.cellIdentityTdscdma.cid =
6038 convertResponseHexStringEntryToInt(response, 2, numStrings);
6039
6040 if (numStrings > 15) {
6041 rilCellIdentity.cellIdentityGsm.mcc =
6042 convertResponseStringEntryToInt(response, 15, numStrings);
6043
6044 rilCellIdentity.cellIdentityGsm.mnc =
6045 convertResponseStringEntryToInt(response, 16, numStrings);
6046 }
6047 break;
6048 }
6049
6050 case RIL_CELL_INFO_TYPE_CDMA:{
6051 rilCellIdentity.cellIdentityCdma.basestationId =
6052 convertResponseStringEntryToInt(response, 4, numStrings);
6053 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
6054 rilCellIdentity.cellIdentityCdma.latitude =
6055 convertResponseStringEntryToInt(response, 5, numStrings);
6056 rilCellIdentity.cellIdentityCdma.longitude =
6057 convertResponseStringEntryToInt(response, 6, numStrings);
6058 rilCellIdentity.cellIdentityCdma.systemId =
6059 convertResponseStringEntryToInt(response, 8, numStrings);
6060 rilCellIdentity.cellIdentityCdma.networkId =
6061 convertResponseStringEntryToInt(response, 9, numStrings);
6062 break;
6063 }
6064
6065 case RIL_CELL_INFO_TYPE_LTE:{
6066 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
6067 rilCellIdentity.cellIdentityLte.tac =
6068 convertResponseHexStringEntryToInt(response, 1, numStrings);
6069
6070 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6071 rilCellIdentity.cellIdentityLte.ci =
6072 convertResponseHexStringEntryToInt(response, 2, numStrings);
6073
6074 if (numStrings > 15) {
6075 rilCellIdentity.cellIdentityGsm.mcc =
6076 convertResponseStringEntryToInt(response, 15, numStrings);
6077
6078 rilCellIdentity.cellIdentityGsm.mnc =
6079 convertResponseStringEntryToInt(response, 16, numStrings);
6080 }
6081 break;
6082 }
6083
6084 default: {
6085 break;
6086 }
6087 }
6088
6089 fillCellIdentityResponse_1_5(cellIdentity, rilCellIdentity);
6090 }
6091
fillCellIdentityFromVoiceRegStateResponseString_1_2(V1_2::CellIdentity & cellIdentity,int numStrings,char ** response)6092 void fillCellIdentityFromVoiceRegStateResponseString_1_2(V1_2::CellIdentity &cellIdentity,
6093 int numStrings, char** response) {
6094 RIL_CellIdentity_v1_2 rilCellIdentity;
6095 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v1_2));
6096
6097 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6098
6099 switch(rilCellIdentity.cellInfoType) {
6100 case RIL_CELL_INFO_TYPE_GSM: {
6101 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6102 rilCellIdentity.cellIdentityGsm.lac =
6103 convertResponseHexStringEntryToInt(response, 1, numStrings);
6104
6105 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6106 rilCellIdentity.cellIdentityGsm.cid =
6107 convertResponseHexStringEntryToInt(response, 2, numStrings);
6108
6109 if (numStrings > 15) {
6110 rilCellIdentity.cellIdentityGsm.mcc =
6111 convertResponseStringEntryToInt(response, 15, numStrings);
6112
6113 rilCellIdentity.cellIdentityGsm.mnc =
6114 convertResponseStringEntryToInt(response, 16, numStrings);
6115 }
6116 break;
6117 }
6118
6119 case RIL_CELL_INFO_TYPE_WCDMA: {
6120 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6121 rilCellIdentity.cellIdentityWcdma.lac =
6122 convertResponseHexStringEntryToInt(response, 1, numStrings);
6123
6124 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6125 rilCellIdentity.cellIdentityWcdma.cid =
6126 convertResponseHexStringEntryToInt(response, 2, numStrings);
6127 rilCellIdentity.cellIdentityWcdma.psc =
6128 convertResponseStringEntryToInt(response, 14, numStrings);
6129
6130 if (numStrings > 15) {
6131 rilCellIdentity.cellIdentityWcdma.mcc =
6132 convertResponseStringEntryToInt(response, 15, numStrings);
6133
6134 rilCellIdentity.cellIdentityWcdma.mnc =
6135 convertResponseStringEntryToInt(response, 16, numStrings);
6136 }
6137 break;
6138 }
6139
6140 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
6141 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6142 rilCellIdentity.cellIdentityTdscdma.lac =
6143 convertResponseHexStringEntryToInt(response, 1, numStrings);
6144
6145 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6146 rilCellIdentity.cellIdentityTdscdma.cid =
6147 convertResponseHexStringEntryToInt(response, 2, numStrings);
6148
6149 if (numStrings > 15) {
6150 rilCellIdentity.cellIdentityTdscdma.mcc =
6151 convertResponseStringEntryToInt(response, 15, numStrings);
6152
6153 rilCellIdentity.cellIdentityTdscdma.mnc =
6154 convertResponseStringEntryToInt(response, 16, numStrings);
6155 }
6156 break;
6157 }
6158
6159 case RIL_CELL_INFO_TYPE_CDMA:{
6160 rilCellIdentity.cellIdentityCdma.basestationId =
6161 convertResponseStringEntryToInt(response, 4, numStrings);
6162 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
6163 rilCellIdentity.cellIdentityCdma.latitude =
6164 convertResponseStringEntryToInt(response, 5, numStrings);
6165 rilCellIdentity.cellIdentityCdma.longitude =
6166 convertResponseStringEntryToInt(response, 6, numStrings);
6167 rilCellIdentity.cellIdentityCdma.systemId =
6168 convertResponseStringEntryToInt(response, 8, numStrings);
6169 rilCellIdentity.cellIdentityCdma.networkId =
6170 convertResponseStringEntryToInt(response, 9, numStrings);
6171 break;
6172 }
6173
6174 case RIL_CELL_INFO_TYPE_LTE:{
6175 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
6176 rilCellIdentity.cellIdentityLte.tac =
6177 convertResponseHexStringEntryToInt(response, 1, numStrings);
6178
6179 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6180 rilCellIdentity.cellIdentityLte.ci =
6181 convertResponseHexStringEntryToInt(response, 2, numStrings);
6182
6183 if (numStrings > 15) {
6184 rilCellIdentity.cellIdentityLte.mcc =
6185 convertResponseStringEntryToInt(response, 15, numStrings);
6186
6187 rilCellIdentity.cellIdentityLte.mnc =
6188 convertResponseStringEntryToInt(response, 16, numStrings);
6189 }
6190 rilCellIdentity.cellIdentityLte.bandwidth = INT_MAX;
6191 break;
6192 }
6193
6194 default: {
6195 break;
6196 }
6197 }
6198
6199 fillCellIdentityResponse_1_2(cellIdentity, rilCellIdentity);
6200 }
6201
6202 /* Fill Cell Identity info from Data Registration State Response.
6203 * This function is applicable only for RIL Version < 15.
6204 * Response is a "char **".
6205 * First and Second entries are in hex string format
6206 * and rest are integers represented in ascii format. */
fillCellIdentityFromDataRegStateResponseString_1_5(V1_5::CellIdentity & cellIdentity,int numStrings,char ** response)6207 void fillCellIdentityFromDataRegStateResponseString_1_5(V1_5::CellIdentity &cellIdentity,
6208 int numStrings, char** response) {
6209
6210 RIL_CellIdentity_v16 rilCellIdentity;
6211 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
6212
6213 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6214 switch(rilCellIdentity.cellInfoType) {
6215 case RIL_CELL_INFO_TYPE_GSM: {
6216 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6217 rilCellIdentity.cellIdentityGsm.lac =
6218 convertResponseHexStringEntryToInt(response, 1, numStrings);
6219
6220 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6221 rilCellIdentity.cellIdentityGsm.cid =
6222 convertResponseHexStringEntryToInt(response, 2, numStrings);
6223
6224 if (numStrings >= 13) {
6225 rilCellIdentity.cellIdentityGsm.mcc =
6226 convertResponseStringEntryToInt(response, 11, numStrings);
6227
6228 rilCellIdentity.cellIdentityGsm.mnc =
6229 convertResponseStringEntryToInt(response, 12, numStrings);
6230 } else {
6231 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6232 rilCellIdentity.cellIdentityGsm.mnc = 0;
6233 rilCellIdentity.cellIdentityGsm.mcc = 0;
6234 }
6235 break;
6236 }
6237 case RIL_CELL_INFO_TYPE_WCDMA: {
6238 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6239 rilCellIdentity.cellIdentityWcdma.lac =
6240 convertResponseHexStringEntryToInt(response, 1, numStrings);
6241
6242 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6243 rilCellIdentity.cellIdentityWcdma.cid =
6244 convertResponseHexStringEntryToInt(response, 2, numStrings);
6245
6246 if (numStrings >= 13) {
6247 rilCellIdentity.cellIdentityWcdma.mcc =
6248 convertResponseStringEntryToInt(response, 11, numStrings);
6249
6250 rilCellIdentity.cellIdentityWcdma.mnc =
6251 convertResponseStringEntryToInt(response, 12, numStrings);
6252 } else {
6253 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6254 rilCellIdentity.cellIdentityWcdma.mnc = 0;
6255 rilCellIdentity.cellIdentityWcdma.mcc = 0;
6256 }
6257 break;
6258 }
6259 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
6260 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6261 rilCellIdentity.cellIdentityTdscdma.lac =
6262 convertResponseHexStringEntryToInt(response, 1, numStrings);
6263
6264 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6265 rilCellIdentity.cellIdentityTdscdma.cid =
6266 convertResponseHexStringEntryToInt(response, 2, numStrings);
6267
6268 if (numStrings >= 13) {
6269 rilCellIdentity.cellIdentityTdscdma.mcc =
6270 convertResponseStringEntryToInt(response, 11, numStrings);
6271
6272 rilCellIdentity.cellIdentityTdscdma.mnc =
6273 convertResponseStringEntryToInt(response, 12, numStrings);
6274 } else {
6275 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6276 rilCellIdentity.cellIdentityTdscdma.mnc = 0;
6277 rilCellIdentity.cellIdentityTdscdma.mcc = 0;
6278 }
6279 break;
6280 }
6281 case RIL_CELL_INFO_TYPE_LTE: {
6282 rilCellIdentity.cellIdentityLte.tac =
6283 convertResponseStringEntryToInt(response, 6, numStrings);
6284 rilCellIdentity.cellIdentityLte.pci =
6285 convertResponseStringEntryToInt(response, 7, numStrings);
6286 rilCellIdentity.cellIdentityLte.ci =
6287 convertResponseStringEntryToInt(response, 8, numStrings);
6288
6289 if (numStrings >= 13) {
6290 rilCellIdentity.cellIdentityLte.mcc =
6291 convertResponseStringEntryToInt(response, 11, numStrings);
6292
6293 rilCellIdentity.cellIdentityLte.mnc =
6294 convertResponseStringEntryToInt(response, 12, numStrings);
6295 } else {
6296 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6297 rilCellIdentity.cellIdentityLte.mnc = 0;
6298 rilCellIdentity.cellIdentityLte.mcc = 0;
6299 }
6300 break;
6301 }
6302 default: {
6303 break;
6304 }
6305 }
6306
6307 fillCellIdentityResponse_1_5(cellIdentity, rilCellIdentity);
6308 }
6309
fillCellIdentityFromDataRegStateResponseString_1_2(V1_2::CellIdentity & cellIdentity,int numStrings,char ** response)6310 void fillCellIdentityFromDataRegStateResponseString_1_2(V1_2::CellIdentity &cellIdentity,
6311 int numStrings, char** response) {
6312
6313 RIL_CellIdentity_v1_2 rilCellIdentity;
6314 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v1_2));
6315
6316 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6317 switch(rilCellIdentity.cellInfoType) {
6318 case RIL_CELL_INFO_TYPE_GSM: {
6319 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6320 rilCellIdentity.cellIdentityGsm.lac =
6321 convertResponseHexStringEntryToInt(response, 1, numStrings);
6322
6323 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6324 rilCellIdentity.cellIdentityGsm.cid =
6325 convertResponseHexStringEntryToInt(response, 2, numStrings);
6326
6327 if (numStrings >= 13) {
6328 rilCellIdentity.cellIdentityGsm.mcc =
6329 convertResponseStringEntryToInt(response, 11, numStrings);
6330
6331 rilCellIdentity.cellIdentityGsm.mnc =
6332 convertResponseStringEntryToInt(response, 12, numStrings);
6333 } else {
6334 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6335 rilCellIdentity.cellIdentityGsm.mnc = 0;
6336 rilCellIdentity.cellIdentityGsm.mcc = 0;
6337 }
6338 break;
6339 }
6340 case RIL_CELL_INFO_TYPE_WCDMA: {
6341 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6342 rilCellIdentity.cellIdentityWcdma.lac =
6343 convertResponseHexStringEntryToInt(response, 1, numStrings);
6344
6345 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6346 rilCellIdentity.cellIdentityWcdma.cid =
6347 convertResponseHexStringEntryToInt(response, 2, numStrings);
6348
6349 if (numStrings >= 13) {
6350 rilCellIdentity.cellIdentityWcdma.mcc =
6351 convertResponseStringEntryToInt(response, 11, numStrings);
6352
6353 rilCellIdentity.cellIdentityWcdma.mnc =
6354 convertResponseStringEntryToInt(response, 12, numStrings);
6355 } else {
6356 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6357 rilCellIdentity.cellIdentityWcdma.mnc = 0;
6358 rilCellIdentity.cellIdentityWcdma.mcc = 0;
6359 }
6360 break;
6361 }
6362 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
6363 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6364 rilCellIdentity.cellIdentityTdscdma.lac =
6365 convertResponseHexStringEntryToInt(response, 1, numStrings);
6366
6367 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6368 rilCellIdentity.cellIdentityTdscdma.cid =
6369 convertResponseHexStringEntryToInt(response, 2, numStrings);
6370
6371 if (numStrings >= 13) {
6372 rilCellIdentity.cellIdentityTdscdma.mcc =
6373 convertResponseStringEntryToInt(response, 11, numStrings);
6374
6375 rilCellIdentity.cellIdentityTdscdma.mnc =
6376 convertResponseStringEntryToInt(response, 12, numStrings);
6377 } else {
6378 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6379 rilCellIdentity.cellIdentityTdscdma.mnc = 0;
6380 rilCellIdentity.cellIdentityTdscdma.mcc = 0;
6381 }
6382 break;
6383 }
6384 case RIL_CELL_INFO_TYPE_LTE: {
6385 rilCellIdentity.cellIdentityLte.tac =
6386 convertResponseStringEntryToInt(response, 6, numStrings);
6387 rilCellIdentity.cellIdentityLte.pci =
6388 convertResponseStringEntryToInt(response, 7, numStrings);
6389 rilCellIdentity.cellIdentityLte.ci =
6390 convertResponseStringEntryToInt(response, 8, numStrings);
6391
6392 if (numStrings >= 13) {
6393 rilCellIdentity.cellIdentityLte.mcc =
6394 convertResponseStringEntryToInt(response, 11, numStrings);
6395
6396 rilCellIdentity.cellIdentityLte.mnc =
6397 convertResponseStringEntryToInt(response, 12, numStrings);
6398 } else {
6399 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6400 rilCellIdentity.cellIdentityLte.mnc = 0;
6401 rilCellIdentity.cellIdentityLte.mcc = 0;
6402 }
6403 break;
6404 }
6405 case RIL_CELL_INFO_TYPE_CDMA: {
6406 break;
6407 }
6408 default: {
6409 break;
6410 }
6411 }
6412
6413 fillCellIdentityResponse_1_2(cellIdentity, rilCellIdentity);
6414 }
6415
fillCellIdentityFromDataRegStateResponseString(CellIdentity & cellIdentity,int numStrings,char ** response)6416 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
6417 int numStrings, char** response) {
6418
6419 RIL_CellIdentity_v16 rilCellIdentity;
6420 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
6421
6422 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6423 switch(rilCellIdentity.cellInfoType) {
6424 case RIL_CELL_INFO_TYPE_GSM: {
6425 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6426 rilCellIdentity.cellIdentityGsm.lac =
6427 convertResponseHexStringEntryToInt(response, 1, numStrings);
6428
6429 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6430 rilCellIdentity.cellIdentityGsm.cid =
6431 convertResponseHexStringEntryToInt(response, 2, numStrings);
6432
6433 if (numStrings >= 13) {
6434 rilCellIdentity.cellIdentityGsm.mcc =
6435 convertResponseStringEntryToInt(response, 11, numStrings);
6436
6437 rilCellIdentity.cellIdentityGsm.mnc =
6438 convertResponseStringEntryToInt(response, 12, numStrings);
6439 } else {
6440 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6441 rilCellIdentity.cellIdentityGsm.mnc = 0;
6442 rilCellIdentity.cellIdentityGsm.mcc = 0;
6443 }
6444 break;
6445 }
6446 case RIL_CELL_INFO_TYPE_WCDMA: {
6447 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6448 rilCellIdentity.cellIdentityWcdma.lac =
6449 convertResponseHexStringEntryToInt(response, 1, numStrings);
6450
6451 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6452 rilCellIdentity.cellIdentityWcdma.cid =
6453 convertResponseHexStringEntryToInt(response, 2, numStrings);
6454
6455 if (numStrings >= 13) {
6456 rilCellIdentity.cellIdentityWcdma.mcc =
6457 convertResponseStringEntryToInt(response, 11, numStrings);
6458
6459 rilCellIdentity.cellIdentityWcdma.mnc =
6460 convertResponseStringEntryToInt(response, 12, numStrings);
6461 } else {
6462 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6463 rilCellIdentity.cellIdentityWcdma.mnc = 0;
6464 rilCellIdentity.cellIdentityWcdma.mcc = 0;
6465 }
6466
6467 break;
6468 }
6469 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
6470 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6471 rilCellIdentity.cellIdentityTdscdma.lac =
6472 convertResponseHexStringEntryToInt(response, 1, numStrings);
6473
6474 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6475 rilCellIdentity.cellIdentityTdscdma.cid =
6476 convertResponseHexStringEntryToInt(response, 2, numStrings);
6477
6478 if (numStrings >= 13) {
6479 rilCellIdentity.cellIdentityTdscdma.mcc =
6480 convertResponseStringEntryToInt(response, 11, numStrings);
6481
6482 rilCellIdentity.cellIdentityTdscdma.mnc =
6483 convertResponseStringEntryToInt(response, 12, numStrings);
6484 } else {
6485 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6486 rilCellIdentity.cellIdentityTdscdma.mnc = 0;
6487 rilCellIdentity.cellIdentityTdscdma.mcc = 0;
6488 }
6489 break;
6490 }
6491 case RIL_CELL_INFO_TYPE_LTE: {
6492 rilCellIdentity.cellIdentityLte.tac =
6493 convertResponseHexStringEntryToInt(response, 1, numStrings);
6494 rilCellIdentity.cellIdentityLte.ci =
6495 convertResponseHexStringEntryToInt(response, 2, numStrings);
6496
6497 if (numStrings >= 13) {
6498 rilCellIdentity.cellIdentityLte.mcc =
6499 convertResponseStringEntryToInt(response, 11, numStrings);
6500
6501 rilCellIdentity.cellIdentityLte.mnc =
6502 convertResponseStringEntryToInt(response, 12, numStrings);
6503 } else {
6504 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6505 rilCellIdentity.cellIdentityLte.mnc = 0;
6506 rilCellIdentity.cellIdentityLte.mcc = 0;
6507 }
6508 break;
6509 }
6510 // TODO add CDMA
6511 default: {
6512 break;
6513 }
6514 }
6515
6516 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
6517 }
6518
getVoiceRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6519 int radio_1_6::getVoiceRegistrationStateResponse(int slotId,
6520 int responseType, int serial, RIL_Errno e,
6521 void *response, size_t responseLen) {
6522 #if VDBG
6523 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
6524 #endif
6525
6526 if (radioService[slotId]->mRadioResponse != NULL ||
6527 radioService[slotId]->mRadioResponseV1_2 != NULL ||
6528 radioService[slotId]->mRadioResponseV1_5 != NULL ||
6529 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6530 RadioResponseInfo responseInfo = {};
6531 populateResponseInfo(responseInfo, serial, responseType, e);
6532
6533 VoiceRegStateResult voiceRegResponse = {};
6534 int numStrings = responseLen / sizeof(char *);
6535 if (response == NULL) {
6536 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
6537 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6538 } else if (s_vendorFunctions->version >= 15 &&
6539 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6540 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6541 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
6542 RegStateResultV1_6 regResponse = {};
6543 if (numStrings != 18) {
6544 RLOGE("getVoiceRegistrationStateResponse_1_6 Invalid response: NULL");
6545 if (e == RIL_E_SUCCESS) responseInfo_1_6.error =
6546 ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
6547 } else {
6548 char **resp = (char **) response;
6549 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6550 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6551 regResponse.rat = (V1_4::RadioTechnology)rat;
6552 if (rat == RADIO_TECH_EVDO_0 || rat == RADIO_TECH_EVDO_A ||
6553 rat == RADIO_TECH_EVDO_B || rat == RADIO_TECH_1xRTT ||
6554 rat == RADIO_TECH_IS95A || rat == RADIO_TECH_IS95B ||
6555 rat == RADIO_TECH_EHRPD) {
6556 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6557 Cdma2000RegistrationInfo cdmaInfo;
6558 cdmaInfo.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
6559 cdmaInfo.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
6560 cdmaInfo.systemIsInPrl = (V1_5::PrlIndicator)ATOI_NULL_HANDLED_DEF(resp[11], 0);
6561 cdmaInfo.defaultRoamingIndicator= ATOI_NULL_HANDLED_DEF(resp[12], 0);
6562 regResponse.accessTechnologySpecificInfo.cdmaInfo(cdmaInfo);
6563 } else if (rat == RADIO_TECH_NR) {
6564 // rat is NR only for NR SA
6565 V1_6::NrVopsInfo nrVopsInfo;
6566 nrVopsInfo.vopsSupported =
6567 ::android::hardware::radio::V1_6::VopsIndicator::VOPS_NOT_SUPPORTED;
6568 nrVopsInfo.emcSupported =
6569 ::android::hardware::radio::V1_6::EmcIndicator::EMC_NOT_SUPPORTED;
6570 nrVopsInfo.emfSupported =
6571 ::android::hardware::radio::V1_6::EmfIndicator::EMF_NOT_SUPPORTED;
6572 regResponse.accessTechnologySpecificInfo.ngranNrVopsInfo(nrVopsInfo);
6573
6574 } else {
6575 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6576 EutranRegistrationInfo eutranInfo;
6577 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA) {
6578 eutranInfo.lteVopsInfo.isVopsSupported = false;
6579 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6580 }
6581 eutranInfo.nrIndicators.isEndcAvailable = false;
6582 eutranInfo.nrIndicators.isDcNrRestricted = false;
6583 eutranInfo.nrIndicators.isEndcAvailable = false;
6584 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6585 }
6586 regResponse.reasonForDenial = (V1_5::RegistrationFailCause)
6587 ATOI_NULL_HANDLED_DEF(resp[13], 0);
6588 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[17]);
6589
6590 fillCellIdentityFromVoiceRegStateResponseString(regResponse.cellIdentity,
6591 numStrings, resp);
6592
6593 Return<void> retStatus =
6594 radioService[slotId]
6595 ->mRadioResponseV1_6
6596 ->getVoiceRegistrationStateResponse_1_6(
6597 responseInfo_1_6, regResponse);
6598 radioService[slotId]->checkReturnStatus(retStatus);
6599 }
6600 } else if (s_vendorFunctions->version <= 14 &&
6601 radioService[slotId]->mRadioResponseV1_5 != NULL) {
6602 RegStateResultV1_5 regResponse = {};
6603 if (numStrings != 18) {
6604 RLOGE("getVoiceRegistrationStateResponse_1_5 Invalid response: NULL");
6605 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6606 } else {
6607 char **resp = (char **) response;
6608 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6609 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6610 regResponse.rat = (V1_4::RadioTechnology)rat;
6611 if (rat == RADIO_TECH_EVDO_0 || rat == RADIO_TECH_EVDO_A ||
6612 rat == RADIO_TECH_EVDO_B || rat == RADIO_TECH_1xRTT ||
6613 rat == RADIO_TECH_IS95A || rat == RADIO_TECH_IS95B ||
6614 rat == RADIO_TECH_EHRPD) {
6615 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6616 Cdma2000RegistrationInfo cdmaInfo;
6617 cdmaInfo.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
6618 cdmaInfo.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
6619 cdmaInfo.systemIsInPrl = (V1_5::PrlIndicator)ATOI_NULL_HANDLED_DEF(resp[11], 0);
6620 cdmaInfo.defaultRoamingIndicator= ATOI_NULL_HANDLED_DEF(resp[12], 0);
6621 regResponse.accessTechnologySpecificInfo.cdmaInfo(cdmaInfo);
6622 } else {
6623 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6624 EutranRegistrationInfo eutranInfo;
6625 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA ||
6626 rat == RADIO_TECH_NR) {
6627 eutranInfo.lteVopsInfo.isVopsSupported = false;
6628 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6629 }
6630 eutranInfo.nrIndicators.isEndcAvailable = false;
6631 eutranInfo.nrIndicators.isDcNrRestricted = false;
6632 eutranInfo.nrIndicators.isEndcAvailable = false;
6633 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6634 }
6635 regResponse.reasonForDenial = (V1_5::RegistrationFailCause)
6636 ATOI_NULL_HANDLED_DEF(resp[13], 0);
6637 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[17]);
6638
6639 fillCellIdentityFromVoiceRegStateResponseString(regResponse.cellIdentity,
6640 numStrings, resp);
6641
6642 Return<void> retStatus =
6643 radioService[slotId]
6644 ->mRadioResponseV1_5
6645 ->getVoiceRegistrationStateResponse_1_5(
6646 responseInfo, regResponse);
6647 radioService[slotId]->checkReturnStatus(retStatus);
6648 }
6649 } else if (s_vendorFunctions->version <= 14 &&
6650 radioService[slotId]->mRadioResponseV1_2 != NULL) {
6651 V1_2::VoiceRegStateResult voiceRegResponse = {};
6652 int numStrings = responseLen / sizeof(char *);
6653 if (numStrings != 18) {
6654 RLOGE("getVoiceRegistrationStateResponse_1_21 Invalid response: NULL");
6655 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6656 } else {
6657 char **resp = (char **) response;
6658 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
6659 voiceRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6660 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
6661 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
6662 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
6663 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
6664 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
6665 fillCellIdentityFromVoiceRegStateResponseString_1_2(
6666 voiceRegResponse.cellIdentity, numStrings, resp);
6667 }
6668 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2->
6669 getVoiceRegistrationStateResponse_1_2(responseInfo, voiceRegResponse);
6670 radioService[slotId]->checkReturnStatus(retStatus);
6671 } else {
6672 RIL_VoiceRegistrationStateResponse *voiceRegState =
6673 (RIL_VoiceRegistrationStateResponse *)response;
6674 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
6675 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
6676 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6677 } else {
6678 voiceRegResponse.regState = (RegState) voiceRegState->regState;
6679 voiceRegResponse.rat = voiceRegState->rat;;
6680 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
6681 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
6682 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
6683 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
6684 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
6685 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
6686 voiceRegState->cellIdentity);
6687 }
6688 Return<void> retStatus =
6689 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
6690 responseInfo, voiceRegResponse);
6691 radioService[slotId]->checkReturnStatus(retStatus);
6692 }
6693
6694 } else {
6695 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
6696 slotId);
6697 }
6698 return 0;
6699 }
6700
getDataRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6701 int radio_1_6::getDataRegistrationStateResponse(int slotId, int responseType, int serial,
6702 RIL_Errno e, void* response, size_t responseLen) {
6703 #if VDBG
6704 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
6705 #endif
6706 if (radioService[slotId]->mRadioResponse != NULL ||
6707 radioService[slotId]->mRadioResponseV1_2 != NULL ||
6708 radioService[slotId]->mRadioResponseV1_5 != NULL ||
6709 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6710 RadioResponseInfo responseInfo = {};
6711 DataRegStateResult dataRegResponse = {};
6712 populateResponseInfo(responseInfo, serial, responseType, e);
6713 if (response == NULL) {
6714 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6715 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6716 } else if (s_vendorFunctions->version >= 15 &&
6717 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6718 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6719 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
6720 RegStateResultV1_6 regResponse = {};
6721 int numStrings = responseLen / sizeof(char *);
6722 if ((numStrings != 6) && (numStrings != 11) && (numStrings != 14)) {
6723 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6724 if (e == RIL_E_SUCCESS) responseInfo_1_6.error =
6725 ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
6726 } else {
6727 char **resp = (char **) response;
6728 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6729 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6730 regResponse.rat = (V1_4::RadioTechnology)rat;
6731 regResponse.reasonForDenial =
6732 (V1_5::RegistrationFailCause)ATOI_NULL_HANDLED(resp[4]);
6733 if (numStrings > 13) {
6734 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[13]);
6735 }
6736
6737 fillCellIdentityFromDataRegStateResponseString_1_5(regResponse.cellIdentity,
6738 numStrings, resp);
6739 if (rat == RADIO_TECH_NR) {
6740 // rat is NR only for NR SA
6741 V1_6::NrVopsInfo nrVopsInfo;
6742 nrVopsInfo.vopsSupported =
6743 ::android::hardware::radio::V1_6::VopsIndicator::VOPS_NOT_SUPPORTED;
6744 nrVopsInfo.emcSupported =
6745 ::android::hardware::radio::V1_6::EmcIndicator::EMC_NOT_SUPPORTED;
6746 nrVopsInfo.emfSupported =
6747 ::android::hardware::radio::V1_6::EmfIndicator::EMF_NOT_SUPPORTED;
6748 regResponse.accessTechnologySpecificInfo.ngranNrVopsInfo(nrVopsInfo);
6749
6750 } else {
6751 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6752 EutranRegistrationInfo eutranInfo;
6753 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA) {
6754 eutranInfo.lteVopsInfo.isVopsSupported = false;
6755 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6756 }
6757 eutranInfo.nrIndicators.isEndcAvailable = false;
6758 eutranInfo.nrIndicators.isDcNrRestricted = false;
6759 eutranInfo.nrIndicators.isEndcAvailable = false;
6760 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6761 }
6762
6763 Return<void> retStatus =
6764 radioService[slotId]
6765 ->mRadioResponseV1_6->getDataRegistrationStateResponse_1_6(
6766 responseInfo_1_6, regResponse);
6767 radioService[slotId]->checkReturnStatus(retStatus);
6768 return 0;
6769 }
6770 } else if (s_vendorFunctions->version <= 14 &&
6771 radioService[slotId]->mRadioResponseV1_5 != NULL) {
6772 RegStateResultV1_5 regResponse = {};
6773 int numStrings = responseLen / sizeof(char *);
6774 if ((numStrings != 6) && (numStrings != 11) && (numStrings != 14)) {
6775 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6776 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6777 } else {
6778 char **resp = (char **) response;
6779 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6780 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6781 regResponse.rat = (V1_4::RadioTechnology)rat;
6782 regResponse.reasonForDenial =
6783 (V1_5::RegistrationFailCause)ATOI_NULL_HANDLED(resp[4]);
6784 if (numStrings > 13) {
6785 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[13]);
6786 }
6787
6788 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6789 EutranRegistrationInfo eutranInfo;
6790 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA ||
6791 rat == RADIO_TECH_NR) {
6792 eutranInfo.lteVopsInfo.isVopsSupported = false;
6793 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6794 }
6795 eutranInfo.nrIndicators.isEndcAvailable = false;
6796 eutranInfo.nrIndicators.isDcNrRestricted = false;
6797 eutranInfo.nrIndicators.isEndcAvailable = false;
6798 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6799
6800 fillCellIdentityFromDataRegStateResponseString_1_5(regResponse.cellIdentity,
6801 numStrings, resp);
6802
6803 Return<void> retStatus =
6804 radioService[slotId]
6805 ->mRadioResponseV1_5->getDataRegistrationStateResponse_1_5(
6806 responseInfo, regResponse);
6807 radioService[slotId]->checkReturnStatus(retStatus);
6808 return 0;
6809 }
6810 } else if (s_vendorFunctions->version <= 14 &&
6811 radioService[slotId]->mRadioResponseV1_2 != NULL) {
6812 V1_2::DataRegStateResult dataRegResponse = {};
6813 int numStrings = responseLen / sizeof(char *);
6814 if ((numStrings != 11) && (numStrings != 13) && (numStrings != 14)) {
6815 RLOGE("getDataRegistrationStateResponse_1_2 Invalid response: NULL");
6816 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6817 } else {
6818 char **resp = (char **)response;
6819 dataRegResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6820 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6821 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
6822 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
6823 fillCellIdentityFromDataRegStateResponseString_1_2(dataRegResponse.cellIdentity,
6824 numStrings, resp);
6825 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2->
6826 getDataRegistrationStateResponse_1_2(responseInfo, dataRegResponse);
6827 radioService[slotId]->checkReturnStatus(retStatus);
6828 return 0;
6829 }
6830 } else if (s_vendorFunctions->version <= 14) {
6831 int numStrings = responseLen / sizeof(char *);
6832 if ((numStrings != 11) && (numStrings != 13) && (numStrings != 14)) {
6833 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6834 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6835 } else {
6836 char **resp = (char **) response;
6837 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
6838 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6839 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
6840 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
6841 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
6842 numStrings, resp);
6843 }
6844 } else {
6845 RIL_DataRegistrationStateResponse *dataRegState =
6846 (RIL_DataRegistrationStateResponse *)response;
6847
6848 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
6849 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6850 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6851 } else {
6852 dataRegResponse.regState = (RegState) dataRegState->regState;
6853 dataRegResponse.rat = dataRegState->rat;
6854 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
6855 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
6856 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
6857 }
6858 }
6859
6860 Return<void> retStatus =
6861 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(
6862 responseInfo, dataRegResponse);
6863 radioService[slotId]->checkReturnStatus(retStatus);
6864 } else {
6865 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
6866 slotId);
6867 }
6868
6869 return 0;
6870 }
6871
getOperatorResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6872 int radio_1_6::getOperatorResponse(int slotId,
6873 int responseType, int serial, RIL_Errno e, void *response,
6874 size_t responseLen) {
6875 #if VDBG
6876 RLOGD("getOperatorResponse: serial %d", serial);
6877 #endif
6878
6879 if (radioService[slotId]->mRadioResponse != NULL) {
6880 RadioResponseInfo responseInfo = {};
6881 populateResponseInfo(responseInfo, serial, responseType, e);
6882 hidl_string longName;
6883 hidl_string shortName;
6884 hidl_string numeric;
6885 int numStrings = responseLen / sizeof(char *);
6886 if (response == NULL || numStrings != 3) {
6887 RLOGE("getOperatorResponse Invalid response: NULL");
6888 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6889
6890 } else {
6891 char **resp = (char **) response;
6892 longName = convertCharPtrToHidlString(resp[0]);
6893 shortName = convertCharPtrToHidlString(resp[1]);
6894 numeric = convertCharPtrToHidlString(resp[2]);
6895 }
6896 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
6897 responseInfo, longName, shortName, numeric);
6898 radioService[slotId]->checkReturnStatus(retStatus);
6899 } else {
6900 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
6901 slotId);
6902 }
6903
6904 return 0;
6905 }
6906
setRadioPowerResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6907 int radio_1_6::setRadioPowerResponse(int slotId,
6908 int responseType, int serial, RIL_Errno e, void *response,
6909 size_t responseLen) {
6910 #if VDBG
6911 RLOGD("setRadioPowerResponse: serial %d", serial);
6912 #endif
6913 RadioResponseInfo responseInfo = {};
6914 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6915 populateResponseInfo(responseInfo, serial, responseType, e);
6916 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
6917
6918 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
6919 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
6920 ->setRadioPowerResponse_1_6(responseInfo_1_6);
6921 radioService[slotId]->checkReturnStatus(retStatus);
6922 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
6923 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
6924 ->setRadioPowerResponse_1_5(responseInfo);
6925 radioService[slotId]->checkReturnStatus(retStatus);
6926 } else if (radioService[slotId]->mRadioResponse != NULL) {
6927 Return<void> retStatus = radioService[slotId]->mRadioResponse
6928 ->setRadioPowerResponse(responseInfo);
6929 radioService[slotId]->checkReturnStatus(retStatus);
6930 } else {
6931 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6932 }
6933
6934 return 0;
6935 }
6936
sendDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6937 int radio_1_6::sendDtmfResponse(int slotId,
6938 int responseType, int serial, RIL_Errno e, void *response,
6939 size_t responseLen) {
6940 #if VDBG
6941 RLOGD("sendDtmfResponse: serial %d", serial);
6942 #endif
6943
6944 if (radioService[slotId]->mRadioResponse != NULL) {
6945 RadioResponseInfo responseInfo = {};
6946 populateResponseInfo(responseInfo, serial, responseType, e);
6947 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
6948 responseInfo);
6949 radioService[slotId]->checkReturnStatus(retStatus);
6950 } else {
6951 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
6952 slotId);
6953 }
6954
6955 return 0;
6956 }
6957
makeSendSmsResult(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)6958 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
6959 RIL_Errno e, void *response, size_t responseLen) {
6960 populateResponseInfo(responseInfo, serial, responseType, e);
6961 SendSmsResult result = {};
6962
6963 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
6964 RLOGE("Invalid response: NULL");
6965 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6966 result.ackPDU = hidl_string();
6967 } else {
6968 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
6969 result.messageRef = resp->messageRef;
6970 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
6971 result.errorCode = resp->errorCode;
6972 }
6973 return result;
6974 }
6975
makeSendSmsResult_1_6(::android::hardware::radio::V1_6::RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)6976 SendSmsResult makeSendSmsResult_1_6(
6977 ::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo, int serial,
6978 int responseType, RIL_Errno e, void *response, size_t responseLen) {
6979 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
6980 SendSmsResult result = {};
6981
6982 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
6983 RLOGE("Invalid response: NULL");
6984 if (e == RIL_E_SUCCESS) {
6985 responseInfo.error = ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
6986 }
6987 result.ackPDU = hidl_string();
6988 } else {
6989 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
6990 result.messageRef = resp->messageRef;
6991 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
6992 result.errorCode = resp->errorCode;
6993 }
6994 return result;
6995 }
6996
sendSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6997 int radio_1_6::sendSmsResponse(int slotId,
6998 int responseType, int serial, RIL_Errno e, void *response,
6999 size_t responseLen) {
7000 #if VDBG
7001 RLOGD("sendSmsResponse: serial %d", serial);
7002 #endif
7003
7004 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
7005 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
7006 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e, response,
7007 responseLen);
7008
7009 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
7010 ->sendSmsResponse_1_6(responseInfo_1_6, result);
7011 radioService[slotId]->checkReturnStatus(retStatus);
7012 } else if (radioService[slotId]->mRadioResponse != NULL) {
7013 RadioResponseInfo responseInfo = {};
7014 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
7015 responseLen);
7016
7017 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
7018 result);
7019 radioService[slotId]->checkReturnStatus(retStatus);
7020 } else {
7021 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7022 }
7023
7024 return 0;
7025 }
7026
sendSmsExpectMoreResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7027 int radio_1_6::sendSmsExpectMoreResponse(int slotId,
7028 int responseType, int serial, RIL_Errno e, void *response,
7029 size_t responseLen) {
7030 #if VDBG
7031 RLOGD("sendSmsExpectMoreResponse: serial %d", serial);
7032 #endif
7033
7034 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
7035 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
7036 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e, response,
7037 responseLen);
7038
7039 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
7040 ->sendSmsExpectMoreResponse_1_6(responseInfo_1_6, result);
7041 radioService[slotId]->checkReturnStatus(retStatus);
7042 } else if (radioService[slotId]->mRadioResponse != NULL) {
7043 RadioResponseInfo responseInfo = {};
7044 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
7045 responseLen);
7046
7047 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
7048 responseInfo, result);
7049 radioService[slotId]->checkReturnStatus(retStatus);
7050 } else {
7051 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7052 }
7053
7054 return 0;
7055 }
7056
setupDataCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7057 int radio_1_6::setupDataCallResponse(int slotId,
7058 int responseType, int serial, RIL_Errno e, void *response,
7059 size_t responseLen) {
7060 #if VDBG
7061 RLOGD("setupDataCallResponse: serial %d", serial);
7062 #endif
7063 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
7064 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
7065 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
7066 ::android::hardware::radio::V1_6::SetupDataCallResult result;
7067 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
7068 if (response != NULL) {
7069 RLOGE("setupDataCallResponse_1_6: Invalid response");
7070 if (e == RIL_E_SUCCESS) responseInfo_1_6.error =
7071 ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
7072 }
7073 result.cause = ::android::hardware::radio::V1_6::DataCallFailCause::ERROR_UNSPECIFIED;
7074 result.type = ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
7075 result.ifname = hidl_string();
7076 result.addresses = hidl_vec<::android::hardware::radio::V1_5::LinkAddress>();
7077 result.dnses = hidl_vec<hidl_string>();
7078 result.gateways = hidl_vec<hidl_string>();
7079 result.pcscf = hidl_vec<hidl_string>();
7080 result.trafficDescriptors =
7081 hidl_vec<::android::hardware::radio::V1_6::TrafficDescriptor>();
7082 } else {
7083 convertRilDataCallToHal((RIL_Data_Call_Response_v11*)response, result);
7084 }
7085
7086 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6->setupDataCallResponse_1_6(
7087 responseInfo_1_6, result);
7088 radioService[slotId]->checkReturnStatus(retStatus);
7089 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7090 RadioResponseInfo responseInfo = {};
7091 populateResponseInfo(responseInfo, serial, responseType, e);
7092 ::android::hardware::radio::V1_5::SetupDataCallResult result;
7093 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
7094 if (response != NULL) {
7095 RLOGE("setupDataCallResponse_1_5: Invalid response");
7096 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7097 }
7098 result.cause = ::android::hardware::radio::V1_4::DataCallFailCause::ERROR_UNSPECIFIED;
7099 result.type = ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
7100 result.ifname = hidl_string();
7101 result.addresses = hidl_vec<::android::hardware::radio::V1_5::LinkAddress>();
7102 result.dnses = hidl_vec<hidl_string>();
7103 result.gateways = hidl_vec<hidl_string>();
7104 result.pcscf = hidl_vec<hidl_string>();
7105 } else {
7106 convertRilDataCallToHal((RIL_Data_Call_Response_v11*)response, result);
7107 }
7108
7109 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5->setupDataCallResponse_1_5(
7110 responseInfo, result);
7111 radioService[slotId]->checkReturnStatus(retStatus);
7112 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7113 RadioResponseInfo responseInfo = {};
7114 populateResponseInfo(responseInfo, serial, responseType, e);
7115 ::android::hardware::radio::V1_4::SetupDataCallResult result;
7116 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
7117 if (response != NULL) {
7118 RLOGE("setupDataCallResponse_1_4: Invalid response");
7119 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7120 }
7121 result.cause = ::android::hardware::radio::V1_4::DataCallFailCause::ERROR_UNSPECIFIED;
7122 result.type = ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
7123 result.ifname = hidl_string();
7124 result.addresses = hidl_vec<hidl_string>();
7125 result.dnses = hidl_vec<hidl_string>();
7126 result.gateways = hidl_vec<hidl_string>();
7127 result.pcscf = hidl_vec<hidl_string>();
7128 } else {
7129 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
7130 }
7131
7132 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4->setupDataCallResponse_1_4(
7133 responseInfo, result);
7134 radioService[slotId]->checkReturnStatus(retStatus);
7135 } else if (radioService[slotId]->mRadioResponse != NULL) {
7136 RadioResponseInfo responseInfo = {};
7137 populateResponseInfo(responseInfo, serial, responseType, e);
7138
7139 SetupDataCallResult result = {};
7140 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
7141 if (response != NULL) {
7142 RLOGE("setupDataCallResponse: Invalid response");
7143 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7144 }
7145 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
7146 result.type = hidl_string();
7147 result.ifname = hidl_string();
7148 result.addresses = hidl_string();
7149 result.dnses = hidl_string();
7150 result.gateways = hidl_string();
7151 result.pcscf = hidl_string();
7152 } else {
7153 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
7154 }
7155
7156 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
7157 responseInfo, result);
7158 radioService[slotId]->checkReturnStatus(retStatus);
7159 } else {
7160 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7161 }
7162
7163 return 0;
7164 }
7165
responseIccIo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)7166 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
7167 RIL_Errno e, void *response, size_t responseLen) {
7168 populateResponseInfo(responseInfo, serial, responseType, e);
7169 IccIoResult result = {};
7170
7171 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
7172 RLOGE("Invalid response: NULL");
7173 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7174 result.simResponse = hidl_string();
7175 } else {
7176 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
7177 result.sw1 = resp->sw1;
7178 result.sw2 = resp->sw2;
7179 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
7180 }
7181 return result;
7182 }
7183
iccIOForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7184 int radio_1_6::iccIOForAppResponse(int slotId,
7185 int responseType, int serial, RIL_Errno e, void *response,
7186 size_t responseLen) {
7187 #if VDBG
7188 RLOGD("iccIOForAppResponse: serial %d", serial);
7189 #endif
7190
7191 if (radioService[slotId]->mRadioResponse != NULL) {
7192 RadioResponseInfo responseInfo = {};
7193 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
7194 responseLen);
7195
7196 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
7197 responseInfo, result);
7198 radioService[slotId]->checkReturnStatus(retStatus);
7199 } else {
7200 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7201 }
7202
7203 return 0;
7204 }
7205
sendUssdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7206 int radio_1_6::sendUssdResponse(int slotId,
7207 int responseType, int serial, RIL_Errno e, void *response,
7208 size_t responseLen) {
7209 #if VDBG
7210 RLOGD("sendUssdResponse: serial %d", serial);
7211 #endif
7212
7213 if (radioService[slotId]->mRadioResponse != NULL) {
7214 RadioResponseInfo responseInfo = {};
7215 populateResponseInfo(responseInfo, serial, responseType, e);
7216 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
7217 responseInfo);
7218 radioService[slotId]->checkReturnStatus(retStatus);
7219 } else {
7220 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
7221 slotId);
7222 }
7223
7224 return 0;
7225 }
7226
cancelPendingUssdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7227 int radio_1_6::cancelPendingUssdResponse(int slotId,
7228 int responseType, int serial, RIL_Errno e, void *response,
7229 size_t responseLen) {
7230 #if VDBG
7231 RLOGD("cancelPendingUssdResponse: serial %d", serial);
7232 #endif
7233
7234 if (radioService[slotId]->mRadioResponse != NULL) {
7235 RadioResponseInfo responseInfo = {};
7236 populateResponseInfo(responseInfo, serial, responseType, e);
7237 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
7238 responseInfo);
7239 radioService[slotId]->checkReturnStatus(retStatus);
7240 } else {
7241 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
7242 slotId);
7243 }
7244
7245 return 0;
7246 }
7247
getClirResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7248 int radio_1_6::getClirResponse(int slotId,
7249 int responseType, int serial, RIL_Errno e, void *response,
7250 size_t responseLen) {
7251 #if VDBG
7252 RLOGD("getClirResponse: serial %d", serial);
7253 #endif
7254
7255 if (radioService[slotId]->mRadioResponse != NULL) {
7256 RadioResponseInfo responseInfo = {};
7257 populateResponseInfo(responseInfo, serial, responseType, e);
7258 int n = -1, m = -1;
7259 int numInts = responseLen / sizeof(int);
7260 if (response == NULL || numInts != 2) {
7261 RLOGE("getClirResponse Invalid response: NULL");
7262 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7263 } else {
7264 int *pInt = (int *) response;
7265 n = pInt[0];
7266 m = pInt[1];
7267 }
7268 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
7269 n, m);
7270 radioService[slotId]->checkReturnStatus(retStatus);
7271 } else {
7272 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7273 }
7274
7275 return 0;
7276 }
7277
setClirResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7278 int radio_1_6::setClirResponse(int slotId,
7279 int responseType, int serial, RIL_Errno e, void *response,
7280 size_t responseLen) {
7281 #if VDBG
7282 RLOGD("setClirResponse: serial %d", serial);
7283 #endif
7284
7285 if (radioService[slotId]->mRadioResponse != NULL) {
7286 RadioResponseInfo responseInfo = {};
7287 populateResponseInfo(responseInfo, serial, responseType, e);
7288 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
7289 responseInfo);
7290 radioService[slotId]->checkReturnStatus(retStatus);
7291 } else {
7292 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7293 }
7294
7295 return 0;
7296 }
7297
getCallForwardStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7298 int radio_1_6::getCallForwardStatusResponse(int slotId,
7299 int responseType, int serial, RIL_Errno e,
7300 void *response, size_t responseLen) {
7301 #if VDBG
7302 RLOGD("getCallForwardStatusResponse: serial %d", serial);
7303 #endif
7304
7305 if (radioService[slotId]->mRadioResponse != NULL) {
7306 RadioResponseInfo responseInfo = {};
7307 populateResponseInfo(responseInfo, serial, responseType, e);
7308 hidl_vec<CallForwardInfo> callForwardInfos;
7309
7310 if ((response == NULL && responseLen != 0)
7311 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
7312 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
7313 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7314 } else {
7315 int num = responseLen / sizeof(RIL_CallForwardInfo *);
7316 callForwardInfos.resize(num);
7317 for (int i = 0 ; i < num; i++) {
7318 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
7319 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
7320 callForwardInfos[i].reason = resp->reason;
7321 callForwardInfos[i].serviceClass = resp->serviceClass;
7322 callForwardInfos[i].toa = resp->toa;
7323 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
7324 callForwardInfos[i].timeSeconds = resp->timeSeconds;
7325 }
7326 }
7327
7328 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
7329 responseInfo, callForwardInfos);
7330 radioService[slotId]->checkReturnStatus(retStatus);
7331 } else {
7332 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
7333 slotId);
7334 }
7335
7336 return 0;
7337 }
7338
setCallForwardResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7339 int radio_1_6::setCallForwardResponse(int slotId,
7340 int responseType, int serial, RIL_Errno e, void *response,
7341 size_t responseLen) {
7342 #if VDBG
7343 RLOGD("setCallForwardResponse: serial %d", serial);
7344 #endif
7345
7346 if (radioService[slotId]->mRadioResponse != NULL) {
7347 RadioResponseInfo responseInfo = {};
7348 populateResponseInfo(responseInfo, serial, responseType, e);
7349 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
7350 responseInfo);
7351 radioService[slotId]->checkReturnStatus(retStatus);
7352 } else {
7353 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7354 }
7355
7356 return 0;
7357 }
7358
getCallWaitingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7359 int radio_1_6::getCallWaitingResponse(int slotId,
7360 int responseType, int serial, RIL_Errno e, void *response,
7361 size_t responseLen) {
7362 #if VDBG
7363 RLOGD("getCallWaitingResponse: serial %d", serial);
7364 #endif
7365
7366 if (radioService[slotId]->mRadioResponse != NULL) {
7367 RadioResponseInfo responseInfo = {};
7368 populateResponseInfo(responseInfo, serial, responseType, e);
7369 bool enable = false;
7370 int serviceClass = -1;
7371 int numInts = responseLen / sizeof(int);
7372 if (response == NULL || numInts != 2) {
7373 RLOGE("getCallWaitingResponse Invalid response: NULL");
7374 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7375 } else {
7376 int *pInt = (int *) response;
7377 enable = pInt[0] == 1 ? true : false;
7378 serviceClass = pInt[1];
7379 }
7380 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
7381 responseInfo, enable, serviceClass);
7382 radioService[slotId]->checkReturnStatus(retStatus);
7383 } else {
7384 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7385 }
7386
7387 return 0;
7388 }
7389
setCallWaitingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7390 int radio_1_6::setCallWaitingResponse(int slotId,
7391 int responseType, int serial, RIL_Errno e, void *response,
7392 size_t responseLen) {
7393 #if VDBG
7394 RLOGD("setCallWaitingResponse: serial %d", serial);
7395 #endif
7396
7397 if (radioService[slotId]->mRadioResponse != NULL) {
7398 RadioResponseInfo responseInfo = {};
7399 populateResponseInfo(responseInfo, serial, responseType, e);
7400 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
7401 responseInfo);
7402 radioService[slotId]->checkReturnStatus(retStatus);
7403 } else {
7404 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7405 }
7406
7407 return 0;
7408 }
7409
acknowledgeLastIncomingGsmSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7410 int radio_1_6::acknowledgeLastIncomingGsmSmsResponse(int slotId,
7411 int responseType, int serial, RIL_Errno e,
7412 void *response, size_t responseLen) {
7413 #if VDBG
7414 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
7415 #endif
7416
7417 if (radioService[slotId]->mRadioResponse != NULL) {
7418 RadioResponseInfo responseInfo = {};
7419 populateResponseInfo(responseInfo, serial, responseType, e);
7420 Return<void> retStatus =
7421 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
7422 responseInfo);
7423 radioService[slotId]->checkReturnStatus(retStatus);
7424 } else {
7425 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
7426 "== NULL", slotId);
7427 }
7428
7429 return 0;
7430 }
7431
acceptCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7432 int radio_1_6::acceptCallResponse(int slotId,
7433 int responseType, int serial, RIL_Errno e,
7434 void *response, size_t responseLen) {
7435 #if VDBG
7436 RLOGD("acceptCallResponse: serial %d", serial);
7437 #endif
7438
7439 if (radioService[slotId]->mRadioResponse != NULL) {
7440 RadioResponseInfo responseInfo = {};
7441 populateResponseInfo(responseInfo, serial, responseType, e);
7442 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
7443 responseInfo);
7444 radioService[slotId]->checkReturnStatus(retStatus);
7445 } else {
7446 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
7447 slotId);
7448 }
7449
7450 return 0;
7451 }
7452
deactivateDataCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7453 int radio_1_6::deactivateDataCallResponse(int slotId,
7454 int responseType, int serial, RIL_Errno e,
7455 void *response, size_t responseLen) {
7456 #if VDBG
7457 RLOGD("deactivateDataCallResponse: serial %d", serial);
7458 #endif
7459
7460 if (radioService[slotId]->mRadioResponse != NULL) {
7461 RadioResponseInfo responseInfo = {};
7462 populateResponseInfo(responseInfo, serial, responseType, e);
7463 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
7464 responseInfo);
7465 radioService[slotId]->checkReturnStatus(retStatus);
7466 } else {
7467 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
7468 slotId);
7469 }
7470
7471 return 0;
7472 }
7473
getFacilityLockForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7474 int radio_1_6::getFacilityLockForAppResponse(int slotId,
7475 int responseType, int serial, RIL_Errno e,
7476 void *response, size_t responseLen) {
7477 #if VDBG
7478 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
7479 #endif
7480
7481 if (radioService[slotId]->mRadioResponse != NULL) {
7482 RadioResponseInfo responseInfo = {};
7483 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
7484 Return<void> retStatus = radioService[slotId]->mRadioResponse->
7485 getFacilityLockForAppResponse(responseInfo, ret);
7486 radioService[slotId]->checkReturnStatus(retStatus);
7487 } else {
7488 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
7489 slotId);
7490 }
7491
7492 return 0;
7493 }
7494
setFacilityLockForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7495 int radio_1_6::setFacilityLockForAppResponse(int slotId,
7496 int responseType, int serial, RIL_Errno e,
7497 void *response, size_t responseLen) {
7498 #if VDBG
7499 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
7500 #endif
7501
7502 if (radioService[slotId]->mRadioResponse != NULL) {
7503 RadioResponseInfo responseInfo = {};
7504 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
7505 Return<void> retStatus
7506 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
7507 ret);
7508 radioService[slotId]->checkReturnStatus(retStatus);
7509 } else {
7510 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
7511 slotId);
7512 }
7513
7514 return 0;
7515 }
7516
setBarringPasswordResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7517 int radio_1_6::setBarringPasswordResponse(int slotId,
7518 int responseType, int serial, RIL_Errno e,
7519 void *response, size_t responseLen) {
7520 #if VDBG
7521 RLOGD("acceptCallResponse: serial %d", serial);
7522 #endif
7523
7524 if (radioService[slotId]->mRadioResponse != NULL) {
7525 RadioResponseInfo responseInfo = {};
7526 populateResponseInfo(responseInfo, serial, responseType, e);
7527 Return<void> retStatus
7528 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
7529 radioService[slotId]->checkReturnStatus(retStatus);
7530 } else {
7531 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
7532 slotId);
7533 }
7534
7535 return 0;
7536 }
7537
getNetworkSelectionModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7538 int radio_1_6::getNetworkSelectionModeResponse(int slotId,
7539 int responseType, int serial, RIL_Errno e, void *response,
7540 size_t responseLen) {
7541 #if VDBG
7542 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
7543 #endif
7544
7545 if (radioService[slotId]->mRadioResponse != NULL) {
7546 RadioResponseInfo responseInfo = {};
7547 populateResponseInfo(responseInfo, serial, responseType, e);
7548 bool manual = false;
7549 if (response == NULL || responseLen != sizeof(int)) {
7550 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
7551 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7552 } else {
7553 int *pInt = (int *) response;
7554 manual = pInt[0] == 1 ? true : false;
7555 }
7556 Return<void> retStatus
7557 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
7558 responseInfo,
7559 manual);
7560 radioService[slotId]->checkReturnStatus(retStatus);
7561 } else {
7562 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
7563 slotId);
7564 }
7565
7566 return 0;
7567 }
7568
setNetworkSelectionModeAutomaticResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7569 int radio_1_6::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
7570 RIL_Errno e, void *response,
7571 size_t responseLen) {
7572 #if VDBG
7573 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
7574 #endif
7575
7576 if (radioService[slotId]->mRadioResponse != NULL) {
7577 RadioResponseInfo responseInfo = {};
7578 populateResponseInfo(responseInfo, serial, responseType, e);
7579 Return<void> retStatus
7580 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
7581 responseInfo);
7582 radioService[slotId]->checkReturnStatus(retStatus);
7583 } else {
7584 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
7585 "== NULL", slotId);
7586 }
7587
7588 return 0;
7589 }
7590
setNetworkSelectionModeManualResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7591 int radio_1_6::setNetworkSelectionModeManualResponse(int slotId,
7592 int responseType, int serial, RIL_Errno e,
7593 void *response, size_t responseLen) {
7594 #if VDBG
7595 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
7596 #endif
7597 RadioResponseInfo responseInfo = {};
7598 populateResponseInfo(responseInfo, serial, responseType, e);
7599
7600 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7601 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
7602 ->setNetworkSelectionModeManualResponse_1_5(responseInfo);
7603 radioService[slotId]->checkReturnStatus(retStatus);
7604 } else if (radioService[slotId]->mRadioResponse != NULL) {
7605 Return<void> retStatus = radioService[slotId]->mRadioResponse
7606 ->setNetworkSelectionModeManualResponse(responseInfo);
7607 radioService[slotId]->checkReturnStatus(retStatus);
7608 } else {
7609 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
7610 "== NULL", slotId);
7611 }
7612
7613 return 0;
7614 }
7615
convertOperatorStatusToInt(const char * str)7616 int convertOperatorStatusToInt(const char *str) {
7617 if (strncmp("unknown", str, 9) == 0) {
7618 return (int) OperatorStatus::UNKNOWN;
7619 } else if (strncmp("available", str, 9) == 0) {
7620 return (int) OperatorStatus::AVAILABLE;
7621 } else if (strncmp("current", str, 9) == 0) {
7622 return (int) OperatorStatus::CURRENT;
7623 } else if (strncmp("forbidden", str, 9) == 0) {
7624 return (int) OperatorStatus::FORBIDDEN;
7625 } else {
7626 return -1;
7627 }
7628 }
7629
getAvailableNetworksResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7630 int radio_1_6::getAvailableNetworksResponse(int slotId,
7631 int responseType, int serial, RIL_Errno e, void *response,
7632 size_t responseLen) {
7633 #if VDBG
7634 RLOGD("getAvailableNetworksResponse: serial %d", serial);
7635 #endif
7636
7637 if (radioService[slotId]->mRadioResponse != NULL) {
7638 RadioResponseInfo responseInfo = {};
7639 populateResponseInfo(responseInfo, serial, responseType, e);
7640 hidl_vec<OperatorInfo> networks;
7641 if ((response == NULL && responseLen != 0)
7642 || responseLen % (4 * sizeof(char *))!= 0) {
7643 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
7644 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7645 } else {
7646 char **resp = (char **) response;
7647 int numStrings = responseLen / sizeof(char *);
7648 networks.resize(numStrings/4);
7649 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
7650 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
7651 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
7652 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
7653 int status = convertOperatorStatusToInt(resp[i + 3]);
7654 if (status == -1) {
7655 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7656 } else {
7657 networks[j].status = (OperatorStatus) status;
7658 }
7659 }
7660 }
7661 Return<void> retStatus
7662 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
7663 networks);
7664 radioService[slotId]->checkReturnStatus(retStatus);
7665 } else {
7666 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
7667 slotId);
7668 }
7669
7670 return 0;
7671 }
7672
startDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7673 int radio_1_6::startDtmfResponse(int slotId,
7674 int responseType, int serial, RIL_Errno e,
7675 void *response, size_t responseLen) {
7676 #if VDBG
7677 RLOGD("startDtmfResponse: serial %d", serial);
7678 #endif
7679
7680 if (radioService[slotId]->mRadioResponse != NULL) {
7681 RadioResponseInfo responseInfo = {};
7682 populateResponseInfo(responseInfo, serial, responseType, e);
7683 Return<void> retStatus
7684 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
7685 radioService[slotId]->checkReturnStatus(retStatus);
7686 } else {
7687 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7688 }
7689
7690 return 0;
7691 }
7692
stopDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7693 int radio_1_6::stopDtmfResponse(int slotId,
7694 int responseType, int serial, RIL_Errno e,
7695 void *response, size_t responseLen) {
7696 #if VDBG
7697 RLOGD("stopDtmfResponse: serial %d", serial);
7698 #endif
7699
7700 if (radioService[slotId]->mRadioResponse != NULL) {
7701 RadioResponseInfo responseInfo = {};
7702 populateResponseInfo(responseInfo, serial, responseType, e);
7703 Return<void> retStatus
7704 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
7705 radioService[slotId]->checkReturnStatus(retStatus);
7706 } else {
7707 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7708 }
7709
7710 return 0;
7711 }
7712
getBasebandVersionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7713 int radio_1_6::getBasebandVersionResponse(int slotId,
7714 int responseType, int serial, RIL_Errno e,
7715 void *response, size_t responseLen) {
7716 #if VDBG
7717 RLOGD("getBasebandVersionResponse: serial %d", serial);
7718 #endif
7719
7720 if (radioService[slotId]->mRadioResponse != NULL) {
7721 RadioResponseInfo responseInfo = {};
7722 populateResponseInfo(responseInfo, serial, responseType, e);
7723 Return<void> retStatus
7724 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
7725 convertCharPtrToHidlString((char *) response));
7726 radioService[slotId]->checkReturnStatus(retStatus);
7727 } else {
7728 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7729 }
7730
7731 return 0;
7732 }
7733
separateConnectionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7734 int radio_1_6::separateConnectionResponse(int slotId,
7735 int responseType, int serial, RIL_Errno e,
7736 void *response, size_t responseLen) {
7737 #if VDBG
7738 RLOGD("separateConnectionResponse: serial %d", serial);
7739 #endif
7740
7741 if (radioService[slotId]->mRadioResponse != NULL) {
7742 RadioResponseInfo responseInfo = {};
7743 populateResponseInfo(responseInfo, serial, responseType, e);
7744 Return<void> retStatus
7745 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
7746 radioService[slotId]->checkReturnStatus(retStatus);
7747 } else {
7748 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
7749 slotId);
7750 }
7751
7752 return 0;
7753 }
7754
setMuteResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7755 int radio_1_6::setMuteResponse(int slotId,
7756 int responseType, int serial, RIL_Errno e,
7757 void *response, size_t responseLen) {
7758 #if VDBG
7759 RLOGD("setMuteResponse: serial %d", serial);
7760 #endif
7761
7762 if (radioService[slotId]->mRadioResponse != NULL) {
7763 RadioResponseInfo responseInfo = {};
7764 populateResponseInfo(responseInfo, serial, responseType, e);
7765 Return<void> retStatus
7766 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
7767 radioService[slotId]->checkReturnStatus(retStatus);
7768 } else {
7769 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7770 }
7771
7772 return 0;
7773 }
7774
getMuteResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7775 int radio_1_6::getMuteResponse(int slotId,
7776 int responseType, int serial, RIL_Errno e, void *response,
7777 size_t responseLen) {
7778 #if VDBG
7779 RLOGD("getMuteResponse: serial %d", serial);
7780 #endif
7781
7782 if (radioService[slotId]->mRadioResponse != NULL) {
7783 RadioResponseInfo responseInfo = {};
7784 populateResponseInfo(responseInfo, serial, responseType, e);
7785 bool enable = false;
7786 if (response == NULL || responseLen != sizeof(int)) {
7787 RLOGE("getMuteResponse Invalid response: NULL");
7788 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7789 } else {
7790 int *pInt = (int *) response;
7791 enable = pInt[0] == 1 ? true : false;
7792 }
7793 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
7794 enable);
7795 radioService[slotId]->checkReturnStatus(retStatus);
7796 } else {
7797 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7798 }
7799
7800 return 0;
7801 }
7802
getClipResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7803 int radio_1_6::getClipResponse(int slotId,
7804 int responseType, int serial, RIL_Errno e,
7805 void *response, size_t responseLen) {
7806 #if VDBG
7807 RLOGD("getClipResponse: serial %d", serial);
7808 #endif
7809
7810 if (radioService[slotId]->mRadioResponse != NULL) {
7811 RadioResponseInfo responseInfo = {};
7812 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
7813 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
7814 (ClipStatus) ret);
7815 radioService[slotId]->checkReturnStatus(retStatus);
7816 } else {
7817 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7818 }
7819
7820 return 0;
7821 }
7822
getDataCallListResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7823 int radio_1_6::getDataCallListResponse(int slotId, int responseType, int serial, RIL_Errno e,
7824 void* response, size_t responseLen) {
7825 #if VDBG
7826 RLOGD("getDataCallListResponse: serial %d", serial);
7827 #endif
7828
7829 if (radioService[slotId]->mRadioResponse != NULL ||
7830 radioService[slotId]->mRadioResponseV1_4 != NULL ||
7831 radioService[slotId]->mRadioResponseV1_5 != NULL ||
7832 radioService[slotId]->mRadioResponseV1_6 != NULL) {
7833 V1_6::RadioResponseInfo responseInfo16 = {};
7834 RadioResponseInfo responseInfo = {};
7835 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
7836 populateResponseInfo_1_6(responseInfo16, serial, responseType, e);
7837 } else {
7838 populateResponseInfo(responseInfo, serial, responseType, e);
7839 }
7840
7841 if ((response == NULL && responseLen != 0)
7842 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
7843 RLOGE("getDataCallListResponse: invalid response");
7844 if (e == RIL_E_SUCCESS) {
7845 responseInfo16.error = V1_6::RadioError::INVALID_RESPONSE;
7846 responseInfo.error = RadioError::INVALID_RESPONSE;
7847 }
7848 } else {
7849 Return<void> retStatus;
7850 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
7851 hidl_vec<V1_6::SetupDataCallResult> ret;
7852 convertRilDataCallListToHal_1_6(response, responseLen, ret);
7853 retStatus = radioService[slotId]->mRadioResponseV1_6->getDataCallListResponse_1_6(
7854 responseInfo16, ret);
7855 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7856 hidl_vec<V1_5::SetupDataCallResult> ret;
7857 convertRilDataCallListToHal_1_5(response, responseLen, ret);
7858 retStatus = radioService[slotId]->mRadioResponseV1_5->getDataCallListResponse_1_5(
7859 responseInfo, ret);
7860 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7861 hidl_vec<V1_4::SetupDataCallResult> ret;
7862 convertRilDataCallListToHal_1_4(response, responseLen, ret);
7863 retStatus = radioService[slotId]->mRadioResponseV1_4->getDataCallListResponse_1_4(
7864 responseInfo, ret);
7865 } else {
7866 hidl_vec<SetupDataCallResult> ret;
7867 convertRilDataCallListToHal(response, responseLen, ret);
7868 retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
7869 responseInfo, ret);
7870 }
7871 radioService[slotId]->checkReturnStatus(retStatus);
7872 }
7873 } else {
7874 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7875 }
7876
7877 return 0;
7878 }
7879
setSuppServiceNotificationsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7880 int radio_1_6::setSuppServiceNotificationsResponse(int slotId,
7881 int responseType, int serial, RIL_Errno e,
7882 void *response, size_t responseLen) {
7883 #if VDBG
7884 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
7885 #endif
7886
7887 if (radioService[slotId]->mRadioResponse != NULL) {
7888 RadioResponseInfo responseInfo = {};
7889 populateResponseInfo(responseInfo, serial, responseType, e);
7890 Return<void> retStatus
7891 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
7892 responseInfo);
7893 radioService[slotId]->checkReturnStatus(retStatus);
7894 } else {
7895 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
7896 "== NULL", slotId);
7897 }
7898
7899 return 0;
7900 }
7901
deleteSmsOnSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7902 int radio_1_6::deleteSmsOnSimResponse(int slotId,
7903 int responseType, int serial, RIL_Errno e,
7904 void *response, size_t responseLen) {
7905 #if VDBG
7906 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
7907 #endif
7908
7909 if (radioService[slotId]->mRadioResponse != NULL) {
7910 RadioResponseInfo responseInfo = {};
7911 populateResponseInfo(responseInfo, serial, responseType, e);
7912 Return<void> retStatus
7913 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
7914 radioService[slotId]->checkReturnStatus(retStatus);
7915 } else {
7916 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7917 }
7918
7919 return 0;
7920 }
7921
setBandModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7922 int radio_1_6::setBandModeResponse(int slotId,
7923 int responseType, int serial, RIL_Errno e,
7924 void *response, size_t responseLen) {
7925 #if VDBG
7926 RLOGD("setBandModeResponse: serial %d", serial);
7927 #endif
7928
7929 if (radioService[slotId]->mRadioResponse != NULL) {
7930 RadioResponseInfo responseInfo = {};
7931 populateResponseInfo(responseInfo, serial, responseType, e);
7932 Return<void> retStatus
7933 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
7934 radioService[slotId]->checkReturnStatus(retStatus);
7935 } else {
7936 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7937 }
7938
7939 return 0;
7940 }
7941
writeSmsToSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7942 int radio_1_6::writeSmsToSimResponse(int slotId,
7943 int responseType, int serial, RIL_Errno e,
7944 void *response, size_t responseLen) {
7945 #if VDBG
7946 RLOGD("writeSmsToSimResponse: serial %d", serial);
7947 #endif
7948
7949 if (radioService[slotId]->mRadioResponse != NULL) {
7950 RadioResponseInfo responseInfo = {};
7951 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
7952 Return<void> retStatus
7953 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
7954 radioService[slotId]->checkReturnStatus(retStatus);
7955 } else {
7956 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7957 }
7958
7959 return 0;
7960 }
7961
getAvailableBandModesResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7962 int radio_1_6::getAvailableBandModesResponse(int slotId,
7963 int responseType, int serial, RIL_Errno e, void *response,
7964 size_t responseLen) {
7965 #if VDBG
7966 RLOGD("getAvailableBandModesResponse: serial %d", serial);
7967 #endif
7968
7969 if (radioService[slotId]->mRadioResponse != NULL) {
7970 RadioResponseInfo responseInfo = {};
7971 populateResponseInfo(responseInfo, serial, responseType, e);
7972 hidl_vec<RadioBandMode> modes;
7973 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
7974 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
7975 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7976 } else {
7977 int *pInt = (int *) response;
7978 int numInts = responseLen / sizeof(int);
7979 modes.resize(numInts);
7980 for (int i = 0; i < numInts; i++) {
7981 modes[i] = (RadioBandMode) pInt[i];
7982 }
7983 }
7984 Return<void> retStatus
7985 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
7986 modes);
7987 radioService[slotId]->checkReturnStatus(retStatus);
7988 } else {
7989 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
7990 slotId);
7991 }
7992
7993 return 0;
7994 }
7995
sendEnvelopeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7996 int radio_1_6::sendEnvelopeResponse(int slotId,
7997 int responseType, int serial, RIL_Errno e,
7998 void *response, size_t responseLen) {
7999 #if VDBG
8000 RLOGD("sendEnvelopeResponse: serial %d", serial);
8001 #endif
8002
8003 if (radioService[slotId]->mRadioResponse != NULL) {
8004 RadioResponseInfo responseInfo = {};
8005 populateResponseInfo(responseInfo, serial, responseType, e);
8006 Return<void> retStatus
8007 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
8008 convertCharPtrToHidlString((char *) response));
8009 radioService[slotId]->checkReturnStatus(retStatus);
8010 } else {
8011 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8012 }
8013
8014 return 0;
8015 }
8016
sendTerminalResponseToSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8017 int radio_1_6::sendTerminalResponseToSimResponse(int slotId,
8018 int responseType, int serial, RIL_Errno e,
8019 void *response, size_t responseLen) {
8020 #if VDBG
8021 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
8022 #endif
8023
8024 if (radioService[slotId]->mRadioResponse != NULL) {
8025 RadioResponseInfo responseInfo = {};
8026 populateResponseInfo(responseInfo, serial, responseType, e);
8027 Return<void> retStatus
8028 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
8029 responseInfo);
8030 radioService[slotId]->checkReturnStatus(retStatus);
8031 } else {
8032 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
8033 slotId);
8034 }
8035
8036 return 0;
8037 }
8038
handleStkCallSetupRequestFromSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8039 int radio_1_6::handleStkCallSetupRequestFromSimResponse(int slotId,
8040 int responseType, int serial,
8041 RIL_Errno e, void *response,
8042 size_t responseLen) {
8043 #if VDBG
8044 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
8045 #endif
8046
8047 if (radioService[slotId]->mRadioResponse != NULL) {
8048 RadioResponseInfo responseInfo = {};
8049 populateResponseInfo(responseInfo, serial, responseType, e);
8050 Return<void> retStatus
8051 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
8052 responseInfo);
8053 radioService[slotId]->checkReturnStatus(retStatus);
8054 } else {
8055 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
8056 "== NULL", slotId);
8057 }
8058
8059 return 0;
8060 }
8061
explicitCallTransferResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8062 int radio_1_6::explicitCallTransferResponse(int slotId,
8063 int responseType, int serial, RIL_Errno e,
8064 void *response, size_t responseLen) {
8065 #if VDBG
8066 RLOGD("explicitCallTransferResponse: serial %d", serial);
8067 #endif
8068
8069 if (radioService[slotId]->mRadioResponse != NULL) {
8070 RadioResponseInfo responseInfo = {};
8071 populateResponseInfo(responseInfo, serial, responseType, e);
8072 Return<void> retStatus
8073 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
8074 radioService[slotId]->checkReturnStatus(retStatus);
8075 } else {
8076 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
8077 slotId);
8078 }
8079
8080 return 0;
8081 }
8082
setPreferredNetworkTypeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8083 int radio_1_6::setPreferredNetworkTypeResponse(int slotId,
8084 int responseType, int serial, RIL_Errno e,
8085 void *response, size_t responseLen) {
8086 #if VDBG
8087 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
8088 #endif
8089
8090 if (radioService[slotId]->mRadioResponse != NULL) {
8091 RadioResponseInfo responseInfo = {};
8092 populateResponseInfo(responseInfo, serial, responseType, e);
8093 Return<void> retStatus
8094 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
8095 responseInfo);
8096 radioService[slotId]->checkReturnStatus(retStatus);
8097 } else {
8098 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
8099 slotId);
8100 }
8101
8102 return 0;
8103 }
8104
setAllowedNetworkTypesBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8105 int radio_1_6::setAllowedNetworkTypesBitmapResponse(int slotId,
8106 int responseType, int serial, RIL_Errno e,
8107 void *response, size_t responseLen) {
8108 #if VDBG
8109 RLOGD("setAllowedNetworkTypesBitmapResponse: serial %d", serial);
8110 #endif
8111
8112 V1_6::RadioResponseInfo responseInfo = {};
8113 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
8114
8115 // If we don't have a radio service, there's nothing we can do
8116 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
8117 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
8118 return 0;
8119 }
8120
8121 Return<void> retStatus =
8122 radioService[slotId]->mRadioResponseV1_6->setAllowedNetworkTypesBitmapResponse(
8123 responseInfo);
8124 radioService[slotId]->checkReturnStatus(retStatus);
8125 return 0;
8126 }
8127
getAllowedNetworkTypesBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8128 int radio_1_6::getAllowedNetworkTypesBitmapResponse(int slotId,
8129 int responseType, int serial, RIL_Errno e,
8130 void *response, size_t responseLen) {
8131 #if VDBG
8132 RLOGD("getAllowedNetworkTypesBitmapResponse: serial %d", serial);
8133 #endif
8134
8135 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
8136 V1_6::RadioResponseInfo responseInfo = {};
8137 int ret = responseInt_1_6(responseInfo, serial, responseType, e, response, responseLen);
8138 Return<void> retStatus
8139 = radioService[slotId]->mRadioResponseV1_6->getAllowedNetworkTypesBitmapResponse(
8140 responseInfo,
8141 (const ::android::hardware::hidl_bitfield<
8142 ::android::hardware::radio::V1_4::RadioAccessFamily>) ret);
8143 radioService[slotId]->checkReturnStatus(retStatus);
8144 } else {
8145 RLOGE("getAllowedNetworkTypesBitmapResponse: radioService[%d]->mRadioResponseV1_6 == NULL",
8146 slotId);
8147 }
8148
8149 return 0;
8150 }
8151
getPreferredNetworkTypeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8152 int radio_1_6::getPreferredNetworkTypeResponse(int slotId,
8153 int responseType, int serial, RIL_Errno e,
8154 void *response, size_t responseLen) {
8155 #if VDBG
8156 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
8157 #endif
8158
8159 if (radioService[slotId]->mRadioResponse != NULL) {
8160 RadioResponseInfo responseInfo = {};
8161 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8162 Return<void> retStatus
8163 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
8164 responseInfo, (PreferredNetworkType) ret);
8165 radioService[slotId]->checkReturnStatus(retStatus);
8166 } else {
8167 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
8168 slotId);
8169 }
8170
8171 return 0;
8172 }
8173
setPreferredNetworkTypeBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8174 int radio_1_6::setPreferredNetworkTypeBitmapResponse(int slotId,
8175 int responseType, int serial, RIL_Errno e,
8176 void *response, size_t responseLen) {
8177 #if VDBG
8178 RLOGD("setPreferredNetworkTypeBitmapResponse: serial %d", serial);
8179 #endif
8180
8181 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
8182 RadioResponseInfo responseInfo = {};
8183 populateResponseInfo(responseInfo, serial, responseType, e);
8184 Return<void> retStatus
8185 = radioService[slotId]->mRadioResponseV1_4->setPreferredNetworkTypeBitmapResponse(
8186 responseInfo);
8187 radioService[slotId]->checkReturnStatus(retStatus);
8188 } else {
8189 RLOGE("setPreferredNetworkTypeBitmapResponse: radioService[%d]->mRadioResponseV1_4 == NULL",
8190 slotId);
8191 }
8192
8193 return 0;
8194 }
8195
8196
getPreferredNetworkTypeBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8197 int radio_1_6::getPreferredNetworkTypeBitmapResponse(int slotId,
8198 int responseType, int serial, RIL_Errno e,
8199 void *response, size_t responseLen) {
8200 #if VDBG
8201 RLOGD("getPreferredNetworkTypeBitmapResponse: serial %d", serial);
8202 #endif
8203
8204 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
8205 RadioResponseInfo responseInfo = {};
8206 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8207 Return<void> retStatus
8208 = radioService[slotId]->mRadioResponseV1_4->getPreferredNetworkTypeBitmapResponse(
8209 responseInfo,
8210 (const ::android::hardware::hidl_bitfield<
8211 ::android::hardware::radio::V1_4::RadioAccessFamily>) ret);
8212 radioService[slotId]->checkReturnStatus(retStatus);
8213 } else {
8214 RLOGE("getPreferredNetworkTypeBitmapResponse: radioService[%d]->mRadioResponseV1_4 == NULL",
8215 slotId);
8216 }
8217
8218 return 0;
8219 }
8220
getNeighboringCidsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8221 int radio_1_6::getNeighboringCidsResponse(int slotId,
8222 int responseType, int serial, RIL_Errno e,
8223 void *response, size_t responseLen) {
8224 #if VDBG
8225 RLOGD("getNeighboringCidsResponse: serial %d", serial);
8226 #endif
8227
8228 if (radioService[slotId]->mRadioResponse != NULL) {
8229 RadioResponseInfo responseInfo = {};
8230 populateResponseInfo(responseInfo, serial, responseType, e);
8231 hidl_vec<NeighboringCell> cells;
8232
8233 if ((response == NULL && responseLen != 0)
8234 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
8235 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
8236 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8237 } else {
8238 int num = responseLen / sizeof(RIL_NeighboringCell *);
8239 cells.resize(num);
8240 for (int i = 0 ; i < num; i++) {
8241 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
8242 cells[i].cid = convertCharPtrToHidlString(resp->cid);
8243 cells[i].rssi = resp->rssi;
8244 }
8245 }
8246
8247 Return<void> retStatus
8248 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
8249 cells);
8250 radioService[slotId]->checkReturnStatus(retStatus);
8251 } else {
8252 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
8253 slotId);
8254 }
8255
8256 return 0;
8257 }
8258
setLocationUpdatesResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8259 int radio_1_6::setLocationUpdatesResponse(int slotId,
8260 int responseType, int serial, RIL_Errno e,
8261 void *response, size_t responseLen) {
8262 #if VDBG
8263 RLOGD("setLocationUpdatesResponse: serial %d", serial);
8264 #endif
8265
8266 if (radioService[slotId]->mRadioResponse != NULL) {
8267 RadioResponseInfo responseInfo = {};
8268 populateResponseInfo(responseInfo, serial, responseType, e);
8269 Return<void> retStatus
8270 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
8271 radioService[slotId]->checkReturnStatus(retStatus);
8272 } else {
8273 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
8274 slotId);
8275 }
8276
8277 return 0;
8278 }
8279
setCdmaSubscriptionSourceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8280 int radio_1_6::setCdmaSubscriptionSourceResponse(int slotId,
8281 int responseType, int serial, RIL_Errno e,
8282 void *response, size_t responseLen) {
8283 #if VDBG
8284 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
8285 #endif
8286
8287 if (radioService[slotId]->mRadioResponse != NULL) {
8288 RadioResponseInfo responseInfo = {};
8289 populateResponseInfo(responseInfo, serial, responseType, e);
8290 Return<void> retStatus
8291 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
8292 responseInfo);
8293 radioService[slotId]->checkReturnStatus(retStatus);
8294 } else {
8295 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
8296 slotId);
8297 }
8298
8299 return 0;
8300 }
8301
setCdmaRoamingPreferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8302 int radio_1_6::setCdmaRoamingPreferenceResponse(int slotId,
8303 int responseType, int serial, RIL_Errno e,
8304 void *response, size_t responseLen) {
8305 #if VDBG
8306 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
8307 #endif
8308
8309 if (radioService[slotId]->mRadioResponse != NULL) {
8310 RadioResponseInfo responseInfo = {};
8311 populateResponseInfo(responseInfo, serial, responseType, e);
8312 Return<void> retStatus
8313 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
8314 responseInfo);
8315 radioService[slotId]->checkReturnStatus(retStatus);
8316 } else {
8317 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
8318 slotId);
8319 }
8320
8321 return 0;
8322 }
8323
getCdmaRoamingPreferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8324 int radio_1_6::getCdmaRoamingPreferenceResponse(int slotId,
8325 int responseType, int serial, RIL_Errno e,
8326 void *response, size_t responseLen) {
8327 #if VDBG
8328 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
8329 #endif
8330
8331 if (radioService[slotId]->mRadioResponse != NULL) {
8332 RadioResponseInfo responseInfo = {};
8333 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8334 Return<void> retStatus
8335 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
8336 responseInfo, (CdmaRoamingType) ret);
8337 radioService[slotId]->checkReturnStatus(retStatus);
8338 } else {
8339 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
8340 slotId);
8341 }
8342
8343 return 0;
8344 }
8345
setTTYModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8346 int radio_1_6::setTTYModeResponse(int slotId,
8347 int responseType, int serial, RIL_Errno e,
8348 void *response, size_t responseLen) {
8349 #if VDBG
8350 RLOGD("setTTYModeResponse: serial %d", serial);
8351 #endif
8352
8353 if (radioService[slotId]->mRadioResponse != NULL) {
8354 RadioResponseInfo responseInfo = {};
8355 populateResponseInfo(responseInfo, serial, responseType, e);
8356 Return<void> retStatus
8357 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
8358 radioService[slotId]->checkReturnStatus(retStatus);
8359 } else {
8360 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8361 }
8362
8363 return 0;
8364 }
8365
getTTYModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8366 int radio_1_6::getTTYModeResponse(int slotId,
8367 int responseType, int serial, RIL_Errno e,
8368 void *response, size_t responseLen) {
8369 #if VDBG
8370 RLOGD("getTTYModeResponse: serial %d", serial);
8371 #endif
8372
8373 if (radioService[slotId]->mRadioResponse != NULL) {
8374 RadioResponseInfo responseInfo = {};
8375 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8376 Return<void> retStatus
8377 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
8378 (TtyMode) ret);
8379 radioService[slotId]->checkReturnStatus(retStatus);
8380 } else {
8381 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8382 }
8383
8384 return 0;
8385 }
8386
setPreferredVoicePrivacyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8387 int radio_1_6::setPreferredVoicePrivacyResponse(int slotId,
8388 int responseType, int serial, RIL_Errno e,
8389 void *response, size_t responseLen) {
8390 #if VDBG
8391 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
8392 #endif
8393
8394 if (radioService[slotId]->mRadioResponse != NULL) {
8395 RadioResponseInfo responseInfo = {};
8396 populateResponseInfo(responseInfo, serial, responseType, e);
8397 Return<void> retStatus
8398 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
8399 responseInfo);
8400 radioService[slotId]->checkReturnStatus(retStatus);
8401 } else {
8402 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
8403 slotId);
8404 }
8405
8406 return 0;
8407 }
8408
getPreferredVoicePrivacyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8409 int radio_1_6::getPreferredVoicePrivacyResponse(int slotId,
8410 int responseType, int serial, RIL_Errno e,
8411 void *response, size_t responseLen) {
8412 #if VDBG
8413 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
8414 #endif
8415
8416 if (radioService[slotId]->mRadioResponse != NULL) {
8417 RadioResponseInfo responseInfo = {};
8418 populateResponseInfo(responseInfo, serial, responseType, e);
8419 bool enable = false;
8420 int numInts = responseLen / sizeof(int);
8421 if (response == NULL || numInts != 1) {
8422 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
8423 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8424 } else {
8425 int *pInt = (int *) response;
8426 enable = pInt[0] == 1 ? true : false;
8427 }
8428 Return<void> retStatus
8429 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
8430 responseInfo, enable);
8431 radioService[slotId]->checkReturnStatus(retStatus);
8432 } else {
8433 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
8434 slotId);
8435 }
8436
8437 return 0;
8438 }
8439
sendCDMAFeatureCodeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8440 int radio_1_6::sendCDMAFeatureCodeResponse(int slotId,
8441 int responseType, int serial, RIL_Errno e,
8442 void *response, size_t responseLen) {
8443 #if VDBG
8444 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
8445 #endif
8446
8447 if (radioService[slotId]->mRadioResponse != NULL) {
8448 RadioResponseInfo responseInfo = {};
8449 populateResponseInfo(responseInfo, serial, responseType, e);
8450 Return<void> retStatus
8451 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
8452 radioService[slotId]->checkReturnStatus(retStatus);
8453 } else {
8454 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
8455 slotId);
8456 }
8457
8458 return 0;
8459 }
8460
sendBurstDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8461 int radio_1_6::sendBurstDtmfResponse(int slotId,
8462 int responseType, int serial, RIL_Errno e,
8463 void *response, size_t responseLen) {
8464 #if VDBG
8465 RLOGD("sendBurstDtmfResponse: serial %d", serial);
8466 #endif
8467
8468 if (radioService[slotId]->mRadioResponse != NULL) {
8469 RadioResponseInfo responseInfo = {};
8470 populateResponseInfo(responseInfo, serial, responseType, e);
8471 Return<void> retStatus
8472 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
8473 radioService[slotId]->checkReturnStatus(retStatus);
8474 } else {
8475 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8476 }
8477
8478 return 0;
8479 }
8480
sendCdmaSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8481 int radio_1_6::sendCdmaSmsResponse(int slotId,
8482 int responseType, int serial, RIL_Errno e, void *response,
8483 size_t responseLen) {
8484 #if VDBG
8485 RLOGD("sendCdmaSmsResponse: serial %d", serial);
8486 #endif
8487
8488 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
8489 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
8490 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e,
8491 response, responseLen);
8492
8493 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
8494 ->sendCdmaSmsResponse_1_6(responseInfo_1_6, result);
8495 radioService[slotId]->checkReturnStatus(retStatus);
8496 } else if (radioService[slotId]->mRadioResponse != NULL) {
8497 RadioResponseInfo responseInfo = {};
8498 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
8499 responseLen);
8500
8501 Return<void> retStatus
8502 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
8503 radioService[slotId]->checkReturnStatus(retStatus);
8504 } else {
8505 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8506 }
8507
8508 return 0;
8509 }
8510
acknowledgeLastIncomingCdmaSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8511 int radio_1_6::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
8512 int responseType, int serial, RIL_Errno e,
8513 void *response, size_t responseLen) {
8514 #if VDBG
8515 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
8516 #endif
8517
8518 if (radioService[slotId]->mRadioResponse != NULL) {
8519 RadioResponseInfo responseInfo = {};
8520 populateResponseInfo(responseInfo, serial, responseType, e);
8521 Return<void> retStatus
8522 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
8523 responseInfo);
8524 radioService[slotId]->checkReturnStatus(retStatus);
8525 } else {
8526 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
8527 "== NULL", slotId);
8528 }
8529
8530 return 0;
8531 }
8532
getGsmBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8533 int radio_1_6::getGsmBroadcastConfigResponse(int slotId,
8534 int responseType, int serial, RIL_Errno e,
8535 void *response, size_t responseLen) {
8536 #if VDBG
8537 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
8538 #endif
8539
8540 if (radioService[slotId]->mRadioResponse != NULL) {
8541 RadioResponseInfo responseInfo = {};
8542 populateResponseInfo(responseInfo, serial, responseType, e);
8543 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
8544
8545 if ((response == NULL && responseLen != 0)
8546 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
8547 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
8548 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8549 } else {
8550 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
8551 configs.resize(num);
8552 for (int i = 0 ; i < num; i++) {
8553 RIL_GSM_BroadcastSmsConfigInfo *resp =
8554 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
8555 configs[i].fromServiceId = resp->fromServiceId;
8556 configs[i].toServiceId = resp->toServiceId;
8557 configs[i].fromCodeScheme = resp->fromCodeScheme;
8558 configs[i].toCodeScheme = resp->toCodeScheme;
8559 configs[i].selected = resp->selected == 1 ? true : false;
8560 }
8561 }
8562
8563 Return<void> retStatus
8564 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
8565 configs);
8566 radioService[slotId]->checkReturnStatus(retStatus);
8567 } else {
8568 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8569 slotId);
8570 }
8571
8572 return 0;
8573 }
8574
setGsmBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8575 int radio_1_6::setGsmBroadcastConfigResponse(int slotId,
8576 int responseType, int serial, RIL_Errno e,
8577 void *response, size_t responseLen) {
8578 #if VDBG
8579 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
8580 #endif
8581
8582 if (radioService[slotId]->mRadioResponse != NULL) {
8583 RadioResponseInfo responseInfo = {};
8584 populateResponseInfo(responseInfo, serial, responseType, e);
8585 Return<void> retStatus
8586 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
8587 radioService[slotId]->checkReturnStatus(retStatus);
8588 } else {
8589 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8590 slotId);
8591 }
8592
8593 return 0;
8594 }
8595
setGsmBroadcastActivationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8596 int radio_1_6::setGsmBroadcastActivationResponse(int slotId,
8597 int responseType, int serial, RIL_Errno e,
8598 void *response, size_t responseLen) {
8599 #if VDBG
8600 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
8601 #endif
8602
8603 if (radioService[slotId]->mRadioResponse != NULL) {
8604 RadioResponseInfo responseInfo = {};
8605 populateResponseInfo(responseInfo, serial, responseType, e);
8606 Return<void> retStatus
8607 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
8608 responseInfo);
8609 radioService[slotId]->checkReturnStatus(retStatus);
8610 } else {
8611 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
8612 slotId);
8613 }
8614
8615 return 0;
8616 }
8617
getCdmaBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8618 int radio_1_6::getCdmaBroadcastConfigResponse(int slotId,
8619 int responseType, int serial, RIL_Errno e,
8620 void *response, size_t responseLen) {
8621 #if VDBG
8622 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
8623 #endif
8624
8625 if (radioService[slotId]->mRadioResponse != NULL) {
8626 RadioResponseInfo responseInfo = {};
8627 populateResponseInfo(responseInfo, serial, responseType, e);
8628 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
8629
8630 if ((response == NULL && responseLen != 0)
8631 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
8632 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
8633 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8634 } else {
8635 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
8636 configs.resize(num);
8637 for (int i = 0 ; i < num; i++) {
8638 RIL_CDMA_BroadcastSmsConfigInfo *resp =
8639 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
8640 configs[i].serviceCategory = resp->service_category;
8641 configs[i].language = resp->language;
8642 configs[i].selected = resp->selected == 1 ? true : false;
8643 }
8644 }
8645
8646 Return<void> retStatus
8647 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
8648 configs);
8649 radioService[slotId]->checkReturnStatus(retStatus);
8650 } else {
8651 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8652 slotId);
8653 }
8654
8655 return 0;
8656 }
8657
setCdmaBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8658 int radio_1_6::setCdmaBroadcastConfigResponse(int slotId,
8659 int responseType, int serial, RIL_Errno e,
8660 void *response, size_t responseLen) {
8661 #if VDBG
8662 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
8663 #endif
8664
8665 if (radioService[slotId]->mRadioResponse != NULL) {
8666 RadioResponseInfo responseInfo = {};
8667 populateResponseInfo(responseInfo, serial, responseType, e);
8668 Return<void> retStatus
8669 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
8670 responseInfo);
8671 radioService[slotId]->checkReturnStatus(retStatus);
8672 } else {
8673 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8674 slotId);
8675 }
8676
8677 return 0;
8678 }
8679
setCdmaBroadcastActivationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8680 int radio_1_6::setCdmaBroadcastActivationResponse(int slotId,
8681 int responseType, int serial, RIL_Errno e,
8682 void *response, size_t responseLen) {
8683 #if VDBG
8684 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
8685 #endif
8686
8687 if (radioService[slotId]->mRadioResponse != NULL) {
8688 RadioResponseInfo responseInfo = {};
8689 populateResponseInfo(responseInfo, serial, responseType, e);
8690 Return<void> retStatus
8691 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
8692 responseInfo);
8693 radioService[slotId]->checkReturnStatus(retStatus);
8694 } else {
8695 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
8696 slotId);
8697 }
8698
8699 return 0;
8700 }
8701
getCDMASubscriptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8702 int radio_1_6::getCDMASubscriptionResponse(int slotId,
8703 int responseType, int serial, RIL_Errno e, void *response,
8704 size_t responseLen) {
8705 #if VDBG
8706 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
8707 #endif
8708
8709 if (radioService[slotId]->mRadioResponse != NULL) {
8710 RadioResponseInfo responseInfo = {};
8711 populateResponseInfo(responseInfo, serial, responseType, e);
8712
8713 int numStrings = responseLen / sizeof(char *);
8714 hidl_string emptyString;
8715 if (response == NULL || numStrings != 5) {
8716 RLOGE("getOperatorResponse Invalid response: NULL");
8717 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8718 Return<void> retStatus
8719 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
8720 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
8721 radioService[slotId]->checkReturnStatus(retStatus);
8722 } else {
8723 char **resp = (char **) response;
8724 Return<void> retStatus
8725 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
8726 responseInfo,
8727 convertCharPtrToHidlString(resp[0]),
8728 convertCharPtrToHidlString(resp[1]),
8729 convertCharPtrToHidlString(resp[2]),
8730 convertCharPtrToHidlString(resp[3]),
8731 convertCharPtrToHidlString(resp[4]));
8732 radioService[slotId]->checkReturnStatus(retStatus);
8733 }
8734 } else {
8735 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
8736 slotId);
8737 }
8738
8739 return 0;
8740 }
8741
writeSmsToRuimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8742 int radio_1_6::writeSmsToRuimResponse(int slotId,
8743 int responseType, int serial, RIL_Errno e,
8744 void *response, size_t responseLen) {
8745 #if VDBG
8746 RLOGD("writeSmsToRuimResponse: serial %d", serial);
8747 #endif
8748
8749 if (radioService[slotId]->mRadioResponse != NULL) {
8750 RadioResponseInfo responseInfo = {};
8751 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8752 Return<void> retStatus
8753 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
8754 radioService[slotId]->checkReturnStatus(retStatus);
8755 } else {
8756 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8757 }
8758
8759 return 0;
8760 }
8761
deleteSmsOnRuimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8762 int radio_1_6::deleteSmsOnRuimResponse(int slotId,
8763 int responseType, int serial, RIL_Errno e,
8764 void *response, size_t responseLen) {
8765 #if VDBG
8766 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
8767 #endif
8768
8769 if (radioService[slotId]->mRadioResponse != NULL) {
8770 RadioResponseInfo responseInfo = {};
8771 populateResponseInfo(responseInfo, serial, responseType, e);
8772 Return<void> retStatus
8773 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
8774 radioService[slotId]->checkReturnStatus(retStatus);
8775 } else {
8776 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8777 }
8778
8779 return 0;
8780 }
8781
getDeviceIdentityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8782 int radio_1_6::getDeviceIdentityResponse(int slotId,
8783 int responseType, int serial, RIL_Errno e, void *response,
8784 size_t responseLen) {
8785 #if VDBG
8786 RLOGD("getDeviceIdentityResponse: serial %d", serial);
8787 #endif
8788
8789 if (radioService[slotId]->mRadioResponse != NULL) {
8790 RadioResponseInfo responseInfo = {};
8791 populateResponseInfo(responseInfo, serial, responseType, e);
8792
8793 int numStrings = responseLen / sizeof(char *);
8794 hidl_string emptyString;
8795 if (response == NULL || numStrings != 4) {
8796 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
8797 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8798 Return<void> retStatus
8799 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
8800 emptyString, emptyString, emptyString, emptyString);
8801 radioService[slotId]->checkReturnStatus(retStatus);
8802 } else {
8803 char **resp = (char **) response;
8804 Return<void> retStatus
8805 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
8806 convertCharPtrToHidlString(resp[0]),
8807 convertCharPtrToHidlString(resp[1]),
8808 convertCharPtrToHidlString(resp[2]),
8809 convertCharPtrToHidlString(resp[3]));
8810 radioService[slotId]->checkReturnStatus(retStatus);
8811 }
8812 } else {
8813 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
8814 slotId);
8815 }
8816
8817 return 0;
8818 }
8819
exitEmergencyCallbackModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8820 int radio_1_6::exitEmergencyCallbackModeResponse(int slotId,
8821 int responseType, int serial, RIL_Errno e,
8822 void *response, size_t responseLen) {
8823 #if VDBG
8824 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
8825 #endif
8826
8827 if (radioService[slotId]->mRadioResponse != NULL) {
8828 RadioResponseInfo responseInfo = {};
8829 populateResponseInfo(responseInfo, serial, responseType, e);
8830 Return<void> retStatus
8831 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
8832 responseInfo);
8833 radioService[slotId]->checkReturnStatus(retStatus);
8834 } else {
8835 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
8836 slotId);
8837 }
8838
8839 return 0;
8840 }
8841
getSmscAddressResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8842 int radio_1_6::getSmscAddressResponse(int slotId,
8843 int responseType, int serial, RIL_Errno e,
8844 void *response, size_t responseLen) {
8845 #if VDBG
8846 RLOGD("getSmscAddressResponse: serial %d", serial);
8847 #endif
8848
8849 if (radioService[slotId]->mRadioResponse != NULL) {
8850 RadioResponseInfo responseInfo = {};
8851 populateResponseInfo(responseInfo, serial, responseType, e);
8852 Return<void> retStatus
8853 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
8854 convertCharPtrToHidlString((char *) response));
8855 radioService[slotId]->checkReturnStatus(retStatus);
8856 } else {
8857 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8858 }
8859
8860 return 0;
8861 }
8862
setSmscAddressResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8863 int radio_1_6::setSmscAddressResponse(int slotId,
8864 int responseType, int serial, RIL_Errno e,
8865 void *response, size_t responseLen) {
8866 #if VDBG
8867 RLOGD("setSmscAddressResponse: serial %d", serial);
8868 #endif
8869
8870 if (radioService[slotId]->mRadioResponse != NULL) {
8871 RadioResponseInfo responseInfo = {};
8872 populateResponseInfo(responseInfo, serial, responseType, e);
8873 Return<void> retStatus
8874 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
8875 radioService[slotId]->checkReturnStatus(retStatus);
8876 } else {
8877 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8878 }
8879
8880 return 0;
8881 }
8882
reportSmsMemoryStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8883 int radio_1_6::reportSmsMemoryStatusResponse(int slotId,
8884 int responseType, int serial, RIL_Errno e,
8885 void *response, size_t responseLen) {
8886 #if VDBG
8887 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
8888 #endif
8889
8890 if (radioService[slotId]->mRadioResponse != NULL) {
8891 RadioResponseInfo responseInfo = {};
8892 populateResponseInfo(responseInfo, serial, responseType, e);
8893 Return<void> retStatus
8894 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
8895 radioService[slotId]->checkReturnStatus(retStatus);
8896 } else {
8897 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
8898 slotId);
8899 }
8900
8901 return 0;
8902 }
8903
reportStkServiceIsRunningResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8904 int radio_1_6::reportStkServiceIsRunningResponse(int slotId,
8905 int responseType, int serial, RIL_Errno e,
8906 void *response, size_t responseLen) {
8907 #if VDBG
8908 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
8909 #endif
8910
8911 if (radioService[slotId]->mRadioResponse != NULL) {
8912 RadioResponseInfo responseInfo = {};
8913 populateResponseInfo(responseInfo, serial, responseType, e);
8914 Return<void> retStatus = radioService[slotId]->mRadioResponse->
8915 reportStkServiceIsRunningResponse(responseInfo);
8916 radioService[slotId]->checkReturnStatus(retStatus);
8917 } else {
8918 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
8919 slotId);
8920 }
8921
8922 return 0;
8923 }
8924
getCdmaSubscriptionSourceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8925 int radio_1_6::getCdmaSubscriptionSourceResponse(int slotId,
8926 int responseType, int serial, RIL_Errno e,
8927 void *response, size_t responseLen) {
8928 #if VDBG
8929 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
8930 #endif
8931
8932 if (radioService[slotId]->mRadioResponse != NULL) {
8933 RadioResponseInfo responseInfo = {};
8934 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8935 Return<void> retStatus
8936 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
8937 responseInfo, (CdmaSubscriptionSource) ret);
8938 radioService[slotId]->checkReturnStatus(retStatus);
8939 } else {
8940 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
8941 slotId);
8942 }
8943
8944 return 0;
8945 }
8946
requestIsimAuthenticationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8947 int radio_1_6::requestIsimAuthenticationResponse(int slotId,
8948 int responseType, int serial, RIL_Errno e,
8949 void *response, size_t responseLen) {
8950 #if VDBG
8951 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
8952 #endif
8953
8954 if (radioService[slotId]->mRadioResponse != NULL) {
8955 RadioResponseInfo responseInfo = {};
8956 populateResponseInfo(responseInfo, serial, responseType, e);
8957 Return<void> retStatus
8958 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
8959 responseInfo,
8960 convertCharPtrToHidlString((char *) response));
8961 radioService[slotId]->checkReturnStatus(retStatus);
8962 } else {
8963 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
8964 slotId);
8965 }
8966
8967 return 0;
8968 }
8969
acknowledgeIncomingGsmSmsWithPduResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8970 int radio_1_6::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
8971 int responseType,
8972 int serial, RIL_Errno e, void *response,
8973 size_t responseLen) {
8974 #if VDBG
8975 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
8976 #endif
8977
8978 if (radioService[slotId]->mRadioResponse != NULL) {
8979 RadioResponseInfo responseInfo = {};
8980 populateResponseInfo(responseInfo, serial, responseType, e);
8981 Return<void> retStatus
8982 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
8983 responseInfo);
8984 radioService[slotId]->checkReturnStatus(retStatus);
8985 } else {
8986 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
8987 "== NULL", slotId);
8988 }
8989
8990 return 0;
8991 }
8992
sendEnvelopeWithStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8993 int radio_1_6::sendEnvelopeWithStatusResponse(int slotId,
8994 int responseType, int serial, RIL_Errno e, void *response,
8995 size_t responseLen) {
8996 #if VDBG
8997 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
8998 #endif
8999
9000 if (radioService[slotId]->mRadioResponse != NULL) {
9001 RadioResponseInfo responseInfo = {};
9002 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
9003 response, responseLen);
9004
9005 Return<void> retStatus
9006 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
9007 result);
9008 radioService[slotId]->checkReturnStatus(retStatus);
9009 } else {
9010 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
9011 slotId);
9012 }
9013
9014 return 0;
9015 }
9016
getVoiceRadioTechnologyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9017 int radio_1_6::getVoiceRadioTechnologyResponse(int slotId,
9018 int responseType, int serial, RIL_Errno e,
9019 void *response, size_t responseLen) {
9020 #if VDBG
9021 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
9022 #endif
9023
9024 if (radioService[slotId]->mRadioResponse != NULL) {
9025 RadioResponseInfo responseInfo = {};
9026 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
9027 Return<void> retStatus
9028 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
9029 responseInfo, (RadioTechnology) ret);
9030 radioService[slotId]->checkReturnStatus(retStatus);
9031 } else {
9032 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
9033 slotId);
9034 }
9035
9036 return 0;
9037 }
9038
getCellInfoListResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9039 int radio_1_6::getCellInfoListResponse(int slotId, int responseType, int serial, RIL_Errno e,
9040 void* response, size_t responseLen) {
9041 #if VDBG
9042 RLOGD("getCellInfoListResponse: serial %d", serial);
9043 #endif
9044 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
9045 V1_6::RadioResponseInfo responseInfo = {};
9046 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
9047 hidl_vec<V1_6::CellInfo> ret;
9048 Return<void> retStatus;
9049 if (response != NULL && responseLen != 0 && responseLen % sizeof(RIL_CellInfo_v16) == 0) {
9050 convertRilCellInfoListToHal_1_6(response, responseLen, ret);
9051 } else {
9052 RLOGE("getCellInfoListResponse_1_6: Invalid response");
9053 if (e == RIL_E_SUCCESS) responseInfo.error = V1_6::RadioError::INVALID_RESPONSE;
9054 }
9055 retStatus = radioService[slotId]->mRadioResponseV1_6->getCellInfoListResponse_1_6(
9056 responseInfo, ret);
9057 radioService[slotId]->checkReturnStatus(retStatus);
9058 } else if (radioService[slotId]->mRadioResponse != NULL ||
9059 radioService[slotId]->mRadioResponseV1_2 != NULL ||
9060 radioService[slotId]->mRadioResponseV1_4 != NULL ||
9061 radioService[slotId]->mRadioResponseV1_5 != NULL) {
9062 RadioResponseInfo responseInfo = {};
9063 populateResponseInfo(responseInfo, serial, responseType, e);
9064 bool error = response == NULL && responseLen != 0;
9065 Return<void> retStatus;
9066 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
9067 hidl_vec<V1_5::CellInfo> ret;
9068 if (!error && responseLen % sizeof(RIL_CellInfo_v16) != 0) {
9069 convertRilCellInfoListToHal_1_5(response, responseLen, ret);
9070 } else {
9071 RLOGE("getCellInfoListResponse_1_5: Invalid response");
9072 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9073 }
9074 retStatus = radioService[slotId]->mRadioResponseV1_5->getCellInfoListResponse_1_5(
9075 responseInfo, ret);
9076 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9077 hidl_vec<V1_4::CellInfo> ret;
9078 if (!error && responseLen % sizeof(RIL_CellInfo_v16) != 0) {
9079 convertRilCellInfoListToHal_1_4(response, responseLen, ret);
9080 } else {
9081 RLOGE("getCellInfoListResponse_1_4: Invalid response");
9082 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9083 }
9084 radioService[slotId]->mRadioResponseV1_4->getCellInfoListResponse_1_4(responseInfo,
9085 ret);
9086 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
9087 hidl_vec<V1_2::CellInfo> ret;
9088 if (!error && responseLen % sizeof(RIL_CellInfo_v12) != 0) {
9089 convertRilCellInfoListToHal_1_2(response, responseLen, ret);
9090 } else {
9091 RLOGE("getCellInfoListResponse_1_2: Invalid response");
9092 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9093 }
9094 radioService[slotId]->mRadioResponseV1_2->getCellInfoListResponse_1_2(responseInfo,
9095 ret);
9096 } else {
9097 hidl_vec<CellInfo> ret;
9098 if (!error && responseLen % sizeof(RIL_CellInfo) != 0) {
9099 convertRilCellInfoListToHal(response, responseLen, ret);
9100 } else {
9101 RLOGE("getCellInfoListResponse: Invalid response");
9102 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9103 }
9104 radioService[slotId]->mRadioResponse->getCellInfoListResponse(responseInfo, ret);
9105 }
9106 radioService[slotId]->checkReturnStatus(retStatus);
9107 } else {
9108 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9109 }
9110
9111 return 0;
9112 }
9113
setCellInfoListRateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9114 int radio_1_6::setCellInfoListRateResponse(int slotId,
9115 int responseType,
9116 int serial, RIL_Errno e, void *response,
9117 size_t responseLen) {
9118 #if VDBG
9119 RLOGD("setCellInfoListRateResponse: serial %d", serial);
9120 #endif
9121
9122 if (radioService[slotId]->mRadioResponse != NULL) {
9123 RadioResponseInfo responseInfo = {};
9124 populateResponseInfo(responseInfo, serial, responseType, e);
9125 Return<void> retStatus
9126 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
9127 radioService[slotId]->checkReturnStatus(retStatus);
9128 } else {
9129 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
9130 slotId);
9131 }
9132
9133 return 0;
9134 }
9135
setInitialAttachApnResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9136 int radio_1_6::setInitialAttachApnResponse(int slotId, int responseType, int serial, RIL_Errno e,
9137 void* response, size_t responseLen) {
9138 #if VDBG
9139 RLOGD("setInitialAttachApnResponse: serial %d", serial);
9140 #endif
9141
9142 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
9143 RadioResponseInfo responseInfo = {};
9144 populateResponseInfo(responseInfo, serial, responseType, e);
9145 Return<void> retStatus =
9146 radioService[slotId]->mRadioResponseV1_5->setInitialAttachApnResponse_1_5(
9147 responseInfo);
9148 radioService[slotId]->checkReturnStatus(retStatus);
9149 } else if (radioService[slotId]->mRadioResponse != NULL) {
9150 RadioResponseInfo responseInfo = {};
9151 populateResponseInfo(responseInfo, serial, responseType, e);
9152 Return<void> retStatus =
9153 radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
9154 radioService[slotId]->checkReturnStatus(retStatus);
9155 } else {
9156 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9157 }
9158
9159 return 0;
9160 }
9161
getImsRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9162 int radio_1_6::getImsRegistrationStateResponse(int slotId,
9163 int responseType, int serial, RIL_Errno e,
9164 void *response, size_t responseLen) {
9165 #if VDBG
9166 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
9167 #endif
9168
9169 if (radioService[slotId]->mRadioResponse != NULL) {
9170 RadioResponseInfo responseInfo = {};
9171 populateResponseInfo(responseInfo, serial, responseType, e);
9172 bool isRegistered = false;
9173 int ratFamily = 0;
9174 int numInts = responseLen / sizeof(int);
9175 if (response == NULL || numInts != 2) {
9176 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
9177 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9178 } else {
9179 int *pInt = (int *) response;
9180 isRegistered = pInt[0] == 1 ? true : false;
9181 ratFamily = pInt[1];
9182 }
9183 Return<void> retStatus
9184 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
9185 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
9186 radioService[slotId]->checkReturnStatus(retStatus);
9187 } else {
9188 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
9189 slotId);
9190 }
9191
9192 return 0;
9193 }
9194
sendImsSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9195 int radio_1_6::sendImsSmsResponse(int slotId,
9196 int responseType, int serial, RIL_Errno e, void *response,
9197 size_t responseLen) {
9198 #if VDBG
9199 RLOGD("sendImsSmsResponse: serial %d", serial);
9200 #endif
9201
9202 if (radioService[slotId]->mRadioResponse != NULL) {
9203 RadioResponseInfo responseInfo = {};
9204 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
9205 responseLen);
9206
9207 Return<void> retStatus
9208 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
9209 radioService[slotId]->checkReturnStatus(retStatus);
9210 } else {
9211 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9212 }
9213
9214 return 0;
9215 }
9216
iccTransmitApduBasicChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9217 int radio_1_6::iccTransmitApduBasicChannelResponse(int slotId,
9218 int responseType, int serial, RIL_Errno e,
9219 void *response, size_t responseLen) {
9220 #if VDBG
9221 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
9222 #endif
9223
9224 if (radioService[slotId]->mRadioResponse != NULL) {
9225 RadioResponseInfo responseInfo = {};
9226 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
9227 responseLen);
9228
9229 Return<void> retStatus
9230 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
9231 responseInfo, result);
9232 radioService[slotId]->checkReturnStatus(retStatus);
9233 } else {
9234 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
9235 "== NULL", slotId);
9236 }
9237
9238 return 0;
9239 }
9240
iccOpenLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9241 int radio_1_6::iccOpenLogicalChannelResponse(int slotId,
9242 int responseType, int serial, RIL_Errno e, void *response,
9243 size_t responseLen) {
9244 #if VDBG
9245 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
9246 #endif
9247
9248 if (radioService[slotId]->mRadioResponse != NULL) {
9249 RadioResponseInfo responseInfo = {};
9250 populateResponseInfo(responseInfo, serial, responseType, e);
9251 int channelId = -1;
9252 hidl_vec<int8_t> selectResponse;
9253 int numInts = responseLen / sizeof(int);
9254 if (response == NULL || responseLen % sizeof(int) != 0) {
9255 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
9256 if (response != NULL) {
9257 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9258 }
9259 } else {
9260 int *pInt = (int *) response;
9261 channelId = pInt[0];
9262 selectResponse.resize(numInts - 1);
9263 for (int i = 1; i < numInts; i++) {
9264 selectResponse[i - 1] = (int8_t) pInt[i];
9265 }
9266 }
9267 Return<void> retStatus
9268 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
9269 channelId, selectResponse);
9270 radioService[slotId]->checkReturnStatus(retStatus);
9271 } else {
9272 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
9273 slotId);
9274 }
9275
9276 return 0;
9277 }
9278
iccCloseLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9279 int radio_1_6::iccCloseLogicalChannelResponse(int slotId,
9280 int responseType, int serial, RIL_Errno e,
9281 void *response, size_t responseLen) {
9282 #if VDBG
9283 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
9284 #endif
9285
9286 if (radioService[slotId]->mRadioResponse != NULL) {
9287 RadioResponseInfo responseInfo = {};
9288 populateResponseInfo(responseInfo, serial, responseType, e);
9289 Return<void> retStatus
9290 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
9291 responseInfo);
9292 radioService[slotId]->checkReturnStatus(retStatus);
9293 } else {
9294 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
9295 slotId);
9296 }
9297
9298 return 0;
9299 }
9300
iccTransmitApduLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9301 int radio_1_6::iccTransmitApduLogicalChannelResponse(int slotId,
9302 int responseType, int serial, RIL_Errno e,
9303 void *response, size_t responseLen) {
9304 #if VDBG
9305 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
9306 #endif
9307
9308 if (radioService[slotId]->mRadioResponse != NULL) {
9309 RadioResponseInfo responseInfo = {};
9310 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
9311 responseLen);
9312
9313 Return<void> retStatus
9314 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
9315 responseInfo, result);
9316 radioService[slotId]->checkReturnStatus(retStatus);
9317 } else {
9318 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
9319 "== NULL", slotId);
9320 }
9321
9322 return 0;
9323 }
9324
nvReadItemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9325 int radio_1_6::nvReadItemResponse(int slotId,
9326 int responseType, int serial, RIL_Errno e,
9327 void *response, size_t responseLen) {
9328 #if VDBG
9329 RLOGD("nvReadItemResponse: serial %d", serial);
9330 #endif
9331
9332 if (radioService[slotId]->mRadioResponse != NULL) {
9333 RadioResponseInfo responseInfo = {};
9334 populateResponseInfo(responseInfo, serial, responseType, e);
9335 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
9336 responseInfo,
9337 convertCharPtrToHidlString((char *) response));
9338 radioService[slotId]->checkReturnStatus(retStatus);
9339 } else {
9340 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9341 }
9342
9343 return 0;
9344 }
9345
nvWriteItemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9346 int radio_1_6::nvWriteItemResponse(int slotId,
9347 int responseType, int serial, RIL_Errno e,
9348 void *response, size_t responseLen) {
9349 #if VDBG
9350 RLOGD("nvWriteItemResponse: serial %d", serial);
9351 #endif
9352
9353 if (radioService[slotId]->mRadioResponse != NULL) {
9354 RadioResponseInfo responseInfo = {};
9355 populateResponseInfo(responseInfo, serial, responseType, e);
9356 Return<void> retStatus
9357 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
9358 radioService[slotId]->checkReturnStatus(retStatus);
9359 } else {
9360 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9361 }
9362
9363 return 0;
9364 }
9365
nvWriteCdmaPrlResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9366 int radio_1_6::nvWriteCdmaPrlResponse(int slotId,
9367 int responseType, int serial, RIL_Errno e,
9368 void *response, size_t responseLen) {
9369 #if VDBG
9370 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
9371 #endif
9372
9373 if (radioService[slotId]->mRadioResponse != NULL) {
9374 RadioResponseInfo responseInfo = {};
9375 populateResponseInfo(responseInfo, serial, responseType, e);
9376 Return<void> retStatus
9377 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
9378 radioService[slotId]->checkReturnStatus(retStatus);
9379 } else {
9380 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9381 }
9382
9383 return 0;
9384 }
9385
nvResetConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9386 int radio_1_6::nvResetConfigResponse(int slotId,
9387 int responseType, int serial, RIL_Errno e,
9388 void *response, size_t responseLen) {
9389 #if VDBG
9390 RLOGD("nvResetConfigResponse: serial %d", serial);
9391 #endif
9392
9393 if (radioService[slotId]->mRadioResponse != NULL) {
9394 RadioResponseInfo responseInfo = {};
9395 populateResponseInfo(responseInfo, serial, responseType, e);
9396 Return<void> retStatus
9397 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
9398 radioService[slotId]->checkReturnStatus(retStatus);
9399 } else {
9400 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9401 }
9402
9403 return 0;
9404 }
9405
setUiccSubscriptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9406 int radio_1_6::setUiccSubscriptionResponse(int slotId,
9407 int responseType, int serial, RIL_Errno e,
9408 void *response, size_t responseLen) {
9409 #if VDBG
9410 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
9411 #endif
9412
9413 if (radioService[slotId]->mRadioResponse != NULL) {
9414 RadioResponseInfo responseInfo = {};
9415 populateResponseInfo(responseInfo, serial, responseType, e);
9416 Return<void> retStatus
9417 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
9418 radioService[slotId]->checkReturnStatus(retStatus);
9419 } else {
9420 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
9421 slotId);
9422 }
9423
9424 return 0;
9425 }
9426
setDataAllowedResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9427 int radio_1_6::setDataAllowedResponse(int slotId,
9428 int responseType, int serial, RIL_Errno e,
9429 void *response, size_t responseLen) {
9430 #if VDBG
9431 RLOGD("setDataAllowedResponse: serial %d", serial);
9432 #endif
9433
9434 if (radioService[slotId]->mRadioResponse != NULL) {
9435 RadioResponseInfo responseInfo = {};
9436 populateResponseInfo(responseInfo, serial, responseType, e);
9437 Return<void> retStatus
9438 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
9439 radioService[slotId]->checkReturnStatus(retStatus);
9440 } else {
9441 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9442 }
9443
9444 return 0;
9445 }
9446
getHardwareConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9447 int radio_1_6::getHardwareConfigResponse(int slotId,
9448 int responseType, int serial, RIL_Errno e,
9449 void *response, size_t responseLen) {
9450 #if VDBG
9451 RLOGD("getHardwareConfigResponse: serial %d", serial);
9452 #endif
9453
9454 if (radioService[slotId]->mRadioResponse != NULL) {
9455 RadioResponseInfo responseInfo = {};
9456 populateResponseInfo(responseInfo, serial, responseType, e);
9457
9458 hidl_vec<HardwareConfig> result;
9459 if ((response == NULL && responseLen != 0)
9460 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
9461 RLOGE("hardwareConfigChangedInd: invalid response");
9462 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9463 } else {
9464 convertRilHardwareConfigListToHal(response, responseLen, result);
9465 }
9466
9467 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
9468 responseInfo, result);
9469 radioService[slotId]->checkReturnStatus(retStatus);
9470 } else {
9471 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9472 }
9473
9474 return 0;
9475 }
9476
requestIccSimAuthenticationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9477 int radio_1_6::requestIccSimAuthenticationResponse(int slotId,
9478 int responseType, int serial, RIL_Errno e,
9479 void *response, size_t responseLen) {
9480 #if VDBG
9481 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
9482 #endif
9483
9484 if (radioService[slotId]->mRadioResponse != NULL) {
9485 RadioResponseInfo responseInfo = {};
9486 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
9487 responseLen);
9488
9489 Return<void> retStatus
9490 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
9491 responseInfo, result);
9492 radioService[slotId]->checkReturnStatus(retStatus);
9493 } else {
9494 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
9495 "== NULL", slotId);
9496 }
9497
9498 return 0;
9499 }
9500
setDataProfileResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9501 int radio_1_6::setDataProfileResponse(int slotId,
9502 int responseType, int serial, RIL_Errno e,
9503 void *response, size_t responseLen) {
9504 #if VDBG
9505 RLOGD("setDataProfileResponse: serial %d", serial);
9506 #endif
9507
9508 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
9509 RadioResponseInfo responseInfo = {};
9510 populateResponseInfo(responseInfo, serial, responseType, e);
9511 Return<void> retStatus
9512 = radioService[slotId]->mRadioResponseV1_5->setDataProfileResponse_1_5(
9513 responseInfo);
9514 } else if (radioService[slotId]->mRadioResponse != NULL) {
9515 RadioResponseInfo responseInfo = {};
9516 populateResponseInfo(responseInfo, serial, responseType, e);
9517 Return<void> retStatus
9518 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
9519 radioService[slotId]->checkReturnStatus(retStatus);
9520 } else {
9521 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9522 }
9523
9524 return 0;
9525 }
9526
requestShutdownResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9527 int radio_1_6::requestShutdownResponse(int slotId,
9528 int responseType, int serial, RIL_Errno e,
9529 void *response, size_t responseLen) {
9530 #if VDBG
9531 RLOGD("requestShutdownResponse: serial %d", serial);
9532 #endif
9533
9534 if (radioService[slotId]->mRadioResponse != NULL) {
9535 RadioResponseInfo responseInfo = {};
9536 populateResponseInfo(responseInfo, serial, responseType, e);
9537 Return<void> retStatus
9538 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
9539 radioService[slotId]->checkReturnStatus(retStatus);
9540 } else {
9541 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9542 }
9543
9544 return 0;
9545 }
9546
responseRadioCapability(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen,RadioCapability & rc)9547 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
9548 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
9549 populateResponseInfo(responseInfo, serial, responseType, e);
9550
9551 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
9552 RLOGE("responseRadioCapability: Invalid response");
9553 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9554 rc.logicalModemUuid = hidl_string();
9555 } else {
9556 convertRilRadioCapabilityToHal(response, responseLen, rc);
9557 }
9558 }
9559
getRadioCapabilityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9560 int radio_1_6::getRadioCapabilityResponse(int slotId,
9561 int responseType, int serial, RIL_Errno e,
9562 void *response, size_t responseLen) {
9563 #if VDBG
9564 RLOGD("getRadioCapabilityResponse: serial %d", serial);
9565 #endif
9566
9567 if (radioService[slotId]->mRadioResponse != NULL) {
9568 RadioResponseInfo responseInfo = {};
9569 RadioCapability result = {};
9570 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
9571 result);
9572 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
9573 responseInfo, result);
9574 radioService[slotId]->checkReturnStatus(retStatus);
9575 } else {
9576 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9577 }
9578
9579 return 0;
9580 }
9581
setRadioCapabilityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9582 int radio_1_6::setRadioCapabilityResponse(int slotId,
9583 int responseType, int serial, RIL_Errno e,
9584 void *response, size_t responseLen) {
9585 #if VDBG
9586 RLOGD("setRadioCapabilityResponse: serial %d", serial);
9587 #endif
9588
9589 if (radioService[slotId]->mRadioResponse != NULL) {
9590 RadioResponseInfo responseInfo = {};
9591 RadioCapability result = {};
9592 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
9593 result);
9594 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
9595 responseInfo, result);
9596 radioService[slotId]->checkReturnStatus(retStatus);
9597 } else {
9598 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9599 }
9600
9601 return 0;
9602 }
9603
responseLceStatusInfo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)9604 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
9605 RIL_Errno e, void *response, size_t responseLen) {
9606 populateResponseInfo(responseInfo, serial, responseType, e);
9607 LceStatusInfo result = {};
9608
9609 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
9610 RLOGE("Invalid response: NULL");
9611 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9612 } else {
9613 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
9614 result.lceStatus = (LceStatus) resp->lce_status;
9615 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
9616 }
9617 return result;
9618 }
9619
startLceServiceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9620 int radio_1_6::startLceServiceResponse(int slotId,
9621 int responseType, int serial, RIL_Errno e,
9622 void *response, size_t responseLen) {
9623 #if VDBG
9624 RLOGD("startLceServiceResponse: serial %d", serial);
9625 #endif
9626
9627 if (radioService[slotId]->mRadioResponse != NULL) {
9628 RadioResponseInfo responseInfo = {};
9629 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
9630 response, responseLen);
9631
9632 Return<void> retStatus
9633 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
9634 result);
9635 radioService[slotId]->checkReturnStatus(retStatus);
9636 } else {
9637 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9638 }
9639
9640 return 0;
9641 }
9642
stopLceServiceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9643 int radio_1_6::stopLceServiceResponse(int slotId,
9644 int responseType, int serial, RIL_Errno e,
9645 void *response, size_t responseLen) {
9646 #if VDBG
9647 RLOGD("stopLceServiceResponse: serial %d", serial);
9648 #endif
9649
9650 if (radioService[slotId]->mRadioResponse != NULL) {
9651 RadioResponseInfo responseInfo = {};
9652 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
9653 response, responseLen);
9654
9655 Return<void> retStatus
9656 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
9657 result);
9658 radioService[slotId]->checkReturnStatus(retStatus);
9659 } else {
9660 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9661 }
9662
9663 return 0;
9664 }
9665
pullLceDataResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9666 int radio_1_6::pullLceDataResponse(int slotId,
9667 int responseType, int serial, RIL_Errno e,
9668 void *response, size_t responseLen) {
9669 #if VDBG
9670 RLOGD("pullLceDataResponse: serial %d", serial);
9671 #endif
9672
9673 if (radioService[slotId]->mRadioResponse != NULL) {
9674 RadioResponseInfo responseInfo = {};
9675 populateResponseInfo(responseInfo, serial, responseType, e);
9676
9677 LceDataInfo result = {};
9678 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
9679 RLOGE("pullLceDataResponse: Invalid response");
9680 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9681 } else {
9682 convertRilLceDataInfoToHal(response, responseLen, result);
9683 }
9684
9685 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
9686 responseInfo, result);
9687 radioService[slotId]->checkReturnStatus(retStatus);
9688 } else {
9689 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9690 }
9691
9692 return 0;
9693 }
9694
getModemActivityInfoResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9695 int radio_1_6::getModemActivityInfoResponse(int slotId,
9696 int responseType, int serial, RIL_Errno e,
9697 void *response, size_t responseLen) {
9698 #if VDBG
9699 RLOGD("getModemActivityInfoResponse: serial %d", serial);
9700 #endif
9701
9702 if (radioService[slotId]->mRadioResponse != NULL) {
9703 RadioResponseInfo responseInfo = {};
9704 populateResponseInfo(responseInfo, serial, responseType, e);
9705 ActivityStatsInfo info;
9706 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
9707 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
9708 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9709 } else {
9710 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
9711 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
9712 info.idleModeTimeMs = resp->idle_mode_time_ms;
9713 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
9714 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
9715 }
9716 info.rxModeTimeMs = resp->rx_mode_time_ms;
9717 }
9718
9719 Return<void> retStatus
9720 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
9721 info);
9722 radioService[slotId]->checkReturnStatus(retStatus);
9723 } else {
9724 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
9725 slotId);
9726 }
9727
9728 return 0;
9729 }
9730
setAllowedCarriersResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9731 int radio_1_6::setAllowedCarriersResponse(int slotId,
9732 int responseType, int serial, RIL_Errno e,
9733 void *response, size_t responseLen) {
9734 #if VDBG
9735 RLOGD("setAllowedCarriersResponse: serial %d", serial);
9736 #endif
9737 RadioResponseInfo responseInfo = {};
9738 populateResponseInfo(responseInfo, serial, responseType, e);
9739
9740 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9741 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
9742 ->setAllowedCarriersResponse_1_4(responseInfo);
9743 radioService[slotId]->checkReturnStatus(retStatus);
9744 } else if (radioService[slotId]->mRadioResponse != NULL) {
9745 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
9746 Return<void> retStatus = radioService[slotId]->mRadioResponse
9747 ->setAllowedCarriersResponse(responseInfo, ret);
9748 radioService[slotId]->checkReturnStatus(retStatus);
9749 } else {
9750 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9751 }
9752
9753 return 0;
9754 }
9755
prepareCarrierRestrictionsResponse(hidl_vec<Carrier> & allowedCarriers,hidl_vec<Carrier> & excludedCarriers,bool & allAllowed,const RIL_CarrierRestrictions * pCr)9756 void prepareCarrierRestrictionsResponse(hidl_vec<Carrier>& allowedCarriers,
9757 hidl_vec<Carrier>& excludedCarriers,
9758 bool& allAllowed,
9759 const RIL_CarrierRestrictions* pCr) {
9760 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
9761 allAllowed = false;
9762 }
9763 allowedCarriers.resize(pCr->len_allowed_carriers);
9764 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
9765 RIL_Carrier *carrier = pCr->allowed_carriers + i;
9766 allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
9767 allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
9768 allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
9769 allowedCarriers[i].matchData =
9770 convertCharPtrToHidlString(carrier->match_data);
9771 }
9772
9773 excludedCarriers.resize(pCr->len_excluded_carriers);
9774 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
9775 RIL_Carrier *carrier = pCr->excluded_carriers + i;
9776 excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
9777 excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
9778 excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
9779 excludedCarriers[i].matchData =
9780 convertCharPtrToHidlString(carrier->match_data);
9781 }
9782 }
9783
getAllowedCarriersResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9784 int radio_1_6::getAllowedCarriersResponse(int slotId,
9785 int responseType, int serial, RIL_Errno e,
9786 void *response, size_t responseLen) {
9787 #if VDBG
9788 RLOGD("getAllowedCarriersResponse: serial %d", serial);
9789 #endif
9790 RadioResponseInfo responseInfo = {};
9791 populateResponseInfo(responseInfo, serial, responseType, e);
9792
9793 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9794 V1_4::CarrierRestrictionsWithPriority carrierInfo = {};
9795 V1_4::SimLockMultiSimPolicy multiSimPolicy =
9796 V1_4::SimLockMultiSimPolicy::NO_MULTISIM_POLICY;
9797 bool allAllowed = true;
9798
9799 if (response == NULL) {
9800 #if VDBG
9801 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
9802 #endif
9803 carrierInfo.allowedCarriers.resize(0);
9804 carrierInfo.excludedCarriers.resize(0);
9805 carrierInfo.allowedCarriersPrioritized = false;
9806 } else if (responseLen != sizeof(RIL_CarrierRestrictionsWithPriority)) {
9807 RLOGE("getAllowedCarriersResponse Invalid response");
9808 if (e == RIL_E_SUCCESS) {
9809 responseInfo.error = RadioError::INVALID_RESPONSE;
9810 }
9811 } else {
9812 RIL_CarrierRestrictionsWithPriority *pCrExt =
9813 (RIL_CarrierRestrictionsWithPriority *)response;
9814
9815 // Convert into the structure used in IRadio 1.0 to reuse existing code
9816 RIL_CarrierRestrictions cr = {};
9817 cr.len_allowed_carriers = pCrExt->len_allowed_carriers;
9818 cr.len_excluded_carriers = pCrExt->len_excluded_carriers;
9819 cr.allowed_carriers = pCrExt->allowed_carriers;
9820 cr.excluded_carriers = pCrExt->excluded_carriers;
9821 prepareCarrierRestrictionsResponse(carrierInfo.allowedCarriers,
9822 carrierInfo.excludedCarriers, allAllowed, &cr);
9823
9824 carrierInfo.allowedCarriersPrioritized = (bool)pCrExt->allowedCarriersPrioritized;
9825 multiSimPolicy = (V1_4::SimLockMultiSimPolicy)pCrExt->multiSimPolicy;
9826 }
9827
9828 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
9829 ->getAllowedCarriersResponse_1_4(responseInfo, carrierInfo, multiSimPolicy);
9830 radioService[slotId]->checkReturnStatus(retStatus);
9831 } else if (radioService[slotId]->mRadioResponse != NULL) {
9832 CarrierRestrictions carrierInfo = {};
9833 bool allAllowed = true;
9834 if (response == NULL) {
9835 #if VDBG
9836 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
9837 #endif
9838 carrierInfo.allowedCarriers.resize(0);
9839 carrierInfo.excludedCarriers.resize(0);
9840 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
9841 RLOGE("getAllowedCarriersResponse Invalid response");
9842 if (e == RIL_E_SUCCESS) {
9843 responseInfo.error = RadioError::INVALID_RESPONSE;
9844 }
9845 } else {
9846 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
9847 prepareCarrierRestrictionsResponse(carrierInfo.allowedCarriers,
9848 carrierInfo.excludedCarriers, allAllowed, pCr);
9849 }
9850
9851 Return<void> retStatus = radioService[slotId]->mRadioResponse
9852 ->getAllowedCarriersResponse(responseInfo, allAllowed, carrierInfo);
9853 radioService[slotId]->checkReturnStatus(retStatus);
9854 } else {
9855 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9856 }
9857
9858 return 0;
9859 }
9860
sendDeviceStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)9861 int radio_1_6::sendDeviceStateResponse(int slotId,
9862 int responseType, int serial, RIL_Errno e,
9863 void *response, size_t responselen) {
9864 #if VDBG
9865 RLOGD("sendDeviceStateResponse: serial %d", serial);
9866 #endif
9867
9868 if (radioService[slotId]->mRadioResponse != NULL) {
9869 RadioResponseInfo responseInfo = {};
9870 populateResponseInfo(responseInfo, serial, responseType, e);
9871 Return<void> retStatus
9872 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
9873 radioService[slotId]->checkReturnStatus(retStatus);
9874 } else {
9875 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9876 }
9877
9878 return 0;
9879 }
9880
setCarrierInfoForImsiEncryptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9881 int radio_1_6::setCarrierInfoForImsiEncryptionResponse(int slotId,
9882 int responseType, int serial, RIL_Errno e,
9883 void *response, size_t responseLen) {
9884 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
9885 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
9886 RadioResponseInfo responseInfo = {};
9887 populateResponseInfo(responseInfo, serial, responseType, e);
9888 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
9889 setCarrierInfoForImsiEncryptionResponse(responseInfo);
9890 radioService[slotId]->checkReturnStatus(retStatus);
9891 } else {
9892 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponseV1_1 == "
9893 "NULL", slotId);
9894 }
9895 return 0;
9896 }
9897
setIndicationFilterResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)9898 int radio_1_6::setIndicationFilterResponse(int slotId,
9899 int responseType, int serial, RIL_Errno e,
9900 void *response, size_t responselen) {
9901 #if VDBG
9902 RLOGD("setIndicationFilterResponse: serial %d", serial);
9903 #endif
9904 RadioResponseInfo responseInfo = {};
9905 populateResponseInfo(responseInfo, serial, responseType, e);
9906
9907 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
9908 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
9909 ->setIndicationFilterResponse_1_5(responseInfo);
9910 radioService[slotId]->checkReturnStatus(retStatus);
9911 } else if (radioService[slotId]->mRadioResponse != NULL) {
9912 Return<void> retStatus = radioService[slotId]->mRadioResponse
9913 ->setIndicationFilterResponse(responseInfo);
9914 radioService[slotId]->checkReturnStatus(retStatus);
9915 } else {
9916 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9917 }
9918
9919 return 0;
9920 }
9921
setSimCardPowerResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9922 int radio_1_6::setSimCardPowerResponse(int slotId,
9923 int responseType, int serial, RIL_Errno e,
9924 void *response, size_t responseLen) {
9925 #if VDBG
9926 RLOGD("setSimCardPowerResponse: serial %d", serial);
9927 #endif
9928
9929 if (radioService[slotId]->mRadioResponse != NULL
9930 || radioService[slotId]->mRadioResponseV1_1 != NULL
9931 || radioService[slotId]->mRadioResponseV1_6 != NULL) {
9932 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
9933 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo = {};
9934 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
9935 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6->
9936 setSimCardPowerResponse_1_6(responseInfo);
9937 radioService[slotId]->checkReturnStatus(retStatus);
9938 } else if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
9939 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_6 == NULL", slotId);
9940 RadioResponseInfo responseInfo = {};
9941 populateResponseInfo(responseInfo, serial, responseType, e);
9942 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
9943 setSimCardPowerResponse_1_1(responseInfo);
9944 radioService[slotId]->checkReturnStatus(retStatus);
9945 } else {
9946 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_6 and V1_1 == NULL",
9947 slotId);
9948 RadioResponseInfo responseInfo = {};
9949 populateResponseInfo(responseInfo, serial, responseType, e);
9950 Return<void> retStatus = radioService[slotId]->mRadioResponse
9951 ->setSimCardPowerResponse(responseInfo);
9952 radioService[slotId]->checkReturnStatus(retStatus);
9953 }
9954 } else {
9955 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL && "
9956 "radioService[%d]->mRadioResponseV1_1 and V1_6 == NULL", slotId, slotId);
9957 }
9958 return 0;
9959 }
9960
startNetworkScanResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9961 int radio_1_6::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
9962 void *response, size_t responseLen) {
9963 #if VDBG
9964 RLOGD("startNetworkScanResponse: serial %d", serial);
9965 #endif
9966
9967 if (radioService[slotId]->mRadioResponseV1_1 != NULL ||
9968 radioService[slotId]->mRadioResponseV1_2 != NULL ||
9969 radioService[slotId]->mRadioResponseV1_4 != NULL ||
9970 radioService[slotId]->mRadioResponseV1_6 != NULL) {
9971 RadioResponseInfo responseInfo = {};
9972 populateResponseInfo(responseInfo, serial, responseType, e);
9973
9974 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
9975 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
9976 ->startNetworkScanResponse_1_5(responseInfo);
9977 radioService[slotId]->checkReturnStatus(retStatus);
9978 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9979 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
9980 ->startNetworkScanResponse_1_4(responseInfo);
9981 radioService[slotId]->checkReturnStatus(retStatus);
9982 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
9983 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2
9984 ->startNetworkScanResponse(responseInfo);
9985 radioService[slotId]->checkReturnStatus(retStatus);
9986 } else if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
9987 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1
9988 ->startNetworkScanResponse(responseInfo);
9989 radioService[slotId]->checkReturnStatus(retStatus);
9990 } else {
9991 RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL or "
9992 "radioService[%d]->mRadioResponseV1_4 == NULL", slotId, slotId);
9993 }
9994 }
9995
9996 return 0;
9997 }
9998
stopNetworkScanResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9999 int radio_1_6::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
10000 void *response, size_t responseLen) {
10001 #if VDBG
10002 RLOGD("stopNetworkScanResponse: serial %d", serial);
10003 #endif
10004
10005 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
10006 RadioResponseInfo responseInfo = {};
10007 populateResponseInfo(responseInfo, serial, responseType, e);
10008 Return<void> retStatus
10009 = radioService[slotId]->mRadioResponseV1_1->stopNetworkScanResponse(responseInfo);
10010 radioService[slotId]->checkReturnStatus(retStatus);
10011 } else {
10012 RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
10013 }
10014
10015 return 0;
10016 }
10017
emergencyDialResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10018 int radio_1_6::emergencyDialResponse(int slotId, int responseType, int serial, RIL_Errno e,
10019 void *response, size_t responseLen) {
10020 #if VDBG
10021 RLOGD("emergencyDialResponse: serial %d", serial);
10022 #endif
10023
10024 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
10025 RadioResponseInfo responseInfo = {};
10026 populateResponseInfo(responseInfo, serial, responseType, e);
10027 Return<void> retStatus
10028 = radioService[slotId]->mRadioResponseV1_4->emergencyDialResponse(responseInfo);
10029 radioService[slotId]->checkReturnStatus(retStatus);
10030 } else {
10031 RLOGE("emergencyDialResponse: radioService[%d]->mRadioResponseV1_4 == NULL", slotId);
10032 }
10033 return 0;
10034 }
10035
convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus * rilStatus,V1_1::KeepaliveStatus & halStatus)10036 void convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus *rilStatus,
10037 V1_1::KeepaliveStatus& halStatus) {
10038 halStatus.sessionHandle = rilStatus->sessionHandle;
10039 halStatus.code = static_cast<V1_1::KeepaliveStatusCode>(rilStatus->code);
10040 }
10041
startKeepaliveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10042 int radio_1_6::startKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
10043 void *response, size_t responseLen) {
10044 #if VDBG
10045 RLOGD("%s(): %d", __FUNCTION__, serial);
10046 #endif
10047 RadioResponseInfo responseInfo = {};
10048 populateResponseInfo(responseInfo, serial, responseType, e);
10049
10050 // If we don't have a radio service, there's nothing we can do
10051 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
10052 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
10053 return 0;
10054 }
10055
10056 V1_1::KeepaliveStatus ks = {};
10057 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
10058 RLOGE("%s: invalid response - %d", __FUNCTION__, static_cast<int>(e));
10059 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
10060 } else {
10061 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
10062 }
10063
10064 Return<void> retStatus =
10065 radioService[slotId]->mRadioResponseV1_1->startKeepaliveResponse(responseInfo, ks);
10066 radioService[slotId]->checkReturnStatus(retStatus);
10067 return 0;
10068 }
10069
stopKeepaliveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10070 int radio_1_6::stopKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
10071 void *response, size_t responseLen) {
10072 #if VDBG
10073 RLOGD("%s(): %d", __FUNCTION__, serial);
10074 #endif
10075 RadioResponseInfo responseInfo = {};
10076 populateResponseInfo(responseInfo, serial, responseType, e);
10077
10078 // If we don't have a radio service, there's nothing we can do
10079 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
10080 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
10081 return 0;
10082 }
10083
10084 Return<void> retStatus =
10085 radioService[slotId]->mRadioResponseV1_1->stopKeepaliveResponse(responseInfo);
10086 radioService[slotId]->checkReturnStatus(retStatus);
10087 return 0;
10088 }
10089
getModemStackStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10090 int radio_1_6::getModemStackStatusResponse(int slotId, int responseType, int serial, RIL_Errno e,
10091 void *response, size_t responseLen) {
10092 #if VDBG
10093 RLOGD("%s(): %d", __FUNCTION__, serial);
10094 #endif
10095 RadioResponseInfo responseInfo = {};
10096 populateResponseInfo(responseInfo, serial, responseType, e);
10097
10098 // If we don't have a radio service, there's nothing we can do
10099 if (radioService[slotId]->mRadioResponseV1_3 == NULL) {
10100 RLOGE("%s: radioService[%d]->mRadioResponseV1_3 == NULL", __FUNCTION__, slotId);
10101 return 0;
10102 }
10103
10104 Return<void> retStatus =
10105 radioService[slotId]->mRadioResponseV1_3->getModemStackStatusResponse(
10106 responseInfo, true);
10107 radioService[slotId]->checkReturnStatus(retStatus);
10108 return 0;
10109 }
10110
enableModemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10111 int radio_1_6::enableModemResponse(int slotId, int responseType, int serial, RIL_Errno e,
10112 void *response, size_t responseLen) {
10113 #if VDBG
10114 RLOGD("%s(): %d", __FUNCTION__, serial);
10115 #endif
10116 RadioResponseInfo responseInfo = {};
10117 populateResponseInfo(responseInfo, serial, responseType, e);
10118
10119 // If we don't have a radio service, there's nothing we can do
10120 if (radioService[slotId]->mRadioResponseV1_3 == NULL) {
10121 RLOGE("%s: radioService[%d]->mRadioResponseV1_3 == NULL", __FUNCTION__, slotId);
10122 return 0;
10123 }
10124
10125 Return<void> retStatus =
10126 radioService[slotId]->mRadioResponseV1_3->enableModemResponse(responseInfo);
10127 radioService[slotId]->checkReturnStatus(retStatus);
10128 return 0;
10129 }
10130
sendRequestRawResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10131 int radio_1_6::sendRequestRawResponse(int slotId,
10132 int responseType, int serial, RIL_Errno e,
10133 void *response, size_t responseLen) {
10134 #if VDBG
10135 RLOGD("sendRequestRawResponse: serial %d", serial);
10136 #endif
10137
10138 if (!kOemHookEnabled) return 0;
10139
10140 if (oemHookService[slotId]->mOemHookResponse != NULL) {
10141 RadioResponseInfo responseInfo = {};
10142 populateResponseInfo(responseInfo, serial, responseType, e);
10143 hidl_vec<uint8_t> data;
10144
10145 if (response == NULL) {
10146 RLOGE("sendRequestRawResponse: Invalid response");
10147 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
10148 } else {
10149 data.setToExternal((uint8_t *) response, responseLen);
10150 }
10151 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
10152 sendRequestRawResponse(responseInfo, data);
10153 checkReturnStatus(slotId, retStatus, false);
10154 } else {
10155 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
10156 slotId);
10157 }
10158
10159 return 0;
10160 }
10161
sendRequestStringsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10162 int radio_1_6::sendRequestStringsResponse(int slotId,
10163 int responseType, int serial, RIL_Errno e,
10164 void *response, size_t responseLen) {
10165 #if VDBG
10166 RLOGD("sendRequestStringsResponse: serial %d", serial);
10167 #endif
10168
10169 if (!kOemHookEnabled) return 0;
10170
10171 if (oemHookService[slotId]->mOemHookResponse != NULL) {
10172 RadioResponseInfo responseInfo = {};
10173 populateResponseInfo(responseInfo, serial, responseType, e);
10174 hidl_vec<hidl_string> data;
10175
10176 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
10177 RLOGE("sendRequestStringsResponse Invalid response: NULL");
10178 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
10179 } else {
10180 char **resp = (char **) response;
10181 int numStrings = responseLen / sizeof(char *);
10182 data.resize(numStrings);
10183 for (int i = 0; i < numStrings; i++) {
10184 data[i] = convertCharPtrToHidlString(resp[i]);
10185 }
10186 }
10187 Return<void> retStatus
10188 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
10189 responseInfo, data);
10190 checkReturnStatus(slotId, retStatus, false);
10191 } else {
10192 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
10193 "NULL", slotId);
10194 }
10195
10196 return 0;
10197 }
10198
setSystemSelectionChannelsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10199 int radio_1_6::setSystemSelectionChannelsResponse(int slotId, int responseType, int serial,
10200 RIL_Errno e, void* response, size_t responseLen) {
10201 #if VDBG
10202 RLOGD("setSystemSelectionChannelsResponse: serial %d", serial);
10203 #endif
10204 RadioResponseInfo responseInfo = {};
10205 populateResponseInfo(responseInfo, serial, responseType, e);
10206
10207 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10208 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10209 ->setSystemSelectionChannelsResponse_1_5(responseInfo);
10210 radioService[slotId]->checkReturnStatus(retStatus);
10211 } else if (radioService[slotId]->mRadioResponseV1_3 != NULL) {
10212 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_3
10213 ->setSystemSelectionChannelsResponse(responseInfo);
10214 radioService[slotId]->checkReturnStatus(retStatus);
10215 } else {
10216 RLOGE("setSystemSelectionChannelsResponse: radioService[%d]->mRadioResponse == NULL",
10217 slotId);
10218 }
10219
10220 return 0;
10221 }
10222
getSystemSelectionChannelsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10223 int radio_1_6::getSystemSelectionChannelsResponse(int slotId, int responseType, int serial,
10224 RIL_Errno e, void* response, size_t responseLen) {
10225 #if VDBG
10226 RLOGD("getSystemSelectionChannelsResponse: serial %d", serial);
10227 #endif
10228 V1_6::RadioResponseInfo responseInfo = {};
10229 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10230
10231 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10232 hidl_vec<::android::hardware::radio::V1_5::RadioAccessSpecifier> ret;
10233 Return<void> retStatus =
10234 radioService[slotId]
10235 ->mRadioResponseV1_6->getSystemSelectionChannelsResponse(
10236 responseInfo, ret);
10237 radioService[slotId]->checkReturnStatus(retStatus);
10238 } else {
10239 RLOGE("getSystemSelectionChannelsResponse: radioService[%d]->mRadioResponse == NULL",
10240 slotId);
10241 }
10242
10243 return 0;
10244 }
10245
setSignalStrengthReportingCriteriaResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10246 int radio_1_6::setSignalStrengthReportingCriteriaResponse(int slotId, int responseType, int serial,
10247 RIL_Errno e, void* response, size_t responseLen) {
10248 #if VDBG
10249 RLOGD("setSignalStrengthReportingCriteriaResponse: serial %d", serial);
10250 #endif
10251 RadioResponseInfo responseInfo = {};
10252 populateResponseInfo(responseInfo, serial, responseType, e);
10253
10254 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10255 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10256 ->setSignalStrengthReportingCriteriaResponse_1_5(responseInfo);
10257 radioService[slotId]->checkReturnStatus(retStatus);
10258 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
10259 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2
10260 ->setSignalStrengthReportingCriteriaResponse(responseInfo);
10261 radioService[slotId]->checkReturnStatus(retStatus);
10262 } else {
10263 RLOGE("setSignalStrengthReportingCriteriaResponse: radioService[%d]->mRadioResponse "
10264 "== NULL", slotId);
10265 }
10266
10267 return 0;
10268 }
10269
setLinkCapacityReportingCriteriaResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10270 int radio_1_6::setLinkCapacityReportingCriteriaResponse(int slotId, int responseType, int serial,
10271 RIL_Errno e, void* response, size_t responseLen) {
10272 #if VDBG
10273 RLOGD("setLinkCapacityReportingCriteriaResponse: serial %d", serial);
10274 #endif
10275 RadioResponseInfo responseInfo = {};
10276 populateResponseInfo(responseInfo, serial, responseType, e);
10277
10278 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10279 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10280 ->setLinkCapacityReportingCriteriaResponse_1_5(responseInfo);
10281 radioService[slotId]->checkReturnStatus(retStatus);
10282 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
10283 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2
10284 ->setLinkCapacityReportingCriteriaResponse(responseInfo);
10285 radioService[slotId]->checkReturnStatus(retStatus);
10286 } else {
10287 RLOGE("setLinkCapacityReportingCriteriaResponse: radioService[%d]->mRadioResponse "
10288 "== NULL", slotId);
10289 }
10290
10291 return 0;
10292 }
10293
enableUiccApplicationsResponse(int slotId,int responseType,int serial,RIL_Errno e,void *,size_t responseLen)10294 int radio_1_6::enableUiccApplicationsResponse(int slotId, int responseType, int serial,
10295 RIL_Errno e, void* /* response */, size_t responseLen) {
10296 #if VDBG
10297 RLOGD("%s(): %d", __FUNCTION__, serial);
10298 #endif
10299 RadioResponseInfo responseInfo = {};
10300 populateResponseInfo(responseInfo, serial, responseType, e);
10301
10302 // If we don't have a radio service, there's nothing we can do
10303 if (radioService[slotId]->mRadioResponseV1_5 == NULL) {
10304 RLOGE("%s: radioService[%d]->mRadioResponseV1_5 == NULL", __FUNCTION__, slotId);
10305 return 0;
10306 }
10307
10308 Return<void> retStatus =
10309 radioService[slotId]->mRadioResponseV1_5->enableUiccApplicationsResponse(
10310 responseInfo);
10311 radioService[slotId]->checkReturnStatus(retStatus);
10312 return 0;
10313 }
10314
areUiccApplicationsEnabledResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10315 int radio_1_6::areUiccApplicationsEnabledResponse(int slotId, int responseType, int serial,
10316 RIL_Errno e, void* response, size_t responseLen) {
10317 #if VDBG
10318 RLOGD("%s(): %d", __FUNCTION__, serial);
10319 #endif
10320 RadioResponseInfo responseInfo = {};
10321 populateResponseInfo(responseInfo, serial, responseType, e);
10322
10323 // If we don't have a radio service, there's nothing we can do
10324 if (radioService[slotId]->mRadioResponseV1_5 == NULL) {
10325 RLOGE("%s: radioService[%d]->mRadioResponseV1_5 == NULL", __FUNCTION__, slotId);
10326 return 0;
10327 }
10328
10329 bool enable = false;
10330 if (response == NULL || responseLen != sizeof(bool)) {
10331 RLOGE("isSimDetachedFromNetwork Invalid response.");
10332 } else {
10333 enable = (*((bool *) response));
10334 }
10335
10336 Return<void> retStatus =
10337 radioService[slotId]->mRadioResponseV1_5->areUiccApplicationsEnabledResponse(
10338 responseInfo, enable);
10339 radioService[slotId]->checkReturnStatus(retStatus);
10340 return 0;
10341 }
10342
getBarringInfoResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)10343 int radio_1_6::getBarringInfoResponse(int slotId,
10344 int responseType, int serial, RIL_Errno e,
10345 void *response, size_t responselen) {
10346 #if VDBG
10347 RLOGD("getBarringInfoResponse: serial %d", serial);
10348 #endif
10349
10350 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10351 RadioResponseInfo responseInfo = {};
10352 populateResponseInfo(responseInfo, serial, responseType, e);
10353 ::android::hardware::radio::V1_5::CellIdentity cellIdentity;
10354 hidl_vec<::android::hardware::radio::V1_5::BarringInfo> barringInfos = {};
10355
10356 if (response == NULL) { /* data for vts */
10357 V1_5::BarringInfo barringInfo = {};
10358 barringInfo.serviceType = V1_5::BarringInfo::ServiceType::CS_SERVICE;
10359 barringInfo.barringType = V1_5::BarringInfo::BarringType::NONE;
10360
10361 V1_5::CellIdentityLte cellIdentityLte = {};
10362 cellIdentity.lte(cellIdentityLte);
10363 barringInfos.resize(1);
10364 barringInfos[0] = barringInfo;
10365
10366 Return<void> retStatus
10367 = radioService[slotId]->mRadioResponseV1_5->
10368 getBarringInfoResponse(responseInfo, cellIdentity, barringInfos);
10369 radioService[slotId]->checkReturnStatus(retStatus);
10370 } else {
10371 RLOGE("getBarringInfoResponse: radioService[%d]->mRadioResponse == NULL",
10372 slotId);
10373 }
10374 }
10375 return 0;
10376 }
10377
sendCdmaSmsExpectMoreResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10378 int radio_1_6::sendCdmaSmsExpectMoreResponse(int slotId, int responseType, int serial, RIL_Errno e,
10379 void *response, size_t responseLen) {
10380 #if VDBG
10381 RLOGD("sendCdmaSmsExpectMoreResponse: serial %d", serial);
10382 #endif
10383
10384 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10385 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
10386 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e,
10387 response, responseLen);
10388
10389 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
10390 ->sendCdmaSmsExpectMoreResponse_1_6(responseInfo_1_6, result);
10391 radioService[slotId]->checkReturnStatus(retStatus);
10392 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10393 RadioResponseInfo responseInfo = {};
10394 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
10395 responseLen);
10396
10397 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10398 ->sendCdmaSmsExpectMoreResponse(responseInfo, result);
10399 radioService[slotId]->checkReturnStatus(retStatus);
10400 } else {
10401 RLOGE("sendCdmaSmsExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10402 }
10403
10404 return 0;
10405 }
10406
supplySimDepersonalizationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10407 int radio_1_6::supplySimDepersonalizationResponse(int slotId, int responseType, int serial,
10408 RIL_Errno e, void *response, size_t responseLen) {
10409 #if VDBG
10410 RLOGD("supplySimDepersonalizationResponse: serial %d", serial);
10411 #endif
10412
10413 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10414 RadioResponseInfo responseInfo = {};
10415 int persoType = -1, remainingRetries = -1;
10416 int numInts = responseLen / sizeof(int);
10417 if (response == NULL || numInts != 2) {
10418 RLOGE("getClirResponse Invalid response: NULL");
10419 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
10420 } else {
10421 int *pInt = (int *) response;
10422 persoType = pInt[0];
10423 remainingRetries = pInt[1];
10424 }
10425 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10426 ->supplySimDepersonalizationResponse(responseInfo, (V1_5::PersoSubstate) persoType,
10427 remainingRetries);
10428 radioService[slotId]->checkReturnStatus(retStatus);
10429 } else {
10430 RLOGE("supplySimDepersonalizationResponse: radioService[%d]->mRadioResponseV1_5 == "
10431 "NULL", slotId);
10432 }
10433
10434 return 0;
10435 }
10436
setNrDualConnectivityStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void *,size_t responseLen)10437 int radio_1_6::setNrDualConnectivityStateResponse(int slotId, int responseType, int serial,
10438 RIL_Errno e, void* /* response */, size_t responseLen) {
10439 #if VDBG
10440 RLOGD("%s(): %d", __FUNCTION__, serial);
10441 #endif
10442 V1_6::RadioResponseInfo responseInfo = {};
10443 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10444
10445 // If we don't have a radio service, there's nothing we can do
10446 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10447 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10448 return 0;
10449 }
10450
10451 Return<void> retStatus =
10452 radioService[slotId]->mRadioResponseV1_6->setNrDualConnectivityStateResponse(
10453 responseInfo);
10454 radioService[slotId]->checkReturnStatus(retStatus);
10455 return 0;
10456 }
10457
isNrDualConnectivityEnabledResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10458 int radio_1_6::isNrDualConnectivityEnabledResponse(int slotId, int responseType, int serial,
10459 RIL_Errno e, void* response, size_t responseLen) {
10460 #if VDBG
10461 RLOGD("%s(): %d", __FUNCTION__, serial);
10462 #endif
10463 V1_6::RadioResponseInfo responseInfo = {};
10464 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10465
10466 // If we don't have a radio service, there's nothing we can do
10467 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10468 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10469 return 0;
10470 }
10471
10472 bool enable = false;
10473 if (response == NULL || responseLen != sizeof(bool)) {
10474 RLOGE("isNrDualConnectivityEnabledResponseInvalid response.");
10475 } else {
10476 enable = (*((bool *) response));
10477 }
10478
10479 Return<void> retStatus =
10480 radioService[slotId]->mRadioResponseV1_6->isNrDualConnectivityEnabledResponse(
10481 responseInfo, enable);
10482 radioService[slotId]->checkReturnStatus(retStatus);
10483 return 0;
10484 }
10485
allocatePduSessionIdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10486 int radio_1_6::allocatePduSessionIdResponse(int slotId, int responseType, int serial,
10487 RIL_Errno e, void* response, size_t responseLen) {
10488 #if VDBG
10489 RLOGD("%s(): %d", __FUNCTION__, serial);
10490 #endif
10491 // If we don't have a radio service, there's nothing we can do
10492 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10493 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10494 return 0;
10495 }
10496 V1_6::RadioResponseInfo responseInfo = {};
10497 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10498
10499 Return<void> retStatus =
10500 radioService[slotId]->mRadioResponseV1_6->allocatePduSessionIdResponse(responseInfo, -1);
10501 radioService[slotId]->checkReturnStatus(retStatus);
10502 return 0;
10503 }
10504
releasePduSessionIdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10505 int radio_1_6::releasePduSessionIdResponse(int slotId, int responseType, int serial,
10506 RIL_Errno e, void* response, size_t responseLen) {
10507 #if VDBG
10508 RLOGD("%s(): %d", __FUNCTION__, serial);
10509 #endif
10510 // If we don't have a radio service, there's nothing we can do
10511 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10512 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10513 return 0;
10514 }
10515
10516 V1_6::RadioResponseInfo responseInfo = {};
10517 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10518
10519 Return<void> retStatus =
10520 radioService[slotId]->mRadioResponseV1_6->releasePduSessionIdResponse(responseInfo);
10521 radioService[slotId]->checkReturnStatus(retStatus);
10522 return 0;
10523 }
10524
startHandoverResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10525 int radio_1_6::startHandoverResponse(int slotId, int responseType, int serial,
10526 RIL_Errno e, void* response, size_t responseLen) {
10527 // If we don't have a radio service, there's nothing we can do
10528 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10529 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10530 return 0;
10531 }
10532 V1_6::RadioResponseInfo responseInfo = {};
10533 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10534
10535 Return<void> retStatus =
10536 radioService[slotId]->mRadioResponseV1_6->startHandoverResponse(responseInfo);
10537
10538 #if VDBG
10539 RLOGD("%s(): %d", __FUNCTION__, serial);
10540 #endif
10541 return 0;
10542 }
10543
cancelHandoverResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10544 int radio_1_6::cancelHandoverResponse(int slotId, int responseType, int serial,
10545 RIL_Errno e, void* response, size_t responseLen) {
10546 // If we don't have a radio service, there's nothing we can do
10547 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10548 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10549 return 0;
10550 }
10551 V1_6::RadioResponseInfo responseInfo = {};
10552 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10553
10554 Return<void> retStatus =
10555 radioService[slotId]->mRadioResponseV1_6->cancelHandoverResponse(responseInfo);
10556
10557 #if VDBG
10558 RLOGD("%s(): %d", __FUNCTION__, serial);
10559 #endif
10560 return 0;
10561 }
10562
10563
setDataThrottlingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)10564 int radio_1_6::setDataThrottlingResponse(int slotId, int responseType,
10565 int serial, RIL_Errno e, void *response, size_t responselen) {
10566 #if VDBG
10567 RLOGD("setDataThrottlingResponse: serial %d", serial);
10568 #endif
10569
10570 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10571 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10572 return 0;
10573 }
10574
10575 V1_6::RadioResponseInfo responseInfo = {};
10576 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10577
10578
10579 Return<void> retstatus =
10580 radioService[slotId]->mRadioResponseV1_6->setDataThrottlingResponse(
10581 responseInfo);
10582 radioService[slotId]->checkReturnStatus(retstatus);
10583 return 0;
10584 }
10585
getSlicingConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10586 int radio_1_6::getSlicingConfigResponse(int slotId, int responseType, int serial,
10587 RIL_Errno e, void* response, size_t responseLen) {
10588 #if VDBG
10589 RLOGD("getSlicingConfigResponse: serial %d", serial);
10590 #endif
10591
10592 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10593 V1_6::RadioResponseInfo responseInfo = {};
10594 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10595
10596 V1_6::SlicingConfig slicingConfig = {};
10597 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6->
10598 getSlicingConfigResponse(responseInfo, slicingConfig);
10599 radioService[slotId]->checkReturnStatus(retStatus);
10600 } else {
10601 RLOGE("getSlicingConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10602 }
10603
10604 return 0;
10605 }
10606
getSimPhonebookRecordsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10607 int radio_1_6::getSimPhonebookRecordsResponse(int slotId, int responseType, int serial,
10608 RIL_Errno e, void *response, size_t responseLen) {
10609 #if VDBG
10610 RLOGD("getSimPhonebookRecordsResponse: serial %d", serial);
10611 #endif
10612
10613 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10614 V1_6::RadioResponseInfo responseInfo = {};
10615 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10616
10617 Return<void> retStatus =
10618 radioService[slotId]->mRadioResponseV1_6->getSimPhonebookRecordsResponse(
10619 responseInfo);
10620 radioService[slotId]->checkReturnStatus(retStatus);
10621 } else {
10622 RLOGE("getSimPhonebookRecordsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10623 }
10624
10625 return 0;
10626 }
10627
getSimPhonebookCapacityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10628 int radio_1_6::getSimPhonebookCapacityResponse(int slotId, int responseType, int serial,
10629 RIL_Errno e, void *response, size_t responseLen) {
10630 #if VDBG
10631 RLOGD("getSimPhonebookCapacityResponse: serial %d", serial);
10632 #endif
10633
10634 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10635 V1_6::RadioResponseInfo responseInfo = {};
10636 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10637
10638 V1_6::PhonebookCapacity phonebookCapacity = {};
10639 Return<void> retStatus =
10640 radioService[slotId]->mRadioResponseV1_6->getSimPhonebookCapacityResponse(
10641 responseInfo, phonebookCapacity);
10642 radioService[slotId]->checkReturnStatus(retStatus);
10643 } else {
10644 RLOGE("getSimPhonebookCapacityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10645 }
10646
10647 return 0;
10648 }
10649
updateSimPhonebookRecordsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10650 int radio_1_6::updateSimPhonebookRecordsResponse(int slotId, int responseType, int serial,
10651 RIL_Errno e, void *response, size_t responseLen) {
10652 #if VDBG
10653 RLOGD("updateSimPhonebookRecordsResponse: serial %d", serial);
10654 #endif
10655
10656 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10657 V1_6::RadioResponseInfo responseInfo = {};
10658 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10659
10660 int32_t updatedRecordIndex = 0;
10661 Return<void> retStatus =
10662 radioService[slotId]->mRadioResponseV1_6->updateSimPhonebookRecordsResponse(
10663 responseInfo, updatedRecordIndex);
10664 radioService[slotId]->checkReturnStatus(retStatus);
10665 } else {
10666 RLOGE("updateSimPhonebookRecordsResponse: radioService[%d]->mRadioResponse == NULL",
10667 slotId);
10668 }
10669
10670 return 0;
10671 }
10672
10673 /***************************************************************************************************
10674 * INDICATION FUNCTIONS
10675 * The below function handle unsolicited messages coming from the Radio
10676 * (messages for which there is no pending request)
10677 **************************************************************************************************/
10678
convertIntToRadioIndicationType(int indicationType)10679 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
10680 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
10681 (RadioIndicationType::UNSOLICITED_ACK_EXP);
10682 }
10683
radioStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10684 int radio_1_6::radioStateChangedInd(int slotId,
10685 int indicationType, int token, RIL_Errno e, void *response,
10686 size_t responseLen) {
10687 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10688 RadioState radioState =
10689 (RadioState) CALL_ONSTATEREQUEST(slotId);
10690 RLOGD("radioStateChangedInd: radioState %d", radioState);
10691 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
10692 convertIntToRadioIndicationType(indicationType), radioState);
10693 radioService[slotId]->checkReturnStatus(retStatus);
10694 } else {
10695 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
10696 }
10697
10698 return 0;
10699 }
10700
callStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10701 int radio_1_6::callStateChangedInd(int slotId,
10702 int indicationType, int token, RIL_Errno e, void *response,
10703 size_t responseLen) {
10704 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10705 #if VDBG
10706 RLOGD("callStateChangedInd");
10707 #endif
10708 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
10709 convertIntToRadioIndicationType(indicationType));
10710 radioService[slotId]->checkReturnStatus(retStatus);
10711 } else {
10712 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
10713 }
10714
10715 return 0;
10716 }
10717
networkStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10718 int radio_1_6::networkStateChangedInd(int slotId,
10719 int indicationType, int token, RIL_Errno e, void *response,
10720 size_t responseLen) {
10721 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10722 #if VDBG
10723 RLOGD("networkStateChangedInd");
10724 #endif
10725 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
10726 convertIntToRadioIndicationType(indicationType));
10727 radioService[slotId]->checkReturnStatus(retStatus);
10728 } else {
10729 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
10730 slotId);
10731 }
10732
10733 return 0;
10734 }
10735
cellularIdentifierDisclosedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responselen)10736 int radio_aidl::cellularIdentifierDisclosedInd(int slotId, int indicationType, int token,
10737 RIL_Errno e, void* response, size_t responselen) {
10738 if (radioService[slotId] == NULL || radioService[slotId]->mCallbackManager == NULL) {
10739 RLOGE("cellularIdentifierDisclosedInd: radioService[%d]->mCallbackManager == NULL", slotId);
10740 return 0;
10741 }
10742 auto networkCb = radioService[slotId]->mCallbackManager->indication().networkCb();
10743
10744 if (!networkCb) {
10745 RLOGE("networkCB is null");
10746 return 0;
10747 }
10748
10749 RIL_CellularIdentifierDisclosure* rawDisclosure =
10750 static_cast<RIL_CellularIdentifierDisclosure*>(response);
10751
10752 aidl_radio::network::CellularIdentifierDisclosure disclosure;
10753 disclosure.identifier =
10754 static_cast<aidl_radio::network::CellularIdentifier>(rawDisclosure->identifierType);
10755 disclosure.protocolMessage =
10756 static_cast<aidl_radio::network::NasProtocolMessage>(rawDisclosure->protocolMessage);
10757 disclosure.plmn = rawDisclosure->plmn;
10758 disclosure.isEmergency = rawDisclosure->isEmergency;
10759
10760 networkCb->cellularIdentifierDisclosed(aidl_radio::RadioIndicationType(indicationType),
10761 disclosure);
10762
10763 return 0;
10764 }
10765
securityAlgorithmUpdatedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responselen)10766 int radio_aidl::securityAlgorithmUpdatedInd(int slotId, int indicationType, int token, RIL_Errno e,
10767 void* response, size_t responselen) {
10768 if (radioService[slotId] == NULL || radioService[slotId]->mCallbackManager == NULL) {
10769 RLOGE("securityAlgorithmUpdatedInd: radioService[%d]->mCallbackManager == NULL", slotId);
10770 return 0;
10771 }
10772 auto networkCb = radioService[slotId]->mCallbackManager->indication().networkCb();
10773
10774 if (!networkCb) {
10775 RLOGE("networkCB is null");
10776 return 0;
10777 }
10778
10779 RIL_SecurityAlgorithmUpdate* rawUpdate = static_cast<RIL_SecurityAlgorithmUpdate*>(response);
10780
10781 aidl_radio::network::SecurityAlgorithmUpdate update;
10782 update.connectionEvent =
10783 static_cast<aidl_radio::network::ConnectionEvent>(rawUpdate->connectionEvent);
10784 update.encryption = static_cast<aidl_radio::network::SecurityAlgorithm>(rawUpdate->encryption);
10785 update.integrity = static_cast<aidl_radio::network::SecurityAlgorithm>(rawUpdate->integrity);
10786 update.isUnprotectedEmergency = rawUpdate->isUnprotectedEmergency;
10787
10788 networkCb->securityAlgorithmsUpdated(aidl_radio::RadioIndicationType(indicationType), update);
10789
10790 return 0;
10791 }
10792
hexCharToInt(uint8_t c)10793 extern "C" uint8_t hexCharToInt(uint8_t c) {
10794 if (c >= '0' && c <= '9') return (c - '0');
10795 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
10796 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
10797
10798 return INVALID_HEX_CHAR;
10799 }
10800
convertHexStringToBytes(void * response,size_t responseLen)10801 extern "C" uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
10802 if (responseLen % 2 != 0) {
10803 return NULL;
10804 }
10805
10806 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
10807 if (bytes == NULL) {
10808 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
10809 return NULL;
10810 }
10811 uint8_t *hexString = (uint8_t *)response;
10812
10813 for (size_t i = 0; i < responseLen; i += 2) {
10814 uint8_t hexChar1 = hexCharToInt(hexString[i]);
10815 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
10816
10817 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
10818 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
10819 hexString[i], hexString[i + 1]);
10820 free(bytes);
10821 return NULL;
10822 }
10823 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
10824 }
10825
10826 return bytes;
10827 }
10828
newSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10829 int radio_1_6::newSmsInd(int slotId, int indicationType,
10830 int token, RIL_Errno e, void *response, size_t responseLen) {
10831 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10832 if (response == NULL || responseLen == 0) {
10833 RLOGE("newSmsInd: invalid response");
10834 return 0;
10835 }
10836
10837 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
10838 if (bytes == NULL) {
10839 RLOGE("newSmsInd: convertHexStringToBytes failed");
10840 return 0;
10841 }
10842
10843 hidl_vec<uint8_t> pdu;
10844 pdu.setToExternal(bytes, responseLen/2);
10845 #if VDBG
10846 RLOGD("newSmsInd");
10847 #endif
10848 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
10849 convertIntToRadioIndicationType(indicationType), pdu);
10850 radioService[slotId]->checkReturnStatus(retStatus);
10851 free(bytes);
10852 } else {
10853 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
10854 }
10855
10856 return 0;
10857 }
10858
newSmsStatusReportInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10859 int radio_1_6::newSmsStatusReportInd(int slotId,
10860 int indicationType, int token, RIL_Errno e, void *response,
10861 size_t responseLen) {
10862 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10863 if (response == NULL || responseLen == 0) {
10864 RLOGE("newSmsStatusReportInd: invalid response");
10865 return 0;
10866 }
10867
10868 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
10869 if (bytes == NULL) {
10870 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
10871 return 0;
10872 }
10873
10874 hidl_vec<uint8_t> pdu;
10875 pdu.setToExternal(bytes, responseLen/2);
10876 #if VDBG
10877 RLOGD("newSmsStatusReportInd");
10878 #endif
10879 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
10880 convertIntToRadioIndicationType(indicationType), pdu);
10881 radioService[slotId]->checkReturnStatus(retStatus);
10882 free(bytes);
10883 } else {
10884 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
10885 }
10886
10887 return 0;
10888 }
10889
newSmsOnSimInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10890 int radio_1_6::newSmsOnSimInd(int slotId, int indicationType,
10891 int token, RIL_Errno e, void *response, size_t responseLen) {
10892 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10893 if (response == NULL || responseLen != sizeof(int)) {
10894 RLOGE("newSmsOnSimInd: invalid response");
10895 return 0;
10896 }
10897 int32_t recordNumber = ((int32_t *) response)[0];
10898 #if VDBG
10899 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
10900 #endif
10901 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
10902 convertIntToRadioIndicationType(indicationType), recordNumber);
10903 radioService[slotId]->checkReturnStatus(retStatus);
10904 } else {
10905 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
10906 }
10907
10908 return 0;
10909 }
10910
onUssdInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10911 int radio_1_6::onUssdInd(int slotId, int indicationType,
10912 int token, RIL_Errno e, void *response, size_t responseLen) {
10913 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10914 if (response == NULL || responseLen != 2 * sizeof(char *)) {
10915 RLOGE("onUssdInd: invalid response");
10916 return 0;
10917 }
10918 char **strings = (char **) response;
10919 char *mode = strings[0];
10920 hidl_string msg = convertCharPtrToHidlString(strings[1]);
10921 UssdModeType modeType = (UssdModeType) atoi(mode);
10922 #if VDBG
10923 RLOGD("onUssdInd: mode %s", mode);
10924 #endif
10925 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
10926 convertIntToRadioIndicationType(indicationType), modeType, msg);
10927 radioService[slotId]->checkReturnStatus(retStatus);
10928 } else {
10929 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
10930 }
10931
10932 return 0;
10933 }
10934
nitzTimeReceivedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10935 int radio_1_6::nitzTimeReceivedInd(int slotId,
10936 int indicationType, int token, RIL_Errno e, void *response,
10937 size_t responseLen) {
10938 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10939 if (response == NULL || responseLen == 0) {
10940 RLOGE("nitzTimeReceivedInd: invalid response");
10941 return 0;
10942 }
10943 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
10944 #if VDBG
10945 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
10946 nitzTimeReceived[slotId]);
10947 #endif
10948 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
10949 convertIntToRadioIndicationType(indicationType), nitzTime,
10950 nitzTimeReceived[slotId]);
10951 radioService[slotId]->checkReturnStatus(retStatus);
10952 } else {
10953 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
10954 return -1;
10955 }
10956
10957 return 0;
10958 }
10959
convertRilSignalStrengthToHal(void * response,size_t responseLen,SignalStrength & signalStrength)10960 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
10961 SignalStrength& signalStrength) {
10962 RIL_SignalStrength_v12 *rilSignalStrength = (RIL_SignalStrength_v12 *) response;
10963
10964 // Fixup LTE for backwards compatibility
10965 // signalStrength: -1 -> 99
10966 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
10967 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
10968 }
10969 // rsrp: -1 -> INT_MAX all other negative value to positive.
10970 // So remap here
10971 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
10972 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
10973 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
10974 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
10975 }
10976 // rsrq: -1 -> INT_MAX
10977 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
10978 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
10979 }
10980 // Not remapping rssnr is already using INT_MAX
10981 // cqi: -1 -> INT_MAX
10982 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
10983 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
10984 }
10985
10986 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
10987 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
10988 // RIL_SignalStrength_v10 not support gw.timingAdvance. Set to INT_MAX as
10989 // invalid value.
10990 signalStrength.gw.timingAdvance = INT_MAX;
10991
10992 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
10993 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
10994 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
10995 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
10996 signalStrength.evdo.signalNoiseRatio =
10997 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
10998 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
10999 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
11000 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
11001 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
11002 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
11003 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
11004 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
11005 }
11006
convertRilSignalStrengthToHal_1_2(void * response,size_t responseLen,V1_2::SignalStrength & signalStrength_1_2)11007 void convertRilSignalStrengthToHal_1_2(void* response, size_t responseLen,
11008 V1_2::SignalStrength& signalStrength_1_2) {
11009 SignalStrength signalStrength = {};
11010 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
11011 signalStrength_1_2.gsm = signalStrength.gw;
11012 signalStrength_1_2.cdma = signalStrength.cdma;
11013 signalStrength_1_2.evdo = signalStrength.evdo;
11014 signalStrength_1_2.lte = signalStrength.lte;
11015
11016 RIL_SignalStrength_v12* rilSignalStrength = (RIL_SignalStrength_v12*)response;
11017 signalStrength_1_2.wcdma.base.signalStrength =
11018 rilSignalStrength->WCDMA_SignalStrength.signalStrength;
11019 signalStrength_1_2.wcdma.base.bitErrorRate =
11020 rilSignalStrength->WCDMA_SignalStrength.bitErrorRate;
11021 signalStrength_1_2.wcdma.rscp = INT_MAX;
11022 signalStrength_1_2.wcdma.ecno = INT_MAX;
11023
11024 signalStrength_1_2.tdScdma.rscp = INT_MAX;
11025 }
11026
convertRilSignalStrengthToHal_1_4(void * response,size_t responseLen,V1_4::SignalStrength & signalStrength_1_4)11027 void convertRilSignalStrengthToHal_1_4(void *response, size_t responseLen,
11028 V1_4::SignalStrength& signalStrength_1_4) {
11029 SignalStrength signalStrength = {};
11030 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
11031 signalStrength_1_4.gsm = signalStrength.gw;
11032 signalStrength_1_4.cdma = signalStrength.cdma;
11033 signalStrength_1_4.evdo = signalStrength.evdo;
11034 signalStrength_1_4.lte = signalStrength.lte;
11035
11036 RIL_SignalStrength_v12 *rilSignalStrength = (RIL_SignalStrength_v12 *) response;
11037 signalStrength_1_4.wcdma.base.signalStrength =
11038 rilSignalStrength->WCDMA_SignalStrength.signalStrength;
11039 signalStrength_1_4.wcdma.base.bitErrorRate =
11040 rilSignalStrength->WCDMA_SignalStrength.bitErrorRate;
11041 signalStrength_1_4.wcdma.rscp = INT_MAX;
11042 signalStrength_1_4.wcdma.ecno = INT_MAX;
11043
11044 signalStrength_1_4.tdscdma.signalStrength = INT_MAX;
11045 signalStrength_1_4.tdscdma.bitErrorRate = INT_MAX;
11046 signalStrength_1_4.tdscdma.rscp = INT_MAX;
11047
11048 signalStrength_1_4.nr.ssRsrp = rilSignalStrength->NR_SignalStrength.ssRsrp;
11049 signalStrength_1_4.nr.ssRsrq = rilSignalStrength->NR_SignalStrength.ssRsrq;
11050 signalStrength_1_4.nr.ssSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
11051 signalStrength_1_4.nr.csiRsrp = rilSignalStrength->NR_SignalStrength.csiRsrp;
11052 signalStrength_1_4.nr.csiRsrq = rilSignalStrength->NR_SignalStrength.csiRsrq;
11053 signalStrength_1_4.nr.csiSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
11054 }
11055
convertRilSignalStrengthToHal_1_6(void * response,size_t responseLen,V1_6::SignalStrength & signalStrength_1_6)11056 void convertRilSignalStrengthToHal_1_6(void* response, size_t responseLen,
11057 V1_6::SignalStrength& signalStrength_1_6) {
11058 SignalStrength signalStrength = {};
11059 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
11060 signalStrength_1_6.gsm = signalStrength.gw;
11061 signalStrength_1_6.cdma = signalStrength.cdma;
11062 signalStrength_1_6.evdo = signalStrength.evdo;
11063 signalStrength_1_6.lte.base = signalStrength.lte;
11064
11065 RIL_SignalStrength_v12* rilSignalStrength = (RIL_SignalStrength_v12*)response;
11066 signalStrength_1_6.wcdma.base.signalStrength =
11067 rilSignalStrength->WCDMA_SignalStrength.signalStrength;
11068 signalStrength_1_6.wcdma.base.bitErrorRate =
11069 rilSignalStrength->WCDMA_SignalStrength.bitErrorRate;
11070 signalStrength_1_6.wcdma.rscp = INT_MAX;
11071 signalStrength_1_6.wcdma.ecno = INT_MAX;
11072
11073 signalStrength_1_6.tdscdma.signalStrength = INT_MAX;
11074 signalStrength_1_6.tdscdma.bitErrorRate = INT_MAX;
11075 signalStrength_1_6.tdscdma.rscp = INT_MAX;
11076
11077 signalStrength_1_6.nr.base.ssRsrp = rilSignalStrength->NR_SignalStrength.ssRsrp;
11078 signalStrength_1_6.nr.base.ssRsrq = rilSignalStrength->NR_SignalStrength.ssRsrq;
11079 signalStrength_1_6.nr.base.ssSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
11080 signalStrength_1_6.nr.base.csiRsrp = rilSignalStrength->NR_SignalStrength.csiRsrp;
11081 signalStrength_1_6.nr.base.csiRsrq = rilSignalStrength->NR_SignalStrength.csiRsrq;
11082 signalStrength_1_6.nr.base.csiSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
11083 }
11084
currentSignalStrengthInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11085 int radio_1_6::currentSignalStrengthInd(int slotId, int indicationType, int token, RIL_Errno e,
11086 void* response, size_t responseLen) {
11087 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndication != NULL ||
11088 radioService[slotId]->mRadioIndicationV1_2 != NULL ||
11089 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
11090 radioService[slotId]->mRadioIndicationV1_6 != NULL)) {
11091 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v12)) {
11092 RLOGE("currentSignalStrengthInd: invalid response");
11093 return 0;
11094 }
11095
11096 #if VDBG
11097 RLOGD("currentSignalStrengthInd");
11098 #endif
11099 Return<void> retStatus;
11100 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
11101 V1_6::SignalStrength signalStrength_1_6 = {};
11102 convertRilSignalStrengthToHal_1_6(response, responseLen, signalStrength_1_6);
11103 retStatus = radioService[slotId]->mRadioIndicationV1_6->currentSignalStrength_1_6(
11104 convertIntToRadioIndicationType(indicationType), signalStrength_1_6);
11105 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
11106 V1_4::SignalStrength signalStrength_1_4 = {};
11107 convertRilSignalStrengthToHal_1_4(response, responseLen, signalStrength_1_4);
11108 retStatus = radioService[slotId]->mRadioIndicationV1_4->currentSignalStrength_1_4(
11109 convertIntToRadioIndicationType(indicationType), signalStrength_1_4);
11110 } else if (radioService[slotId]->mRadioIndicationV1_2 != NULL) {
11111 V1_2::SignalStrength signalStrength_1_2 = {};
11112 convertRilSignalStrengthToHal_1_2(response, responseLen, signalStrength_1_2);
11113 retStatus = radioService[slotId]->mRadioIndicationV1_2->currentSignalStrength_1_2(
11114 convertIntToRadioIndicationType(indicationType), signalStrength_1_2);
11115 } else {
11116 SignalStrength signalStrength = {};
11117 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
11118 retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
11119 convertIntToRadioIndicationType(indicationType), signalStrength);
11120 }
11121 radioService[slotId]->checkReturnStatus(retStatus);
11122 } else {
11123 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
11124 slotId);
11125 }
11126
11127 return 0;
11128 }
11129
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,SetupDataCallResult & dcResult)11130 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
11131 SetupDataCallResult& dcResult) {
11132 dcResult.status = (DataCallFailCause) dcResponse->status;
11133 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
11134 dcResult.cid = dcResponse->cid;
11135 dcResult.active = dcResponse->active;
11136 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
11137 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
11138 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
11139 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
11140 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
11141 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
11142 dcResult.mtu = dcResponse->mtu;
11143 }
11144
split(hidl_string str)11145 hidl_vec<hidl_string> split(hidl_string str) {
11146 std::vector<hidl_string> ret;
11147 std::stringstream ss(static_cast<std::string>(str));
11148
11149 std::string tok;
11150
11151 while(getline(ss, tok, ' ')) {
11152 ret.push_back(hidl_string(tok));
11153 }
11154
11155 return ret;
11156 }
11157
convertToPdpProtocolType(hidl_string str)11158 ::android::hardware::radio::V1_4::PdpProtocolType convertToPdpProtocolType(hidl_string str) {
11159 if (strncmp("IP", str.c_str(), 2) == 0) {
11160 return ::android::hardware::radio::V1_4::PdpProtocolType::IP;
11161 } else if (strncmp("IPV6", str.c_str(), 4) == 0) {
11162 return ::android::hardware::radio::V1_4::PdpProtocolType::IPV6;
11163 } else if (strncmp("IPV4V6", str.c_str(), 6) == 0) {
11164 return ::android::hardware::radio::V1_4::PdpProtocolType::IPV4V6;
11165 } else if (strncmp("PPP", str.c_str(), 3) == 0) {
11166 return ::android::hardware::radio::V1_4::PdpProtocolType::PPP;
11167 } else if (strncmp("NON_IP", str.c_str(), 6) == 0) {
11168 return ::android::hardware::radio::V1_4::PdpProtocolType::NON_IP;
11169 } else if (strncmp("UNSTRUCTURED", str.c_str(), 12) == 0) {
11170 return ::android::hardware::radio::V1_4::PdpProtocolType::UNSTRUCTURED;
11171 } else {
11172 return ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
11173 }
11174 }
11175
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,::android::hardware::radio::V1_4::SetupDataCallResult & dcResult)11176 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
11177 ::android::hardware::radio::V1_4::SetupDataCallResult& dcResult) {
11178 dcResult.cause = (::android::hardware::radio::V1_4::DataCallFailCause) dcResponse->status;
11179 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
11180 dcResult.cid = dcResponse->cid;
11181 dcResult.active = (::android::hardware::radio::V1_4::DataConnActiveStatus)dcResponse->active;
11182 dcResult.type = convertToPdpProtocolType(convertCharPtrToHidlString(dcResponse->type));
11183 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
11184 dcResult.addresses = split(convertCharPtrToHidlString(dcResponse->addresses));
11185 dcResult.dnses = split(convertCharPtrToHidlString(dcResponse->dnses));
11186 dcResult.gateways = split(convertCharPtrToHidlString(dcResponse->gateways));
11187 dcResult.pcscf = split(convertCharPtrToHidlString(dcResponse->pcscf));
11188 dcResult.mtu = dcResponse->mtu;
11189 }
11190
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,::android::hardware::radio::V1_5::SetupDataCallResult & dcResult)11191 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
11192 ::android::hardware::radio::V1_5::SetupDataCallResult& dcResult) {
11193 dcResult.cause = (::android::hardware::radio::V1_4::DataCallFailCause) dcResponse->status;
11194 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
11195 dcResult.cid = dcResponse->cid;
11196 dcResult.active = (::android::hardware::radio::V1_4::DataConnActiveStatus)dcResponse->active;
11197 dcResult.type = convertToPdpProtocolType(convertCharPtrToHidlString(dcResponse->type));
11198 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
11199
11200 std::vector<::android::hardware::radio::V1_5::LinkAddress> linkAddresses;
11201 if (dcResponse->addresses != NULL) {
11202 std::stringstream ss(static_cast<std::string>(dcResponse->addresses));
11203 std::string tok;
11204 while (getline(ss, tok, ' ')) {
11205 ::android::hardware::radio::V1_5::LinkAddress la;
11206 la.address = hidl_string(tok);
11207 la.properties = 0;
11208 la.deprecationTime = INT64_MAX; // LinkAddress.java LIFETIME_PERMANENT = Long.MAX_VALUE
11209 la.expirationTime = INT64_MAX; // --"--
11210 linkAddresses.push_back(la);
11211 }
11212 }
11213
11214 dcResult.addresses = linkAddresses;
11215 dcResult.dnses = split(convertCharPtrToHidlString(dcResponse->dnses));
11216 dcResult.gateways = split(convertCharPtrToHidlString(dcResponse->gateways));
11217 dcResult.pcscf = split(convertCharPtrToHidlString(dcResponse->pcscf));
11218 dcResult.mtuV4 = dcResponse->mtu;
11219 dcResult.mtuV6 = dcResponse->mtu;
11220 }
11221
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,::android::hardware::radio::V1_6::SetupDataCallResult & dcResult)11222 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
11223 ::android::hardware::radio::V1_6::SetupDataCallResult& dcResult) {
11224 dcResult.cause = (::android::hardware::radio::V1_6::DataCallFailCause) dcResponse->status;
11225 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
11226 dcResult.cid = dcResponse->cid;
11227 dcResult.active = (::android::hardware::radio::V1_4::DataConnActiveStatus)dcResponse->active;
11228 dcResult.type = convertToPdpProtocolType(convertCharPtrToHidlString(dcResponse->type));
11229 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
11230
11231 std::vector<::android::hardware::radio::V1_5::LinkAddress> linkAddresses;
11232 std::stringstream ss(static_cast<std::string>(dcResponse->addresses));
11233 std::string tok;
11234 while(getline(ss, tok, ' ')) {
11235 ::android::hardware::radio::V1_5::LinkAddress la;
11236 la.address = hidl_string(tok);
11237 la.properties = 0;
11238 la.deprecationTime = INT64_MAX; // LinkAddress.java LIFETIME_PERMANENT = Long.MAX_VALUE
11239 la.expirationTime = INT64_MAX; // --"--
11240 linkAddresses.push_back(la);
11241 }
11242
11243 dcResult.addresses = linkAddresses;
11244 dcResult.dnses = split(convertCharPtrToHidlString(dcResponse->dnses));
11245 dcResult.gateways = split(convertCharPtrToHidlString(dcResponse->gateways));
11246 dcResult.pcscf = split(convertCharPtrToHidlString(dcResponse->pcscf));
11247 dcResult.mtuV4 = dcResponse->mtu;
11248 dcResult.mtuV6 = dcResponse->mtu;
11249
11250 std::vector<::android::hardware::radio::V1_6::TrafficDescriptor> trafficDescriptors;
11251 ::android::hardware::radio::V1_6::TrafficDescriptor trafficDescriptor;
11252 ::android::hardware::radio::V1_6::OsAppId osAppId;
11253 osAppId.osAppId = osAppIdVec;
11254 trafficDescriptor.osAppId.value(osAppId);
11255 trafficDescriptors.push_back(trafficDescriptor);
11256 dcResult.trafficDescriptors = trafficDescriptors;
11257 }
11258
convertRilDataCallListToHal(void * response,size_t responseLen,hidl_vec<SetupDataCallResult> & dcResultList)11259 void convertRilDataCallListToHal(void *response, size_t responseLen,
11260 hidl_vec<SetupDataCallResult>& dcResultList) {
11261 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11262
11263 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
11264 dcResultList.resize(num);
11265 for (int i = 0; i < num; i++) {
11266 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11267 }
11268 }
11269
convertRilDataCallListToHal_1_4(void * response,size_t responseLen,hidl_vec<V1_4::SetupDataCallResult> & dcResultList)11270 void convertRilDataCallListToHal_1_4(void* response, size_t responseLen,
11271 hidl_vec<V1_4::SetupDataCallResult>& dcResultList) {
11272 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11273
11274 RIL_Data_Call_Response_v11* dcResponse = (RIL_Data_Call_Response_v11*)response;
11275 dcResultList.resize(num);
11276 for (int i = 0; i < num; i++) {
11277 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11278 }
11279 }
11280
convertRilDataCallListToHal_1_5(void * response,size_t responseLen,hidl_vec<V1_5::SetupDataCallResult> & dcResultList)11281 void convertRilDataCallListToHal_1_5(void* response, size_t responseLen,
11282 hidl_vec<V1_5::SetupDataCallResult>& dcResultList) {
11283 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11284
11285 RIL_Data_Call_Response_v11* dcResponse = (RIL_Data_Call_Response_v11*)response;
11286 dcResultList.resize(num);
11287 for (int i = 0; i < num; i++) {
11288 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11289 }
11290 }
11291
convertRilDataCallListToHal_1_6(void * response,size_t responseLen,hidl_vec<V1_6::SetupDataCallResult> & dcResultList)11292 void convertRilDataCallListToHal_1_6(void* response, size_t responseLen,
11293 hidl_vec<V1_6::SetupDataCallResult>& dcResultList) {
11294 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11295
11296 RIL_Data_Call_Response_v11* dcResponse = (RIL_Data_Call_Response_v11*)response;
11297 dcResultList.resize(num);
11298 for (int i = 0; i < num; i++) {
11299 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11300 }
11301 }
11302
dataCallListChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11303 int radio_1_6::dataCallListChangedInd(int slotId,
11304 int indicationType, int token, RIL_Errno e, void *response,
11305 size_t responseLen) {
11306 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndication != NULL ||
11307 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
11308 radioService[slotId]->mRadioIndicationV1_5 != NULL ||
11309 radioService[slotId]->mRadioIndicationV1_6 != NULL)) {
11310 if ((response == NULL && responseLen != 0)
11311 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
11312 RLOGE("dataCallListChangedInd: invalid response");
11313 return 0;
11314 }
11315 #if VDBG
11316 RLOGD("dataCallListChangedInd");
11317 #endif
11318 Return<void> retStatus;
11319 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
11320 hidl_vec<V1_6::SetupDataCallResult> dcList;
11321 convertRilDataCallListToHal_1_6(response, responseLen, dcList);
11322 retStatus = radioService[slotId]->mRadioIndicationV1_6->dataCallListChanged_1_6(
11323 convertIntToRadioIndicationType(indicationType), dcList);
11324 } else if (radioService[slotId]->mRadioIndicationV1_5 != NULL) {
11325 hidl_vec<V1_5::SetupDataCallResult> dcList;
11326 convertRilDataCallListToHal_1_5(response, responseLen, dcList);
11327 retStatus = radioService[slotId]->mRadioIndicationV1_5->dataCallListChanged_1_5(
11328 convertIntToRadioIndicationType(indicationType), dcList);
11329 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
11330 hidl_vec<V1_4::SetupDataCallResult> dcList;
11331 convertRilDataCallListToHal_1_4(response, responseLen, dcList);
11332 retStatus = radioService[slotId]->mRadioIndicationV1_4->dataCallListChanged_1_4(
11333 convertIntToRadioIndicationType(indicationType), dcList);
11334 } else {
11335 hidl_vec<SetupDataCallResult> dcList;
11336 convertRilDataCallListToHal(response, responseLen, dcList);
11337 retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
11338 convertIntToRadioIndicationType(indicationType), dcList);
11339 }
11340 radioService[slotId]->checkReturnStatus(retStatus);
11341 } else {
11342 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
11343 }
11344
11345 return 0;
11346 }
11347
suppSvcNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11348 int radio_1_6::suppSvcNotifyInd(int slotId, int indicationType,
11349 int token, RIL_Errno e, void *response, size_t responseLen) {
11350 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11351 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
11352 RLOGE("suppSvcNotifyInd: invalid response");
11353 return 0;
11354 }
11355
11356 SuppSvcNotification suppSvc = {};
11357 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
11358 suppSvc.isMT = ssn->notificationType;
11359 suppSvc.code = ssn->code;
11360 suppSvc.index = ssn->index;
11361 suppSvc.type = ssn->type;
11362 suppSvc.number = convertCharPtrToHidlString(ssn->number);
11363
11364 #if VDBG
11365 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
11366 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
11367 #endif
11368 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
11369 convertIntToRadioIndicationType(indicationType), suppSvc);
11370 radioService[slotId]->checkReturnStatus(retStatus);
11371 } else {
11372 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
11373 }
11374
11375 return 0;
11376 }
11377
stkSessionEndInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11378 int radio_1_6::stkSessionEndInd(int slotId, int indicationType,
11379 int token, RIL_Errno e, void *response, size_t responseLen) {
11380 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11381 #if VDBG
11382 RLOGD("stkSessionEndInd");
11383 #endif
11384 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
11385 convertIntToRadioIndicationType(indicationType));
11386 radioService[slotId]->checkReturnStatus(retStatus);
11387 } else {
11388 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
11389 }
11390
11391 return 0;
11392 }
11393
stkProactiveCommandInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11394 int radio_1_6::stkProactiveCommandInd(int slotId,
11395 int indicationType, int token, RIL_Errno e, void *response,
11396 size_t responseLen) {
11397 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11398 if (response == NULL || responseLen == 0) {
11399 RLOGE("stkProactiveCommandInd: invalid response");
11400 return 0;
11401 }
11402 #if VDBG
11403 RLOGD("stkProactiveCommandInd");
11404 #endif
11405 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
11406 convertIntToRadioIndicationType(indicationType),
11407 convertCharPtrToHidlString((char *) response));
11408 radioService[slotId]->checkReturnStatus(retStatus);
11409 } else {
11410 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
11411 }
11412
11413 return 0;
11414 }
11415
stkEventNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11416 int radio_1_6::stkEventNotifyInd(int slotId, int indicationType,
11417 int token, RIL_Errno e, void *response, size_t responseLen) {
11418 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11419 if (response == NULL || responseLen == 0) {
11420 RLOGE("stkEventNotifyInd: invalid response");
11421 return 0;
11422 }
11423 #if VDBG
11424 RLOGD("stkEventNotifyInd");
11425 #endif
11426 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
11427 convertIntToRadioIndicationType(indicationType),
11428 convertCharPtrToHidlString((char *) response));
11429 radioService[slotId]->checkReturnStatus(retStatus);
11430 } else {
11431 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
11432 }
11433
11434 return 0;
11435 }
11436
stkCallSetupInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11437 int radio_1_6::stkCallSetupInd(int slotId, int indicationType,
11438 int token, RIL_Errno e, void *response, size_t responseLen) {
11439 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11440 if (response == NULL || responseLen != sizeof(int)) {
11441 RLOGE("stkCallSetupInd: invalid response");
11442 return 0;
11443 }
11444 int32_t timeout = ((int32_t *) response)[0];
11445 #if VDBG
11446 RLOGD("stkCallSetupInd: timeout %d", timeout);
11447 #endif
11448 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
11449 convertIntToRadioIndicationType(indicationType), timeout);
11450 radioService[slotId]->checkReturnStatus(retStatus);
11451 } else {
11452 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
11453 }
11454
11455 return 0;
11456 }
11457
simSmsStorageFullInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11458 int radio_1_6::simSmsStorageFullInd(int slotId,
11459 int indicationType, int token, RIL_Errno e, void *response,
11460 size_t responseLen) {
11461 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11462 #if VDBG
11463 RLOGD("simSmsStorageFullInd");
11464 #endif
11465 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
11466 convertIntToRadioIndicationType(indicationType));
11467 radioService[slotId]->checkReturnStatus(retStatus);
11468 } else {
11469 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
11470 }
11471
11472 return 0;
11473 }
11474
simRefreshInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11475 int radio_1_6::simRefreshInd(int slotId, int indicationType,
11476 int token, RIL_Errno e, void *response, size_t responseLen) {
11477 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11478 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
11479 RLOGE("simRefreshInd: invalid response");
11480 return 0;
11481 }
11482
11483 SimRefreshResult refreshResult = {};
11484 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
11485 refreshResult.type =
11486 (V1_0::SimRefreshType) simRefreshResponse->result;
11487 refreshResult.efId = simRefreshResponse->ef_id;
11488 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
11489
11490 #if VDBG
11491 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
11492 #endif
11493 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
11494 convertIntToRadioIndicationType(indicationType), refreshResult);
11495 radioService[slotId]->checkReturnStatus(retStatus);
11496 } else {
11497 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
11498 }
11499
11500 return 0;
11501 }
11502
convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord * signalInfoRecord,CdmaSignalInfoRecord & record)11503 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
11504 CdmaSignalInfoRecord& record) {
11505 record.isPresent = signalInfoRecord->isPresent;
11506 record.signalType = signalInfoRecord->signalType;
11507 record.alertPitch = signalInfoRecord->alertPitch;
11508 record.signal = signalInfoRecord->signal;
11509 }
11510
callRingInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11511 int radio_1_6::callRingInd(int slotId, int indicationType,
11512 int token, RIL_Errno e, void *response, size_t responseLen) {
11513 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11514 bool isGsm;
11515 CdmaSignalInfoRecord record = {};
11516 if (response == NULL || responseLen == 0) {
11517 isGsm = true;
11518 } else {
11519 isGsm = false;
11520 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
11521 RLOGE("callRingInd: invalid response");
11522 return 0;
11523 }
11524 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
11525 }
11526
11527 #if VDBG
11528 RLOGD("callRingInd: isGsm %d", isGsm);
11529 #endif
11530 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
11531 convertIntToRadioIndicationType(indicationType), isGsm, record);
11532 radioService[slotId]->checkReturnStatus(retStatus);
11533 } else {
11534 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
11535 }
11536
11537 return 0;
11538 }
11539
simStatusChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11540 int radio_1_6::simStatusChangedInd(int slotId,
11541 int indicationType, int token, RIL_Errno e, void *response,
11542 size_t responseLen) {
11543 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11544 #if VDBG
11545 RLOGD("simStatusChangedInd");
11546 #endif
11547 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
11548 convertIntToRadioIndicationType(indicationType));
11549 radioService[slotId]->checkReturnStatus(retStatus);
11550 } else {
11551 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
11552 }
11553
11554 return 0;
11555 }
11556
cdmaNewSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11557 int radio_1_6::cdmaNewSmsInd(int slotId, int indicationType,
11558 int token, RIL_Errno e, void *response, size_t responseLen) {
11559 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11560 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
11561 RLOGE("cdmaNewSmsInd: invalid response");
11562 return 0;
11563 }
11564
11565 CdmaSmsMessage msg = {};
11566 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
11567 msg.teleserviceId = rilMsg->uTeleserviceID;
11568 msg.isServicePresent = rilMsg->bIsServicePresent;
11569 msg.serviceCategory = rilMsg->uServicecategory;
11570 msg.address.digitMode =
11571 (V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
11572 msg.address.numberMode =
11573 (V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
11574 msg.address.numberType =
11575 (V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
11576 msg.address.numberPlan =
11577 (V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
11578
11579 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
11580 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
11581
11582 msg.subAddress.subaddressType = (V1_0::CdmaSmsSubaddressType)
11583 rilMsg->sSubAddress.subaddressType;
11584 msg.subAddress.odd = rilMsg->sSubAddress.odd;
11585
11586 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
11587 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
11588
11589 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
11590 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
11591
11592 #if VDBG
11593 RLOGD("cdmaNewSmsInd");
11594 #endif
11595 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
11596 convertIntToRadioIndicationType(indicationType), msg);
11597 radioService[slotId]->checkReturnStatus(retStatus);
11598 } else {
11599 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
11600 }
11601
11602 return 0;
11603 }
11604
newBroadcastSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11605 int radio_1_6::newBroadcastSmsInd(int slotId,
11606 int indicationType, int token, RIL_Errno e, void *response,
11607 size_t responseLen) {
11608 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11609 if (response == NULL || responseLen == 0) {
11610 RLOGE("newBroadcastSmsInd: invalid response");
11611 return 0;
11612 }
11613
11614 hidl_vec<uint8_t> data;
11615 data.setToExternal((uint8_t *) response, responseLen);
11616 #if VDBG
11617 RLOGD("newBroadcastSmsInd");
11618 #endif
11619 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
11620 convertIntToRadioIndicationType(indicationType), data);
11621 radioService[slotId]->checkReturnStatus(retStatus);
11622 } else {
11623 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
11624 }
11625
11626 return 0;
11627 }
11628
cdmaRuimSmsStorageFullInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11629 int radio_1_6::cdmaRuimSmsStorageFullInd(int slotId,
11630 int indicationType, int token, RIL_Errno e, void *response,
11631 size_t responseLen) {
11632 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11633 #if VDBG
11634 RLOGD("cdmaRuimSmsStorageFullInd");
11635 #endif
11636 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
11637 convertIntToRadioIndicationType(indicationType));
11638 radioService[slotId]->checkReturnStatus(retStatus);
11639 } else {
11640 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
11641 slotId);
11642 }
11643
11644 return 0;
11645 }
11646
restrictedStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11647 int radio_1_6::restrictedStateChangedInd(int slotId,
11648 int indicationType, int token, RIL_Errno e, void *response,
11649 size_t responseLen) {
11650 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11651 if (response == NULL || responseLen != sizeof(int)) {
11652 RLOGE("restrictedStateChangedInd: invalid response");
11653 return 0;
11654 }
11655 int32_t state = ((int32_t *) response)[0];
11656 #if VDBG
11657 RLOGD("restrictedStateChangedInd: state %d", state);
11658 #endif
11659 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
11660 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
11661 radioService[slotId]->checkReturnStatus(retStatus);
11662 } else {
11663 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
11664 slotId);
11665 }
11666
11667 return 0;
11668 }
11669
enterEmergencyCallbackModeInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11670 int radio_1_6::enterEmergencyCallbackModeInd(int slotId,
11671 int indicationType, int token, RIL_Errno e, void *response,
11672 size_t responseLen) {
11673 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11674 #if VDBG
11675 RLOGD("enterEmergencyCallbackModeInd");
11676 #endif
11677 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
11678 convertIntToRadioIndicationType(indicationType));
11679 radioService[slotId]->checkReturnStatus(retStatus);
11680 } else {
11681 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
11682 slotId);
11683 }
11684
11685 return 0;
11686 }
11687
cdmaCallWaitingInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11688 int radio_1_6::cdmaCallWaitingInd(int slotId,
11689 int indicationType, int token, RIL_Errno e, void *response,
11690 size_t responseLen) {
11691 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11692 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
11693 RLOGE("cdmaCallWaitingInd: invalid response");
11694 return 0;
11695 }
11696
11697 CdmaCallWaiting callWaitingRecord = {};
11698 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
11699 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
11700 callWaitingRecord.numberPresentation =
11701 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
11702 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
11703 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
11704 callWaitingRecord.signalInfoRecord);
11705 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
11706 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
11707
11708 #if VDBG
11709 RLOGD("cdmaCallWaitingInd");
11710 #endif
11711 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
11712 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
11713 radioService[slotId]->checkReturnStatus(retStatus);
11714 } else {
11715 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
11716 }
11717
11718 return 0;
11719 }
11720
cdmaOtaProvisionStatusInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11721 int radio_1_6::cdmaOtaProvisionStatusInd(int slotId,
11722 int indicationType, int token, RIL_Errno e, void *response,
11723 size_t responseLen) {
11724 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11725 if (response == NULL || responseLen != sizeof(int)) {
11726 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
11727 return 0;
11728 }
11729 int32_t status = ((int32_t *) response)[0];
11730 #if VDBG
11731 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
11732 #endif
11733 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
11734 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
11735 radioService[slotId]->checkReturnStatus(retStatus);
11736 } else {
11737 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
11738 slotId);
11739 }
11740
11741 return 0;
11742 }
11743
cdmaInfoRecInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11744 int radio_1_6::cdmaInfoRecInd(int slotId,
11745 int indicationType, int token, RIL_Errno e, void *response,
11746 size_t responseLen) {
11747 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11748 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
11749 RLOGE("cdmaInfoRecInd: invalid response");
11750 return 0;
11751 }
11752
11753 CdmaInformationRecords records = {};
11754 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
11755
11756 char* string8 = NULL;
11757 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
11758 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
11759 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
11760 "additional ones", recordsRil->numberOfInfoRecs,
11761 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
11762 }
11763 records.infoRec.resize(num);
11764 for (int i = 0 ; i < num ; i++) {
11765 CdmaInformationRecord *record = &records.infoRec[i];
11766 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
11767 record->name = (CdmaInfoRecName) infoRec->name;
11768 // All vectors should be size 0 except one which will be size 1. Set everything to
11769 // size 0 initially.
11770 record->display.resize(0);
11771 record->number.resize(0);
11772 record->signal.resize(0);
11773 record->redir.resize(0);
11774 record->lineCtrl.resize(0);
11775 record->clir.resize(0);
11776 record->audioCtrl.resize(0);
11777 switch (infoRec->name) {
11778 case RIL_CDMA_DISPLAY_INFO_REC:
11779 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
11780 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
11781 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
11782 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
11783 CDMA_ALPHA_INFO_BUFFER_LENGTH);
11784 return 0;
11785 }
11786 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
11787 if (string8 == NULL) {
11788 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
11789 "responseCdmaInformationRecords");
11790 return 0;
11791 }
11792 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
11793 string8[(int)infoRec->rec.display.alpha_len] = '\0';
11794
11795 record->display.resize(1);
11796 record->display[0].alphaBuf = string8;
11797 free(string8);
11798 string8 = NULL;
11799 break;
11800 }
11801
11802 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
11803 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
11804 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
11805 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
11806 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
11807 "expected not more than %d", (int) infoRec->rec.number.len,
11808 CDMA_NUMBER_INFO_BUFFER_LENGTH);
11809 return 0;
11810 }
11811 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
11812 if (string8 == NULL) {
11813 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
11814 "responseCdmaInformationRecords");
11815 return 0;
11816 }
11817 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
11818 string8[(int)infoRec->rec.number.len] = '\0';
11819
11820 record->number.resize(1);
11821 record->number[0].number = string8;
11822 free(string8);
11823 string8 = NULL;
11824 record->number[0].numberType = infoRec->rec.number.number_type;
11825 record->number[0].numberPlan = infoRec->rec.number.number_plan;
11826 record->number[0].pi = infoRec->rec.number.pi;
11827 record->number[0].si = infoRec->rec.number.si;
11828 break;
11829 }
11830
11831 case RIL_CDMA_SIGNAL_INFO_REC: {
11832 record->signal.resize(1);
11833 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
11834 record->signal[0].signalType = infoRec->rec.signal.signalType;
11835 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
11836 record->signal[0].signal = infoRec->rec.signal.signal;
11837 break;
11838 }
11839
11840 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
11841 if (infoRec->rec.redir.redirectingNumber.len >
11842 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
11843 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
11844 "expected not more than %d\n",
11845 (int)infoRec->rec.redir.redirectingNumber.len,
11846 CDMA_NUMBER_INFO_BUFFER_LENGTH);
11847 return 0;
11848 }
11849 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
11850 sizeof(char));
11851 if (string8 == NULL) {
11852 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
11853 "responseCdmaInformationRecords");
11854 return 0;
11855 }
11856 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
11857 infoRec->rec.redir.redirectingNumber.len);
11858 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
11859
11860 record->redir.resize(1);
11861 record->redir[0].redirectingNumber.number = string8;
11862 free(string8);
11863 string8 = NULL;
11864 record->redir[0].redirectingNumber.numberType =
11865 infoRec->rec.redir.redirectingNumber.number_type;
11866 record->redir[0].redirectingNumber.numberPlan =
11867 infoRec->rec.redir.redirectingNumber.number_plan;
11868 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
11869 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
11870 record->redir[0].redirectingReason =
11871 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
11872 break;
11873 }
11874
11875 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
11876 record->lineCtrl.resize(1);
11877 record->lineCtrl[0].lineCtrlPolarityIncluded =
11878 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
11879 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
11880 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
11881 record->lineCtrl[0].lineCtrlPowerDenial =
11882 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
11883 break;
11884 }
11885
11886 case RIL_CDMA_T53_CLIR_INFO_REC: {
11887 record->clir.resize(1);
11888 record->clir[0].cause = infoRec->rec.clir.cause;
11889 break;
11890 }
11891
11892 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
11893 record->audioCtrl.resize(1);
11894 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
11895 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
11896 break;
11897 }
11898
11899 case RIL_CDMA_T53_RELEASE_INFO_REC:
11900 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
11901 return 0;
11902
11903 default:
11904 RLOGE("cdmaInfoRecInd: Incorrect name value");
11905 return 0;
11906 }
11907 }
11908
11909 #if VDBG
11910 RLOGD("cdmaInfoRecInd");
11911 #endif
11912 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
11913 convertIntToRadioIndicationType(indicationType), records);
11914 radioService[slotId]->checkReturnStatus(retStatus);
11915 } else {
11916 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
11917 }
11918
11919 return 0;
11920 }
11921
indicateRingbackToneInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11922 int radio_1_6::indicateRingbackToneInd(int slotId,
11923 int indicationType, int token, RIL_Errno e, void *response,
11924 size_t responseLen) {
11925 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11926 if (response == NULL || responseLen != sizeof(int)) {
11927 RLOGE("indicateRingbackToneInd: invalid response");
11928 return 0;
11929 }
11930 bool start = ((int32_t *) response)[0];
11931 #if VDBG
11932 RLOGD("indicateRingbackToneInd: start %d", start);
11933 #endif
11934 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
11935 convertIntToRadioIndicationType(indicationType), start);
11936 radioService[slotId]->checkReturnStatus(retStatus);
11937 } else {
11938 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
11939 }
11940
11941 return 0;
11942 }
11943
resendIncallMuteInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11944 int radio_1_6::resendIncallMuteInd(int slotId,
11945 int indicationType, int token, RIL_Errno e, void *response,
11946 size_t responseLen) {
11947 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11948 #if VDBG
11949 RLOGD("resendIncallMuteInd");
11950 #endif
11951 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
11952 convertIntToRadioIndicationType(indicationType));
11953 radioService[slotId]->checkReturnStatus(retStatus);
11954 } else {
11955 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
11956 }
11957
11958 return 0;
11959 }
11960
cdmaSubscriptionSourceChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11961 int radio_1_6::cdmaSubscriptionSourceChangedInd(int slotId,
11962 int indicationType, int token, RIL_Errno e,
11963 void *response, size_t responseLen) {
11964 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11965 if (response == NULL || responseLen != sizeof(int)) {
11966 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
11967 return 0;
11968 }
11969 int32_t cdmaSource = ((int32_t *) response)[0];
11970 #if VDBG
11971 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
11972 #endif
11973 Return<void> retStatus = radioService[slotId]->mRadioIndication->
11974 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
11975 (CdmaSubscriptionSource) cdmaSource);
11976 radioService[slotId]->checkReturnStatus(retStatus);
11977 } else {
11978 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
11979 slotId);
11980 }
11981
11982 return 0;
11983 }
11984
cdmaPrlChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11985 int radio_1_6::cdmaPrlChangedInd(int slotId,
11986 int indicationType, int token, RIL_Errno e, void *response,
11987 size_t responseLen) {
11988 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11989 if (response == NULL || responseLen != sizeof(int)) {
11990 RLOGE("cdmaPrlChangedInd: invalid response");
11991 return 0;
11992 }
11993 int32_t version = ((int32_t *) response)[0];
11994 #if VDBG
11995 RLOGD("cdmaPrlChangedInd: version %d", version);
11996 #endif
11997 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
11998 convertIntToRadioIndicationType(indicationType), version);
11999 radioService[slotId]->checkReturnStatus(retStatus);
12000 } else {
12001 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
12002 }
12003
12004 return 0;
12005 }
12006
exitEmergencyCallbackModeInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12007 int radio_1_6::exitEmergencyCallbackModeInd(int slotId,
12008 int indicationType, int token, RIL_Errno e, void *response,
12009 size_t responseLen) {
12010 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12011 #if VDBG
12012 RLOGD("exitEmergencyCallbackModeInd");
12013 #endif
12014 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
12015 convertIntToRadioIndicationType(indicationType));
12016 radioService[slotId]->checkReturnStatus(retStatus);
12017 } else {
12018 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
12019 slotId);
12020 }
12021
12022 return 0;
12023 }
12024
rilConnectedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12025 int radio_1_6::rilConnectedInd(int slotId,
12026 int indicationType, int token, RIL_Errno e, void *response,
12027 size_t responseLen) {
12028 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12029 RLOGD("rilConnectedInd");
12030 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
12031 convertIntToRadioIndicationType(indicationType));
12032 radioService[slotId]->checkReturnStatus(retStatus);
12033 } else {
12034 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
12035 }
12036
12037 return 0;
12038 }
12039
voiceRadioTechChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12040 int radio_1_6::voiceRadioTechChangedInd(int slotId,
12041 int indicationType, int token, RIL_Errno e, void *response,
12042 size_t responseLen) {
12043 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12044 if (response == NULL || responseLen != sizeof(int)) {
12045 RLOGE("voiceRadioTechChangedInd: invalid response");
12046 return 0;
12047 }
12048 int32_t rat = ((int32_t *) response)[0];
12049 #if VDBG
12050 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
12051 #endif
12052 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
12053 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
12054 radioService[slotId]->checkReturnStatus(retStatus);
12055 } else {
12056 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
12057 slotId);
12058 }
12059
12060 return 0;
12061 }
12062
convertRilCellInfoListToHal(void * response,size_t responseLen,hidl_vec<CellInfo> & records)12063 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
12064 int num = responseLen / sizeof(RIL_CellInfo_v12);
12065 records.resize(num);
12066
12067 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
12068 for (int i = 0; i < num; i++) {
12069 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
12070 records[i].registered = rillCellInfo->registered;
12071 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
12072 records[i].timeStamp = rillCellInfo->timeStamp;
12073 // All vectors should be size 0 except one which will be size 1. Set everything to
12074 // size 0 initially.
12075 records[i].gsm.resize(0);
12076 records[i].wcdma.resize(0);
12077 records[i].cdma.resize(0);
12078 records[i].lte.resize(0);
12079 records[i].tdscdma.resize(0);
12080 switch(rillCellInfo->cellInfoType) {
12081 case RIL_CELL_INFO_TYPE_GSM: {
12082 records[i].gsm.resize(1);
12083 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
12084 cellInfoGsm->cellIdentityGsm.mcc =
12085 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12086 cellInfoGsm->cellIdentityGsm.mnc =
12087 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12088 cellInfoGsm->cellIdentityGsm.lac =
12089 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12090 cellInfoGsm->cellIdentityGsm.cid =
12091 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12092 cellInfoGsm->cellIdentityGsm.arfcn =
12093 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12094 cellInfoGsm->cellIdentityGsm.bsic =
12095 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12096 cellInfoGsm->signalStrengthGsm.signalStrength =
12097 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12098 cellInfoGsm->signalStrengthGsm.bitErrorRate =
12099 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12100 cellInfoGsm->signalStrengthGsm.timingAdvance =
12101 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12102 break;
12103 }
12104
12105 case RIL_CELL_INFO_TYPE_WCDMA: {
12106 records[i].wcdma.resize(1);
12107 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
12108 cellInfoWcdma->cellIdentityWcdma.mcc =
12109 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12110 cellInfoWcdma->cellIdentityWcdma.mnc =
12111 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12112 cellInfoWcdma->cellIdentityWcdma.lac =
12113 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12114 cellInfoWcdma->cellIdentityWcdma.cid =
12115 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12116 cellInfoWcdma->cellIdentityWcdma.psc =
12117 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12118 cellInfoWcdma->cellIdentityWcdma.uarfcn =
12119 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12120 cellInfoWcdma->signalStrengthWcdma.signalStrength =
12121 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12122 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
12123 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12124 break;
12125 }
12126
12127 case RIL_CELL_INFO_TYPE_CDMA: {
12128 records[i].cdma.resize(1);
12129 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
12130 cellInfoCdma->cellIdentityCdma.networkId =
12131 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12132 cellInfoCdma->cellIdentityCdma.systemId =
12133 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12134 cellInfoCdma->cellIdentityCdma.baseStationId =
12135 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12136 cellInfoCdma->cellIdentityCdma.longitude =
12137 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12138 cellInfoCdma->cellIdentityCdma.latitude =
12139 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12140 cellInfoCdma->signalStrengthCdma.dbm =
12141 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12142 cellInfoCdma->signalStrengthCdma.ecio =
12143 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12144 cellInfoCdma->signalStrengthEvdo.dbm =
12145 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12146 cellInfoCdma->signalStrengthEvdo.ecio =
12147 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12148 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
12149 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12150 break;
12151 }
12152
12153 case RIL_CELL_INFO_TYPE_LTE: {
12154 records[i].lte.resize(1);
12155 CellInfoLte *cellInfoLte = &records[i].lte[0];
12156 cellInfoLte->cellIdentityLte.mcc =
12157 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12158 cellInfoLte->cellIdentityLte.mnc =
12159 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12160 cellInfoLte->cellIdentityLte.ci =
12161 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12162 cellInfoLte->cellIdentityLte.pci =
12163 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12164 cellInfoLte->cellIdentityLte.tac =
12165 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12166 cellInfoLte->cellIdentityLte.earfcn =
12167 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12168 cellInfoLte->signalStrengthLte.signalStrength =
12169 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12170 cellInfoLte->signalStrengthLte.rsrp =
12171 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12172 cellInfoLte->signalStrengthLte.rsrq =
12173 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12174 cellInfoLte->signalStrengthLte.rssnr =
12175 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12176 cellInfoLte->signalStrengthLte.cqi =
12177 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12178 cellInfoLte->signalStrengthLte.timingAdvance =
12179 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12180 break;
12181 }
12182
12183 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12184 records[i].tdscdma.resize(1);
12185 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
12186 cellInfoTdscdma->cellIdentityTdscdma.mcc =
12187 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12188 cellInfoTdscdma->cellIdentityTdscdma.mnc =
12189 ril::util::mnc::decode(
12190 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12191 cellInfoTdscdma->cellIdentityTdscdma.lac =
12192 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12193 cellInfoTdscdma->cellIdentityTdscdma.cid =
12194 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12195 cellInfoTdscdma->cellIdentityTdscdma.cpid =
12196 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12197 cellInfoTdscdma->signalStrengthTdscdma.rscp =
12198 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12199 break;
12200 }
12201 default: {
12202 break;
12203 }
12204 }
12205 rillCellInfo += 1;
12206 }
12207 }
12208
convertRilCellInfoListToHal_1_2(void * response,size_t responseLen,hidl_vec<V1_2::CellInfo> & records)12209 void convertRilCellInfoListToHal_1_2(void *response, size_t responseLen, hidl_vec<V1_2::CellInfo>& records) {
12210 int num = responseLen / sizeof(RIL_CellInfo_v12);
12211 records.resize(num);
12212 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
12213 for (int i = 0; i < num; i++) {
12214 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
12215 records[i].registered = rillCellInfo->registered;
12216 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
12217 records[i].timeStamp = rillCellInfo->timeStamp;
12218 records[i].connectionStatus =(V1_2::CellConnectionStatus)0;
12219 // All vectors should be size 0 except one which will be size 1. Set everything to
12220 // size 0 initially.
12221 records[i].gsm.resize(0);
12222 records[i].wcdma.resize(0);
12223 records[i].cdma.resize(0);
12224 records[i].lte.resize(0);
12225 records[i].tdscdma.resize(0);
12226 switch(rillCellInfo->cellInfoType) {
12227 case RIL_CELL_INFO_TYPE_GSM: {
12228 records[i].gsm.resize(1);
12229 V1_2::CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
12230 cellInfoGsm->cellIdentityGsm.base.mcc =
12231 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12232 cellInfoGsm->cellIdentityGsm.base.mnc =
12233 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12234 cellInfoGsm->cellIdentityGsm.base.lac =
12235 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12236 cellInfoGsm->cellIdentityGsm.base.cid =
12237 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12238 cellInfoGsm->cellIdentityGsm.base.arfcn =
12239 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12240 cellInfoGsm->cellIdentityGsm.base.bsic =
12241 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12242 cellInfoGsm->signalStrengthGsm.signalStrength =
12243 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12244 cellInfoGsm->signalStrengthGsm.bitErrorRate =
12245 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12246 cellInfoGsm->signalStrengthGsm.timingAdvance =
12247 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12248 break;
12249 }
12250
12251 case RIL_CELL_INFO_TYPE_WCDMA: {
12252 records[i].wcdma.resize(1);
12253 V1_2::CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
12254 cellInfoWcdma->cellIdentityWcdma.base.mcc =
12255 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12256 cellInfoWcdma->cellIdentityWcdma.base.mnc =
12257 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12258 cellInfoWcdma->cellIdentityWcdma.base.lac =
12259 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12260 cellInfoWcdma->cellIdentityWcdma.base.cid =
12261 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12262 cellInfoWcdma->cellIdentityWcdma.base.psc =
12263 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12264 cellInfoWcdma->cellIdentityWcdma.base.uarfcn =
12265 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12266 cellInfoWcdma->signalStrengthWcdma.base.signalStrength =
12267 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12268 cellInfoWcdma->signalStrengthWcdma.base.bitErrorRate =
12269 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12270 break;
12271 }
12272
12273 case RIL_CELL_INFO_TYPE_CDMA: {
12274 records[i].cdma.resize(1);
12275 V1_2::CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
12276 cellInfoCdma->cellIdentityCdma.base.networkId =
12277 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12278 cellInfoCdma->cellIdentityCdma.base.systemId =
12279 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12280 cellInfoCdma->cellIdentityCdma.base.baseStationId =
12281 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12282 cellInfoCdma->cellIdentityCdma.base.longitude =
12283 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12284 cellInfoCdma->cellIdentityCdma.base.latitude =
12285 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12286 cellInfoCdma->signalStrengthCdma.dbm =
12287 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12288 cellInfoCdma->signalStrengthCdma.ecio =
12289 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12290 cellInfoCdma->signalStrengthEvdo.dbm =
12291 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12292 cellInfoCdma->signalStrengthEvdo.ecio =
12293 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12294 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
12295 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12296 break;
12297 }
12298
12299 case RIL_CELL_INFO_TYPE_LTE: {
12300 records[i].lte.resize(1);
12301 V1_2::CellInfoLte *cellInfoLte = &records[i].lte[0];
12302 cellInfoLte->cellIdentityLte.base.mcc =
12303 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12304 cellInfoLte->cellIdentityLte.base.mnc =
12305 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12306 cellInfoLte->cellIdentityLte.base.ci =
12307 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12308 cellInfoLte->cellIdentityLte.base.pci =
12309 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12310 cellInfoLte->cellIdentityLte.base.tac =
12311 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12312 cellInfoLte->cellIdentityLte.base.earfcn =
12313 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12314 cellInfoLte->signalStrengthLte.signalStrength =
12315 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12316 cellInfoLte->signalStrengthLte.rsrp =
12317 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12318 cellInfoLte->signalStrengthLte.rsrq =
12319 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12320 cellInfoLte->signalStrengthLte.rssnr =
12321 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12322 cellInfoLte->signalStrengthLte.cqi =
12323 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12324 cellInfoLte->signalStrengthLte.timingAdvance =
12325 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12326 break;
12327 }
12328
12329 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12330 records[i].tdscdma.resize(1);
12331 V1_2::CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
12332 cellInfoTdscdma->cellIdentityTdscdma.base.mcc =
12333 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12334 cellInfoTdscdma->cellIdentityTdscdma.base.mnc =
12335 ril::util::mnc::decode(
12336 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12337 cellInfoTdscdma->cellIdentityTdscdma.base.lac =
12338 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12339 cellInfoTdscdma->cellIdentityTdscdma.base.cid =
12340 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12341 cellInfoTdscdma->cellIdentityTdscdma.base.cpid =
12342 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12343 cellInfoTdscdma->signalStrengthTdscdma.rscp =
12344 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12345 break;
12346 }
12347 default: {
12348 break;
12349 }
12350 }
12351 rillCellInfo += 1;
12352 }
12353 }
12354
convertRilCellInfoListToHal_1_4(void * response,size_t responseLen,hidl_vec<V1_4::CellInfo> & records)12355 void convertRilCellInfoListToHal_1_4(void *response, size_t responseLen, hidl_vec<V1_4::CellInfo>& records) {
12356 int num = responseLen / sizeof(RIL_CellInfo_v16);
12357 records.resize(num);
12358 RIL_CellInfo_v16 *rillCellInfo = (RIL_CellInfo_v16 *) response;
12359 for (int i = 0; i < num; i++) {
12360 records[i].isRegistered = rillCellInfo->registered;
12361 records[i].connectionStatus = (V1_2::CellConnectionStatus)rillCellInfo->connectionStatus;
12362
12363 switch(rillCellInfo->cellInfoType) {
12364 case RIL_CELL_INFO_TYPE_GSM: {
12365 V1_2::CellInfoGsm cellInfoGsm;
12366 cellInfoGsm.cellIdentityGsm.base.mcc =
12367 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12368 cellInfoGsm.cellIdentityGsm.base.mnc =
12369 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12370 cellInfoGsm.cellIdentityGsm.base.lac =
12371 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12372 cellInfoGsm.cellIdentityGsm.base.cid =
12373 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12374 cellInfoGsm.cellIdentityGsm.base.arfcn =
12375 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12376 cellInfoGsm.cellIdentityGsm.base.bsic =
12377 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12378 cellInfoGsm.signalStrengthGsm.signalStrength =
12379 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12380 cellInfoGsm.signalStrengthGsm.bitErrorRate =
12381 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12382 cellInfoGsm.signalStrengthGsm.timingAdvance =
12383 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12384 records[i].info.gsm(cellInfoGsm);
12385 break;
12386 }
12387
12388 case RIL_CELL_INFO_TYPE_WCDMA: {
12389 V1_2::CellInfoWcdma cellInfoWcdma;
12390 cellInfoWcdma.cellIdentityWcdma.base.mcc =
12391 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12392 cellInfoWcdma.cellIdentityWcdma.base.mnc =
12393 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12394 cellInfoWcdma.cellIdentityWcdma.base.lac =
12395 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12396 cellInfoWcdma.cellIdentityWcdma.base.cid =
12397 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12398 cellInfoWcdma.cellIdentityWcdma.base.psc =
12399 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12400 cellInfoWcdma.cellIdentityWcdma.base.uarfcn =
12401 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12402 cellInfoWcdma.signalStrengthWcdma.base.signalStrength =
12403 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12404 cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate =
12405 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12406 records[i].info.wcdma(cellInfoWcdma);
12407 break;
12408 }
12409
12410 case RIL_CELL_INFO_TYPE_CDMA: {
12411 V1_2::CellInfoCdma cellInfoCdma;
12412 cellInfoCdma.cellIdentityCdma.base.networkId =
12413 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12414 cellInfoCdma.cellIdentityCdma.base.systemId =
12415 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12416 cellInfoCdma.cellIdentityCdma.base.baseStationId =
12417 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12418 cellInfoCdma.cellIdentityCdma.base.longitude =
12419 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12420 cellInfoCdma.cellIdentityCdma.base.latitude =
12421 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12422 cellInfoCdma.signalStrengthCdma.dbm =
12423 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12424 cellInfoCdma.signalStrengthCdma.ecio =
12425 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12426 cellInfoCdma.signalStrengthEvdo.dbm =
12427 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12428 cellInfoCdma.signalStrengthEvdo.ecio =
12429 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12430 cellInfoCdma.signalStrengthEvdo.signalNoiseRatio =
12431 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12432 records[i].info.cdma(cellInfoCdma);
12433 break;
12434 }
12435
12436 case RIL_CELL_INFO_TYPE_LTE: {
12437 V1_4::CellInfoLte cellInfoLte;
12438 cellInfoLte.base.cellIdentityLte.base.mcc =
12439 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12440 cellInfoLte.base.cellIdentityLte.base.mnc =
12441 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12442 cellInfoLte.base.cellIdentityLte.base.ci =
12443 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12444 cellInfoLte.base.cellIdentityLte.base.pci =
12445 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12446 cellInfoLte.base.cellIdentityLte.base.tac =
12447 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12448 cellInfoLte.base.cellIdentityLte.base.earfcn =
12449 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12450 cellInfoLte.base.signalStrengthLte.signalStrength =
12451 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12452 cellInfoLte.base.signalStrengthLte.rsrp =
12453 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12454 cellInfoLte.base.signalStrengthLte.rsrq =
12455 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12456 cellInfoLte.base.signalStrengthLte.rssnr =
12457 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12458 cellInfoLte.base.signalStrengthLte.cqi =
12459 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12460 cellInfoLte.base.signalStrengthLte.timingAdvance =
12461 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12462 records[i].info.lte(cellInfoLte);
12463 break;
12464 }
12465
12466 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12467 V1_2::CellInfoTdscdma cellInfoTdscdma;
12468 cellInfoTdscdma.cellIdentityTdscdma.base.mcc =
12469 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12470 cellInfoTdscdma.cellIdentityTdscdma.base.mnc =
12471 ril::util::mnc::decode(
12472 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12473 cellInfoTdscdma.cellIdentityTdscdma.base.lac =
12474 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12475 cellInfoTdscdma.cellIdentityTdscdma.base.cid =
12476 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12477 cellInfoTdscdma.cellIdentityTdscdma.base.cpid =
12478 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12479 cellInfoTdscdma.signalStrengthTdscdma.rscp =
12480 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12481 records[i].info.tdscdma(cellInfoTdscdma);
12482 break;
12483 }
12484
12485 case RIL_CELL_INFO_TYPE_NR: {
12486 V1_4::CellInfoNr cellInfoNr;
12487 cellInfoNr.cellidentity.mcc =
12488 std::to_string(rillCellInfo->CellInfo.nr.cellidentity.mcc);
12489 cellInfoNr.cellidentity.mnc =
12490 ril::util::mnc::decode(
12491 rillCellInfo->CellInfo.nr.cellidentity.mnc);
12492 cellInfoNr.cellidentity.nci =
12493 rillCellInfo->CellInfo.nr.cellidentity.nci;
12494 cellInfoNr.cellidentity.pci =
12495 rillCellInfo->CellInfo.nr.cellidentity.pci;
12496 cellInfoNr.cellidentity.tac =
12497 rillCellInfo->CellInfo.nr.cellidentity.tac;
12498 cellInfoNr.cellidentity.nrarfcn =
12499 rillCellInfo->CellInfo.nr.cellidentity.nrarfcn;
12500 cellInfoNr.cellidentity.operatorNames.alphaLong =
12501 convertCharPtrToHidlString(rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaLong);
12502 cellInfoNr.cellidentity.operatorNames.alphaShort =
12503 convertCharPtrToHidlString(rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaShort);
12504
12505 cellInfoNr.signalStrength.ssRsrp =
12506 rillCellInfo->CellInfo.nr.signalStrength.ssRsrp;
12507 cellInfoNr.signalStrength.ssRsrq =
12508 rillCellInfo->CellInfo.nr.signalStrength.ssRsrq;
12509 cellInfoNr.signalStrength.ssSinr =
12510 rillCellInfo->CellInfo.nr.signalStrength.ssSinr;
12511 cellInfoNr.signalStrength.csiRsrp =
12512 rillCellInfo->CellInfo.nr.signalStrength.csiRsrp;
12513 cellInfoNr.signalStrength.csiRsrq =
12514 rillCellInfo->CellInfo.nr.signalStrength.csiRsrq;
12515 cellInfoNr.signalStrength.csiSinr =
12516 rillCellInfo->CellInfo.nr.signalStrength.csiSinr;
12517 records[i].info.nr(cellInfoNr);
12518 break;
12519 }
12520 default: {
12521 break;
12522 }
12523 }
12524 rillCellInfo += 1;
12525 }
12526 }
12527
convertRilCellInfoListToHal_1_5(void * response,size_t responseLen,hidl_vec<V1_5::CellInfo> & records)12528 void convertRilCellInfoListToHal_1_5(void* response, size_t responseLen,
12529 hidl_vec<V1_5::CellInfo>& records) {
12530 int num = responseLen / sizeof(RIL_CellInfo_v16);
12531 records.resize(num);
12532 RIL_CellInfo_v16* rillCellInfo = (RIL_CellInfo_v16*)response;
12533 for (int i = 0; i < num; i++) {
12534 records[i].registered = rillCellInfo->registered;
12535 records[i].connectionStatus = (V1_2::CellConnectionStatus)rillCellInfo->connectionStatus;
12536
12537 switch (rillCellInfo->cellInfoType) {
12538 case RIL_CELL_INFO_TYPE_GSM: {
12539 V1_5::CellInfoGsm cellInfoGsm;
12540 cellInfoGsm.cellIdentityGsm.base.base.mcc =
12541 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12542 cellInfoGsm.cellIdentityGsm.base.base.mnc =
12543 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12544 cellInfoGsm.cellIdentityGsm.base.base.lac =
12545 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12546 cellInfoGsm.cellIdentityGsm.base.base.cid =
12547 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12548 cellInfoGsm.cellIdentityGsm.base.base.arfcn =
12549 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12550 cellInfoGsm.cellIdentityGsm.base.base.bsic =
12551 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12552 cellInfoGsm.signalStrengthGsm.signalStrength =
12553 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12554 cellInfoGsm.signalStrengthGsm.bitErrorRate =
12555 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12556 cellInfoGsm.signalStrengthGsm.timingAdvance =
12557 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12558 records[i].ratSpecificInfo.gsm(cellInfoGsm);
12559 break;
12560 }
12561
12562 case RIL_CELL_INFO_TYPE_WCDMA: {
12563 V1_5::CellInfoWcdma cellInfoWcdma;
12564 cellInfoWcdma.cellIdentityWcdma.base.base.mcc =
12565 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12566 cellInfoWcdma.cellIdentityWcdma.base.base.mnc =
12567 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12568 cellInfoWcdma.cellIdentityWcdma.base.base.lac =
12569 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12570 cellInfoWcdma.cellIdentityWcdma.base.base.cid =
12571 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12572 cellInfoWcdma.cellIdentityWcdma.base.base.psc =
12573 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12574 cellInfoWcdma.cellIdentityWcdma.base.base.uarfcn =
12575 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12576 cellInfoWcdma.signalStrengthWcdma.base.signalStrength =
12577 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12578 cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate =
12579 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12580 records[i].ratSpecificInfo.wcdma(cellInfoWcdma);
12581 break;
12582 }
12583
12584 case RIL_CELL_INFO_TYPE_CDMA: {
12585 V1_2::CellInfoCdma cellInfoCdma;
12586 cellInfoCdma.cellIdentityCdma.base.networkId =
12587 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12588 cellInfoCdma.cellIdentityCdma.base.systemId =
12589 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12590 cellInfoCdma.cellIdentityCdma.base.baseStationId =
12591 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12592 cellInfoCdma.cellIdentityCdma.base.longitude =
12593 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12594 cellInfoCdma.cellIdentityCdma.base.latitude =
12595 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12596 cellInfoCdma.signalStrengthCdma.dbm =
12597 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12598 cellInfoCdma.signalStrengthCdma.ecio =
12599 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12600 cellInfoCdma.signalStrengthEvdo.dbm =
12601 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12602 cellInfoCdma.signalStrengthEvdo.ecio =
12603 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12604 cellInfoCdma.signalStrengthEvdo.signalNoiseRatio =
12605 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12606 records[i].ratSpecificInfo.cdma(cellInfoCdma);
12607 break;
12608 }
12609
12610 case RIL_CELL_INFO_TYPE_LTE: {
12611 V1_5::CellInfoLte cellInfoLte;
12612 cellInfoLte.cellIdentityLte.base.base.mcc =
12613 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12614 cellInfoLte.cellIdentityLte.base.base.mnc =
12615 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12616 cellInfoLte.cellIdentityLte.base.base.ci =
12617 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12618 cellInfoLte.cellIdentityLte.base.base.pci =
12619 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12620 cellInfoLte.cellIdentityLte.base.base.tac =
12621 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12622 cellInfoLte.cellIdentityLte.base.base.earfcn =
12623 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12624 cellInfoLte.signalStrengthLte.signalStrength =
12625 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12626 cellInfoLte.signalStrengthLte.rsrp =
12627 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12628 cellInfoLte.signalStrengthLte.rsrq =
12629 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12630 cellInfoLte.signalStrengthLte.rssnr =
12631 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12632 cellInfoLte.signalStrengthLte.cqi =
12633 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12634 cellInfoLte.signalStrengthLte.timingAdvance =
12635 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12636 records[i].ratSpecificInfo.lte(cellInfoLte);
12637 break;
12638 }
12639
12640 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12641 V1_5::CellInfoTdscdma cellInfoTdscdma;
12642 cellInfoTdscdma.cellIdentityTdscdma.base.base.mcc =
12643 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12644 cellInfoTdscdma.cellIdentityTdscdma.base.base.mnc = ril::util::mnc::decode(
12645 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12646 cellInfoTdscdma.cellIdentityTdscdma.base.base.lac =
12647 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12648 cellInfoTdscdma.cellIdentityTdscdma.base.base.cid =
12649 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12650 cellInfoTdscdma.cellIdentityTdscdma.base.base.cpid =
12651 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12652 cellInfoTdscdma.signalStrengthTdscdma.rscp =
12653 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12654 records[i].ratSpecificInfo.tdscdma(cellInfoTdscdma);
12655 break;
12656 }
12657
12658 case RIL_CELL_INFO_TYPE_NR: {
12659 V1_5::CellInfoNr cellInfoNr;
12660 cellInfoNr.cellIdentityNr.base.mcc =
12661 std::to_string(rillCellInfo->CellInfo.nr.cellidentity.mcc);
12662 cellInfoNr.cellIdentityNr.base.mnc =
12663 ril::util::mnc::decode(rillCellInfo->CellInfo.nr.cellidentity.mnc);
12664 cellInfoNr.cellIdentityNr.base.nci = rillCellInfo->CellInfo.nr.cellidentity.nci;
12665 cellInfoNr.cellIdentityNr.base.pci = rillCellInfo->CellInfo.nr.cellidentity.pci;
12666 cellInfoNr.cellIdentityNr.base.tac = rillCellInfo->CellInfo.nr.cellidentity.tac;
12667 cellInfoNr.cellIdentityNr.base.nrarfcn =
12668 rillCellInfo->CellInfo.nr.cellidentity.nrarfcn;
12669 cellInfoNr.cellIdentityNr.base.operatorNames.alphaLong = convertCharPtrToHidlString(
12670 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaLong);
12671 cellInfoNr.cellIdentityNr.base.operatorNames.alphaShort =
12672 convertCharPtrToHidlString(
12673 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaShort);
12674
12675 cellInfoNr.signalStrengthNr.ssRsrp =
12676 rillCellInfo->CellInfo.nr.signalStrength.ssRsrp;
12677 cellInfoNr.signalStrengthNr.ssRsrq =
12678 rillCellInfo->CellInfo.nr.signalStrength.ssRsrq;
12679 cellInfoNr.signalStrengthNr.ssSinr =
12680 rillCellInfo->CellInfo.nr.signalStrength.ssSinr;
12681 cellInfoNr.signalStrengthNr.csiRsrp =
12682 rillCellInfo->CellInfo.nr.signalStrength.csiRsrp;
12683 cellInfoNr.signalStrengthNr.csiRsrq =
12684 rillCellInfo->CellInfo.nr.signalStrength.csiRsrq;
12685 cellInfoNr.signalStrengthNr.csiSinr =
12686 rillCellInfo->CellInfo.nr.signalStrength.csiSinr;
12687 records[i].ratSpecificInfo.nr(cellInfoNr);
12688 break;
12689 }
12690 default: {
12691 break;
12692 }
12693 }
12694 rillCellInfo += 1;
12695 }
12696 }
12697
convertRilCellInfoListToHal_1_6(void * response,size_t responseLen,hidl_vec<V1_6::CellInfo> & records)12698 void convertRilCellInfoListToHal_1_6(void* response, size_t responseLen,
12699 hidl_vec<V1_6::CellInfo>& records) {
12700 int num = responseLen / sizeof(RIL_CellInfo_v16);
12701 records.resize(num);
12702 RIL_CellInfo_v16* rillCellInfo = (RIL_CellInfo_v16*)response;
12703 for (int i = 0; i < num; i++) {
12704 records[i].registered = rillCellInfo->registered;
12705 records[i].connectionStatus = (V1_2::CellConnectionStatus)rillCellInfo->connectionStatus;
12706
12707 switch (rillCellInfo->cellInfoType) {
12708 case RIL_CELL_INFO_TYPE_GSM: {
12709 V1_5::CellInfoGsm cellInfoGsm;
12710 cellInfoGsm.cellIdentityGsm.base.base.mcc =
12711 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12712 cellInfoGsm.cellIdentityGsm.base.base.mnc =
12713 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12714 cellInfoGsm.cellIdentityGsm.base.base.lac =
12715 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12716 cellInfoGsm.cellIdentityGsm.base.base.cid =
12717 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12718 cellInfoGsm.cellIdentityGsm.base.base.arfcn =
12719 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12720 cellInfoGsm.cellIdentityGsm.base.base.bsic =
12721 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12722 cellInfoGsm.signalStrengthGsm.signalStrength =
12723 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12724 cellInfoGsm.signalStrengthGsm.bitErrorRate =
12725 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12726 cellInfoGsm.signalStrengthGsm.timingAdvance =
12727 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12728 records[i].ratSpecificInfo.gsm(cellInfoGsm);
12729 break;
12730 }
12731
12732 case RIL_CELL_INFO_TYPE_WCDMA: {
12733 V1_5::CellInfoWcdma cellInfoWcdma;
12734 cellInfoWcdma.cellIdentityWcdma.base.base.mcc =
12735 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12736 cellInfoWcdma.cellIdentityWcdma.base.base.mnc =
12737 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12738 cellInfoWcdma.cellIdentityWcdma.base.base.lac =
12739 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12740 cellInfoWcdma.cellIdentityWcdma.base.base.cid =
12741 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12742 cellInfoWcdma.cellIdentityWcdma.base.base.psc =
12743 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12744 cellInfoWcdma.cellIdentityWcdma.base.base.uarfcn =
12745 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12746 cellInfoWcdma.signalStrengthWcdma.base.signalStrength =
12747 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12748 cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate =
12749 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12750 records[i].ratSpecificInfo.wcdma(cellInfoWcdma);
12751 break;
12752 }
12753
12754 case RIL_CELL_INFO_TYPE_CDMA: {
12755 V1_2::CellInfoCdma cellInfoCdma;
12756 cellInfoCdma.cellIdentityCdma.base.networkId =
12757 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12758 cellInfoCdma.cellIdentityCdma.base.systemId =
12759 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12760 cellInfoCdma.cellIdentityCdma.base.baseStationId =
12761 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12762 cellInfoCdma.cellIdentityCdma.base.longitude =
12763 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12764 cellInfoCdma.cellIdentityCdma.base.latitude =
12765 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12766 cellInfoCdma.signalStrengthCdma.dbm =
12767 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12768 cellInfoCdma.signalStrengthCdma.ecio =
12769 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12770 cellInfoCdma.signalStrengthEvdo.dbm =
12771 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12772 cellInfoCdma.signalStrengthEvdo.ecio =
12773 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12774 cellInfoCdma.signalStrengthEvdo.signalNoiseRatio =
12775 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12776 records[i].ratSpecificInfo.cdma(cellInfoCdma);
12777 break;
12778 }
12779
12780 case RIL_CELL_INFO_TYPE_LTE: {
12781 V1_6::CellInfoLte cellInfoLte;
12782 cellInfoLte.cellIdentityLte.base.base.mcc =
12783 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12784 cellInfoLte.cellIdentityLte.base.base.mnc =
12785 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12786 cellInfoLte.cellIdentityLte.base.base.ci =
12787 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12788 cellInfoLte.cellIdentityLte.base.base.pci =
12789 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12790 cellInfoLte.cellIdentityLte.base.base.tac =
12791 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12792 cellInfoLte.cellIdentityLte.base.base.earfcn =
12793 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12794 cellInfoLte.cellIdentityLte.base.bandwidth = INT_MAX;
12795 hidl_vec<V1_5::EutranBands> bands;
12796 bands.resize(1);
12797 bands[0] = V1_5::EutranBands::BAND_1;
12798 cellInfoLte.cellIdentityLte.bands = bands;
12799 cellInfoLte.signalStrengthLte.base.signalStrength =
12800 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12801 cellInfoLte.signalStrengthLte.base.rsrp =
12802 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12803 cellInfoLte.signalStrengthLte.base.rsrq =
12804 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12805 cellInfoLte.signalStrengthLte.base.rssnr =
12806 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12807 cellInfoLte.signalStrengthLte.base.cqi =
12808 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12809 cellInfoLte.signalStrengthLte.base.timingAdvance =
12810 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12811 records[i].ratSpecificInfo.lte(cellInfoLte);
12812 break;
12813 }
12814
12815 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12816 V1_5::CellInfoTdscdma cellInfoTdscdma;
12817 cellInfoTdscdma.cellIdentityTdscdma.base.base.mcc =
12818 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12819 cellInfoTdscdma.cellIdentityTdscdma.base.base.mnc = ril::util::mnc::decode(
12820 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12821 cellInfoTdscdma.cellIdentityTdscdma.base.base.lac =
12822 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12823 cellInfoTdscdma.cellIdentityTdscdma.base.base.cid =
12824 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12825 cellInfoTdscdma.cellIdentityTdscdma.base.base.cpid =
12826 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12827 cellInfoTdscdma.signalStrengthTdscdma.rscp =
12828 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12829 records[i].ratSpecificInfo.tdscdma(cellInfoTdscdma);
12830 break;
12831 }
12832
12833 case RIL_CELL_INFO_TYPE_NR: {
12834 V1_6::CellInfoNr cellInfoNr;
12835 cellInfoNr.cellIdentityNr.base.mcc =
12836 std::to_string(rillCellInfo->CellInfo.nr.cellidentity.mcc);
12837 cellInfoNr.cellIdentityNr.base.mnc =
12838 ril::util::mnc::decode(rillCellInfo->CellInfo.nr.cellidentity.mnc);
12839 cellInfoNr.cellIdentityNr.base.nci = rillCellInfo->CellInfo.nr.cellidentity.nci;
12840 cellInfoNr.cellIdentityNr.base.pci = rillCellInfo->CellInfo.nr.cellidentity.pci;
12841 cellInfoNr.cellIdentityNr.base.tac = rillCellInfo->CellInfo.nr.cellidentity.tac;
12842 cellInfoNr.cellIdentityNr.base.nrarfcn =
12843 rillCellInfo->CellInfo.nr.cellidentity.nrarfcn;
12844 cellInfoNr.cellIdentityNr.base.operatorNames.alphaLong = convertCharPtrToHidlString(
12845 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaLong);
12846 cellInfoNr.cellIdentityNr.base.operatorNames.alphaShort =
12847 convertCharPtrToHidlString(
12848 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaShort);
12849
12850 cellInfoNr.signalStrengthNr.base.ssRsrp =
12851 rillCellInfo->CellInfo.nr.signalStrength.ssRsrp;
12852 cellInfoNr.signalStrengthNr.base.ssRsrq =
12853 rillCellInfo->CellInfo.nr.signalStrength.ssRsrq;
12854 cellInfoNr.signalStrengthNr.base.ssSinr =
12855 rillCellInfo->CellInfo.nr.signalStrength.ssSinr;
12856 cellInfoNr.signalStrengthNr.base.csiRsrp =
12857 rillCellInfo->CellInfo.nr.signalStrength.csiRsrp;
12858 cellInfoNr.signalStrengthNr.base.csiRsrq =
12859 rillCellInfo->CellInfo.nr.signalStrength.csiRsrq;
12860 cellInfoNr.signalStrengthNr.base.csiSinr =
12861 rillCellInfo->CellInfo.nr.signalStrength.csiSinr;
12862 records[i].ratSpecificInfo.nr(cellInfoNr);
12863 break;
12864 }
12865 default: {
12866 break;
12867 }
12868 }
12869 rillCellInfo += 1;
12870 }
12871 }
12872
cellInfoListInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12873 int radio_1_6::cellInfoListInd(int slotId,
12874 int indicationType, int token, RIL_Errno e, void *response,
12875 size_t responseLen) {
12876 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12877 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
12878 RLOGE("cellInfoListInd: invalid response");
12879 return 0;
12880 }
12881
12882 hidl_vec<CellInfo> records;
12883 convertRilCellInfoListToHal(response, responseLen, records);
12884
12885 #if VDBG
12886 RLOGD("cellInfoListInd");
12887 #endif
12888 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
12889 convertIntToRadioIndicationType(indicationType), records);
12890 radioService[slotId]->checkReturnStatus(retStatus);
12891 } else {
12892 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
12893 }
12894
12895 return 0;
12896 }
12897
imsNetworkStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12898 int radio_1_6::imsNetworkStateChangedInd(int slotId,
12899 int indicationType, int token, RIL_Errno e, void *response,
12900 size_t responseLen) {
12901 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12902 #if VDBG
12903 RLOGD("imsNetworkStateChangedInd");
12904 #endif
12905 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
12906 convertIntToRadioIndicationType(indicationType));
12907 radioService[slotId]->checkReturnStatus(retStatus);
12908 } else {
12909 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
12910 slotId);
12911 }
12912
12913 return 0;
12914 }
12915
subscriptionStatusChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12916 int radio_1_6::subscriptionStatusChangedInd(int slotId,
12917 int indicationType, int token, RIL_Errno e, void *response,
12918 size_t responseLen) {
12919 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12920 if (response == NULL || responseLen != sizeof(int)) {
12921 RLOGE("subscriptionStatusChangedInd: invalid response");
12922 return 0;
12923 }
12924 bool activate = ((int32_t *) response)[0];
12925 #if VDBG
12926 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
12927 #endif
12928 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
12929 convertIntToRadioIndicationType(indicationType), activate);
12930 radioService[slotId]->checkReturnStatus(retStatus);
12931 } else {
12932 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
12933 slotId);
12934 }
12935
12936 return 0;
12937 }
12938
srvccStateNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12939 int radio_1_6::srvccStateNotifyInd(int slotId,
12940 int indicationType, int token, RIL_Errno e, void *response,
12941 size_t responseLen) {
12942 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12943 if (response == NULL || responseLen != sizeof(int)) {
12944 RLOGE("srvccStateNotifyInd: invalid response");
12945 return 0;
12946 }
12947 int32_t state = ((int32_t *) response)[0];
12948 #if VDBG
12949 RLOGD("srvccStateNotifyInd: rat %d", state);
12950 #endif
12951 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
12952 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
12953 radioService[slotId]->checkReturnStatus(retStatus);
12954 } else {
12955 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
12956 }
12957
12958 return 0;
12959 }
12960
convertRilHardwareConfigListToHal(void * response,size_t responseLen,hidl_vec<HardwareConfig> & records)12961 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
12962 hidl_vec<HardwareConfig>& records) {
12963 int num = responseLen / sizeof(RIL_HardwareConfig);
12964 records.resize(num);
12965
12966 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
12967 for (int i = 0; i < num; i++) {
12968 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
12969 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
12970 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
12971 switch (rilHardwareConfig[i].type) {
12972 case RIL_HARDWARE_CONFIG_MODEM: {
12973 records[i].modem.resize(1);
12974 records[i].sim.resize(0);
12975 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
12976 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
12977 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
12978 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
12979 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
12980 break;
12981 }
12982
12983 case RIL_HARDWARE_CONFIG_SIM: {
12984 records[i].sim.resize(1);
12985 records[i].modem.resize(0);
12986 records[i].sim[0].modemUuid =
12987 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
12988 break;
12989 }
12990 }
12991 }
12992 }
12993
hardwareConfigChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12994 int radio_1_6::hardwareConfigChangedInd(int slotId,
12995 int indicationType, int token, RIL_Errno e, void *response,
12996 size_t responseLen) {
12997 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12998 if ((response == NULL && responseLen != 0)
12999 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
13000 RLOGE("hardwareConfigChangedInd: invalid response");
13001 return 0;
13002 }
13003
13004 hidl_vec<HardwareConfig> configs;
13005 convertRilHardwareConfigListToHal(response, responseLen, configs);
13006
13007 #if VDBG
13008 RLOGD("hardwareConfigChangedInd");
13009 #endif
13010 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
13011 convertIntToRadioIndicationType(indicationType), configs);
13012 radioService[slotId]->checkReturnStatus(retStatus);
13013 } else {
13014 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
13015 slotId);
13016 }
13017
13018 return 0;
13019 }
13020
convertRilRadioCapabilityToHal(void * response,size_t responseLen,RadioCapability & rc)13021 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
13022 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
13023 rc.session = rilRadioCapability->session;
13024 rc.phase = (V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
13025 rc.raf = rilRadioCapability->rat;
13026 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
13027 rc.status = (V1_0::RadioCapabilityStatus) rilRadioCapability->status;
13028 }
13029
radioCapabilityIndicationInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13030 int radio_1_6::radioCapabilityIndicationInd(int slotId,
13031 int indicationType, int token, RIL_Errno e, void *response,
13032 size_t responseLen) {
13033 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13034 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
13035 RLOGE("radioCapabilityIndicationInd: invalid response");
13036 return 0;
13037 }
13038
13039 RadioCapability rc = {};
13040 convertRilRadioCapabilityToHal(response, responseLen, rc);
13041
13042 #if VDBG
13043 RLOGD("radioCapabilityIndicationInd");
13044 #endif
13045 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
13046 convertIntToRadioIndicationType(indicationType), rc);
13047 radioService[slotId]->checkReturnStatus(retStatus);
13048 } else {
13049 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
13050 slotId);
13051 }
13052
13053 return 0;
13054 }
13055
isServiceTypeCfQuery(RIL_SsServiceType serType,RIL_SsRequestType reqType)13056 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
13057 if ((reqType == SS_INTERROGATION) &&
13058 (serType == SS_CFU ||
13059 serType == SS_CF_BUSY ||
13060 serType == SS_CF_NO_REPLY ||
13061 serType == SS_CF_NOT_REACHABLE ||
13062 serType == SS_CF_ALL ||
13063 serType == SS_CF_ALL_CONDITIONAL)) {
13064 return true;
13065 }
13066 return false;
13067 }
13068
onSupplementaryServiceIndicationInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13069 int radio_1_6::onSupplementaryServiceIndicationInd(int slotId,
13070 int indicationType, int token, RIL_Errno e,
13071 void *response, size_t responseLen) {
13072 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13073 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
13074 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
13075 return 0;
13076 }
13077
13078 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
13079 StkCcUnsolSsResult ss = {};
13080 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
13081 ss.requestType = (SsRequestType) rilSsResponse->requestType;
13082 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
13083 ss.serviceClass = rilSsResponse->serviceClass;
13084 ss.result = (RadioError) rilSsResponse->result;
13085
13086 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
13087 #if VDBG
13088 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
13089 rilSsResponse->cfData.numValidIndexes);
13090 #endif
13091 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
13092 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
13093 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
13094 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
13095 }
13096
13097 ss.cfData.resize(1);
13098 ss.ssInfo.resize(0);
13099
13100 /* number of call info's */
13101 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
13102
13103 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
13104 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
13105 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
13106
13107 cfInfo->status = (CallForwardInfoStatus) cf.status;
13108 cfInfo->reason = cf.reason;
13109 cfInfo->serviceClass = cf.serviceClass;
13110 cfInfo->toa = cf.toa;
13111 cfInfo->number = convertCharPtrToHidlString(cf.number);
13112 cfInfo->timeSeconds = cf.timeSeconds;
13113 #if VDBG
13114 RLOGD("onSupplementaryServiceIndicationInd: "
13115 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
13116 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
13117 #endif
13118 }
13119 } else {
13120 ss.ssInfo.resize(1);
13121 ss.cfData.resize(0);
13122
13123 /* each int */
13124 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
13125 for (int i = 0; i < SS_INFO_MAX; i++) {
13126 #if VDBG
13127 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
13128 rilSsResponse->ssInfo[i]);
13129 #endif
13130 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
13131 }
13132 }
13133
13134 #if VDBG
13135 RLOGD("onSupplementaryServiceIndicationInd");
13136 #endif
13137 Return<void> retStatus = radioService[slotId]->mRadioIndication->
13138 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
13139 ss);
13140 radioService[slotId]->checkReturnStatus(retStatus);
13141 } else {
13142 RLOGE("onSupplementaryServiceIndicationInd: "
13143 "radioService[%d]->mRadioIndication == NULL", slotId);
13144 }
13145
13146 return 0;
13147 }
13148
stkCallControlAlphaNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13149 int radio_1_6::stkCallControlAlphaNotifyInd(int slotId,
13150 int indicationType, int token, RIL_Errno e, void *response,
13151 size_t responseLen) {
13152 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13153 if (response == NULL || responseLen == 0) {
13154 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
13155 return 0;
13156 }
13157 #if VDBG
13158 RLOGD("stkCallControlAlphaNotifyInd");
13159 #endif
13160 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
13161 convertIntToRadioIndicationType(indicationType),
13162 convertCharPtrToHidlString((char *) response));
13163 radioService[slotId]->checkReturnStatus(retStatus);
13164 } else {
13165 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
13166 slotId);
13167 }
13168
13169 return 0;
13170 }
13171
convertRilLceDataInfoToHal(void * response,size_t responseLen,LceDataInfo & lce)13172 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
13173 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
13174 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
13175 lce.confidenceLevel = rilLceDataInfo->confidence_level;
13176 lce.lceSuspended = rilLceDataInfo->lce_suspended;
13177 }
13178
lceDataInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13179 int radio_1_6::lceDataInd(int slotId,
13180 int indicationType, int token, RIL_Errno e, void *response,
13181 size_t responseLen) {
13182 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13183 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
13184 RLOGE("lceDataInd: invalid response");
13185 return 0;
13186 }
13187
13188 LceDataInfo lce = {};
13189 convertRilLceDataInfoToHal(response, responseLen, lce);
13190 #if VDBG
13191 RLOGD("lceDataInd");
13192 #endif
13193 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
13194 convertIntToRadioIndicationType(indicationType), lce);
13195 radioService[slotId]->checkReturnStatus(retStatus);
13196 } else {
13197 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
13198 }
13199
13200 return 0;
13201 }
13202
pcoDataInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13203 int radio_1_6::pcoDataInd(int slotId,
13204 int indicationType, int token, RIL_Errno e, void *response,
13205 size_t responseLen) {
13206 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13207 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
13208 RLOGE("pcoDataInd: invalid response");
13209 return 0;
13210 }
13211
13212 PcoDataInfo pco = {};
13213 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
13214 pco.cid = rilPcoData->cid;
13215 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
13216 pco.pcoId = rilPcoData->pco_id;
13217 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
13218
13219 #if VDBG
13220 RLOGD("pcoDataInd");
13221 #endif
13222 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
13223 convertIntToRadioIndicationType(indicationType), pco);
13224 radioService[slotId]->checkReturnStatus(retStatus);
13225 } else {
13226 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
13227 }
13228
13229 return 0;
13230 }
13231
modemResetInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13232 int radio_1_6::modemResetInd(int slotId,
13233 int indicationType, int token, RIL_Errno e, void *response,
13234 size_t responseLen) {
13235 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13236 if (response == NULL || responseLen == 0) {
13237 RLOGE("modemResetInd: invalid response");
13238 return 0;
13239 }
13240 #if VDBG
13241 RLOGD("modemResetInd");
13242 #endif
13243 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
13244 convertIntToRadioIndicationType(indicationType),
13245 convertCharPtrToHidlString((char *) response));
13246 radioService[slotId]->checkReturnStatus(retStatus);
13247 } else {
13248 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
13249 }
13250
13251 return 0;
13252 }
13253
networkScanResultInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13254 int radio_1_6::networkScanResultInd(int slotId, int indicationType, int token, RIL_Errno e,
13255 void* response, size_t responseLen) {
13256 #if VDBG
13257 RLOGD("networkScanResultInd");
13258 #endif
13259 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndicationV1_6 != NULL ||
13260 radioService[slotId]->mRadioIndicationV1_5 != NULL ||
13261 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
13262 radioService[slotId]->mRadioIndicationV1_2 != NULL ||
13263 radioService[slotId]->mRadioIndicationV1_1 != NULL)) {
13264 if (response == NULL || responseLen == 0) {
13265 RLOGE("networkScanResultInd: invalid response");
13266 return 0;
13267 }
13268 RLOGD("networkScanResultInd");
13269
13270 RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
13271 Return<void> retStatus;
13272 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
13273 V1_6::NetworkScanResult result;
13274 result.status = (V1_1::ScanStatus)networkScanResult->status;
13275 result.error = (V1_6::RadioError)networkScanResult->error;
13276 convertRilCellInfoListToHal_1_6(
13277 networkScanResult->network_infos,
13278 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v16),
13279 result.networkInfos);
13280 retStatus = radioService[slotId]->mRadioIndicationV1_6->networkScanResult_1_6(
13281 convertIntToRadioIndicationType(indicationType), result);
13282 } else if (radioService[slotId]->mRadioIndicationV1_5 != NULL) {
13283 V1_5::NetworkScanResult result;
13284 result.status = (V1_1::ScanStatus)networkScanResult->status;
13285 result.error = (RadioError)networkScanResult->error;
13286 convertRilCellInfoListToHal_1_5(
13287 networkScanResult->network_infos,
13288 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
13289 result.networkInfos);
13290 retStatus = radioService[slotId]->mRadioIndicationV1_5->networkScanResult_1_5(
13291 convertIntToRadioIndicationType(indicationType), result);
13292 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
13293 V1_4::NetworkScanResult result;
13294 result.status = (V1_1::ScanStatus)networkScanResult->status;
13295 result.error = (RadioError)networkScanResult->error;
13296 convertRilCellInfoListToHal_1_4(
13297 networkScanResult->network_infos,
13298 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
13299 result.networkInfos);
13300 retStatus = radioService[slotId]->mRadioIndicationV1_4->networkScanResult_1_4(
13301 convertIntToRadioIndicationType(indicationType), result);
13302 } else if (radioService[slotId]->mRadioIndicationV1_2 != NULL) {
13303 V1_2::NetworkScanResult result;
13304 result.status = (V1_1::ScanStatus)networkScanResult->status;
13305 result.error = (RadioError)networkScanResult->error;
13306 convertRilCellInfoListToHal_1_2(
13307 networkScanResult->network_infos,
13308 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
13309 result.networkInfos);
13310 retStatus = radioService[slotId]->mRadioIndicationV1_2->networkScanResult_1_2(
13311 convertIntToRadioIndicationType(indicationType), result);
13312 } else {
13313 V1_1::NetworkScanResult result;
13314 result.status = (V1_1::ScanStatus)networkScanResult->status;
13315 result.error = (RadioError)networkScanResult->error;
13316 convertRilCellInfoListToHal(
13317 networkScanResult->network_infos,
13318 networkScanResult->network_infos_length * sizeof(RIL_CellInfo),
13319 result.networkInfos);
13320 retStatus = radioService[slotId]->mRadioIndicationV1_1->networkScanResult(
13321 convertIntToRadioIndicationType(indicationType), result);
13322 }
13323 radioService[slotId]->checkReturnStatus(retStatus);
13324 } else {
13325 RLOGE("networkScanResultInd: radioService[%d]->mRadioIndication == NULL", slotId);
13326 }
13327 return 0;
13328 }
13329
carrierInfoForImsiEncryption(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13330 int radio_1_6::carrierInfoForImsiEncryption(int slotId, int indicationType, int token, RIL_Errno e,
13331 void* response, size_t responseLen) {
13332 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndicationV1_2 != NULL)) {
13333 if (response == NULL || responseLen == 0) {
13334 RLOGE("carrierInfoForImsiEncryption: invalid response");
13335 return 0;
13336 }
13337 RLOGD("carrierInfoForImsiEncryption");
13338 Return<void> retStatus =
13339 radioService[slotId]->mRadioIndicationV1_2->carrierInfoForImsiEncryption(
13340 convertIntToRadioIndicationType(indicationType));
13341 radioService[slotId]->checkReturnStatus(retStatus);
13342 } else {
13343 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndication == NULL", slotId);
13344 }
13345
13346 return 0;
13347 }
13348
reportPhysicalChannelConfigs(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13349 int radio_1_6::reportPhysicalChannelConfigs(int slotId, int indicationType, int token, RIL_Errno e,
13350 void* response, size_t responseLen) {
13351 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndicationV1_6 != NULL ||
13352 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
13353 radioService[slotId]->mRadioIndicationV1_2 != NULL)) {
13354 int* configs = (int*)response;
13355 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
13356 hidl_vec<V1_6::PhysicalChannelConfig> physChanConfig;
13357 physChanConfig.resize(1);
13358 physChanConfig[0].status = (V1_2::CellConnectionStatus)configs[0];
13359 physChanConfig[0].cellBandwidthDownlinkKhz = configs[1];
13360 physChanConfig[0].rat = (V1_4::RadioTechnology)configs[2];
13361 physChanConfig[0].contextIds.resize(1);
13362 physChanConfig[0].contextIds[0] = configs[4];
13363 RLOGD("reportPhysicalChannelConfigs_1_6: %d %d %d %d %d", configs[0], configs[1],
13364 configs[2], configs[3], configs[4]);
13365 Return<void> retStatus =
13366 radioService[slotId]->mRadioIndicationV1_6->currentPhysicalChannelConfigs_1_6(
13367 RadioIndicationType::UNSOLICITED, physChanConfig);
13368 radioService[slotId]->checkReturnStatus(retStatus);
13369 // checkReturnStatus() call might set mRadioIndicationV1_6 to NULL
13370 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
13371 // Just send the link estimate along with physical channel config, as it has
13372 // at least the downlink bandwidth.
13373 // Note: the bandwidth is just some hardcoded value, as there is not way to get
13374 // that reliably on virtual devices, as of now.
13375 V1_6::LinkCapacityEstimate lce = {
13376 .downlinkCapacityKbps = static_cast<uint32_t>(configs[1]),
13377 .uplinkCapacityKbps = static_cast<uint32_t>(configs[1])};
13378 RLOGD("reporting link capacity estimate download: %d upload: %d",
13379 lce.downlinkCapacityKbps, lce.uplinkCapacityKbps);
13380 Return<void> retStatus =
13381 radioService[slotId]->mRadioIndicationV1_6->currentLinkCapacityEstimate_1_6(
13382 RadioIndicationType::UNSOLICITED, lce);
13383 radioService[slotId]->checkReturnStatus(retStatus);
13384 }
13385 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
13386 hidl_vec<PhysicalChannelConfigV1_4> physChanConfig;
13387 physChanConfig.resize(1);
13388 physChanConfig[0].base.status = (V1_2::CellConnectionStatus)configs[0];
13389 physChanConfig[0].base.cellBandwidthDownlink = configs[1];
13390 physChanConfig[0].rat = (V1_4::RadioTechnology)configs[2];
13391 physChanConfig[0].rfInfo.range((V1_4::FrequencyRange)configs[3]);
13392 physChanConfig[0].contextIds.resize(1);
13393 physChanConfig[0].contextIds[0] = configs[4];
13394 RLOGD("reportPhysicalChannelConfigs_1_4: %d %d %d %d %d", configs[0], configs[1],
13395 configs[2], configs[3], configs[4]);
13396 Return<void> retStatus =
13397 radioService[slotId]->mRadioIndicationV1_4->currentPhysicalChannelConfigs_1_4(
13398 RadioIndicationType::UNSOLICITED, physChanConfig);
13399 radioService[slotId]->checkReturnStatus(retStatus);
13400 // checkReturnStatus() call might set mRadioIndicationV1_4 to NULL
13401 if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
13402 // Just send the link estimate along with physical channel config, as it has
13403 // at least the downlink bandwidth.
13404 // Note: the bandwidth is just some hardcoded value, as there is not way to get
13405 // that reliably on virtual devices, as of now.
13406 V1_2::LinkCapacityEstimate lce = {
13407 .downlinkCapacityKbps = static_cast<uint32_t>(configs[1]),
13408 .uplinkCapacityKbps = static_cast<uint32_t>(configs[1])};
13409 RLOGD("reporting link capacity estimate download: %d upload: %d",
13410 lce.downlinkCapacityKbps, lce.uplinkCapacityKbps);
13411 Return<void> retStatus =
13412 radioService[slotId]->mRadioIndicationV1_4->currentLinkCapacityEstimate(
13413 RadioIndicationType::UNSOLICITED, lce);
13414 radioService[slotId]->checkReturnStatus(retStatus);
13415 }
13416 } else if (radioService[slotId]->mRadioIndicationV1_2 != NULL) {
13417 hidl_vec<V1_2::PhysicalChannelConfig> physChanConfig;
13418 physChanConfig.resize(1);
13419 physChanConfig[0].status = (V1_2::CellConnectionStatus)configs[0];
13420 physChanConfig[0].cellBandwidthDownlink = configs[1];
13421 RLOGD("reportPhysicalChannelConfigs_1_2: %d %d", configs[0], configs[1]);
13422 Return<void> retStatus =
13423 radioService[slotId]->mRadioIndicationV1_2->currentPhysicalChannelConfigs(
13424 RadioIndicationType::UNSOLICITED, physChanConfig);
13425 radioService[slotId]->checkReturnStatus(retStatus);
13426 // checkReturnStatus() call might set mRadioIndicationV1_2 to NULL
13427 if (radioService[slotId]->mRadioIndicationV1_2 != NULL) {
13428 // Just send the link estimate along with physical channel config, as it has
13429 // at least the downlink bandwidth.
13430 // Note: the bandwidth is just some hardcoded value, as there is not way to get
13431 // that reliably on virtual devices, as of now.
13432 V1_2::LinkCapacityEstimate lce = {
13433 .downlinkCapacityKbps = static_cast<uint32_t>(configs[1]),
13434 .uplinkCapacityKbps = static_cast<uint32_t>(configs[1])};
13435 RLOGD("reporting link capacity estimate download: %d upload: %d",
13436 lce.downlinkCapacityKbps, lce.uplinkCapacityKbps);
13437 Return<void> retStatus =
13438 radioService[slotId]->mRadioIndicationV1_2->currentLinkCapacityEstimate(
13439 RadioIndicationType::UNSOLICITED, lce);
13440 radioService[slotId]->checkReturnStatus(retStatus);
13441 }
13442 }
13443 } else {
13444 RLOGE("reportPhysicalChannelConfigs: radioService[%d]->mRadioIndication == NULL", slotId);
13445 return -1;
13446 }
13447 return 0;
13448 }
13449
keepaliveStatusInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13450 int radio_1_6::keepaliveStatusInd(int slotId,
13451 int indicationType, int token, RIL_Errno e, void *response,
13452 size_t responseLen) {
13453 #if VDBG
13454 RLOGD("%s(): token=%d", __FUNCTION__, token);
13455 #endif
13456 if (radioService[slotId] == NULL || radioService[slotId]->mRadioIndication == NULL) {
13457 RLOGE("%s: radioService[%d]->mRadioIndication == NULL", __FUNCTION__, slotId);
13458 return 0;
13459 }
13460
13461 auto ret = V1_1::IRadioIndication::castFrom(
13462 radioService[slotId]->mRadioIndication);
13463 if (!ret.isOk()) {
13464 RLOGE("%s: ret.isOk() == false for radioService[%d]", __FUNCTION__, slotId);
13465 return 0;
13466 }
13467 sp<V1_1::IRadioIndication> radioIndicationV1_1 = ret;
13468
13469 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
13470 RLOGE("%s: invalid response", __FUNCTION__);
13471 return 0;
13472 }
13473
13474 V1_1::KeepaliveStatus ks;
13475 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
13476
13477 Return<void> retStatus = radioIndicationV1_1->keepaliveStatus(
13478 convertIntToRadioIndicationType(indicationType), ks);
13479 radioService[slotId]->checkReturnStatus(retStatus);
13480 return 0;
13481 }
13482
oemHookRawInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13483 int radio_1_6::oemHookRawInd(int slotId,
13484 int indicationType, int token, RIL_Errno e, void *response,
13485 size_t responseLen) {
13486 if (!kOemHookEnabled) return 0;
13487
13488 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
13489 if (response == NULL || responseLen == 0) {
13490 RLOGE("oemHookRawInd: invalid response");
13491 return 0;
13492 }
13493
13494 hidl_vec<uint8_t> data;
13495 data.setToExternal((uint8_t *) response, responseLen);
13496 #if VDBG
13497 RLOGD("oemHookRawInd");
13498 #endif
13499 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
13500 convertIntToRadioIndicationType(indicationType), data);
13501 checkReturnStatus(slotId, retStatus, false);
13502 } else {
13503 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
13504 }
13505
13506 return 0;
13507 }
13508
13509 template <typename T>
publishRadioHal(std::shared_ptr<compat::DriverContext> ctx,sp<V1_5::IRadio> hidlHal,std::shared_ptr<compat::CallbackManager> cm,const std::string & slot)13510 static void publishRadioHal(std::shared_ptr<compat::DriverContext> ctx, sp<V1_5::IRadio> hidlHal,
13511 std::shared_ptr<compat::CallbackManager> cm, const std::string& slot) {
13512 static std::vector<std::shared_ptr<ndk::ICInterface>> gPublishedHals;
13513
13514 const auto instance = T::descriptor + "/"s + slot;
13515 RLOGD("Publishing %s", instance.c_str());
13516
13517 if (!AServiceManager_isDeclared(instance.c_str())) {
13518 RLOGW("%s is not declared in VINTF (this may be intentional on `next` when interface is "
13519 "not frozen)",
13520 instance.c_str());
13521 return;
13522 }
13523
13524 auto aidlHal = ndk::SharedRefBase::make<T>(ctx, hidlHal, cm);
13525 gPublishedHals.push_back(aidlHal);
13526 const auto status = AServiceManager_addService(aidlHal->asBinder().get(), instance.c_str());
13527 CHECK_EQ(status, STATUS_OK);
13528 }
13529
registerService(RIL_RadioFunctions * callbacks,CommandInfo * commands)13530 void radio_1_6::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
13531 using namespace android::hardware;
13532 int simCount = 1;
13533 const char *serviceNames[] = {
13534 android::RIL_getServiceName()
13535 #if (SIM_COUNT >= 2)
13536 , RIL2_SERVICE_NAME
13537 #if (SIM_COUNT >= 3)
13538 , RIL3_SERVICE_NAME
13539 #if (SIM_COUNT >= 4)
13540 , RIL4_SERVICE_NAME
13541 #endif
13542 #endif
13543 #endif
13544 };
13545
13546 #if (SIM_COUNT >= 2)
13547 simCount = SIM_COUNT;
13548 #endif
13549
13550 s_vendorFunctions = callbacks;
13551 s_commands = commands;
13552
13553 for (int i = 0; i < simCount; i++) {
13554 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
13555 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
13556 CHECK_EQ(ret, 0);
13557
13558 RLOGD("sim i = %d registering ...", i);
13559
13560 radioService[i] = new RadioImpl_1_6;
13561 radioService[i]->mSlotId = i;
13562 RLOGD("registerService: initializing power state to POWER_UP");
13563 radioService[i]->mSimCardPowerState = V1_1::CardPowerState::POWER_UP;
13564 RLOGD("registerService: starting android::hardware::radio::V1_6::IRadio %s for slot %d",
13565 serviceNames[i], i);
13566
13567 // use a compat shim to convert HIDL interface to AIDL and publish it
13568 // TODO(bug 220004469): replace with a full AIDL implementation
13569 auto radioHidl = radioService[i];
13570 const auto slot = serviceNames[i];
13571 auto context = std::make_shared<compat::DriverContext>();
13572 auto callbackMgr = std::make_shared<compat::CallbackManager>(context, radioHidl);
13573 radioService[i]->mCallbackManager = callbackMgr;
13574 publishRadioHal<compat::RadioData>(context, radioHidl, callbackMgr, slot);
13575 publishRadioHal<compat::RadioMessaging>(context, radioHidl, callbackMgr, slot);
13576 publishRadioHal<compat::RadioModem>(context, radioHidl, callbackMgr, slot);
13577 publishRadioHal<cf::ril::RefRadioNetwork>(context, radioHidl, callbackMgr, slot);
13578 publishRadioHal<compat::RadioSim>(context, radioHidl, callbackMgr, slot);
13579 publishRadioHal<compat::RadioVoice>(context, radioHidl, callbackMgr, slot);
13580 publishRadioHal<cf::ril::RefRadioIms>(context, radioHidl, callbackMgr, slot);
13581 publishRadioHal<cf::ril::RefImsMedia>(context, radioHidl, callbackMgr,
13582 std::string("default"));
13583 publishRadioHal<cf::ril::RefRadioModem>(context, radioHidl, callbackMgr, slot);
13584 publishRadioHal<cf::ril::RefRadioSim>(context, radioHidl, callbackMgr, slot);
13585
13586 RLOGD("registerService: OemHook is enabled = %s", kOemHookEnabled ? "true" : "false");
13587 if (kOemHookEnabled) {
13588 oemHookService[i] = new OemHookImpl;
13589 oemHookService[i]->mSlotId = i;
13590 // status = oemHookService[i]->registerAsService(serviceNames[i]);
13591 }
13592 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
13593 CHECK_EQ(ret, 0);
13594 }
13595 }
13596
rilc_thread_pool()13597 void rilc_thread_pool() {
13598 ABinderProcess_joinThreadPool();
13599 }
13600
getRadioServiceRwlock(int slotId)13601 pthread_rwlock_t * radio_1_6::getRadioServiceRwlock(int slotId) {
13602 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
13603
13604 #if (SIM_COUNT >= 2)
13605 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
13606 #if (SIM_COUNT >= 3)
13607 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
13608 #if (SIM_COUNT >= 4)
13609 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
13610 #endif
13611 #endif
13612 #endif
13613
13614 return radioServiceRwlockPtr;
13615 }
13616
13617 // should acquire write lock for the corresponding service before calling this
setNitzTimeReceived(int slotId,long timeReceived)13618 void radio_1_6::setNitzTimeReceived(int slotId, long timeReceived) {
13619 nitzTimeReceived[slotId] = timeReceived;
13620 }
13621