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 "RefRadioNetwork.h"
20
21 #include <android-base/logging.h>
22 #include <android/binder_manager.h>
23 #include <android/binder_process.h>
24 #include <android/hardware/radio/1.6/IRadio.h>
25 #include <android/hardware/radio/1.6/IRadioIndication.h>
26 #include <android/hardware/radio/1.6/IRadioResponse.h>
27 #include <android/hardware/radio/1.6/types.h>
28 #include <libradiocompat/CallbackManager.h>
29 #include <libradiocompat/RadioData.h>
30 #include <libradiocompat/RadioMessaging.h>
31 #include <libradiocompat/RadioModem.h>
32 #include <libradiocompat/RadioSim.h>
33 #include <libradiocompat/RadioVoice.h>
34
35 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
36
37 #include <hwbinder/IPCThreadState.h>
38 #include <hwbinder/ProcessState.h>
39 #include <guest/hals/ril/reference-libril/ril.h>
40 #include <telephony/ril_mnc.h>
41 #include <guest/hals/ril/reference-libril/ril_service.h>
42 #include <hidl/HidlTransportSupport.h>
43 #include <utils/SystemClock.h>
44 #include <inttypes.h>
45
46 #define INVALID_HEX_CHAR 16
47
48 using namespace android::hardware::radio;
49 using namespace android::hardware::radio::V1_0;
50 using namespace android::hardware::radio::deprecated::V1_0;
51 using namespace std::string_literals;
52 namespace compat = android::hardware::radio::compat;
53 using ::android::hardware::Return;
54 using ::android::hardware::hidl_bitfield;
55 using ::android::hardware::hidl_string;
56 using ::android::hardware::hidl_vec;
57 using ::android::hardware::hidl_array;
58 using ::android::hardware::Void;
59 using android::CommandInfo;
60 using android::RequestInfo;
61 using android::requestToString;
62 using android::sp;
63
64 using RegStateResultV1_6 = android::hardware::radio::V1_6::RegStateResult;
65 using RegStateResultV1_5 = android::hardware::radio::V1_5::RegStateResult;
66 using PhysicalChannelConfigV1_4 =
67 android::hardware::radio::V1_4::PhysicalChannelConfig;
68 using RadioTechnologyV1_4 = android::hardware::radio::V1_4::RadioTechnology;
69
70 #define BOOL_TO_INT(x) (x ? 1 : 0)
71 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
72 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
73
74 #if defined(ANDROID_MULTI_SIM)
75 #define CALL_ONREQUEST(a, b, c, d, e) \
76 s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e)))
77 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a))
78 #else
79 #define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d))
80 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
81 #endif
82
83 #ifdef OEM_HOOK_DISABLED
84 constexpr bool kOemHookEnabled = false;
85 #else
86 constexpr bool kOemHookEnabled = true;
87 #endif
88
89 RIL_RadioFunctions *s_vendorFunctions = NULL;
90 static CommandInfo *s_commands;
91
92 struct RadioImpl_1_6;
93 struct OemHookImpl;
94
95 #if (SIM_COUNT >= 2)
96 sp<RadioImpl_1_6> radioService[SIM_COUNT];
97 sp<OemHookImpl> oemHookService[SIM_COUNT];
98 int64_t nitzTimeReceived[SIM_COUNT];
99 // counter used for synchronization. It is incremented every time response callbacks are updated.
100 volatile int32_t mCounterRadio[SIM_COUNT];
101 volatile int32_t mCounterOemHook[SIM_COUNT];
102 #else
103 sp<RadioImpl_1_6> radioService[1];
104 sp<OemHookImpl> oemHookService[1];
105 int64_t nitzTimeReceived[1];
106 // counter used for synchronization. It is incremented every time response callbacks are updated.
107 volatile int32_t mCounterRadio[1];
108 volatile int32_t mCounterOemHook[1];
109 #endif
110
111 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
112
113 #if (SIM_COUNT >= 2)
114 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
115 #if (SIM_COUNT >= 3)
116 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
117 #if (SIM_COUNT >= 4)
118 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
119 #endif
120 #endif
121 #endif
122
123 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
124 hidl_vec<HardwareConfig>& records);
125
126 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
127
128 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
129
130 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
131 SignalStrength& signalStrength);
132
133 void convertRilSignalStrengthToHal_1_2(void* response, size_t responseLen,
134 V1_2::SignalStrength& signalStrength);
135
136 void convertRilSignalStrengthToHal_1_4(void *response, size_t responseLen,
137 V1_4::SignalStrength& signalStrength);
138
139 void convertRilSignalStrengthToHal_1_6(void* response, size_t responseLen,
140 V1_6::SignalStrength& signalStrength);
141
142 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse, SetupDataCallResult& dcResult);
143
144 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
145 V1_4::SetupDataCallResult& dcResult);
146
147 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
148 V1_5::SetupDataCallResult& dcResult);
149
150 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
151 V1_6::SetupDataCallResult& dcResult);
152
153 void convertRilDataCallListToHal(void *response, size_t responseLen,
154 hidl_vec<SetupDataCallResult>& dcResultList);
155
156 void convertRilDataCallListToHal_1_4(void* response, size_t responseLen,
157 hidl_vec<V1_4::SetupDataCallResult>& dcResultList);
158
159 void convertRilDataCallListToHal_1_5(void* response, size_t responseLen,
160 hidl_vec<V1_5::SetupDataCallResult>& dcResultList);
161
162 void convertRilDataCallListToHal_1_6(void* response, size_t responseLen,
163 hidl_vec<V1_6::SetupDataCallResult>& dcResultList);
164
165 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
166 void convertRilCellInfoListToHal_1_2(void *response, size_t responseLen, hidl_vec<V1_2::CellInfo>& records);
167 void convertRilCellInfoListToHal_1_4(void* response, size_t responseLen,
168 hidl_vec<V1_4::CellInfo>& records);
169 void convertRilCellInfoListToHal_1_5(void* response, size_t responseLen,
170 hidl_vec<V1_5::CellInfo>& records);
171 void convertRilCellInfoListToHal_1_6(void* response, size_t responseLen,
172 hidl_vec<V1_6::CellInfo>& records);
173
174 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
175 RIL_Errno e);
176
177 void populateResponseInfo_1_6(
178 ::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo,
179 int serial, int responseType, RIL_Errno e);
180
181 struct RadioImpl_1_6 : public V1_6::IRadio {
182 int32_t mSlotId;
183 V1_1::CardPowerState mSimCardPowerState;
184 sp<IRadioResponse> mRadioResponse;
185 sp<IRadioIndication> mRadioIndication;
186 sp<V1_1::IRadioResponse> mRadioResponseV1_1;
187 sp<V1_1::IRadioIndication> mRadioIndicationV1_1;
188 sp<V1_2::IRadioResponse> mRadioResponseV1_2;
189 sp<V1_2::IRadioIndication> mRadioIndicationV1_2;
190 sp<V1_3::IRadioResponse> mRadioResponseV1_3;
191 sp<V1_3::IRadioIndication> mRadioIndicationV1_3;
192 sp<V1_4::IRadioResponse> mRadioResponseV1_4;
193 sp<V1_4::IRadioIndication> mRadioIndicationV1_4;
194 sp<V1_5::IRadioResponse> mRadioResponseV1_5;
195 sp<V1_5::IRadioIndication> mRadioIndicationV1_5;
196 sp<V1_6::IRadioResponse> mRadioResponseV1_6;
197 sp<V1_6::IRadioIndication> mRadioIndicationV1_6;
198
199 Return<void> setResponseFunctions(
200 const ::android::sp<IRadioResponse>& radioResponse,
201 const ::android::sp<IRadioIndication>& radioIndication);
202
203 Return<void> getIccCardStatus(int32_t serial);
204
205 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
206 const hidl_string& aid);
207
208 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
209 const hidl_string& pin, const hidl_string& aid);
210
211 Return<void> supplyIccPin2ForApp(int32_t serial,
212 const hidl_string& pin2,
213 const hidl_string& aid);
214
215 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
216 const hidl_string& pin2, const hidl_string& aid);
217
218 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
219 const hidl_string& newPin, const hidl_string& aid);
220
221 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
222 const hidl_string& newPin2, const hidl_string& aid);
223
224 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
225
226 Return<void> getCurrentCalls(int32_t serial);
227
228 Return<void> getCurrentCalls_1_6(int32_t serial);
229
230 Return<void> dial(int32_t serial, const Dial& dialInfo);
231
232 Return<void> getImsiForApp(int32_t serial,
233 const ::android::hardware::hidl_string& aid);
234
235 Return<void> hangup(int32_t serial, int32_t gsmIndex);
236
237 Return<void> hangupWaitingOrBackground(int32_t serial);
238
239 Return<void> hangupForegroundResumeBackground(int32_t serial);
240
241 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
242
243 Return<void> conference(int32_t serial);
244
245 Return<void> rejectCall(int32_t serial);
246
247 Return<void> getLastCallFailCause(int32_t serial);
248
249 Return<void> getSignalStrength(int32_t serial);
250
251 Return<void> getSignalStrength_1_6(int32_t serial);
252
253 Return<void> getVoiceRegistrationState(int32_t serial);
254
255 Return<void> getDataRegistrationState(int32_t serial);
256
257 Return<void> getOperator(int32_t serial);
258
259 Return<void> setRadioPower(int32_t serial, bool on);
260
261 Return<void> sendDtmf(int32_t serial,
262 const ::android::hardware::hidl_string& s);
263
264 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
265
266 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
267
268 Return<void> setupDataCall(int32_t serial,
269 RadioTechnology radioTechnology,
270 const DataProfileInfo& profileInfo,
271 bool modemCognitive,
272 bool roamingAllowed,
273 bool isRoaming);
274
275 Return<void> iccIOForApp(int32_t serial,
276 const IccIo& iccIo);
277
278 Return<void> sendUssd(int32_t serial,
279 const ::android::hardware::hidl_string& ussd);
280
281 Return<void> cancelPendingUssd(int32_t serial);
282
283 Return<void> getClir(int32_t serial);
284
285 Return<void> setClir(int32_t serial, int32_t status);
286
287 Return<void> getCallForwardStatus(int32_t serial,
288 const CallForwardInfo& callInfo);
289
290 Return<void> setCallForward(int32_t serial,
291 const CallForwardInfo& callInfo);
292
293 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
294
295 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
296
297 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
298 bool success, SmsAcknowledgeFailCause cause);
299
300 Return<void> acceptCall(int32_t serial);
301
302 Return<void> deactivateDataCall(int32_t serial,
303 int32_t cid, bool reasonRadioShutDown);
304
305 Return<void> getFacilityLockForApp(int32_t serial,
306 const ::android::hardware::hidl_string& facility,
307 const ::android::hardware::hidl_string& password,
308 int32_t serviceClass,
309 const ::android::hardware::hidl_string& appId);
310
311 Return<void> setFacilityLockForApp(int32_t serial,
312 const ::android::hardware::hidl_string& facility,
313 bool lockState,
314 const ::android::hardware::hidl_string& password,
315 int32_t serviceClass,
316 const ::android::hardware::hidl_string& appId);
317
318 Return<void> setBarringPassword(int32_t serial,
319 const ::android::hardware::hidl_string& facility,
320 const ::android::hardware::hidl_string& oldPassword,
321 const ::android::hardware::hidl_string& newPassword);
322
323 Return<void> getNetworkSelectionMode(int32_t serial);
324
325 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
326
327 Return<void> setNetworkSelectionModeManual(int32_t serial,
328 const ::android::hardware::hidl_string& operatorNumeric);
329
330 Return<void> getAvailableNetworks(int32_t serial);
331
332 Return<void> startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request);
333
334 Return<void> stopNetworkScan(int32_t serial);
335
336 Return<void> startDtmf(int32_t serial,
337 const ::android::hardware::hidl_string& s);
338
339 Return<void> stopDtmf(int32_t serial);
340
341 Return<void> getBasebandVersion(int32_t serial);
342
343 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
344
345 Return<void> setMute(int32_t serial, bool enable);
346
347 Return<void> getMute(int32_t serial);
348
349 Return<void> getClip(int32_t serial);
350
351 Return<void> getDataCallList(int32_t serial);
352
353 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
354
355 Return<void> writeSmsToSim(int32_t serial,
356 const SmsWriteArgs& smsWriteArgs);
357
358 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
359
360 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
361
362 Return<void> getAvailableBandModes(int32_t serial);
363
364 Return<void> sendEnvelope(int32_t serial,
365 const ::android::hardware::hidl_string& command);
366
367 Return<void> sendTerminalResponseToSim(int32_t serial,
368 const ::android::hardware::hidl_string& commandResponse);
369
370 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
371
372 Return<void> explicitCallTransfer(int32_t serial);
373
374 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
375
376 Return<void> getPreferredNetworkType(int32_t serial);
377
378 Return<void> getNeighboringCids(int32_t serial);
379
380 Return<void> setLocationUpdates(int32_t serial, bool enable);
381
382 Return<void> setCdmaSubscriptionSource(int32_t serial,
383 CdmaSubscriptionSource cdmaSub);
384
385 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
386
387 Return<void> getCdmaRoamingPreference(int32_t serial);
388
389 Return<void> setTTYMode(int32_t serial, TtyMode mode);
390
391 Return<void> getTTYMode(int32_t serial);
392
393 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
394
395 Return<void> getPreferredVoicePrivacy(int32_t serial);
396
397 Return<void> sendCDMAFeatureCode(int32_t serial,
398 const ::android::hardware::hidl_string& featureCode);
399
400 Return<void> sendBurstDtmf(int32_t serial,
401 const ::android::hardware::hidl_string& dtmf,
402 int32_t on,
403 int32_t off);
404
405 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
406
407 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
408 const CdmaSmsAck& smsAck);
409
410 Return<void> getGsmBroadcastConfig(int32_t serial);
411
412 Return<void> setGsmBroadcastConfig(int32_t serial,
413 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
414
415 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
416
417 Return<void> getCdmaBroadcastConfig(int32_t serial);
418
419 Return<void> setCdmaBroadcastConfig(int32_t serial,
420 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
421
422 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
423
424 Return<void> getCDMASubscription(int32_t serial);
425
426 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
427
428 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
429
430 Return<void> getDeviceIdentity(int32_t serial);
431
432 Return<void> exitEmergencyCallbackMode(int32_t serial);
433
434 Return<void> getSmscAddress(int32_t serial);
435
436 Return<void> setSmscAddress(int32_t serial,
437 const ::android::hardware::hidl_string& smsc);
438
439 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
440
441 Return<void> reportStkServiceIsRunning(int32_t serial);
442
443 Return<void> getCdmaSubscriptionSource(int32_t serial);
444
445 Return<void> requestIsimAuthentication(int32_t serial,
446 const ::android::hardware::hidl_string& challenge);
447
448 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
449 bool success,
450 const ::android::hardware::hidl_string& ackPdu);
451
452 Return<void> sendEnvelopeWithStatus(int32_t serial,
453 const ::android::hardware::hidl_string& contents);
454
455 Return<void> getVoiceRadioTechnology(int32_t serial);
456
457 Return<void> getCellInfoList(int32_t serial);
458
459 Return<void> getCellInfoList_1_6(int32_t serial);
460
461 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
462
463 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
464 bool modemCognitive, bool isRoaming);
465
466 Return<void> getImsRegistrationState(int32_t serial);
467
468 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
469
470 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
471
472 Return<void> iccOpenLogicalChannel(int32_t serial,
473 const ::android::hardware::hidl_string& aid, int32_t p2);
474
475 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
476
477 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
478
479 Return<void> nvReadItem(int32_t serial, NvItem itemId);
480
481 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
482
483 Return<void> nvWriteCdmaPrl(int32_t serial,
484 const ::android::hardware::hidl_vec<uint8_t>& prl);
485
486 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
487
488 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
489
490 Return<void> setDataAllowed(int32_t serial, bool allow);
491
492 Return<void> getHardwareConfig(int32_t serial);
493
494 Return<void> requestIccSimAuthentication(int32_t serial,
495 int32_t authContext,
496 const ::android::hardware::hidl_string& authData,
497 const ::android::hardware::hidl_string& aid);
498
499 Return<void> setDataProfile(int32_t serial,
500 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
501
502 Return<void> requestShutdown(int32_t serial);
503
504 Return<void> getRadioCapability(int32_t serial);
505
506 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
507
508 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
509
510 Return<void> stopLceService(int32_t serial);
511
512 Return<void> pullLceData(int32_t serial);
513
514 Return<void> getModemActivityInfo(int32_t serial);
515
516 Return<void> setAllowedCarriers(int32_t serial,
517 bool allAllowed,
518 const CarrierRestrictions& carriers);
519
520 Return<void> getAllowedCarriers(int32_t serial);
521
522 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
523
524 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
525
526 Return<void> startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive);
527
528 Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
529
530 Return<void> setSimCardPower(int32_t serial, bool powerUp);
531 Return<void> setSimCardPower_1_1(int32_t serial,
532 const V1_1::CardPowerState state);
533 Return<void> setSimCardPower_1_6(int32_t serial,
534 const V1_1::CardPowerState state);
535
536 Return<void> responseAcknowledgement();
537
538 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
539 const V1_1::ImsiEncryptionInfo& message);
540
541 void checkReturnStatus(Return<void>& ret);
542
543 // Methods from ::android::hardware::radio::V1_2::IRadio follow.
544 Return<void> startNetworkScan_1_2(int32_t serial,
545 const ::android::hardware::radio::V1_2::NetworkScanRequest& request);
546 Return<void> setIndicationFilter_1_2(int32_t serial,
547 hidl_bitfield<::android::hardware::radio::V1_2::IndicationFilter> indicationFilter);
548 Return<void> setSignalStrengthReportingCriteria(int32_t serial, int32_t hysteresisMs,
549 int32_t hysteresisDb, const hidl_vec<int32_t>& thresholdsDbm,
550 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork);
551 Return<void> setLinkCapacityReportingCriteria(int32_t serial, int32_t hysteresisMs,
552 int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
553 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
554 const hidl_vec<int32_t>& thresholdsUplinkKbps,
555 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork);
556 Return<void> setupDataCall_1_2(int32_t serial,
557 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork,
558 const ::android::hardware::radio::V1_0::DataProfileInfo& dataProfileInfo,
559 bool modemCognitive, bool roamingAllowed, bool isRoaming,
560 ::android::hardware::radio::V1_2::DataRequestReason reason,
561 const hidl_vec<hidl_string>& addresses, const hidl_vec<hidl_string>& dnses);
562 Return<void> deactivateDataCall_1_2(int32_t serial, int32_t cid,
563 ::android::hardware::radio::V1_2::DataRequestReason reason);
564
565 // Methods from ::android::hardware::radio::V1_3::IRadio follow.
566 Return<void> setSystemSelectionChannels(int32_t serial, bool specifyChannels,
567 const hidl_vec<::android::hardware::radio::V1_1::RadioAccessSpecifier>& specifiers);
568 Return<void> enableModem(int32_t serial, bool on);
569 Return<void> getModemStackStatus(int32_t serial);
570
571 // Methods from ::android::hardware::radio::V1_4::IRadio follow.
572 Return<void> setupDataCall_1_4(int32_t serial,
573 ::android::hardware::radio::V1_4::AccessNetwork accessNetwork,
574 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo,
575 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason reason,
576 const hidl_vec<hidl_string>& addresses, const hidl_vec<hidl_string>& dnses);
577 Return<void> setInitialAttachApn_1_4(int32_t serial,
578 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo);
579 Return<void> setDataProfile_1_4(int32_t serial,
580 const hidl_vec<::android::hardware::radio::V1_4::DataProfileInfo>& profiles);
581 Return<void> emergencyDial(int32_t serial,
582 const ::android::hardware::radio::V1_0::Dial& dialInfo,
583 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
584 const hidl_vec<hidl_string>& urns,
585 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
586 bool fromEmergencyDialer, bool isTesting);
587 Return<void> emergencyDial_1_6(int32_t serial,
588 const ::android::hardware::radio::V1_0::Dial& dialInfo,
589 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
590 const hidl_vec<hidl_string>& urns,
591 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
592 bool fromEmergencyDialer, bool isTesting);
593 Return<void> startNetworkScan_1_4(int32_t serial,
594 const ::android::hardware::radio::V1_2::NetworkScanRequest& request);
595 Return<void> getPreferredNetworkTypeBitmap(int32_t serial);
596 Return<void> setPreferredNetworkTypeBitmap(
597 int32_t serial, hidl_bitfield<RadioAccessFamily> networkTypeBitmap);
598 Return<void> setAllowedCarriers_1_4(int32_t serial,
599 const ::android::hardware::radio::V1_4::CarrierRestrictionsWithPriority& carriers,
600 ::android::hardware::radio::V1_4::SimLockMultiSimPolicy multiSimPolicy);
601 Return<void> getAllowedCarriers_1_4(int32_t serial);
602 Return<void> getSignalStrength_1_4(int32_t serial);
603
604 // Methods from ::android::hardware::radio::V1_5::IRadio follow.
605 Return<void> setSignalStrengthReportingCriteria_1_5(int32_t serial,
606 const ::android::hardware::radio::V1_5::SignalThresholdInfo& signalThresholdInfo,
607 const ::android::hardware::radio::V1_5::AccessNetwork accessNetwork);
608 Return<void> setLinkCapacityReportingCriteria_1_5(int32_t serial, int32_t hysteresisMs,
609 int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
610 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
611 const hidl_vec<int32_t>& thresholdsUplinkKbps,
612 V1_5::AccessNetwork accessNetwork);
613 Return<void> enableUiccApplications(int32_t serial, bool detach);
614 Return<void> areUiccApplicationsEnabled(int32_t serial);
615 Return<void> setSystemSelectionChannels_1_5(int32_t serial, bool specifyChannels,
616 const hidl_vec<::android::hardware::radio::V1_5::RadioAccessSpecifier>& specifiers);
617 Return<void> startNetworkScan_1_5(int32_t serial,
618 const ::android::hardware::radio::V1_5::NetworkScanRequest& request);
619 Return<void> setupDataCall_1_5(int32_t serial,
620 ::android::hardware::radio::V1_5::AccessNetwork accessNetwork,
621 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
622 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason reason,
623 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& addresses,
624 const hidl_vec<hidl_string>& dnses);
625 Return<void> setInitialAttachApn_1_5(int32_t serial,
626 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo);
627 Return<void> setDataProfile_1_5(int32_t serial,
628 const hidl_vec<::android::hardware::radio::V1_5::DataProfileInfo>& profiles);
629 Return<void> setRadioPower_1_5(int32_t serial, bool powerOn, bool forEmergencyCall,
630 bool preferredForEmergencyCall);
631 Return<void> setIndicationFilter_1_5(int32_t serial,
632 hidl_bitfield<::android::hardware::radio::V1_5::IndicationFilter> indicationFilter);
633 Return<void> getBarringInfo(int32_t serial);
634 Return<void> getVoiceRegistrationState_1_5(int32_t serial);
635 Return<void> getDataRegistrationState_1_5(int32_t serial);
636 Return<void> setNetworkSelectionModeManual_1_5(int32_t serial,
637 const hidl_string& operatorNumeric, V1_5::RadioAccessNetworks ran);
638 Return<void> sendCdmaSmsExpectMore(int32_t serial, const CdmaSmsMessage& sms);
639 Return<void> supplySimDepersonalization(int32_t serial, V1_5::PersoSubstate persoType,
640 const hidl_string& controlKey);
641 Return<void> setNrDualConnectivityState(int32_t serial,
642 V1_6::NrDualConnectivityState nrDualConnectivityState);
643 Return<void> isNrDualConnectivityEnabled(int32_t serial);
644
645 // Methods from ::android::hardware::radio::V1_6::IRadio follow.
646 Return<void> getDataCallList_1_6(int32_t serial);
647 Return<void> setupDataCall_1_6(int32_t serial,
648 ::android::hardware::radio::V1_5::AccessNetwork accessNetwork,
649 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
650 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason reason,
651 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& addresses,
652 const hidl_vec<hidl_string>& dnses,
653 int32_t pduSessionId,
654 const ::android::hardware::radio::V1_6::OptionalSliceInfo& sliceInfo,
655 const ::android::hardware::radio::V1_6::OptionalTrafficDescriptor& trafficDescriptor,
656 bool matchAllRuleAllowed);
657 Return<void> sendSms_1_6(int32_t serial, const GsmSmsMessage& message);
658 Return<void> sendSmsExpectMore_1_6(int32_t serial, const GsmSmsMessage& message);
659 Return<void> sendCdmaSms_1_6(int32_t serial, const CdmaSmsMessage& sms);
660 Return<void> sendCdmaSmsExpectMore_1_6(int32_t serial, const CdmaSmsMessage& sms);
661 Return<void> setRadioPower_1_6(int32_t serial, bool powerOn, bool forEmergencyCall,
662 bool preferredForEmergencyCall);
663 Return<void> allocatePduSessionId(int32_t serial);
664 Return<void> releasePduSessionId(int32_t serial, int32_t id);
665 Return<void> startHandover(int32_t serial, int32_t callId);
666 Return<void> cancelHandover(int32_t serial, int32_t callId);
667 Return<void> setAllowedNetworkTypesBitmap(uint32_t serial,
668 hidl_bitfield<::android::hardware::radio::V1_4::RadioAccessFamily> networkTypeBitmap);
669 Return<void> setDataThrottling(int32_t serial,
670 V1_6::DataThrottlingAction dataThrottlingAction,
671 int64_t completionDurationMillis);
672 Return<void> getSystemSelectionChannels(int32_t serial);
673 Return<void> getVoiceRegistrationState_1_6(int32_t serial);
674 Return<void> getDataRegistrationState_1_6(int32_t serial);
675 Return<void> getAllowedNetworkTypesBitmap(int32_t serial);
676 Return<void> getSlicingConfig(int32_t serial);
677 Return<void> setCarrierInfoForImsiEncryption_1_6(
678 int32_t serial,
679 const ::android::hardware::radio::V1_6::ImsiEncryptionInfo& imsiEncryptionInfo);
680 Return<void> getSimPhonebookRecords(int32_t serial);
681 Return<void> getSimPhonebookCapacity(int32_t serial);
682 Return<void> updateSimPhonebookRecords(
683 int32_t serial,
684 const ::android::hardware::radio::V1_6::PhonebookRecordInfo& recordInfo);
685 };
686
687 struct OemHookImpl : public IOemHook {
688 int32_t mSlotId;
689 sp<IOemHookResponse> mOemHookResponse;
690 sp<IOemHookIndication> mOemHookIndication;
691
692 Return<void> setResponseFunctions(
693 const ::android::sp<IOemHookResponse>& oemHookResponse,
694 const ::android::sp<IOemHookIndication>& oemHookIndication);
695
696 Return<void> sendRequestRaw(int32_t serial,
697 const ::android::hardware::hidl_vec<uint8_t>& data);
698
699 Return<void> sendRequestStrings(int32_t serial,
700 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
701 };
702
memsetAndFreeStrings(int numPointers,...)703 void memsetAndFreeStrings(int numPointers, ...) {
704 va_list ap;
705 va_start(ap, numPointers);
706 for (int i = 0; i < numPointers; i++) {
707 char *ptr = va_arg(ap, char *);
708 if (ptr) {
709 #ifdef MEMSET_FREED
710 #define MAX_STRING_LENGTH 4096
711 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
712 #endif
713 free(ptr);
714 }
715 }
716 va_end(ap);
717 }
718
sendErrorResponse(RequestInfo * pRI,RIL_Errno err)719 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
720 pRI->pCI->responseFunction((int) pRI->socket_id,
721 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
722 }
723
724 /**
725 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
726 * request with error RIL_E_NO_MEMORY. The size() method is used to determine the size of the
727 * destination buffer into which the HIDL string is copied. If there is a discrepancy between
728 * the string length reported by the size() method, and the length of the string returned by
729 * the c_str() method, the function will return false indicating a failure.
730 *
731 * Returns true on success, and false on failure.
732 */
copyHidlStringToRil(char ** dest,const hidl_string & src,RequestInfo * pRI,bool allowEmpty)733 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI, bool allowEmpty) {
734 size_t len = src.size();
735 if (len == 0 && !allowEmpty) {
736 *dest = NULL;
737 return true;
738 }
739 *dest = (char *) calloc(len + 1, sizeof(char));
740 if (*dest == NULL) {
741 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
742 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
743 return false;
744 }
745 if (strlcpy(*dest, src.c_str(), len + 1) >= (len + 1)) {
746 RLOGE("Copy of the HIDL string has been truncated, as "
747 "the string length reported by size() does not "
748 "match the length of string returned by c_str().");
749 free(*dest);
750 *dest = NULL;
751 sendErrorResponse(pRI, RIL_E_INTERNAL_ERR);
752 return false;
753 }
754 return true;
755 }
756
copyHidlStringToRil(char ** dest,const hidl_string & src,RequestInfo * pRI)757 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
758 return copyHidlStringToRil(dest, src, pRI, false);
759 }
760
convertCharPtrToHidlString(const char * ptr)761 hidl_string convertCharPtrToHidlString(const char *ptr) {
762 hidl_string ret;
763 if (ptr != NULL) {
764 // TODO: replace this with strnlen
765 ret.setToExternal(ptr, strlen(ptr));
766 }
767 return ret;
768 }
769
dispatchVoid(int serial,int slotId,int request)770 bool dispatchVoid(int serial, int slotId, int request) {
771 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
772 if (pRI == NULL) {
773 return false;
774 }
775 CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
776 return true;
777 }
778
dispatchString(int serial,int slotId,int request,const char * str)779 bool dispatchString(int serial, int slotId, int request, const char * str) {
780 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
781 if (pRI == NULL) {
782 return false;
783 }
784
785 char *pString;
786 if (!copyHidlStringToRil(&pString, str, pRI)) {
787 return false;
788 }
789
790 CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
791
792 memsetAndFreeStrings(1, pString);
793 return true;
794 }
795
dispatchStrings(int serial,int slotId,int request,bool allowEmpty,int countStrings,...)796 bool dispatchStrings(int serial, int slotId, int request, bool allowEmpty, int countStrings, ...) {
797 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
798 if (pRI == NULL) {
799 return false;
800 }
801
802 char **pStrings;
803 pStrings = (char **)calloc(countStrings, sizeof(char *));
804 if (pStrings == NULL) {
805 RLOGE("Memory allocation failed for request %s", requestToString(request));
806 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
807 return false;
808 }
809 va_list ap;
810 va_start(ap, countStrings);
811 for (int i = 0; i < countStrings; i++) {
812 const char* str = va_arg(ap, const char *);
813 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI, allowEmpty)) {
814 va_end(ap);
815 for (int j = 0; j < i; j++) {
816 memsetAndFreeStrings(1, pStrings[j]);
817 }
818 free(pStrings);
819 return false;
820 }
821 }
822 va_end(ap);
823
824 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
825
826 if (pStrings != NULL) {
827 for (int i = 0 ; i < countStrings ; i++) {
828 memsetAndFreeStrings(1, pStrings[i]);
829 }
830
831 #ifdef MEMSET_FREED
832 memset(pStrings, 0, countStrings * sizeof(char *));
833 #endif
834 free(pStrings);
835 }
836 return true;
837 }
838
dispatchStrings(int serial,int slotId,int request,const hidl_vec<hidl_string> & data)839 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
840 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
841 if (pRI == NULL) {
842 return false;
843 }
844
845 int countStrings = data.size();
846 char **pStrings;
847 pStrings = (char **)calloc(countStrings, sizeof(char *));
848 if (pStrings == NULL) {
849 RLOGE("Memory allocation failed for request %s", requestToString(request));
850 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
851 return false;
852 }
853
854 for (int i = 0; i < countStrings; i++) {
855 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
856 for (int j = 0; j < i; j++) {
857 memsetAndFreeStrings(1, pStrings[j]);
858 }
859 free(pStrings);
860 return false;
861 }
862 }
863
864 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
865
866 if (pStrings != NULL) {
867 for (int i = 0 ; i < countStrings ; i++) {
868 memsetAndFreeStrings(1, pStrings[i]);
869 }
870
871 #ifdef MEMSET_FREED
872 memset(pStrings, 0, countStrings * sizeof(char *));
873 #endif
874 free(pStrings);
875 }
876 return true;
877 }
878
dispatchInts(int serial,int slotId,int request,int countInts,...)879 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
880 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
881 if (pRI == NULL) {
882 return false;
883 }
884
885 int *pInts = (int *)calloc(countInts, sizeof(int));
886
887 if (pInts == NULL) {
888 RLOGE("Memory allocation failed for request %s", requestToString(request));
889 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
890 return false;
891 }
892 va_list ap;
893 va_start(ap, countInts);
894 for (int i = 0; i < countInts; i++) {
895 pInts[i] = va_arg(ap, int);
896 }
897 va_end(ap);
898
899 CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
900
901 if (pInts != NULL) {
902 #ifdef MEMSET_FREED
903 memset(pInts, 0, countInts * sizeof(int));
904 #endif
905 free(pInts);
906 }
907 return true;
908 }
909
dispatchCallForwardStatus(int serial,int slotId,int request,const CallForwardInfo & callInfo)910 bool dispatchCallForwardStatus(int serial, int slotId, int request,
911 const CallForwardInfo& callInfo) {
912 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
913 if (pRI == NULL) {
914 return false;
915 }
916
917 RIL_CallForwardInfo cf;
918 cf.status = (int) callInfo.status;
919 cf.reason = callInfo.reason;
920 cf.serviceClass = callInfo.serviceClass;
921 cf.toa = callInfo.toa;
922 cf.timeSeconds = callInfo.timeSeconds;
923
924 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
925 return false;
926 }
927
928 CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
929
930 memsetAndFreeStrings(1, cf.number);
931
932 return true;
933 }
934
dispatchRaw(int serial,int slotId,int request,const hidl_vec<uint8_t> & rawBytes)935 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
936 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
937 if (pRI == NULL) {
938 return false;
939 }
940
941 const uint8_t *uData = rawBytes.data();
942
943 CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
944
945 return true;
946 }
947
dispatchIccApdu(int serial,int slotId,int request,const SimApdu & message)948 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
949 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
950 if (pRI == NULL) {
951 return false;
952 }
953
954 RIL_SIM_APDU apdu = {};
955
956 apdu.sessionid = message.sessionId;
957 apdu.cla = message.cla;
958 apdu.instruction = message.instruction;
959 apdu.p1 = message.p1;
960 apdu.p2 = message.p2;
961 apdu.p3 = message.p3;
962
963 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
964 return false;
965 }
966
967 CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
968
969 memsetAndFreeStrings(1, apdu.data);
970
971 return true;
972 }
973
checkReturnStatus(int32_t slotId,Return<void> & ret,bool isRadioService)974 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
975 if (ret.isOk() == false) {
976 RLOGE("checkReturnStatus: unable to call response/indication callback");
977 // Remote process hosting the callbacks must be dead. Reset the callback objects;
978 // there's no other recovery to be done here. When the client process is back up, it will
979 // call setResponseFunctions()
980
981 // Caller should already hold rdlock, release that first
982 // note the current counter to avoid overwriting updates made by another thread before
983 // write lock is acquired.
984 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
985 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_6::getRadioServiceRwlock(slotId);
986 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
987 CHECK_EQ(ret, 0);
988
989 // acquire wrlock
990 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
991 CHECK_EQ(ret, 0);
992
993 // make sure the counter value has not changed
994 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
995 if (isRadioService) {
996 radioService[slotId]->mRadioResponse = NULL;
997 radioService[slotId]->mRadioIndication = NULL;
998 radioService[slotId]->mRadioResponseV1_2 = NULL;
999 radioService[slotId]->mRadioIndicationV1_2 = NULL;
1000 radioService[slotId]->mRadioResponseV1_3 = NULL;
1001 radioService[slotId]->mRadioIndicationV1_3 = NULL;
1002 radioService[slotId]->mRadioResponseV1_4 = NULL;
1003 radioService[slotId]->mRadioIndicationV1_4 = NULL;
1004 radioService[slotId]->mRadioResponseV1_5 = NULL;
1005 radioService[slotId]->mRadioIndicationV1_5 = NULL;
1006 radioService[slotId]->mRadioResponseV1_6 = NULL;
1007 radioService[slotId]->mRadioIndicationV1_6 = NULL;
1008 } else {
1009 oemHookService[slotId]->mOemHookResponse = NULL;
1010 oemHookService[slotId]->mOemHookIndication = NULL;
1011 }
1012 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
1013 } else {
1014 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
1015 "got updated on another thread");
1016 }
1017
1018 // release wrlock
1019 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
1020 CHECK_EQ(ret, 0);
1021
1022 // Reacquire rdlock
1023 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
1024 CHECK_EQ(ret, 0);
1025 }
1026 }
1027
checkReturnStatus(Return<void> & ret)1028 void RadioImpl_1_6::checkReturnStatus(Return<void>& ret) {
1029 ::checkReturnStatus(mSlotId, ret, true);
1030 }
1031
setResponseFunctions(const::android::sp<IRadioResponse> & radioResponseParam,const::android::sp<IRadioIndication> & radioIndicationParam)1032 Return<void> RadioImpl_1_6::setResponseFunctions(
1033 const ::android::sp<IRadioResponse>& radioResponseParam,
1034 const ::android::sp<IRadioIndication>& radioIndicationParam) {
1035 RLOGD("setResponseFunctions");
1036
1037 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_6::getRadioServiceRwlock(mSlotId);
1038 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
1039 CHECK_EQ(ret, 0);
1040
1041 mRadioResponse = radioResponseParam;
1042 mRadioIndication = radioIndicationParam;
1043
1044 mRadioResponseV1_6 = V1_6::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1045 mRadioIndicationV1_6 = V1_6::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1046 if (mRadioResponseV1_6 == nullptr || mRadioIndicationV1_6 == nullptr) {
1047 mRadioResponseV1_6 = nullptr;
1048 mRadioIndicationV1_6 = nullptr;
1049 }
1050
1051 mRadioResponseV1_5 = V1_5::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1052 mRadioIndicationV1_5 = V1_5::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1053 if (mRadioResponseV1_5 == nullptr || mRadioIndicationV1_5 == nullptr) {
1054 mRadioResponseV1_5 = nullptr;
1055 mRadioIndicationV1_5 = nullptr;
1056 }
1057
1058 mRadioResponseV1_4 = V1_4::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1059 mRadioIndicationV1_4 = V1_4::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1060 if (mRadioResponseV1_4 == nullptr || mRadioIndicationV1_4 == nullptr) {
1061 mRadioResponseV1_4 = nullptr;
1062 mRadioIndicationV1_4 = nullptr;
1063 }
1064
1065 mRadioResponseV1_3 = V1_3::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1066 mRadioIndicationV1_3 = V1_3::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1067 if (mRadioResponseV1_3 == nullptr || mRadioIndicationV1_3 == nullptr) {
1068 mRadioResponseV1_3 = nullptr;
1069 mRadioIndicationV1_3 = nullptr;
1070 }
1071
1072 mRadioResponseV1_2 = V1_2::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1073 mRadioIndicationV1_2 = V1_2::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1074 if (mRadioResponseV1_2 == nullptr || mRadioIndicationV1_2 == nullptr) {
1075 mRadioResponseV1_2 = nullptr;
1076 mRadioIndicationV1_2 = nullptr;
1077 }
1078
1079 mRadioResponseV1_1 = V1_1::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1080 mRadioIndicationV1_1 = V1_1::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1081 if (mRadioResponseV1_1 == nullptr || mRadioIndicationV1_1 == nullptr) {
1082 mRadioResponseV1_1 = nullptr;
1083 mRadioIndicationV1_1 = nullptr;
1084 }
1085
1086 mCounterRadio[mSlotId]++;
1087
1088 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
1089 CHECK_EQ(ret, 0);
1090
1091 // client is connected. Send initial indications.
1092 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
1093
1094 return Void();
1095 }
1096
getIccCardStatus(int32_t serial)1097 Return<void> RadioImpl_1_6::getIccCardStatus(int32_t serial) {
1098 #if VDBG
1099 RLOGD("getIccCardStatus: serial %d", serial);
1100 #endif
1101 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
1102 return Void();
1103 }
1104
supplyIccPinForApp(int32_t serial,const hidl_string & pin,const hidl_string & aid)1105 Return<void> RadioImpl_1_6::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
1106 const hidl_string& aid) {
1107 #if VDBG
1108 RLOGD("supplyIccPinForApp: serial %d", serial);
1109 #endif
1110 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN, true,
1111 2, pin.c_str(), aid.c_str());
1112 return Void();
1113 }
1114
supplyIccPukForApp(int32_t serial,const hidl_string & puk,const hidl_string & pin,const hidl_string & aid)1115 Return<void> RadioImpl_1_6::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
1116 const hidl_string& pin, const hidl_string& aid) {
1117 #if VDBG
1118 RLOGD("supplyIccPukForApp: serial %d", serial);
1119 #endif
1120 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK, true,
1121 3, puk.c_str(), pin.c_str(), aid.c_str());
1122 return Void();
1123 }
1124
supplyIccPin2ForApp(int32_t serial,const hidl_string & pin2,const hidl_string & aid)1125 Return<void> RadioImpl_1_6::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
1126 const hidl_string& aid) {
1127 #if VDBG
1128 RLOGD("supplyIccPin2ForApp: serial %d", serial);
1129 #endif
1130 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2, true,
1131 2, pin2.c_str(), aid.c_str());
1132 return Void();
1133 }
1134
supplyIccPuk2ForApp(int32_t serial,const hidl_string & puk2,const hidl_string & pin2,const hidl_string & aid)1135 Return<void> RadioImpl_1_6::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
1136 const hidl_string& pin2, const hidl_string& aid) {
1137 #if VDBG
1138 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
1139 #endif
1140 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2, true,
1141 3, puk2.c_str(), pin2.c_str(), aid.c_str());
1142 return Void();
1143 }
1144
changeIccPinForApp(int32_t serial,const hidl_string & oldPin,const hidl_string & newPin,const hidl_string & aid)1145 Return<void> RadioImpl_1_6::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
1146 const hidl_string& newPin, const hidl_string& aid) {
1147 #if VDBG
1148 RLOGD("changeIccPinForApp: serial %d", serial);
1149 #endif
1150 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN, true,
1151 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
1152 return Void();
1153 }
1154
changeIccPin2ForApp(int32_t serial,const hidl_string & oldPin2,const hidl_string & newPin2,const hidl_string & aid)1155 Return<void> RadioImpl_1_6::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
1156 const hidl_string& newPin2, const hidl_string& aid) {
1157 #if VDBG
1158 RLOGD("changeIccPin2ForApp: serial %d", serial);
1159 #endif
1160 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2, true,
1161 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
1162 return Void();
1163 }
1164
supplyNetworkDepersonalization(int32_t serial,const hidl_string & netPin)1165 Return<void> RadioImpl_1_6::supplyNetworkDepersonalization(int32_t serial,
1166 const hidl_string& netPin) {
1167 #if VDBG
1168 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
1169 #endif
1170 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, true,
1171 1, netPin.c_str());
1172 return Void();
1173 }
1174
getCurrentCalls(int32_t serial)1175 Return<void> RadioImpl_1_6::getCurrentCalls(int32_t serial) {
1176 #if VDBG
1177 RLOGD("getCurrentCalls: serial %d", serial);
1178 #endif
1179 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
1180 return Void();
1181 }
1182
getCurrentCalls_1_6(int32_t serial)1183 Return<void> RadioImpl_1_6::getCurrentCalls_1_6(int32_t serial) {
1184 #if VDBG
1185 RLOGD("getCurrentCalls_1_6: serial %d", serial);
1186 #endif
1187 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
1188 return Void();
1189 }
1190
dial(int32_t serial,const Dial & dialInfo)1191 Return<void> RadioImpl_1_6::dial(int32_t serial, const Dial& dialInfo) {
1192 #if VDBG
1193 RLOGD("dial: serial %d", serial);
1194 #endif
1195 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
1196 if (pRI == NULL) {
1197 return Void();
1198 }
1199 RIL_Dial dial = {};
1200 RIL_UUS_Info uusInfo = {};
1201 int32_t sizeOfDial = sizeof(dial);
1202
1203 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
1204 return Void();
1205 }
1206 dial.clir = (int) dialInfo.clir;
1207
1208 if (dialInfo.uusInfo.size() != 0) {
1209 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
1210 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
1211
1212 if (dialInfo.uusInfo[0].uusData.size() == 0) {
1213 uusInfo.uusData = NULL;
1214 uusInfo.uusLength = 0;
1215 } else {
1216 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
1217 memsetAndFreeStrings(1, dial.address);
1218 return Void();
1219 }
1220 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
1221 }
1222
1223 dial.uusInfo = &uusInfo;
1224 }
1225
1226 CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
1227
1228 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1229
1230 return Void();
1231 }
1232
getImsiForApp(int32_t serial,const hidl_string & aid)1233 Return<void> RadioImpl_1_6::getImsiForApp(int32_t serial, const hidl_string& aid) {
1234 #if VDBG
1235 RLOGD("getImsiForApp: serial %d", serial);
1236 #endif
1237 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI, false,
1238 1, aid.c_str());
1239 return Void();
1240 }
1241
hangup(int32_t serial,int32_t gsmIndex)1242 Return<void> RadioImpl_1_6::hangup(int32_t serial, int32_t gsmIndex) {
1243 #if VDBG
1244 RLOGD("hangup: serial %d", serial);
1245 #endif
1246 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
1247 return Void();
1248 }
1249
hangupWaitingOrBackground(int32_t serial)1250 Return<void> RadioImpl_1_6::hangupWaitingOrBackground(int32_t serial) {
1251 #if VDBG
1252 RLOGD("hangupWaitingOrBackground: serial %d", serial);
1253 #endif
1254 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
1255 return Void();
1256 }
1257
hangupForegroundResumeBackground(int32_t serial)1258 Return<void> RadioImpl_1_6::hangupForegroundResumeBackground(int32_t serial) {
1259 #if VDBG
1260 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
1261 #endif
1262 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
1263 return Void();
1264 }
1265
switchWaitingOrHoldingAndActive(int32_t serial)1266 Return<void> RadioImpl_1_6::switchWaitingOrHoldingAndActive(int32_t serial) {
1267 #if VDBG
1268 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
1269 #endif
1270 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
1271 return Void();
1272 }
1273
conference(int32_t serial)1274 Return<void> RadioImpl_1_6::conference(int32_t serial) {
1275 #if VDBG
1276 RLOGD("conference: serial %d", serial);
1277 #endif
1278 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
1279 return Void();
1280 }
1281
rejectCall(int32_t serial)1282 Return<void> RadioImpl_1_6::rejectCall(int32_t serial) {
1283 #if VDBG
1284 RLOGD("rejectCall: serial %d", serial);
1285 #endif
1286 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
1287 return Void();
1288 }
1289
getLastCallFailCause(int32_t serial)1290 Return<void> RadioImpl_1_6::getLastCallFailCause(int32_t serial) {
1291 #if VDBG
1292 RLOGD("getLastCallFailCause: serial %d", serial);
1293 #endif
1294 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
1295 return Void();
1296 }
1297
getSignalStrength(int32_t serial)1298 Return<void> RadioImpl_1_6::getSignalStrength(int32_t serial) {
1299 #if VDBG
1300 RLOGD("getSignalStrength: serial %d", serial);
1301 #endif
1302 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
1303 return Void();
1304 }
1305
getVoiceRegistrationState(int32_t serial)1306 Return<void> RadioImpl_1_6::getVoiceRegistrationState(int32_t serial) {
1307 #if VDBG
1308 RLOGD("getVoiceRegistrationState: serial %d", serial);
1309 #endif
1310 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
1311 return Void();
1312 }
1313
getDataRegistrationState(int32_t serial)1314 Return<void> RadioImpl_1_6::getDataRegistrationState(int32_t serial) {
1315 #if VDBG
1316 RLOGD("getDataRegistrationState: serial %d", serial);
1317 #endif
1318 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1319 return Void();
1320 }
1321
getOperator(int32_t serial)1322 Return<void> RadioImpl_1_6::getOperator(int32_t serial) {
1323 #if VDBG
1324 RLOGD("getOperator: serial %d", serial);
1325 #endif
1326 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1327 return Void();
1328 }
1329
setRadioPower(int32_t serial,bool on)1330 Return<void> RadioImpl_1_6::setRadioPower(int32_t serial, bool on) {
1331 #if VDBG
1332 RLOGD("setRadioPower: serial %d on %d", serial, on);
1333 #endif
1334 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1335 return Void();
1336 }
1337
sendDtmf(int32_t serial,const hidl_string & s)1338 Return<void> RadioImpl_1_6::sendDtmf(int32_t serial, const hidl_string& s) {
1339 #if VDBG
1340 RLOGD("sendDtmf: serial %d", serial);
1341 #endif
1342 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1343 return Void();
1344 }
1345
sendSms(int32_t serial,const GsmSmsMessage & message)1346 Return<void> RadioImpl_1_6::sendSms(int32_t serial, const GsmSmsMessage& message) {
1347 #if VDBG
1348 RLOGD("sendSms: serial %d", serial);
1349 #endif
1350 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, false,
1351 2, message.smscPdu.c_str(), message.pdu.c_str());
1352 return Void();
1353 }
1354
sendSms_1_6(int32_t serial,const GsmSmsMessage & message)1355 Return<void> RadioImpl_1_6::sendSms_1_6(int32_t serial, const GsmSmsMessage& message) {
1356 #if VDBG
1357 RLOGD("sendSms: serial %d", serial);
1358 #endif
1359 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, false,
1360 2, message.smscPdu.c_str(), message.pdu.c_str());
1361 return Void();
1362 }
1363
sendSMSExpectMore(int32_t serial,const GsmSmsMessage & message)1364 Return<void> RadioImpl_1_6::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1365 #if VDBG
1366 RLOGD("sendSmsExpectMore: serial %d", serial);
1367 #endif
1368 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, false,
1369 2, message.smscPdu.c_str(), message.pdu.c_str());
1370 return Void();
1371 }
1372
sendSmsExpectMore_1_6(int32_t serial,const GsmSmsMessage & message)1373 Return<void> RadioImpl_1_6::sendSmsExpectMore_1_6(int32_t serial, const GsmSmsMessage& message) {
1374 #if VDBG
1375 RLOGD("sendSmsExpectMore: serial %d", serial);
1376 #endif
1377 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, false,
1378 2, message.smscPdu.c_str(), message.pdu.c_str());
1379 return Void();
1380 }
1381
convertMvnoTypeToString(MvnoType type,char * & str)1382 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1383 switch (type) {
1384 case MvnoType::IMSI:
1385 str = (char *)"imsi";
1386 return true;
1387 case MvnoType::GID:
1388 str = (char *)"gid";
1389 return true;
1390 case MvnoType::SPN:
1391 str = (char *)"spn";
1392 return true;
1393 case MvnoType::NONE:
1394 str = (char *)"";
1395 return true;
1396 }
1397 return false;
1398 }
1399
setupDataCall(int32_t serial,RadioTechnology radioTechnology,const DataProfileInfo & dataProfileInfo,bool modemCognitive,bool roamingAllowed,bool isRoaming)1400 Return<void> RadioImpl_1_6::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1401 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1402 bool roamingAllowed, bool isRoaming) {
1403
1404 #if VDBG
1405 RLOGD("setupDataCall: serial %d", serial);
1406 #endif
1407
1408 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1409 const hidl_string &protocol =
1410 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1411 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 7,
1412 std::to_string((int) radioTechnology + 2).c_str(),
1413 std::to_string((int) dataProfileInfo.profileId).c_str(),
1414 dataProfileInfo.apn.c_str(),
1415 dataProfileInfo.user.c_str(),
1416 dataProfileInfo.password.c_str(),
1417 std::to_string((int) dataProfileInfo.authType).c_str(),
1418 protocol.c_str());
1419 } else if (s_vendorFunctions->version == 15) {
1420 char *mvnoTypeStr = NULL;
1421 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1422 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1423 RIL_REQUEST_SETUP_DATA_CALL);
1424 if (pRI != NULL) {
1425 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1426 }
1427 return Void();
1428 }
1429 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
1430 std::to_string((int) radioTechnology + 2).c_str(),
1431 std::to_string((int) dataProfileInfo.profileId).c_str(),
1432 dataProfileInfo.apn.c_str(),
1433 dataProfileInfo.user.c_str(),
1434 dataProfileInfo.password.c_str(),
1435 std::to_string((int) dataProfileInfo.authType).c_str(),
1436 dataProfileInfo.protocol.c_str(),
1437 dataProfileInfo.roamingProtocol.c_str(),
1438 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1439 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1440 modemCognitive ? "1" : "0",
1441 std::to_string(dataProfileInfo.mtu).c_str(),
1442 mvnoTypeStr,
1443 dataProfileInfo.mvnoMatchData.c_str(),
1444 roamingAllowed ? "1" : "0");
1445 } else if (s_vendorFunctions->version >= 16) {
1446 char *mvnoTypeStr = NULL;
1447 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1448 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1449 RIL_REQUEST_SETUP_DATA_CALL);
1450 if (pRI != NULL) {
1451 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1452 }
1453 return Void();
1454 }
1455 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 16,
1456 std::to_string((int) radioTechnology + 2).c_str(),
1457 std::to_string((int) dataProfileInfo.profileId).c_str(),
1458 dataProfileInfo.apn.c_str(),
1459 dataProfileInfo.user.c_str(),
1460 dataProfileInfo.password.c_str(),
1461 std::to_string((int) dataProfileInfo.authType).c_str(),
1462 dataProfileInfo.protocol.c_str(),
1463 dataProfileInfo.roamingProtocol.c_str(),
1464 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1465 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1466 modemCognitive ? "1" : "0",
1467 std::to_string(dataProfileInfo.mtu).c_str(),
1468 mvnoTypeStr,
1469 dataProfileInfo.mvnoMatchData.c_str(),
1470 roamingAllowed ? "1" : "0",
1471 "-1",
1472 "");
1473 } else {
1474 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1475 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1476 RIL_REQUEST_SETUP_DATA_CALL);
1477 if (pRI != NULL) {
1478 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1479 }
1480 }
1481 return Void();
1482 }
1483
iccIOForApp(int32_t serial,const IccIo & iccIo)1484 Return<void> RadioImpl_1_6::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1485 #if VDBG
1486 RLOGD("iccIOForApp: serial %d", serial);
1487 #endif
1488 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1489 if (pRI == NULL) {
1490 return Void();
1491 }
1492
1493 RIL_SIM_IO_v6 rilIccIo = {};
1494 rilIccIo.command = iccIo.command;
1495 rilIccIo.fileid = iccIo.fileId;
1496 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1497 return Void();
1498 }
1499
1500 rilIccIo.p1 = iccIo.p1;
1501 rilIccIo.p2 = iccIo.p2;
1502 rilIccIo.p3 = iccIo.p3;
1503
1504 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1505 memsetAndFreeStrings(1, rilIccIo.path);
1506 return Void();
1507 }
1508
1509 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1510 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1511 return Void();
1512 }
1513
1514 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1515 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1516 return Void();
1517 }
1518
1519 CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1520
1521 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1522
1523 return Void();
1524 }
1525
sendUssd(int32_t serial,const hidl_string & ussd)1526 Return<void> RadioImpl_1_6::sendUssd(int32_t serial, const hidl_string& ussd) {
1527 #if VDBG
1528 RLOGD("sendUssd: serial %d", serial);
1529 #endif
1530 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1531 return Void();
1532 }
1533
cancelPendingUssd(int32_t serial)1534 Return<void> RadioImpl_1_6::cancelPendingUssd(int32_t serial) {
1535 #if VDBG
1536 RLOGD("cancelPendingUssd: serial %d", serial);
1537 #endif
1538 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1539 return Void();
1540 }
1541
getClir(int32_t serial)1542 Return<void> RadioImpl_1_6::getClir(int32_t serial) {
1543 #if VDBG
1544 RLOGD("getClir: serial %d", serial);
1545 #endif
1546 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1547 return Void();
1548 }
1549
setClir(int32_t serial,int32_t status)1550 Return<void> RadioImpl_1_6::setClir(int32_t serial, int32_t status) {
1551 #if VDBG
1552 RLOGD("setClir: serial %d", serial);
1553 #endif
1554 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1555 return Void();
1556 }
1557
getCallForwardStatus(int32_t serial,const CallForwardInfo & callInfo)1558 Return<void> RadioImpl_1_6::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1559 #if VDBG
1560 RLOGD("getCallForwardStatus: serial %d", serial);
1561 #endif
1562 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1563 callInfo);
1564 return Void();
1565 }
1566
setCallForward(int32_t serial,const CallForwardInfo & callInfo)1567 Return<void> RadioImpl_1_6::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1568 #if VDBG
1569 RLOGD("setCallForward: serial %d", serial);
1570 #endif
1571 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1572 callInfo);
1573 return Void();
1574 }
1575
getCallWaiting(int32_t serial,int32_t serviceClass)1576 Return<void> RadioImpl_1_6::getCallWaiting(int32_t serial, int32_t serviceClass) {
1577 #if VDBG
1578 RLOGD("getCallWaiting: serial %d", serial);
1579 #endif
1580 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1581 return Void();
1582 }
1583
setCallWaiting(int32_t serial,bool enable,int32_t serviceClass)1584 Return<void> RadioImpl_1_6::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1585 #if VDBG
1586 RLOGD("setCallWaiting: serial %d", serial);
1587 #endif
1588 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1589 serviceClass);
1590 return Void();
1591 }
1592
acknowledgeLastIncomingGsmSms(int32_t serial,bool success,SmsAcknowledgeFailCause cause)1593 Return<void> RadioImpl_1_6::acknowledgeLastIncomingGsmSms(int32_t serial,
1594 bool success, SmsAcknowledgeFailCause cause) {
1595 #if VDBG
1596 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1597 #endif
1598 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1599 cause);
1600 return Void();
1601 }
1602
acceptCall(int32_t serial)1603 Return<void> RadioImpl_1_6::acceptCall(int32_t serial) {
1604 #if VDBG
1605 RLOGD("acceptCall: serial %d", serial);
1606 #endif
1607 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1608 return Void();
1609 }
1610
deactivateDataCall(int32_t serial,int32_t cid,bool reasonRadioShutDown)1611 Return<void> RadioImpl_1_6::deactivateDataCall(int32_t serial,
1612 int32_t cid, bool reasonRadioShutDown) {
1613 #if VDBG
1614 RLOGD("deactivateDataCall: serial %d", serial);
1615 #endif
1616 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, false,
1617 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1618 return Void();
1619 }
1620
getFacilityLockForApp(int32_t serial,const hidl_string & facility,const hidl_string & password,int32_t serviceClass,const hidl_string & appId)1621 Return<void> RadioImpl_1_6::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1622 const hidl_string& password, int32_t serviceClass,
1623 const hidl_string& appId) {
1624 #if VDBG
1625 RLOGD("getFacilityLockForApp: serial %d", serial);
1626 #endif
1627 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK, true,
1628 4, facility.c_str(), password.c_str(),
1629 (std::to_string(serviceClass)).c_str(), appId.c_str());
1630 return Void();
1631 }
1632
setFacilityLockForApp(int32_t serial,const hidl_string & facility,bool lockState,const hidl_string & password,int32_t serviceClass,const hidl_string & appId)1633 Return<void> RadioImpl_1_6::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1634 bool lockState, const hidl_string& password,
1635 int32_t serviceClass, const hidl_string& appId) {
1636 #if VDBG
1637 RLOGD("setFacilityLockForApp: serial %d", serial);
1638 #endif
1639 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK, true,
1640 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1641 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1642 return Void();
1643 }
1644
setBarringPassword(int32_t serial,const hidl_string & facility,const hidl_string & oldPassword,const hidl_string & newPassword)1645 Return<void> RadioImpl_1_6::setBarringPassword(int32_t serial, const hidl_string& facility,
1646 const hidl_string& oldPassword,
1647 const hidl_string& newPassword) {
1648 #if VDBG
1649 RLOGD("setBarringPassword: serial %d", serial);
1650 #endif
1651 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD, true,
1652 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1653 return Void();
1654 }
1655
getNetworkSelectionMode(int32_t serial)1656 Return<void> RadioImpl_1_6::getNetworkSelectionMode(int32_t serial) {
1657 #if VDBG
1658 RLOGD("getNetworkSelectionMode: serial %d", serial);
1659 #endif
1660 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1661 return Void();
1662 }
1663
setNetworkSelectionModeAutomatic(int32_t serial)1664 Return<void> RadioImpl_1_6::setNetworkSelectionModeAutomatic(int32_t serial) {
1665 #if VDBG
1666 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1667 #endif
1668 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1669 return Void();
1670 }
1671
setNetworkSelectionModeManual(int32_t serial,const hidl_string & operatorNumeric)1672 Return<void> RadioImpl_1_6::setNetworkSelectionModeManual(int32_t serial,
1673 const hidl_string& operatorNumeric) {
1674 #if VDBG
1675 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1676 #endif
1677 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1678 RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL);
1679 if (pRI == NULL) {
1680 return Void();
1681 }
1682
1683 RIL_NetworkOperator networkOperator = {};
1684
1685 networkOperator.act = UNKNOWN;
1686 if (!copyHidlStringToRil(&networkOperator.operatorNumeric, operatorNumeric, pRI)) {
1687 return Void();
1688 }
1689 CALL_ONREQUEST(pRI->pCI->requestNumber, &networkOperator,
1690 sizeof(networkOperator), pRI, mSlotId);
1691
1692 return Void();
1693 }
1694
getAvailableNetworks(int32_t serial)1695 Return<void> RadioImpl_1_6::getAvailableNetworks(int32_t serial) {
1696 #if VDBG
1697 RLOGD("getAvailableNetworks: serial %d", serial);
1698 #endif
1699 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1700 return Void();
1701 }
1702
startNetworkScan(int32_t serial,const V1_1::NetworkScanRequest & request)1703 Return<void> RadioImpl_1_6::startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request) {
1704 #if VDBG
1705 RLOGD("startNetworkScan: serial %d", serial);
1706 #endif
1707
1708 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1709 if (pRI == NULL) {
1710 return Void();
1711 }
1712
1713 if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
1714 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1715 return Void();
1716 }
1717
1718 RIL_NetworkScanRequest scan_request = {};
1719
1720 scan_request.type = (RIL_ScanType) request.type;
1721 scan_request.interval = request.interval;
1722 scan_request.specifiers_length = request.specifiers.size();
1723 for (size_t i = 0; i < request.specifiers.size(); ++i) {
1724 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
1725 request.specifiers[i].utranBands.size() > MAX_BANDS ||
1726 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
1727 request.specifiers[i].channels.size() > MAX_CHANNELS) {
1728 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1729 return Void();
1730 }
1731 const V1_1::RadioAccessSpecifier& ras_from =
1732 request.specifiers[i];
1733 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
1734
1735 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
1736 ras_to.channels_length = ras_from.channels.size();
1737
1738 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
1739 const std::vector<uint32_t> * bands = nullptr;
1740 switch (request.specifiers[i].radioAccessNetwork) {
1741 case V1_1::RadioAccessNetworks::GERAN:
1742 ras_to.bands_length = ras_from.geranBands.size();
1743 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
1744 break;
1745 case V1_1::RadioAccessNetworks::UTRAN:
1746 ras_to.bands_length = ras_from.utranBands.size();
1747 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
1748 break;
1749 case V1_1::RadioAccessNetworks::EUTRAN:
1750 ras_to.bands_length = ras_from.eutranBands.size();
1751 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
1752 break;
1753 default:
1754 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1755 return Void();
1756 }
1757 // safe to copy to geran_bands because it's a union member
1758 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
1759 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
1760 }
1761 }
1762
1763 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
1764 mSlotId);
1765
1766 return Void();
1767 }
1768
stopNetworkScan(int32_t serial)1769 Return<void> RadioImpl_1_6::stopNetworkScan(int32_t serial) {
1770 #if VDBG
1771 RLOGD("stopNetworkScan: serial %d", serial);
1772 #endif
1773 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1774 return Void();
1775 }
1776
startDtmf(int32_t serial,const hidl_string & s)1777 Return<void> RadioImpl_1_6::startDtmf(int32_t serial, const hidl_string& s) {
1778 #if VDBG
1779 RLOGD("startDtmf: serial %d", serial);
1780 #endif
1781 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1782 s.c_str());
1783 return Void();
1784 }
1785
stopDtmf(int32_t serial)1786 Return<void> RadioImpl_1_6::stopDtmf(int32_t serial) {
1787 #if VDBG
1788 RLOGD("stopDtmf: serial %d", serial);
1789 #endif
1790 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1791 return Void();
1792 }
1793
getBasebandVersion(int32_t serial)1794 Return<void> RadioImpl_1_6::getBasebandVersion(int32_t serial) {
1795 #if VDBG
1796 RLOGD("getBasebandVersion: serial %d", serial);
1797 #endif
1798 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1799 return Void();
1800 }
1801
separateConnection(int32_t serial,int32_t gsmIndex)1802 Return<void> RadioImpl_1_6::separateConnection(int32_t serial, int32_t gsmIndex) {
1803 #if VDBG
1804 RLOGD("separateConnection: serial %d", serial);
1805 #endif
1806 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1807 return Void();
1808 }
1809
setMute(int32_t serial,bool enable)1810 Return<void> RadioImpl_1_6::setMute(int32_t serial, bool enable) {
1811 #if VDBG
1812 RLOGD("setMute: serial %d", serial);
1813 #endif
1814 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1815 return Void();
1816 }
1817
getMute(int32_t serial)1818 Return<void> RadioImpl_1_6::getMute(int32_t serial) {
1819 #if VDBG
1820 RLOGD("getMute: serial %d", serial);
1821 #endif
1822 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1823 return Void();
1824 }
1825
getClip(int32_t serial)1826 Return<void> RadioImpl_1_6::getClip(int32_t serial) {
1827 #if VDBG
1828 RLOGD("getClip: serial %d", serial);
1829 #endif
1830 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1831 return Void();
1832 }
1833
getDataCallList(int32_t serial)1834 Return<void> RadioImpl_1_6::getDataCallList(int32_t serial) {
1835 #if VDBG
1836 RLOGD("getDataCallList: serial %d", serial);
1837 #endif
1838 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1839 return Void();
1840 }
1841
getDataCallList_1_6(int32_t serial)1842 Return<void> RadioImpl_1_6::getDataCallList_1_6(int32_t serial) {
1843 #if VDBG
1844 RLOGD("getDataCallList_1_6: serial %d", serial);
1845 #endif
1846 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1847 return Void();
1848 }
1849
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)1850 Return<void> RadioImpl_1_6::emergencyDial_1_6(int32_t serial,
1851 const ::android::hardware::radio::V1_0::Dial& dialInfo,
1852 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
1853 const hidl_vec<hidl_string>& urns ,
1854 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
1855 bool fromEmergencyDialer, bool /* isTesting */) {
1856 #if VDBG
1857 RLOGD("emergencyDial: serial %d", serial);
1858 #endif
1859
1860 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_EMERGENCY_DIAL);
1861 if (pRI == NULL) {
1862 return Void();
1863 }
1864
1865 RIL_EmergencyDial eccDial = {};
1866 RIL_Dial& dial = eccDial.dialInfo;
1867 RIL_UUS_Info uusInfo = {};
1868
1869 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
1870 return Void();
1871 }
1872 dial.clir = (int) dialInfo.clir;
1873
1874 if (dialInfo.uusInfo.size() != 0) {
1875 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
1876 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
1877
1878 if (dialInfo.uusInfo[0].uusData.size() == 0) {
1879 uusInfo.uusData = NULL;
1880 uusInfo.uusLength = 0;
1881 } else {
1882 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
1883 memsetAndFreeStrings(1, dial.address);
1884 return Void();
1885 }
1886 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
1887 }
1888
1889 dial.uusInfo = &uusInfo;
1890 }
1891
1892 eccDial.urnsNumber = urns.size();
1893 if (eccDial.urnsNumber != 0) {
1894 char **ppUrns = (char **)calloc(eccDial.urnsNumber, sizeof(char *));
1895 if (ppUrns == NULL) {
1896 RLOGE("Memory allocation failed for request %s",
1897 requestToString(pRI->pCI->requestNumber));
1898 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1899 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1900 return Void();
1901 }
1902 for (uint32_t i = 0; i < eccDial.urnsNumber; i++) {
1903 if (!copyHidlStringToRil(&ppUrns[i], hidl_string(urns[i]), pRI)) {
1904 for (uint32_t j = 0; j < i; j++) {
1905 memsetAndFreeStrings(1, ppUrns[j]);
1906 }
1907 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1908 free(ppUrns);
1909 return Void();
1910 }
1911 }
1912 eccDial.urns = ppUrns;
1913 }
1914
1915 eccDial.categories = (RIL_EmergencyServiceCategory)categories;
1916 eccDial.routing = (RIL_EmergencyCallRouting)routing;
1917 eccDial.fromEmergencyDialer = fromEmergencyDialer;
1918
1919 CALL_ONREQUEST(RIL_REQUEST_EMERGENCY_DIAL, &eccDial, sizeof(RIL_EmergencyDial), pRI, mSlotId);
1920
1921 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1922 if (eccDial.urns != NULL) {
1923 for (size_t i = 0; i < eccDial.urnsNumber; i++) {
1924 memsetAndFreeStrings(1, eccDial.urns[i]);
1925 }
1926 free(eccDial.urns);
1927 }
1928 return Void();
1929 }
1930
setSuppServiceNotifications(int32_t serial,bool enable)1931 Return<void> RadioImpl_1_6::setSuppServiceNotifications(int32_t serial, bool enable) {
1932 #if VDBG
1933 RLOGD("setSuppServiceNotifications: serial %d", serial);
1934 #endif
1935 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1936 BOOL_TO_INT(enable));
1937 return Void();
1938 }
1939
writeSmsToSim(int32_t serial,const SmsWriteArgs & smsWriteArgs)1940 Return<void> RadioImpl_1_6::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1941 #if VDBG
1942 RLOGD("writeSmsToSim: serial %d", serial);
1943 #endif
1944 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1945 if (pRI == NULL) {
1946 return Void();
1947 }
1948
1949 RIL_SMS_WriteArgs args;
1950 args.status = (int) smsWriteArgs.status;
1951
1952 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1953 return Void();
1954 }
1955
1956 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1957 memsetAndFreeStrings(1, args.pdu);
1958 return Void();
1959 }
1960
1961 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
1962
1963 memsetAndFreeStrings(2, args.smsc, args.pdu);
1964
1965 return Void();
1966 }
1967
deleteSmsOnSim(int32_t serial,int32_t index)1968 Return<void> RadioImpl_1_6::deleteSmsOnSim(int32_t serial, int32_t index) {
1969 #if VDBG
1970 RLOGD("deleteSmsOnSim: serial %d", serial);
1971 #endif
1972 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1973 return Void();
1974 }
1975
setBandMode(int32_t serial,RadioBandMode mode)1976 Return<void> RadioImpl_1_6::setBandMode(int32_t serial, RadioBandMode mode) {
1977 #if VDBG
1978 RLOGD("setBandMode: serial %d", serial);
1979 #endif
1980 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1981 return Void();
1982 }
1983
getAvailableBandModes(int32_t serial)1984 Return<void> RadioImpl_1_6::getAvailableBandModes(int32_t serial) {
1985 #if VDBG
1986 RLOGD("getAvailableBandModes: serial %d", serial);
1987 #endif
1988 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1989 return Void();
1990 }
1991
sendEnvelope(int32_t serial,const hidl_string & command)1992 Return<void> RadioImpl_1_6::sendEnvelope(int32_t serial, const hidl_string& command) {
1993 #if VDBG
1994 RLOGD("sendEnvelope: serial %d", serial);
1995 #endif
1996 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1997 command.c_str());
1998 return Void();
1999 }
2000
sendTerminalResponseToSim(int32_t serial,const hidl_string & commandResponse)2001 Return<void> RadioImpl_1_6::sendTerminalResponseToSim(int32_t serial,
2002 const hidl_string& commandResponse) {
2003 #if VDBG
2004 RLOGD("sendTerminalResponseToSim: serial %d", serial);
2005 #endif
2006 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
2007 commandResponse.c_str());
2008 return Void();
2009 }
2010
handleStkCallSetupRequestFromSim(int32_t serial,bool accept)2011 Return<void> RadioImpl_1_6::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
2012 #if VDBG
2013 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
2014 #endif
2015 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
2016 1, BOOL_TO_INT(accept));
2017 return Void();
2018 }
2019
explicitCallTransfer(int32_t serial)2020 Return<void> RadioImpl_1_6::explicitCallTransfer(int32_t serial) {
2021 #if VDBG
2022 RLOGD("explicitCallTransfer: serial %d", serial);
2023 #endif
2024 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
2025 return Void();
2026 }
2027
setPreferredNetworkType(int32_t serial,PreferredNetworkType nwType)2028 Return<void> RadioImpl_1_6::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
2029 #if VDBG
2030 RLOGD("setPreferredNetworkType: serial %d", serial);
2031 #endif
2032 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
2033 return Void();
2034 }
2035
getPreferredNetworkType(int32_t serial)2036 Return<void> RadioImpl_1_6::getPreferredNetworkType(int32_t serial) {
2037 #if VDBG
2038 RLOGD("getPreferredNetworkType: serial %d", serial);
2039 #endif
2040 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
2041 return Void();
2042 }
2043
getNeighboringCids(int32_t serial)2044 Return<void> RadioImpl_1_6::getNeighboringCids(int32_t serial) {
2045 #if VDBG
2046 RLOGD("getNeighboringCids: serial %d", serial);
2047 #endif
2048 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
2049 return Void();
2050 }
2051
setLocationUpdates(int32_t serial,bool enable)2052 Return<void> RadioImpl_1_6::setLocationUpdates(int32_t serial, bool enable) {
2053 #if VDBG
2054 RLOGD("setLocationUpdates: serial %d", serial);
2055 #endif
2056 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
2057 return Void();
2058 }
2059
setCdmaSubscriptionSource(int32_t serial,CdmaSubscriptionSource cdmaSub)2060 Return<void> RadioImpl_1_6::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
2061 #if VDBG
2062 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
2063 #endif
2064 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
2065 return Void();
2066 }
2067
setCdmaRoamingPreference(int32_t serial,CdmaRoamingType type)2068 Return<void> RadioImpl_1_6::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
2069 #if VDBG
2070 RLOGD("setCdmaRoamingPreference: serial %d", serial);
2071 #endif
2072 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
2073 return Void();
2074 }
2075
getCdmaRoamingPreference(int32_t serial)2076 Return<void> RadioImpl_1_6::getCdmaRoamingPreference(int32_t serial) {
2077 #if VDBG
2078 RLOGD("getCdmaRoamingPreference: serial %d", serial);
2079 #endif
2080 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
2081 return Void();
2082 }
2083
setTTYMode(int32_t serial,TtyMode mode)2084 Return<void> RadioImpl_1_6::setTTYMode(int32_t serial, TtyMode mode) {
2085 #if VDBG
2086 RLOGD("setTTYMode: serial %d", serial);
2087 #endif
2088 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
2089 return Void();
2090 }
2091
getTTYMode(int32_t serial)2092 Return<void> RadioImpl_1_6::getTTYMode(int32_t serial) {
2093 #if VDBG
2094 RLOGD("getTTYMode: serial %d", serial);
2095 #endif
2096 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
2097 return Void();
2098 }
2099
setPreferredVoicePrivacy(int32_t serial,bool enable)2100 Return<void> RadioImpl_1_6::setPreferredVoicePrivacy(int32_t serial, bool enable) {
2101 #if VDBG
2102 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
2103 #endif
2104 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
2105 1, BOOL_TO_INT(enable));
2106 return Void();
2107 }
2108
getPreferredVoicePrivacy(int32_t serial)2109 Return<void> RadioImpl_1_6::getPreferredVoicePrivacy(int32_t serial) {
2110 #if VDBG
2111 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
2112 #endif
2113 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
2114 return Void();
2115 }
2116
sendCDMAFeatureCode(int32_t serial,const hidl_string & featureCode)2117 Return<void> RadioImpl_1_6::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
2118 #if VDBG
2119 RLOGD("sendCDMAFeatureCode: serial %d", serial);
2120 #endif
2121 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
2122 featureCode.c_str());
2123 return Void();
2124 }
2125
sendBurstDtmf(int32_t serial,const hidl_string & dtmf,int32_t on,int32_t off)2126 Return<void> RadioImpl_1_6::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
2127 int32_t off) {
2128 #if VDBG
2129 RLOGD("sendBurstDtmf: serial %d", serial);
2130 #endif
2131 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF, false,
2132 3, dtmf.c_str(), (std::to_string(on)).c_str(),
2133 (std::to_string(off)).c_str());
2134 return Void();
2135 }
2136
constructCdmaSms(RIL_CDMA_SMS_Message & rcsm,const CdmaSmsMessage & sms)2137 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
2138 rcsm.uTeleserviceID = sms.teleserviceId;
2139 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
2140 rcsm.uServicecategory = sms.serviceCategory;
2141 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
2142 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
2143 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
2144 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
2145
2146 rcsm.sAddress.number_of_digits = sms.address.digits.size();
2147 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
2148 for (int i = 0; i < digitLimit; i++) {
2149 rcsm.sAddress.digits[i] = sms.address.digits[i];
2150 }
2151
2152 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
2153 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
2154
2155 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
2156 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
2157 for (int i = 0; i < digitLimit; i++) {
2158 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
2159 }
2160
2161 rcsm.uBearerDataLen = sms.bearerData.size();
2162 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
2163 for (int i = 0; i < digitLimit; i++) {
2164 rcsm.aBearerData[i] = sms.bearerData[i];
2165 }
2166 }
2167
sendCdmaSms(int32_t serial,const CdmaSmsMessage & sms)2168 Return<void> RadioImpl_1_6::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
2169 #if VDBG
2170 RLOGD("sendCdmaSms: serial %d", serial);
2171 #endif
2172 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
2173 if (pRI == NULL) {
2174 return Void();
2175 }
2176
2177 RIL_CDMA_SMS_Message rcsm = {};
2178 constructCdmaSms(rcsm, sms);
2179
2180 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
2181 return Void();
2182 }
2183
sendCdmaSms_1_6(int32_t serial,const CdmaSmsMessage & sms)2184 Return<void> RadioImpl_1_6::sendCdmaSms_1_6(int32_t serial, const CdmaSmsMessage& sms) {
2185 #if VDBG
2186 RLOGD("sendCdmaSms: serial %d", serial);
2187 #endif
2188 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
2189 if (pRI == NULL) {
2190 return Void();
2191 }
2192
2193 RIL_CDMA_SMS_Message rcsm = {};
2194 constructCdmaSms(rcsm, sms);
2195
2196 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
2197 return Void();
2198 }
2199
acknowledgeLastIncomingCdmaSms(int32_t serial,const CdmaSmsAck & smsAck)2200 Return<void> RadioImpl_1_6::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
2201 #if VDBG
2202 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
2203 #endif
2204 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
2205 if (pRI == NULL) {
2206 return Void();
2207 }
2208
2209 RIL_CDMA_SMS_Ack rcsa = {};
2210
2211 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
2212 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
2213
2214 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
2215 return Void();
2216 }
2217
getGsmBroadcastConfig(int32_t serial)2218 Return<void> RadioImpl_1_6::getGsmBroadcastConfig(int32_t serial) {
2219 #if VDBG
2220 RLOGD("getGsmBroadcastConfig: serial %d", serial);
2221 #endif
2222 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
2223 return Void();
2224 }
2225
setGsmBroadcastConfig(int32_t serial,const hidl_vec<GsmBroadcastSmsConfigInfo> & configInfo)2226 Return<void> RadioImpl_1_6::setGsmBroadcastConfig(int32_t serial,
2227 const hidl_vec<GsmBroadcastSmsConfigInfo>&
2228 configInfo) {
2229 #if VDBG
2230 RLOGD("setGsmBroadcastConfig: serial %d", serial);
2231 #endif
2232 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2233 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
2234 if (pRI == NULL) {
2235 return Void();
2236 }
2237
2238 int num = configInfo.size();
2239 if (num > MAX_BROADCAST_SMS_CONFIG_INFO) {
2240 RLOGE("setGsmBroadcastConfig: Invalid configInfo length %s",
2241 requestToString(pRI->pCI->requestNumber));
2242 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2243 return Void();
2244 }
2245 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
2246 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
2247
2248 for (int i = 0 ; i < num ; i++ ) {
2249 gsmBciPtrs[i] = &gsmBci[i];
2250 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
2251 gsmBci[i].toServiceId = configInfo[i].toServiceId;
2252 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
2253 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
2254 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
2255 }
2256
2257 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs,
2258 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
2259 return Void();
2260 }
2261
setGsmBroadcastActivation(int32_t serial,bool activate)2262 Return<void> RadioImpl_1_6::setGsmBroadcastActivation(int32_t serial, bool activate) {
2263 #if VDBG
2264 RLOGD("setGsmBroadcastActivation: serial %d", serial);
2265 #endif
2266 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
2267 1, BOOL_TO_INT(!activate));
2268 return Void();
2269 }
2270
getCdmaBroadcastConfig(int32_t serial)2271 Return<void> RadioImpl_1_6::getCdmaBroadcastConfig(int32_t serial) {
2272 #if VDBG
2273 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
2274 #endif
2275 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
2276 return Void();
2277 }
2278
setCdmaBroadcastConfig(int32_t serial,const hidl_vec<CdmaBroadcastSmsConfigInfo> & configInfo)2279 Return<void> RadioImpl_1_6::setCdmaBroadcastConfig(int32_t serial,
2280 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
2281 configInfo) {
2282 #if VDBG
2283 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
2284 #endif
2285 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2286 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
2287 if (pRI == NULL) {
2288 return Void();
2289 }
2290
2291 int num = configInfo.size();
2292 if (num > MAX_BROADCAST_SMS_CONFIG_INFO) {
2293 RLOGE("setCdmaBroadcastConfig: Invalid configInfo length %s",
2294 requestToString(pRI->pCI->requestNumber));
2295 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2296 return Void();
2297 }
2298 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
2299 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
2300
2301 for (int i = 0 ; i < num ; i++ ) {
2302 cdmaBciPtrs[i] = &cdmaBci[i];
2303 cdmaBci[i].service_category = configInfo[i].serviceCategory;
2304 cdmaBci[i].language = configInfo[i].language;
2305 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
2306 }
2307
2308 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs,
2309 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
2310 return Void();
2311 }
2312
setCdmaBroadcastActivation(int32_t serial,bool activate)2313 Return<void> RadioImpl_1_6::setCdmaBroadcastActivation(int32_t serial, bool activate) {
2314 #if VDBG
2315 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
2316 #endif
2317 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
2318 1, BOOL_TO_INT(!activate));
2319 return Void();
2320 }
2321
getCDMASubscription(int32_t serial)2322 Return<void> RadioImpl_1_6::getCDMASubscription(int32_t serial) {
2323 #if VDBG
2324 RLOGD("getCDMASubscription: serial %d", serial);
2325 #endif
2326 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
2327 return Void();
2328 }
2329
writeSmsToRuim(int32_t serial,const CdmaSmsWriteArgs & cdmaSms)2330 Return<void> RadioImpl_1_6::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
2331 #if VDBG
2332 RLOGD("writeSmsToRuim: serial %d", serial);
2333 #endif
2334 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2335 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
2336 if (pRI == NULL) {
2337 return Void();
2338 }
2339
2340 RIL_CDMA_SMS_WriteArgs rcsw = {};
2341 rcsw.status = (int) cdmaSms.status;
2342 constructCdmaSms(rcsw.message, cdmaSms.message);
2343
2344 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
2345 return Void();
2346 }
2347
deleteSmsOnRuim(int32_t serial,int32_t index)2348 Return<void> RadioImpl_1_6::deleteSmsOnRuim(int32_t serial, int32_t index) {
2349 #if VDBG
2350 RLOGD("deleteSmsOnRuim: serial %d", serial);
2351 #endif
2352 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
2353 return Void();
2354 }
2355
getDeviceIdentity(int32_t serial)2356 Return<void> RadioImpl_1_6::getDeviceIdentity(int32_t serial) {
2357 #if VDBG
2358 RLOGD("getDeviceIdentity: serial %d", serial);
2359 #endif
2360 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
2361 return Void();
2362 }
2363
exitEmergencyCallbackMode(int32_t serial)2364 Return<void> RadioImpl_1_6::exitEmergencyCallbackMode(int32_t serial) {
2365 #if VDBG
2366 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
2367 #endif
2368 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
2369 return Void();
2370 }
2371
getSmscAddress(int32_t serial)2372 Return<void> RadioImpl_1_6::getSmscAddress(int32_t serial) {
2373 #if VDBG
2374 RLOGD("getSmscAddress: serial %d", serial);
2375 #endif
2376 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
2377 return Void();
2378 }
2379
setSmscAddress(int32_t serial,const hidl_string & smsc)2380 Return<void> RadioImpl_1_6::setSmscAddress(int32_t serial, const hidl_string& smsc) {
2381 #if VDBG
2382 RLOGD("setSmscAddress: serial %d", serial);
2383 #endif
2384 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
2385 smsc.c_str());
2386 return Void();
2387 }
2388
reportSmsMemoryStatus(int32_t serial,bool available)2389 Return<void> RadioImpl_1_6::reportSmsMemoryStatus(int32_t serial, bool available) {
2390 #if VDBG
2391 RLOGD("reportSmsMemoryStatus: serial %d", serial);
2392 #endif
2393 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
2394 BOOL_TO_INT(available));
2395 return Void();
2396 }
2397
reportStkServiceIsRunning(int32_t serial)2398 Return<void> RadioImpl_1_6::reportStkServiceIsRunning(int32_t serial) {
2399 #if VDBG
2400 RLOGD("reportStkServiceIsRunning: serial %d", serial);
2401 #endif
2402 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
2403 return Void();
2404 }
2405
getCdmaSubscriptionSource(int32_t serial)2406 Return<void> RadioImpl_1_6::getCdmaSubscriptionSource(int32_t serial) {
2407 #if VDBG
2408 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
2409 #endif
2410 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
2411 return Void();
2412 }
2413
requestIsimAuthentication(int32_t serial,const hidl_string & challenge)2414 Return<void> RadioImpl_1_6::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
2415 #if VDBG
2416 RLOGD("requestIsimAuthentication: serial %d", serial);
2417 #endif
2418 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
2419 challenge.c_str());
2420 return Void();
2421 }
2422
acknowledgeIncomingGsmSmsWithPdu(int32_t serial,bool success,const hidl_string & ackPdu)2423 Return<void> RadioImpl_1_6::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
2424 const hidl_string& ackPdu) {
2425 #if VDBG
2426 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
2427 #endif
2428 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, false,
2429 2, success ? "1" : "0", ackPdu.c_str());
2430 return Void();
2431 }
2432
sendEnvelopeWithStatus(int32_t serial,const hidl_string & contents)2433 Return<void> RadioImpl_1_6::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
2434 #if VDBG
2435 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
2436 #endif
2437 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
2438 contents.c_str());
2439 return Void();
2440 }
2441
getVoiceRadioTechnology(int32_t serial)2442 Return<void> RadioImpl_1_6::getVoiceRadioTechnology(int32_t serial) {
2443 #if VDBG
2444 RLOGD("getVoiceRadioTechnology: serial %d", serial);
2445 #endif
2446 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
2447 return Void();
2448 }
2449
getCellInfoList(int32_t serial)2450 Return<void> RadioImpl_1_6::getCellInfoList(int32_t serial) {
2451 #if VDBG
2452 RLOGD("getCellInfoList: serial %d", serial);
2453 #endif
2454 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
2455 return Void();
2456 }
2457
getCellInfoList_1_6(int32_t serial)2458 Return<void> RadioImpl_1_6::getCellInfoList_1_6(int32_t serial) {
2459 #if VDBG
2460 RLOGD("getCellInfoList_1_6: serial %d", serial);
2461 #endif
2462 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST_1_6);
2463 return Void();
2464 }
2465
setCellInfoListRate(int32_t serial,int32_t rate)2466 Return<void> RadioImpl_1_6::setCellInfoListRate(int32_t serial, int32_t rate) {
2467 #if VDBG
2468 RLOGD("setCellInfoListRate: serial %d", serial);
2469 #endif
2470 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
2471 return Void();
2472 }
2473
setInitialAttachApn(int32_t serial,const DataProfileInfo & dataProfileInfo,bool modemCognitive,bool isRoaming)2474 Return<void> RadioImpl_1_6::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
2475 bool modemCognitive, bool isRoaming) {
2476 #if VDBG
2477 RLOGD("setInitialAttachApn: serial %d", serial);
2478 #endif
2479 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2480 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
2481 if (pRI == NULL) {
2482 return Void();
2483 }
2484
2485 if (s_vendorFunctions->version <= 14) {
2486 RIL_InitialAttachApn iaa = {};
2487
2488 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2489 return Void();
2490 }
2491
2492 const hidl_string &protocol =
2493 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
2494
2495 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
2496 memsetAndFreeStrings(1, iaa.apn);
2497 return Void();
2498 }
2499 iaa.authtype = (int) dataProfileInfo.authType;
2500 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2501 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2502 return Void();
2503 }
2504 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2505 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
2506 return Void();
2507 }
2508
2509 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2510
2511 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
2512 } else {
2513 RIL_InitialAttachApn_v15 iaa = {};
2514
2515 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2516 return Void();
2517 }
2518
2519 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
2520 memsetAndFreeStrings(1, iaa.apn);
2521 return Void();
2522 }
2523 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
2524 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2525 return Void();
2526 }
2527 iaa.authtype = (int) dataProfileInfo.authType;
2528 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2529 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
2530 return Void();
2531 }
2532 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2533 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
2534 return Void();
2535 }
2536 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
2537 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
2538 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
2539 iaa.mtu = dataProfileInfo.mtu;
2540
2541 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
2542 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2543 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2544 iaa.password);
2545 return Void();
2546 }
2547
2548 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
2549 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2550 iaa.password);
2551 return Void();
2552 }
2553
2554 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2555
2556 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2557 iaa.password, iaa.mvnoMatchData);
2558 }
2559
2560 return Void();
2561 }
2562
getImsRegistrationState(int32_t serial)2563 Return<void> RadioImpl_1_6::getImsRegistrationState(int32_t serial) {
2564 #if VDBG
2565 RLOGD("getImsRegistrationState: serial %d", serial);
2566 #endif
2567 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2568 return Void();
2569 }
2570
dispatchImsGsmSms(const ImsSmsMessage & message,RequestInfo * pRI)2571 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2572 RIL_IMS_SMS_Message rism = {};
2573 char **pStrings;
2574 int countStrings = 2;
2575 int dataLen = sizeof(char *) * countStrings;
2576
2577 rism.tech = RADIO_TECH_3GPP;
2578 rism.retry = BOOL_TO_INT(message.retry);
2579 rism.messageRef = message.messageRef;
2580
2581 if (message.gsmMessage.size() != 1) {
2582 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2583 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2584 return false;
2585 }
2586
2587 pStrings = (char **)calloc(countStrings, sizeof(char *));
2588 if (pStrings == NULL) {
2589 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2590 requestToString(pRI->pCI->requestNumber));
2591 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2592 return false;
2593 }
2594
2595 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2596 #ifdef MEMSET_FREED
2597 memset(pStrings, 0, dataLen);
2598 #endif
2599 free(pStrings);
2600 return false;
2601 }
2602
2603 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2604 memsetAndFreeStrings(1, pStrings[0]);
2605 #ifdef MEMSET_FREED
2606 memset(pStrings, 0, dataLen);
2607 #endif
2608 free(pStrings);
2609 return false;
2610 }
2611
2612 rism.message.gsmMessage = pStrings;
2613 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2614 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2615
2616 for (int i = 0 ; i < countStrings ; i++) {
2617 memsetAndFreeStrings(1, pStrings[i]);
2618 }
2619
2620 #ifdef MEMSET_FREED
2621 memset(pStrings, 0, dataLen);
2622 #endif
2623 free(pStrings);
2624
2625 return true;
2626 }
2627
2628 struct ImsCdmaSms {
2629 RIL_IMS_SMS_Message imsSms;
2630 RIL_CDMA_SMS_Message cdmaSms;
2631 };
2632
dispatchImsCdmaSms(const ImsSmsMessage & message,RequestInfo * pRI)2633 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2634 ImsCdmaSms temp = {};
2635
2636 if (message.cdmaMessage.size() != 1) {
2637 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2638 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2639 return false;
2640 }
2641
2642 temp.imsSms.tech = RADIO_TECH_3GPP2;
2643 temp.imsSms.retry = BOOL_TO_INT(message.retry);
2644 temp.imsSms.messageRef = message.messageRef;
2645 temp.imsSms.message.cdmaMessage = &temp.cdmaSms;
2646
2647 constructCdmaSms(temp.cdmaSms, message.cdmaMessage[0]);
2648
2649 // Vendor code expects payload length to include actual msg payload
2650 // (sizeof(RIL_CDMA_SMS_Message)) instead of (RIL_CDMA_SMS_Message *) + size of other fields in
2651 // RIL_IMS_SMS_Message
2652 int payloadLen = sizeof(RIL_RadioTechnologyFamily) + sizeof(uint8_t) + sizeof(int32_t)
2653 + sizeof(RIL_CDMA_SMS_Message);
2654
2655 CALL_ONREQUEST(pRI->pCI->requestNumber, &temp.imsSms, payloadLen, pRI, pRI->socket_id);
2656
2657 return true;
2658 }
2659
sendImsSms(int32_t serial,const ImsSmsMessage & message)2660 Return<void> RadioImpl_1_6::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2661 #if VDBG
2662 RLOGD("sendImsSms: serial %d", serial);
2663 #endif
2664 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2665 if (pRI == NULL) {
2666 return Void();
2667 }
2668
2669 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2670
2671 if (RADIO_TECH_3GPP == format) {
2672 dispatchImsGsmSms(message, pRI);
2673 } else if (RADIO_TECH_3GPP2 == format) {
2674 dispatchImsCdmaSms(message, pRI);
2675 } else {
2676 RLOGE("sendImsSms: Invalid radio tech %s",
2677 requestToString(pRI->pCI->requestNumber));
2678 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2679 }
2680 return Void();
2681 }
2682
iccTransmitApduBasicChannel(int32_t serial,const SimApdu & message)2683 Return<void> RadioImpl_1_6::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2684 #if VDBG
2685 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2686 #endif
2687 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2688 return Void();
2689 }
2690
iccOpenLogicalChannel(int32_t serial,const hidl_string & aid,int32_t p2)2691 Return<void> RadioImpl_1_6::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2692 #if VDBG
2693 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2694 #endif
2695 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2696 if (pRI == NULL) {
2697 return Void();
2698 }
2699
2700 RIL_OpenChannelParams params = {};
2701
2702 params.p2 = p2;
2703
2704 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2705 return Void();
2706 }
2707
2708 CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId);
2709
2710 memsetAndFreeStrings(1, params.aidPtr);
2711 return Void();
2712 }
2713
iccCloseLogicalChannel(int32_t serial,int32_t channelId)2714 Return<void> RadioImpl_1_6::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2715 #if VDBG
2716 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2717 #endif
2718 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2719 return Void();
2720 }
2721
iccTransmitApduLogicalChannel(int32_t serial,const SimApdu & message)2722 Return<void> RadioImpl_1_6::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2723 #if VDBG
2724 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2725 #endif
2726 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2727 return Void();
2728 }
2729
nvReadItem(int32_t serial,NvItem itemId)2730 Return<void> RadioImpl_1_6::nvReadItem(int32_t serial, NvItem itemId) {
2731 #if VDBG
2732 RLOGD("nvReadItem: serial %d", serial);
2733 #endif
2734 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2735 if (pRI == NULL) {
2736 return Void();
2737 }
2738
2739 RIL_NV_ReadItem nvri = {};
2740 nvri.itemID = (RIL_NV_Item) itemId;
2741
2742 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2743 return Void();
2744 }
2745
nvWriteItem(int32_t serial,const NvWriteItem & item)2746 Return<void> RadioImpl_1_6::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2747 #if VDBG
2748 RLOGD("nvWriteItem: serial %d", serial);
2749 #endif
2750 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2751 if (pRI == NULL) {
2752 return Void();
2753 }
2754
2755 RIL_NV_WriteItem nvwi = {};
2756
2757 nvwi.itemID = (RIL_NV_Item) item.itemId;
2758
2759 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2760 return Void();
2761 }
2762
2763 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2764
2765 memsetAndFreeStrings(1, nvwi.value);
2766 return Void();
2767 }
2768
nvWriteCdmaPrl(int32_t serial,const hidl_vec<uint8_t> & prl)2769 Return<void> RadioImpl_1_6::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2770 #if VDBG
2771 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2772 #endif
2773 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2774 return Void();
2775 }
2776
nvResetConfig(int32_t serial,ResetNvType resetType)2777 Return<void> RadioImpl_1_6::nvResetConfig(int32_t serial, ResetNvType resetType) {
2778 int rilResetType = -1;
2779 #if VDBG
2780 RLOGD("nvResetConfig: serial %d", serial);
2781 #endif
2782 /* Convert ResetNvType to RIL.h values
2783 * RIL_REQUEST_NV_RESET_CONFIG
2784 * 1 - reload all NV items
2785 * 2 - erase NV reset (SCRTN)
2786 * 3 - factory reset (RTN)
2787 */
2788 switch(resetType) {
2789 case ResetNvType::RELOAD:
2790 rilResetType = 1;
2791 break;
2792 case ResetNvType::ERASE:
2793 rilResetType = 2;
2794 break;
2795 case ResetNvType::FACTORY_RESET:
2796 rilResetType = 3;
2797 break;
2798 }
2799 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2800 return Void();
2801 }
2802
setUiccSubscription(int32_t serial,const SelectUiccSub & uiccSub)2803 Return<void> RadioImpl_1_6::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2804 #if VDBG
2805 RLOGD("setUiccSubscription: serial %d", serial);
2806 #endif
2807 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2808 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2809 if (pRI == NULL) {
2810 return Void();
2811 }
2812
2813 RIL_SelectUiccSub rilUiccSub = {};
2814
2815 rilUiccSub.slot = uiccSub.slot;
2816 rilUiccSub.app_index = uiccSub.appIndex;
2817 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2818 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2819
2820 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2821 return Void();
2822 }
2823
setDataAllowed(int32_t serial,bool allow)2824 Return<void> RadioImpl_1_6::setDataAllowed(int32_t serial, bool allow) {
2825 #if VDBG
2826 RLOGD("setDataAllowed: serial %d", serial);
2827 #endif
2828 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2829 return Void();
2830 }
2831
getHardwareConfig(int32_t serial)2832 Return<void> RadioImpl_1_6::getHardwareConfig(int32_t serial) {
2833 #if VDBG
2834 RLOGD("getHardwareConfig: serial %d", serial);
2835 #endif
2836 RLOGD("getHardwareConfig: serial %d, mSlotId = %d", serial, mSlotId);
2837 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2838 return Void();
2839 }
2840
requestIccSimAuthentication(int32_t serial,int32_t authContext,const hidl_string & authData,const hidl_string & aid)2841 Return<void> RadioImpl_1_6::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2842 const hidl_string& authData, const hidl_string& aid) {
2843 #if VDBG
2844 RLOGD("requestIccSimAuthentication: serial %d", serial);
2845 #endif
2846 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2847 if (pRI == NULL) {
2848 return Void();
2849 }
2850
2851 RIL_SimAuthentication pf = {};
2852
2853 pf.authContext = authContext;
2854
2855 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2856 return Void();
2857 }
2858
2859 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2860 memsetAndFreeStrings(1, pf.authData);
2861 return Void();
2862 }
2863
2864 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2865
2866 memsetAndFreeStrings(2, pf.authData, pf.aid);
2867 return Void();
2868 }
2869
2870 /**
2871 * @param numProfiles number of data profile
2872 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2873 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2874 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2875 * @param numfields number of string-type member in the data profile structure
2876 * @param ... the variadic parameters are pointers to each string-type member
2877 **/
2878 template <typename T>
freeSetDataProfileData(int numProfiles,T * dataProfiles,T ** dataProfilePtrs,int numfields,...)2879 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2880 int numfields, ...) {
2881 va_list args;
2882 va_start(args, numfields);
2883
2884 // Iterate through each string-type field that need to be free.
2885 for (int i = 0; i < numfields; i++) {
2886 // Iterate through each data profile and free that specific string-type field.
2887 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2888 char *T::*ptr = va_arg(args, char *T::*);
2889 for (int j = 0; j < numProfiles; j++) {
2890 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2891 }
2892 }
2893
2894 va_end(args);
2895
2896 #ifdef MEMSET_FREED
2897 memset(dataProfiles, 0, numProfiles * sizeof(T));
2898 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2899 #endif
2900 free(dataProfiles);
2901 free(dataProfilePtrs);
2902 }
2903
setDataProfile(int32_t serial,const hidl_vec<DataProfileInfo> & profiles,bool isRoaming)2904 Return<void> RadioImpl_1_6::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2905 bool isRoaming) {
2906 #if VDBG
2907 RLOGD("setDataProfile: serial %d", serial);
2908 #endif
2909 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2910 if (pRI == NULL) {
2911 return Void();
2912 }
2913
2914 size_t num = profiles.size();
2915 bool success = false;
2916
2917 if (s_vendorFunctions->version <= 14) {
2918
2919 RIL_DataProfileInfo *dataProfiles =
2920 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2921
2922 if (dataProfiles == NULL) {
2923 RLOGE("Memory allocation failed for request %s",
2924 requestToString(pRI->pCI->requestNumber));
2925 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2926 return Void();
2927 }
2928
2929 RIL_DataProfileInfo **dataProfilePtrs =
2930 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2931 if (dataProfilePtrs == NULL) {
2932 RLOGE("Memory allocation failed for request %s",
2933 requestToString(pRI->pCI->requestNumber));
2934 free(dataProfiles);
2935 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2936 return Void();
2937 }
2938
2939 for (size_t i = 0; i < num; i++) {
2940 dataProfilePtrs[i] = &dataProfiles[i];
2941
2942 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2943
2944 const hidl_string &protocol =
2945 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2946
2947 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI, true)) {
2948 success = false;
2949 }
2950
2951 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2952 true)) {
2953 success = false;
2954 }
2955 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2956 pRI, true)) {
2957 success = false;
2958 }
2959
2960 if (!success) {
2961 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2962 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2963 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2964 return Void();
2965 }
2966
2967 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2968 dataProfiles[i].authType = (int) profiles[i].authType;
2969 dataProfiles[i].type = (int) profiles[i].type;
2970 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2971 dataProfiles[i].maxConns = profiles[i].maxConns;
2972 dataProfiles[i].waitTime = profiles[i].waitTime;
2973 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2974 }
2975
2976 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2977 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2978
2979 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2980 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2981 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2982 } else {
2983 RIL_DataProfileInfo_v15 *dataProfiles =
2984 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2985
2986 if (dataProfiles == NULL) {
2987 RLOGE("Memory allocation failed for request %s",
2988 requestToString(pRI->pCI->requestNumber));
2989 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2990 return Void();
2991 }
2992
2993 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2994 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2995 if (dataProfilePtrs == NULL) {
2996 RLOGE("Memory allocation failed for request %s",
2997 requestToString(pRI->pCI->requestNumber));
2998 free(dataProfiles);
2999 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3000 return Void();
3001 }
3002
3003 for (size_t i = 0; i < num; i++) {
3004 dataProfilePtrs[i] = &dataProfiles[i];
3005
3006 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
3007 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
3008 pRI)) {
3009 success = false;
3010 }
3011 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
3012 profiles[i].roamingProtocol, pRI, true)) {
3013 success = false;
3014 }
3015 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
3016 true)) {
3017 success = false;
3018 }
3019 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
3020 pRI, true)) {
3021 success = false;
3022 }
3023 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
3024 profiles[i].mvnoMatchData, pRI, true)) {
3025 success = false;
3026 }
3027
3028 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
3029 dataProfiles[i].mvnoType)) {
3030 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3031 success = false;
3032 }
3033
3034 if (!success) {
3035 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
3036 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
3037 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
3038 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
3039 return Void();
3040 }
3041
3042 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
3043 dataProfiles[i].authType = (int) profiles[i].authType;
3044 dataProfiles[i].type = (int) profiles[i].type;
3045 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
3046 dataProfiles[i].maxConns = profiles[i].maxConns;
3047 dataProfiles[i].waitTime = profiles[i].waitTime;
3048 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
3049 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
3050 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
3051 dataProfiles[i].mtu = profiles[i].mtu;
3052 }
3053
3054 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
3055 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
3056
3057 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
3058 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
3059 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
3060 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
3061 }
3062
3063 return Void();
3064 }
3065
requestShutdown(int32_t serial)3066 Return<void> RadioImpl_1_6::requestShutdown(int32_t serial) {
3067 #if VDBG
3068 RLOGD("requestShutdown: serial %d", serial);
3069 #endif
3070 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
3071 return Void();
3072 }
3073
getRadioCapability(int32_t serial)3074 Return<void> RadioImpl_1_6::getRadioCapability(int32_t serial) {
3075 #if VDBG
3076 RLOGD("getRadioCapability: serial %d", serial);
3077 #endif
3078 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
3079 return Void();
3080 }
3081
setRadioCapability(int32_t serial,const RadioCapability & rc)3082 Return<void> RadioImpl_1_6::setRadioCapability(int32_t serial, const RadioCapability& rc) {
3083 #if VDBG
3084 RLOGD("setRadioCapability: serial %d", serial);
3085 #endif
3086 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
3087 if (pRI == NULL) {
3088 return Void();
3089 }
3090
3091 RIL_RadioCapability rilRc = {};
3092
3093 // TODO : set rilRc.version using HIDL version ?
3094 rilRc.session = rc.session;
3095 rilRc.phase = (int) rc.phase;
3096 rilRc.rat = (int) rc.raf;
3097 rilRc.status = (int) rc.status;
3098 strlcpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), sizeof(rilRc.logicalModemUuid));
3099
3100 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
3101
3102 return Void();
3103 }
3104
startLceService(int32_t serial,int32_t reportInterval,bool pullMode)3105 Return<void> RadioImpl_1_6::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
3106 #if VDBG
3107 RLOGD("startLceService: serial %d", serial);
3108 #endif
3109 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
3110 BOOL_TO_INT(pullMode));
3111 return Void();
3112 }
3113
stopLceService(int32_t serial)3114 Return<void> RadioImpl_1_6::stopLceService(int32_t serial) {
3115 #if VDBG
3116 RLOGD("stopLceService: serial %d", serial);
3117 #endif
3118 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
3119 return Void();
3120 }
3121
pullLceData(int32_t serial)3122 Return<void> RadioImpl_1_6::pullLceData(int32_t serial) {
3123 #if VDBG
3124 RLOGD("pullLceData: serial %d", serial);
3125 #endif
3126 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
3127 return Void();
3128 }
3129
getModemActivityInfo(int32_t serial)3130 Return<void> RadioImpl_1_6::getModemActivityInfo(int32_t serial) {
3131 #if VDBG
3132 RLOGD("getModemActivityInfo: serial %d", serial);
3133 #endif
3134 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
3135 return Void();
3136 }
3137
prepareCarrierRestrictions(RIL_CarrierRestrictions & request,bool allAllowed,const hidl_vec<Carrier> & allowedList,const hidl_vec<Carrier> & excludedList,RequestInfo * pRI)3138 int prepareCarrierRestrictions(RIL_CarrierRestrictions &request, bool allAllowed,
3139 const hidl_vec<Carrier>& allowedList,
3140 const hidl_vec<Carrier>& excludedList,
3141 RequestInfo *pRI) {
3142 RIL_Carrier *allowedCarriers = NULL;
3143 RIL_Carrier *excludedCarriers = NULL;
3144
3145 request.len_allowed_carriers = allowedList.size();
3146 allowedCarriers = (RIL_Carrier *)calloc(request.len_allowed_carriers, sizeof(RIL_Carrier));
3147 if (allowedCarriers == NULL) {
3148 RLOGE("prepareCarrierRestrictions: Memory allocation failed for request %s",
3149 requestToString(pRI->pCI->requestNumber));
3150 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3151 return -1;
3152 }
3153 request.allowed_carriers = allowedCarriers;
3154
3155 request.len_excluded_carriers = excludedList.size();
3156 excludedCarriers = (RIL_Carrier *)calloc(request.len_excluded_carriers, sizeof(RIL_Carrier));
3157 if (excludedCarriers == NULL) {
3158 RLOGE("prepareCarrierRestrictions: Memory allocation failed for request %s",
3159 requestToString(pRI->pCI->requestNumber));
3160 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3161 #ifdef MEMSET_FREED
3162 memset(allowedCarriers, 0, request.len_allowed_carriers * sizeof(RIL_Carrier));
3163 #endif
3164 free(allowedCarriers);
3165 return -1;
3166 }
3167 request.excluded_carriers = excludedCarriers;
3168
3169 for (int i = 0; i < request.len_allowed_carriers; i++) {
3170 allowedCarriers[i].mcc = allowedList[i].mcc.c_str();
3171 allowedCarriers[i].mnc = allowedList[i].mnc.c_str();
3172 allowedCarriers[i].match_type = (RIL_CarrierMatchType) allowedList[i].matchType;
3173 allowedCarriers[i].match_data = allowedList[i].matchData.c_str();
3174 }
3175
3176 for (int i = 0; i < request.len_excluded_carriers; i++) {
3177 excludedCarriers[i].mcc = excludedList[i].mcc.c_str();
3178 excludedCarriers[i].mnc = excludedList[i].mnc.c_str();
3179 excludedCarriers[i].match_type =
3180 (RIL_CarrierMatchType) excludedList[i].matchType;
3181 excludedCarriers[i].match_data = excludedList[i].matchData.c_str();
3182 }
3183
3184 return 0;
3185 }
3186
freeCarrierRestrictions(RIL_CarrierRestrictions & request)3187 void freeCarrierRestrictions(RIL_CarrierRestrictions &request) {
3188 if (request.allowed_carriers != NULL) {
3189 #ifdef MEMSET_FREED
3190 memset(request.allowed_carriers, 0, request.len_allowed_carriers * sizeof(RIL_Carrier));
3191 #endif
3192 free(request.allowed_carriers);
3193 }
3194 if (request.excluded_carriers != NULL) {
3195 #ifdef MEMSET_FREED
3196 memset(request.excluded_carriers, 0, request.len_excluded_carriers * sizeof(RIL_Carrier));
3197 #endif
3198 free(request.excluded_carriers);
3199 }
3200 }
3201
setAllowedCarriers(int32_t serial,bool allAllowed,const CarrierRestrictions & carriers)3202 Return<void> RadioImpl_1_6::setAllowedCarriers(int32_t serial, bool allAllowed,
3203 const CarrierRestrictions& carriers) {
3204 #if VDBG
3205 RLOGD("setAllowedCarriers: serial %d", serial);
3206 #endif
3207 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3208 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
3209 if (pRI == NULL) {
3210 return Void();
3211 }
3212
3213 RIL_CarrierRestrictions cr = {};
3214 if (prepareCarrierRestrictions(cr, allAllowed, carriers.allowedCarriers,
3215 carriers.excludedCarriers, pRI) < 0) {
3216 return Void();
3217 }
3218
3219 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
3220
3221 freeCarrierRestrictions(cr);
3222
3223 return Void();
3224 }
3225
getAllowedCarriers(int32_t serial)3226 Return<void> RadioImpl_1_6::getAllowedCarriers(int32_t serial) {
3227 #if VDBG
3228 RLOGD("getAllowedCarriers: serial %d", serial);
3229 #endif
3230 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
3231 return Void();
3232 }
3233
sendDeviceState(int32_t serial,DeviceStateType deviceStateType,bool state)3234 Return<void> RadioImpl_1_6::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
3235 bool state) {
3236 #if VDBG
3237 RLOGD("sendDeviceState: serial %d", serial);
3238 #endif
3239 if (s_vendorFunctions->version < 15) {
3240 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
3241 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
3242 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
3243 } else {
3244 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3245 RIL_REQUEST_SEND_DEVICE_STATE);
3246 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
3247 }
3248 return Void();
3249 }
3250 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
3251 BOOL_TO_INT(state));
3252 return Void();
3253 }
3254
setIndicationFilter(int32_t serial,int32_t indicationFilter)3255 Return<void> RadioImpl_1_6::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
3256 #if VDBG
3257 RLOGD("setIndicationFilter: serial %d", serial);
3258 #endif
3259 if (s_vendorFunctions->version < 15) {
3260 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3261 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
3262 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
3263 return Void();
3264 }
3265 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
3266 return Void();
3267 }
3268
setSimCardPower(int32_t serial,bool powerUp)3269 Return<void> RadioImpl_1_6::setSimCardPower(int32_t serial, bool powerUp) {
3270 #if VDBG
3271 RLOGD("setSimCardPower: serial %d", serial);
3272 #endif
3273 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
3274 return Void();
3275 }
3276
setSimCardPower_1_1(int32_t serial,const V1_1::CardPowerState state)3277 Return<void> RadioImpl_1_6::setSimCardPower_1_1(int32_t serial, const V1_1::CardPowerState state) {
3278 #if VDBG
3279 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
3280 #endif
3281 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
3282 return Void();
3283 }
3284
setSimCardPower_1_6(int32_t serial,const V1_1::CardPowerState state)3285 Return<void> RadioImpl_1_6::setSimCardPower_1_6(int32_t serial, const V1_1::CardPowerState state) {
3286 #if VDBG
3287 RLOGD("setSimCardPower_1_6: serial %d state %d", serial, state);
3288 #endif
3289 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
3290 mSimCardPowerState = state;
3291 return Void();
3292 }
3293
setCarrierInfoForImsiEncryption(int32_t serial,const V1_1::ImsiEncryptionInfo & data)3294 Return<void> RadioImpl_1_6::setCarrierInfoForImsiEncryption(int32_t serial,
3295 const V1_1::ImsiEncryptionInfo& data) {
3296 #if VDBG
3297 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
3298 #endif
3299 RequestInfo *pRI = android::addRequestToList(
3300 serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
3301 if (pRI == NULL) {
3302 return Void();
3303 }
3304
3305 RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
3306
3307 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
3308 return Void();
3309 }
3310 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
3311 memsetAndFreeStrings(1, imsiEncryption.mnc);
3312 return Void();
3313 }
3314 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
3315 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
3316 return Void();
3317 }
3318 imsiEncryption.carrierKeyLength = data.carrierKey.size();
3319 imsiEncryption.carrierKey = new uint8_t[imsiEncryption.carrierKeyLength];
3320 memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), imsiEncryption.carrierKeyLength);
3321 imsiEncryption.expirationTime = data.expirationTime;
3322 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
3323 sizeof(RIL_CarrierInfoForImsiEncryption), pRI, mSlotId);
3324 delete(imsiEncryption.carrierKey);
3325 return Void();
3326 }
3327
startKeepalive(int32_t serial,const V1_1::KeepaliveRequest & keepalive)3328 Return<void> RadioImpl_1_6::startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive) {
3329 #if VDBG
3330 RLOGD("%s(): %d", __FUNCTION__, serial);
3331 #endif
3332 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_KEEPALIVE);
3333 if (pRI == NULL) {
3334 return Void();
3335 }
3336
3337 RIL_KeepaliveRequest kaReq = {};
3338
3339 kaReq.type = static_cast<RIL_KeepaliveType>(keepalive.type);
3340 switch(kaReq.type) {
3341 case NATT_IPV4:
3342 if (keepalive.sourceAddress.size() != 4 ||
3343 keepalive.destinationAddress.size() != 4) {
3344 RLOGE("Invalid address for keepalive!");
3345 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3346 return Void();
3347 }
3348 break;
3349 case NATT_IPV6:
3350 if (keepalive.sourceAddress.size() != 16 ||
3351 keepalive.destinationAddress.size() != 16) {
3352 RLOGE("Invalid address for keepalive!");
3353 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3354 return Void();
3355 }
3356 break;
3357 default:
3358 RLOGE("Unknown packet keepalive type!");
3359 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3360 return Void();
3361 }
3362
3363 ::memcpy(kaReq.sourceAddress, keepalive.sourceAddress.data(), keepalive.sourceAddress.size());
3364 kaReq.sourcePort = keepalive.sourcePort;
3365
3366 ::memcpy(kaReq.destinationAddress,
3367 keepalive.destinationAddress.data(), keepalive.destinationAddress.size());
3368 kaReq.destinationPort = keepalive.destinationPort;
3369
3370 kaReq.maxKeepaliveIntervalMillis = keepalive.maxKeepaliveIntervalMillis;
3371 kaReq.cid = keepalive.cid; // This is the context ID of the data call
3372
3373 CALL_ONREQUEST(pRI->pCI->requestNumber, &kaReq, sizeof(RIL_KeepaliveRequest), pRI, mSlotId);
3374 return Void();
3375 }
3376
stopKeepalive(int32_t serial,int32_t sessionHandle)3377 Return<void> RadioImpl_1_6::stopKeepalive(int32_t serial, int32_t sessionHandle) {
3378 #if VDBG
3379 RLOGD("%s(): %d", __FUNCTION__, serial);
3380 #endif
3381 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_STOP_KEEPALIVE);
3382 if (pRI == NULL) {
3383 return Void();
3384 }
3385
3386 CALL_ONREQUEST(pRI->pCI->requestNumber, &sessionHandle, sizeof(uint32_t), pRI, mSlotId);
3387 return Void();
3388 }
3389
responseAcknowledgement()3390 Return<void> RadioImpl_1_6::responseAcknowledgement() {
3391 android::releaseWakeLock();
3392 return Void();
3393 }
3394
3395 // 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)3396 int prepareNetworkScanRequest_1_2(RIL_NetworkScanRequest &scan_request,
3397 const ::android::hardware::radio::V1_2::NetworkScanRequest& request,
3398 RequestInfo *pRI) {
3399
3400 scan_request.type = (RIL_ScanType) request.type;
3401 scan_request.interval = request.interval;
3402 scan_request.specifiers_length = request.specifiers.size();
3403
3404 int intervalLow = static_cast<int>(::android::hardware::radio::V1_2::ScanIntervalRange::MIN);
3405 int intervalHigh = static_cast<int>(::android::hardware::radio::V1_2::ScanIntervalRange::MAX);
3406 int maxSearchTimeLow =
3407 static_cast<int>(::android::hardware::radio::V1_2::MaxSearchTimeRange::MIN);
3408 int maxSearchTimeHigh =
3409 static_cast<int>(::android::hardware::radio::V1_2::MaxSearchTimeRange::MAX);
3410 int incrementalResultsPeriodicityRangeLow =
3411 static_cast<int>(::android::hardware::radio::V1_2::IncrementalResultsPeriodicityRange::MIN);
3412 int incrementalResultsPeriodicityRangeHigh =
3413 static_cast<int>(::android::hardware::radio::V1_2::IncrementalResultsPeriodicityRange::MAX);
3414 uint maxSpecifierSize =
3415 static_cast<uint>(::android::hardware::radio::V1_2::RadioConst
3416 ::RADIO_ACCESS_SPECIFIER_MAX_SIZE);
3417
3418 if (request.interval < intervalLow || request.interval > intervalHigh) {
3419 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3420 return -1;
3421 }
3422 // If defined, must fall in correct range.
3423 if (request.maxSearchTime != 0
3424 && (request.maxSearchTime < maxSearchTimeLow
3425 || request.maxSearchTime > maxSearchTimeHigh)) {
3426 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3427 return -1;
3428 }
3429 if (request.maxSearchTime != 0
3430 && (request.incrementalResultsPeriodicity < incrementalResultsPeriodicityRangeLow
3431 || request.incrementalResultsPeriodicity > incrementalResultsPeriodicityRangeHigh
3432 || request.incrementalResultsPeriodicity > request.maxSearchTime)) {
3433 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3434 return -1;
3435 }
3436 if (request.specifiers.size() == 0 || request.specifiers.size() > maxSpecifierSize) {
3437 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3438 return -1;
3439 }
3440
3441 for (size_t i = 0; i < request.specifiers.size(); ++i) {
3442 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
3443 request.specifiers[i].utranBands.size() > MAX_BANDS ||
3444 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
3445 request.specifiers[i].channels.size() > MAX_CHANNELS) {
3446 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3447 return -1;
3448 }
3449 const V1_1::RadioAccessSpecifier& ras_from =
3450 request.specifiers[i];
3451 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
3452
3453 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
3454 ras_to.channels_length = ras_from.channels.size();
3455
3456 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
3457 const std::vector<uint32_t> * bands = nullptr;
3458 switch (request.specifiers[i].radioAccessNetwork) {
3459 case V1_1::RadioAccessNetworks::GERAN:
3460 ras_to.bands_length = ras_from.geranBands.size();
3461 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
3462 break;
3463 case V1_1::RadioAccessNetworks::UTRAN:
3464 ras_to.bands_length = ras_from.utranBands.size();
3465 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
3466 break;
3467 case V1_1::RadioAccessNetworks::EUTRAN:
3468 ras_to.bands_length = ras_from.eutranBands.size();
3469 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
3470 break;
3471 default:
3472 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3473 return -1;
3474 }
3475 // safe to copy to geran_bands because it's a union member
3476 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
3477 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
3478 }
3479 }
3480
3481 return 0;
3482 }
3483
startNetworkScan_1_2(int32_t serial,const::android::hardware::radio::V1_2::NetworkScanRequest & request)3484 Return<void> RadioImpl_1_6::startNetworkScan_1_2(int32_t serial,
3485 const ::android::hardware::radio::V1_2::NetworkScanRequest& request) {
3486 #if VDBG
3487 RLOGD("startNetworkScan_1_2: serial %d", serial);
3488 #endif
3489
3490 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
3491 if (pRI == NULL) {
3492 return Void();
3493 }
3494
3495 RIL_NetworkScanRequest scan_request = {};
3496
3497 if (prepareNetworkScanRequest_1_2(scan_request, request, pRI) < 0) {
3498 return Void();
3499 }
3500
3501 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
3502 mSlotId);
3503
3504 return Void();
3505 }
3506
setIndicationFilter_1_2(int32_t serial,::android::hardware::hidl_bitfield<V1_2::IndicationFilter> indicationFilter)3507 Return<void> RadioImpl_1_6::setIndicationFilter_1_2(int32_t serial,
3508 ::android::hardware::hidl_bitfield<V1_2::IndicationFilter> indicationFilter) {
3509 #if VDBG
3510 RLOGD("setIndicationFilter_1_2: serial %d", serial);
3511 #endif
3512
3513 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3514 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
3515 sendErrorResponse(pRI, RIL_E_SUCCESS); // TODO: for vts
3516 return Void();
3517 }
3518
setSignalStrengthReportingCriteria(int32_t serial,int32_t hysteresisMs,int32_t hysteresisDb,const hidl_vec<int32_t> & thresholdsDbm,::android::hardware::radio::V1_2::AccessNetwork accessNetwork)3519 Return<void> RadioImpl_1_6::setSignalStrengthReportingCriteria(int32_t serial,
3520 int32_t hysteresisMs, int32_t hysteresisDb,
3521 const hidl_vec<int32_t>& thresholdsDbm,
3522 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork) {
3523 #if VDBG
3524 RLOGD("setSignalStrengthReportingCriteria: %d", serial);
3525 #endif
3526 RIL_Errno e;
3527 if (radioService[mSlotId]->mRadioResponseV1_2 != NULL) {
3528 RadioResponseInfo responseInfo = {};
3529 if (hysteresisDb >= 10) {
3530 e = RIL_E_INVALID_ARGUMENTS;
3531 } else {
3532 e = RIL_E_SUCCESS;
3533 }
3534 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, e);
3535 Return<void> retStatus =
3536 radioService[mSlotId]
3537 ->mRadioResponseV1_2->setSignalStrengthReportingCriteriaResponse(
3538 responseInfo);
3539 radioService[mSlotId]->checkReturnStatus(retStatus);
3540 } else {
3541 RLOGE("setSignalStrengthReportingCriteria: radioService[%d]->mRadioResponse == NULL",
3542 mSlotId);
3543 }
3544 return Void();
3545 }
3546
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)3547 Return<void> RadioImpl_1_6::setLinkCapacityReportingCriteria(int32_t serial,
3548 int32_t hysteresisMs, int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
3549 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
3550 const hidl_vec<int32_t>& thresholdsUplinkKbps,
3551 V1_2::AccessNetwork accessNetwork) {
3552 #if VDBG
3553 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3554 RLOGD("setLinkCapacityReportingCriteria: %d", serial);
3555 #endif
3556
3557 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3558 RIL_REQUEST_SET_LINK_CAPACITY_REPORTING_CRITERIA);
3559 if (pRI == NULL) {
3560 return Void();
3561 }
3562 // TODO: for vts. hysteresisDlKbps and hysteresisUlKbps range not confirmed
3563 if (hysteresisDlKbps >= 5000 || hysteresisUlKbps >= 1000) {
3564 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3565 return Void();
3566 } else {
3567 sendErrorResponse(pRI, RIL_E_SUCCESS);
3568 }
3569 return Void();
3570 }
3571
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)3572 Return<void> RadioImpl_1_6::setupDataCall_1_2(int32_t serial, V1_2::AccessNetwork accessNetwork,
3573 const V1_0::DataProfileInfo& dataProfileInfo, bool modemCognitive,
3574 bool roamingAllowed, bool isRoaming, V1_2::DataRequestReason reason,
3575 const hidl_vec<hidl_string>& addresses, const hidl_vec<hidl_string>& dnses) {
3576 #if VDBG
3577 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3578 RLOGD("setupDataCall_1_2: serial %d", serial);
3579 #endif
3580
3581 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
3582 const hidl_string &protocol =
3583 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
3584 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 7,
3585 std::to_string((int)accessNetwork).c_str(),
3586 std::to_string((int)dataProfileInfo.profileId).c_str(),
3587 dataProfileInfo.apn.c_str(),
3588 dataProfileInfo.user.c_str(),
3589 dataProfileInfo.password.c_str(),
3590 std::to_string((int)dataProfileInfo.authType).c_str(),
3591 protocol.c_str());
3592 } else if (s_vendorFunctions->version >= 15) {
3593 char *mvnoTypeStr = NULL;
3594 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
3595 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3596 RIL_REQUEST_SETUP_DATA_CALL);
3597 if (pRI != NULL) {
3598 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3599 }
3600 return Void();
3601 }
3602 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
3603 std::to_string((int)accessNetwork).c_str(),
3604 std::to_string((int)dataProfileInfo.profileId).c_str(),
3605 dataProfileInfo.apn.c_str(),
3606 dataProfileInfo.user.c_str(),
3607 dataProfileInfo.password.c_str(),
3608 std::to_string((int) dataProfileInfo.authType).c_str(),
3609 dataProfileInfo.protocol.c_str(),
3610 dataProfileInfo.roamingProtocol.c_str(),
3611 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
3612 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
3613 modemCognitive ? "1" : "0",
3614 std::to_string(dataProfileInfo.mtu).c_str(),
3615 mvnoTypeStr,
3616 dataProfileInfo.mvnoMatchData.c_str(),
3617 roamingAllowed ? "1" : "0");
3618 } else {
3619 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
3620 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3621 RIL_REQUEST_SETUP_DATA_CALL);
3622 if (pRI != NULL) {
3623 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
3624 }
3625 }
3626 return Void();
3627 }
3628
deactivateDataCall_1_2(int32_t serial,int32_t cid,::android::hardware::radio::V1_2::DataRequestReason reason)3629 Return<void> RadioImpl_1_6::deactivateDataCall_1_2(int32_t serial, int32_t cid,
3630 ::android::hardware::radio::V1_2::DataRequestReason reason) {
3631 #if VDBG
3632 RLOGD("deactivateDataCall_1_2: serial %d", serial);
3633 #endif
3634
3635 RIL_DataRequestReason dataRequestReason = (RIL_DataRequestReason)reason;
3636 const char *reasonStr = NULL;
3637 switch (dataRequestReason) {
3638 case DATA_REQ_REASOPN_NORMAL:
3639 reasonStr = "normal";
3640 break;
3641 case DATA_REQ_REASOPN_SHUTDOWN:
3642 reasonStr = "shutdown";
3643 break;
3644 case DATA_REQ_REASOPN_HANDOVER:
3645 reasonStr = "handover";
3646 break;
3647 default:
3648 reasonStr = "unknown";
3649 break;
3650 }
3651
3652 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, false,
3653 2, (std::to_string(cid)).c_str(), reasonStr);
3654 return Void();
3655 }
3656
3657 // Methods from ::android::hardware::radio::V1_3::IRadio follow.
setSystemSelectionChannels(int32_t serial,bool,const hidl_vec<::android::hardware::radio::V1_1::RadioAccessSpecifier> &)3658 Return<void> RadioImpl_1_6::setSystemSelectionChannels(int32_t serial, bool /* specifyChannels */,
3659 const hidl_vec<::android::hardware::radio::V1_1::RadioAccessSpecifier>& /* specifiers */) {
3660 #if VDBG
3661 RLOGD("setSystemSelectionChannels: serial %d", serial);
3662 #endif
3663 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS);
3664 return Void();
3665 }
3666
enableModem(int32_t serial,bool)3667 Return<void> RadioImpl_1_6::enableModem(int32_t serial, bool /* on */) {
3668 #if VDBG
3669 RLOGE("enableModem: serial = %d", serial);
3670 #endif
3671 dispatchVoid(serial, mSlotId, RIL_REQUEST_ENABLE_MODEM);
3672 return Void();
3673 }
3674
getModemStackStatus(int32_t serial)3675 Return<void> RadioImpl_1_6::getModemStackStatus(int32_t serial) {
3676 #if VDBG
3677 RLOGD("getModemStackStatus: serial %d", serial);
3678 #endif
3679 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MODEM_STACK_STATUS);
3680 return Void();
3681 }
3682
getProtocolString(const::android::hardware::radio::V1_4::PdpProtocolType protocolVal)3683 const char * getProtocolString(const ::android::hardware::radio::V1_4::PdpProtocolType protocolVal) {
3684 switch(protocolVal) {
3685 case ::android::hardware::radio::V1_4::PdpProtocolType::IP:
3686 return "IP";
3687 case ::android::hardware::radio::V1_4::PdpProtocolType::IPV6:
3688 return "IPV6";
3689 case ::android::hardware::radio::V1_4::PdpProtocolType::IPV4V6:
3690 return "IPV4V6";
3691 case ::android::hardware::radio::V1_4::PdpProtocolType::PPP:
3692 return "PPP";
3693 case ::android::hardware::radio::V1_4::PdpProtocolType::NON_IP:
3694 return "NON_IP";
3695 case ::android::hardware::radio::V1_4::PdpProtocolType::UNSTRUCTURED:
3696 return "UNSTRUCTURED";
3697 default:
3698 return "UNKNOWN";
3699 }
3700 }
3701
3702 // Methods from ::android::hardware::radio::V1_4::IRadio follow.
setAllowedCarriers_1_4(int32_t serial,const V1_4::CarrierRestrictionsWithPriority & carriers,V1_4::SimLockMultiSimPolicy multiSimPolicy)3703 Return<void> RadioImpl_1_6::setAllowedCarriers_1_4(int32_t serial,
3704 const V1_4::CarrierRestrictionsWithPriority& carriers,
3705 V1_4::SimLockMultiSimPolicy multiSimPolicy) {
3706 #if VDBG
3707 RLOGD("setAllowedCarriers_1_4: serial %d", serial);
3708 #endif
3709
3710 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3711 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
3712 if (pRI == NULL) {
3713 return Void();
3714 }
3715
3716 // Prepare legacy structure (defined in IRadio 1.0) to re-use existing code.
3717 RIL_CarrierRestrictions cr = {};
3718 if (prepareCarrierRestrictions(cr, false, carriers.allowedCarriers, carriers.excludedCarriers,
3719 pRI) < 0) {
3720 return Void();
3721 }
3722 // Copy the legacy structure into the new structure (defined in IRadio 1.4)
3723 RIL_CarrierRestrictionsWithPriority crExt = {};
3724 crExt.len_allowed_carriers = cr.len_allowed_carriers;
3725 crExt.allowed_carriers = cr.allowed_carriers;
3726 crExt.len_excluded_carriers = cr.len_excluded_carriers;
3727 crExt.excluded_carriers = cr.excluded_carriers;
3728 crExt.allowedCarriersPrioritized = BOOL_TO_INT(carriers.allowedCarriersPrioritized);
3729 crExt.multiSimPolicy = (RIL_SimLockMultiSimPolicy)multiSimPolicy;
3730
3731 CALL_ONREQUEST(pRI->pCI->requestNumber, &crExt, sizeof(RIL_CarrierRestrictionsWithPriority),
3732 pRI, mSlotId);
3733
3734 freeCarrierRestrictions(cr);
3735
3736 return Void();
3737 }
3738
getAllowedCarriers_1_4(int32_t serial)3739 Return<void> RadioImpl_1_6::getAllowedCarriers_1_4(int32_t serial) {
3740 #if VDBG
3741 RLOGD("getAllowedCarriers_1_4: serial %d", serial);
3742 #endif
3743 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
3744 return Void();
3745 }
3746
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> &)3747 Return<void> RadioImpl_1_6::setupDataCall_1_4(int32_t serial ,
3748 ::android::hardware::radio::V1_4::AccessNetwork /* accessNetwork */,
3749 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo,
3750 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
3751 const hidl_vec<hidl_string>& /* addresses */, const hidl_vec<hidl_string>& /* dnses */) {
3752
3753 #if VDBG
3754 RLOGD("setupDataCall_1_4: serial %d", serial);
3755 #endif
3756
3757 char *mvnoTypeStr = NULL;
3758 if (!convertMvnoTypeToString(MvnoType::IMSI, mvnoTypeStr)) {
3759 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3760 RIL_REQUEST_SETUP_DATA_CALL);
3761 if (pRI != NULL) {
3762 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3763 }
3764 return Void();
3765 }
3766 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 16,
3767 std::to_string((int) RadioTechnology::UNKNOWN + 2).c_str(),
3768 std::to_string((int) dataProfileInfo.profileId).c_str(),
3769 dataProfileInfo.apn.c_str(),
3770 dataProfileInfo.user.c_str(),
3771 dataProfileInfo.password.c_str(),
3772 std::to_string((int) dataProfileInfo.authType).c_str(),
3773 getProtocolString(dataProfileInfo.protocol),
3774 getProtocolString(dataProfileInfo.roamingProtocol),
3775 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
3776 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
3777 dataProfileInfo.persistent ? "1" : "0",
3778 std::to_string(dataProfileInfo.mtu).c_str(),
3779 mvnoTypeStr,
3780 "302720x94",
3781 roamingAllowed ? "1" : "0",
3782 "-1");
3783 return Void();
3784 }
3785
setInitialAttachApn_1_4(int32_t serial,const::android::hardware::radio::V1_4::DataProfileInfo & dataProfileInfo)3786 Return<void> RadioImpl_1_6::setInitialAttachApn_1_4(int32_t serial ,
3787 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo) {
3788 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3789 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
3790 if (pRI == NULL) {
3791 return Void();
3792 }
3793
3794 RadioResponseInfo responseInfo = {};
3795 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
3796
3797 if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
3798 Return<void> retStatus
3799 = radioService[mSlotId]->mRadioResponseV1_4->setInitialAttachApnResponse(responseInfo);
3800 radioService[mSlotId]->checkReturnStatus(retStatus);
3801 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
3802 Return<void> retStatus
3803 = radioService[mSlotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
3804 radioService[mSlotId]->checkReturnStatus(retStatus);
3805 } else {
3806 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
3807 }
3808
3809 return Void();
3810 }
3811
setDataProfile_1_4(int32_t serial,const hidl_vec<::android::hardware::radio::V1_4::DataProfileInfo> &)3812 Return<void> RadioImpl_1_6::setDataProfile_1_4(int32_t serial ,
3813 const hidl_vec<::android::hardware::radio::V1_4::DataProfileInfo>& /* profiles */) {
3814 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3815 RIL_REQUEST_SET_DATA_PROFILE);
3816 if (pRI == NULL) {
3817 return Void();
3818 }
3819
3820 RadioResponseInfo responseInfo = {};
3821 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
3822
3823 if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
3824 Return<void> retStatus
3825 = radioService[mSlotId]->mRadioResponseV1_4->setDataProfileResponse(responseInfo);
3826 radioService[mSlotId]->checkReturnStatus(retStatus);
3827 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
3828 Return<void> retStatus
3829 = radioService[mSlotId]->mRadioResponse->setDataProfileResponse(responseInfo);
3830 radioService[mSlotId]->checkReturnStatus(retStatus);
3831 } else {
3832 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
3833 }
3834
3835 return Void();
3836 }
3837
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)3838 Return<void> RadioImpl_1_6::emergencyDial(int32_t serial,
3839 const ::android::hardware::radio::V1_0::Dial& dialInfo,
3840 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
3841 const hidl_vec<hidl_string>& urns ,
3842 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
3843 bool fromEmergencyDialer, bool /* isTesting */) {
3844 #if VDBG
3845 RLOGD("emergencyDial: serial %d", serial);
3846 #endif
3847
3848 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_EMERGENCY_DIAL);
3849 if (pRI == NULL) {
3850 return Void();
3851 }
3852
3853 RIL_EmergencyDial eccDial = {};
3854 RIL_Dial& dial = eccDial.dialInfo;
3855 RIL_UUS_Info uusInfo = {};
3856
3857 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
3858 return Void();
3859 }
3860 dial.clir = (int) dialInfo.clir;
3861
3862 if (dialInfo.uusInfo.size() != 0) {
3863 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
3864 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
3865
3866 if (dialInfo.uusInfo[0].uusData.size() == 0) {
3867 uusInfo.uusData = NULL;
3868 uusInfo.uusLength = 0;
3869 } else {
3870 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
3871 memsetAndFreeStrings(1, dial.address);
3872 return Void();
3873 }
3874 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
3875 }
3876
3877 dial.uusInfo = &uusInfo;
3878 }
3879
3880 eccDial.urnsNumber = urns.size();
3881 if (eccDial.urnsNumber != 0) {
3882 char **ppUrns = (char **)calloc(eccDial.urnsNumber, sizeof(char *));
3883 if (ppUrns == NULL) {
3884 RLOGE("Memory allocation failed for request %s",
3885 requestToString(pRI->pCI->requestNumber));
3886 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3887 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
3888 return Void();
3889 }
3890 for (uint32_t i = 0; i < eccDial.urnsNumber; i++) {
3891 if (!copyHidlStringToRil(&ppUrns[i], hidl_string(urns[i]), pRI)) {
3892 for (uint32_t j = 0; j < i; j++) {
3893 memsetAndFreeStrings(1, ppUrns[j]);
3894 }
3895 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
3896 free(ppUrns);
3897 return Void();
3898 }
3899 }
3900 eccDial.urns = ppUrns;
3901 }
3902
3903 eccDial.categories = (RIL_EmergencyServiceCategory)categories;
3904 eccDial.routing = (RIL_EmergencyCallRouting)routing;
3905 eccDial.fromEmergencyDialer = fromEmergencyDialer;
3906
3907 CALL_ONREQUEST(RIL_REQUEST_EMERGENCY_DIAL, &eccDial, sizeof(RIL_EmergencyDial), pRI, mSlotId);
3908
3909 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
3910 if (eccDial.urns != NULL) {
3911 for (size_t i = 0; i < eccDial.urnsNumber; i++) {
3912 memsetAndFreeStrings(1, eccDial.urns[i]);
3913 }
3914 free(eccDial.urns);
3915 }
3916 return Void();
3917 }
3918
startNetworkScan_1_4(int32_t serial,const::android::hardware::radio::V1_2::NetworkScanRequest & request)3919 Return<void> RadioImpl_1_6::startNetworkScan_1_4(int32_t serial,
3920 const ::android::hardware::radio::V1_2::NetworkScanRequest& request) {
3921 #if VDBG
3922 RLOGD("startNetworkScan_1_4: serial %d", serial);
3923 #endif
3924
3925 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
3926 if (pRI == NULL) {
3927 return Void();
3928 }
3929
3930 RIL_NetworkScanRequest scan_request = {};
3931
3932 if (prepareNetworkScanRequest_1_2(scan_request, request, pRI) < 0) {
3933 return Void();
3934 }
3935
3936 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
3937 mSlotId);
3938
3939 return Void();
3940 }
3941
getPreferredNetworkTypeBitmap(int32_t serial)3942 Return<void> RadioImpl_1_6::getPreferredNetworkTypeBitmap(int32_t serial ) {
3943 #if VDBG
3944 RLOGD("getPreferredNetworkTypeBitmap: serial %d", serial);
3945 #endif
3946 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE_BITMAP);
3947 return Void();
3948 }
3949
setPreferredNetworkTypeBitmap(int32_t serial,hidl_bitfield<RadioAccessFamily> networkTypeBitmap)3950 Return<void> RadioImpl_1_6::setPreferredNetworkTypeBitmap(
3951 int32_t serial, hidl_bitfield<RadioAccessFamily> networkTypeBitmap) {
3952 #if VDBG
3953 RLOGD("setPreferredNetworkTypeBitmap: serial %d", serial);
3954 #endif
3955 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE_BITMAP, 1, networkTypeBitmap);
3956 return Void();
3957 }
3958
setAllowedNetworkTypesBitmap(uint32_t serial,hidl_bitfield<RadioAccessFamily> networkTypeBitmap)3959 Return<void> RadioImpl_1_6::setAllowedNetworkTypesBitmap(
3960 uint32_t serial, hidl_bitfield<RadioAccessFamily> networkTypeBitmap) {
3961 #if VDBG
3962 RLOGD("setAllowedNetworkTypesBitmap: serial %d", serial);
3963 #endif
3964 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_ALLOWED_NETWORK_TYPES_BITMAP, 1, networkTypeBitmap);
3965 return Void();
3966 }
3967
getAllowedNetworkTypesBitmap(int32_t serial)3968 Return<void> RadioImpl_1_6::getAllowedNetworkTypesBitmap(int32_t serial) {
3969 #if VDBG
3970 RLOGD("getAllowedNetworkTypesBitmap: serial %d", serial);
3971 #endif
3972 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ALLOWED_NETWORK_TYPES_BITMAP);
3973 return Void();
3974 }
3975
getSignalStrength_1_4(int32_t serial)3976 Return<void> RadioImpl_1_6::getSignalStrength_1_4(int32_t serial) {
3977 #if VDBG
3978 RLOGD("getSignalStrength_1_4: serial %d", serial);
3979 #endif
3980 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
3981 return Void();
3982 }
3983
getSignalStrength_1_6(int32_t serial)3984 Return<void> RadioImpl_1_6::getSignalStrength_1_6(int32_t serial) {
3985 #if VDBG
3986 RLOGD("getSignalStrength_1_6: serial %d", serial);
3987 #endif
3988 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
3989 return Void();
3990 }
3991
3992 // Methods from ::android::hardware::radio::V1_5::IRadio follow.
setSignalStrengthReportingCriteria_1_5(int32_t serial,const V1_5::SignalThresholdInfo & signalThresholdInfo,V1_5::AccessNetwork accessNetwork)3993 Return<void> RadioImpl_1_6::setSignalStrengthReportingCriteria_1_5(int32_t serial,
3994 const V1_5::SignalThresholdInfo& signalThresholdInfo,
3995 V1_5::AccessNetwork accessNetwork) {
3996 #if VDBG
3997 RLOGD("setSignalStrengthReportingCriteria_1_5: %d", serial);
3998 #endif
3999
4000 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4001 RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA);
4002 if (pRI == NULL) {
4003 return Void();
4004 }
4005
4006 if (signalThresholdInfo.hysteresisDb >= 10) { // TODO: for vts. hysteresisDb range not checked
4007 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4008 return Void();
4009 }
4010
4011 RIL_SignalStrengthReportingCriteria_v1_5 *criteria = (RIL_SignalStrengthReportingCriteria_v1_5 *)
4012 calloc(1, sizeof(RIL_SignalStrengthReportingCriteria_v1_5));
4013 if (criteria == NULL) {
4014 RLOGE("Memory allocation failed for request %s",
4015 requestToString(pRI->pCI->requestNumber));
4016 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4017 return Void();
4018 }
4019
4020 criteria->signalMeasurement = (SignalMeasurementType)signalThresholdInfo.signalMeasurement;
4021 criteria->isEnabled = signalThresholdInfo.isEnabled;
4022 criteria->hysteresisMs = signalThresholdInfo.hysteresisMs;
4023 criteria->hysteresisDb = signalThresholdInfo.hysteresisDb;
4024 criteria->thresholdsDbmNumber = signalThresholdInfo.thresholds.size();
4025 criteria->thresholdsDbm = new int32_t[criteria->thresholdsDbmNumber];
4026 memcpy(criteria->thresholdsDbm, signalThresholdInfo.thresholds.data(),
4027 criteria->thresholdsDbmNumber * sizeof(int32_t));
4028 criteria->accessNetwork = (RIL_RadioAccessNetworks_v1_5)accessNetwork;
4029
4030 CALL_ONREQUEST(pRI->pCI->requestNumber, criteria,
4031 sizeof(RIL_SignalStrengthReportingCriteria_v1_5), pRI, mSlotId);
4032
4033 return Void();
4034 }
4035
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)4036 Return<void> RadioImpl_1_6::setLinkCapacityReportingCriteria_1_5(int32_t serial,
4037 int32_t hysteresisMs, int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
4038 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
4039 const hidl_vec<int32_t>& thresholdsUplinkKbps,
4040 V1_5::AccessNetwork accessNetwork) {
4041 #if VDBG
4042 RLOGD("setLinkCapacityReportingCriteria_1_5: %d", serial);
4043 #endif
4044
4045 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4046 RIL_REQUEST_SET_LINK_CAPACITY_REPORTING_CRITERIA);
4047 if (pRI == NULL) {
4048 return Void();
4049 }
4050 // TODO: for vts. hysteresisDlKbps and hysteresisUlKbps range not confirmed
4051 if (hysteresisDlKbps >= 5000 || hysteresisUlKbps >= 1000) {
4052 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4053 return Void();
4054 }
4055
4056 RIL_LinkCapacityReportingCriteria *criteria = (RIL_LinkCapacityReportingCriteria *)
4057 calloc(1, sizeof(RIL_LinkCapacityReportingCriteria));
4058 if (criteria == NULL) {
4059 RLOGE("Memory allocation failed for request %s",
4060 requestToString(pRI->pCI->requestNumber));
4061 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4062 return Void();
4063 }
4064
4065 criteria->hysteresisMs = hysteresisMs;
4066 criteria->hysteresisDlKbps = hysteresisDlKbps;
4067 criteria->hysteresisUlKbps = hysteresisUlKbps;
4068 criteria->thresholdsDownlinkKbpsLength = thresholdsDownlinkKbps.size();
4069 criteria->thresholdsUplinkKbpsLength = thresholdsUplinkKbps.size();
4070 criteria->thresholdsDownlinkKbps = new int32_t[criteria->thresholdsDownlinkKbpsLength];
4071 criteria->thresholdsUplinkKbps = new int32_t[criteria->thresholdsUplinkKbpsLength];
4072 memcpy(criteria->thresholdsDownlinkKbps, thresholdsDownlinkKbps.data(),
4073 criteria->thresholdsDownlinkKbpsLength * sizeof(int32_t));
4074 memcpy(criteria->thresholdsUplinkKbps, thresholdsUplinkKbps.data(),
4075 criteria->thresholdsUplinkKbpsLength * sizeof(int32_t));
4076 criteria->accessNetwork = (RIL_RadioAccessNetworks_v1_5)accessNetwork;
4077
4078 CALL_ONREQUEST(pRI->pCI->requestNumber, criteria,
4079 sizeof(RIL_LinkCapacityReportingCriteria), pRI, pRI->socket_id);
4080
4081 return Void();
4082 }
4083
enableUiccApplications(int32_t serial,bool enable)4084 Return<void> RadioImpl_1_6::enableUiccApplications(int32_t serial, bool enable) {
4085 #if VDBG
4086 RLOGD("enableUiccApplications: serial %d enable %d", serial, enable);
4087 #endif
4088 dispatchInts(serial, mSlotId, RIL_REQUEST_ENABLE_UICC_APPLICATIONS, 1, BOOL_TO_INT(enable));
4089 return Void();
4090 }
4091
setRadioPower_1_5(int32_t serial,bool powerOn,bool forEmergencyCall,bool preferredForEmergencyCall)4092 Return<void> RadioImpl_1_6::setRadioPower_1_5(int32_t serial, bool powerOn, bool forEmergencyCall,
4093 bool preferredForEmergencyCall) {
4094 #if VDBG
4095 RLOGD("setRadioPower_1_6: serial %d powerOn %d forEmergency %d preferredForEmergencyCall %d",
4096 serial, powerOn, forEmergencyCall, preferredForEmergencyCall);
4097 #endif
4098 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(powerOn));
4099 return Void();
4100 }
4101
setRadioPower_1_6(int32_t serial,bool powerOn,bool forEmergencyCall,bool preferredForEmergencyCall)4102 Return<void> RadioImpl_1_6::setRadioPower_1_6(int32_t serial, bool powerOn, bool forEmergencyCall,
4103 bool preferredForEmergencyCall) {
4104 #if VDBG
4105 RLOGD("setRadioPower_1_6: serial %d powerOn %d forEmergency %d preferredForEmergencyCall %d",
4106 serial, powerOn, forEmergencyCall, preferredForEmergencyCall);
4107 #endif
4108 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(powerOn));
4109 return Void();
4110 }
4111
areUiccApplicationsEnabled(int32_t serial)4112 Return<void> RadioImpl_1_6::areUiccApplicationsEnabled(int32_t serial) {
4113 #if VDBG
4114 RLOGD("areUiccApplicationsEnabled: serial %d", serial);
4115 #endif
4116 dispatchVoid(serial, mSlotId, RIL_REQUEST_ARE_UICC_APPLICATIONS_ENABLED);
4117 return Void();
4118 }
4119
getVoiceRegistrationState_1_5(int32_t serial)4120 Return<void> RadioImpl_1_6::getVoiceRegistrationState_1_5(int32_t serial) {
4121 #if VDBG
4122 RLOGD("getVoiceRegistrationState_1_5: serial %d", serial);
4123 #endif
4124 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
4125 return Void();
4126 }
4127
getDataRegistrationState_1_5(int32_t serial)4128 Return<void> RadioImpl_1_6::getDataRegistrationState_1_5(int32_t serial) {
4129 #if VDBG
4130 RLOGD("getDataRegistrationState_1_5: serial %d", serial);
4131 #endif
4132 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
4133 return Void();
4134 }
4135
getVoiceRegistrationState_1_6(int32_t serial)4136 Return<void> RadioImpl_1_6::getVoiceRegistrationState_1_6(int32_t serial) {
4137 #if VDBG
4138 RLOGD("getVoiceRegistrationState_1_6: serial %d", serial);
4139 #endif
4140 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
4141 return Void();
4142 }
4143
getDataRegistrationState_1_6(int32_t serial)4144 Return<void> RadioImpl_1_6::getDataRegistrationState_1_6(int32_t serial) {
4145 #if VDBG
4146 RLOGD("getDataRegistrationState_1_6: serial %d", serial);
4147 #endif
4148 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
4149 return Void();
4150 }
4151
setSystemSelectionChannels_1_5(int32_t serial,bool specifyChannels,const hidl_vec<V1_5::RadioAccessSpecifier> & specifiers)4152 Return<void> RadioImpl_1_6::setSystemSelectionChannels_1_5(int32_t serial,
4153 bool specifyChannels, const hidl_vec<V1_5::RadioAccessSpecifier>& specifiers) {
4154
4155 #if VDBG
4156 RLOGD("setSystemSelectionChannels_1_5: %d", serial);
4157 #endif
4158
4159 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4160 RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS);
4161 if (pRI == NULL) {
4162 return Void();
4163 }
4164
4165 if (specifiers.size() > RIL_RADIO_ACCESS_SPECIFIER_MAX_SIZE) {
4166 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4167 return Void();
4168 }
4169
4170 RIL_SystemSelectionChannels_v1_5 *sysSelectionChannels =
4171 (RIL_SystemSelectionChannels_v1_5 *)calloc(1, sizeof(RIL_SystemSelectionChannels_v1_5));
4172 if (sysSelectionChannels == NULL) {
4173 RLOGE("Memory allocation failed for request %s",
4174 requestToString(pRI->pCI->requestNumber));
4175 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4176 return Void();
4177 }
4178 sysSelectionChannels->specifyChannels = specifyChannels;
4179 sysSelectionChannels->specifiers_length = specifiers.size();
4180 for (size_t i = 0; i < specifiers.size(); ++i) {
4181 const V1_5::RadioAccessSpecifier& ras_from = specifiers[i];
4182 RIL_RadioAccessSpecifier_v1_5 &ras_to = sysSelectionChannels->specifiers[i];
4183
4184 ras_to.radio_access_network = (RIL_RadioAccessNetworks_v1_5)ras_from.radioAccessNetwork;
4185 ras_to.channels_length = ras_from.channels.size();
4186
4187 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
4188 const std::vector<uint32_t> * bands = nullptr;
4189 switch (specifiers[i].radioAccessNetwork) {
4190 case V1_5::RadioAccessNetworks::GERAN:
4191 ras_to.bands_length = ras_from.bands.geranBands().size();
4192 bands = (std::vector<uint32_t> *) &ras_from.bands.geranBands();
4193 break;
4194 case V1_5::RadioAccessNetworks::UTRAN:
4195 ras_to.bands_length = ras_from.bands.utranBands().size();
4196 bands = (std::vector<uint32_t> *) &ras_from.bands.utranBands();
4197 break;
4198 case V1_5::RadioAccessNetworks::EUTRAN:
4199 ras_to.bands_length = ras_from.bands.eutranBands().size();
4200 bands = (std::vector<uint32_t> *) &ras_from.bands.eutranBands();
4201 break;
4202 case V1_5::RadioAccessNetworks::NGRAN:
4203 ras_to.bands_length = ras_from.bands.ngranBands().size();
4204 bands = (std::vector<uint32_t> *) &ras_from.bands.ngranBands();
4205 break;
4206 default: {
4207 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4208 free(sysSelectionChannels);
4209 return Void();
4210 }
4211 }
4212 // safe to copy to geran_bands because it's a union member
4213 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4214 ras_to.bands.geran_bands[idx] = (RIL_GeranBands)(*bands)[idx];
4215 }
4216 }
4217
4218 CALL_ONREQUEST(RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS, sysSelectionChannels,
4219 sizeof(RIL_SystemSelectionChannels_v1_5), pRI, mSlotId);
4220
4221 return Void();
4222 }
4223
prepareNetworkScanRequest_1_5(RIL_NetworkScanRequest_v1_5 & scan_request,const V1_5::NetworkScanRequest & request,RequestInfo * pRI)4224 int prepareNetworkScanRequest_1_5(RIL_NetworkScanRequest_v1_5 &scan_request,
4225 const V1_5::NetworkScanRequest& request, RequestInfo *pRI) {
4226 scan_request.type = (RIL_ScanType) request.type;
4227 scan_request.interval = request.interval;
4228 scan_request.specifiers_length = request.specifiers.size();
4229 scan_request.maxSearchTime = request.maxSearchTime;
4230 scan_request.incrementalResults = request.incrementalResults;
4231 scan_request.incrementalResultsPeriodicity = request.incrementalResultsPeriodicity;
4232 scan_request.mccMncsNumbers = request.mccMncs.size();
4233
4234 int intervalLow = static_cast<int>(V1_2::ScanIntervalRange::MIN);
4235 int intervalHigh = static_cast<int>(V1_2::ScanIntervalRange::MAX);
4236 int maxSearchTimeLow = static_cast<int>(V1_2::MaxSearchTimeRange::MIN);
4237 int maxSearchTimeHigh = static_cast<int>(V1_2::MaxSearchTimeRange::MAX);
4238 int incrementalResultsPeriodicityRangeLow =
4239 static_cast<int>(V1_2::IncrementalResultsPeriodicityRange::MIN);
4240 int incrementalResultsPeriodicityRangeHigh =
4241 static_cast<int>(V1_2::IncrementalResultsPeriodicityRange::MAX);
4242 uint maxSpecifierSize = static_cast<uint>(V1_2::RadioConst::RADIO_ACCESS_SPECIFIER_MAX_SIZE);
4243
4244 if (request.interval < intervalLow || request.interval > intervalHigh) {
4245 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4246 return -1;
4247 }
4248 // If defined, must fall in correct range.
4249 if (request.maxSearchTime != 0 && (request.maxSearchTime < maxSearchTimeLow
4250 || request.maxSearchTime > maxSearchTimeHigh)) {
4251 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4252 return -1;
4253 }
4254 if (request.maxSearchTime != 0
4255 && (request.incrementalResultsPeriodicity < incrementalResultsPeriodicityRangeLow
4256 || request.incrementalResultsPeriodicity > incrementalResultsPeriodicityRangeHigh
4257 || request.incrementalResultsPeriodicity > request.maxSearchTime)) {
4258 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4259 return -1;
4260 }
4261 if (request.specifiers.size() == 0 || request.specifiers.size() > maxSpecifierSize) {
4262 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4263 return -1;
4264 }
4265
4266 for (size_t i = 0; i < request.specifiers.size(); ++i) {
4267 if (request.specifiers[i].channels.size() > MAX_CHANNELS) {
4268 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4269 return -1;
4270 }
4271 switch (request.specifiers[i].bands.getDiscriminator()) {
4272 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::geranBands:
4273 if (request.specifiers[i].bands.geranBands().size() > MAX_BANDS) {
4274 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4275 return -1;
4276 }
4277 break;
4278 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::utranBands:
4279 if (request.specifiers[i].bands.utranBands().size() > MAX_BANDS) {
4280 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4281 return -1;
4282 }
4283 break;
4284 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::eutranBands:
4285 if (request.specifiers[i].bands.eutranBands().size() > MAX_BANDS) {
4286 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4287 return -1;
4288 }
4289 break;
4290 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::ngranBands:
4291 if (request.specifiers[i].bands.ngranBands().size() > MAX_BANDS) {
4292 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4293 return -1;
4294 }
4295 break;
4296 default:
4297 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4298 return -1;
4299 }
4300
4301 if (request.specifiers[i].channels.size() > MAX_CHANNELS) {
4302 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4303 return -1;
4304 }
4305
4306 const V1_5::RadioAccessSpecifier& ras_from = request.specifiers[i];
4307 RIL_RadioAccessSpecifier_v1_5& ras_to = scan_request.specifiers[i];
4308
4309 ras_to.radio_access_network = (RIL_RadioAccessNetworks_v1_5) ras_from.radioAccessNetwork;
4310 ras_to.channels_length = ras_from.channels.size();
4311
4312 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
4313 const std::vector<uint32_t> * bands = nullptr;
4314 switch (request.specifiers[i].radioAccessNetwork) {
4315 case V1_5::RadioAccessNetworks::GERAN:
4316 ras_to.bands_length = ras_from.bands.geranBands().size();
4317
4318 bands = (std::vector<uint32_t> *) &ras_from.bands.geranBands();
4319 // safe to copy to geran_bands because it's a union member
4320 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4321 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
4322 }
4323 break;
4324 case V1_5::RadioAccessNetworks::UTRAN:
4325 ras_to.bands_length = ras_from.bands.utranBands().size();
4326 bands = (std::vector<uint32_t> *) &ras_from.bands;
4327 // safe to copy to geran_bands because it's a union member
4328 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4329 ras_to.bands.utran_bands[idx] = (RIL_UtranBands) (*bands)[idx];
4330 }
4331 break;
4332 case V1_5::RadioAccessNetworks::EUTRAN:
4333 ras_to.bands_length = ras_from.bands.eutranBands().size();
4334 bands = (std::vector<uint32_t> *) &ras_from.bands;
4335 // safe to copy to geran_bands because it's a union member
4336 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4337 ras_to.bands.eutran_bands[idx] = (RIL_EutranBands) (*bands)[idx];
4338 }
4339 break;
4340 case V1_5::RadioAccessNetworks::NGRAN:
4341 ras_to.bands_length = ras_from.bands.ngranBands().size();
4342 bands = (std::vector<uint32_t> *) &ras_from.bands;
4343 // safe to copy to geran_bands because it's a union member
4344 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4345 ras_to.bands.ngran_bands[idx] = (RIL_NgranBands) (*bands)[idx];
4346 }
4347 break;
4348 default:
4349 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4350 return -1;
4351 }
4352 }
4353 if (scan_request.mccMncsNumbers != 0) {
4354 char **pStrings = (char **)calloc(scan_request.mccMncsNumbers, sizeof(char *));
4355 if (pStrings == NULL) {
4356 RLOGE("Memory allocation failed for request %s",
4357 requestToString(pRI->pCI->requestNumber));
4358 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4359 return -1;
4360 }
4361 for (size_t i = 0; i < request.mccMncs.size(); ++i) {
4362 if (!copyHidlStringToRil(&pStrings[i], hidl_string(request.mccMncs[i]), pRI)) {
4363 for (size_t j = 0; j < i; j++) {
4364 memsetAndFreeStrings(1, pStrings[j]);
4365 }
4366 free(pStrings);
4367 return -1;
4368 }
4369 }
4370 scan_request.mccMncs = pStrings;
4371 }
4372 return 0;
4373 }
4374
startNetworkScan_1_5(int32_t serial,const::android::hardware::radio::V1_5::NetworkScanRequest & request)4375 Return<void> RadioImpl_1_6::startNetworkScan_1_5(int32_t serial,
4376 const ::android::hardware::radio::V1_5::NetworkScanRequest& request) {
4377 #if VDBG
4378 RLOGD("startNetworkScan_1_6: serial %d", serial);
4379 #endif
4380
4381 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
4382 if (pRI == NULL) {
4383 return Void();
4384 }
4385
4386 RIL_NetworkScanRequest_v1_5 scan_request = {};
4387
4388 if (prepareNetworkScanRequest_1_5(scan_request, request, pRI) < 0) {
4389 return Void();
4390 }
4391
4392 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
4393 mSlotId);
4394
4395 return Void();
4396 }
4397
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> &)4398 Return<void> RadioImpl_1_6::setupDataCall_1_5(int32_t serial ,
4399 ::android::hardware::radio::V1_5::AccessNetwork /* accessNetwork */,
4400 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
4401 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
4402 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& /* addresses */,
4403 const hidl_vec<hidl_string>& /* dnses */) {
4404
4405 #if VDBG
4406 RLOGD("setupDataCall_1_5: serial %d", serial);
4407 #endif
4408
4409 char *mvnoTypeStr = NULL;
4410 if (!convertMvnoTypeToString(MvnoType::IMSI, mvnoTypeStr)) {
4411 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4412 RIL_REQUEST_SETUP_DATA_CALL);
4413 if (pRI != NULL) {
4414 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4415 }
4416 return Void();
4417 }
4418 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
4419 std::to_string((int) RadioTechnology::UNKNOWN + 2).c_str(),
4420 std::to_string((int) dataProfileInfo.profileId).c_str(),
4421 dataProfileInfo.apn.c_str(),
4422 dataProfileInfo.user.c_str(),
4423 dataProfileInfo.password.c_str(),
4424 std::to_string((int) dataProfileInfo.authType).c_str(),
4425 getProtocolString(dataProfileInfo.protocol),
4426 getProtocolString(dataProfileInfo.roamingProtocol),
4427 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
4428 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
4429 dataProfileInfo.persistent ? "1" : "0",
4430 std::to_string(dataProfileInfo.mtuV4).c_str(),
4431 std::to_string(dataProfileInfo.mtuV6).c_str(),
4432 mvnoTypeStr,
4433 "302720x94",
4434 roamingAllowed ? "1" : "0");
4435 return Void();
4436 }
4437
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 &,bool matchAllRuleAllowed)4438 Return<void> RadioImpl_1_6::setupDataCall_1_6(int32_t serial ,
4439 ::android::hardware::radio::V1_5::AccessNetwork /* accessNetwork */,
4440 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
4441 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
4442 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& /* addresses */,
4443 const hidl_vec<hidl_string>& /* dnses */,
4444 int32_t /* pduSessionId */,
4445 const ::android::hardware::radio::V1_6::OptionalSliceInfo& /* sliceInfo */,
4446 const ::android::hardware::radio::V1_6::OptionalTrafficDescriptor& /*trafficDescriptor*/,
4447 bool matchAllRuleAllowed) {
4448
4449 #if VDBG
4450 RLOGD("setupDataCall_1_6: serial %d", serial);
4451 #endif
4452
4453 char *mvnoTypeStr = NULL;
4454 if (!convertMvnoTypeToString(MvnoType::IMSI, mvnoTypeStr)) {
4455 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4456 RIL_REQUEST_SETUP_DATA_CALL);
4457 if (pRI != NULL) {
4458 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4459 }
4460 return Void();
4461 }
4462 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 16,
4463 std::to_string((int) RadioTechnology::UNKNOWN + 2).c_str(),
4464 std::to_string((int) dataProfileInfo.profileId).c_str(),
4465 dataProfileInfo.apn.c_str(),
4466 dataProfileInfo.user.c_str(),
4467 dataProfileInfo.password.c_str(),
4468 std::to_string((int) dataProfileInfo.authType).c_str(),
4469 getProtocolString(dataProfileInfo.protocol),
4470 getProtocolString(dataProfileInfo.roamingProtocol),
4471 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
4472 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
4473 dataProfileInfo.persistent ? "1" : "0",
4474 std::to_string(dataProfileInfo.mtuV4).c_str(),
4475 std::to_string(dataProfileInfo.mtuV6).c_str(),
4476 mvnoTypeStr,
4477 "302720x94",
4478 roamingAllowed ? "1" : "0");
4479 return Void();
4480 }
4481
setInitialAttachApn_1_5(int32_t serial,const::android::hardware::radio::V1_5::DataProfileInfo & dataProfileInfo)4482 Return<void> RadioImpl_1_6::setInitialAttachApn_1_5(int32_t serial ,
4483 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo) {
4484 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4485 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
4486 if (pRI == NULL) {
4487 return Void();
4488 }
4489
4490 RadioResponseInfo responseInfo = {};
4491 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
4492
4493 if (radioService[mSlotId]->mRadioResponseV1_5 != NULL) {
4494 Return<void> retStatus =
4495 radioService[mSlotId]->mRadioResponseV1_5->setInitialAttachApnResponse_1_5(
4496 responseInfo);
4497 } else if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
4498 Return<void> retStatus
4499 = radioService[mSlotId]->mRadioResponseV1_4->setInitialAttachApnResponse(responseInfo);
4500 radioService[mSlotId]->checkReturnStatus(retStatus);
4501 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
4502 Return<void> retStatus
4503 = radioService[mSlotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
4504 radioService[mSlotId]->checkReturnStatus(retStatus);
4505 } else {
4506 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
4507 }
4508
4509 return Void();
4510 }
4511
setDataProfile_1_5(int32_t serial,const hidl_vec<::android::hardware::radio::V1_5::DataProfileInfo> &)4512 Return<void> RadioImpl_1_6::setDataProfile_1_5(int32_t serial ,
4513 const hidl_vec<::android::hardware::radio::V1_5::DataProfileInfo>& /* profiles */) {
4514 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4515 RIL_REQUEST_SET_DATA_PROFILE);
4516 if (pRI == NULL) {
4517 return Void();
4518 }
4519
4520 RadioResponseInfo responseInfo = {};
4521 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
4522
4523 if (radioService[mSlotId]->mRadioResponseV1_5 != NULL) {
4524 Return<void> retStatus =
4525 radioService[mSlotId]->mRadioResponseV1_5->setDataProfileResponse_1_5(responseInfo);
4526 } else if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
4527 Return<void> retStatus
4528 = radioService[mSlotId]->mRadioResponseV1_4->setDataProfileResponse(responseInfo);
4529 radioService[mSlotId]->checkReturnStatus(retStatus);
4530 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
4531 Return<void> retStatus
4532 = radioService[mSlotId]->mRadioResponse->setDataProfileResponse(responseInfo);
4533 radioService[mSlotId]->checkReturnStatus(retStatus);
4534 } else {
4535 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
4536 }
4537
4538 return Void();
4539 }
4540
setIndicationFilter_1_5(int32_t serial,hidl_bitfield<::android::hardware::radio::V1_5::IndicationFilter> indicationFilter)4541 Return<void> RadioImpl_1_6::setIndicationFilter_1_5(
4542 int32_t serial,
4543 hidl_bitfield<::android::hardware::radio::V1_5::IndicationFilter> indicationFilter) {
4544 #if VDBG
4545 RLOGE("setIndicationFilter_1_5: serial %d");
4546 #endif
4547 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
4548 return Void();
4549 }
4550
getBarringInfo(int32_t serial)4551 Return<void> RadioImpl_1_6::getBarringInfo(int32_t serial) {
4552 #if VDBG
4553 RLOGD("getBarringInfo: serial %d", serial);
4554 #endif
4555 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_BARRING_INFO);
4556 return Void();
4557 }
4558
setNetworkSelectionModeManual_1_5(int32_t serial,const hidl_string & operatorNumeric,V1_5::RadioAccessNetworks ran)4559 Return<void> RadioImpl_1_6::setNetworkSelectionModeManual_1_5(int32_t serial,
4560 const hidl_string& operatorNumeric, V1_5::RadioAccessNetworks ran) {
4561 #if VDBG
4562 RLOGD("setNetworkSelectionModeManual_1_6: serial %d", serial);
4563 #endif
4564 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4565 RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL);
4566 if (pRI == NULL) {
4567 return Void();
4568 }
4569
4570 RIL_NetworkOperator networkOperator = {};
4571
4572 networkOperator.act = (RIL_RadioAccessNetworks)ran;
4573 if (!copyHidlStringToRil(&networkOperator.operatorNumeric, operatorNumeric, pRI)) {
4574 return Void();
4575 }
4576 CALL_ONREQUEST(pRI->pCI->requestNumber, &networkOperator,
4577 sizeof(networkOperator), pRI, mSlotId);
4578
4579 return Void();
4580 }
4581
sendCdmaSmsExpectMore(int32_t serial,const CdmaSmsMessage & sms)4582 Return<void> RadioImpl_1_6::sendCdmaSmsExpectMore(int32_t serial, const CdmaSmsMessage& sms) {
4583 #if VDBG
4584 RLOGD("sendCdmaSmsExpectMore: serial %d", serial);
4585 #endif
4586 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4587 RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE);
4588 if (pRI == NULL) {
4589 return Void();
4590 }
4591
4592 RIL_CDMA_SMS_Message rcsm = {};
4593 constructCdmaSms(rcsm, sms);
4594
4595 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
4596 return Void();
4597 }
4598
4599 // Methods from ::android::hardware::radio::V1_6::IRadio follow.
sendCdmaSmsExpectMore_1_6(int32_t serial,const CdmaSmsMessage & sms)4600 Return<void> RadioImpl_1_6::sendCdmaSmsExpectMore_1_6(int32_t serial, const CdmaSmsMessage& sms) {
4601 #if VDBG
4602 RLOGD("sendCdmaSmsExpectMore: serial %d", serial);
4603 #endif
4604 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4605 RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE);
4606 if (pRI == NULL) {
4607 return Void();
4608 }
4609
4610 RIL_CDMA_SMS_Message rcsm = {};
4611 constructCdmaSms(rcsm, sms);
4612
4613 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
4614 return Void();
4615 }
4616
supplySimDepersonalization(int32_t serial,V1_5::PersoSubstate persoType,const hidl_string & controlKey)4617 Return<void> RadioImpl_1_6::supplySimDepersonalization(int32_t serial,
4618 V1_5::PersoSubstate persoType, const hidl_string& controlKey) {
4619 #if VDBG
4620 RLOGD("supplySimDepersonalization: serial %d", serial);
4621 #endif
4622 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_DEPERSONALIZATION, true, 1,
4623 controlKey.c_str());
4624 return Void();
4625 }
4626
setNrDualConnectivityState(int32_t serial,V1_6::NrDualConnectivityState nrDualConnectivityState)4627 Return<void> RadioImpl_1_6::setNrDualConnectivityState(int32_t serial,
4628 V1_6::NrDualConnectivityState nrDualConnectivityState) {
4629 #if VDBG
4630 RLOGD("setNrDualConnectivityState: serial %d", serial);
4631 #endif
4632 dispatchInts(serial, mSlotId, RIL_REQUEST_ENABLE_NR_DUAL_CONNECTIVITY, 1,
4633 nrDualConnectivityState);
4634 return Void();
4635 }
4636
isNrDualConnectivityEnabled(int32_t serial)4637 Return<void> RadioImpl_1_6::isNrDualConnectivityEnabled(int32_t serial) {
4638 #if VDBG
4639 RLOGD("isNrDualConnectivityEnabled: serial %d", serial);
4640 #endif
4641 dispatchVoid(serial, mSlotId, RIL_REQUEST_IS_NR_DUAL_CONNECTIVITY_ENABLED);
4642 return Void();
4643 }
4644
allocatePduSessionId(int32_t serial)4645 Return<void> RadioImpl_1_6::allocatePduSessionId(int32_t serial) {
4646 #if VDBG
4647 RLOGD("allocatePduSessionId: serial %d", serial);
4648 #endif
4649 dispatchVoid(serial, mSlotId, RIL_REQUEST_ALLOCATE_PDU_SESSION_ID);
4650 return Void();
4651 }
4652
releasePduSessionId(int32_t serial,int32_t id)4653 Return<void> RadioImpl_1_6::releasePduSessionId(int32_t serial, int32_t id) {
4654 #if VDBG
4655 RLOGD("releasePduSessionId: serial %d, pduSessionId: %d", serial, id);
4656 #endif
4657 dispatchVoid(serial, mSlotId, RIL_REQUEST_RELEASE_PDU_SESSION_ID);
4658 return Void();
4659 }
4660
startHandover(int32_t serial,int32_t callId)4661 Return<void> RadioImpl_1_6::startHandover(int32_t serial, int32_t callId) {
4662 #if VDBG
4663 RLOGD("startHandover: serial %d, callId: %d", serial, callId);
4664 #endif
4665 dispatchVoid(serial, mSlotId, RIL_REQUEST_START_HANDOVER);
4666 return Void();
4667 }
4668
cancelHandover(int32_t serial,int32_t callId)4669 Return<void> RadioImpl_1_6::cancelHandover(int32_t serial, int32_t callId) {
4670 #if VDBG
4671 RLOGD("cancelHandover: serial %d, callId: %d", serial, callId);
4672 #endif
4673 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_HANDOVER);
4674 return Void();
4675 }
4676
4677
setDataThrottling(int32_t serial,V1_6::DataThrottlingAction dataThrottlingAction,int64_t completionDurationMillis)4678 Return<void> RadioImpl_1_6::setDataThrottling(int32_t serial, V1_6::DataThrottlingAction dataThrottlingAction, int64_t completionDurationMillis) {
4679 #if VDBG
4680 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
4681 #endif
4682 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_DATA_THROTTLING, 2,
4683 dataThrottlingAction, completionDurationMillis);
4684 return Void();
4685 }
4686
getSystemSelectionChannels(int32_t serial)4687 Return<void> RadioImpl_1_6::getSystemSelectionChannels(int32_t serial) {
4688 #if VDBG
4689 RLOGD("getSystemSelectionChannels: serial %d", serial);
4690 #endif
4691 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SYSTEM_SELECTION_CHANNELS);
4692 return Void();
4693 }
4694
getSlicingConfig(int32_t serial)4695 Return<void> RadioImpl_1_6::getSlicingConfig(int32_t serial) {
4696 #if VDBG
4697 RLOGD("getSlicingConfig: serial %d", serial);
4698 #endif
4699 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SLICING_CONFIG);
4700 return Void();
4701 }
4702
setCarrierInfoForImsiEncryption_1_6(int32_t serial,const V1_6::ImsiEncryptionInfo & data)4703 Return<void> RadioImpl_1_6::setCarrierInfoForImsiEncryption_1_6(
4704 int32_t serial, const V1_6::ImsiEncryptionInfo& data) {
4705 #if VDBG
4706 RLOGD("setCarrierInfoForImsiEncryption_1_6: serial %d", serial);
4707 #endif
4708 RequestInfo* pRI = android::addRequestToList(serial, mSlotId,
4709 RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
4710 if (pRI == NULL) {
4711 return Void();
4712 }
4713
4714 RIL_CarrierInfoForImsiEncryption_v16 imsiEncryption = {};
4715
4716 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.base.mnc, pRI)) {
4717 return Void();
4718 }
4719 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.base.mcc, pRI)) {
4720 memsetAndFreeStrings(1, imsiEncryption.mnc);
4721 return Void();
4722 }
4723 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.base.keyIdentifier, pRI)) {
4724 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
4725 return Void();
4726 }
4727 imsiEncryption.carrierKeyLength = data.base.carrierKey.size();
4728 imsiEncryption.carrierKey = new uint8_t[imsiEncryption.carrierKeyLength];
4729 memcpy(imsiEncryption.carrierKey, data.base.carrierKey.data(), imsiEncryption.carrierKeyLength);
4730 imsiEncryption.expirationTime = data.base.expirationTime;
4731 imsiEncryption.keyType = (RIL_PublicKeyType)data.keyType;
4732
4733 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
4734 sizeof(RIL_CarrierInfoForImsiEncryption_v16), pRI, mSlotId);
4735 delete (imsiEncryption.carrierKey);
4736 return Void();
4737 }
4738
4739
getSimPhonebookRecords(int32_t serial)4740 Return<void> RadioImpl_1_6::getSimPhonebookRecords(int32_t serial) {
4741 #if VDBG
4742 RLOGD("getSimPhonebookRecords: serial %d", serial);
4743 #endif
4744 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_PHONEBOOK_RECORDS);
4745 return Void();
4746 }
4747
getSimPhonebookCapacity(int32_t serial)4748 Return<void> RadioImpl_1_6::getSimPhonebookCapacity(int32_t serial) {
4749 #if VDBG
4750 RLOGD("getSimPhonebookCapacity: serial %d", serial);
4751 #endif
4752 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_PHONEBOOK_CAPACITY);
4753 return Void();
4754 }
4755
updateSimPhonebookRecords(int32_t serial,const::android::hardware::radio::V1_6::PhonebookRecordInfo & recordInfo)4756 Return<void> RadioImpl_1_6::updateSimPhonebookRecords(
4757 int32_t serial,
4758 const ::android::hardware::radio::V1_6::PhonebookRecordInfo& recordInfo) {
4759 #if VDBG
4760 RLOGD("updateSimPhonebookRecords: serial %d", serial);
4761 #endif
4762 dispatchVoid(serial, mSlotId, RIL_REQUEST_UPDATE_SIM_PHONEBOOK_RECORDS);
4763 return Void();
4764 }
4765
4766
4767 // OEM hook methods:
setResponseFunctions(const::android::sp<IOemHookResponse> & oemHookResponseParam,const::android::sp<IOemHookIndication> & oemHookIndicationParam)4768 Return<void> OemHookImpl::setResponseFunctions(
4769 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
4770 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
4771 #if VDBG
4772 RLOGD("OemHookImpl::setResponseFunctions");
4773 #endif
4774
4775 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_6::getRadioServiceRwlock(mSlotId);
4776 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
4777 CHECK_EQ(ret, 0);
4778
4779 mOemHookResponse = oemHookResponseParam;
4780 mOemHookIndication = oemHookIndicationParam;
4781 mCounterOemHook[mSlotId]++;
4782
4783 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
4784 CHECK_EQ(ret, 0);
4785
4786 return Void();
4787 }
4788
sendRequestRaw(int32_t serial,const hidl_vec<uint8_t> & data)4789 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
4790 #if VDBG
4791 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
4792 #endif
4793 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
4794 return Void();
4795 }
4796
sendRequestStrings(int32_t serial,const hidl_vec<hidl_string> & data)4797 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
4798 const hidl_vec<hidl_string>& data) {
4799 #if VDBG
4800 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
4801 #endif
4802 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
4803 return Void();
4804 }
4805
4806 /***************************************************************************************************
4807 * RESPONSE FUNCTIONS
4808 * Functions above are used for requests going from framework to vendor code. The ones below are
4809 * responses for those requests coming back from the vendor code.
4810 **************************************************************************************************/
4811
acknowledgeRequest(int slotId,int serial)4812 void radio_1_6::acknowledgeRequest(int slotId, int serial) {
4813 if (radioService[slotId]->mRadioResponse != NULL) {
4814 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
4815 radioService[slotId]->checkReturnStatus(retStatus);
4816 } else {
4817 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
4818 }
4819 }
4820
populateResponseInfo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e)4821 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
4822 RIL_Errno e) {
4823 responseInfo.serial = serial;
4824 switch (responseType) {
4825 case RESPONSE_SOLICITED:
4826 responseInfo.type = RadioResponseType::SOLICITED;
4827 break;
4828 case RESPONSE_SOLICITED_ACK_EXP:
4829 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
4830 break;
4831 }
4832 responseInfo.error = (RadioError) e;
4833 }
4834
populateResponseInfo_1_6(::android::hardware::radio::V1_6::RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e)4835 void populateResponseInfo_1_6(
4836 ::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo,
4837 int serial, int responseType, RIL_Errno e) {
4838 responseInfo.serial = serial;
4839 switch (responseType) {
4840 case RESPONSE_SOLICITED:
4841 responseInfo.type = RadioResponseType::SOLICITED;
4842 break;
4843 case RESPONSE_SOLICITED_ACK_EXP:
4844 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
4845 break;
4846 }
4847 responseInfo.error = (::android::hardware::radio::V1_6::RadioError)e;
4848 }
4849
responseIntOrEmpty(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)4850 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
4851 void *response, size_t responseLen) {
4852 populateResponseInfo(responseInfo, serial, responseType, e);
4853 int ret = -1;
4854
4855 if (response == NULL && responseLen == 0) {
4856 // Earlier RILs did not send a response for some cases although the interface
4857 // expected an integer as response. Do not return error if response is empty. Instead
4858 // Return -1 in those cases to maintain backward compatibility.
4859 } else if (response == NULL || responseLen != sizeof(int)) {
4860 RLOGE("responseIntOrEmpty: Invalid response");
4861 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4862 } else {
4863 int *p_int = (int *) response;
4864 ret = p_int[0];
4865 }
4866 return ret;
4867 }
4868
responseInt(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)4869 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
4870 void *response, size_t responseLen) {
4871 populateResponseInfo(responseInfo, serial, responseType, e);
4872 int ret = -1;
4873
4874 if (response == NULL || responseLen != sizeof(int)) {
4875 RLOGE("responseInt: Invalid response");
4876 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4877 } else {
4878 int *p_int = (int *) response;
4879 ret = p_int[0];
4880 }
4881 return ret;
4882 }
4883
responseInt_1_6(::android::hardware::radio::V1_6::RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)4884 int responseInt_1_6(::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo, int serial, int responseType, RIL_Errno e,
4885 void *response, size_t responseLen) {
4886 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
4887 int ret = -1;
4888
4889 if (response == NULL || responseLen != sizeof(int)) {
4890 RLOGE("responseInt_1_6: Invalid response");
4891 if (e == RIL_E_SUCCESS) responseInfo.error = ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
4892 } else {
4893 int *p_int = (int *) response;
4894 ret = p_int[0];
4895 }
4896 return ret;
4897 }
4898
getIccCardStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4899 int radio_1_6::getIccCardStatusResponse(int slotId,
4900 int responseType, int serial, RIL_Errno e,
4901 void *response, size_t responseLen) {
4902 #if VDBG
4903 RLOGD("getIccCardStatusResponse: serial %d", serial);
4904 #endif
4905 if (radioService[slotId]->mRadioResponseV1_5 != NULL
4906 || radioService[slotId]->mRadioResponseV1_4 != NULL
4907 || radioService[slotId]->mRadioResponseV1_2 != NULL
4908 || radioService[slotId]->mRadioResponse != NULL) {
4909 RadioResponseInfo responseInfo = {};
4910 populateResponseInfo(responseInfo, serial, responseType, e);
4911 CardStatus cardStatus = {CardState::ABSENT, PinState::UNKNOWN, -1, -1, -1, {}};
4912 RIL_AppStatus *rilAppStatus = NULL;
4913 RIL_CardStatus_v1_5 *p_cur = ((RIL_CardStatus_v1_5 *) response);
4914 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v1_5)
4915 || p_cur->base.base.base.gsm_umts_subscription_app_index >= p_cur->base.base.base.num_applications
4916 || p_cur->base.base.base.cdma_subscription_app_index >= p_cur->base.base.base.num_applications
4917 || p_cur->base.base.base.ims_subscription_app_index >= p_cur->base.base.base.num_applications) {
4918 RLOGE("getIccCardStatusResponse: Invalid response");
4919 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4920 } else {
4921 cardStatus.cardState = (CardState) p_cur->base.base.base.card_state;
4922 cardStatus.universalPinState = (PinState) p_cur->base.base.base.universal_pin_state;
4923 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->base.base.base.gsm_umts_subscription_app_index;
4924 cardStatus.cdmaSubscriptionAppIndex = p_cur->base.base.base.cdma_subscription_app_index;
4925 cardStatus.imsSubscriptionAppIndex = p_cur->base.base.base.ims_subscription_app_index;
4926 rilAppStatus = p_cur->base.base.base.applications;
4927 cardStatus.applications.resize(p_cur->base.base.base.num_applications);
4928 AppStatus *appStatus = cardStatus.applications.data();
4929 #if VDBG
4930 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->base.base.base.num_applications);
4931 #endif
4932 for (int i = 0; i < p_cur->base.base.base.num_applications; i++) {
4933 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
4934 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
4935 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
4936 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
4937 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
4938 rilAppStatus[i].app_label_ptr);
4939 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
4940 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
4941 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
4942 }
4943 }
4944 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
4945 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
4946 ::android::hardware::radio::V1_4::CardStatus cardStatusV1_4;
4947 ::android::hardware::radio::V1_5::CardStatus cardStatusV1_5;
4948 cardStatusV1_2.base = cardStatus;
4949 cardStatusV1_2.physicalSlotId = -1;
4950 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
4951 cardStatusV1_4.base = cardStatusV1_2;
4952 cardStatusV1_5.base = cardStatusV1_4;
4953 cardStatusV1_5.applications.resize(p_cur->base.base.base.num_applications);
4954 for (int i = 0; i < p_cur->base.base.base.num_applications; i++) {
4955 cardStatusV1_5.applications[i].base.appType = (AppType) rilAppStatus[i].app_type;
4956 cardStatusV1_5.applications[i].base.appState = (AppState) rilAppStatus[i].app_state;
4957 cardStatusV1_5.applications[i].base.persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
4958 cardStatusV1_5.applications[i].base.aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
4959 cardStatusV1_5.applications[i].base.appLabelPtr = convertCharPtrToHidlString(
4960 rilAppStatus[i].app_label_ptr);
4961 cardStatusV1_5.applications[i].base.pin1Replaced = rilAppStatus[i].pin1_replaced;
4962 cardStatusV1_5.applications[i].base.pin1 = (PinState) rilAppStatus[i].pin1;
4963 cardStatusV1_5.applications[i].base.pin2 = (PinState) rilAppStatus[i].pin2;
4964 cardStatusV1_5.applications[i].persoSubstate = (V1_5::PersoSubstate)rilAppStatus[i].perso_substate;
4965 }
4966
4967 // If POWER_DOWN then set applications to empty
4968 if (radioService[slotId]->mSimCardPowerState == V1_1::CardPowerState::POWER_DOWN) {
4969 RLOGD("getIccCardStatusResponse: state is POWER_DOWN so clearing apps");
4970 cardStatusV1_5.applications = {};
4971 }
4972 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5->
4973 getIccCardStatusResponse_1_5(responseInfo, cardStatusV1_5);
4974 radioService[slotId]->checkReturnStatus(retStatus);
4975 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
4976 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
4977 ::android::hardware::radio::V1_4::CardStatus cardStatusV1_4;
4978 cardStatusV1_2.base = cardStatus;
4979 cardStatusV1_2.physicalSlotId = -1;
4980 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
4981 cardStatusV1_4.base = cardStatusV1_2;
4982 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4->
4983 getIccCardStatusResponse_1_4(responseInfo, cardStatusV1_4);
4984 radioService[slotId]->checkReturnStatus(retStatus);
4985 } else if (radioService[slotId]->mRadioResponseV1_3 != NULL) {
4986 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
4987 cardStatusV1_2.base = cardStatus;
4988 cardStatusV1_2.physicalSlotId = -1;
4989 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
4990 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_3->
4991 getIccCardStatusResponse_1_2(responseInfo, cardStatusV1_2);
4992 radioService[slotId]->checkReturnStatus(retStatus);
4993 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
4994 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
4995 cardStatusV1_2.base = cardStatus;
4996 cardStatusV1_2.physicalSlotId = -1;
4997 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
4998 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2->
4999 getIccCardStatusResponse_1_2(responseInfo, cardStatusV1_2);
5000 radioService[slotId]->checkReturnStatus(retStatus);
5001 // TODO: add 1.1 if needed.
5002 } else {
5003 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5004 getIccCardStatusResponse(responseInfo, cardStatus);
5005 radioService[slotId]->checkReturnStatus(retStatus);
5006 }
5007 } else {
5008 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5009 }
5010 return 0;
5011 }
5012
supplyIccPinForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5013 int radio_1_6::supplyIccPinForAppResponse(int slotId,
5014 int responseType, int serial, RIL_Errno e,
5015 void *response, size_t responseLen) {
5016 #if VDBG
5017 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
5018 #endif
5019
5020 if (radioService[slotId]->mRadioResponse != NULL) {
5021 RadioResponseInfo responseInfo = {};
5022 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5023 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5024 supplyIccPinForAppResponse(responseInfo, ret);
5025 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
5026 radioService[slotId]->checkReturnStatus(retStatus);
5027 } else {
5028 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
5029 slotId);
5030 }
5031
5032 return 0;
5033 }
5034
supplyIccPukForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5035 int radio_1_6::supplyIccPukForAppResponse(int slotId,
5036 int responseType, int serial, RIL_Errno e,
5037 void *response, size_t responseLen) {
5038 #if VDBG
5039 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
5040 #endif
5041
5042 if (radioService[slotId]->mRadioResponse != NULL) {
5043 RadioResponseInfo responseInfo = {};
5044 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5045 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
5046 responseInfo, ret);
5047 radioService[slotId]->checkReturnStatus(retStatus);
5048 } else {
5049 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
5050 slotId);
5051 }
5052
5053 return 0;
5054 }
5055
supplyIccPin2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5056 int radio_1_6::supplyIccPin2ForAppResponse(int slotId,
5057 int responseType, int serial, RIL_Errno e,
5058 void *response, size_t responseLen) {
5059 #if VDBG
5060 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
5061 #endif
5062
5063 if (radioService[slotId]->mRadioResponse != NULL) {
5064 RadioResponseInfo responseInfo = {};
5065 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5066 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5067 supplyIccPin2ForAppResponse(responseInfo, ret);
5068 radioService[slotId]->checkReturnStatus(retStatus);
5069 } else {
5070 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
5071 slotId);
5072 }
5073
5074 return 0;
5075 }
5076
supplyIccPuk2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5077 int radio_1_6::supplyIccPuk2ForAppResponse(int slotId,
5078 int responseType, int serial, RIL_Errno e,
5079 void *response, size_t responseLen) {
5080 #if VDBG
5081 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
5082 #endif
5083
5084 if (radioService[slotId]->mRadioResponse != NULL) {
5085 RadioResponseInfo responseInfo = {};
5086 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5087 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5088 supplyIccPuk2ForAppResponse(responseInfo, ret);
5089 radioService[slotId]->checkReturnStatus(retStatus);
5090 } else {
5091 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
5092 slotId);
5093 }
5094
5095 return 0;
5096 }
5097
changeIccPinForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5098 int radio_1_6::changeIccPinForAppResponse(int slotId,
5099 int responseType, int serial, RIL_Errno e,
5100 void *response, size_t responseLen) {
5101 #if VDBG
5102 RLOGD("changeIccPinForAppResponse: serial %d", serial);
5103 #endif
5104
5105 if (radioService[slotId]->mRadioResponse != NULL) {
5106 RadioResponseInfo responseInfo = {};
5107 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5108 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5109 changeIccPinForAppResponse(responseInfo, ret);
5110 radioService[slotId]->checkReturnStatus(retStatus);
5111 } else {
5112 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
5113 slotId);
5114 }
5115
5116 return 0;
5117 }
5118
changeIccPin2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5119 int radio_1_6::changeIccPin2ForAppResponse(int slotId,
5120 int responseType, int serial, RIL_Errno e,
5121 void *response, size_t responseLen) {
5122 #if VDBG
5123 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
5124 #endif
5125
5126 if (radioService[slotId]->mRadioResponse != NULL) {
5127 RadioResponseInfo responseInfo = {};
5128 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5129 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5130 changeIccPin2ForAppResponse(responseInfo, ret);
5131 radioService[slotId]->checkReturnStatus(retStatus);
5132 } else {
5133 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
5134 slotId);
5135 }
5136
5137 return 0;
5138 }
5139
supplyNetworkDepersonalizationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5140 int radio_1_6::supplyNetworkDepersonalizationResponse(int slotId,
5141 int responseType, int serial, RIL_Errno e,
5142 void *response, size_t responseLen) {
5143 #if VDBG
5144 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
5145 #endif
5146
5147 if (radioService[slotId]->mRadioResponse != NULL) {
5148 RadioResponseInfo responseInfo = {};
5149 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5150 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5151 supplyNetworkDepersonalizationResponse(responseInfo, ret);
5152 radioService[slotId]->checkReturnStatus(retStatus);
5153 } else {
5154 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
5155 "NULL", slotId);
5156 }
5157
5158 return 0;
5159 }
5160
getCurrentCallsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5161 int radio_1_6::getCurrentCallsResponse(int slotId, int responseType, int serial, RIL_Errno e,
5162 void* response, size_t responseLen) {
5163 #if VDBG
5164 RLOGD("getCurrentCallsResponse: serial %d", serial);
5165 #endif
5166
5167 if (radioService[slotId]->mRadioResponseV1_6 != NULL ||
5168 radioService[slotId]->mRadioResponseV1_2 != NULL ||
5169 radioService[slotId]->mRadioResponse != NULL) {
5170 V1_6::RadioResponseInfo responseInfo16 = {};
5171 RadioResponseInfo responseInfo = {};
5172 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5173 populateResponseInfo_1_6(responseInfo16, serial, responseType, e);
5174 } else {
5175 populateResponseInfo(responseInfo, serial, responseType, e);
5176 }
5177 if ((response == NULL && responseLen != 0) || (responseLen % sizeof(RIL_Call*)) != 0) {
5178 RLOGE("getCurrentCallsResponse: Invalid response");
5179 if (e == RIL_E_SUCCESS) {
5180 responseInfo16.error = V1_6::RadioError::INVALID_RESPONSE;
5181 responseInfo.error = RadioError::INVALID_RESPONSE;
5182 }
5183 return 0;
5184 } else {
5185 Return<void> retStatus;
5186 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5187 hidl_vec<V1_6::Call> calls;
5188 int num = responseLen / sizeof(RIL_Call*);
5189 calls.resize(num);
5190
5191 for (int i = 0; i < num; i++) {
5192 RIL_Call* p_cur = ((RIL_Call**)response)[i];
5193 /* each call info */
5194 calls[i].base.base.state = (CallState)p_cur->state;
5195 calls[i].base.base.index = p_cur->index;
5196 calls[i].base.base.toa = p_cur->toa;
5197 calls[i].base.base.isMpty = p_cur->isMpty;
5198 calls[i].base.base.isMT = p_cur->isMT;
5199 calls[i].base.base.als = p_cur->als;
5200 calls[i].base.base.isVoice = p_cur->isVoice;
5201 calls[i].base.base.isVoicePrivacy = p_cur->isVoicePrivacy;
5202 calls[i].base.base.number = convertCharPtrToHidlString(p_cur->number);
5203 calls[i].base.base.numberPresentation =
5204 (CallPresentation)p_cur->numberPresentation;
5205 calls[i].base.base.name = convertCharPtrToHidlString(p_cur->name);
5206 calls[i].base.base.namePresentation = (CallPresentation)p_cur->namePresentation;
5207 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
5208 RIL_UUS_Info* uusInfo = p_cur->uusInfo;
5209 calls[i].base.base.uusInfo.resize(1);
5210 calls[i].base.base.uusInfo[0].uusType = (UusType)uusInfo->uusType;
5211 calls[i].base.base.uusInfo[0].uusDcs = (UusDcs)uusInfo->uusDcs;
5212 // convert uusInfo->uusData to a null-terminated string
5213 char* nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
5214 calls[i].base.base.uusInfo[0].uusData = nullTermStr;
5215 free(nullTermStr);
5216 }
5217 }
5218 retStatus = radioService[slotId]->mRadioResponseV1_6->getCurrentCallsResponse_1_6(
5219 responseInfo16, calls);
5220 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
5221 hidl_vec<V1_2::Call> calls;
5222 int num = responseLen / sizeof(RIL_Call*);
5223 calls.resize(num);
5224
5225 for (int i = 0; i < num; i++) {
5226 RIL_Call* p_cur = ((RIL_Call**)response)[i];
5227 /* each call info */
5228 calls[i].base.state = (CallState)p_cur->state;
5229 calls[i].base.index = p_cur->index;
5230 calls[i].base.toa = p_cur->toa;
5231 calls[i].base.isMpty = p_cur->isMpty;
5232 calls[i].base.isMT = p_cur->isMT;
5233 calls[i].base.als = p_cur->als;
5234 calls[i].base.isVoice = p_cur->isVoice;
5235 calls[i].base.isVoicePrivacy = p_cur->isVoicePrivacy;
5236 calls[i].base.number = convertCharPtrToHidlString(p_cur->number);
5237 calls[i].base.numberPresentation = (CallPresentation)p_cur->numberPresentation;
5238 calls[i].base.name = convertCharPtrToHidlString(p_cur->name);
5239 calls[i].base.namePresentation = (CallPresentation)p_cur->namePresentation;
5240 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
5241 RIL_UUS_Info* uusInfo = p_cur->uusInfo;
5242 calls[i].base.uusInfo.resize(1);
5243 calls[i].base.uusInfo[0].uusType = (UusType)uusInfo->uusType;
5244 calls[i].base.uusInfo[0].uusDcs = (UusDcs)uusInfo->uusDcs;
5245 // convert uusInfo->uusData to a null-terminated string
5246 char* nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
5247 calls[i].base.uusInfo[0].uusData = nullTermStr;
5248 free(nullTermStr);
5249 }
5250 }
5251 retStatus = radioService[slotId]->mRadioResponseV1_2->getCurrentCallsResponse_1_2(
5252 responseInfo, calls);
5253 } else {
5254 hidl_vec<Call> calls;
5255 int num = responseLen / sizeof(RIL_Call*);
5256 calls.resize(num);
5257
5258 for (int i = 0; i < num; i++) {
5259 RIL_Call* p_cur = ((RIL_Call**)response)[i];
5260 /* each call info */
5261 calls[i].state = (CallState)p_cur->state;
5262 calls[i].index = p_cur->index;
5263 calls[i].toa = p_cur->toa;
5264 calls[i].isMpty = p_cur->isMpty;
5265 calls[i].isMT = p_cur->isMT;
5266 calls[i].als = p_cur->als;
5267 calls[i].isVoice = p_cur->isVoice;
5268 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
5269 calls[i].number = convertCharPtrToHidlString(p_cur->number);
5270 calls[i].numberPresentation = (CallPresentation)p_cur->numberPresentation;
5271 calls[i].name = convertCharPtrToHidlString(p_cur->name);
5272 calls[i].namePresentation = (CallPresentation)p_cur->namePresentation;
5273 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
5274 RIL_UUS_Info* uusInfo = p_cur->uusInfo;
5275 calls[i].uusInfo.resize(1);
5276 calls[i].uusInfo[0].uusType = (UusType)uusInfo->uusType;
5277 calls[i].uusInfo[0].uusDcs = (UusDcs)uusInfo->uusDcs;
5278 // convert uusInfo->uusData to a null-terminated string
5279 char* nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
5280 calls[i].uusInfo[0].uusData = nullTermStr;
5281 free(nullTermStr);
5282 }
5283 }
5284 retStatus = radioService[slotId]->mRadioResponse->getCurrentCallsResponse(
5285 responseInfo, calls);
5286 }
5287 radioService[slotId]->checkReturnStatus(retStatus);
5288 }
5289 } else {
5290 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5291 }
5292
5293 return 0;
5294 }
5295
dialResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5296 int radio_1_6::dialResponse(int slotId,
5297 int responseType, int serial, RIL_Errno e, void *response,
5298 size_t responseLen) {
5299 #if VDBG
5300 RLOGD("dialResponse: serial %d", serial);
5301 #endif
5302
5303 if (radioService[slotId]->mRadioResponse != NULL) {
5304 RadioResponseInfo responseInfo = {};
5305 populateResponseInfo(responseInfo, serial, responseType, e);
5306 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
5307 radioService[slotId]->checkReturnStatus(retStatus);
5308 } else {
5309 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5310 }
5311
5312 return 0;
5313 }
5314
getIMSIForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5315 int radio_1_6::getIMSIForAppResponse(int slotId,
5316 int responseType, int serial, RIL_Errno e, void *response,
5317 size_t responseLen) {
5318 #if VDBG
5319 RLOGD("getIMSIForAppResponse: serial %d", serial);
5320 #endif
5321
5322 if (radioService[slotId]->mRadioResponse != NULL) {
5323 RadioResponseInfo responseInfo = {};
5324 populateResponseInfo(responseInfo, serial, responseType, e);
5325 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
5326 responseInfo, convertCharPtrToHidlString((char *) response));
5327 radioService[slotId]->checkReturnStatus(retStatus);
5328 } else {
5329 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
5330 slotId);
5331 }
5332
5333 return 0;
5334 }
5335
hangupConnectionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5336 int radio_1_6::hangupConnectionResponse(int slotId,
5337 int responseType, int serial, RIL_Errno e,
5338 void *response, size_t responseLen) {
5339 #if VDBG
5340 RLOGD("hangupConnectionResponse: serial %d", serial);
5341 #endif
5342
5343 if (radioService[slotId]->mRadioResponse != NULL) {
5344 RadioResponseInfo responseInfo = {};
5345 populateResponseInfo(responseInfo, serial, responseType, e);
5346 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
5347 responseInfo);
5348 radioService[slotId]->checkReturnStatus(retStatus);
5349 } else {
5350 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
5351 slotId);
5352 }
5353
5354 return 0;
5355 }
5356
hangupWaitingOrBackgroundResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5357 int radio_1_6::hangupWaitingOrBackgroundResponse(int slotId,
5358 int responseType, int serial, RIL_Errno e,
5359 void *response, size_t responseLen) {
5360 #if VDBG
5361 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
5362 #endif
5363
5364 if (radioService[slotId]->mRadioResponse != NULL) {
5365 RadioResponseInfo responseInfo = {};
5366 populateResponseInfo(responseInfo, serial, responseType, e);
5367 Return<void> retStatus =
5368 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
5369 responseInfo);
5370 radioService[slotId]->checkReturnStatus(retStatus);
5371 } else {
5372 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
5373 slotId);
5374 }
5375
5376 return 0;
5377 }
5378
hangupForegroundResumeBackgroundResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5379 int radio_1_6::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
5380 RIL_Errno e, void *response,
5381 size_t responseLen) {
5382 #if VDBG
5383 RLOGD("hangupForegroundResumeBackgroundResponse: serial %d", serial);
5384 #endif
5385
5386 if (radioService[slotId]->mRadioResponse != NULL) {
5387 RadioResponseInfo responseInfo = {};
5388 populateResponseInfo(responseInfo, serial, responseType, e);
5389 Return<void> retStatus =
5390 radioService[slotId]->mRadioResponse->hangupForegroundResumeBackgroundResponse(
5391 responseInfo);
5392 radioService[slotId]->checkReturnStatus(retStatus);
5393 } else {
5394 RLOGE("hangupForegroundResumeBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
5395 slotId);
5396 }
5397
5398 return 0;
5399 }
5400
switchWaitingOrHoldingAndActiveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5401 int radio_1_6::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
5402 RIL_Errno e, void *response,
5403 size_t responseLen) {
5404 #if VDBG
5405 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
5406 #endif
5407
5408 if (radioService[slotId]->mRadioResponse != NULL) {
5409 RadioResponseInfo responseInfo = {};
5410 populateResponseInfo(responseInfo, serial, responseType, e);
5411 Return<void> retStatus =
5412 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
5413 responseInfo);
5414 radioService[slotId]->checkReturnStatus(retStatus);
5415 } else {
5416 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
5417 "== NULL", slotId);
5418 }
5419
5420 return 0;
5421 }
5422
conferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5423 int radio_1_6::conferenceResponse(int slotId, int responseType,
5424 int serial, RIL_Errno e, void *response, size_t responseLen) {
5425 #if VDBG
5426 RLOGD("conferenceResponse: serial %d", serial);
5427 #endif
5428
5429 if (radioService[slotId]->mRadioResponse != NULL) {
5430 RadioResponseInfo responseInfo = {};
5431 populateResponseInfo(responseInfo, serial, responseType, e);
5432 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
5433 responseInfo);
5434 radioService[slotId]->checkReturnStatus(retStatus);
5435 } else {
5436 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
5437 slotId);
5438 }
5439
5440 return 0;
5441 }
5442
rejectCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5443 int radio_1_6::rejectCallResponse(int slotId, int responseType,
5444 int serial, RIL_Errno e, void *response, size_t responseLen) {
5445 #if VDBG
5446 RLOGD("rejectCallResponse: serial %d", serial);
5447 #endif
5448
5449 if (radioService[slotId]->mRadioResponse != NULL) {
5450 RadioResponseInfo responseInfo = {};
5451 populateResponseInfo(responseInfo, serial, responseType, e);
5452 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
5453 responseInfo);
5454 radioService[slotId]->checkReturnStatus(retStatus);
5455 } else {
5456 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
5457 slotId);
5458 }
5459
5460 return 0;
5461 }
5462
getLastCallFailCauseResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5463 int radio_1_6::getLastCallFailCauseResponse(int slotId,
5464 int responseType, int serial, RIL_Errno e, void *response,
5465 size_t responseLen) {
5466 #if VDBG
5467 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
5468 #endif
5469
5470 if (radioService[slotId]->mRadioResponse != NULL) {
5471 RadioResponseInfo responseInfo = {};
5472 populateResponseInfo(responseInfo, serial, responseType, e);
5473
5474 LastCallFailCauseInfo info = {};
5475 info.vendorCause = hidl_string();
5476 if (response == NULL) {
5477 RLOGE("getLastCallFailCauseResponse Invalid response: NULL");
5478 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5479 } else if (responseLen == sizeof(int)) {
5480 int *pInt = (int *) response;
5481 info.causeCode = (LastCallFailCause) pInt[0];
5482 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
5483 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
5484 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
5485 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
5486 } else {
5487 RLOGE("getLastCallFailCauseResponse Invalid response: NULL");
5488 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5489 }
5490
5491 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
5492 responseInfo, info);
5493 radioService[slotId]->checkReturnStatus(retStatus);
5494 } else {
5495 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
5496 slotId);
5497 }
5498
5499 return 0;
5500 }
5501
getSignalStrengthResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5502 int radio_1_6::getSignalStrengthResponse(int slotId, int responseType, int serial, RIL_Errno e,
5503 void* response, size_t responseLen) {
5504 #if VDBG
5505 RLOGD("getSignalStrengthResponse: serial %d", serial);
5506 #endif
5507
5508 V1_6::RadioResponseInfo responseInfo16 = {};
5509 RadioResponseInfo responseInfo = {};
5510 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5511 populateResponseInfo_1_6(responseInfo16, serial, responseType, e);
5512 } else {
5513 populateResponseInfo(responseInfo, serial, responseType, e);
5514 }
5515
5516 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v12)) {
5517 RLOGE("getSignalStrengthResponse: Invalid response");
5518 if (e == RIL_E_SUCCESS) {
5519 responseInfo16.error = V1_6::RadioError::INVALID_RESPONSE;
5520 responseInfo.error = RadioError::INVALID_RESPONSE;
5521 }
5522 } else {
5523 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5524 V1_6::SignalStrength signalStrength_1_6 = {};
5525 convertRilSignalStrengthToHal_1_6(response, responseLen, signalStrength_1_6);
5526 Return<void> retStatus =
5527 radioService[slotId]->mRadioResponseV1_6->getSignalStrengthResponse_1_6(
5528 responseInfo16, signalStrength_1_6);
5529 radioService[slotId]->checkReturnStatus(retStatus);
5530 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
5531 V1_4::SignalStrength signalStrength_1_4 = {};
5532 convertRilSignalStrengthToHal_1_4(response, responseLen, signalStrength_1_4);
5533 // TODO: future implementation needs to fill tdScdma, wcdma and nr signal strength.
5534 Return<void> retStatus =
5535 radioService[slotId]->mRadioResponseV1_4->getSignalStrengthResponse_1_4(
5536 responseInfo, signalStrength_1_4);
5537 radioService[slotId]->checkReturnStatus(retStatus);
5538 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
5539 V1_2::SignalStrength signalStrength_1_2 = {};
5540 convertRilSignalStrengthToHal_1_2(response, responseLen, signalStrength_1_2);
5541 Return<void> retStatus =
5542 radioService[slotId]->mRadioResponseV1_2->getSignalStrengthResponse_1_2(
5543 responseInfo, signalStrength_1_2);
5544 radioService[slotId]->checkReturnStatus(retStatus);
5545 } else if (radioService[slotId]->mRadioResponse != NULL) {
5546 SignalStrength signalStrength = {};
5547 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
5548 Return<void> retStatus =
5549 radioService[slotId]->mRadioResponse->getSignalStrengthResponse(responseInfo,
5550 signalStrength);
5551 radioService[slotId]->checkReturnStatus(retStatus);
5552 } else {
5553 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5554 }
5555 }
5556
5557 return 0;
5558 }
5559
getCellInfoTypeRadioTechnology(char * rat)5560 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
5561 if (rat == NULL) {
5562 return RIL_CELL_INFO_TYPE_NONE;
5563 }
5564
5565 int radioTech = atoi(rat);
5566
5567 switch(radioTech) {
5568
5569 case RADIO_TECH_GPRS:
5570 case RADIO_TECH_EDGE:
5571 case RADIO_TECH_GSM: {
5572 return RIL_CELL_INFO_TYPE_GSM;
5573 }
5574
5575 case RADIO_TECH_UMTS:
5576 case RADIO_TECH_HSDPA:
5577 case RADIO_TECH_HSUPA:
5578 case RADIO_TECH_HSPA:
5579 case RADIO_TECH_HSPAP: {
5580 return RIL_CELL_INFO_TYPE_WCDMA;
5581 }
5582
5583 case RADIO_TECH_IS95A:
5584 case RADIO_TECH_IS95B:
5585 case RADIO_TECH_1xRTT:
5586 case RADIO_TECH_EVDO_0:
5587 case RADIO_TECH_EVDO_A:
5588 case RADIO_TECH_EVDO_B:
5589 case RADIO_TECH_EHRPD: {
5590 return RIL_CELL_INFO_TYPE_CDMA;
5591 }
5592
5593 case RADIO_TECH_LTE:
5594 case RADIO_TECH_LTE_CA: {
5595 return RIL_CELL_INFO_TYPE_LTE;
5596 }
5597
5598 case RADIO_TECH_TD_SCDMA: {
5599 return RIL_CELL_INFO_TYPE_TD_SCDMA;
5600 }
5601
5602 default: {
5603 break;
5604 }
5605 }
5606
5607 return RIL_CELL_INFO_TYPE_NONE;
5608
5609 }
5610
fillCellIdentityResponse(CellIdentity & cellIdentity,RIL_CellIdentity_v16 & rilCellIdentity)5611 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
5612
5613 cellIdentity.cellIdentityGsm.resize(0);
5614 cellIdentity.cellIdentityWcdma.resize(0);
5615 cellIdentity.cellIdentityCdma.resize(0);
5616 cellIdentity.cellIdentityTdscdma.resize(0);
5617 cellIdentity.cellIdentityLte.resize(0);
5618 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
5619 switch(rilCellIdentity.cellInfoType) {
5620
5621 case RIL_CELL_INFO_TYPE_GSM: {
5622 cellIdentity.cellIdentityGsm.resize(1);
5623 cellIdentity.cellIdentityGsm[0].mcc =
5624 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5625 cellIdentity.cellIdentityGsm[0].mnc =
5626 ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
5627 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
5628 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
5629 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
5630 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
5631 break;
5632 }
5633
5634 case RIL_CELL_INFO_TYPE_WCDMA: {
5635 cellIdentity.cellIdentityWcdma.resize(1);
5636 cellIdentity.cellIdentityWcdma[0].mcc =
5637 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
5638 cellIdentity.cellIdentityWcdma[0].mnc =
5639 ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
5640 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
5641 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
5642 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
5643 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
5644 break;
5645 }
5646
5647 case RIL_CELL_INFO_TYPE_CDMA: {
5648 cellIdentity.cellIdentityCdma.resize(1);
5649 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
5650 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
5651 cellIdentity.cellIdentityCdma[0].baseStationId =
5652 rilCellIdentity.cellIdentityCdma.basestationId;
5653 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
5654 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
5655 break;
5656 }
5657
5658 case RIL_CELL_INFO_TYPE_LTE: {
5659 cellIdentity.cellIdentityLte.resize(1);
5660 cellIdentity.cellIdentityLte[0].mcc =
5661 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
5662 cellIdentity.cellIdentityLte[0].mnc =
5663 ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
5664 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
5665 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
5666 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
5667 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
5668 break;
5669 }
5670
5671 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
5672 cellIdentity.cellIdentityTdscdma.resize(1);
5673 cellIdentity.cellIdentityTdscdma[0].mcc =
5674 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
5675 cellIdentity.cellIdentityTdscdma[0].mnc =
5676 ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
5677 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
5678 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
5679 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
5680 break;
5681 }
5682
5683 default: {
5684 break;
5685 }
5686 }
5687 }
5688
fillCellIdentityResponse_1_5(V1_5::CellIdentity & cellIdentity,RIL_CellIdentity_v16 & rilCellIdentity)5689 void fillCellIdentityResponse_1_5(V1_5::CellIdentity &cellIdentity,
5690 RIL_CellIdentity_v16 &rilCellIdentity) {
5691
5692 switch (rilCellIdentity.cellInfoType) {
5693 case RIL_CELL_INFO_TYPE_GSM: {
5694 V1_5::CellIdentityGsm gsm;
5695 gsm.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5696 gsm.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
5697 if (gsm.base.base.mcc == "-1") {
5698 gsm.base.base.mcc = "";
5699 }
5700 gsm.base.base.lac = rilCellIdentity.cellIdentityGsm.lac;
5701 gsm.base.base.cid = rilCellIdentity.cellIdentityGsm.cid;
5702 gsm.base.base.arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
5703 gsm.base.base.bsic = rilCellIdentity.cellIdentityGsm.bsic;
5704 cellIdentity.gsm(gsm);
5705 break;
5706 }
5707
5708 case RIL_CELL_INFO_TYPE_WCDMA: {
5709 V1_5::CellIdentityWcdma wcdma;
5710 wcdma.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5711 wcdma.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
5712 if (wcdma.base.base.mcc == "-1") {
5713 wcdma.base.base.mcc = "";
5714 }
5715 wcdma.base.base.lac = rilCellIdentity.cellIdentityWcdma.lac;
5716 wcdma.base.base.cid = rilCellIdentity.cellIdentityWcdma.cid;
5717 wcdma.base.base.psc = rilCellIdentity.cellIdentityWcdma.psc;
5718 wcdma.base.base.uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
5719 cellIdentity.wcdma(wcdma);
5720 break;
5721 }
5722
5723 case RIL_CELL_INFO_TYPE_CDMA: {
5724 V1_2::CellIdentityCdma cdma;
5725 cdma.base.networkId = rilCellIdentity.cellIdentityCdma.networkId;
5726 cdma.base.systemId = rilCellIdentity.cellIdentityCdma.systemId;
5727 cdma.base.baseStationId =
5728 rilCellIdentity.cellIdentityCdma.basestationId;
5729 cdma.base.longitude = rilCellIdentity.cellIdentityCdma.longitude;
5730 cdma.base.latitude = rilCellIdentity.cellIdentityCdma.latitude;
5731 cellIdentity.cdma(cdma);
5732 break;
5733 }
5734
5735 case RIL_CELL_INFO_TYPE_LTE: {
5736 V1_5::CellIdentityLte lte;
5737 lte.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5738 lte.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
5739 if (lte.base.base.mcc == "-1") {
5740 lte.base.base.mcc = "";
5741 }
5742 lte.base.base.ci = rilCellIdentity.cellIdentityLte.ci;
5743 lte.base.base.pci = rilCellIdentity.cellIdentityLte.pci;
5744 lte.base.base.tac = rilCellIdentity.cellIdentityLte.tac;
5745 lte.base.base.earfcn = rilCellIdentity.cellIdentityLte.earfcn;
5746 cellIdentity.lte(lte);
5747 break;
5748 }
5749
5750 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
5751 V1_5::CellIdentityTdscdma tdscdma;
5752 tdscdma.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5753 tdscdma.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
5754 if (tdscdma.base.base.mcc == "-1") {
5755 tdscdma.base.base.mcc = "";
5756 }
5757 tdscdma.base.base.lac = rilCellIdentity.cellIdentityTdscdma.lac;
5758 tdscdma.base.base.cid = rilCellIdentity.cellIdentityTdscdma.cid;
5759 tdscdma.base.base.cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
5760 cellIdentity.tdscdma(tdscdma);
5761 break;
5762 }
5763
5764 default: {
5765 break;
5766 }
5767 }
5768 }
5769
fillCellIdentityResponse_1_2(V1_2::CellIdentity & cellIdentity,RIL_CellIdentity_v1_2 & rilCellIdentity)5770 void fillCellIdentityResponse_1_2(V1_2::CellIdentity &cellIdentity,
5771 RIL_CellIdentity_v1_2 &rilCellIdentity) {
5772 cellIdentity.cellIdentityGsm.resize(0);
5773 cellIdentity.cellIdentityWcdma.resize(0);
5774 cellIdentity.cellIdentityCdma.resize(0);
5775 cellIdentity.cellIdentityTdscdma.resize(0);
5776 cellIdentity.cellIdentityLte.resize(0);
5777 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
5778 switch(rilCellIdentity.cellInfoType) {
5779
5780 case RIL_CELL_INFO_TYPE_GSM: {
5781 cellIdentity.cellIdentityGsm.resize(1);
5782 cellIdentity.cellIdentityGsm[0].base.mcc =
5783 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5784 cellIdentity.cellIdentityGsm[0].base.mnc =
5785 ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
5786
5787 if (cellIdentity.cellIdentityGsm[0].base.mcc == "-1") {
5788 cellIdentity.cellIdentityGsm[0].base.mcc = "";
5789 }
5790
5791 cellIdentity.cellIdentityGsm[0].base.lac = rilCellIdentity.cellIdentityGsm.lac;
5792 cellIdentity.cellIdentityGsm[0].base.cid = rilCellIdentity.cellIdentityGsm.cid;
5793 cellIdentity.cellIdentityGsm[0].base.arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
5794 cellIdentity.cellIdentityGsm[0].base.bsic = rilCellIdentity.cellIdentityGsm.bsic;
5795 break;
5796 }
5797
5798 case RIL_CELL_INFO_TYPE_WCDMA: {
5799 cellIdentity.cellIdentityWcdma.resize(1);
5800 cellIdentity.cellIdentityWcdma[0].base.mcc =
5801 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
5802 cellIdentity.cellIdentityWcdma[0].base.mnc =
5803 ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
5804
5805 if (cellIdentity.cellIdentityWcdma[0].base.mcc == "-1") {
5806 cellIdentity.cellIdentityWcdma[0].base.mcc = "";
5807 }
5808
5809 cellIdentity.cellIdentityWcdma[0].base.lac = rilCellIdentity.cellIdentityWcdma.lac;
5810 cellIdentity.cellIdentityWcdma[0].base.cid = rilCellIdentity.cellIdentityWcdma.cid;
5811 cellIdentity.cellIdentityWcdma[0].base.psc = rilCellIdentity.cellIdentityWcdma.psc;
5812 cellIdentity.cellIdentityWcdma[0].base.uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
5813 break;
5814 }
5815
5816 case RIL_CELL_INFO_TYPE_CDMA: {
5817 cellIdentity.cellIdentityCdma.resize(1);
5818 cellIdentity.cellIdentityCdma[0].base.networkId = rilCellIdentity.cellIdentityCdma.networkId;
5819 cellIdentity.cellIdentityCdma[0].base.systemId = rilCellIdentity.cellIdentityCdma.systemId;
5820 cellIdentity.cellIdentityCdma[0].base.baseStationId =
5821 rilCellIdentity.cellIdentityCdma.basestationId;
5822 cellIdentity.cellIdentityCdma[0].base.longitude = rilCellIdentity.cellIdentityCdma.longitude;
5823 cellIdentity.cellIdentityCdma[0].base.latitude = rilCellIdentity.cellIdentityCdma.latitude;
5824 break;
5825 }
5826
5827 case RIL_CELL_INFO_TYPE_LTE: {
5828 cellIdentity.cellIdentityLte.resize(1);
5829 cellIdentity.cellIdentityLte[0].base.mcc =
5830 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
5831 cellIdentity.cellIdentityLte[0].base.mnc =
5832 ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
5833
5834 if (cellIdentity.cellIdentityLte[0].base.mcc == "-1") {
5835 cellIdentity.cellIdentityLte[0].base.mcc = "";
5836 }
5837
5838 cellIdentity.cellIdentityLte[0].base.ci = rilCellIdentity.cellIdentityLte.ci;
5839 cellIdentity.cellIdentityLte[0].base.pci = rilCellIdentity.cellIdentityLte.pci;
5840 cellIdentity.cellIdentityLte[0].base.tac = rilCellIdentity.cellIdentityLte.tac;
5841 cellIdentity.cellIdentityLte[0].base.earfcn = rilCellIdentity.cellIdentityLte.earfcn;
5842 cellIdentity.cellIdentityLte[0].bandwidth = rilCellIdentity.cellIdentityLte.bandwidth;
5843 break;
5844 }
5845
5846 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
5847 cellIdentity.cellIdentityTdscdma.resize(1);
5848 cellIdentity.cellIdentityTdscdma[0].base.mcc =
5849 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
5850 cellIdentity.cellIdentityTdscdma[0].base.mnc =
5851 ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
5852
5853 if (cellIdentity.cellIdentityTdscdma[0].base.mcc == "-1") {
5854 cellIdentity.cellIdentityTdscdma[0].base.mcc = "";
5855 }
5856
5857 cellIdentity.cellIdentityTdscdma[0].base.lac = rilCellIdentity.cellIdentityTdscdma.lac;
5858 cellIdentity.cellIdentityTdscdma[0].base.cid = rilCellIdentity.cellIdentityTdscdma.cid;
5859 cellIdentity.cellIdentityTdscdma[0].base.cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
5860 cellIdentity.cellIdentityTdscdma[0].uarfcn = rilCellIdentity.cellIdentityTdscdma.uarfcn;
5861 break;
5862 }
5863
5864 default: {
5865 break;
5866 }
5867 }
5868 }
5869
convertResponseStringEntryToInt(char ** response,int index,int numStrings)5870 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
5871 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
5872 return atoi(response[index]);
5873 }
5874
5875 return -1;
5876 }
5877
convertResponseHexStringEntryToInt(char ** response,int index,int numStrings)5878 int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
5879 const int hexBase = 16;
5880 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
5881 return strtol(response[index], NULL, hexBase);
5882 }
5883
5884 return -1;
5885 }
5886
5887 /* Fill Cell Identity info from Voice Registration State Response.
5888 * This fucntion is applicable only for RIL Version < 15.
5889 * Response is a "char **".
5890 * First and Second entries are in hex string format
5891 * and rest are integers represented in ascii format. */
fillCellIdentityFromVoiceRegStateResponseString(V1_5::CellIdentity & cellIdentity,int numStrings,char ** response)5892 void fillCellIdentityFromVoiceRegStateResponseString(V1_5::CellIdentity &cellIdentity,
5893 int numStrings, char** response) {
5894
5895 RIL_CellIdentity_v16 rilCellIdentity;
5896 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
5897
5898 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
5899 switch(rilCellIdentity.cellInfoType) {
5900
5901 case RIL_CELL_INFO_TYPE_GSM: {
5902 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
5903 rilCellIdentity.cellIdentityGsm.lac =
5904 convertResponseHexStringEntryToInt(response, 1, numStrings);
5905
5906 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
5907 rilCellIdentity.cellIdentityGsm.cid =
5908 convertResponseHexStringEntryToInt(response, 2, numStrings);
5909
5910 if (numStrings > 15) {
5911 rilCellIdentity.cellIdentityGsm.mcc =
5912 convertResponseStringEntryToInt(response, 15, numStrings);
5913
5914 rilCellIdentity.cellIdentityGsm.mnc =
5915 convertResponseStringEntryToInt(response, 16, numStrings);
5916 }
5917 break;
5918 }
5919
5920 case RIL_CELL_INFO_TYPE_WCDMA: {
5921 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
5922 rilCellIdentity.cellIdentityWcdma.lac =
5923 convertResponseHexStringEntryToInt(response, 1, numStrings);
5924
5925 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
5926 rilCellIdentity.cellIdentityWcdma.cid =
5927 convertResponseHexStringEntryToInt(response, 2, numStrings);
5928 rilCellIdentity.cellIdentityWcdma.psc =
5929 convertResponseStringEntryToInt(response, 14, numStrings);
5930
5931 if (numStrings > 15) {
5932 rilCellIdentity.cellIdentityGsm.mcc =
5933 convertResponseStringEntryToInt(response, 15, numStrings);
5934
5935 rilCellIdentity.cellIdentityGsm.mnc =
5936 convertResponseStringEntryToInt(response, 16, numStrings);
5937 }
5938 break;
5939 }
5940
5941 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
5942 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
5943 rilCellIdentity.cellIdentityTdscdma.lac =
5944 convertResponseHexStringEntryToInt(response, 1, numStrings);
5945
5946 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
5947 rilCellIdentity.cellIdentityTdscdma.cid =
5948 convertResponseHexStringEntryToInt(response, 2, numStrings);
5949
5950 if (numStrings > 15) {
5951 rilCellIdentity.cellIdentityGsm.mcc =
5952 convertResponseStringEntryToInt(response, 15, numStrings);
5953
5954 rilCellIdentity.cellIdentityGsm.mnc =
5955 convertResponseStringEntryToInt(response, 16, numStrings);
5956 }
5957 break;
5958 }
5959
5960 case RIL_CELL_INFO_TYPE_CDMA:{
5961 rilCellIdentity.cellIdentityCdma.basestationId =
5962 convertResponseStringEntryToInt(response, 4, numStrings);
5963 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
5964 rilCellIdentity.cellIdentityCdma.latitude =
5965 convertResponseStringEntryToInt(response, 5, numStrings);
5966 rilCellIdentity.cellIdentityCdma.longitude =
5967 convertResponseStringEntryToInt(response, 6, numStrings);
5968 rilCellIdentity.cellIdentityCdma.systemId =
5969 convertResponseStringEntryToInt(response, 8, numStrings);
5970 rilCellIdentity.cellIdentityCdma.networkId =
5971 convertResponseStringEntryToInt(response, 9, numStrings);
5972 break;
5973 }
5974
5975 case RIL_CELL_INFO_TYPE_LTE:{
5976 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
5977 rilCellIdentity.cellIdentityLte.tac =
5978 convertResponseHexStringEntryToInt(response, 1, numStrings);
5979
5980 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
5981 rilCellIdentity.cellIdentityLte.ci =
5982 convertResponseHexStringEntryToInt(response, 2, numStrings);
5983
5984 if (numStrings > 15) {
5985 rilCellIdentity.cellIdentityGsm.mcc =
5986 convertResponseStringEntryToInt(response, 15, numStrings);
5987
5988 rilCellIdentity.cellIdentityGsm.mnc =
5989 convertResponseStringEntryToInt(response, 16, numStrings);
5990 }
5991 break;
5992 }
5993
5994 default: {
5995 break;
5996 }
5997 }
5998
5999 fillCellIdentityResponse_1_5(cellIdentity, rilCellIdentity);
6000 }
6001
fillCellIdentityFromVoiceRegStateResponseString_1_2(V1_2::CellIdentity & cellIdentity,int numStrings,char ** response)6002 void fillCellIdentityFromVoiceRegStateResponseString_1_2(V1_2::CellIdentity &cellIdentity,
6003 int numStrings, char** response) {
6004 RIL_CellIdentity_v1_2 rilCellIdentity;
6005 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v1_2));
6006
6007 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6008
6009 switch(rilCellIdentity.cellInfoType) {
6010 case RIL_CELL_INFO_TYPE_GSM: {
6011 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6012 rilCellIdentity.cellIdentityGsm.lac =
6013 convertResponseHexStringEntryToInt(response, 1, numStrings);
6014
6015 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6016 rilCellIdentity.cellIdentityGsm.cid =
6017 convertResponseHexStringEntryToInt(response, 2, numStrings);
6018
6019 if (numStrings > 15) {
6020 rilCellIdentity.cellIdentityGsm.mcc =
6021 convertResponseStringEntryToInt(response, 15, numStrings);
6022
6023 rilCellIdentity.cellIdentityGsm.mnc =
6024 convertResponseStringEntryToInt(response, 16, numStrings);
6025 }
6026 break;
6027 }
6028
6029 case RIL_CELL_INFO_TYPE_WCDMA: {
6030 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6031 rilCellIdentity.cellIdentityWcdma.lac =
6032 convertResponseHexStringEntryToInt(response, 1, numStrings);
6033
6034 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6035 rilCellIdentity.cellIdentityWcdma.cid =
6036 convertResponseHexStringEntryToInt(response, 2, numStrings);
6037 rilCellIdentity.cellIdentityWcdma.psc =
6038 convertResponseStringEntryToInt(response, 14, numStrings);
6039
6040 if (numStrings > 15) {
6041 rilCellIdentity.cellIdentityWcdma.mcc =
6042 convertResponseStringEntryToInt(response, 15, numStrings);
6043
6044 rilCellIdentity.cellIdentityWcdma.mnc =
6045 convertResponseStringEntryToInt(response, 16, numStrings);
6046 }
6047 break;
6048 }
6049
6050 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
6051 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6052 rilCellIdentity.cellIdentityTdscdma.lac =
6053 convertResponseHexStringEntryToInt(response, 1, numStrings);
6054
6055 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6056 rilCellIdentity.cellIdentityTdscdma.cid =
6057 convertResponseHexStringEntryToInt(response, 2, numStrings);
6058
6059 if (numStrings > 15) {
6060 rilCellIdentity.cellIdentityTdscdma.mcc =
6061 convertResponseStringEntryToInt(response, 15, numStrings);
6062
6063 rilCellIdentity.cellIdentityTdscdma.mnc =
6064 convertResponseStringEntryToInt(response, 16, numStrings);
6065 }
6066 break;
6067 }
6068
6069 case RIL_CELL_INFO_TYPE_CDMA:{
6070 rilCellIdentity.cellIdentityCdma.basestationId =
6071 convertResponseStringEntryToInt(response, 4, numStrings);
6072 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
6073 rilCellIdentity.cellIdentityCdma.latitude =
6074 convertResponseStringEntryToInt(response, 5, numStrings);
6075 rilCellIdentity.cellIdentityCdma.longitude =
6076 convertResponseStringEntryToInt(response, 6, numStrings);
6077 rilCellIdentity.cellIdentityCdma.systemId =
6078 convertResponseStringEntryToInt(response, 8, numStrings);
6079 rilCellIdentity.cellIdentityCdma.networkId =
6080 convertResponseStringEntryToInt(response, 9, numStrings);
6081 break;
6082 }
6083
6084 case RIL_CELL_INFO_TYPE_LTE:{
6085 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
6086 rilCellIdentity.cellIdentityLte.tac =
6087 convertResponseHexStringEntryToInt(response, 1, numStrings);
6088
6089 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6090 rilCellIdentity.cellIdentityLte.ci =
6091 convertResponseHexStringEntryToInt(response, 2, numStrings);
6092
6093 if (numStrings > 15) {
6094 rilCellIdentity.cellIdentityLte.mcc =
6095 convertResponseStringEntryToInt(response, 15, numStrings);
6096
6097 rilCellIdentity.cellIdentityLte.mnc =
6098 convertResponseStringEntryToInt(response, 16, numStrings);
6099 }
6100 rilCellIdentity.cellIdentityLte.bandwidth = INT_MAX;
6101 break;
6102 }
6103
6104 default: {
6105 break;
6106 }
6107 }
6108
6109 fillCellIdentityResponse_1_2(cellIdentity, rilCellIdentity);
6110 }
6111
6112 /* Fill Cell Identity info from Data Registration State Response.
6113 * This fucntion is applicable only for RIL Version < 15.
6114 * Response is a "char **".
6115 * First and Second entries are in hex string format
6116 * and rest are integers represented in ascii format. */
fillCellIdentityFromDataRegStateResponseString_1_5(V1_5::CellIdentity & cellIdentity,int numStrings,char ** response)6117 void fillCellIdentityFromDataRegStateResponseString_1_5(V1_5::CellIdentity &cellIdentity,
6118 int numStrings, char** response) {
6119
6120 RIL_CellIdentity_v16 rilCellIdentity;
6121 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
6122
6123 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6124 switch(rilCellIdentity.cellInfoType) {
6125 case RIL_CELL_INFO_TYPE_GSM: {
6126 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6127 rilCellIdentity.cellIdentityGsm.lac =
6128 convertResponseHexStringEntryToInt(response, 1, numStrings);
6129
6130 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6131 rilCellIdentity.cellIdentityGsm.cid =
6132 convertResponseHexStringEntryToInt(response, 2, numStrings);
6133
6134 if (numStrings >= 13) {
6135 rilCellIdentity.cellIdentityGsm.mcc =
6136 convertResponseStringEntryToInt(response, 11, numStrings);
6137
6138 rilCellIdentity.cellIdentityGsm.mnc =
6139 convertResponseStringEntryToInt(response, 12, numStrings);
6140 } else {
6141 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6142 rilCellIdentity.cellIdentityGsm.mnc = 0;
6143 rilCellIdentity.cellIdentityGsm.mcc = 0;
6144 }
6145 break;
6146 }
6147 case RIL_CELL_INFO_TYPE_WCDMA: {
6148 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6149 rilCellIdentity.cellIdentityWcdma.lac =
6150 convertResponseHexStringEntryToInt(response, 1, numStrings);
6151
6152 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6153 rilCellIdentity.cellIdentityWcdma.cid =
6154 convertResponseHexStringEntryToInt(response, 2, numStrings);
6155
6156 if (numStrings >= 13) {
6157 rilCellIdentity.cellIdentityWcdma.mcc =
6158 convertResponseStringEntryToInt(response, 11, numStrings);
6159
6160 rilCellIdentity.cellIdentityWcdma.mnc =
6161 convertResponseStringEntryToInt(response, 12, numStrings);
6162 } else {
6163 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6164 rilCellIdentity.cellIdentityWcdma.mnc = 0;
6165 rilCellIdentity.cellIdentityWcdma.mcc = 0;
6166 }
6167 break;
6168 }
6169 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
6170 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6171 rilCellIdentity.cellIdentityTdscdma.lac =
6172 convertResponseHexStringEntryToInt(response, 1, numStrings);
6173
6174 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6175 rilCellIdentity.cellIdentityTdscdma.cid =
6176 convertResponseHexStringEntryToInt(response, 2, numStrings);
6177
6178 if (numStrings >= 13) {
6179 rilCellIdentity.cellIdentityTdscdma.mcc =
6180 convertResponseStringEntryToInt(response, 11, numStrings);
6181
6182 rilCellIdentity.cellIdentityTdscdma.mnc =
6183 convertResponseStringEntryToInt(response, 12, numStrings);
6184 } else {
6185 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6186 rilCellIdentity.cellIdentityTdscdma.mnc = 0;
6187 rilCellIdentity.cellIdentityTdscdma.mcc = 0;
6188 }
6189 break;
6190 }
6191 case RIL_CELL_INFO_TYPE_LTE: {
6192 rilCellIdentity.cellIdentityLte.tac =
6193 convertResponseStringEntryToInt(response, 6, numStrings);
6194 rilCellIdentity.cellIdentityLte.pci =
6195 convertResponseStringEntryToInt(response, 7, numStrings);
6196 rilCellIdentity.cellIdentityLte.ci =
6197 convertResponseStringEntryToInt(response, 8, numStrings);
6198
6199 if (numStrings >= 13) {
6200 rilCellIdentity.cellIdentityLte.mcc =
6201 convertResponseStringEntryToInt(response, 11, numStrings);
6202
6203 rilCellIdentity.cellIdentityLte.mnc =
6204 convertResponseStringEntryToInt(response, 12, numStrings);
6205 } else {
6206 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6207 rilCellIdentity.cellIdentityLte.mnc = 0;
6208 rilCellIdentity.cellIdentityLte.mcc = 0;
6209 }
6210 break;
6211 }
6212 default: {
6213 break;
6214 }
6215 }
6216
6217 fillCellIdentityResponse_1_5(cellIdentity, rilCellIdentity);
6218 }
6219
fillCellIdentityFromDataRegStateResponseString_1_2(V1_2::CellIdentity & cellIdentity,int numStrings,char ** response)6220 void fillCellIdentityFromDataRegStateResponseString_1_2(V1_2::CellIdentity &cellIdentity,
6221 int numStrings, char** response) {
6222
6223 RIL_CellIdentity_v1_2 rilCellIdentity;
6224 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v1_2));
6225
6226 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6227 switch(rilCellIdentity.cellInfoType) {
6228 case RIL_CELL_INFO_TYPE_GSM: {
6229 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6230 rilCellIdentity.cellIdentityGsm.lac =
6231 convertResponseHexStringEntryToInt(response, 1, numStrings);
6232
6233 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6234 rilCellIdentity.cellIdentityGsm.cid =
6235 convertResponseHexStringEntryToInt(response, 2, numStrings);
6236
6237 if (numStrings >= 13) {
6238 rilCellIdentity.cellIdentityGsm.mcc =
6239 convertResponseStringEntryToInt(response, 11, numStrings);
6240
6241 rilCellIdentity.cellIdentityGsm.mnc =
6242 convertResponseStringEntryToInt(response, 12, numStrings);
6243 } else {
6244 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6245 rilCellIdentity.cellIdentityGsm.mnc = 0;
6246 rilCellIdentity.cellIdentityGsm.mcc = 0;
6247 }
6248 break;
6249 }
6250 case RIL_CELL_INFO_TYPE_WCDMA: {
6251 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6252 rilCellIdentity.cellIdentityWcdma.lac =
6253 convertResponseHexStringEntryToInt(response, 1, numStrings);
6254
6255 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6256 rilCellIdentity.cellIdentityWcdma.cid =
6257 convertResponseHexStringEntryToInt(response, 2, numStrings);
6258
6259 if (numStrings >= 13) {
6260 rilCellIdentity.cellIdentityWcdma.mcc =
6261 convertResponseStringEntryToInt(response, 11, numStrings);
6262
6263 rilCellIdentity.cellIdentityWcdma.mnc =
6264 convertResponseStringEntryToInt(response, 12, numStrings);
6265 } else {
6266 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6267 rilCellIdentity.cellIdentityWcdma.mnc = 0;
6268 rilCellIdentity.cellIdentityWcdma.mcc = 0;
6269 }
6270 break;
6271 }
6272 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
6273 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6274 rilCellIdentity.cellIdentityTdscdma.lac =
6275 convertResponseHexStringEntryToInt(response, 1, numStrings);
6276
6277 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6278 rilCellIdentity.cellIdentityTdscdma.cid =
6279 convertResponseHexStringEntryToInt(response, 2, numStrings);
6280
6281 if (numStrings >= 13) {
6282 rilCellIdentity.cellIdentityTdscdma.mcc =
6283 convertResponseStringEntryToInt(response, 11, numStrings);
6284
6285 rilCellIdentity.cellIdentityTdscdma.mnc =
6286 convertResponseStringEntryToInt(response, 12, numStrings);
6287 } else {
6288 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6289 rilCellIdentity.cellIdentityTdscdma.mnc = 0;
6290 rilCellIdentity.cellIdentityTdscdma.mcc = 0;
6291 }
6292 break;
6293 }
6294 case RIL_CELL_INFO_TYPE_LTE: {
6295 rilCellIdentity.cellIdentityLte.tac =
6296 convertResponseStringEntryToInt(response, 6, numStrings);
6297 rilCellIdentity.cellIdentityLte.pci =
6298 convertResponseStringEntryToInt(response, 7, numStrings);
6299 rilCellIdentity.cellIdentityLte.ci =
6300 convertResponseStringEntryToInt(response, 8, numStrings);
6301
6302 if (numStrings >= 13) {
6303 rilCellIdentity.cellIdentityLte.mcc =
6304 convertResponseStringEntryToInt(response, 11, numStrings);
6305
6306 rilCellIdentity.cellIdentityLte.mnc =
6307 convertResponseStringEntryToInt(response, 12, numStrings);
6308 } else {
6309 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6310 rilCellIdentity.cellIdentityLte.mnc = 0;
6311 rilCellIdentity.cellIdentityLte.mcc = 0;
6312 }
6313 break;
6314 }
6315 case RIL_CELL_INFO_TYPE_CDMA: {
6316 break;
6317 }
6318 default: {
6319 break;
6320 }
6321 }
6322
6323 fillCellIdentityResponse_1_2(cellIdentity, rilCellIdentity);
6324 }
6325
fillCellIdentityFromDataRegStateResponseString(CellIdentity & cellIdentity,int numStrings,char ** response)6326 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
6327 int numStrings, char** response) {
6328
6329 RIL_CellIdentity_v16 rilCellIdentity;
6330 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
6331
6332 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6333 switch(rilCellIdentity.cellInfoType) {
6334 case RIL_CELL_INFO_TYPE_GSM: {
6335 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6336 rilCellIdentity.cellIdentityGsm.lac =
6337 convertResponseHexStringEntryToInt(response, 1, numStrings);
6338
6339 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6340 rilCellIdentity.cellIdentityGsm.cid =
6341 convertResponseHexStringEntryToInt(response, 2, numStrings);
6342
6343 if (numStrings >= 13) {
6344 rilCellIdentity.cellIdentityGsm.mcc =
6345 convertResponseStringEntryToInt(response, 11, numStrings);
6346
6347 rilCellIdentity.cellIdentityGsm.mnc =
6348 convertResponseStringEntryToInt(response, 12, numStrings);
6349 } else {
6350 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6351 rilCellIdentity.cellIdentityGsm.mnc = 0;
6352 rilCellIdentity.cellIdentityGsm.mcc = 0;
6353 }
6354 break;
6355 }
6356 case RIL_CELL_INFO_TYPE_WCDMA: {
6357 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6358 rilCellIdentity.cellIdentityWcdma.lac =
6359 convertResponseHexStringEntryToInt(response, 1, numStrings);
6360
6361 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6362 rilCellIdentity.cellIdentityWcdma.cid =
6363 convertResponseHexStringEntryToInt(response, 2, numStrings);
6364
6365 if (numStrings >= 13) {
6366 rilCellIdentity.cellIdentityWcdma.mcc =
6367 convertResponseStringEntryToInt(response, 11, numStrings);
6368
6369 rilCellIdentity.cellIdentityWcdma.mnc =
6370 convertResponseStringEntryToInt(response, 12, numStrings);
6371 } else {
6372 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6373 rilCellIdentity.cellIdentityWcdma.mnc = 0;
6374 rilCellIdentity.cellIdentityWcdma.mcc = 0;
6375 }
6376
6377 break;
6378 }
6379 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
6380 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6381 rilCellIdentity.cellIdentityTdscdma.lac =
6382 convertResponseHexStringEntryToInt(response, 1, numStrings);
6383
6384 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6385 rilCellIdentity.cellIdentityTdscdma.cid =
6386 convertResponseHexStringEntryToInt(response, 2, numStrings);
6387
6388 if (numStrings >= 13) {
6389 rilCellIdentity.cellIdentityTdscdma.mcc =
6390 convertResponseStringEntryToInt(response, 11, numStrings);
6391
6392 rilCellIdentity.cellIdentityTdscdma.mnc =
6393 convertResponseStringEntryToInt(response, 12, numStrings);
6394 } else {
6395 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6396 rilCellIdentity.cellIdentityTdscdma.mnc = 0;
6397 rilCellIdentity.cellIdentityTdscdma.mcc = 0;
6398 }
6399 break;
6400 }
6401 case RIL_CELL_INFO_TYPE_LTE: {
6402 rilCellIdentity.cellIdentityLte.tac =
6403 convertResponseHexStringEntryToInt(response, 1, numStrings);
6404 rilCellIdentity.cellIdentityLte.ci =
6405 convertResponseHexStringEntryToInt(response, 2, numStrings);
6406
6407 if (numStrings >= 13) {
6408 rilCellIdentity.cellIdentityLte.mcc =
6409 convertResponseStringEntryToInt(response, 11, numStrings);
6410
6411 rilCellIdentity.cellIdentityLte.mnc =
6412 convertResponseStringEntryToInt(response, 12, numStrings);
6413 } else {
6414 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6415 rilCellIdentity.cellIdentityLte.mnc = 0;
6416 rilCellIdentity.cellIdentityLte.mcc = 0;
6417 }
6418 break;
6419 }
6420 // TODO add CDMA
6421 default: {
6422 break;
6423 }
6424 }
6425
6426 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
6427 }
6428
getVoiceRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6429 int radio_1_6::getVoiceRegistrationStateResponse(int slotId,
6430 int responseType, int serial, RIL_Errno e,
6431 void *response, size_t responseLen) {
6432 #if VDBG
6433 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
6434 #endif
6435
6436 if (radioService[slotId]->mRadioResponse != NULL ||
6437 radioService[slotId]->mRadioResponseV1_2 != NULL ||
6438 radioService[slotId]->mRadioResponseV1_5 != NULL ||
6439 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6440 RadioResponseInfo responseInfo = {};
6441 populateResponseInfo(responseInfo, serial, responseType, e);
6442
6443 VoiceRegStateResult voiceRegResponse = {};
6444 int numStrings = responseLen / sizeof(char *);
6445 if (response == NULL) {
6446 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
6447 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6448 } else if (s_vendorFunctions->version >= 15 &&
6449 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6450 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6451 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
6452 RegStateResultV1_6 regResponse = {};
6453 if (numStrings != 18) {
6454 RLOGE("getVoiceRegistrationStateResponse_1_6 Invalid response: NULL");
6455 if (e == RIL_E_SUCCESS) responseInfo_1_6.error =
6456 ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
6457 } else {
6458 char **resp = (char **) response;
6459 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6460 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6461 regResponse.rat = (V1_4::RadioTechnology)rat;
6462 if (rat == RADIO_TECH_EVDO_0 || rat == RADIO_TECH_EVDO_A ||
6463 rat == RADIO_TECH_EVDO_B || rat == RADIO_TECH_1xRTT ||
6464 rat == RADIO_TECH_IS95A || rat == RADIO_TECH_IS95B ||
6465 rat == RADIO_TECH_EHRPD) {
6466 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6467 Cdma2000RegistrationInfo cdmaInfo;
6468 cdmaInfo.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
6469 cdmaInfo.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
6470 cdmaInfo.systemIsInPrl = (V1_5::PrlIndicator)ATOI_NULL_HANDLED_DEF(resp[11], 0);
6471 cdmaInfo.defaultRoamingIndicator= ATOI_NULL_HANDLED_DEF(resp[12], 0);
6472 regResponse.accessTechnologySpecificInfo.cdmaInfo(cdmaInfo);
6473 } else if (rat == RADIO_TECH_NR) {
6474 // rat is NR only for NR SA
6475 V1_6::NrVopsInfo nrVopsInfo;
6476 nrVopsInfo.vopsSupported =
6477 ::android::hardware::radio::V1_6::VopsIndicator::VOPS_NOT_SUPPORTED;
6478 nrVopsInfo.emcSupported =
6479 ::android::hardware::radio::V1_6::EmcIndicator::EMC_NOT_SUPPORTED;
6480 nrVopsInfo.emfSupported =
6481 ::android::hardware::radio::V1_6::EmfIndicator::EMF_NOT_SUPPORTED;
6482 regResponse.accessTechnologySpecificInfo.ngranNrVopsInfo(nrVopsInfo);
6483
6484 } else {
6485 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6486 EutranRegistrationInfo eutranInfo;
6487 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA) {
6488 eutranInfo.lteVopsInfo.isVopsSupported = false;
6489 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6490 }
6491 eutranInfo.nrIndicators.isEndcAvailable = false;
6492 eutranInfo.nrIndicators.isDcNrRestricted = false;
6493 eutranInfo.nrIndicators.isEndcAvailable = false;
6494 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6495 }
6496 regResponse.reasonForDenial = (V1_5::RegistrationFailCause)
6497 ATOI_NULL_HANDLED_DEF(resp[13], 0);
6498 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[17]);
6499
6500 fillCellIdentityFromVoiceRegStateResponseString(regResponse.cellIdentity,
6501 numStrings, resp);
6502
6503 Return<void> retStatus =
6504 radioService[slotId]
6505 ->mRadioResponseV1_6
6506 ->getVoiceRegistrationStateResponse_1_6(
6507 responseInfo_1_6, regResponse);
6508 radioService[slotId]->checkReturnStatus(retStatus);
6509 }
6510 } else if (s_vendorFunctions->version <= 14 &&
6511 radioService[slotId]->mRadioResponseV1_5 != NULL) {
6512 RegStateResultV1_5 regResponse = {};
6513 if (numStrings != 18) {
6514 RLOGE("getVoiceRegistrationStateResponse_1_5 Invalid response: NULL");
6515 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6516 } else {
6517 char **resp = (char **) response;
6518 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6519 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6520 regResponse.rat = (V1_4::RadioTechnology)rat;
6521 if (rat == RADIO_TECH_EVDO_0 || rat == RADIO_TECH_EVDO_A ||
6522 rat == RADIO_TECH_EVDO_B || rat == RADIO_TECH_1xRTT ||
6523 rat == RADIO_TECH_IS95A || rat == RADIO_TECH_IS95B ||
6524 rat == RADIO_TECH_EHRPD) {
6525 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6526 Cdma2000RegistrationInfo cdmaInfo;
6527 cdmaInfo.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
6528 cdmaInfo.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
6529 cdmaInfo.systemIsInPrl = (V1_5::PrlIndicator)ATOI_NULL_HANDLED_DEF(resp[11], 0);
6530 cdmaInfo.defaultRoamingIndicator= ATOI_NULL_HANDLED_DEF(resp[12], 0);
6531 regResponse.accessTechnologySpecificInfo.cdmaInfo(cdmaInfo);
6532 } else {
6533 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6534 EutranRegistrationInfo eutranInfo;
6535 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA ||
6536 rat == RADIO_TECH_NR) {
6537 eutranInfo.lteVopsInfo.isVopsSupported = false;
6538 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6539 }
6540 eutranInfo.nrIndicators.isEndcAvailable = false;
6541 eutranInfo.nrIndicators.isDcNrRestricted = false;
6542 eutranInfo.nrIndicators.isEndcAvailable = false;
6543 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6544 }
6545 regResponse.reasonForDenial = (V1_5::RegistrationFailCause)
6546 ATOI_NULL_HANDLED_DEF(resp[13], 0);
6547 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[17]);
6548
6549 fillCellIdentityFromVoiceRegStateResponseString(regResponse.cellIdentity,
6550 numStrings, resp);
6551
6552 Return<void> retStatus =
6553 radioService[slotId]
6554 ->mRadioResponseV1_5
6555 ->getVoiceRegistrationStateResponse_1_5(
6556 responseInfo, regResponse);
6557 radioService[slotId]->checkReturnStatus(retStatus);
6558 }
6559 } else if (s_vendorFunctions->version <= 14 &&
6560 radioService[slotId]->mRadioResponseV1_2 != NULL) {
6561 V1_2::VoiceRegStateResult voiceRegResponse = {};
6562 int numStrings = responseLen / sizeof(char *);
6563 if (numStrings != 18) {
6564 RLOGE("getVoiceRegistrationStateResponse_1_21 Invalid response: NULL");
6565 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6566 } else {
6567 char **resp = (char **) response;
6568 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
6569 voiceRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6570 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
6571 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
6572 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
6573 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
6574 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
6575 fillCellIdentityFromVoiceRegStateResponseString_1_2(
6576 voiceRegResponse.cellIdentity, numStrings, resp);
6577 }
6578 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2->
6579 getVoiceRegistrationStateResponse_1_2(responseInfo, voiceRegResponse);
6580 radioService[slotId]->checkReturnStatus(retStatus);
6581 } else {
6582 RIL_VoiceRegistrationStateResponse *voiceRegState =
6583 (RIL_VoiceRegistrationStateResponse *)response;
6584 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
6585 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
6586 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6587 } else {
6588 voiceRegResponse.regState = (RegState) voiceRegState->regState;
6589 voiceRegResponse.rat = voiceRegState->rat;;
6590 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
6591 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
6592 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
6593 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
6594 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
6595 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
6596 voiceRegState->cellIdentity);
6597 }
6598 Return<void> retStatus =
6599 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
6600 responseInfo, voiceRegResponse);
6601 radioService[slotId]->checkReturnStatus(retStatus);
6602 }
6603
6604 } else {
6605 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
6606 slotId);
6607 }
6608 return 0;
6609 }
6610
getDataRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6611 int radio_1_6::getDataRegistrationStateResponse(int slotId, int responseType, int serial,
6612 RIL_Errno e, void* response, size_t responseLen) {
6613 #if VDBG
6614 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
6615 #endif
6616 if (radioService[slotId]->mRadioResponse != NULL ||
6617 radioService[slotId]->mRadioResponseV1_2 != NULL ||
6618 radioService[slotId]->mRadioResponseV1_5 != NULL ||
6619 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6620 RadioResponseInfo responseInfo = {};
6621 DataRegStateResult dataRegResponse = {};
6622 populateResponseInfo(responseInfo, serial, responseType, e);
6623 if (response == NULL) {
6624 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6625 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6626 } else if (s_vendorFunctions->version >= 15 &&
6627 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6628 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6629 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
6630 RegStateResultV1_6 regResponse = {};
6631 int numStrings = responseLen / sizeof(char *);
6632 if ((numStrings != 6) && (numStrings != 11) && (numStrings != 14)) {
6633 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6634 if (e == RIL_E_SUCCESS) responseInfo_1_6.error =
6635 ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
6636 } else {
6637 char **resp = (char **) response;
6638 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6639 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6640 regResponse.rat = (V1_4::RadioTechnology)rat;
6641 regResponse.reasonForDenial =
6642 (V1_5::RegistrationFailCause)ATOI_NULL_HANDLED(resp[4]);
6643 if (numStrings > 13) {
6644 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[13]);
6645 }
6646
6647 fillCellIdentityFromDataRegStateResponseString_1_5(regResponse.cellIdentity,
6648 numStrings, resp);
6649 if (rat == RADIO_TECH_NR) {
6650 // rat is NR only for NR SA
6651 V1_6::NrVopsInfo nrVopsInfo;
6652 nrVopsInfo.vopsSupported =
6653 ::android::hardware::radio::V1_6::VopsIndicator::VOPS_NOT_SUPPORTED;
6654 nrVopsInfo.emcSupported =
6655 ::android::hardware::radio::V1_6::EmcIndicator::EMC_NOT_SUPPORTED;
6656 nrVopsInfo.emfSupported =
6657 ::android::hardware::radio::V1_6::EmfIndicator::EMF_NOT_SUPPORTED;
6658 regResponse.accessTechnologySpecificInfo.ngranNrVopsInfo(nrVopsInfo);
6659
6660 } else {
6661 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6662 EutranRegistrationInfo eutranInfo;
6663 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA) {
6664 eutranInfo.lteVopsInfo.isVopsSupported = false;
6665 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6666 }
6667 eutranInfo.nrIndicators.isEndcAvailable = false;
6668 eutranInfo.nrIndicators.isDcNrRestricted = false;
6669 eutranInfo.nrIndicators.isEndcAvailable = false;
6670 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6671 }
6672
6673 Return<void> retStatus =
6674 radioService[slotId]
6675 ->mRadioResponseV1_6->getDataRegistrationStateResponse_1_6(
6676 responseInfo_1_6, regResponse);
6677 radioService[slotId]->checkReturnStatus(retStatus);
6678 return 0;
6679 }
6680 } else if (s_vendorFunctions->version <= 14 &&
6681 radioService[slotId]->mRadioResponseV1_5 != NULL) {
6682 RegStateResultV1_5 regResponse = {};
6683 int numStrings = responseLen / sizeof(char *);
6684 if ((numStrings != 6) && (numStrings != 11) && (numStrings != 14)) {
6685 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6686 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6687 } else {
6688 char **resp = (char **) response;
6689 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6690 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6691 regResponse.rat = (V1_4::RadioTechnology)rat;
6692 regResponse.reasonForDenial =
6693 (V1_5::RegistrationFailCause)ATOI_NULL_HANDLED(resp[4]);
6694 if (numStrings > 13) {
6695 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[13]);
6696 }
6697
6698 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6699 EutranRegistrationInfo eutranInfo;
6700 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA ||
6701 rat == RADIO_TECH_NR) {
6702 eutranInfo.lteVopsInfo.isVopsSupported = false;
6703 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6704 }
6705 eutranInfo.nrIndicators.isEndcAvailable = false;
6706 eutranInfo.nrIndicators.isDcNrRestricted = false;
6707 eutranInfo.nrIndicators.isEndcAvailable = false;
6708 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6709
6710 fillCellIdentityFromDataRegStateResponseString_1_5(regResponse.cellIdentity,
6711 numStrings, resp);
6712
6713 Return<void> retStatus =
6714 radioService[slotId]
6715 ->mRadioResponseV1_5->getDataRegistrationStateResponse_1_5(
6716 responseInfo, regResponse);
6717 radioService[slotId]->checkReturnStatus(retStatus);
6718 return 0;
6719 }
6720 } else if (s_vendorFunctions->version <= 14 &&
6721 radioService[slotId]->mRadioResponseV1_2 != NULL) {
6722 V1_2::DataRegStateResult dataRegResponse = {};
6723 int numStrings = responseLen / sizeof(char *);
6724 if ((numStrings != 11) && (numStrings != 13) && (numStrings != 14)) {
6725 RLOGE("getDataRegistrationStateResponse_1_2 Invalid response: NULL");
6726 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6727 } else {
6728 char **resp = (char **)response;
6729 dataRegResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6730 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6731 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
6732 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
6733 fillCellIdentityFromDataRegStateResponseString_1_2(dataRegResponse.cellIdentity,
6734 numStrings, resp);
6735 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2->
6736 getDataRegistrationStateResponse_1_2(responseInfo, dataRegResponse);
6737 radioService[slotId]->checkReturnStatus(retStatus);
6738 return 0;
6739 }
6740 } else if (s_vendorFunctions->version <= 14) {
6741 int numStrings = responseLen / sizeof(char *);
6742 if ((numStrings != 11) && (numStrings != 13) && (numStrings != 14)) {
6743 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6744 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6745 } else {
6746 char **resp = (char **) response;
6747 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
6748 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6749 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
6750 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
6751 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
6752 numStrings, resp);
6753 }
6754 } else {
6755 RIL_DataRegistrationStateResponse *dataRegState =
6756 (RIL_DataRegistrationStateResponse *)response;
6757
6758 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
6759 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6760 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6761 } else {
6762 dataRegResponse.regState = (RegState) dataRegState->regState;
6763 dataRegResponse.rat = dataRegState->rat;
6764 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
6765 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
6766 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
6767 }
6768 }
6769
6770 Return<void> retStatus =
6771 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(
6772 responseInfo, dataRegResponse);
6773 radioService[slotId]->checkReturnStatus(retStatus);
6774 } else {
6775 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
6776 slotId);
6777 }
6778
6779 return 0;
6780 }
6781
getOperatorResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6782 int radio_1_6::getOperatorResponse(int slotId,
6783 int responseType, int serial, RIL_Errno e, void *response,
6784 size_t responseLen) {
6785 #if VDBG
6786 RLOGD("getOperatorResponse: serial %d", serial);
6787 #endif
6788
6789 if (radioService[slotId]->mRadioResponse != NULL) {
6790 RadioResponseInfo responseInfo = {};
6791 populateResponseInfo(responseInfo, serial, responseType, e);
6792 hidl_string longName;
6793 hidl_string shortName;
6794 hidl_string numeric;
6795 int numStrings = responseLen / sizeof(char *);
6796 if (response == NULL || numStrings != 3) {
6797 RLOGE("getOperatorResponse Invalid response: NULL");
6798 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6799
6800 } else {
6801 char **resp = (char **) response;
6802 longName = convertCharPtrToHidlString(resp[0]);
6803 shortName = convertCharPtrToHidlString(resp[1]);
6804 numeric = convertCharPtrToHidlString(resp[2]);
6805 }
6806 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
6807 responseInfo, longName, shortName, numeric);
6808 radioService[slotId]->checkReturnStatus(retStatus);
6809 } else {
6810 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
6811 slotId);
6812 }
6813
6814 return 0;
6815 }
6816
setRadioPowerResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6817 int radio_1_6::setRadioPowerResponse(int slotId,
6818 int responseType, int serial, RIL_Errno e, void *response,
6819 size_t responseLen) {
6820 #if VDBG
6821 RLOGD("setRadioPowerResponse: serial %d", serial);
6822 #endif
6823 RadioResponseInfo responseInfo = {};
6824 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6825 populateResponseInfo(responseInfo, serial, responseType, e);
6826 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
6827
6828 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
6829 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
6830 ->setRadioPowerResponse_1_6(responseInfo_1_6);
6831 radioService[slotId]->checkReturnStatus(retStatus);
6832 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
6833 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
6834 ->setRadioPowerResponse_1_5(responseInfo);
6835 radioService[slotId]->checkReturnStatus(retStatus);
6836 } else if (radioService[slotId]->mRadioResponse != NULL) {
6837 Return<void> retStatus = radioService[slotId]->mRadioResponse
6838 ->setRadioPowerResponse(responseInfo);
6839 radioService[slotId]->checkReturnStatus(retStatus);
6840 } else {
6841 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6842 }
6843
6844 return 0;
6845 }
6846
sendDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6847 int radio_1_6::sendDtmfResponse(int slotId,
6848 int responseType, int serial, RIL_Errno e, void *response,
6849 size_t responseLen) {
6850 #if VDBG
6851 RLOGD("sendDtmfResponse: serial %d", serial);
6852 #endif
6853
6854 if (radioService[slotId]->mRadioResponse != NULL) {
6855 RadioResponseInfo responseInfo = {};
6856 populateResponseInfo(responseInfo, serial, responseType, e);
6857 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
6858 responseInfo);
6859 radioService[slotId]->checkReturnStatus(retStatus);
6860 } else {
6861 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
6862 slotId);
6863 }
6864
6865 return 0;
6866 }
6867
makeSendSmsResult(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)6868 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
6869 RIL_Errno e, void *response, size_t responseLen) {
6870 populateResponseInfo(responseInfo, serial, responseType, e);
6871 SendSmsResult result = {};
6872
6873 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
6874 RLOGE("Invalid response: NULL");
6875 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6876 result.ackPDU = hidl_string();
6877 } else {
6878 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
6879 result.messageRef = resp->messageRef;
6880 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
6881 result.errorCode = resp->errorCode;
6882 }
6883 return result;
6884 }
6885
makeSendSmsResult_1_6(::android::hardware::radio::V1_6::RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)6886 SendSmsResult makeSendSmsResult_1_6(
6887 ::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo, int serial,
6888 int responseType, RIL_Errno e, void *response, size_t responseLen) {
6889 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
6890 SendSmsResult result = {};
6891
6892 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
6893 RLOGE("Invalid response: NULL");
6894 if (e == RIL_E_SUCCESS) {
6895 responseInfo.error = ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
6896 }
6897 result.ackPDU = hidl_string();
6898 } else {
6899 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
6900 result.messageRef = resp->messageRef;
6901 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
6902 result.errorCode = resp->errorCode;
6903 }
6904 return result;
6905 }
6906
sendSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6907 int radio_1_6::sendSmsResponse(int slotId,
6908 int responseType, int serial, RIL_Errno e, void *response,
6909 size_t responseLen) {
6910 #if VDBG
6911 RLOGD("sendSmsResponse: serial %d", serial);
6912 #endif
6913
6914 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
6915 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6916 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e, response,
6917 responseLen);
6918
6919 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
6920 ->sendSmsResponse_1_6(responseInfo_1_6, result);
6921 radioService[slotId]->checkReturnStatus(retStatus);
6922 } else if (radioService[slotId]->mRadioResponse != NULL) {
6923 RadioResponseInfo responseInfo = {};
6924 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
6925 responseLen);
6926
6927 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
6928 result);
6929 radioService[slotId]->checkReturnStatus(retStatus);
6930 } else {
6931 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6932 }
6933
6934 return 0;
6935 }
6936
sendSmsExpectMoreResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6937 int radio_1_6::sendSmsExpectMoreResponse(int slotId,
6938 int responseType, int serial, RIL_Errno e, void *response,
6939 size_t responseLen) {
6940 #if VDBG
6941 RLOGD("sendSmsExpectMoreResponse: serial %d", serial);
6942 #endif
6943
6944 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
6945 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6946 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e, response,
6947 responseLen);
6948
6949 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
6950 ->sendSmsExpectMoreResponse_1_6(responseInfo_1_6, result);
6951 radioService[slotId]->checkReturnStatus(retStatus);
6952 } else if (radioService[slotId]->mRadioResponse != NULL) {
6953 RadioResponseInfo responseInfo = {};
6954 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
6955 responseLen);
6956
6957 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
6958 responseInfo, result);
6959 radioService[slotId]->checkReturnStatus(retStatus);
6960 } else {
6961 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6962 }
6963
6964 return 0;
6965 }
6966
setupDataCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6967 int radio_1_6::setupDataCallResponse(int slotId,
6968 int responseType, int serial, RIL_Errno e, void *response,
6969 size_t responseLen) {
6970 #if VDBG
6971 RLOGD("setupDataCallResponse: serial %d", serial);
6972 #endif
6973 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
6974 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6975 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
6976 ::android::hardware::radio::V1_6::SetupDataCallResult result;
6977 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
6978 if (response != NULL) {
6979 RLOGE("setupDataCallResponse_1_6: Invalid response");
6980 if (e == RIL_E_SUCCESS) responseInfo_1_6.error =
6981 ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
6982 }
6983 result.cause = ::android::hardware::radio::V1_6::DataCallFailCause::ERROR_UNSPECIFIED;
6984 result.type = ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
6985 result.ifname = hidl_string();
6986 result.addresses = hidl_vec<::android::hardware::radio::V1_5::LinkAddress>();
6987 result.dnses = hidl_vec<hidl_string>();
6988 result.gateways = hidl_vec<hidl_string>();
6989 result.pcscf = hidl_vec<hidl_string>();
6990 result.trafficDescriptors =
6991 hidl_vec<::android::hardware::radio::V1_6::TrafficDescriptor>();
6992 } else {
6993 convertRilDataCallToHal((RIL_Data_Call_Response_v11*)response, result);
6994 }
6995
6996 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6->setupDataCallResponse_1_6(
6997 responseInfo_1_6, result);
6998 radioService[slotId]->checkReturnStatus(retStatus);
6999 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7000 RadioResponseInfo responseInfo = {};
7001 populateResponseInfo(responseInfo, serial, responseType, e);
7002 ::android::hardware::radio::V1_5::SetupDataCallResult result;
7003 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
7004 if (response != NULL) {
7005 RLOGE("setupDataCallResponse_1_5: Invalid response");
7006 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7007 }
7008 result.cause = ::android::hardware::radio::V1_4::DataCallFailCause::ERROR_UNSPECIFIED;
7009 result.type = ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
7010 result.ifname = hidl_string();
7011 result.addresses = hidl_vec<::android::hardware::radio::V1_5::LinkAddress>();
7012 result.dnses = hidl_vec<hidl_string>();
7013 result.gateways = hidl_vec<hidl_string>();
7014 result.pcscf = hidl_vec<hidl_string>();
7015 } else {
7016 convertRilDataCallToHal((RIL_Data_Call_Response_v11*)response, result);
7017 }
7018
7019 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5->setupDataCallResponse_1_5(
7020 responseInfo, result);
7021 radioService[slotId]->checkReturnStatus(retStatus);
7022 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7023 RadioResponseInfo responseInfo = {};
7024 populateResponseInfo(responseInfo, serial, responseType, e);
7025 ::android::hardware::radio::V1_4::SetupDataCallResult result;
7026 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
7027 if (response != NULL) {
7028 RLOGE("setupDataCallResponse_1_4: Invalid response");
7029 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7030 }
7031 result.cause = ::android::hardware::radio::V1_4::DataCallFailCause::ERROR_UNSPECIFIED;
7032 result.type = ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
7033 result.ifname = hidl_string();
7034 result.addresses = hidl_vec<hidl_string>();
7035 result.dnses = hidl_vec<hidl_string>();
7036 result.gateways = hidl_vec<hidl_string>();
7037 result.pcscf = hidl_vec<hidl_string>();
7038 } else {
7039 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
7040 }
7041
7042 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4->setupDataCallResponse_1_4(
7043 responseInfo, result);
7044 radioService[slotId]->checkReturnStatus(retStatus);
7045 } else if (radioService[slotId]->mRadioResponse != NULL) {
7046 RadioResponseInfo responseInfo = {};
7047 populateResponseInfo(responseInfo, serial, responseType, e);
7048
7049 SetupDataCallResult result = {};
7050 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
7051 if (response != NULL) {
7052 RLOGE("setupDataCallResponse: Invalid response");
7053 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7054 }
7055 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
7056 result.type = hidl_string();
7057 result.ifname = hidl_string();
7058 result.addresses = hidl_string();
7059 result.dnses = hidl_string();
7060 result.gateways = hidl_string();
7061 result.pcscf = hidl_string();
7062 } else {
7063 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
7064 }
7065
7066 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
7067 responseInfo, result);
7068 radioService[slotId]->checkReturnStatus(retStatus);
7069 } else {
7070 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7071 }
7072
7073 return 0;
7074 }
7075
responseIccIo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)7076 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
7077 RIL_Errno e, void *response, size_t responseLen) {
7078 populateResponseInfo(responseInfo, serial, responseType, e);
7079 IccIoResult result = {};
7080
7081 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
7082 RLOGE("Invalid response: NULL");
7083 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7084 result.simResponse = hidl_string();
7085 } else {
7086 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
7087 result.sw1 = resp->sw1;
7088 result.sw2 = resp->sw2;
7089 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
7090 }
7091 return result;
7092 }
7093
iccIOForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7094 int radio_1_6::iccIOForAppResponse(int slotId,
7095 int responseType, int serial, RIL_Errno e, void *response,
7096 size_t responseLen) {
7097 #if VDBG
7098 RLOGD("iccIOForAppResponse: serial %d", serial);
7099 #endif
7100
7101 if (radioService[slotId]->mRadioResponse != NULL) {
7102 RadioResponseInfo responseInfo = {};
7103 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
7104 responseLen);
7105
7106 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
7107 responseInfo, result);
7108 radioService[slotId]->checkReturnStatus(retStatus);
7109 } else {
7110 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7111 }
7112
7113 return 0;
7114 }
7115
sendUssdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7116 int radio_1_6::sendUssdResponse(int slotId,
7117 int responseType, int serial, RIL_Errno e, void *response,
7118 size_t responseLen) {
7119 #if VDBG
7120 RLOGD("sendUssdResponse: serial %d", serial);
7121 #endif
7122
7123 if (radioService[slotId]->mRadioResponse != NULL) {
7124 RadioResponseInfo responseInfo = {};
7125 populateResponseInfo(responseInfo, serial, responseType, e);
7126 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
7127 responseInfo);
7128 radioService[slotId]->checkReturnStatus(retStatus);
7129 } else {
7130 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
7131 slotId);
7132 }
7133
7134 return 0;
7135 }
7136
cancelPendingUssdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7137 int radio_1_6::cancelPendingUssdResponse(int slotId,
7138 int responseType, int serial, RIL_Errno e, void *response,
7139 size_t responseLen) {
7140 #if VDBG
7141 RLOGD("cancelPendingUssdResponse: serial %d", serial);
7142 #endif
7143
7144 if (radioService[slotId]->mRadioResponse != NULL) {
7145 RadioResponseInfo responseInfo = {};
7146 populateResponseInfo(responseInfo, serial, responseType, e);
7147 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
7148 responseInfo);
7149 radioService[slotId]->checkReturnStatus(retStatus);
7150 } else {
7151 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
7152 slotId);
7153 }
7154
7155 return 0;
7156 }
7157
getClirResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7158 int radio_1_6::getClirResponse(int slotId,
7159 int responseType, int serial, RIL_Errno e, void *response,
7160 size_t responseLen) {
7161 #if VDBG
7162 RLOGD("getClirResponse: serial %d", serial);
7163 #endif
7164
7165 if (radioService[slotId]->mRadioResponse != NULL) {
7166 RadioResponseInfo responseInfo = {};
7167 populateResponseInfo(responseInfo, serial, responseType, e);
7168 int n = -1, m = -1;
7169 int numInts = responseLen / sizeof(int);
7170 if (response == NULL || numInts != 2) {
7171 RLOGE("getClirResponse Invalid response: NULL");
7172 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7173 } else {
7174 int *pInt = (int *) response;
7175 n = pInt[0];
7176 m = pInt[1];
7177 }
7178 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
7179 n, m);
7180 radioService[slotId]->checkReturnStatus(retStatus);
7181 } else {
7182 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7183 }
7184
7185 return 0;
7186 }
7187
setClirResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7188 int radio_1_6::setClirResponse(int slotId,
7189 int responseType, int serial, RIL_Errno e, void *response,
7190 size_t responseLen) {
7191 #if VDBG
7192 RLOGD("setClirResponse: serial %d", serial);
7193 #endif
7194
7195 if (radioService[slotId]->mRadioResponse != NULL) {
7196 RadioResponseInfo responseInfo = {};
7197 populateResponseInfo(responseInfo, serial, responseType, e);
7198 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
7199 responseInfo);
7200 radioService[slotId]->checkReturnStatus(retStatus);
7201 } else {
7202 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7203 }
7204
7205 return 0;
7206 }
7207
getCallForwardStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7208 int radio_1_6::getCallForwardStatusResponse(int slotId,
7209 int responseType, int serial, RIL_Errno e,
7210 void *response, size_t responseLen) {
7211 #if VDBG
7212 RLOGD("getCallForwardStatusResponse: serial %d", serial);
7213 #endif
7214
7215 if (radioService[slotId]->mRadioResponse != NULL) {
7216 RadioResponseInfo responseInfo = {};
7217 populateResponseInfo(responseInfo, serial, responseType, e);
7218 hidl_vec<CallForwardInfo> callForwardInfos;
7219
7220 if ((response == NULL && responseLen != 0)
7221 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
7222 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
7223 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7224 } else {
7225 int num = responseLen / sizeof(RIL_CallForwardInfo *);
7226 callForwardInfos.resize(num);
7227 for (int i = 0 ; i < num; i++) {
7228 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
7229 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
7230 callForwardInfos[i].reason = resp->reason;
7231 callForwardInfos[i].serviceClass = resp->serviceClass;
7232 callForwardInfos[i].toa = resp->toa;
7233 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
7234 callForwardInfos[i].timeSeconds = resp->timeSeconds;
7235 }
7236 }
7237
7238 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
7239 responseInfo, callForwardInfos);
7240 radioService[slotId]->checkReturnStatus(retStatus);
7241 } else {
7242 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
7243 slotId);
7244 }
7245
7246 return 0;
7247 }
7248
setCallForwardResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7249 int radio_1_6::setCallForwardResponse(int slotId,
7250 int responseType, int serial, RIL_Errno e, void *response,
7251 size_t responseLen) {
7252 #if VDBG
7253 RLOGD("setCallForwardResponse: serial %d", serial);
7254 #endif
7255
7256 if (radioService[slotId]->mRadioResponse != NULL) {
7257 RadioResponseInfo responseInfo = {};
7258 populateResponseInfo(responseInfo, serial, responseType, e);
7259 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
7260 responseInfo);
7261 radioService[slotId]->checkReturnStatus(retStatus);
7262 } else {
7263 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7264 }
7265
7266 return 0;
7267 }
7268
getCallWaitingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7269 int radio_1_6::getCallWaitingResponse(int slotId,
7270 int responseType, int serial, RIL_Errno e, void *response,
7271 size_t responseLen) {
7272 #if VDBG
7273 RLOGD("getCallWaitingResponse: serial %d", serial);
7274 #endif
7275
7276 if (radioService[slotId]->mRadioResponse != NULL) {
7277 RadioResponseInfo responseInfo = {};
7278 populateResponseInfo(responseInfo, serial, responseType, e);
7279 bool enable = false;
7280 int serviceClass = -1;
7281 int numInts = responseLen / sizeof(int);
7282 if (response == NULL || numInts != 2) {
7283 RLOGE("getCallWaitingResponse Invalid response: NULL");
7284 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7285 } else {
7286 int *pInt = (int *) response;
7287 enable = pInt[0] == 1 ? true : false;
7288 serviceClass = pInt[1];
7289 }
7290 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
7291 responseInfo, enable, serviceClass);
7292 radioService[slotId]->checkReturnStatus(retStatus);
7293 } else {
7294 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7295 }
7296
7297 return 0;
7298 }
7299
setCallWaitingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7300 int radio_1_6::setCallWaitingResponse(int slotId,
7301 int responseType, int serial, RIL_Errno e, void *response,
7302 size_t responseLen) {
7303 #if VDBG
7304 RLOGD("setCallWaitingResponse: serial %d", serial);
7305 #endif
7306
7307 if (radioService[slotId]->mRadioResponse != NULL) {
7308 RadioResponseInfo responseInfo = {};
7309 populateResponseInfo(responseInfo, serial, responseType, e);
7310 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
7311 responseInfo);
7312 radioService[slotId]->checkReturnStatus(retStatus);
7313 } else {
7314 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7315 }
7316
7317 return 0;
7318 }
7319
acknowledgeLastIncomingGsmSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7320 int radio_1_6::acknowledgeLastIncomingGsmSmsResponse(int slotId,
7321 int responseType, int serial, RIL_Errno e,
7322 void *response, size_t responseLen) {
7323 #if VDBG
7324 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
7325 #endif
7326
7327 if (radioService[slotId]->mRadioResponse != NULL) {
7328 RadioResponseInfo responseInfo = {};
7329 populateResponseInfo(responseInfo, serial, responseType, e);
7330 Return<void> retStatus =
7331 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
7332 responseInfo);
7333 radioService[slotId]->checkReturnStatus(retStatus);
7334 } else {
7335 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
7336 "== NULL", slotId);
7337 }
7338
7339 return 0;
7340 }
7341
acceptCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7342 int radio_1_6::acceptCallResponse(int slotId,
7343 int responseType, int serial, RIL_Errno e,
7344 void *response, size_t responseLen) {
7345 #if VDBG
7346 RLOGD("acceptCallResponse: serial %d", serial);
7347 #endif
7348
7349 if (radioService[slotId]->mRadioResponse != NULL) {
7350 RadioResponseInfo responseInfo = {};
7351 populateResponseInfo(responseInfo, serial, responseType, e);
7352 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
7353 responseInfo);
7354 radioService[slotId]->checkReturnStatus(retStatus);
7355 } else {
7356 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
7357 slotId);
7358 }
7359
7360 return 0;
7361 }
7362
deactivateDataCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7363 int radio_1_6::deactivateDataCallResponse(int slotId,
7364 int responseType, int serial, RIL_Errno e,
7365 void *response, size_t responseLen) {
7366 #if VDBG
7367 RLOGD("deactivateDataCallResponse: serial %d", serial);
7368 #endif
7369
7370 if (radioService[slotId]->mRadioResponse != NULL) {
7371 RadioResponseInfo responseInfo = {};
7372 populateResponseInfo(responseInfo, serial, responseType, e);
7373 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
7374 responseInfo);
7375 radioService[slotId]->checkReturnStatus(retStatus);
7376 } else {
7377 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
7378 slotId);
7379 }
7380
7381 return 0;
7382 }
7383
getFacilityLockForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7384 int radio_1_6::getFacilityLockForAppResponse(int slotId,
7385 int responseType, int serial, RIL_Errno e,
7386 void *response, size_t responseLen) {
7387 #if VDBG
7388 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
7389 #endif
7390
7391 if (radioService[slotId]->mRadioResponse != NULL) {
7392 RadioResponseInfo responseInfo = {};
7393 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
7394 Return<void> retStatus = radioService[slotId]->mRadioResponse->
7395 getFacilityLockForAppResponse(responseInfo, ret);
7396 radioService[slotId]->checkReturnStatus(retStatus);
7397 } else {
7398 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
7399 slotId);
7400 }
7401
7402 return 0;
7403 }
7404
setFacilityLockForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7405 int radio_1_6::setFacilityLockForAppResponse(int slotId,
7406 int responseType, int serial, RIL_Errno e,
7407 void *response, size_t responseLen) {
7408 #if VDBG
7409 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
7410 #endif
7411
7412 if (radioService[slotId]->mRadioResponse != NULL) {
7413 RadioResponseInfo responseInfo = {};
7414 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
7415 Return<void> retStatus
7416 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
7417 ret);
7418 radioService[slotId]->checkReturnStatus(retStatus);
7419 } else {
7420 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
7421 slotId);
7422 }
7423
7424 return 0;
7425 }
7426
setBarringPasswordResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7427 int radio_1_6::setBarringPasswordResponse(int slotId,
7428 int responseType, int serial, RIL_Errno e,
7429 void *response, size_t responseLen) {
7430 #if VDBG
7431 RLOGD("acceptCallResponse: serial %d", serial);
7432 #endif
7433
7434 if (radioService[slotId]->mRadioResponse != NULL) {
7435 RadioResponseInfo responseInfo = {};
7436 populateResponseInfo(responseInfo, serial, responseType, e);
7437 Return<void> retStatus
7438 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
7439 radioService[slotId]->checkReturnStatus(retStatus);
7440 } else {
7441 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
7442 slotId);
7443 }
7444
7445 return 0;
7446 }
7447
getNetworkSelectionModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7448 int radio_1_6::getNetworkSelectionModeResponse(int slotId,
7449 int responseType, int serial, RIL_Errno e, void *response,
7450 size_t responseLen) {
7451 #if VDBG
7452 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
7453 #endif
7454
7455 if (radioService[slotId]->mRadioResponse != NULL) {
7456 RadioResponseInfo responseInfo = {};
7457 populateResponseInfo(responseInfo, serial, responseType, e);
7458 bool manual = false;
7459 if (response == NULL || responseLen != sizeof(int)) {
7460 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
7461 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7462 } else {
7463 int *pInt = (int *) response;
7464 manual = pInt[0] == 1 ? true : false;
7465 }
7466 Return<void> retStatus
7467 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
7468 responseInfo,
7469 manual);
7470 radioService[slotId]->checkReturnStatus(retStatus);
7471 } else {
7472 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
7473 slotId);
7474 }
7475
7476 return 0;
7477 }
7478
setNetworkSelectionModeAutomaticResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7479 int radio_1_6::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
7480 RIL_Errno e, void *response,
7481 size_t responseLen) {
7482 #if VDBG
7483 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
7484 #endif
7485
7486 if (radioService[slotId]->mRadioResponse != NULL) {
7487 RadioResponseInfo responseInfo = {};
7488 populateResponseInfo(responseInfo, serial, responseType, e);
7489 Return<void> retStatus
7490 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
7491 responseInfo);
7492 radioService[slotId]->checkReturnStatus(retStatus);
7493 } else {
7494 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
7495 "== NULL", slotId);
7496 }
7497
7498 return 0;
7499 }
7500
setNetworkSelectionModeManualResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7501 int radio_1_6::setNetworkSelectionModeManualResponse(int slotId,
7502 int responseType, int serial, RIL_Errno e,
7503 void *response, size_t responseLen) {
7504 #if VDBG
7505 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
7506 #endif
7507 RadioResponseInfo responseInfo = {};
7508 populateResponseInfo(responseInfo, serial, responseType, e);
7509
7510 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7511 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
7512 ->setNetworkSelectionModeManualResponse_1_5(responseInfo);
7513 radioService[slotId]->checkReturnStatus(retStatus);
7514 } else if (radioService[slotId]->mRadioResponse != NULL) {
7515 Return<void> retStatus = radioService[slotId]->mRadioResponse
7516 ->setNetworkSelectionModeManualResponse(responseInfo);
7517 radioService[slotId]->checkReturnStatus(retStatus);
7518 } else {
7519 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
7520 "== NULL", slotId);
7521 }
7522
7523 return 0;
7524 }
7525
convertOperatorStatusToInt(const char * str)7526 int convertOperatorStatusToInt(const char *str) {
7527 if (strncmp("unknown", str, 9) == 0) {
7528 return (int) OperatorStatus::UNKNOWN;
7529 } else if (strncmp("available", str, 9) == 0) {
7530 return (int) OperatorStatus::AVAILABLE;
7531 } else if (strncmp("current", str, 9) == 0) {
7532 return (int) OperatorStatus::CURRENT;
7533 } else if (strncmp("forbidden", str, 9) == 0) {
7534 return (int) OperatorStatus::FORBIDDEN;
7535 } else {
7536 return -1;
7537 }
7538 }
7539
getAvailableNetworksResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7540 int radio_1_6::getAvailableNetworksResponse(int slotId,
7541 int responseType, int serial, RIL_Errno e, void *response,
7542 size_t responseLen) {
7543 #if VDBG
7544 RLOGD("getAvailableNetworksResponse: serial %d", serial);
7545 #endif
7546
7547 if (radioService[slotId]->mRadioResponse != NULL) {
7548 RadioResponseInfo responseInfo = {};
7549 populateResponseInfo(responseInfo, serial, responseType, e);
7550 hidl_vec<OperatorInfo> networks;
7551 if ((response == NULL && responseLen != 0)
7552 || responseLen % (4 * sizeof(char *))!= 0) {
7553 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
7554 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7555 } else {
7556 char **resp = (char **) response;
7557 int numStrings = responseLen / sizeof(char *);
7558 networks.resize(numStrings/4);
7559 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
7560 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
7561 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
7562 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
7563 int status = convertOperatorStatusToInt(resp[i + 3]);
7564 if (status == -1) {
7565 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7566 } else {
7567 networks[j].status = (OperatorStatus) status;
7568 }
7569 }
7570 }
7571 Return<void> retStatus
7572 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
7573 networks);
7574 radioService[slotId]->checkReturnStatus(retStatus);
7575 } else {
7576 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
7577 slotId);
7578 }
7579
7580 return 0;
7581 }
7582
startDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7583 int radio_1_6::startDtmfResponse(int slotId,
7584 int responseType, int serial, RIL_Errno e,
7585 void *response, size_t responseLen) {
7586 #if VDBG
7587 RLOGD("startDtmfResponse: serial %d", serial);
7588 #endif
7589
7590 if (radioService[slotId]->mRadioResponse != NULL) {
7591 RadioResponseInfo responseInfo = {};
7592 populateResponseInfo(responseInfo, serial, responseType, e);
7593 Return<void> retStatus
7594 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
7595 radioService[slotId]->checkReturnStatus(retStatus);
7596 } else {
7597 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7598 }
7599
7600 return 0;
7601 }
7602
stopDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7603 int radio_1_6::stopDtmfResponse(int slotId,
7604 int responseType, int serial, RIL_Errno e,
7605 void *response, size_t responseLen) {
7606 #if VDBG
7607 RLOGD("stopDtmfResponse: serial %d", serial);
7608 #endif
7609
7610 if (radioService[slotId]->mRadioResponse != NULL) {
7611 RadioResponseInfo responseInfo = {};
7612 populateResponseInfo(responseInfo, serial, responseType, e);
7613 Return<void> retStatus
7614 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
7615 radioService[slotId]->checkReturnStatus(retStatus);
7616 } else {
7617 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7618 }
7619
7620 return 0;
7621 }
7622
getBasebandVersionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7623 int radio_1_6::getBasebandVersionResponse(int slotId,
7624 int responseType, int serial, RIL_Errno e,
7625 void *response, size_t responseLen) {
7626 #if VDBG
7627 RLOGD("getBasebandVersionResponse: serial %d", serial);
7628 #endif
7629
7630 if (radioService[slotId]->mRadioResponse != NULL) {
7631 RadioResponseInfo responseInfo = {};
7632 populateResponseInfo(responseInfo, serial, responseType, e);
7633 Return<void> retStatus
7634 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
7635 convertCharPtrToHidlString((char *) response));
7636 radioService[slotId]->checkReturnStatus(retStatus);
7637 } else {
7638 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7639 }
7640
7641 return 0;
7642 }
7643
separateConnectionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7644 int radio_1_6::separateConnectionResponse(int slotId,
7645 int responseType, int serial, RIL_Errno e,
7646 void *response, size_t responseLen) {
7647 #if VDBG
7648 RLOGD("separateConnectionResponse: serial %d", serial);
7649 #endif
7650
7651 if (radioService[slotId]->mRadioResponse != NULL) {
7652 RadioResponseInfo responseInfo = {};
7653 populateResponseInfo(responseInfo, serial, responseType, e);
7654 Return<void> retStatus
7655 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
7656 radioService[slotId]->checkReturnStatus(retStatus);
7657 } else {
7658 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
7659 slotId);
7660 }
7661
7662 return 0;
7663 }
7664
setMuteResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7665 int radio_1_6::setMuteResponse(int slotId,
7666 int responseType, int serial, RIL_Errno e,
7667 void *response, size_t responseLen) {
7668 #if VDBG
7669 RLOGD("setMuteResponse: serial %d", serial);
7670 #endif
7671
7672 if (radioService[slotId]->mRadioResponse != NULL) {
7673 RadioResponseInfo responseInfo = {};
7674 populateResponseInfo(responseInfo, serial, responseType, e);
7675 Return<void> retStatus
7676 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
7677 radioService[slotId]->checkReturnStatus(retStatus);
7678 } else {
7679 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7680 }
7681
7682 return 0;
7683 }
7684
getMuteResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7685 int radio_1_6::getMuteResponse(int slotId,
7686 int responseType, int serial, RIL_Errno e, void *response,
7687 size_t responseLen) {
7688 #if VDBG
7689 RLOGD("getMuteResponse: serial %d", serial);
7690 #endif
7691
7692 if (radioService[slotId]->mRadioResponse != NULL) {
7693 RadioResponseInfo responseInfo = {};
7694 populateResponseInfo(responseInfo, serial, responseType, e);
7695 bool enable = false;
7696 if (response == NULL || responseLen != sizeof(int)) {
7697 RLOGE("getMuteResponse Invalid response: NULL");
7698 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7699 } else {
7700 int *pInt = (int *) response;
7701 enable = pInt[0] == 1 ? true : false;
7702 }
7703 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
7704 enable);
7705 radioService[slotId]->checkReturnStatus(retStatus);
7706 } else {
7707 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7708 }
7709
7710 return 0;
7711 }
7712
getClipResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7713 int radio_1_6::getClipResponse(int slotId,
7714 int responseType, int serial, RIL_Errno e,
7715 void *response, size_t responseLen) {
7716 #if VDBG
7717 RLOGD("getClipResponse: serial %d", serial);
7718 #endif
7719
7720 if (radioService[slotId]->mRadioResponse != NULL) {
7721 RadioResponseInfo responseInfo = {};
7722 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
7723 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
7724 (ClipStatus) ret);
7725 radioService[slotId]->checkReturnStatus(retStatus);
7726 } else {
7727 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7728 }
7729
7730 return 0;
7731 }
7732
getDataCallListResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7733 int radio_1_6::getDataCallListResponse(int slotId, int responseType, int serial, RIL_Errno e,
7734 void* response, size_t responseLen) {
7735 #if VDBG
7736 RLOGD("getDataCallListResponse: serial %d", serial);
7737 #endif
7738
7739 if (radioService[slotId]->mRadioResponse != NULL ||
7740 radioService[slotId]->mRadioResponseV1_4 != NULL ||
7741 radioService[slotId]->mRadioResponseV1_5 != NULL ||
7742 radioService[slotId]->mRadioResponseV1_6 != NULL) {
7743 V1_6::RadioResponseInfo responseInfo16 = {};
7744 RadioResponseInfo responseInfo = {};
7745 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
7746 populateResponseInfo_1_6(responseInfo16, serial, responseType, e);
7747 } else {
7748 populateResponseInfo(responseInfo, serial, responseType, e);
7749 }
7750
7751 if ((response == NULL && responseLen != 0)
7752 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
7753 RLOGE("getDataCallListResponse: invalid response");
7754 if (e == RIL_E_SUCCESS) {
7755 responseInfo16.error = V1_6::RadioError::INVALID_RESPONSE;
7756 responseInfo.error = RadioError::INVALID_RESPONSE;
7757 }
7758 } else {
7759 Return<void> retStatus;
7760 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
7761 hidl_vec<V1_6::SetupDataCallResult> ret;
7762 convertRilDataCallListToHal_1_6(response, responseLen, ret);
7763 retStatus = radioService[slotId]->mRadioResponseV1_6->getDataCallListResponse_1_6(
7764 responseInfo16, ret);
7765 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7766 hidl_vec<V1_5::SetupDataCallResult> ret;
7767 convertRilDataCallListToHal_1_5(response, responseLen, ret);
7768 retStatus = radioService[slotId]->mRadioResponseV1_5->getDataCallListResponse_1_5(
7769 responseInfo, ret);
7770 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7771 hidl_vec<V1_4::SetupDataCallResult> ret;
7772 convertRilDataCallListToHal_1_4(response, responseLen, ret);
7773 retStatus = radioService[slotId]->mRadioResponseV1_4->getDataCallListResponse_1_4(
7774 responseInfo, ret);
7775 } else {
7776 hidl_vec<SetupDataCallResult> ret;
7777 convertRilDataCallListToHal(response, responseLen, ret);
7778 retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
7779 responseInfo, ret);
7780 }
7781 radioService[slotId]->checkReturnStatus(retStatus);
7782 }
7783 } else {
7784 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7785 }
7786
7787 return 0;
7788 }
7789
setSuppServiceNotificationsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7790 int radio_1_6::setSuppServiceNotificationsResponse(int slotId,
7791 int responseType, int serial, RIL_Errno e,
7792 void *response, size_t responseLen) {
7793 #if VDBG
7794 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
7795 #endif
7796
7797 if (radioService[slotId]->mRadioResponse != NULL) {
7798 RadioResponseInfo responseInfo = {};
7799 populateResponseInfo(responseInfo, serial, responseType, e);
7800 Return<void> retStatus
7801 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
7802 responseInfo);
7803 radioService[slotId]->checkReturnStatus(retStatus);
7804 } else {
7805 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
7806 "== NULL", slotId);
7807 }
7808
7809 return 0;
7810 }
7811
deleteSmsOnSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7812 int radio_1_6::deleteSmsOnSimResponse(int slotId,
7813 int responseType, int serial, RIL_Errno e,
7814 void *response, size_t responseLen) {
7815 #if VDBG
7816 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
7817 #endif
7818
7819 if (radioService[slotId]->mRadioResponse != NULL) {
7820 RadioResponseInfo responseInfo = {};
7821 populateResponseInfo(responseInfo, serial, responseType, e);
7822 Return<void> retStatus
7823 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
7824 radioService[slotId]->checkReturnStatus(retStatus);
7825 } else {
7826 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7827 }
7828
7829 return 0;
7830 }
7831
setBandModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7832 int radio_1_6::setBandModeResponse(int slotId,
7833 int responseType, int serial, RIL_Errno e,
7834 void *response, size_t responseLen) {
7835 #if VDBG
7836 RLOGD("setBandModeResponse: serial %d", serial);
7837 #endif
7838
7839 if (radioService[slotId]->mRadioResponse != NULL) {
7840 RadioResponseInfo responseInfo = {};
7841 populateResponseInfo(responseInfo, serial, responseType, e);
7842 Return<void> retStatus
7843 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
7844 radioService[slotId]->checkReturnStatus(retStatus);
7845 } else {
7846 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7847 }
7848
7849 return 0;
7850 }
7851
writeSmsToSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7852 int radio_1_6::writeSmsToSimResponse(int slotId,
7853 int responseType, int serial, RIL_Errno e,
7854 void *response, size_t responseLen) {
7855 #if VDBG
7856 RLOGD("writeSmsToSimResponse: serial %d", serial);
7857 #endif
7858
7859 if (radioService[slotId]->mRadioResponse != NULL) {
7860 RadioResponseInfo responseInfo = {};
7861 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
7862 Return<void> retStatus
7863 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
7864 radioService[slotId]->checkReturnStatus(retStatus);
7865 } else {
7866 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7867 }
7868
7869 return 0;
7870 }
7871
getAvailableBandModesResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7872 int radio_1_6::getAvailableBandModesResponse(int slotId,
7873 int responseType, int serial, RIL_Errno e, void *response,
7874 size_t responseLen) {
7875 #if VDBG
7876 RLOGD("getAvailableBandModesResponse: serial %d", serial);
7877 #endif
7878
7879 if (radioService[slotId]->mRadioResponse != NULL) {
7880 RadioResponseInfo responseInfo = {};
7881 populateResponseInfo(responseInfo, serial, responseType, e);
7882 hidl_vec<RadioBandMode> modes;
7883 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
7884 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
7885 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7886 } else {
7887 int *pInt = (int *) response;
7888 int numInts = responseLen / sizeof(int);
7889 modes.resize(numInts);
7890 for (int i = 0; i < numInts; i++) {
7891 modes[i] = (RadioBandMode) pInt[i];
7892 }
7893 }
7894 Return<void> retStatus
7895 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
7896 modes);
7897 radioService[slotId]->checkReturnStatus(retStatus);
7898 } else {
7899 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
7900 slotId);
7901 }
7902
7903 return 0;
7904 }
7905
sendEnvelopeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7906 int radio_1_6::sendEnvelopeResponse(int slotId,
7907 int responseType, int serial, RIL_Errno e,
7908 void *response, size_t responseLen) {
7909 #if VDBG
7910 RLOGD("sendEnvelopeResponse: serial %d", serial);
7911 #endif
7912
7913 if (radioService[slotId]->mRadioResponse != NULL) {
7914 RadioResponseInfo responseInfo = {};
7915 populateResponseInfo(responseInfo, serial, responseType, e);
7916 Return<void> retStatus
7917 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
7918 convertCharPtrToHidlString((char *) response));
7919 radioService[slotId]->checkReturnStatus(retStatus);
7920 } else {
7921 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7922 }
7923
7924 return 0;
7925 }
7926
sendTerminalResponseToSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7927 int radio_1_6::sendTerminalResponseToSimResponse(int slotId,
7928 int responseType, int serial, RIL_Errno e,
7929 void *response, size_t responseLen) {
7930 #if VDBG
7931 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
7932 #endif
7933
7934 if (radioService[slotId]->mRadioResponse != NULL) {
7935 RadioResponseInfo responseInfo = {};
7936 populateResponseInfo(responseInfo, serial, responseType, e);
7937 Return<void> retStatus
7938 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
7939 responseInfo);
7940 radioService[slotId]->checkReturnStatus(retStatus);
7941 } else {
7942 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
7943 slotId);
7944 }
7945
7946 return 0;
7947 }
7948
handleStkCallSetupRequestFromSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7949 int radio_1_6::handleStkCallSetupRequestFromSimResponse(int slotId,
7950 int responseType, int serial,
7951 RIL_Errno e, void *response,
7952 size_t responseLen) {
7953 #if VDBG
7954 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
7955 #endif
7956
7957 if (radioService[slotId]->mRadioResponse != NULL) {
7958 RadioResponseInfo responseInfo = {};
7959 populateResponseInfo(responseInfo, serial, responseType, e);
7960 Return<void> retStatus
7961 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
7962 responseInfo);
7963 radioService[slotId]->checkReturnStatus(retStatus);
7964 } else {
7965 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
7966 "== NULL", slotId);
7967 }
7968
7969 return 0;
7970 }
7971
explicitCallTransferResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7972 int radio_1_6::explicitCallTransferResponse(int slotId,
7973 int responseType, int serial, RIL_Errno e,
7974 void *response, size_t responseLen) {
7975 #if VDBG
7976 RLOGD("explicitCallTransferResponse: serial %d", serial);
7977 #endif
7978
7979 if (radioService[slotId]->mRadioResponse != NULL) {
7980 RadioResponseInfo responseInfo = {};
7981 populateResponseInfo(responseInfo, serial, responseType, e);
7982 Return<void> retStatus
7983 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
7984 radioService[slotId]->checkReturnStatus(retStatus);
7985 } else {
7986 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
7987 slotId);
7988 }
7989
7990 return 0;
7991 }
7992
setPreferredNetworkTypeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7993 int radio_1_6::setPreferredNetworkTypeResponse(int slotId,
7994 int responseType, int serial, RIL_Errno e,
7995 void *response, size_t responseLen) {
7996 #if VDBG
7997 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
7998 #endif
7999
8000 if (radioService[slotId]->mRadioResponse != NULL) {
8001 RadioResponseInfo responseInfo = {};
8002 populateResponseInfo(responseInfo, serial, responseType, e);
8003 Return<void> retStatus
8004 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
8005 responseInfo);
8006 radioService[slotId]->checkReturnStatus(retStatus);
8007 } else {
8008 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
8009 slotId);
8010 }
8011
8012 return 0;
8013 }
8014
setAllowedNetworkTypesBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8015 int radio_1_6::setAllowedNetworkTypesBitmapResponse(int slotId,
8016 int responseType, int serial, RIL_Errno e,
8017 void *response, size_t responseLen) {
8018 #if VDBG
8019 RLOGD("setAllowedNetworkTypesBitmapResponse: serial %d", serial);
8020 #endif
8021
8022 V1_6::RadioResponseInfo responseInfo = {};
8023 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
8024
8025 // If we don't have a radio service, there's nothing we can do
8026 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
8027 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
8028 return 0;
8029 }
8030
8031 Return<void> retStatus =
8032 radioService[slotId]->mRadioResponseV1_6->setAllowedNetworkTypesBitmapResponse(
8033 responseInfo);
8034 radioService[slotId]->checkReturnStatus(retStatus);
8035 return 0;
8036 }
8037
getAllowedNetworkTypesBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8038 int radio_1_6::getAllowedNetworkTypesBitmapResponse(int slotId,
8039 int responseType, int serial, RIL_Errno e,
8040 void *response, size_t responseLen) {
8041 #if VDBG
8042 RLOGD("getAllowedNetworkTypesBitmapResponse: serial %d", serial);
8043 #endif
8044
8045 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
8046 V1_6::RadioResponseInfo responseInfo = {};
8047 int ret = responseInt_1_6(responseInfo, serial, responseType, e, response, responseLen);
8048 Return<void> retStatus
8049 = radioService[slotId]->mRadioResponseV1_6->getAllowedNetworkTypesBitmapResponse(
8050 responseInfo,
8051 (const ::android::hardware::hidl_bitfield<
8052 ::android::hardware::radio::V1_4::RadioAccessFamily>) ret);
8053 radioService[slotId]->checkReturnStatus(retStatus);
8054 } else {
8055 RLOGE("getAllowedNetworkTypesBitmapResponse: radioService[%d]->mRadioResponseV1_6 == NULL",
8056 slotId);
8057 }
8058
8059 return 0;
8060 }
8061
getPreferredNetworkTypeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8062 int radio_1_6::getPreferredNetworkTypeResponse(int slotId,
8063 int responseType, int serial, RIL_Errno e,
8064 void *response, size_t responseLen) {
8065 #if VDBG
8066 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
8067 #endif
8068
8069 if (radioService[slotId]->mRadioResponse != NULL) {
8070 RadioResponseInfo responseInfo = {};
8071 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8072 Return<void> retStatus
8073 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
8074 responseInfo, (PreferredNetworkType) ret);
8075 radioService[slotId]->checkReturnStatus(retStatus);
8076 } else {
8077 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
8078 slotId);
8079 }
8080
8081 return 0;
8082 }
8083
setPreferredNetworkTypeBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8084 int radio_1_6::setPreferredNetworkTypeBitmapResponse(int slotId,
8085 int responseType, int serial, RIL_Errno e,
8086 void *response, size_t responseLen) {
8087 #if VDBG
8088 RLOGD("setPreferredNetworkTypeBitmapResponse: serial %d", serial);
8089 #endif
8090
8091 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
8092 RadioResponseInfo responseInfo = {};
8093 populateResponseInfo(responseInfo, serial, responseType, e);
8094 Return<void> retStatus
8095 = radioService[slotId]->mRadioResponseV1_4->setPreferredNetworkTypeBitmapResponse(
8096 responseInfo);
8097 radioService[slotId]->checkReturnStatus(retStatus);
8098 } else {
8099 RLOGE("setPreferredNetworkTypeBitmapResponse: radioService[%d]->mRadioResponseV1_4 == NULL",
8100 slotId);
8101 }
8102
8103 return 0;
8104 }
8105
8106
getPreferredNetworkTypeBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8107 int radio_1_6::getPreferredNetworkTypeBitmapResponse(int slotId,
8108 int responseType, int serial, RIL_Errno e,
8109 void *response, size_t responseLen) {
8110 #if VDBG
8111 RLOGD("getPreferredNetworkTypeBitmapResponse: serial %d", serial);
8112 #endif
8113
8114 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
8115 RadioResponseInfo responseInfo = {};
8116 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8117 Return<void> retStatus
8118 = radioService[slotId]->mRadioResponseV1_4->getPreferredNetworkTypeBitmapResponse(
8119 responseInfo,
8120 (const ::android::hardware::hidl_bitfield<
8121 ::android::hardware::radio::V1_4::RadioAccessFamily>) ret);
8122 radioService[slotId]->checkReturnStatus(retStatus);
8123 } else {
8124 RLOGE("getPreferredNetworkTypeBitmapResponse: radioService[%d]->mRadioResponseV1_4 == NULL",
8125 slotId);
8126 }
8127
8128 return 0;
8129 }
8130
getNeighboringCidsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8131 int radio_1_6::getNeighboringCidsResponse(int slotId,
8132 int responseType, int serial, RIL_Errno e,
8133 void *response, size_t responseLen) {
8134 #if VDBG
8135 RLOGD("getNeighboringCidsResponse: serial %d", serial);
8136 #endif
8137
8138 if (radioService[slotId]->mRadioResponse != NULL) {
8139 RadioResponseInfo responseInfo = {};
8140 populateResponseInfo(responseInfo, serial, responseType, e);
8141 hidl_vec<NeighboringCell> cells;
8142
8143 if ((response == NULL && responseLen != 0)
8144 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
8145 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
8146 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8147 } else {
8148 int num = responseLen / sizeof(RIL_NeighboringCell *);
8149 cells.resize(num);
8150 for (int i = 0 ; i < num; i++) {
8151 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
8152 cells[i].cid = convertCharPtrToHidlString(resp->cid);
8153 cells[i].rssi = resp->rssi;
8154 }
8155 }
8156
8157 Return<void> retStatus
8158 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
8159 cells);
8160 radioService[slotId]->checkReturnStatus(retStatus);
8161 } else {
8162 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
8163 slotId);
8164 }
8165
8166 return 0;
8167 }
8168
setLocationUpdatesResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8169 int radio_1_6::setLocationUpdatesResponse(int slotId,
8170 int responseType, int serial, RIL_Errno e,
8171 void *response, size_t responseLen) {
8172 #if VDBG
8173 RLOGD("setLocationUpdatesResponse: serial %d", serial);
8174 #endif
8175
8176 if (radioService[slotId]->mRadioResponse != NULL) {
8177 RadioResponseInfo responseInfo = {};
8178 populateResponseInfo(responseInfo, serial, responseType, e);
8179 Return<void> retStatus
8180 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
8181 radioService[slotId]->checkReturnStatus(retStatus);
8182 } else {
8183 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
8184 slotId);
8185 }
8186
8187 return 0;
8188 }
8189
setCdmaSubscriptionSourceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8190 int radio_1_6::setCdmaSubscriptionSourceResponse(int slotId,
8191 int responseType, int serial, RIL_Errno e,
8192 void *response, size_t responseLen) {
8193 #if VDBG
8194 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
8195 #endif
8196
8197 if (radioService[slotId]->mRadioResponse != NULL) {
8198 RadioResponseInfo responseInfo = {};
8199 populateResponseInfo(responseInfo, serial, responseType, e);
8200 Return<void> retStatus
8201 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
8202 responseInfo);
8203 radioService[slotId]->checkReturnStatus(retStatus);
8204 } else {
8205 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
8206 slotId);
8207 }
8208
8209 return 0;
8210 }
8211
setCdmaRoamingPreferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8212 int radio_1_6::setCdmaRoamingPreferenceResponse(int slotId,
8213 int responseType, int serial, RIL_Errno e,
8214 void *response, size_t responseLen) {
8215 #if VDBG
8216 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
8217 #endif
8218
8219 if (radioService[slotId]->mRadioResponse != NULL) {
8220 RadioResponseInfo responseInfo = {};
8221 populateResponseInfo(responseInfo, serial, responseType, e);
8222 Return<void> retStatus
8223 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
8224 responseInfo);
8225 radioService[slotId]->checkReturnStatus(retStatus);
8226 } else {
8227 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
8228 slotId);
8229 }
8230
8231 return 0;
8232 }
8233
getCdmaRoamingPreferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8234 int radio_1_6::getCdmaRoamingPreferenceResponse(int slotId,
8235 int responseType, int serial, RIL_Errno e,
8236 void *response, size_t responseLen) {
8237 #if VDBG
8238 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
8239 #endif
8240
8241 if (radioService[slotId]->mRadioResponse != NULL) {
8242 RadioResponseInfo responseInfo = {};
8243 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8244 Return<void> retStatus
8245 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
8246 responseInfo, (CdmaRoamingType) ret);
8247 radioService[slotId]->checkReturnStatus(retStatus);
8248 } else {
8249 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
8250 slotId);
8251 }
8252
8253 return 0;
8254 }
8255
setTTYModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8256 int radio_1_6::setTTYModeResponse(int slotId,
8257 int responseType, int serial, RIL_Errno e,
8258 void *response, size_t responseLen) {
8259 #if VDBG
8260 RLOGD("setTTYModeResponse: serial %d", serial);
8261 #endif
8262
8263 if (radioService[slotId]->mRadioResponse != NULL) {
8264 RadioResponseInfo responseInfo = {};
8265 populateResponseInfo(responseInfo, serial, responseType, e);
8266 Return<void> retStatus
8267 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
8268 radioService[slotId]->checkReturnStatus(retStatus);
8269 } else {
8270 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8271 }
8272
8273 return 0;
8274 }
8275
getTTYModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8276 int radio_1_6::getTTYModeResponse(int slotId,
8277 int responseType, int serial, RIL_Errno e,
8278 void *response, size_t responseLen) {
8279 #if VDBG
8280 RLOGD("getTTYModeResponse: serial %d", serial);
8281 #endif
8282
8283 if (radioService[slotId]->mRadioResponse != NULL) {
8284 RadioResponseInfo responseInfo = {};
8285 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8286 Return<void> retStatus
8287 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
8288 (TtyMode) ret);
8289 radioService[slotId]->checkReturnStatus(retStatus);
8290 } else {
8291 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8292 }
8293
8294 return 0;
8295 }
8296
setPreferredVoicePrivacyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8297 int radio_1_6::setPreferredVoicePrivacyResponse(int slotId,
8298 int responseType, int serial, RIL_Errno e,
8299 void *response, size_t responseLen) {
8300 #if VDBG
8301 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
8302 #endif
8303
8304 if (radioService[slotId]->mRadioResponse != NULL) {
8305 RadioResponseInfo responseInfo = {};
8306 populateResponseInfo(responseInfo, serial, responseType, e);
8307 Return<void> retStatus
8308 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
8309 responseInfo);
8310 radioService[slotId]->checkReturnStatus(retStatus);
8311 } else {
8312 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
8313 slotId);
8314 }
8315
8316 return 0;
8317 }
8318
getPreferredVoicePrivacyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8319 int radio_1_6::getPreferredVoicePrivacyResponse(int slotId,
8320 int responseType, int serial, RIL_Errno e,
8321 void *response, size_t responseLen) {
8322 #if VDBG
8323 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
8324 #endif
8325
8326 if (radioService[slotId]->mRadioResponse != NULL) {
8327 RadioResponseInfo responseInfo = {};
8328 populateResponseInfo(responseInfo, serial, responseType, e);
8329 bool enable = false;
8330 int numInts = responseLen / sizeof(int);
8331 if (response == NULL || numInts != 1) {
8332 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
8333 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8334 } else {
8335 int *pInt = (int *) response;
8336 enable = pInt[0] == 1 ? true : false;
8337 }
8338 Return<void> retStatus
8339 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
8340 responseInfo, enable);
8341 radioService[slotId]->checkReturnStatus(retStatus);
8342 } else {
8343 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
8344 slotId);
8345 }
8346
8347 return 0;
8348 }
8349
sendCDMAFeatureCodeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8350 int radio_1_6::sendCDMAFeatureCodeResponse(int slotId,
8351 int responseType, int serial, RIL_Errno e,
8352 void *response, size_t responseLen) {
8353 #if VDBG
8354 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
8355 #endif
8356
8357 if (radioService[slotId]->mRadioResponse != NULL) {
8358 RadioResponseInfo responseInfo = {};
8359 populateResponseInfo(responseInfo, serial, responseType, e);
8360 Return<void> retStatus
8361 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
8362 radioService[slotId]->checkReturnStatus(retStatus);
8363 } else {
8364 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
8365 slotId);
8366 }
8367
8368 return 0;
8369 }
8370
sendBurstDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8371 int radio_1_6::sendBurstDtmfResponse(int slotId,
8372 int responseType, int serial, RIL_Errno e,
8373 void *response, size_t responseLen) {
8374 #if VDBG
8375 RLOGD("sendBurstDtmfResponse: serial %d", serial);
8376 #endif
8377
8378 if (radioService[slotId]->mRadioResponse != NULL) {
8379 RadioResponseInfo responseInfo = {};
8380 populateResponseInfo(responseInfo, serial, responseType, e);
8381 Return<void> retStatus
8382 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
8383 radioService[slotId]->checkReturnStatus(retStatus);
8384 } else {
8385 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8386 }
8387
8388 return 0;
8389 }
8390
sendCdmaSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8391 int radio_1_6::sendCdmaSmsResponse(int slotId,
8392 int responseType, int serial, RIL_Errno e, void *response,
8393 size_t responseLen) {
8394 #if VDBG
8395 RLOGD("sendCdmaSmsResponse: serial %d", serial);
8396 #endif
8397
8398 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
8399 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
8400 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e,
8401 response, responseLen);
8402
8403 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
8404 ->sendCdmaSmsResponse_1_6(responseInfo_1_6, result);
8405 radioService[slotId]->checkReturnStatus(retStatus);
8406 } else if (radioService[slotId]->mRadioResponse != NULL) {
8407 RadioResponseInfo responseInfo = {};
8408 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
8409 responseLen);
8410
8411 Return<void> retStatus
8412 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
8413 radioService[slotId]->checkReturnStatus(retStatus);
8414 } else {
8415 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8416 }
8417
8418 return 0;
8419 }
8420
acknowledgeLastIncomingCdmaSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8421 int radio_1_6::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
8422 int responseType, int serial, RIL_Errno e,
8423 void *response, size_t responseLen) {
8424 #if VDBG
8425 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
8426 #endif
8427
8428 if (radioService[slotId]->mRadioResponse != NULL) {
8429 RadioResponseInfo responseInfo = {};
8430 populateResponseInfo(responseInfo, serial, responseType, e);
8431 Return<void> retStatus
8432 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
8433 responseInfo);
8434 radioService[slotId]->checkReturnStatus(retStatus);
8435 } else {
8436 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
8437 "== NULL", slotId);
8438 }
8439
8440 return 0;
8441 }
8442
getGsmBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8443 int radio_1_6::getGsmBroadcastConfigResponse(int slotId,
8444 int responseType, int serial, RIL_Errno e,
8445 void *response, size_t responseLen) {
8446 #if VDBG
8447 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
8448 #endif
8449
8450 if (radioService[slotId]->mRadioResponse != NULL) {
8451 RadioResponseInfo responseInfo = {};
8452 populateResponseInfo(responseInfo, serial, responseType, e);
8453 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
8454
8455 if ((response == NULL && responseLen != 0)
8456 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
8457 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
8458 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8459 } else {
8460 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
8461 configs.resize(num);
8462 for (int i = 0 ; i < num; i++) {
8463 RIL_GSM_BroadcastSmsConfigInfo *resp =
8464 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
8465 configs[i].fromServiceId = resp->fromServiceId;
8466 configs[i].toServiceId = resp->toServiceId;
8467 configs[i].fromCodeScheme = resp->fromCodeScheme;
8468 configs[i].toCodeScheme = resp->toCodeScheme;
8469 configs[i].selected = resp->selected == 1 ? true : false;
8470 }
8471 }
8472
8473 Return<void> retStatus
8474 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
8475 configs);
8476 radioService[slotId]->checkReturnStatus(retStatus);
8477 } else {
8478 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8479 slotId);
8480 }
8481
8482 return 0;
8483 }
8484
setGsmBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8485 int radio_1_6::setGsmBroadcastConfigResponse(int slotId,
8486 int responseType, int serial, RIL_Errno e,
8487 void *response, size_t responseLen) {
8488 #if VDBG
8489 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
8490 #endif
8491
8492 if (radioService[slotId]->mRadioResponse != NULL) {
8493 RadioResponseInfo responseInfo = {};
8494 populateResponseInfo(responseInfo, serial, responseType, e);
8495 Return<void> retStatus
8496 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
8497 radioService[slotId]->checkReturnStatus(retStatus);
8498 } else {
8499 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8500 slotId);
8501 }
8502
8503 return 0;
8504 }
8505
setGsmBroadcastActivationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8506 int radio_1_6::setGsmBroadcastActivationResponse(int slotId,
8507 int responseType, int serial, RIL_Errno e,
8508 void *response, size_t responseLen) {
8509 #if VDBG
8510 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
8511 #endif
8512
8513 if (radioService[slotId]->mRadioResponse != NULL) {
8514 RadioResponseInfo responseInfo = {};
8515 populateResponseInfo(responseInfo, serial, responseType, e);
8516 Return<void> retStatus
8517 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
8518 responseInfo);
8519 radioService[slotId]->checkReturnStatus(retStatus);
8520 } else {
8521 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
8522 slotId);
8523 }
8524
8525 return 0;
8526 }
8527
getCdmaBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8528 int radio_1_6::getCdmaBroadcastConfigResponse(int slotId,
8529 int responseType, int serial, RIL_Errno e,
8530 void *response, size_t responseLen) {
8531 #if VDBG
8532 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
8533 #endif
8534
8535 if (radioService[slotId]->mRadioResponse != NULL) {
8536 RadioResponseInfo responseInfo = {};
8537 populateResponseInfo(responseInfo, serial, responseType, e);
8538 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
8539
8540 if ((response == NULL && responseLen != 0)
8541 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
8542 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
8543 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8544 } else {
8545 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
8546 configs.resize(num);
8547 for (int i = 0 ; i < num; i++) {
8548 RIL_CDMA_BroadcastSmsConfigInfo *resp =
8549 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
8550 configs[i].serviceCategory = resp->service_category;
8551 configs[i].language = resp->language;
8552 configs[i].selected = resp->selected == 1 ? true : false;
8553 }
8554 }
8555
8556 Return<void> retStatus
8557 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
8558 configs);
8559 radioService[slotId]->checkReturnStatus(retStatus);
8560 } else {
8561 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8562 slotId);
8563 }
8564
8565 return 0;
8566 }
8567
setCdmaBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8568 int radio_1_6::setCdmaBroadcastConfigResponse(int slotId,
8569 int responseType, int serial, RIL_Errno e,
8570 void *response, size_t responseLen) {
8571 #if VDBG
8572 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
8573 #endif
8574
8575 if (radioService[slotId]->mRadioResponse != NULL) {
8576 RadioResponseInfo responseInfo = {};
8577 populateResponseInfo(responseInfo, serial, responseType, e);
8578 Return<void> retStatus
8579 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
8580 responseInfo);
8581 radioService[slotId]->checkReturnStatus(retStatus);
8582 } else {
8583 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8584 slotId);
8585 }
8586
8587 return 0;
8588 }
8589
setCdmaBroadcastActivationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8590 int radio_1_6::setCdmaBroadcastActivationResponse(int slotId,
8591 int responseType, int serial, RIL_Errno e,
8592 void *response, size_t responseLen) {
8593 #if VDBG
8594 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
8595 #endif
8596
8597 if (radioService[slotId]->mRadioResponse != NULL) {
8598 RadioResponseInfo responseInfo = {};
8599 populateResponseInfo(responseInfo, serial, responseType, e);
8600 Return<void> retStatus
8601 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
8602 responseInfo);
8603 radioService[slotId]->checkReturnStatus(retStatus);
8604 } else {
8605 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
8606 slotId);
8607 }
8608
8609 return 0;
8610 }
8611
getCDMASubscriptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8612 int radio_1_6::getCDMASubscriptionResponse(int slotId,
8613 int responseType, int serial, RIL_Errno e, void *response,
8614 size_t responseLen) {
8615 #if VDBG
8616 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
8617 #endif
8618
8619 if (radioService[slotId]->mRadioResponse != NULL) {
8620 RadioResponseInfo responseInfo = {};
8621 populateResponseInfo(responseInfo, serial, responseType, e);
8622
8623 int numStrings = responseLen / sizeof(char *);
8624 hidl_string emptyString;
8625 if (response == NULL || numStrings != 5) {
8626 RLOGE("getOperatorResponse Invalid response: NULL");
8627 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8628 Return<void> retStatus
8629 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
8630 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
8631 radioService[slotId]->checkReturnStatus(retStatus);
8632 } else {
8633 char **resp = (char **) response;
8634 Return<void> retStatus
8635 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
8636 responseInfo,
8637 convertCharPtrToHidlString(resp[0]),
8638 convertCharPtrToHidlString(resp[1]),
8639 convertCharPtrToHidlString(resp[2]),
8640 convertCharPtrToHidlString(resp[3]),
8641 convertCharPtrToHidlString(resp[4]));
8642 radioService[slotId]->checkReturnStatus(retStatus);
8643 }
8644 } else {
8645 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
8646 slotId);
8647 }
8648
8649 return 0;
8650 }
8651
writeSmsToRuimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8652 int radio_1_6::writeSmsToRuimResponse(int slotId,
8653 int responseType, int serial, RIL_Errno e,
8654 void *response, size_t responseLen) {
8655 #if VDBG
8656 RLOGD("writeSmsToRuimResponse: serial %d", serial);
8657 #endif
8658
8659 if (radioService[slotId]->mRadioResponse != NULL) {
8660 RadioResponseInfo responseInfo = {};
8661 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8662 Return<void> retStatus
8663 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
8664 radioService[slotId]->checkReturnStatus(retStatus);
8665 } else {
8666 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8667 }
8668
8669 return 0;
8670 }
8671
deleteSmsOnRuimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8672 int radio_1_6::deleteSmsOnRuimResponse(int slotId,
8673 int responseType, int serial, RIL_Errno e,
8674 void *response, size_t responseLen) {
8675 #if VDBG
8676 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
8677 #endif
8678
8679 if (radioService[slotId]->mRadioResponse != NULL) {
8680 RadioResponseInfo responseInfo = {};
8681 populateResponseInfo(responseInfo, serial, responseType, e);
8682 Return<void> retStatus
8683 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
8684 radioService[slotId]->checkReturnStatus(retStatus);
8685 } else {
8686 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8687 }
8688
8689 return 0;
8690 }
8691
getDeviceIdentityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8692 int radio_1_6::getDeviceIdentityResponse(int slotId,
8693 int responseType, int serial, RIL_Errno e, void *response,
8694 size_t responseLen) {
8695 #if VDBG
8696 RLOGD("getDeviceIdentityResponse: serial %d", serial);
8697 #endif
8698
8699 if (radioService[slotId]->mRadioResponse != NULL) {
8700 RadioResponseInfo responseInfo = {};
8701 populateResponseInfo(responseInfo, serial, responseType, e);
8702
8703 int numStrings = responseLen / sizeof(char *);
8704 hidl_string emptyString;
8705 if (response == NULL || numStrings != 4) {
8706 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
8707 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8708 Return<void> retStatus
8709 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
8710 emptyString, emptyString, emptyString, emptyString);
8711 radioService[slotId]->checkReturnStatus(retStatus);
8712 } else {
8713 char **resp = (char **) response;
8714 Return<void> retStatus
8715 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
8716 convertCharPtrToHidlString(resp[0]),
8717 convertCharPtrToHidlString(resp[1]),
8718 convertCharPtrToHidlString(resp[2]),
8719 convertCharPtrToHidlString(resp[3]));
8720 radioService[slotId]->checkReturnStatus(retStatus);
8721 }
8722 } else {
8723 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
8724 slotId);
8725 }
8726
8727 return 0;
8728 }
8729
exitEmergencyCallbackModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8730 int radio_1_6::exitEmergencyCallbackModeResponse(int slotId,
8731 int responseType, int serial, RIL_Errno e,
8732 void *response, size_t responseLen) {
8733 #if VDBG
8734 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
8735 #endif
8736
8737 if (radioService[slotId]->mRadioResponse != NULL) {
8738 RadioResponseInfo responseInfo = {};
8739 populateResponseInfo(responseInfo, serial, responseType, e);
8740 Return<void> retStatus
8741 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
8742 responseInfo);
8743 radioService[slotId]->checkReturnStatus(retStatus);
8744 } else {
8745 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
8746 slotId);
8747 }
8748
8749 return 0;
8750 }
8751
getSmscAddressResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8752 int radio_1_6::getSmscAddressResponse(int slotId,
8753 int responseType, int serial, RIL_Errno e,
8754 void *response, size_t responseLen) {
8755 #if VDBG
8756 RLOGD("getSmscAddressResponse: serial %d", serial);
8757 #endif
8758
8759 if (radioService[slotId]->mRadioResponse != NULL) {
8760 RadioResponseInfo responseInfo = {};
8761 populateResponseInfo(responseInfo, serial, responseType, e);
8762 Return<void> retStatus
8763 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
8764 convertCharPtrToHidlString((char *) response));
8765 radioService[slotId]->checkReturnStatus(retStatus);
8766 } else {
8767 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8768 }
8769
8770 return 0;
8771 }
8772
setSmscAddressResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8773 int radio_1_6::setSmscAddressResponse(int slotId,
8774 int responseType, int serial, RIL_Errno e,
8775 void *response, size_t responseLen) {
8776 #if VDBG
8777 RLOGD("setSmscAddressResponse: serial %d", serial);
8778 #endif
8779
8780 if (radioService[slotId]->mRadioResponse != NULL) {
8781 RadioResponseInfo responseInfo = {};
8782 populateResponseInfo(responseInfo, serial, responseType, e);
8783 Return<void> retStatus
8784 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
8785 radioService[slotId]->checkReturnStatus(retStatus);
8786 } else {
8787 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8788 }
8789
8790 return 0;
8791 }
8792
reportSmsMemoryStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8793 int radio_1_6::reportSmsMemoryStatusResponse(int slotId,
8794 int responseType, int serial, RIL_Errno e,
8795 void *response, size_t responseLen) {
8796 #if VDBG
8797 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
8798 #endif
8799
8800 if (radioService[slotId]->mRadioResponse != NULL) {
8801 RadioResponseInfo responseInfo = {};
8802 populateResponseInfo(responseInfo, serial, responseType, e);
8803 Return<void> retStatus
8804 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
8805 radioService[slotId]->checkReturnStatus(retStatus);
8806 } else {
8807 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
8808 slotId);
8809 }
8810
8811 return 0;
8812 }
8813
reportStkServiceIsRunningResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8814 int radio_1_6::reportStkServiceIsRunningResponse(int slotId,
8815 int responseType, int serial, RIL_Errno e,
8816 void *response, size_t responseLen) {
8817 #if VDBG
8818 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
8819 #endif
8820
8821 if (radioService[slotId]->mRadioResponse != NULL) {
8822 RadioResponseInfo responseInfo = {};
8823 populateResponseInfo(responseInfo, serial, responseType, e);
8824 Return<void> retStatus = radioService[slotId]->mRadioResponse->
8825 reportStkServiceIsRunningResponse(responseInfo);
8826 radioService[slotId]->checkReturnStatus(retStatus);
8827 } else {
8828 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
8829 slotId);
8830 }
8831
8832 return 0;
8833 }
8834
getCdmaSubscriptionSourceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8835 int radio_1_6::getCdmaSubscriptionSourceResponse(int slotId,
8836 int responseType, int serial, RIL_Errno e,
8837 void *response, size_t responseLen) {
8838 #if VDBG
8839 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
8840 #endif
8841
8842 if (radioService[slotId]->mRadioResponse != NULL) {
8843 RadioResponseInfo responseInfo = {};
8844 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8845 Return<void> retStatus
8846 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
8847 responseInfo, (CdmaSubscriptionSource) ret);
8848 radioService[slotId]->checkReturnStatus(retStatus);
8849 } else {
8850 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
8851 slotId);
8852 }
8853
8854 return 0;
8855 }
8856
requestIsimAuthenticationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8857 int radio_1_6::requestIsimAuthenticationResponse(int slotId,
8858 int responseType, int serial, RIL_Errno e,
8859 void *response, size_t responseLen) {
8860 #if VDBG
8861 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
8862 #endif
8863
8864 if (radioService[slotId]->mRadioResponse != NULL) {
8865 RadioResponseInfo responseInfo = {};
8866 populateResponseInfo(responseInfo, serial, responseType, e);
8867 Return<void> retStatus
8868 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
8869 responseInfo,
8870 convertCharPtrToHidlString((char *) response));
8871 radioService[slotId]->checkReturnStatus(retStatus);
8872 } else {
8873 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
8874 slotId);
8875 }
8876
8877 return 0;
8878 }
8879
acknowledgeIncomingGsmSmsWithPduResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8880 int radio_1_6::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
8881 int responseType,
8882 int serial, RIL_Errno e, void *response,
8883 size_t responseLen) {
8884 #if VDBG
8885 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
8886 #endif
8887
8888 if (radioService[slotId]->mRadioResponse != NULL) {
8889 RadioResponseInfo responseInfo = {};
8890 populateResponseInfo(responseInfo, serial, responseType, e);
8891 Return<void> retStatus
8892 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
8893 responseInfo);
8894 radioService[slotId]->checkReturnStatus(retStatus);
8895 } else {
8896 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
8897 "== NULL", slotId);
8898 }
8899
8900 return 0;
8901 }
8902
sendEnvelopeWithStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8903 int radio_1_6::sendEnvelopeWithStatusResponse(int slotId,
8904 int responseType, int serial, RIL_Errno e, void *response,
8905 size_t responseLen) {
8906 #if VDBG
8907 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
8908 #endif
8909
8910 if (radioService[slotId]->mRadioResponse != NULL) {
8911 RadioResponseInfo responseInfo = {};
8912 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
8913 response, responseLen);
8914
8915 Return<void> retStatus
8916 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
8917 result);
8918 radioService[slotId]->checkReturnStatus(retStatus);
8919 } else {
8920 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
8921 slotId);
8922 }
8923
8924 return 0;
8925 }
8926
getVoiceRadioTechnologyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8927 int radio_1_6::getVoiceRadioTechnologyResponse(int slotId,
8928 int responseType, int serial, RIL_Errno e,
8929 void *response, size_t responseLen) {
8930 #if VDBG
8931 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
8932 #endif
8933
8934 if (radioService[slotId]->mRadioResponse != NULL) {
8935 RadioResponseInfo responseInfo = {};
8936 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8937 Return<void> retStatus
8938 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
8939 responseInfo, (RadioTechnology) ret);
8940 radioService[slotId]->checkReturnStatus(retStatus);
8941 } else {
8942 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
8943 slotId);
8944 }
8945
8946 return 0;
8947 }
8948
getCellInfoListResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8949 int radio_1_6::getCellInfoListResponse(int slotId, int responseType, int serial, RIL_Errno e,
8950 void* response, size_t responseLen) {
8951 #if VDBG
8952 RLOGD("getCellInfoListResponse: serial %d", serial);
8953 #endif
8954 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
8955 V1_6::RadioResponseInfo responseInfo = {};
8956 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
8957 hidl_vec<V1_6::CellInfo> ret;
8958 Return<void> retStatus;
8959 if (response != NULL && responseLen != 0 && responseLen % sizeof(RIL_CellInfo_v16) == 0) {
8960 convertRilCellInfoListToHal_1_6(response, responseLen, ret);
8961 } else {
8962 RLOGE("getCellInfoListResponse_1_6: Invalid response");
8963 if (e == RIL_E_SUCCESS) responseInfo.error = V1_6::RadioError::INVALID_RESPONSE;
8964 }
8965 retStatus = radioService[slotId]->mRadioResponseV1_6->getCellInfoListResponse_1_6(
8966 responseInfo, ret);
8967 radioService[slotId]->checkReturnStatus(retStatus);
8968 } else if (radioService[slotId]->mRadioResponse != NULL ||
8969 radioService[slotId]->mRadioResponseV1_2 != NULL ||
8970 radioService[slotId]->mRadioResponseV1_4 != NULL ||
8971 radioService[slotId]->mRadioResponseV1_5 != NULL) {
8972 RadioResponseInfo responseInfo = {};
8973 populateResponseInfo(responseInfo, serial, responseType, e);
8974 bool error = response == NULL && responseLen != 0;
8975 Return<void> retStatus;
8976 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
8977 hidl_vec<V1_5::CellInfo> ret;
8978 if (!error && responseLen % sizeof(RIL_CellInfo_v16) != 0) {
8979 convertRilCellInfoListToHal_1_5(response, responseLen, ret);
8980 } else {
8981 RLOGE("getCellInfoListResponse_1_5: Invalid response");
8982 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8983 }
8984 retStatus = radioService[slotId]->mRadioResponseV1_5->getCellInfoListResponse_1_5(
8985 responseInfo, ret);
8986 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
8987 hidl_vec<V1_4::CellInfo> ret;
8988 if (!error && responseLen % sizeof(RIL_CellInfo_v16) != 0) {
8989 convertRilCellInfoListToHal_1_4(response, responseLen, ret);
8990 } else {
8991 RLOGE("getCellInfoListResponse_1_4: Invalid response");
8992 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8993 }
8994 radioService[slotId]->mRadioResponseV1_4->getCellInfoListResponse_1_4(responseInfo,
8995 ret);
8996 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
8997 hidl_vec<V1_2::CellInfo> ret;
8998 if (!error && responseLen % sizeof(RIL_CellInfo_v12) != 0) {
8999 convertRilCellInfoListToHal_1_2(response, responseLen, ret);
9000 } else {
9001 RLOGE("getCellInfoListResponse_1_2: Invalid response");
9002 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9003 }
9004 radioService[slotId]->mRadioResponseV1_2->getCellInfoListResponse_1_2(responseInfo,
9005 ret);
9006 } else {
9007 hidl_vec<CellInfo> ret;
9008 if (!error && responseLen % sizeof(RIL_CellInfo) != 0) {
9009 convertRilCellInfoListToHal(response, responseLen, ret);
9010 } else {
9011 RLOGE("getCellInfoListResponse: Invalid response");
9012 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9013 }
9014 radioService[slotId]->mRadioResponse->getCellInfoListResponse(responseInfo, ret);
9015 }
9016 radioService[slotId]->checkReturnStatus(retStatus);
9017 } else {
9018 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9019 }
9020
9021 return 0;
9022 }
9023
setCellInfoListRateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9024 int radio_1_6::setCellInfoListRateResponse(int slotId,
9025 int responseType,
9026 int serial, RIL_Errno e, void *response,
9027 size_t responseLen) {
9028 #if VDBG
9029 RLOGD("setCellInfoListRateResponse: serial %d", serial);
9030 #endif
9031
9032 if (radioService[slotId]->mRadioResponse != NULL) {
9033 RadioResponseInfo responseInfo = {};
9034 populateResponseInfo(responseInfo, serial, responseType, e);
9035 Return<void> retStatus
9036 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
9037 radioService[slotId]->checkReturnStatus(retStatus);
9038 } else {
9039 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
9040 slotId);
9041 }
9042
9043 return 0;
9044 }
9045
setInitialAttachApnResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9046 int radio_1_6::setInitialAttachApnResponse(int slotId, int responseType, int serial, RIL_Errno e,
9047 void* response, size_t responseLen) {
9048 #if VDBG
9049 RLOGD("setInitialAttachApnResponse: serial %d", serial);
9050 #endif
9051
9052 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
9053 RadioResponseInfo responseInfo = {};
9054 populateResponseInfo(responseInfo, serial, responseType, e);
9055 Return<void> retStatus =
9056 radioService[slotId]->mRadioResponseV1_5->setInitialAttachApnResponse_1_5(
9057 responseInfo);
9058 radioService[slotId]->checkReturnStatus(retStatus);
9059 } else if (radioService[slotId]->mRadioResponse != NULL) {
9060 RadioResponseInfo responseInfo = {};
9061 populateResponseInfo(responseInfo, serial, responseType, e);
9062 Return<void> retStatus =
9063 radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
9064 radioService[slotId]->checkReturnStatus(retStatus);
9065 } else {
9066 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9067 }
9068
9069 return 0;
9070 }
9071
getImsRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9072 int radio_1_6::getImsRegistrationStateResponse(int slotId,
9073 int responseType, int serial, RIL_Errno e,
9074 void *response, size_t responseLen) {
9075 #if VDBG
9076 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
9077 #endif
9078
9079 if (radioService[slotId]->mRadioResponse != NULL) {
9080 RadioResponseInfo responseInfo = {};
9081 populateResponseInfo(responseInfo, serial, responseType, e);
9082 bool isRegistered = false;
9083 int ratFamily = 0;
9084 int numInts = responseLen / sizeof(int);
9085 if (response == NULL || numInts != 2) {
9086 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
9087 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9088 } else {
9089 int *pInt = (int *) response;
9090 isRegistered = pInt[0] == 1 ? true : false;
9091 ratFamily = pInt[1];
9092 }
9093 Return<void> retStatus
9094 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
9095 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
9096 radioService[slotId]->checkReturnStatus(retStatus);
9097 } else {
9098 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
9099 slotId);
9100 }
9101
9102 return 0;
9103 }
9104
sendImsSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9105 int radio_1_6::sendImsSmsResponse(int slotId,
9106 int responseType, int serial, RIL_Errno e, void *response,
9107 size_t responseLen) {
9108 #if VDBG
9109 RLOGD("sendImsSmsResponse: serial %d", serial);
9110 #endif
9111
9112 if (radioService[slotId]->mRadioResponse != NULL) {
9113 RadioResponseInfo responseInfo = {};
9114 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
9115 responseLen);
9116
9117 Return<void> retStatus
9118 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
9119 radioService[slotId]->checkReturnStatus(retStatus);
9120 } else {
9121 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9122 }
9123
9124 return 0;
9125 }
9126
iccTransmitApduBasicChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9127 int radio_1_6::iccTransmitApduBasicChannelResponse(int slotId,
9128 int responseType, int serial, RIL_Errno e,
9129 void *response, size_t responseLen) {
9130 #if VDBG
9131 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
9132 #endif
9133
9134 if (radioService[slotId]->mRadioResponse != NULL) {
9135 RadioResponseInfo responseInfo = {};
9136 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
9137 responseLen);
9138
9139 Return<void> retStatus
9140 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
9141 responseInfo, result);
9142 radioService[slotId]->checkReturnStatus(retStatus);
9143 } else {
9144 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
9145 "== NULL", slotId);
9146 }
9147
9148 return 0;
9149 }
9150
iccOpenLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9151 int radio_1_6::iccOpenLogicalChannelResponse(int slotId,
9152 int responseType, int serial, RIL_Errno e, void *response,
9153 size_t responseLen) {
9154 #if VDBG
9155 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
9156 #endif
9157
9158 if (radioService[slotId]->mRadioResponse != NULL) {
9159 RadioResponseInfo responseInfo = {};
9160 populateResponseInfo(responseInfo, serial, responseType, e);
9161 int channelId = -1;
9162 hidl_vec<int8_t> selectResponse;
9163 int numInts = responseLen / sizeof(int);
9164 if (response == NULL || responseLen % sizeof(int) != 0) {
9165 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
9166 if (response != NULL) {
9167 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9168 }
9169 } else {
9170 int *pInt = (int *) response;
9171 channelId = pInt[0];
9172 selectResponse.resize(numInts - 1);
9173 for (int i = 1; i < numInts; i++) {
9174 selectResponse[i - 1] = (int8_t) pInt[i];
9175 }
9176 }
9177 Return<void> retStatus
9178 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
9179 channelId, selectResponse);
9180 radioService[slotId]->checkReturnStatus(retStatus);
9181 } else {
9182 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
9183 slotId);
9184 }
9185
9186 return 0;
9187 }
9188
iccCloseLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9189 int radio_1_6::iccCloseLogicalChannelResponse(int slotId,
9190 int responseType, int serial, RIL_Errno e,
9191 void *response, size_t responseLen) {
9192 #if VDBG
9193 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
9194 #endif
9195
9196 if (radioService[slotId]->mRadioResponse != NULL) {
9197 RadioResponseInfo responseInfo = {};
9198 populateResponseInfo(responseInfo, serial, responseType, e);
9199 Return<void> retStatus
9200 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
9201 responseInfo);
9202 radioService[slotId]->checkReturnStatus(retStatus);
9203 } else {
9204 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
9205 slotId);
9206 }
9207
9208 return 0;
9209 }
9210
iccTransmitApduLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9211 int radio_1_6::iccTransmitApduLogicalChannelResponse(int slotId,
9212 int responseType, int serial, RIL_Errno e,
9213 void *response, size_t responseLen) {
9214 #if VDBG
9215 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
9216 #endif
9217
9218 if (radioService[slotId]->mRadioResponse != NULL) {
9219 RadioResponseInfo responseInfo = {};
9220 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
9221 responseLen);
9222
9223 Return<void> retStatus
9224 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
9225 responseInfo, result);
9226 radioService[slotId]->checkReturnStatus(retStatus);
9227 } else {
9228 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
9229 "== NULL", slotId);
9230 }
9231
9232 return 0;
9233 }
9234
nvReadItemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9235 int radio_1_6::nvReadItemResponse(int slotId,
9236 int responseType, int serial, RIL_Errno e,
9237 void *response, size_t responseLen) {
9238 #if VDBG
9239 RLOGD("nvReadItemResponse: serial %d", serial);
9240 #endif
9241
9242 if (radioService[slotId]->mRadioResponse != NULL) {
9243 RadioResponseInfo responseInfo = {};
9244 populateResponseInfo(responseInfo, serial, responseType, e);
9245 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
9246 responseInfo,
9247 convertCharPtrToHidlString((char *) response));
9248 radioService[slotId]->checkReturnStatus(retStatus);
9249 } else {
9250 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9251 }
9252
9253 return 0;
9254 }
9255
nvWriteItemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9256 int radio_1_6::nvWriteItemResponse(int slotId,
9257 int responseType, int serial, RIL_Errno e,
9258 void *response, size_t responseLen) {
9259 #if VDBG
9260 RLOGD("nvWriteItemResponse: serial %d", serial);
9261 #endif
9262
9263 if (radioService[slotId]->mRadioResponse != NULL) {
9264 RadioResponseInfo responseInfo = {};
9265 populateResponseInfo(responseInfo, serial, responseType, e);
9266 Return<void> retStatus
9267 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
9268 radioService[slotId]->checkReturnStatus(retStatus);
9269 } else {
9270 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9271 }
9272
9273 return 0;
9274 }
9275
nvWriteCdmaPrlResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9276 int radio_1_6::nvWriteCdmaPrlResponse(int slotId,
9277 int responseType, int serial, RIL_Errno e,
9278 void *response, size_t responseLen) {
9279 #if VDBG
9280 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
9281 #endif
9282
9283 if (radioService[slotId]->mRadioResponse != NULL) {
9284 RadioResponseInfo responseInfo = {};
9285 populateResponseInfo(responseInfo, serial, responseType, e);
9286 Return<void> retStatus
9287 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
9288 radioService[slotId]->checkReturnStatus(retStatus);
9289 } else {
9290 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9291 }
9292
9293 return 0;
9294 }
9295
nvResetConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9296 int radio_1_6::nvResetConfigResponse(int slotId,
9297 int responseType, int serial, RIL_Errno e,
9298 void *response, size_t responseLen) {
9299 #if VDBG
9300 RLOGD("nvResetConfigResponse: serial %d", serial);
9301 #endif
9302
9303 if (radioService[slotId]->mRadioResponse != NULL) {
9304 RadioResponseInfo responseInfo = {};
9305 populateResponseInfo(responseInfo, serial, responseType, e);
9306 Return<void> retStatus
9307 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
9308 radioService[slotId]->checkReturnStatus(retStatus);
9309 } else {
9310 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9311 }
9312
9313 return 0;
9314 }
9315
setUiccSubscriptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9316 int radio_1_6::setUiccSubscriptionResponse(int slotId,
9317 int responseType, int serial, RIL_Errno e,
9318 void *response, size_t responseLen) {
9319 #if VDBG
9320 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
9321 #endif
9322
9323 if (radioService[slotId]->mRadioResponse != NULL) {
9324 RadioResponseInfo responseInfo = {};
9325 populateResponseInfo(responseInfo, serial, responseType, e);
9326 Return<void> retStatus
9327 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
9328 radioService[slotId]->checkReturnStatus(retStatus);
9329 } else {
9330 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
9331 slotId);
9332 }
9333
9334 return 0;
9335 }
9336
setDataAllowedResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9337 int radio_1_6::setDataAllowedResponse(int slotId,
9338 int responseType, int serial, RIL_Errno e,
9339 void *response, size_t responseLen) {
9340 #if VDBG
9341 RLOGD("setDataAllowedResponse: serial %d", serial);
9342 #endif
9343
9344 if (radioService[slotId]->mRadioResponse != NULL) {
9345 RadioResponseInfo responseInfo = {};
9346 populateResponseInfo(responseInfo, serial, responseType, e);
9347 Return<void> retStatus
9348 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
9349 radioService[slotId]->checkReturnStatus(retStatus);
9350 } else {
9351 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9352 }
9353
9354 return 0;
9355 }
9356
getHardwareConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9357 int radio_1_6::getHardwareConfigResponse(int slotId,
9358 int responseType, int serial, RIL_Errno e,
9359 void *response, size_t responseLen) {
9360 #if VDBG
9361 RLOGD("getHardwareConfigResponse: serial %d", serial);
9362 #endif
9363
9364 if (radioService[slotId]->mRadioResponse != NULL) {
9365 RadioResponseInfo responseInfo = {};
9366 populateResponseInfo(responseInfo, serial, responseType, e);
9367
9368 hidl_vec<HardwareConfig> result;
9369 if ((response == NULL && responseLen != 0)
9370 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
9371 RLOGE("hardwareConfigChangedInd: invalid response");
9372 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9373 } else {
9374 convertRilHardwareConfigListToHal(response, responseLen, result);
9375 }
9376
9377 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
9378 responseInfo, result);
9379 radioService[slotId]->checkReturnStatus(retStatus);
9380 } else {
9381 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9382 }
9383
9384 return 0;
9385 }
9386
requestIccSimAuthenticationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9387 int radio_1_6::requestIccSimAuthenticationResponse(int slotId,
9388 int responseType, int serial, RIL_Errno e,
9389 void *response, size_t responseLen) {
9390 #if VDBG
9391 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
9392 #endif
9393
9394 if (radioService[slotId]->mRadioResponse != NULL) {
9395 RadioResponseInfo responseInfo = {};
9396 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
9397 responseLen);
9398
9399 Return<void> retStatus
9400 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
9401 responseInfo, result);
9402 radioService[slotId]->checkReturnStatus(retStatus);
9403 } else {
9404 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
9405 "== NULL", slotId);
9406 }
9407
9408 return 0;
9409 }
9410
setDataProfileResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9411 int radio_1_6::setDataProfileResponse(int slotId,
9412 int responseType, int serial, RIL_Errno e,
9413 void *response, size_t responseLen) {
9414 #if VDBG
9415 RLOGD("setDataProfileResponse: serial %d", serial);
9416 #endif
9417
9418 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
9419 RadioResponseInfo responseInfo = {};
9420 populateResponseInfo(responseInfo, serial, responseType, e);
9421 Return<void> retStatus
9422 = radioService[slotId]->mRadioResponseV1_5->setDataProfileResponse_1_5(
9423 responseInfo);
9424 } else if (radioService[slotId]->mRadioResponse != NULL) {
9425 RadioResponseInfo responseInfo = {};
9426 populateResponseInfo(responseInfo, serial, responseType, e);
9427 Return<void> retStatus
9428 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
9429 radioService[slotId]->checkReturnStatus(retStatus);
9430 } else {
9431 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9432 }
9433
9434 return 0;
9435 }
9436
requestShutdownResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9437 int radio_1_6::requestShutdownResponse(int slotId,
9438 int responseType, int serial, RIL_Errno e,
9439 void *response, size_t responseLen) {
9440 #if VDBG
9441 RLOGD("requestShutdownResponse: serial %d", serial);
9442 #endif
9443
9444 if (radioService[slotId]->mRadioResponse != NULL) {
9445 RadioResponseInfo responseInfo = {};
9446 populateResponseInfo(responseInfo, serial, responseType, e);
9447 Return<void> retStatus
9448 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
9449 radioService[slotId]->checkReturnStatus(retStatus);
9450 } else {
9451 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9452 }
9453
9454 return 0;
9455 }
9456
responseRadioCapability(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen,RadioCapability & rc)9457 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
9458 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
9459 populateResponseInfo(responseInfo, serial, responseType, e);
9460
9461 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
9462 RLOGE("responseRadioCapability: Invalid response");
9463 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9464 rc.logicalModemUuid = hidl_string();
9465 } else {
9466 convertRilRadioCapabilityToHal(response, responseLen, rc);
9467 }
9468 }
9469
getRadioCapabilityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9470 int radio_1_6::getRadioCapabilityResponse(int slotId,
9471 int responseType, int serial, RIL_Errno e,
9472 void *response, size_t responseLen) {
9473 #if VDBG
9474 RLOGD("getRadioCapabilityResponse: serial %d", serial);
9475 #endif
9476
9477 if (radioService[slotId]->mRadioResponse != NULL) {
9478 RadioResponseInfo responseInfo = {};
9479 RadioCapability result = {};
9480 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
9481 result);
9482 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
9483 responseInfo, result);
9484 radioService[slotId]->checkReturnStatus(retStatus);
9485 } else {
9486 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9487 }
9488
9489 return 0;
9490 }
9491
setRadioCapabilityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9492 int radio_1_6::setRadioCapabilityResponse(int slotId,
9493 int responseType, int serial, RIL_Errno e,
9494 void *response, size_t responseLen) {
9495 #if VDBG
9496 RLOGD("setRadioCapabilityResponse: serial %d", serial);
9497 #endif
9498
9499 if (radioService[slotId]->mRadioResponse != NULL) {
9500 RadioResponseInfo responseInfo = {};
9501 RadioCapability result = {};
9502 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
9503 result);
9504 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
9505 responseInfo, result);
9506 radioService[slotId]->checkReturnStatus(retStatus);
9507 } else {
9508 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9509 }
9510
9511 return 0;
9512 }
9513
responseLceStatusInfo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)9514 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
9515 RIL_Errno e, void *response, size_t responseLen) {
9516 populateResponseInfo(responseInfo, serial, responseType, e);
9517 LceStatusInfo result = {};
9518
9519 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
9520 RLOGE("Invalid response: NULL");
9521 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9522 } else {
9523 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
9524 result.lceStatus = (LceStatus) resp->lce_status;
9525 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
9526 }
9527 return result;
9528 }
9529
startLceServiceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9530 int radio_1_6::startLceServiceResponse(int slotId,
9531 int responseType, int serial, RIL_Errno e,
9532 void *response, size_t responseLen) {
9533 #if VDBG
9534 RLOGD("startLceServiceResponse: serial %d", serial);
9535 #endif
9536
9537 if (radioService[slotId]->mRadioResponse != NULL) {
9538 RadioResponseInfo responseInfo = {};
9539 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
9540 response, responseLen);
9541
9542 Return<void> retStatus
9543 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
9544 result);
9545 radioService[slotId]->checkReturnStatus(retStatus);
9546 } else {
9547 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9548 }
9549
9550 return 0;
9551 }
9552
stopLceServiceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9553 int radio_1_6::stopLceServiceResponse(int slotId,
9554 int responseType, int serial, RIL_Errno e,
9555 void *response, size_t responseLen) {
9556 #if VDBG
9557 RLOGD("stopLceServiceResponse: serial %d", serial);
9558 #endif
9559
9560 if (radioService[slotId]->mRadioResponse != NULL) {
9561 RadioResponseInfo responseInfo = {};
9562 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
9563 response, responseLen);
9564
9565 Return<void> retStatus
9566 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
9567 result);
9568 radioService[slotId]->checkReturnStatus(retStatus);
9569 } else {
9570 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9571 }
9572
9573 return 0;
9574 }
9575
pullLceDataResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9576 int radio_1_6::pullLceDataResponse(int slotId,
9577 int responseType, int serial, RIL_Errno e,
9578 void *response, size_t responseLen) {
9579 #if VDBG
9580 RLOGD("pullLceDataResponse: serial %d", serial);
9581 #endif
9582
9583 if (radioService[slotId]->mRadioResponse != NULL) {
9584 RadioResponseInfo responseInfo = {};
9585 populateResponseInfo(responseInfo, serial, responseType, e);
9586
9587 LceDataInfo result = {};
9588 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
9589 RLOGE("pullLceDataResponse: Invalid response");
9590 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9591 } else {
9592 convertRilLceDataInfoToHal(response, responseLen, result);
9593 }
9594
9595 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
9596 responseInfo, result);
9597 radioService[slotId]->checkReturnStatus(retStatus);
9598 } else {
9599 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9600 }
9601
9602 return 0;
9603 }
9604
getModemActivityInfoResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9605 int radio_1_6::getModemActivityInfoResponse(int slotId,
9606 int responseType, int serial, RIL_Errno e,
9607 void *response, size_t responseLen) {
9608 #if VDBG
9609 RLOGD("getModemActivityInfoResponse: serial %d", serial);
9610 #endif
9611
9612 if (radioService[slotId]->mRadioResponse != NULL) {
9613 RadioResponseInfo responseInfo = {};
9614 populateResponseInfo(responseInfo, serial, responseType, e);
9615 ActivityStatsInfo info;
9616 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
9617 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
9618 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9619 } else {
9620 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
9621 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
9622 info.idleModeTimeMs = resp->idle_mode_time_ms;
9623 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
9624 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
9625 }
9626 info.rxModeTimeMs = resp->rx_mode_time_ms;
9627 }
9628
9629 Return<void> retStatus
9630 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
9631 info);
9632 radioService[slotId]->checkReturnStatus(retStatus);
9633 } else {
9634 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
9635 slotId);
9636 }
9637
9638 return 0;
9639 }
9640
setAllowedCarriersResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9641 int radio_1_6::setAllowedCarriersResponse(int slotId,
9642 int responseType, int serial, RIL_Errno e,
9643 void *response, size_t responseLen) {
9644 #if VDBG
9645 RLOGD("setAllowedCarriersResponse: serial %d", serial);
9646 #endif
9647 RadioResponseInfo responseInfo = {};
9648 populateResponseInfo(responseInfo, serial, responseType, e);
9649
9650 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9651 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
9652 ->setAllowedCarriersResponse_1_4(responseInfo);
9653 radioService[slotId]->checkReturnStatus(retStatus);
9654 } else if (radioService[slotId]->mRadioResponse != NULL) {
9655 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
9656 Return<void> retStatus = radioService[slotId]->mRadioResponse
9657 ->setAllowedCarriersResponse(responseInfo, ret);
9658 radioService[slotId]->checkReturnStatus(retStatus);
9659 } else {
9660 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9661 }
9662
9663 return 0;
9664 }
9665
prepareCarrierRestrictionsResponse(hidl_vec<Carrier> & allowedCarriers,hidl_vec<Carrier> & excludedCarriers,bool & allAllowed,const RIL_CarrierRestrictions * pCr)9666 void prepareCarrierRestrictionsResponse(hidl_vec<Carrier>& allowedCarriers,
9667 hidl_vec<Carrier>& excludedCarriers,
9668 bool& allAllowed,
9669 const RIL_CarrierRestrictions* pCr) {
9670 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
9671 allAllowed = false;
9672 }
9673 allowedCarriers.resize(pCr->len_allowed_carriers);
9674 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
9675 RIL_Carrier *carrier = pCr->allowed_carriers + i;
9676 allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
9677 allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
9678 allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
9679 allowedCarriers[i].matchData =
9680 convertCharPtrToHidlString(carrier->match_data);
9681 }
9682
9683 excludedCarriers.resize(pCr->len_excluded_carriers);
9684 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
9685 RIL_Carrier *carrier = pCr->excluded_carriers + i;
9686 excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
9687 excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
9688 excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
9689 excludedCarriers[i].matchData =
9690 convertCharPtrToHidlString(carrier->match_data);
9691 }
9692 }
9693
getAllowedCarriersResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9694 int radio_1_6::getAllowedCarriersResponse(int slotId,
9695 int responseType, int serial, RIL_Errno e,
9696 void *response, size_t responseLen) {
9697 #if VDBG
9698 RLOGD("getAllowedCarriersResponse: serial %d", serial);
9699 #endif
9700 RadioResponseInfo responseInfo = {};
9701 populateResponseInfo(responseInfo, serial, responseType, e);
9702
9703 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9704 V1_4::CarrierRestrictionsWithPriority carrierInfo = {};
9705 V1_4::SimLockMultiSimPolicy multiSimPolicy =
9706 V1_4::SimLockMultiSimPolicy::NO_MULTISIM_POLICY;
9707 bool allAllowed = true;
9708
9709 if (response == NULL) {
9710 #if VDBG
9711 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
9712 #endif
9713 carrierInfo.allowedCarriers.resize(0);
9714 carrierInfo.excludedCarriers.resize(0);
9715 carrierInfo.allowedCarriersPrioritized = false;
9716 } else if (responseLen != sizeof(RIL_CarrierRestrictionsWithPriority)) {
9717 RLOGE("getAllowedCarriersResponse Invalid response");
9718 if (e == RIL_E_SUCCESS) {
9719 responseInfo.error = RadioError::INVALID_RESPONSE;
9720 }
9721 } else {
9722 RIL_CarrierRestrictionsWithPriority *pCrExt =
9723 (RIL_CarrierRestrictionsWithPriority *)response;
9724
9725 // Convert into the structure used in IRadio 1.0 to re-use existing code
9726 RIL_CarrierRestrictions cr = {};
9727 cr.len_allowed_carriers = pCrExt->len_allowed_carriers;
9728 cr.len_excluded_carriers = pCrExt->len_excluded_carriers;
9729 cr.allowed_carriers = pCrExt->allowed_carriers;
9730 cr.excluded_carriers = pCrExt->excluded_carriers;
9731 prepareCarrierRestrictionsResponse(carrierInfo.allowedCarriers,
9732 carrierInfo.excludedCarriers, allAllowed, &cr);
9733
9734 carrierInfo.allowedCarriersPrioritized = (bool)pCrExt->allowedCarriersPrioritized;
9735 multiSimPolicy = (V1_4::SimLockMultiSimPolicy)pCrExt->multiSimPolicy;
9736 }
9737
9738 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
9739 ->getAllowedCarriersResponse_1_4(responseInfo, carrierInfo, multiSimPolicy);
9740 radioService[slotId]->checkReturnStatus(retStatus);
9741 } else if (radioService[slotId]->mRadioResponse != NULL) {
9742 CarrierRestrictions carrierInfo = {};
9743 bool allAllowed = true;
9744 if (response == NULL) {
9745 #if VDBG
9746 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
9747 #endif
9748 carrierInfo.allowedCarriers.resize(0);
9749 carrierInfo.excludedCarriers.resize(0);
9750 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
9751 RLOGE("getAllowedCarriersResponse Invalid response");
9752 if (e == RIL_E_SUCCESS) {
9753 responseInfo.error = RadioError::INVALID_RESPONSE;
9754 }
9755 } else {
9756 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
9757 prepareCarrierRestrictionsResponse(carrierInfo.allowedCarriers,
9758 carrierInfo.excludedCarriers, allAllowed, pCr);
9759 }
9760
9761 Return<void> retStatus = radioService[slotId]->mRadioResponse
9762 ->getAllowedCarriersResponse(responseInfo, allAllowed, carrierInfo);
9763 radioService[slotId]->checkReturnStatus(retStatus);
9764 } else {
9765 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9766 }
9767
9768 return 0;
9769 }
9770
sendDeviceStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)9771 int radio_1_6::sendDeviceStateResponse(int slotId,
9772 int responseType, int serial, RIL_Errno e,
9773 void *response, size_t responselen) {
9774 #if VDBG
9775 RLOGD("sendDeviceStateResponse: serial %d", serial);
9776 #endif
9777
9778 if (radioService[slotId]->mRadioResponse != NULL) {
9779 RadioResponseInfo responseInfo = {};
9780 populateResponseInfo(responseInfo, serial, responseType, e);
9781 Return<void> retStatus
9782 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
9783 radioService[slotId]->checkReturnStatus(retStatus);
9784 } else {
9785 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9786 }
9787
9788 return 0;
9789 }
9790
setCarrierInfoForImsiEncryptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9791 int radio_1_6::setCarrierInfoForImsiEncryptionResponse(int slotId,
9792 int responseType, int serial, RIL_Errno e,
9793 void *response, size_t responseLen) {
9794 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
9795 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
9796 RadioResponseInfo responseInfo = {};
9797 populateResponseInfo(responseInfo, serial, responseType, e);
9798 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
9799 setCarrierInfoForImsiEncryptionResponse(responseInfo);
9800 radioService[slotId]->checkReturnStatus(retStatus);
9801 } else {
9802 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponseV1_1 == "
9803 "NULL", slotId);
9804 }
9805 return 0;
9806 }
9807
setIndicationFilterResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)9808 int radio_1_6::setIndicationFilterResponse(int slotId,
9809 int responseType, int serial, RIL_Errno e,
9810 void *response, size_t responselen) {
9811 #if VDBG
9812 RLOGD("setIndicationFilterResponse: serial %d", serial);
9813 #endif
9814 RadioResponseInfo responseInfo = {};
9815 populateResponseInfo(responseInfo, serial, responseType, e);
9816
9817 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
9818 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
9819 ->setIndicationFilterResponse_1_5(responseInfo);
9820 radioService[slotId]->checkReturnStatus(retStatus);
9821 } else if (radioService[slotId]->mRadioResponse != NULL) {
9822 Return<void> retStatus = radioService[slotId]->mRadioResponse
9823 ->setIndicationFilterResponse(responseInfo);
9824 radioService[slotId]->checkReturnStatus(retStatus);
9825 } else {
9826 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9827 }
9828
9829 return 0;
9830 }
9831
setSimCardPowerResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9832 int radio_1_6::setSimCardPowerResponse(int slotId,
9833 int responseType, int serial, RIL_Errno e,
9834 void *response, size_t responseLen) {
9835 #if VDBG
9836 RLOGD("setSimCardPowerResponse: serial %d", serial);
9837 #endif
9838
9839 if (radioService[slotId]->mRadioResponse != NULL
9840 || radioService[slotId]->mRadioResponseV1_1 != NULL
9841 || radioService[slotId]->mRadioResponseV1_6 != NULL) {
9842 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
9843 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo = {};
9844 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
9845 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6->
9846 setSimCardPowerResponse_1_6(responseInfo);
9847 radioService[slotId]->checkReturnStatus(retStatus);
9848 } else if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
9849 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_6 == NULL", slotId);
9850 RadioResponseInfo responseInfo = {};
9851 populateResponseInfo(responseInfo, serial, responseType, e);
9852 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
9853 setSimCardPowerResponse_1_1(responseInfo);
9854 radioService[slotId]->checkReturnStatus(retStatus);
9855 } else {
9856 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_6 and V1_1 == NULL",
9857 slotId);
9858 RadioResponseInfo responseInfo = {};
9859 populateResponseInfo(responseInfo, serial, responseType, e);
9860 Return<void> retStatus = radioService[slotId]->mRadioResponse
9861 ->setSimCardPowerResponse(responseInfo);
9862 radioService[slotId]->checkReturnStatus(retStatus);
9863 }
9864 } else {
9865 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL && "
9866 "radioService[%d]->mRadioResponseV1_1 and V1_6 == NULL", slotId, slotId);
9867 }
9868 return 0;
9869 }
9870
startNetworkScanResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9871 int radio_1_6::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
9872 void *response, size_t responseLen) {
9873 #if VDBG
9874 RLOGD("startNetworkScanResponse: serial %d", serial);
9875 #endif
9876
9877 if (radioService[slotId]->mRadioResponseV1_1 != NULL ||
9878 radioService[slotId]->mRadioResponseV1_2 != NULL ||
9879 radioService[slotId]->mRadioResponseV1_4 != NULL ||
9880 radioService[slotId]->mRadioResponseV1_6 != NULL) {
9881 RadioResponseInfo responseInfo = {};
9882 populateResponseInfo(responseInfo, serial, responseType, e);
9883
9884 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
9885 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
9886 ->startNetworkScanResponse_1_5(responseInfo);
9887 radioService[slotId]->checkReturnStatus(retStatus);
9888 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9889 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
9890 ->startNetworkScanResponse_1_4(responseInfo);
9891 radioService[slotId]->checkReturnStatus(retStatus);
9892 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
9893 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2
9894 ->startNetworkScanResponse(responseInfo);
9895 radioService[slotId]->checkReturnStatus(retStatus);
9896 } else if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
9897 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1
9898 ->startNetworkScanResponse(responseInfo);
9899 radioService[slotId]->checkReturnStatus(retStatus);
9900 } else {
9901 RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL or "
9902 "radioService[%d]->mRadioResponseV1_4 == NULL", slotId, slotId);
9903 }
9904 }
9905
9906 return 0;
9907 }
9908
stopNetworkScanResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9909 int radio_1_6::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
9910 void *response, size_t responseLen) {
9911 #if VDBG
9912 RLOGD("stopNetworkScanResponse: serial %d", serial);
9913 #endif
9914
9915 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
9916 RadioResponseInfo responseInfo = {};
9917 populateResponseInfo(responseInfo, serial, responseType, e);
9918 Return<void> retStatus
9919 = radioService[slotId]->mRadioResponseV1_1->stopNetworkScanResponse(responseInfo);
9920 radioService[slotId]->checkReturnStatus(retStatus);
9921 } else {
9922 RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
9923 }
9924
9925 return 0;
9926 }
9927
emergencyDialResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9928 int radio_1_6::emergencyDialResponse(int slotId, int responseType, int serial, RIL_Errno e,
9929 void *response, size_t responseLen) {
9930 #if VDBG
9931 RLOGD("emergencyDialResponse: serial %d", serial);
9932 #endif
9933
9934 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9935 RadioResponseInfo responseInfo = {};
9936 populateResponseInfo(responseInfo, serial, responseType, e);
9937 Return<void> retStatus
9938 = radioService[slotId]->mRadioResponseV1_4->emergencyDialResponse(responseInfo);
9939 radioService[slotId]->checkReturnStatus(retStatus);
9940 } else {
9941 RLOGE("emergencyDialResponse: radioService[%d]->mRadioResponseV1_4 == NULL", slotId);
9942 }
9943 return 0;
9944 }
9945
convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus * rilStatus,V1_1::KeepaliveStatus & halStatus)9946 void convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus *rilStatus,
9947 V1_1::KeepaliveStatus& halStatus) {
9948 halStatus.sessionHandle = rilStatus->sessionHandle;
9949 halStatus.code = static_cast<V1_1::KeepaliveStatusCode>(rilStatus->code);
9950 }
9951
startKeepaliveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9952 int radio_1_6::startKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
9953 void *response, size_t responseLen) {
9954 #if VDBG
9955 RLOGD("%s(): %d", __FUNCTION__, serial);
9956 #endif
9957 RadioResponseInfo responseInfo = {};
9958 populateResponseInfo(responseInfo, serial, responseType, e);
9959
9960 // If we don't have a radio service, there's nothing we can do
9961 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
9962 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
9963 return 0;
9964 }
9965
9966 V1_1::KeepaliveStatus ks = {};
9967 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
9968 RLOGE("%s: invalid response - %d", __FUNCTION__, static_cast<int>(e));
9969 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9970 } else {
9971 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
9972 }
9973
9974 Return<void> retStatus =
9975 radioService[slotId]->mRadioResponseV1_1->startKeepaliveResponse(responseInfo, ks);
9976 radioService[slotId]->checkReturnStatus(retStatus);
9977 return 0;
9978 }
9979
stopKeepaliveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9980 int radio_1_6::stopKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
9981 void *response, size_t responseLen) {
9982 #if VDBG
9983 RLOGD("%s(): %d", __FUNCTION__, serial);
9984 #endif
9985 RadioResponseInfo responseInfo = {};
9986 populateResponseInfo(responseInfo, serial, responseType, e);
9987
9988 // If we don't have a radio service, there's nothing we can do
9989 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
9990 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
9991 return 0;
9992 }
9993
9994 Return<void> retStatus =
9995 radioService[slotId]->mRadioResponseV1_1->stopKeepaliveResponse(responseInfo);
9996 radioService[slotId]->checkReturnStatus(retStatus);
9997 return 0;
9998 }
9999
getModemStackStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10000 int radio_1_6::getModemStackStatusResponse(int slotId, int responseType, int serial, RIL_Errno e,
10001 void *response, size_t responseLen) {
10002 #if VDBG
10003 RLOGD("%s(): %d", __FUNCTION__, serial);
10004 #endif
10005 RadioResponseInfo responseInfo = {};
10006 populateResponseInfo(responseInfo, serial, responseType, e);
10007
10008 // If we don't have a radio service, there's nothing we can do
10009 if (radioService[slotId]->mRadioResponseV1_3 == NULL) {
10010 RLOGE("%s: radioService[%d]->mRadioResponseV1_3 == NULL", __FUNCTION__, slotId);
10011 return 0;
10012 }
10013
10014 Return<void> retStatus =
10015 radioService[slotId]->mRadioResponseV1_3->getModemStackStatusResponse(
10016 responseInfo, true);
10017 radioService[slotId]->checkReturnStatus(retStatus);
10018 return 0;
10019 }
10020
enableModemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10021 int radio_1_6::enableModemResponse(int slotId, int responseType, int serial, RIL_Errno e,
10022 void *response, size_t responseLen) {
10023 #if VDBG
10024 RLOGD("%s(): %d", __FUNCTION__, serial);
10025 #endif
10026 RadioResponseInfo responseInfo = {};
10027 populateResponseInfo(responseInfo, serial, responseType, e);
10028
10029 // If we don't have a radio service, there's nothing we can do
10030 if (radioService[slotId]->mRadioResponseV1_3 == NULL) {
10031 RLOGE("%s: radioService[%d]->mRadioResponseV1_3 == NULL", __FUNCTION__, slotId);
10032 return 0;
10033 }
10034
10035 Return<void> retStatus =
10036 radioService[slotId]->mRadioResponseV1_3->enableModemResponse(responseInfo);
10037 radioService[slotId]->checkReturnStatus(retStatus);
10038 return 0;
10039 }
10040
sendRequestRawResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10041 int radio_1_6::sendRequestRawResponse(int slotId,
10042 int responseType, int serial, RIL_Errno e,
10043 void *response, size_t responseLen) {
10044 #if VDBG
10045 RLOGD("sendRequestRawResponse: serial %d", serial);
10046 #endif
10047
10048 if (!kOemHookEnabled) return 0;
10049
10050 if (oemHookService[slotId]->mOemHookResponse != NULL) {
10051 RadioResponseInfo responseInfo = {};
10052 populateResponseInfo(responseInfo, serial, responseType, e);
10053 hidl_vec<uint8_t> data;
10054
10055 if (response == NULL) {
10056 RLOGE("sendRequestRawResponse: Invalid response");
10057 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
10058 } else {
10059 data.setToExternal((uint8_t *) response, responseLen);
10060 }
10061 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
10062 sendRequestRawResponse(responseInfo, data);
10063 checkReturnStatus(slotId, retStatus, false);
10064 } else {
10065 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
10066 slotId);
10067 }
10068
10069 return 0;
10070 }
10071
sendRequestStringsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10072 int radio_1_6::sendRequestStringsResponse(int slotId,
10073 int responseType, int serial, RIL_Errno e,
10074 void *response, size_t responseLen) {
10075 #if VDBG
10076 RLOGD("sendRequestStringsResponse: serial %d", serial);
10077 #endif
10078
10079 if (!kOemHookEnabled) return 0;
10080
10081 if (oemHookService[slotId]->mOemHookResponse != NULL) {
10082 RadioResponseInfo responseInfo = {};
10083 populateResponseInfo(responseInfo, serial, responseType, e);
10084 hidl_vec<hidl_string> data;
10085
10086 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
10087 RLOGE("sendRequestStringsResponse Invalid response: NULL");
10088 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
10089 } else {
10090 char **resp = (char **) response;
10091 int numStrings = responseLen / sizeof(char *);
10092 data.resize(numStrings);
10093 for (int i = 0; i < numStrings; i++) {
10094 data[i] = convertCharPtrToHidlString(resp[i]);
10095 }
10096 }
10097 Return<void> retStatus
10098 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
10099 responseInfo, data);
10100 checkReturnStatus(slotId, retStatus, false);
10101 } else {
10102 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
10103 "NULL", slotId);
10104 }
10105
10106 return 0;
10107 }
10108
setSystemSelectionChannelsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10109 int radio_1_6::setSystemSelectionChannelsResponse(int slotId, int responseType, int serial,
10110 RIL_Errno e, void* response, size_t responseLen) {
10111 #if VDBG
10112 RLOGD("setSystemSelectionChannelsResponse: serial %d", serial);
10113 #endif
10114 RadioResponseInfo responseInfo = {};
10115 populateResponseInfo(responseInfo, serial, responseType, e);
10116
10117 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10118 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10119 ->setSystemSelectionChannelsResponse_1_5(responseInfo);
10120 radioService[slotId]->checkReturnStatus(retStatus);
10121 } else if (radioService[slotId]->mRadioResponseV1_3 != NULL) {
10122 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_3
10123 ->setSystemSelectionChannelsResponse(responseInfo);
10124 radioService[slotId]->checkReturnStatus(retStatus);
10125 } else {
10126 RLOGE("setSystemSelectionChannelsResponse: radioService[%d]->mRadioResponse == NULL",
10127 slotId);
10128 }
10129
10130 return 0;
10131 }
10132
getSystemSelectionChannelsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10133 int radio_1_6::getSystemSelectionChannelsResponse(int slotId, int responseType, int serial,
10134 RIL_Errno e, void* response, size_t responseLen) {
10135 #if VDBG
10136 RLOGD("getSystemSelectionChannelsResponse: serial %d", serial);
10137 #endif
10138 V1_6::RadioResponseInfo responseInfo = {};
10139 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10140
10141 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10142 hidl_vec<::android::hardware::radio::V1_5::RadioAccessSpecifier> ret;
10143 Return<void> retStatus =
10144 radioService[slotId]
10145 ->mRadioResponseV1_6->getSystemSelectionChannelsResponse(
10146 responseInfo, ret);
10147 radioService[slotId]->checkReturnStatus(retStatus);
10148 } else {
10149 RLOGE("getSystemSelectionChannelsResponse: radioService[%d]->mRadioResponse == NULL",
10150 slotId);
10151 }
10152
10153 return 0;
10154 }
10155
setSignalStrengthReportingCriteriaResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10156 int radio_1_6::setSignalStrengthReportingCriteriaResponse(int slotId, int responseType, int serial,
10157 RIL_Errno e, void* response, size_t responseLen) {
10158 #if VDBG
10159 RLOGD("setSignalStrengthReportingCriteriaResponse: serial %d", serial);
10160 #endif
10161 RadioResponseInfo responseInfo = {};
10162 populateResponseInfo(responseInfo, serial, responseType, e);
10163
10164 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10165 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10166 ->setSignalStrengthReportingCriteriaResponse_1_5(responseInfo);
10167 radioService[slotId]->checkReturnStatus(retStatus);
10168 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
10169 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2
10170 ->setSignalStrengthReportingCriteriaResponse(responseInfo);
10171 radioService[slotId]->checkReturnStatus(retStatus);
10172 } else {
10173 RLOGE("setSignalStrengthReportingCriteriaResponse: radioService[%d]->mRadioResponse "
10174 "== NULL", slotId);
10175 }
10176
10177 return 0;
10178 }
10179
setLinkCapacityReportingCriteriaResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10180 int radio_1_6::setLinkCapacityReportingCriteriaResponse(int slotId, int responseType, int serial,
10181 RIL_Errno e, void* response, size_t responseLen) {
10182 #if VDBG
10183 RLOGD("setLinkCapacityReportingCriteriaResponse: serial %d", serial);
10184 #endif
10185 RadioResponseInfo responseInfo = {};
10186 populateResponseInfo(responseInfo, serial, responseType, e);
10187
10188 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10189 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10190 ->setLinkCapacityReportingCriteriaResponse_1_5(responseInfo);
10191 radioService[slotId]->checkReturnStatus(retStatus);
10192 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
10193 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2
10194 ->setLinkCapacityReportingCriteriaResponse(responseInfo);
10195 radioService[slotId]->checkReturnStatus(retStatus);
10196 } else {
10197 RLOGE("setLinkCapacityReportingCriteriaResponse: radioService[%d]->mRadioResponse "
10198 "== NULL", slotId);
10199 }
10200
10201 return 0;
10202 }
10203
enableUiccApplicationsResponse(int slotId,int responseType,int serial,RIL_Errno e,void *,size_t responseLen)10204 int radio_1_6::enableUiccApplicationsResponse(int slotId, int responseType, int serial,
10205 RIL_Errno e, void* /* response */, size_t responseLen) {
10206 #if VDBG
10207 RLOGD("%s(): %d", __FUNCTION__, serial);
10208 #endif
10209 RadioResponseInfo responseInfo = {};
10210 populateResponseInfo(responseInfo, serial, responseType, e);
10211
10212 // If we don't have a radio service, there's nothing we can do
10213 if (radioService[slotId]->mRadioResponseV1_5 == NULL) {
10214 RLOGE("%s: radioService[%d]->mRadioResponseV1_5 == NULL", __FUNCTION__, slotId);
10215 return 0;
10216 }
10217
10218 Return<void> retStatus =
10219 radioService[slotId]->mRadioResponseV1_5->enableUiccApplicationsResponse(
10220 responseInfo);
10221 radioService[slotId]->checkReturnStatus(retStatus);
10222 return 0;
10223 }
10224
areUiccApplicationsEnabledResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10225 int radio_1_6::areUiccApplicationsEnabledResponse(int slotId, int responseType, int serial,
10226 RIL_Errno e, void* response, size_t responseLen) {
10227 #if VDBG
10228 RLOGD("%s(): %d", __FUNCTION__, serial);
10229 #endif
10230 RadioResponseInfo responseInfo = {};
10231 populateResponseInfo(responseInfo, serial, responseType, e);
10232
10233 // If we don't have a radio service, there's nothing we can do
10234 if (radioService[slotId]->mRadioResponseV1_5 == NULL) {
10235 RLOGE("%s: radioService[%d]->mRadioResponseV1_5 == NULL", __FUNCTION__, slotId);
10236 return 0;
10237 }
10238
10239 bool enable = false;
10240 if (response == NULL || responseLen != sizeof(bool)) {
10241 RLOGE("isSimDetachedFromNetwork Invalid response.");
10242 } else {
10243 enable = (*((bool *) response));
10244 }
10245
10246 Return<void> retStatus =
10247 radioService[slotId]->mRadioResponseV1_5->areUiccApplicationsEnabledResponse(
10248 responseInfo, enable);
10249 radioService[slotId]->checkReturnStatus(retStatus);
10250 return 0;
10251 }
10252
getBarringInfoResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)10253 int radio_1_6::getBarringInfoResponse(int slotId,
10254 int responseType, int serial, RIL_Errno e,
10255 void *response, size_t responselen) {
10256 #if VDBG
10257 RLOGD("getBarringInfoResponse: serial %d", serial);
10258 #endif
10259
10260 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10261 RadioResponseInfo responseInfo = {};
10262 populateResponseInfo(responseInfo, serial, responseType, e);
10263 ::android::hardware::radio::V1_5::CellIdentity cellIdentity;
10264 hidl_vec<::android::hardware::radio::V1_5::BarringInfo> barringInfos = {};
10265
10266 if (response == NULL) { /* data for vts */
10267 V1_5::BarringInfo barringInfo = {};
10268 barringInfo.serviceType = V1_5::BarringInfo::ServiceType::CS_SERVICE;
10269 barringInfo.barringType = V1_5::BarringInfo::BarringType::NONE;
10270
10271 V1_5::CellIdentityLte cellIdentityLte = {};
10272 cellIdentity.lte(cellIdentityLte);
10273 barringInfos.resize(1);
10274 barringInfos[0] = barringInfo;
10275
10276 Return<void> retStatus
10277 = radioService[slotId]->mRadioResponseV1_5->
10278 getBarringInfoResponse(responseInfo, cellIdentity, barringInfos);
10279 radioService[slotId]->checkReturnStatus(retStatus);
10280 } else {
10281 RLOGE("getBarringInfoResponse: radioService[%d]->mRadioResponse == NULL",
10282 slotId);
10283 }
10284 }
10285 return 0;
10286 }
10287
sendCdmaSmsExpectMoreResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10288 int radio_1_6::sendCdmaSmsExpectMoreResponse(int slotId, int responseType, int serial, RIL_Errno e,
10289 void *response, size_t responseLen) {
10290 #if VDBG
10291 RLOGD("sendCdmaSmsExpectMoreResponse: serial %d", serial);
10292 #endif
10293
10294 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10295 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
10296 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e,
10297 response, responseLen);
10298
10299 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
10300 ->sendCdmaSmsExpectMoreResponse_1_6(responseInfo_1_6, result);
10301 radioService[slotId]->checkReturnStatus(retStatus);
10302 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10303 RadioResponseInfo responseInfo = {};
10304 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
10305 responseLen);
10306
10307 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10308 ->sendCdmaSmsExpectMoreResponse(responseInfo, result);
10309 radioService[slotId]->checkReturnStatus(retStatus);
10310 } else {
10311 RLOGE("sendCdmaSmsExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10312 }
10313
10314 return 0;
10315 }
10316
supplySimDepersonalizationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10317 int radio_1_6::supplySimDepersonalizationResponse(int slotId, int responseType, int serial,
10318 RIL_Errno e, void *response, size_t responseLen) {
10319 #if VDBG
10320 RLOGD("supplySimDepersonalizationResponse: serial %d", serial);
10321 #endif
10322
10323 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10324 RadioResponseInfo responseInfo = {};
10325 int persoType = -1, remainingRetries = -1;
10326 int numInts = responseLen / sizeof(int);
10327 if (response == NULL || numInts != 2) {
10328 RLOGE("getClirResponse Invalid response: NULL");
10329 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
10330 } else {
10331 int *pInt = (int *) response;
10332 persoType = pInt[0];
10333 remainingRetries = pInt[1];
10334 }
10335 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10336 ->supplySimDepersonalizationResponse(responseInfo, (V1_5::PersoSubstate) persoType,
10337 remainingRetries);
10338 radioService[slotId]->checkReturnStatus(retStatus);
10339 } else {
10340 RLOGE("supplySimDepersonalizationResponse: radioService[%d]->mRadioResponseV1_5 == "
10341 "NULL", slotId);
10342 }
10343
10344 return 0;
10345 }
10346
setNrDualConnectivityStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void *,size_t responseLen)10347 int radio_1_6::setNrDualConnectivityStateResponse(int slotId, int responseType, int serial,
10348 RIL_Errno e, void* /* response */, size_t responseLen) {
10349 #if VDBG
10350 RLOGD("%s(): %d", __FUNCTION__, serial);
10351 #endif
10352 V1_6::RadioResponseInfo responseInfo = {};
10353 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10354
10355 // If we don't have a radio service, there's nothing we can do
10356 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10357 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10358 return 0;
10359 }
10360
10361 Return<void> retStatus =
10362 radioService[slotId]->mRadioResponseV1_6->setNrDualConnectivityStateResponse(
10363 responseInfo);
10364 radioService[slotId]->checkReturnStatus(retStatus);
10365 return 0;
10366 }
10367
isNrDualConnectivityEnabledResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10368 int radio_1_6::isNrDualConnectivityEnabledResponse(int slotId, int responseType, int serial,
10369 RIL_Errno e, void* response, size_t responseLen) {
10370 #if VDBG
10371 RLOGD("%s(): %d", __FUNCTION__, serial);
10372 #endif
10373 V1_6::RadioResponseInfo responseInfo = {};
10374 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10375
10376 // If we don't have a radio service, there's nothing we can do
10377 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10378 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10379 return 0;
10380 }
10381
10382 bool enable = false;
10383 if (response == NULL || responseLen != sizeof(bool)) {
10384 RLOGE("isNrDualConnectivityEnabledResponseInvalid response.");
10385 } else {
10386 enable = (*((bool *) response));
10387 }
10388
10389 Return<void> retStatus =
10390 radioService[slotId]->mRadioResponseV1_6->isNrDualConnectivityEnabledResponse(
10391 responseInfo, enable);
10392 radioService[slotId]->checkReturnStatus(retStatus);
10393 return 0;
10394 }
10395
allocatePduSessionIdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10396 int radio_1_6::allocatePduSessionIdResponse(int slotId, int responseType, int serial,
10397 RIL_Errno e, void* response, size_t responseLen) {
10398 #if VDBG
10399 RLOGD("%s(): %d", __FUNCTION__, serial);
10400 #endif
10401 // If we don't have a radio service, there's nothing we can do
10402 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10403 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10404 return 0;
10405 }
10406 V1_6::RadioResponseInfo responseInfo = {};
10407 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10408
10409 Return<void> retStatus =
10410 radioService[slotId]->mRadioResponseV1_6->allocatePduSessionIdResponse(responseInfo, -1);
10411 radioService[slotId]->checkReturnStatus(retStatus);
10412 return 0;
10413 }
10414
releasePduSessionIdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10415 int radio_1_6::releasePduSessionIdResponse(int slotId, int responseType, int serial,
10416 RIL_Errno e, void* response, size_t responseLen) {
10417 #if VDBG
10418 RLOGD("%s(): %d", __FUNCTION__, serial);
10419 #endif
10420 // If we don't have a radio service, there's nothing we can do
10421 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10422 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10423 return 0;
10424 }
10425
10426 V1_6::RadioResponseInfo responseInfo = {};
10427 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10428
10429 Return<void> retStatus =
10430 radioService[slotId]->mRadioResponseV1_6->releasePduSessionIdResponse(responseInfo);
10431 radioService[slotId]->checkReturnStatus(retStatus);
10432 return 0;
10433 }
10434
startHandoverResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10435 int radio_1_6::startHandoverResponse(int slotId, int responseType, int serial,
10436 RIL_Errno e, void* response, size_t responseLen) {
10437 // If we don't have a radio service, there's nothing we can do
10438 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10439 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10440 return 0;
10441 }
10442 V1_6::RadioResponseInfo responseInfo = {};
10443 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10444
10445 Return<void> retStatus =
10446 radioService[slotId]->mRadioResponseV1_6->startHandoverResponse(responseInfo);
10447
10448 #if VDBG
10449 RLOGD("%s(): %d", __FUNCTION__, serial);
10450 #endif
10451 return 0;
10452 }
10453
cancelHandoverResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10454 int radio_1_6::cancelHandoverResponse(int slotId, int responseType, int serial,
10455 RIL_Errno e, void* response, size_t responseLen) {
10456 // If we don't have a radio service, there's nothing we can do
10457 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10458 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10459 return 0;
10460 }
10461 V1_6::RadioResponseInfo responseInfo = {};
10462 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10463
10464 Return<void> retStatus =
10465 radioService[slotId]->mRadioResponseV1_6->cancelHandoverResponse(responseInfo);
10466
10467 #if VDBG
10468 RLOGD("%s(): %d", __FUNCTION__, serial);
10469 #endif
10470 return 0;
10471 }
10472
10473
setDataThrottlingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)10474 int radio_1_6::setDataThrottlingResponse(int slotId, int responseType,
10475 int serial, RIL_Errno e, void *response, size_t responselen) {
10476 #if VDBG
10477 RLOGD("setDataThrottlingResponse: serial %d", serial);
10478 #endif
10479
10480 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10481 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10482 return 0;
10483 }
10484
10485 V1_6::RadioResponseInfo responseInfo = {};
10486 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10487
10488
10489 Return<void> retstatus =
10490 radioService[slotId]->mRadioResponseV1_6->setDataThrottlingResponse(
10491 responseInfo);
10492 radioService[slotId]->checkReturnStatus(retstatus);
10493 return 0;
10494 }
10495
getSlicingConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10496 int radio_1_6::getSlicingConfigResponse(int slotId, int responseType, int serial,
10497 RIL_Errno e, void* response, size_t responseLen) {
10498 #if VDBG
10499 RLOGD("getSlicingConfigResponse: serial %d", serial);
10500 #endif
10501
10502 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10503 V1_6::RadioResponseInfo responseInfo = {};
10504 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10505
10506 V1_6::SlicingConfig slicingConfig = {};
10507 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6->
10508 getSlicingConfigResponse(responseInfo, slicingConfig);
10509 radioService[slotId]->checkReturnStatus(retStatus);
10510 } else {
10511 RLOGE("getSlicingConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10512 }
10513
10514 return 0;
10515 }
10516
getSimPhonebookRecordsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10517 int radio_1_6::getSimPhonebookRecordsResponse(int slotId, int responseType, int serial,
10518 RIL_Errno e, void *response, size_t responseLen) {
10519 #if VDBG
10520 RLOGD("getSimPhonebookRecordsResponse: serial %d", serial);
10521 #endif
10522
10523 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10524 V1_6::RadioResponseInfo responseInfo = {};
10525 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10526
10527 Return<void> retStatus =
10528 radioService[slotId]->mRadioResponseV1_6->getSimPhonebookRecordsResponse(
10529 responseInfo);
10530 radioService[slotId]->checkReturnStatus(retStatus);
10531 } else {
10532 RLOGE("getSimPhonebookRecordsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10533 }
10534
10535 return 0;
10536 }
10537
getSimPhonebookCapacityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10538 int radio_1_6::getSimPhonebookCapacityResponse(int slotId, int responseType, int serial,
10539 RIL_Errno e, void *response, size_t responseLen) {
10540 #if VDBG
10541 RLOGD("getSimPhonebookCapacityResponse: serial %d", serial);
10542 #endif
10543
10544 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10545 V1_6::RadioResponseInfo responseInfo = {};
10546 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10547
10548 V1_6::PhonebookCapacity phonebookCapacity = {};
10549 Return<void> retStatus =
10550 radioService[slotId]->mRadioResponseV1_6->getSimPhonebookCapacityResponse(
10551 responseInfo, phonebookCapacity);
10552 radioService[slotId]->checkReturnStatus(retStatus);
10553 } else {
10554 RLOGE("getSimPhonebookCapacityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10555 }
10556
10557 return 0;
10558 }
10559
updateSimPhonebookRecordsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10560 int radio_1_6::updateSimPhonebookRecordsResponse(int slotId, int responseType, int serial,
10561 RIL_Errno e, void *response, size_t responseLen) {
10562 #if VDBG
10563 RLOGD("updateSimPhonebookRecordsResponse: serial %d", serial);
10564 #endif
10565
10566 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10567 V1_6::RadioResponseInfo responseInfo = {};
10568 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10569
10570 int32_t updatedRecordIndex = 0;
10571 Return<void> retStatus =
10572 radioService[slotId]->mRadioResponseV1_6->updateSimPhonebookRecordsResponse(
10573 responseInfo, updatedRecordIndex);
10574 radioService[slotId]->checkReturnStatus(retStatus);
10575 } else {
10576 RLOGE("updateSimPhonebookRecordsResponse: radioService[%d]->mRadioResponse == NULL",
10577 slotId);
10578 }
10579
10580 return 0;
10581 }
10582
10583 /***************************************************************************************************
10584 * INDICATION FUNCTIONS
10585 * The below function handle unsolicited messages coming from the Radio
10586 * (messages for which there is no pending request)
10587 **************************************************************************************************/
10588
convertIntToRadioIndicationType(int indicationType)10589 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
10590 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
10591 (RadioIndicationType::UNSOLICITED_ACK_EXP);
10592 }
10593
radioStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10594 int radio_1_6::radioStateChangedInd(int slotId,
10595 int indicationType, int token, RIL_Errno e, void *response,
10596 size_t responseLen) {
10597 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10598 RadioState radioState =
10599 (RadioState) CALL_ONSTATEREQUEST(slotId);
10600 RLOGD("radioStateChangedInd: radioState %d", radioState);
10601 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
10602 convertIntToRadioIndicationType(indicationType), radioState);
10603 radioService[slotId]->checkReturnStatus(retStatus);
10604 } else {
10605 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
10606 }
10607
10608 return 0;
10609 }
10610
callStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10611 int radio_1_6::callStateChangedInd(int slotId,
10612 int indicationType, int token, RIL_Errno e, void *response,
10613 size_t responseLen) {
10614 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10615 #if VDBG
10616 RLOGD("callStateChangedInd");
10617 #endif
10618 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
10619 convertIntToRadioIndicationType(indicationType));
10620 radioService[slotId]->checkReturnStatus(retStatus);
10621 } else {
10622 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
10623 }
10624
10625 return 0;
10626 }
10627
networkStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10628 int radio_1_6::networkStateChangedInd(int slotId,
10629 int indicationType, int token, RIL_Errno e, void *response,
10630 size_t responseLen) {
10631 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10632 #if VDBG
10633 RLOGD("networkStateChangedInd");
10634 #endif
10635 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
10636 convertIntToRadioIndicationType(indicationType));
10637 radioService[slotId]->checkReturnStatus(retStatus);
10638 } else {
10639 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
10640 slotId);
10641 }
10642
10643 return 0;
10644 }
10645
hexCharToInt(uint8_t c)10646 extern "C" uint8_t hexCharToInt(uint8_t c) {
10647 if (c >= '0' && c <= '9') return (c - '0');
10648 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
10649 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
10650
10651 return INVALID_HEX_CHAR;
10652 }
10653
convertHexStringToBytes(void * response,size_t responseLen)10654 extern "C" uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
10655 if (responseLen % 2 != 0) {
10656 return NULL;
10657 }
10658
10659 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
10660 if (bytes == NULL) {
10661 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
10662 return NULL;
10663 }
10664 uint8_t *hexString = (uint8_t *)response;
10665
10666 for (size_t i = 0; i < responseLen; i += 2) {
10667 uint8_t hexChar1 = hexCharToInt(hexString[i]);
10668 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
10669
10670 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
10671 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
10672 hexString[i], hexString[i + 1]);
10673 free(bytes);
10674 return NULL;
10675 }
10676 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
10677 }
10678
10679 return bytes;
10680 }
10681
newSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10682 int radio_1_6::newSmsInd(int slotId, int indicationType,
10683 int token, RIL_Errno e, void *response, size_t responseLen) {
10684 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10685 if (response == NULL || responseLen == 0) {
10686 RLOGE("newSmsInd: invalid response");
10687 return 0;
10688 }
10689
10690 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
10691 if (bytes == NULL) {
10692 RLOGE("newSmsInd: convertHexStringToBytes failed");
10693 return 0;
10694 }
10695
10696 hidl_vec<uint8_t> pdu;
10697 pdu.setToExternal(bytes, responseLen/2);
10698 #if VDBG
10699 RLOGD("newSmsInd");
10700 #endif
10701 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
10702 convertIntToRadioIndicationType(indicationType), pdu);
10703 radioService[slotId]->checkReturnStatus(retStatus);
10704 free(bytes);
10705 } else {
10706 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
10707 }
10708
10709 return 0;
10710 }
10711
newSmsStatusReportInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10712 int radio_1_6::newSmsStatusReportInd(int slotId,
10713 int indicationType, int token, RIL_Errno e, void *response,
10714 size_t responseLen) {
10715 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10716 if (response == NULL || responseLen == 0) {
10717 RLOGE("newSmsStatusReportInd: invalid response");
10718 return 0;
10719 }
10720
10721 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
10722 if (bytes == NULL) {
10723 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
10724 return 0;
10725 }
10726
10727 hidl_vec<uint8_t> pdu;
10728 pdu.setToExternal(bytes, responseLen/2);
10729 #if VDBG
10730 RLOGD("newSmsStatusReportInd");
10731 #endif
10732 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
10733 convertIntToRadioIndicationType(indicationType), pdu);
10734 radioService[slotId]->checkReturnStatus(retStatus);
10735 free(bytes);
10736 } else {
10737 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
10738 }
10739
10740 return 0;
10741 }
10742
newSmsOnSimInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10743 int radio_1_6::newSmsOnSimInd(int slotId, int indicationType,
10744 int token, RIL_Errno e, void *response, size_t responseLen) {
10745 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10746 if (response == NULL || responseLen != sizeof(int)) {
10747 RLOGE("newSmsOnSimInd: invalid response");
10748 return 0;
10749 }
10750 int32_t recordNumber = ((int32_t *) response)[0];
10751 #if VDBG
10752 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
10753 #endif
10754 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
10755 convertIntToRadioIndicationType(indicationType), recordNumber);
10756 radioService[slotId]->checkReturnStatus(retStatus);
10757 } else {
10758 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
10759 }
10760
10761 return 0;
10762 }
10763
onUssdInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10764 int radio_1_6::onUssdInd(int slotId, int indicationType,
10765 int token, RIL_Errno e, void *response, size_t responseLen) {
10766 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10767 if (response == NULL || responseLen != 2 * sizeof(char *)) {
10768 RLOGE("onUssdInd: invalid response");
10769 return 0;
10770 }
10771 char **strings = (char **) response;
10772 char *mode = strings[0];
10773 hidl_string msg = convertCharPtrToHidlString(strings[1]);
10774 UssdModeType modeType = (UssdModeType) atoi(mode);
10775 #if VDBG
10776 RLOGD("onUssdInd: mode %s", mode);
10777 #endif
10778 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
10779 convertIntToRadioIndicationType(indicationType), modeType, msg);
10780 radioService[slotId]->checkReturnStatus(retStatus);
10781 } else {
10782 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
10783 }
10784
10785 return 0;
10786 }
10787
nitzTimeReceivedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10788 int radio_1_6::nitzTimeReceivedInd(int slotId,
10789 int indicationType, int token, RIL_Errno e, void *response,
10790 size_t responseLen) {
10791 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10792 if (response == NULL || responseLen == 0) {
10793 RLOGE("nitzTimeReceivedInd: invalid response");
10794 return 0;
10795 }
10796 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
10797 #if VDBG
10798 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
10799 nitzTimeReceived[slotId]);
10800 #endif
10801 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
10802 convertIntToRadioIndicationType(indicationType), nitzTime,
10803 nitzTimeReceived[slotId]);
10804 radioService[slotId]->checkReturnStatus(retStatus);
10805 } else {
10806 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
10807 return -1;
10808 }
10809
10810 return 0;
10811 }
10812
convertRilSignalStrengthToHal(void * response,size_t responseLen,SignalStrength & signalStrength)10813 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
10814 SignalStrength& signalStrength) {
10815 RIL_SignalStrength_v12 *rilSignalStrength = (RIL_SignalStrength_v12 *) response;
10816
10817 // Fixup LTE for backwards compatibility
10818 // signalStrength: -1 -> 99
10819 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
10820 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
10821 }
10822 // rsrp: -1 -> INT_MAX all other negative value to positive.
10823 // So remap here
10824 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
10825 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
10826 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
10827 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
10828 }
10829 // rsrq: -1 -> INT_MAX
10830 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
10831 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
10832 }
10833 // Not remapping rssnr is already using INT_MAX
10834 // cqi: -1 -> INT_MAX
10835 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
10836 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
10837 }
10838
10839 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
10840 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
10841 // RIL_SignalStrength_v10 not support gw.timingAdvance. Set to INT_MAX as
10842 // invalid value.
10843 signalStrength.gw.timingAdvance = INT_MAX;
10844
10845 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
10846 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
10847 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
10848 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
10849 signalStrength.evdo.signalNoiseRatio =
10850 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
10851 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
10852 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
10853 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
10854 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
10855 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
10856 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
10857 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
10858 }
10859
convertRilSignalStrengthToHal_1_2(void * response,size_t responseLen,V1_2::SignalStrength & signalStrength_1_2)10860 void convertRilSignalStrengthToHal_1_2(void* response, size_t responseLen,
10861 V1_2::SignalStrength& signalStrength_1_2) {
10862 SignalStrength signalStrength = {};
10863 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
10864 signalStrength_1_2.gsm = signalStrength.gw;
10865 signalStrength_1_2.cdma = signalStrength.cdma;
10866 signalStrength_1_2.evdo = signalStrength.evdo;
10867 signalStrength_1_2.lte = signalStrength.lte;
10868
10869 RIL_SignalStrength_v12* rilSignalStrength = (RIL_SignalStrength_v12*)response;
10870 signalStrength_1_2.wcdma.base.signalStrength =
10871 rilSignalStrength->WCDMA_SignalStrength.signalStrength;
10872 signalStrength_1_2.wcdma.base.bitErrorRate =
10873 rilSignalStrength->WCDMA_SignalStrength.bitErrorRate;
10874 signalStrength_1_2.wcdma.rscp = INT_MAX;
10875 signalStrength_1_2.wcdma.ecno = INT_MAX;
10876
10877 signalStrength_1_2.tdScdma.rscp = INT_MAX;
10878 }
10879
convertRilSignalStrengthToHal_1_4(void * response,size_t responseLen,V1_4::SignalStrength & signalStrength_1_4)10880 void convertRilSignalStrengthToHal_1_4(void *response, size_t responseLen,
10881 V1_4::SignalStrength& signalStrength_1_4) {
10882 SignalStrength signalStrength = {};
10883 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
10884 signalStrength_1_4.gsm = signalStrength.gw;
10885 signalStrength_1_4.cdma = signalStrength.cdma;
10886 signalStrength_1_4.evdo = signalStrength.evdo;
10887 signalStrength_1_4.lte = signalStrength.lte;
10888
10889 RIL_SignalStrength_v12 *rilSignalStrength = (RIL_SignalStrength_v12 *) response;
10890 signalStrength_1_4.wcdma.base.signalStrength =
10891 rilSignalStrength->WCDMA_SignalStrength.signalStrength;
10892 signalStrength_1_4.wcdma.base.bitErrorRate =
10893 rilSignalStrength->WCDMA_SignalStrength.bitErrorRate;
10894 signalStrength_1_4.wcdma.rscp = INT_MAX;
10895 signalStrength_1_4.wcdma.ecno = INT_MAX;
10896
10897 signalStrength_1_4.tdscdma.signalStrength = INT_MAX;
10898 signalStrength_1_4.tdscdma.bitErrorRate = INT_MAX;
10899 signalStrength_1_4.tdscdma.rscp = INT_MAX;
10900
10901 signalStrength_1_4.nr.ssRsrp = rilSignalStrength->NR_SignalStrength.ssRsrp;
10902 signalStrength_1_4.nr.ssRsrq = rilSignalStrength->NR_SignalStrength.ssRsrq;
10903 signalStrength_1_4.nr.ssSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
10904 signalStrength_1_4.nr.csiRsrp = rilSignalStrength->NR_SignalStrength.csiRsrp;
10905 signalStrength_1_4.nr.csiRsrq = rilSignalStrength->NR_SignalStrength.csiRsrq;
10906 signalStrength_1_4.nr.csiSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
10907 }
10908
convertRilSignalStrengthToHal_1_6(void * response,size_t responseLen,V1_6::SignalStrength & signalStrength_1_6)10909 void convertRilSignalStrengthToHal_1_6(void* response, size_t responseLen,
10910 V1_6::SignalStrength& signalStrength_1_6) {
10911 SignalStrength signalStrength = {};
10912 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
10913 signalStrength_1_6.gsm = signalStrength.gw;
10914 signalStrength_1_6.cdma = signalStrength.cdma;
10915 signalStrength_1_6.evdo = signalStrength.evdo;
10916 signalStrength_1_6.lte.base = signalStrength.lte;
10917
10918 RIL_SignalStrength_v12* rilSignalStrength = (RIL_SignalStrength_v12*)response;
10919 signalStrength_1_6.wcdma.base.signalStrength =
10920 rilSignalStrength->WCDMA_SignalStrength.signalStrength;
10921 signalStrength_1_6.wcdma.base.bitErrorRate =
10922 rilSignalStrength->WCDMA_SignalStrength.bitErrorRate;
10923 signalStrength_1_6.wcdma.rscp = INT_MAX;
10924 signalStrength_1_6.wcdma.ecno = INT_MAX;
10925
10926 signalStrength_1_6.tdscdma.signalStrength = INT_MAX;
10927 signalStrength_1_6.tdscdma.bitErrorRate = INT_MAX;
10928 signalStrength_1_6.tdscdma.rscp = INT_MAX;
10929
10930 signalStrength_1_6.nr.base.ssRsrp = rilSignalStrength->NR_SignalStrength.ssRsrp;
10931 signalStrength_1_6.nr.base.ssRsrq = rilSignalStrength->NR_SignalStrength.ssRsrq;
10932 signalStrength_1_6.nr.base.ssSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
10933 signalStrength_1_6.nr.base.csiRsrp = rilSignalStrength->NR_SignalStrength.csiRsrp;
10934 signalStrength_1_6.nr.base.csiRsrq = rilSignalStrength->NR_SignalStrength.csiRsrq;
10935 signalStrength_1_6.nr.base.csiSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
10936 }
10937
currentSignalStrengthInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10938 int radio_1_6::currentSignalStrengthInd(int slotId, int indicationType, int token, RIL_Errno e,
10939 void* response, size_t responseLen) {
10940 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndication != NULL ||
10941 radioService[slotId]->mRadioIndicationV1_2 != NULL ||
10942 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
10943 radioService[slotId]->mRadioIndicationV1_6 != NULL)) {
10944 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v12)) {
10945 RLOGE("currentSignalStrengthInd: invalid response");
10946 return 0;
10947 }
10948
10949 #if VDBG
10950 RLOGD("currentSignalStrengthInd");
10951 #endif
10952 Return<void> retStatus;
10953 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
10954 V1_6::SignalStrength signalStrength_1_6 = {};
10955 convertRilSignalStrengthToHal_1_6(response, responseLen, signalStrength_1_6);
10956 retStatus = radioService[slotId]->mRadioIndicationV1_6->currentSignalStrength_1_6(
10957 convertIntToRadioIndicationType(indicationType), signalStrength_1_6);
10958 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
10959 V1_4::SignalStrength signalStrength_1_4 = {};
10960 convertRilSignalStrengthToHal_1_4(response, responseLen, signalStrength_1_4);
10961 retStatus = radioService[slotId]->mRadioIndicationV1_4->currentSignalStrength_1_4(
10962 convertIntToRadioIndicationType(indicationType), signalStrength_1_4);
10963 } else if (radioService[slotId]->mRadioIndicationV1_2 != NULL) {
10964 V1_2::SignalStrength signalStrength_1_2 = {};
10965 convertRilSignalStrengthToHal_1_2(response, responseLen, signalStrength_1_2);
10966 retStatus = radioService[slotId]->mRadioIndicationV1_2->currentSignalStrength_1_2(
10967 convertIntToRadioIndicationType(indicationType), signalStrength_1_2);
10968 } else {
10969 SignalStrength signalStrength = {};
10970 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
10971 retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
10972 convertIntToRadioIndicationType(indicationType), signalStrength);
10973 }
10974 radioService[slotId]->checkReturnStatus(retStatus);
10975 } else {
10976 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
10977 slotId);
10978 }
10979
10980 return 0;
10981 }
10982
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,SetupDataCallResult & dcResult)10983 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
10984 SetupDataCallResult& dcResult) {
10985 dcResult.status = (DataCallFailCause) dcResponse->status;
10986 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
10987 dcResult.cid = dcResponse->cid;
10988 dcResult.active = dcResponse->active;
10989 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
10990 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
10991 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
10992 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
10993 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
10994 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
10995 dcResult.mtu = dcResponse->mtu;
10996 }
10997
split(hidl_string str)10998 hidl_vec<hidl_string> split(hidl_string str) {
10999 std::vector<hidl_string> ret;
11000 std::stringstream ss(static_cast<std::string>(str));
11001
11002 std::string tok;
11003
11004 while(getline(ss, tok, ' ')) {
11005 ret.push_back(hidl_string(tok));
11006 }
11007
11008 return ret;
11009 }
11010
convertToPdpProtocolType(hidl_string str)11011 ::android::hardware::radio::V1_4::PdpProtocolType convertToPdpProtocolType(hidl_string str) {
11012 if (strncmp("IP", str.c_str(), 2) == 0) {
11013 return ::android::hardware::radio::V1_4::PdpProtocolType::IP;
11014 } else if (strncmp("IPV6", str.c_str(), 4) == 0) {
11015 return ::android::hardware::radio::V1_4::PdpProtocolType::IPV6;
11016 } else if (strncmp("IPV4V6", str.c_str(), 6) == 0) {
11017 return ::android::hardware::radio::V1_4::PdpProtocolType::IPV4V6;
11018 } else if (strncmp("PPP", str.c_str(), 3) == 0) {
11019 return ::android::hardware::radio::V1_4::PdpProtocolType::PPP;
11020 } else if (strncmp("NON_IP", str.c_str(), 6) == 0) {
11021 return ::android::hardware::radio::V1_4::PdpProtocolType::NON_IP;
11022 } else if (strncmp("UNSTRUCTURED", str.c_str(), 12) == 0) {
11023 return ::android::hardware::radio::V1_4::PdpProtocolType::UNSTRUCTURED;
11024 } else {
11025 return ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
11026 }
11027 }
11028
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,::android::hardware::radio::V1_4::SetupDataCallResult & dcResult)11029 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
11030 ::android::hardware::radio::V1_4::SetupDataCallResult& dcResult) {
11031 dcResult.cause = (::android::hardware::radio::V1_4::DataCallFailCause) dcResponse->status;
11032 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
11033 dcResult.cid = dcResponse->cid;
11034 dcResult.active = (::android::hardware::radio::V1_4::DataConnActiveStatus)dcResponse->active;
11035 dcResult.type = convertToPdpProtocolType(convertCharPtrToHidlString(dcResponse->type));
11036 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
11037 dcResult.addresses = split(convertCharPtrToHidlString(dcResponse->addresses));
11038 dcResult.dnses = split(convertCharPtrToHidlString(dcResponse->dnses));
11039 dcResult.gateways = split(convertCharPtrToHidlString(dcResponse->gateways));
11040 dcResult.pcscf = split(convertCharPtrToHidlString(dcResponse->pcscf));
11041 dcResult.mtu = dcResponse->mtu;
11042 }
11043
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,::android::hardware::radio::V1_5::SetupDataCallResult & dcResult)11044 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
11045 ::android::hardware::radio::V1_5::SetupDataCallResult& dcResult) {
11046 dcResult.cause = (::android::hardware::radio::V1_4::DataCallFailCause) dcResponse->status;
11047 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
11048 dcResult.cid = dcResponse->cid;
11049 dcResult.active = (::android::hardware::radio::V1_4::DataConnActiveStatus)dcResponse->active;
11050 dcResult.type = convertToPdpProtocolType(convertCharPtrToHidlString(dcResponse->type));
11051 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
11052
11053 std::vector<::android::hardware::radio::V1_5::LinkAddress> linkAddresses;
11054 std::stringstream ss(static_cast<std::string>(dcResponse->addresses));
11055 std::string tok;
11056 while(getline(ss, tok, ' ')) {
11057 ::android::hardware::radio::V1_5::LinkAddress la;
11058 la.address = hidl_string(tok);
11059 la.properties = 0;
11060 la.deprecationTime = 0;
11061 la.expirationTime = 0;
11062 linkAddresses.push_back(la);
11063 }
11064
11065 dcResult.addresses = linkAddresses;
11066 dcResult.dnses = split(convertCharPtrToHidlString(dcResponse->dnses));
11067 dcResult.gateways = split(convertCharPtrToHidlString(dcResponse->gateways));
11068 dcResult.pcscf = split(convertCharPtrToHidlString(dcResponse->pcscf));
11069 dcResult.mtuV4 = dcResponse->mtu;
11070 dcResult.mtuV6 = dcResponse->mtu;
11071 }
11072
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,::android::hardware::radio::V1_6::SetupDataCallResult & dcResult)11073 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
11074 ::android::hardware::radio::V1_6::SetupDataCallResult& dcResult) {
11075 dcResult.cause = (::android::hardware::radio::V1_6::DataCallFailCause) dcResponse->status;
11076 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
11077 dcResult.cid = dcResponse->cid;
11078 dcResult.active = (::android::hardware::radio::V1_4::DataConnActiveStatus)dcResponse->active;
11079 dcResult.type = convertToPdpProtocolType(convertCharPtrToHidlString(dcResponse->type));
11080 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
11081
11082 std::vector<::android::hardware::radio::V1_5::LinkAddress> linkAddresses;
11083 std::stringstream ss(static_cast<std::string>(dcResponse->addresses));
11084 std::string tok;
11085 while(getline(ss, tok, ' ')) {
11086 ::android::hardware::radio::V1_5::LinkAddress la;
11087 la.address = hidl_string(tok);
11088 la.properties = 0;
11089 la.deprecationTime = 0;
11090 la.expirationTime = 0;
11091 linkAddresses.push_back(la);
11092 }
11093
11094 dcResult.addresses = linkAddresses;
11095 dcResult.dnses = split(convertCharPtrToHidlString(dcResponse->dnses));
11096 dcResult.gateways = split(convertCharPtrToHidlString(dcResponse->gateways));
11097 dcResult.pcscf = split(convertCharPtrToHidlString(dcResponse->pcscf));
11098 dcResult.mtuV4 = dcResponse->mtu;
11099 dcResult.mtuV6 = dcResponse->mtu;
11100
11101 std::vector<::android::hardware::radio::V1_6::TrafficDescriptor> trafficDescriptors;
11102 ::android::hardware::radio::V1_6::TrafficDescriptor trafficDescriptor;
11103 ::android::hardware::radio::V1_6::OsAppId osAppId;
11104
11105 std::vector<uint8_t> osAppIdVec;
11106 osAppIdVec.push_back('o');
11107 osAppIdVec.push_back('s');
11108 osAppIdVec.push_back('A');
11109 osAppIdVec.push_back('p');
11110 osAppIdVec.push_back('p');
11111 osAppIdVec.push_back('I');
11112 osAppIdVec.push_back('d');
11113
11114 osAppId.osAppId = osAppIdVec;
11115 trafficDescriptor.osAppId.value(osAppId);
11116 trafficDescriptors.push_back(trafficDescriptor);
11117 dcResult.trafficDescriptors = trafficDescriptors;
11118 }
11119
convertRilDataCallListToHal(void * response,size_t responseLen,hidl_vec<SetupDataCallResult> & dcResultList)11120 void convertRilDataCallListToHal(void *response, size_t responseLen,
11121 hidl_vec<SetupDataCallResult>& dcResultList) {
11122 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11123
11124 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
11125 dcResultList.resize(num);
11126 for (int i = 0; i < num; i++) {
11127 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11128 }
11129 }
11130
convertRilDataCallListToHal_1_4(void * response,size_t responseLen,hidl_vec<V1_4::SetupDataCallResult> & dcResultList)11131 void convertRilDataCallListToHal_1_4(void* response, size_t responseLen,
11132 hidl_vec<V1_4::SetupDataCallResult>& dcResultList) {
11133 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11134
11135 RIL_Data_Call_Response_v11* dcResponse = (RIL_Data_Call_Response_v11*)response;
11136 dcResultList.resize(num);
11137 for (int i = 0; i < num; i++) {
11138 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11139 }
11140 }
11141
convertRilDataCallListToHal_1_5(void * response,size_t responseLen,hidl_vec<V1_5::SetupDataCallResult> & dcResultList)11142 void convertRilDataCallListToHal_1_5(void* response, size_t responseLen,
11143 hidl_vec<V1_5::SetupDataCallResult>& dcResultList) {
11144 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11145
11146 RIL_Data_Call_Response_v11* dcResponse = (RIL_Data_Call_Response_v11*)response;
11147 dcResultList.resize(num);
11148 for (int i = 0; i < num; i++) {
11149 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11150 }
11151 }
11152
convertRilDataCallListToHal_1_6(void * response,size_t responseLen,hidl_vec<V1_6::SetupDataCallResult> & dcResultList)11153 void convertRilDataCallListToHal_1_6(void* response, size_t responseLen,
11154 hidl_vec<V1_6::SetupDataCallResult>& dcResultList) {
11155 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11156
11157 RIL_Data_Call_Response_v11* dcResponse = (RIL_Data_Call_Response_v11*)response;
11158 dcResultList.resize(num);
11159 for (int i = 0; i < num; i++) {
11160 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11161 }
11162 }
11163
dataCallListChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11164 int radio_1_6::dataCallListChangedInd(int slotId,
11165 int indicationType, int token, RIL_Errno e, void *response,
11166 size_t responseLen) {
11167 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndication != NULL ||
11168 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
11169 radioService[slotId]->mRadioIndicationV1_5 != NULL ||
11170 radioService[slotId]->mRadioIndicationV1_6 != NULL)) {
11171 if ((response == NULL && responseLen != 0)
11172 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
11173 RLOGE("dataCallListChangedInd: invalid response");
11174 return 0;
11175 }
11176 #if VDBG
11177 RLOGD("dataCallListChangedInd");
11178 #endif
11179 Return<void> retStatus;
11180 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
11181 hidl_vec<V1_6::SetupDataCallResult> dcList;
11182 convertRilDataCallListToHal_1_6(response, responseLen, dcList);
11183 retStatus = radioService[slotId]->mRadioIndicationV1_6->dataCallListChanged_1_6(
11184 convertIntToRadioIndicationType(indicationType), dcList);
11185 } else if (radioService[slotId]->mRadioIndicationV1_5 != NULL) {
11186 hidl_vec<V1_5::SetupDataCallResult> dcList;
11187 convertRilDataCallListToHal_1_5(response, responseLen, dcList);
11188 retStatus = radioService[slotId]->mRadioIndicationV1_5->dataCallListChanged_1_5(
11189 convertIntToRadioIndicationType(indicationType), dcList);
11190 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
11191 hidl_vec<V1_4::SetupDataCallResult> dcList;
11192 convertRilDataCallListToHal_1_4(response, responseLen, dcList);
11193 retStatus = radioService[slotId]->mRadioIndicationV1_4->dataCallListChanged_1_4(
11194 convertIntToRadioIndicationType(indicationType), dcList);
11195 } else {
11196 hidl_vec<SetupDataCallResult> dcList;
11197 convertRilDataCallListToHal(response, responseLen, dcList);
11198 retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
11199 convertIntToRadioIndicationType(indicationType), dcList);
11200 }
11201 radioService[slotId]->checkReturnStatus(retStatus);
11202 } else {
11203 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
11204 }
11205
11206 return 0;
11207 }
11208
suppSvcNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11209 int radio_1_6::suppSvcNotifyInd(int slotId, int indicationType,
11210 int token, RIL_Errno e, void *response, size_t responseLen) {
11211 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11212 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
11213 RLOGE("suppSvcNotifyInd: invalid response");
11214 return 0;
11215 }
11216
11217 SuppSvcNotification suppSvc = {};
11218 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
11219 suppSvc.isMT = ssn->notificationType;
11220 suppSvc.code = ssn->code;
11221 suppSvc.index = ssn->index;
11222 suppSvc.type = ssn->type;
11223 suppSvc.number = convertCharPtrToHidlString(ssn->number);
11224
11225 #if VDBG
11226 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
11227 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
11228 #endif
11229 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
11230 convertIntToRadioIndicationType(indicationType), suppSvc);
11231 radioService[slotId]->checkReturnStatus(retStatus);
11232 } else {
11233 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
11234 }
11235
11236 return 0;
11237 }
11238
stkSessionEndInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11239 int radio_1_6::stkSessionEndInd(int slotId, int indicationType,
11240 int token, RIL_Errno e, void *response, size_t responseLen) {
11241 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11242 #if VDBG
11243 RLOGD("stkSessionEndInd");
11244 #endif
11245 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
11246 convertIntToRadioIndicationType(indicationType));
11247 radioService[slotId]->checkReturnStatus(retStatus);
11248 } else {
11249 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
11250 }
11251
11252 return 0;
11253 }
11254
stkProactiveCommandInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11255 int radio_1_6::stkProactiveCommandInd(int slotId,
11256 int indicationType, int token, RIL_Errno e, void *response,
11257 size_t responseLen) {
11258 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11259 if (response == NULL || responseLen == 0) {
11260 RLOGE("stkProactiveCommandInd: invalid response");
11261 return 0;
11262 }
11263 #if VDBG
11264 RLOGD("stkProactiveCommandInd");
11265 #endif
11266 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
11267 convertIntToRadioIndicationType(indicationType),
11268 convertCharPtrToHidlString((char *) response));
11269 radioService[slotId]->checkReturnStatus(retStatus);
11270 } else {
11271 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
11272 }
11273
11274 return 0;
11275 }
11276
stkEventNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11277 int radio_1_6::stkEventNotifyInd(int slotId, int indicationType,
11278 int token, RIL_Errno e, void *response, size_t responseLen) {
11279 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11280 if (response == NULL || responseLen == 0) {
11281 RLOGE("stkEventNotifyInd: invalid response");
11282 return 0;
11283 }
11284 #if VDBG
11285 RLOGD("stkEventNotifyInd");
11286 #endif
11287 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
11288 convertIntToRadioIndicationType(indicationType),
11289 convertCharPtrToHidlString((char *) response));
11290 radioService[slotId]->checkReturnStatus(retStatus);
11291 } else {
11292 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
11293 }
11294
11295 return 0;
11296 }
11297
stkCallSetupInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11298 int radio_1_6::stkCallSetupInd(int slotId, int indicationType,
11299 int token, RIL_Errno e, void *response, size_t responseLen) {
11300 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11301 if (response == NULL || responseLen != sizeof(int)) {
11302 RLOGE("stkCallSetupInd: invalid response");
11303 return 0;
11304 }
11305 int32_t timeout = ((int32_t *) response)[0];
11306 #if VDBG
11307 RLOGD("stkCallSetupInd: timeout %d", timeout);
11308 #endif
11309 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
11310 convertIntToRadioIndicationType(indicationType), timeout);
11311 radioService[slotId]->checkReturnStatus(retStatus);
11312 } else {
11313 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
11314 }
11315
11316 return 0;
11317 }
11318
simSmsStorageFullInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11319 int radio_1_6::simSmsStorageFullInd(int slotId,
11320 int indicationType, int token, RIL_Errno e, void *response,
11321 size_t responseLen) {
11322 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11323 #if VDBG
11324 RLOGD("simSmsStorageFullInd");
11325 #endif
11326 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
11327 convertIntToRadioIndicationType(indicationType));
11328 radioService[slotId]->checkReturnStatus(retStatus);
11329 } else {
11330 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
11331 }
11332
11333 return 0;
11334 }
11335
simRefreshInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11336 int radio_1_6::simRefreshInd(int slotId, int indicationType,
11337 int token, RIL_Errno e, void *response, size_t responseLen) {
11338 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11339 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
11340 RLOGE("simRefreshInd: invalid response");
11341 return 0;
11342 }
11343
11344 SimRefreshResult refreshResult = {};
11345 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
11346 refreshResult.type =
11347 (V1_0::SimRefreshType) simRefreshResponse->result;
11348 refreshResult.efId = simRefreshResponse->ef_id;
11349 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
11350
11351 #if VDBG
11352 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
11353 #endif
11354 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
11355 convertIntToRadioIndicationType(indicationType), refreshResult);
11356 radioService[slotId]->checkReturnStatus(retStatus);
11357 } else {
11358 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
11359 }
11360
11361 return 0;
11362 }
11363
convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord * signalInfoRecord,CdmaSignalInfoRecord & record)11364 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
11365 CdmaSignalInfoRecord& record) {
11366 record.isPresent = signalInfoRecord->isPresent;
11367 record.signalType = signalInfoRecord->signalType;
11368 record.alertPitch = signalInfoRecord->alertPitch;
11369 record.signal = signalInfoRecord->signal;
11370 }
11371
callRingInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11372 int radio_1_6::callRingInd(int slotId, int indicationType,
11373 int token, RIL_Errno e, void *response, size_t responseLen) {
11374 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11375 bool isGsm;
11376 CdmaSignalInfoRecord record = {};
11377 if (response == NULL || responseLen == 0) {
11378 isGsm = true;
11379 } else {
11380 isGsm = false;
11381 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
11382 RLOGE("callRingInd: invalid response");
11383 return 0;
11384 }
11385 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
11386 }
11387
11388 #if VDBG
11389 RLOGD("callRingInd: isGsm %d", isGsm);
11390 #endif
11391 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
11392 convertIntToRadioIndicationType(indicationType), isGsm, record);
11393 radioService[slotId]->checkReturnStatus(retStatus);
11394 } else {
11395 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
11396 }
11397
11398 return 0;
11399 }
11400
simStatusChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11401 int radio_1_6::simStatusChangedInd(int slotId,
11402 int indicationType, int token, RIL_Errno e, void *response,
11403 size_t responseLen) {
11404 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11405 #if VDBG
11406 RLOGD("simStatusChangedInd");
11407 #endif
11408 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
11409 convertIntToRadioIndicationType(indicationType));
11410 radioService[slotId]->checkReturnStatus(retStatus);
11411 } else {
11412 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
11413 }
11414
11415 return 0;
11416 }
11417
cdmaNewSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11418 int radio_1_6::cdmaNewSmsInd(int slotId, int indicationType,
11419 int token, RIL_Errno e, void *response, size_t responseLen) {
11420 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11421 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
11422 RLOGE("cdmaNewSmsInd: invalid response");
11423 return 0;
11424 }
11425
11426 CdmaSmsMessage msg = {};
11427 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
11428 msg.teleserviceId = rilMsg->uTeleserviceID;
11429 msg.isServicePresent = rilMsg->bIsServicePresent;
11430 msg.serviceCategory = rilMsg->uServicecategory;
11431 msg.address.digitMode =
11432 (V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
11433 msg.address.numberMode =
11434 (V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
11435 msg.address.numberType =
11436 (V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
11437 msg.address.numberPlan =
11438 (V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
11439
11440 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
11441 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
11442
11443 msg.subAddress.subaddressType = (V1_0::CdmaSmsSubaddressType)
11444 rilMsg->sSubAddress.subaddressType;
11445 msg.subAddress.odd = rilMsg->sSubAddress.odd;
11446
11447 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
11448 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
11449
11450 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
11451 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
11452
11453 #if VDBG
11454 RLOGD("cdmaNewSmsInd");
11455 #endif
11456 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
11457 convertIntToRadioIndicationType(indicationType), msg);
11458 radioService[slotId]->checkReturnStatus(retStatus);
11459 } else {
11460 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
11461 }
11462
11463 return 0;
11464 }
11465
newBroadcastSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11466 int radio_1_6::newBroadcastSmsInd(int slotId,
11467 int indicationType, int token, RIL_Errno e, void *response,
11468 size_t responseLen) {
11469 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11470 if (response == NULL || responseLen == 0) {
11471 RLOGE("newBroadcastSmsInd: invalid response");
11472 return 0;
11473 }
11474
11475 hidl_vec<uint8_t> data;
11476 data.setToExternal((uint8_t *) response, responseLen);
11477 #if VDBG
11478 RLOGD("newBroadcastSmsInd");
11479 #endif
11480 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
11481 convertIntToRadioIndicationType(indicationType), data);
11482 radioService[slotId]->checkReturnStatus(retStatus);
11483 } else {
11484 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
11485 }
11486
11487 return 0;
11488 }
11489
cdmaRuimSmsStorageFullInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11490 int radio_1_6::cdmaRuimSmsStorageFullInd(int slotId,
11491 int indicationType, int token, RIL_Errno e, void *response,
11492 size_t responseLen) {
11493 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11494 #if VDBG
11495 RLOGD("cdmaRuimSmsStorageFullInd");
11496 #endif
11497 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
11498 convertIntToRadioIndicationType(indicationType));
11499 radioService[slotId]->checkReturnStatus(retStatus);
11500 } else {
11501 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
11502 slotId);
11503 }
11504
11505 return 0;
11506 }
11507
restrictedStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11508 int radio_1_6::restrictedStateChangedInd(int slotId,
11509 int indicationType, int token, RIL_Errno e, void *response,
11510 size_t responseLen) {
11511 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11512 if (response == NULL || responseLen != sizeof(int)) {
11513 RLOGE("restrictedStateChangedInd: invalid response");
11514 return 0;
11515 }
11516 int32_t state = ((int32_t *) response)[0];
11517 #if VDBG
11518 RLOGD("restrictedStateChangedInd: state %d", state);
11519 #endif
11520 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
11521 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
11522 radioService[slotId]->checkReturnStatus(retStatus);
11523 } else {
11524 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
11525 slotId);
11526 }
11527
11528 return 0;
11529 }
11530
enterEmergencyCallbackModeInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11531 int radio_1_6::enterEmergencyCallbackModeInd(int slotId,
11532 int indicationType, int token, RIL_Errno e, void *response,
11533 size_t responseLen) {
11534 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11535 #if VDBG
11536 RLOGD("enterEmergencyCallbackModeInd");
11537 #endif
11538 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
11539 convertIntToRadioIndicationType(indicationType));
11540 radioService[slotId]->checkReturnStatus(retStatus);
11541 } else {
11542 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
11543 slotId);
11544 }
11545
11546 return 0;
11547 }
11548
cdmaCallWaitingInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11549 int radio_1_6::cdmaCallWaitingInd(int slotId,
11550 int indicationType, int token, RIL_Errno e, void *response,
11551 size_t responseLen) {
11552 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11553 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
11554 RLOGE("cdmaCallWaitingInd: invalid response");
11555 return 0;
11556 }
11557
11558 CdmaCallWaiting callWaitingRecord = {};
11559 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
11560 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
11561 callWaitingRecord.numberPresentation =
11562 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
11563 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
11564 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
11565 callWaitingRecord.signalInfoRecord);
11566 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
11567 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
11568
11569 #if VDBG
11570 RLOGD("cdmaCallWaitingInd");
11571 #endif
11572 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
11573 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
11574 radioService[slotId]->checkReturnStatus(retStatus);
11575 } else {
11576 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
11577 }
11578
11579 return 0;
11580 }
11581
cdmaOtaProvisionStatusInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11582 int radio_1_6::cdmaOtaProvisionStatusInd(int slotId,
11583 int indicationType, int token, RIL_Errno e, void *response,
11584 size_t responseLen) {
11585 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11586 if (response == NULL || responseLen != sizeof(int)) {
11587 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
11588 return 0;
11589 }
11590 int32_t status = ((int32_t *) response)[0];
11591 #if VDBG
11592 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
11593 #endif
11594 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
11595 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
11596 radioService[slotId]->checkReturnStatus(retStatus);
11597 } else {
11598 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
11599 slotId);
11600 }
11601
11602 return 0;
11603 }
11604
cdmaInfoRecInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11605 int radio_1_6::cdmaInfoRecInd(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 != sizeof(RIL_CDMA_InformationRecords)) {
11610 RLOGE("cdmaInfoRecInd: invalid response");
11611 return 0;
11612 }
11613
11614 CdmaInformationRecords records = {};
11615 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
11616
11617 char* string8 = NULL;
11618 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
11619 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
11620 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
11621 "additional ones", recordsRil->numberOfInfoRecs,
11622 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
11623 }
11624 records.infoRec.resize(num);
11625 for (int i = 0 ; i < num ; i++) {
11626 CdmaInformationRecord *record = &records.infoRec[i];
11627 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
11628 record->name = (CdmaInfoRecName) infoRec->name;
11629 // All vectors should be size 0 except one which will be size 1. Set everything to
11630 // size 0 initially.
11631 record->display.resize(0);
11632 record->number.resize(0);
11633 record->signal.resize(0);
11634 record->redir.resize(0);
11635 record->lineCtrl.resize(0);
11636 record->clir.resize(0);
11637 record->audioCtrl.resize(0);
11638 switch (infoRec->name) {
11639 case RIL_CDMA_DISPLAY_INFO_REC:
11640 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
11641 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
11642 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
11643 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
11644 CDMA_ALPHA_INFO_BUFFER_LENGTH);
11645 return 0;
11646 }
11647 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
11648 if (string8 == NULL) {
11649 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
11650 "responseCdmaInformationRecords");
11651 return 0;
11652 }
11653 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
11654 string8[(int)infoRec->rec.display.alpha_len] = '\0';
11655
11656 record->display.resize(1);
11657 record->display[0].alphaBuf = string8;
11658 free(string8);
11659 string8 = NULL;
11660 break;
11661 }
11662
11663 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
11664 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
11665 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
11666 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
11667 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
11668 "expected not more than %d", (int) infoRec->rec.number.len,
11669 CDMA_NUMBER_INFO_BUFFER_LENGTH);
11670 return 0;
11671 }
11672 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
11673 if (string8 == NULL) {
11674 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
11675 "responseCdmaInformationRecords");
11676 return 0;
11677 }
11678 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
11679 string8[(int)infoRec->rec.number.len] = '\0';
11680
11681 record->number.resize(1);
11682 record->number[0].number = string8;
11683 free(string8);
11684 string8 = NULL;
11685 record->number[0].numberType = infoRec->rec.number.number_type;
11686 record->number[0].numberPlan = infoRec->rec.number.number_plan;
11687 record->number[0].pi = infoRec->rec.number.pi;
11688 record->number[0].si = infoRec->rec.number.si;
11689 break;
11690 }
11691
11692 case RIL_CDMA_SIGNAL_INFO_REC: {
11693 record->signal.resize(1);
11694 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
11695 record->signal[0].signalType = infoRec->rec.signal.signalType;
11696 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
11697 record->signal[0].signal = infoRec->rec.signal.signal;
11698 break;
11699 }
11700
11701 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
11702 if (infoRec->rec.redir.redirectingNumber.len >
11703 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
11704 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
11705 "expected not more than %d\n",
11706 (int)infoRec->rec.redir.redirectingNumber.len,
11707 CDMA_NUMBER_INFO_BUFFER_LENGTH);
11708 return 0;
11709 }
11710 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
11711 sizeof(char));
11712 if (string8 == NULL) {
11713 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
11714 "responseCdmaInformationRecords");
11715 return 0;
11716 }
11717 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
11718 infoRec->rec.redir.redirectingNumber.len);
11719 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
11720
11721 record->redir.resize(1);
11722 record->redir[0].redirectingNumber.number = string8;
11723 free(string8);
11724 string8 = NULL;
11725 record->redir[0].redirectingNumber.numberType =
11726 infoRec->rec.redir.redirectingNumber.number_type;
11727 record->redir[0].redirectingNumber.numberPlan =
11728 infoRec->rec.redir.redirectingNumber.number_plan;
11729 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
11730 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
11731 record->redir[0].redirectingReason =
11732 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
11733 break;
11734 }
11735
11736 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
11737 record->lineCtrl.resize(1);
11738 record->lineCtrl[0].lineCtrlPolarityIncluded =
11739 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
11740 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
11741 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
11742 record->lineCtrl[0].lineCtrlPowerDenial =
11743 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
11744 break;
11745 }
11746
11747 case RIL_CDMA_T53_CLIR_INFO_REC: {
11748 record->clir.resize(1);
11749 record->clir[0].cause = infoRec->rec.clir.cause;
11750 break;
11751 }
11752
11753 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
11754 record->audioCtrl.resize(1);
11755 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
11756 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
11757 break;
11758 }
11759
11760 case RIL_CDMA_T53_RELEASE_INFO_REC:
11761 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
11762 return 0;
11763
11764 default:
11765 RLOGE("cdmaInfoRecInd: Incorrect name value");
11766 return 0;
11767 }
11768 }
11769
11770 #if VDBG
11771 RLOGD("cdmaInfoRecInd");
11772 #endif
11773 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
11774 convertIntToRadioIndicationType(indicationType), records);
11775 radioService[slotId]->checkReturnStatus(retStatus);
11776 } else {
11777 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
11778 }
11779
11780 return 0;
11781 }
11782
indicateRingbackToneInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11783 int radio_1_6::indicateRingbackToneInd(int slotId,
11784 int indicationType, int token, RIL_Errno e, void *response,
11785 size_t responseLen) {
11786 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11787 if (response == NULL || responseLen != sizeof(int)) {
11788 RLOGE("indicateRingbackToneInd: invalid response");
11789 return 0;
11790 }
11791 bool start = ((int32_t *) response)[0];
11792 #if VDBG
11793 RLOGD("indicateRingbackToneInd: start %d", start);
11794 #endif
11795 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
11796 convertIntToRadioIndicationType(indicationType), start);
11797 radioService[slotId]->checkReturnStatus(retStatus);
11798 } else {
11799 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
11800 }
11801
11802 return 0;
11803 }
11804
resendIncallMuteInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11805 int radio_1_6::resendIncallMuteInd(int slotId,
11806 int indicationType, int token, RIL_Errno e, void *response,
11807 size_t responseLen) {
11808 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11809 #if VDBG
11810 RLOGD("resendIncallMuteInd");
11811 #endif
11812 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
11813 convertIntToRadioIndicationType(indicationType));
11814 radioService[slotId]->checkReturnStatus(retStatus);
11815 } else {
11816 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
11817 }
11818
11819 return 0;
11820 }
11821
cdmaSubscriptionSourceChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11822 int radio_1_6::cdmaSubscriptionSourceChangedInd(int slotId,
11823 int indicationType, int token, RIL_Errno e,
11824 void *response, size_t responseLen) {
11825 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11826 if (response == NULL || responseLen != sizeof(int)) {
11827 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
11828 return 0;
11829 }
11830 int32_t cdmaSource = ((int32_t *) response)[0];
11831 #if VDBG
11832 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
11833 #endif
11834 Return<void> retStatus = radioService[slotId]->mRadioIndication->
11835 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
11836 (CdmaSubscriptionSource) cdmaSource);
11837 radioService[slotId]->checkReturnStatus(retStatus);
11838 } else {
11839 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
11840 slotId);
11841 }
11842
11843 return 0;
11844 }
11845
cdmaPrlChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11846 int radio_1_6::cdmaPrlChangedInd(int slotId,
11847 int indicationType, int token, RIL_Errno e, void *response,
11848 size_t responseLen) {
11849 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11850 if (response == NULL || responseLen != sizeof(int)) {
11851 RLOGE("cdmaPrlChangedInd: invalid response");
11852 return 0;
11853 }
11854 int32_t version = ((int32_t *) response)[0];
11855 #if VDBG
11856 RLOGD("cdmaPrlChangedInd: version %d", version);
11857 #endif
11858 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
11859 convertIntToRadioIndicationType(indicationType), version);
11860 radioService[slotId]->checkReturnStatus(retStatus);
11861 } else {
11862 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
11863 }
11864
11865 return 0;
11866 }
11867
exitEmergencyCallbackModeInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11868 int radio_1_6::exitEmergencyCallbackModeInd(int slotId,
11869 int indicationType, int token, RIL_Errno e, void *response,
11870 size_t responseLen) {
11871 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11872 #if VDBG
11873 RLOGD("exitEmergencyCallbackModeInd");
11874 #endif
11875 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
11876 convertIntToRadioIndicationType(indicationType));
11877 radioService[slotId]->checkReturnStatus(retStatus);
11878 } else {
11879 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
11880 slotId);
11881 }
11882
11883 return 0;
11884 }
11885
rilConnectedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11886 int radio_1_6::rilConnectedInd(int slotId,
11887 int indicationType, int token, RIL_Errno e, void *response,
11888 size_t responseLen) {
11889 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11890 RLOGD("rilConnectedInd");
11891 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
11892 convertIntToRadioIndicationType(indicationType));
11893 radioService[slotId]->checkReturnStatus(retStatus);
11894 } else {
11895 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
11896 }
11897
11898 return 0;
11899 }
11900
voiceRadioTechChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11901 int radio_1_6::voiceRadioTechChangedInd(int slotId,
11902 int indicationType, int token, RIL_Errno e, void *response,
11903 size_t responseLen) {
11904 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11905 if (response == NULL || responseLen != sizeof(int)) {
11906 RLOGE("voiceRadioTechChangedInd: invalid response");
11907 return 0;
11908 }
11909 int32_t rat = ((int32_t *) response)[0];
11910 #if VDBG
11911 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
11912 #endif
11913 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
11914 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
11915 radioService[slotId]->checkReturnStatus(retStatus);
11916 } else {
11917 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
11918 slotId);
11919 }
11920
11921 return 0;
11922 }
11923
convertRilCellInfoListToHal(void * response,size_t responseLen,hidl_vec<CellInfo> & records)11924 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
11925 int num = responseLen / sizeof(RIL_CellInfo_v12);
11926 records.resize(num);
11927
11928 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
11929 for (int i = 0; i < num; i++) {
11930 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
11931 records[i].registered = rillCellInfo->registered;
11932 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
11933 records[i].timeStamp = rillCellInfo->timeStamp;
11934 // All vectors should be size 0 except one which will be size 1. Set everything to
11935 // size 0 initially.
11936 records[i].gsm.resize(0);
11937 records[i].wcdma.resize(0);
11938 records[i].cdma.resize(0);
11939 records[i].lte.resize(0);
11940 records[i].tdscdma.resize(0);
11941 switch(rillCellInfo->cellInfoType) {
11942 case RIL_CELL_INFO_TYPE_GSM: {
11943 records[i].gsm.resize(1);
11944 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
11945 cellInfoGsm->cellIdentityGsm.mcc =
11946 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
11947 cellInfoGsm->cellIdentityGsm.mnc =
11948 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
11949 cellInfoGsm->cellIdentityGsm.lac =
11950 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
11951 cellInfoGsm->cellIdentityGsm.cid =
11952 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
11953 cellInfoGsm->cellIdentityGsm.arfcn =
11954 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
11955 cellInfoGsm->cellIdentityGsm.bsic =
11956 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
11957 cellInfoGsm->signalStrengthGsm.signalStrength =
11958 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
11959 cellInfoGsm->signalStrengthGsm.bitErrorRate =
11960 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
11961 cellInfoGsm->signalStrengthGsm.timingAdvance =
11962 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
11963 break;
11964 }
11965
11966 case RIL_CELL_INFO_TYPE_WCDMA: {
11967 records[i].wcdma.resize(1);
11968 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
11969 cellInfoWcdma->cellIdentityWcdma.mcc =
11970 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
11971 cellInfoWcdma->cellIdentityWcdma.mnc =
11972 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
11973 cellInfoWcdma->cellIdentityWcdma.lac =
11974 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
11975 cellInfoWcdma->cellIdentityWcdma.cid =
11976 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
11977 cellInfoWcdma->cellIdentityWcdma.psc =
11978 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
11979 cellInfoWcdma->cellIdentityWcdma.uarfcn =
11980 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
11981 cellInfoWcdma->signalStrengthWcdma.signalStrength =
11982 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
11983 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
11984 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
11985 break;
11986 }
11987
11988 case RIL_CELL_INFO_TYPE_CDMA: {
11989 records[i].cdma.resize(1);
11990 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
11991 cellInfoCdma->cellIdentityCdma.networkId =
11992 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
11993 cellInfoCdma->cellIdentityCdma.systemId =
11994 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
11995 cellInfoCdma->cellIdentityCdma.baseStationId =
11996 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
11997 cellInfoCdma->cellIdentityCdma.longitude =
11998 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
11999 cellInfoCdma->cellIdentityCdma.latitude =
12000 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12001 cellInfoCdma->signalStrengthCdma.dbm =
12002 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12003 cellInfoCdma->signalStrengthCdma.ecio =
12004 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12005 cellInfoCdma->signalStrengthEvdo.dbm =
12006 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12007 cellInfoCdma->signalStrengthEvdo.ecio =
12008 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12009 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
12010 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12011 break;
12012 }
12013
12014 case RIL_CELL_INFO_TYPE_LTE: {
12015 records[i].lte.resize(1);
12016 CellInfoLte *cellInfoLte = &records[i].lte[0];
12017 cellInfoLte->cellIdentityLte.mcc =
12018 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12019 cellInfoLte->cellIdentityLte.mnc =
12020 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12021 cellInfoLte->cellIdentityLte.ci =
12022 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12023 cellInfoLte->cellIdentityLte.pci =
12024 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12025 cellInfoLte->cellIdentityLte.tac =
12026 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12027 cellInfoLte->cellIdentityLte.earfcn =
12028 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12029 cellInfoLte->signalStrengthLte.signalStrength =
12030 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12031 cellInfoLte->signalStrengthLte.rsrp =
12032 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12033 cellInfoLte->signalStrengthLte.rsrq =
12034 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12035 cellInfoLte->signalStrengthLte.rssnr =
12036 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12037 cellInfoLte->signalStrengthLte.cqi =
12038 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12039 cellInfoLte->signalStrengthLte.timingAdvance =
12040 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12041 break;
12042 }
12043
12044 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12045 records[i].tdscdma.resize(1);
12046 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
12047 cellInfoTdscdma->cellIdentityTdscdma.mcc =
12048 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12049 cellInfoTdscdma->cellIdentityTdscdma.mnc =
12050 ril::util::mnc::decode(
12051 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12052 cellInfoTdscdma->cellIdentityTdscdma.lac =
12053 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12054 cellInfoTdscdma->cellIdentityTdscdma.cid =
12055 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12056 cellInfoTdscdma->cellIdentityTdscdma.cpid =
12057 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12058 cellInfoTdscdma->signalStrengthTdscdma.rscp =
12059 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12060 break;
12061 }
12062 default: {
12063 break;
12064 }
12065 }
12066 rillCellInfo += 1;
12067 }
12068 }
12069
convertRilCellInfoListToHal_1_2(void * response,size_t responseLen,hidl_vec<V1_2::CellInfo> & records)12070 void convertRilCellInfoListToHal_1_2(void *response, size_t responseLen, hidl_vec<V1_2::CellInfo>& records) {
12071 int num = responseLen / sizeof(RIL_CellInfo_v12);
12072 records.resize(num);
12073 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
12074 for (int i = 0; i < num; i++) {
12075 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
12076 records[i].registered = rillCellInfo->registered;
12077 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
12078 records[i].timeStamp = rillCellInfo->timeStamp;
12079 records[i].connectionStatus =(V1_2::CellConnectionStatus)0;
12080 // All vectors should be size 0 except one which will be size 1. Set everything to
12081 // size 0 initially.
12082 records[i].gsm.resize(0);
12083 records[i].wcdma.resize(0);
12084 records[i].cdma.resize(0);
12085 records[i].lte.resize(0);
12086 records[i].tdscdma.resize(0);
12087 switch(rillCellInfo->cellInfoType) {
12088 case RIL_CELL_INFO_TYPE_GSM: {
12089 records[i].gsm.resize(1);
12090 V1_2::CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
12091 cellInfoGsm->cellIdentityGsm.base.mcc =
12092 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12093 cellInfoGsm->cellIdentityGsm.base.mnc =
12094 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12095 cellInfoGsm->cellIdentityGsm.base.lac =
12096 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12097 cellInfoGsm->cellIdentityGsm.base.cid =
12098 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12099 cellInfoGsm->cellIdentityGsm.base.arfcn =
12100 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12101 cellInfoGsm->cellIdentityGsm.base.bsic =
12102 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12103 cellInfoGsm->signalStrengthGsm.signalStrength =
12104 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12105 cellInfoGsm->signalStrengthGsm.bitErrorRate =
12106 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12107 cellInfoGsm->signalStrengthGsm.timingAdvance =
12108 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12109 break;
12110 }
12111
12112 case RIL_CELL_INFO_TYPE_WCDMA: {
12113 records[i].wcdma.resize(1);
12114 V1_2::CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
12115 cellInfoWcdma->cellIdentityWcdma.base.mcc =
12116 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12117 cellInfoWcdma->cellIdentityWcdma.base.mnc =
12118 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12119 cellInfoWcdma->cellIdentityWcdma.base.lac =
12120 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12121 cellInfoWcdma->cellIdentityWcdma.base.cid =
12122 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12123 cellInfoWcdma->cellIdentityWcdma.base.psc =
12124 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12125 cellInfoWcdma->cellIdentityWcdma.base.uarfcn =
12126 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12127 cellInfoWcdma->signalStrengthWcdma.base.signalStrength =
12128 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12129 cellInfoWcdma->signalStrengthWcdma.base.bitErrorRate =
12130 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12131 break;
12132 }
12133
12134 case RIL_CELL_INFO_TYPE_CDMA: {
12135 records[i].cdma.resize(1);
12136 V1_2::CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
12137 cellInfoCdma->cellIdentityCdma.base.networkId =
12138 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12139 cellInfoCdma->cellIdentityCdma.base.systemId =
12140 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12141 cellInfoCdma->cellIdentityCdma.base.baseStationId =
12142 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12143 cellInfoCdma->cellIdentityCdma.base.longitude =
12144 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12145 cellInfoCdma->cellIdentityCdma.base.latitude =
12146 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12147 cellInfoCdma->signalStrengthCdma.dbm =
12148 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12149 cellInfoCdma->signalStrengthCdma.ecio =
12150 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12151 cellInfoCdma->signalStrengthEvdo.dbm =
12152 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12153 cellInfoCdma->signalStrengthEvdo.ecio =
12154 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12155 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
12156 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12157 break;
12158 }
12159
12160 case RIL_CELL_INFO_TYPE_LTE: {
12161 records[i].lte.resize(1);
12162 V1_2::CellInfoLte *cellInfoLte = &records[i].lte[0];
12163 cellInfoLte->cellIdentityLte.base.mcc =
12164 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12165 cellInfoLte->cellIdentityLte.base.mnc =
12166 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12167 cellInfoLte->cellIdentityLte.base.ci =
12168 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12169 cellInfoLte->cellIdentityLte.base.pci =
12170 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12171 cellInfoLte->cellIdentityLte.base.tac =
12172 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12173 cellInfoLte->cellIdentityLte.base.earfcn =
12174 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12175 cellInfoLte->signalStrengthLte.signalStrength =
12176 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12177 cellInfoLte->signalStrengthLte.rsrp =
12178 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12179 cellInfoLte->signalStrengthLte.rsrq =
12180 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12181 cellInfoLte->signalStrengthLte.rssnr =
12182 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12183 cellInfoLte->signalStrengthLte.cqi =
12184 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12185 cellInfoLte->signalStrengthLte.timingAdvance =
12186 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12187 break;
12188 }
12189
12190 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12191 records[i].tdscdma.resize(1);
12192 V1_2::CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
12193 cellInfoTdscdma->cellIdentityTdscdma.base.mcc =
12194 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12195 cellInfoTdscdma->cellIdentityTdscdma.base.mnc =
12196 ril::util::mnc::decode(
12197 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12198 cellInfoTdscdma->cellIdentityTdscdma.base.lac =
12199 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12200 cellInfoTdscdma->cellIdentityTdscdma.base.cid =
12201 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12202 cellInfoTdscdma->cellIdentityTdscdma.base.cpid =
12203 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12204 cellInfoTdscdma->signalStrengthTdscdma.rscp =
12205 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12206 break;
12207 }
12208 default: {
12209 break;
12210 }
12211 }
12212 rillCellInfo += 1;
12213 }
12214 }
12215
convertRilCellInfoListToHal_1_4(void * response,size_t responseLen,hidl_vec<V1_4::CellInfo> & records)12216 void convertRilCellInfoListToHal_1_4(void *response, size_t responseLen, hidl_vec<V1_4::CellInfo>& records) {
12217 int num = responseLen / sizeof(RIL_CellInfo_v16);
12218 records.resize(num);
12219 RIL_CellInfo_v16 *rillCellInfo = (RIL_CellInfo_v16 *) response;
12220 for (int i = 0; i < num; i++) {
12221 records[i].isRegistered = rillCellInfo->registered;
12222 records[i].connectionStatus = (V1_2::CellConnectionStatus)rillCellInfo->connectionStatus;
12223
12224 switch(rillCellInfo->cellInfoType) {
12225 case RIL_CELL_INFO_TYPE_GSM: {
12226 V1_2::CellInfoGsm cellInfoGsm;
12227 cellInfoGsm.cellIdentityGsm.base.mcc =
12228 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12229 cellInfoGsm.cellIdentityGsm.base.mnc =
12230 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12231 cellInfoGsm.cellIdentityGsm.base.lac =
12232 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12233 cellInfoGsm.cellIdentityGsm.base.cid =
12234 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12235 cellInfoGsm.cellIdentityGsm.base.arfcn =
12236 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12237 cellInfoGsm.cellIdentityGsm.base.bsic =
12238 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12239 cellInfoGsm.signalStrengthGsm.signalStrength =
12240 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12241 cellInfoGsm.signalStrengthGsm.bitErrorRate =
12242 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12243 cellInfoGsm.signalStrengthGsm.timingAdvance =
12244 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12245 records[i].info.gsm(cellInfoGsm);
12246 break;
12247 }
12248
12249 case RIL_CELL_INFO_TYPE_WCDMA: {
12250 V1_2::CellInfoWcdma cellInfoWcdma;
12251 cellInfoWcdma.cellIdentityWcdma.base.mcc =
12252 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12253 cellInfoWcdma.cellIdentityWcdma.base.mnc =
12254 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12255 cellInfoWcdma.cellIdentityWcdma.base.lac =
12256 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12257 cellInfoWcdma.cellIdentityWcdma.base.cid =
12258 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12259 cellInfoWcdma.cellIdentityWcdma.base.psc =
12260 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12261 cellInfoWcdma.cellIdentityWcdma.base.uarfcn =
12262 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12263 cellInfoWcdma.signalStrengthWcdma.base.signalStrength =
12264 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12265 cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate =
12266 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12267 records[i].info.wcdma(cellInfoWcdma);
12268 break;
12269 }
12270
12271 case RIL_CELL_INFO_TYPE_CDMA: {
12272 V1_2::CellInfoCdma cellInfoCdma;
12273 cellInfoCdma.cellIdentityCdma.base.networkId =
12274 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12275 cellInfoCdma.cellIdentityCdma.base.systemId =
12276 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12277 cellInfoCdma.cellIdentityCdma.base.baseStationId =
12278 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12279 cellInfoCdma.cellIdentityCdma.base.longitude =
12280 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12281 cellInfoCdma.cellIdentityCdma.base.latitude =
12282 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12283 cellInfoCdma.signalStrengthCdma.dbm =
12284 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12285 cellInfoCdma.signalStrengthCdma.ecio =
12286 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12287 cellInfoCdma.signalStrengthEvdo.dbm =
12288 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12289 cellInfoCdma.signalStrengthEvdo.ecio =
12290 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12291 cellInfoCdma.signalStrengthEvdo.signalNoiseRatio =
12292 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12293 records[i].info.cdma(cellInfoCdma);
12294 break;
12295 }
12296
12297 case RIL_CELL_INFO_TYPE_LTE: {
12298 V1_4::CellInfoLte cellInfoLte;
12299 cellInfoLte.base.cellIdentityLte.base.mcc =
12300 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12301 cellInfoLte.base.cellIdentityLte.base.mnc =
12302 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12303 cellInfoLte.base.cellIdentityLte.base.ci =
12304 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12305 cellInfoLte.base.cellIdentityLte.base.pci =
12306 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12307 cellInfoLte.base.cellIdentityLte.base.tac =
12308 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12309 cellInfoLte.base.cellIdentityLte.base.earfcn =
12310 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12311 cellInfoLte.base.signalStrengthLte.signalStrength =
12312 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12313 cellInfoLte.base.signalStrengthLte.rsrp =
12314 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12315 cellInfoLte.base.signalStrengthLte.rsrq =
12316 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12317 cellInfoLte.base.signalStrengthLte.rssnr =
12318 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12319 cellInfoLte.base.signalStrengthLte.cqi =
12320 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12321 cellInfoLte.base.signalStrengthLte.timingAdvance =
12322 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12323 records[i].info.lte(cellInfoLte);
12324 break;
12325 }
12326
12327 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12328 V1_2::CellInfoTdscdma cellInfoTdscdma;
12329 cellInfoTdscdma.cellIdentityTdscdma.base.mcc =
12330 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12331 cellInfoTdscdma.cellIdentityTdscdma.base.mnc =
12332 ril::util::mnc::decode(
12333 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12334 cellInfoTdscdma.cellIdentityTdscdma.base.lac =
12335 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12336 cellInfoTdscdma.cellIdentityTdscdma.base.cid =
12337 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12338 cellInfoTdscdma.cellIdentityTdscdma.base.cpid =
12339 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12340 cellInfoTdscdma.signalStrengthTdscdma.rscp =
12341 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12342 records[i].info.tdscdma(cellInfoTdscdma);
12343 break;
12344 }
12345
12346 case RIL_CELL_INFO_TYPE_NR: {
12347 V1_4::CellInfoNr cellInfoNr;
12348 cellInfoNr.cellidentity.mcc =
12349 std::to_string(rillCellInfo->CellInfo.nr.cellidentity.mcc);
12350 cellInfoNr.cellidentity.mnc =
12351 ril::util::mnc::decode(
12352 rillCellInfo->CellInfo.nr.cellidentity.mnc);
12353 cellInfoNr.cellidentity.nci =
12354 rillCellInfo->CellInfo.nr.cellidentity.nci;
12355 cellInfoNr.cellidentity.pci =
12356 rillCellInfo->CellInfo.nr.cellidentity.pci;
12357 cellInfoNr.cellidentity.tac =
12358 rillCellInfo->CellInfo.nr.cellidentity.tac;
12359 cellInfoNr.cellidentity.nrarfcn =
12360 rillCellInfo->CellInfo.nr.cellidentity.nrarfcn;
12361 cellInfoNr.cellidentity.operatorNames.alphaLong =
12362 convertCharPtrToHidlString(rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaLong);
12363 cellInfoNr.cellidentity.operatorNames.alphaShort =
12364 convertCharPtrToHidlString(rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaShort);
12365
12366 cellInfoNr.signalStrength.ssRsrp =
12367 rillCellInfo->CellInfo.nr.signalStrength.ssRsrp;
12368 cellInfoNr.signalStrength.ssRsrq =
12369 rillCellInfo->CellInfo.nr.signalStrength.ssRsrq;
12370 cellInfoNr.signalStrength.ssSinr =
12371 rillCellInfo->CellInfo.nr.signalStrength.ssSinr;
12372 cellInfoNr.signalStrength.csiRsrp =
12373 rillCellInfo->CellInfo.nr.signalStrength.csiRsrp;
12374 cellInfoNr.signalStrength.csiRsrq =
12375 rillCellInfo->CellInfo.nr.signalStrength.csiRsrq;
12376 cellInfoNr.signalStrength.csiSinr =
12377 rillCellInfo->CellInfo.nr.signalStrength.csiSinr;
12378 records[i].info.nr(cellInfoNr);
12379 break;
12380 }
12381 default: {
12382 break;
12383 }
12384 }
12385 rillCellInfo += 1;
12386 }
12387 }
12388
convertRilCellInfoListToHal_1_5(void * response,size_t responseLen,hidl_vec<V1_5::CellInfo> & records)12389 void convertRilCellInfoListToHal_1_5(void* response, size_t responseLen,
12390 hidl_vec<V1_5::CellInfo>& records) {
12391 int num = responseLen / sizeof(RIL_CellInfo_v16);
12392 records.resize(num);
12393 RIL_CellInfo_v16* rillCellInfo = (RIL_CellInfo_v16*)response;
12394 for (int i = 0; i < num; i++) {
12395 records[i].registered = rillCellInfo->registered;
12396 records[i].connectionStatus = (V1_2::CellConnectionStatus)rillCellInfo->connectionStatus;
12397
12398 switch (rillCellInfo->cellInfoType) {
12399 case RIL_CELL_INFO_TYPE_GSM: {
12400 V1_5::CellInfoGsm cellInfoGsm;
12401 cellInfoGsm.cellIdentityGsm.base.base.mcc =
12402 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12403 cellInfoGsm.cellIdentityGsm.base.base.mnc =
12404 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12405 cellInfoGsm.cellIdentityGsm.base.base.lac =
12406 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12407 cellInfoGsm.cellIdentityGsm.base.base.cid =
12408 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12409 cellInfoGsm.cellIdentityGsm.base.base.arfcn =
12410 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12411 cellInfoGsm.cellIdentityGsm.base.base.bsic =
12412 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12413 cellInfoGsm.signalStrengthGsm.signalStrength =
12414 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12415 cellInfoGsm.signalStrengthGsm.bitErrorRate =
12416 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12417 cellInfoGsm.signalStrengthGsm.timingAdvance =
12418 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12419 records[i].ratSpecificInfo.gsm(cellInfoGsm);
12420 break;
12421 }
12422
12423 case RIL_CELL_INFO_TYPE_WCDMA: {
12424 V1_5::CellInfoWcdma cellInfoWcdma;
12425 cellInfoWcdma.cellIdentityWcdma.base.base.mcc =
12426 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12427 cellInfoWcdma.cellIdentityWcdma.base.base.mnc =
12428 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12429 cellInfoWcdma.cellIdentityWcdma.base.base.lac =
12430 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12431 cellInfoWcdma.cellIdentityWcdma.base.base.cid =
12432 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12433 cellInfoWcdma.cellIdentityWcdma.base.base.psc =
12434 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12435 cellInfoWcdma.cellIdentityWcdma.base.base.uarfcn =
12436 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12437 cellInfoWcdma.signalStrengthWcdma.base.signalStrength =
12438 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12439 cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate =
12440 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12441 records[i].ratSpecificInfo.wcdma(cellInfoWcdma);
12442 break;
12443 }
12444
12445 case RIL_CELL_INFO_TYPE_CDMA: {
12446 V1_2::CellInfoCdma cellInfoCdma;
12447 cellInfoCdma.cellIdentityCdma.base.networkId =
12448 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12449 cellInfoCdma.cellIdentityCdma.base.systemId =
12450 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12451 cellInfoCdma.cellIdentityCdma.base.baseStationId =
12452 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12453 cellInfoCdma.cellIdentityCdma.base.longitude =
12454 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12455 cellInfoCdma.cellIdentityCdma.base.latitude =
12456 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12457 cellInfoCdma.signalStrengthCdma.dbm =
12458 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12459 cellInfoCdma.signalStrengthCdma.ecio =
12460 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12461 cellInfoCdma.signalStrengthEvdo.dbm =
12462 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12463 cellInfoCdma.signalStrengthEvdo.ecio =
12464 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12465 cellInfoCdma.signalStrengthEvdo.signalNoiseRatio =
12466 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12467 records[i].ratSpecificInfo.cdma(cellInfoCdma);
12468 break;
12469 }
12470
12471 case RIL_CELL_INFO_TYPE_LTE: {
12472 V1_5::CellInfoLte cellInfoLte;
12473 cellInfoLte.cellIdentityLte.base.base.mcc =
12474 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12475 cellInfoLte.cellIdentityLte.base.base.mnc =
12476 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12477 cellInfoLte.cellIdentityLte.base.base.ci =
12478 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12479 cellInfoLte.cellIdentityLte.base.base.pci =
12480 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12481 cellInfoLte.cellIdentityLte.base.base.tac =
12482 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12483 cellInfoLte.cellIdentityLte.base.base.earfcn =
12484 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12485 cellInfoLte.signalStrengthLte.signalStrength =
12486 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12487 cellInfoLte.signalStrengthLte.rsrp =
12488 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12489 cellInfoLte.signalStrengthLte.rsrq =
12490 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12491 cellInfoLte.signalStrengthLte.rssnr =
12492 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12493 cellInfoLte.signalStrengthLte.cqi =
12494 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12495 cellInfoLte.signalStrengthLte.timingAdvance =
12496 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12497 records[i].ratSpecificInfo.lte(cellInfoLte);
12498 break;
12499 }
12500
12501 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12502 V1_5::CellInfoTdscdma cellInfoTdscdma;
12503 cellInfoTdscdma.cellIdentityTdscdma.base.base.mcc =
12504 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12505 cellInfoTdscdma.cellIdentityTdscdma.base.base.mnc = ril::util::mnc::decode(
12506 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12507 cellInfoTdscdma.cellIdentityTdscdma.base.base.lac =
12508 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12509 cellInfoTdscdma.cellIdentityTdscdma.base.base.cid =
12510 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12511 cellInfoTdscdma.cellIdentityTdscdma.base.base.cpid =
12512 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12513 cellInfoTdscdma.signalStrengthTdscdma.rscp =
12514 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12515 records[i].ratSpecificInfo.tdscdma(cellInfoTdscdma);
12516 break;
12517 }
12518
12519 case RIL_CELL_INFO_TYPE_NR: {
12520 V1_5::CellInfoNr cellInfoNr;
12521 cellInfoNr.cellIdentityNr.base.mcc =
12522 std::to_string(rillCellInfo->CellInfo.nr.cellidentity.mcc);
12523 cellInfoNr.cellIdentityNr.base.mnc =
12524 ril::util::mnc::decode(rillCellInfo->CellInfo.nr.cellidentity.mnc);
12525 cellInfoNr.cellIdentityNr.base.nci = rillCellInfo->CellInfo.nr.cellidentity.nci;
12526 cellInfoNr.cellIdentityNr.base.pci = rillCellInfo->CellInfo.nr.cellidentity.pci;
12527 cellInfoNr.cellIdentityNr.base.tac = rillCellInfo->CellInfo.nr.cellidentity.tac;
12528 cellInfoNr.cellIdentityNr.base.nrarfcn =
12529 rillCellInfo->CellInfo.nr.cellidentity.nrarfcn;
12530 cellInfoNr.cellIdentityNr.base.operatorNames.alphaLong = convertCharPtrToHidlString(
12531 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaLong);
12532 cellInfoNr.cellIdentityNr.base.operatorNames.alphaShort =
12533 convertCharPtrToHidlString(
12534 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaShort);
12535
12536 cellInfoNr.signalStrengthNr.ssRsrp =
12537 rillCellInfo->CellInfo.nr.signalStrength.ssRsrp;
12538 cellInfoNr.signalStrengthNr.ssRsrq =
12539 rillCellInfo->CellInfo.nr.signalStrength.ssRsrq;
12540 cellInfoNr.signalStrengthNr.ssSinr =
12541 rillCellInfo->CellInfo.nr.signalStrength.ssSinr;
12542 cellInfoNr.signalStrengthNr.csiRsrp =
12543 rillCellInfo->CellInfo.nr.signalStrength.csiRsrp;
12544 cellInfoNr.signalStrengthNr.csiRsrq =
12545 rillCellInfo->CellInfo.nr.signalStrength.csiRsrq;
12546 cellInfoNr.signalStrengthNr.csiSinr =
12547 rillCellInfo->CellInfo.nr.signalStrength.csiSinr;
12548 records[i].ratSpecificInfo.nr(cellInfoNr);
12549 break;
12550 }
12551 default: {
12552 break;
12553 }
12554 }
12555 rillCellInfo += 1;
12556 }
12557 }
12558
convertRilCellInfoListToHal_1_6(void * response,size_t responseLen,hidl_vec<V1_6::CellInfo> & records)12559 void convertRilCellInfoListToHal_1_6(void* response, size_t responseLen,
12560 hidl_vec<V1_6::CellInfo>& records) {
12561 int num = responseLen / sizeof(RIL_CellInfo_v16);
12562 records.resize(num);
12563 RIL_CellInfo_v16* rillCellInfo = (RIL_CellInfo_v16*)response;
12564 for (int i = 0; i < num; i++) {
12565 records[i].registered = rillCellInfo->registered;
12566 records[i].connectionStatus = (V1_2::CellConnectionStatus)rillCellInfo->connectionStatus;
12567
12568 switch (rillCellInfo->cellInfoType) {
12569 case RIL_CELL_INFO_TYPE_GSM: {
12570 V1_5::CellInfoGsm cellInfoGsm;
12571 cellInfoGsm.cellIdentityGsm.base.base.mcc =
12572 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12573 cellInfoGsm.cellIdentityGsm.base.base.mnc =
12574 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12575 cellInfoGsm.cellIdentityGsm.base.base.lac =
12576 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12577 cellInfoGsm.cellIdentityGsm.base.base.cid =
12578 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12579 cellInfoGsm.cellIdentityGsm.base.base.arfcn =
12580 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12581 cellInfoGsm.cellIdentityGsm.base.base.bsic =
12582 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12583 cellInfoGsm.signalStrengthGsm.signalStrength =
12584 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12585 cellInfoGsm.signalStrengthGsm.bitErrorRate =
12586 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12587 cellInfoGsm.signalStrengthGsm.timingAdvance =
12588 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12589 records[i].ratSpecificInfo.gsm(cellInfoGsm);
12590 break;
12591 }
12592
12593 case RIL_CELL_INFO_TYPE_WCDMA: {
12594 V1_5::CellInfoWcdma cellInfoWcdma;
12595 cellInfoWcdma.cellIdentityWcdma.base.base.mcc =
12596 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12597 cellInfoWcdma.cellIdentityWcdma.base.base.mnc =
12598 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12599 cellInfoWcdma.cellIdentityWcdma.base.base.lac =
12600 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12601 cellInfoWcdma.cellIdentityWcdma.base.base.cid =
12602 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12603 cellInfoWcdma.cellIdentityWcdma.base.base.psc =
12604 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12605 cellInfoWcdma.cellIdentityWcdma.base.base.uarfcn =
12606 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12607 cellInfoWcdma.signalStrengthWcdma.base.signalStrength =
12608 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12609 cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate =
12610 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12611 records[i].ratSpecificInfo.wcdma(cellInfoWcdma);
12612 break;
12613 }
12614
12615 case RIL_CELL_INFO_TYPE_CDMA: {
12616 V1_2::CellInfoCdma cellInfoCdma;
12617 cellInfoCdma.cellIdentityCdma.base.networkId =
12618 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12619 cellInfoCdma.cellIdentityCdma.base.systemId =
12620 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12621 cellInfoCdma.cellIdentityCdma.base.baseStationId =
12622 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12623 cellInfoCdma.cellIdentityCdma.base.longitude =
12624 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12625 cellInfoCdma.cellIdentityCdma.base.latitude =
12626 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12627 cellInfoCdma.signalStrengthCdma.dbm =
12628 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12629 cellInfoCdma.signalStrengthCdma.ecio =
12630 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12631 cellInfoCdma.signalStrengthEvdo.dbm =
12632 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12633 cellInfoCdma.signalStrengthEvdo.ecio =
12634 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12635 cellInfoCdma.signalStrengthEvdo.signalNoiseRatio =
12636 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12637 records[i].ratSpecificInfo.cdma(cellInfoCdma);
12638 break;
12639 }
12640
12641 case RIL_CELL_INFO_TYPE_LTE: {
12642 V1_6::CellInfoLte cellInfoLte;
12643 cellInfoLte.cellIdentityLte.base.base.mcc =
12644 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12645 cellInfoLte.cellIdentityLte.base.base.mnc =
12646 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12647 cellInfoLte.cellIdentityLte.base.base.ci =
12648 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12649 cellInfoLte.cellIdentityLte.base.base.pci =
12650 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12651 cellInfoLte.cellIdentityLte.base.base.tac =
12652 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12653 cellInfoLte.cellIdentityLte.base.base.earfcn =
12654 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12655 cellInfoLte.cellIdentityLte.base.bandwidth = INT_MAX;
12656 hidl_vec<V1_5::EutranBands> bands;
12657 bands.resize(1);
12658 bands[0] = V1_5::EutranBands::BAND_1;
12659 cellInfoLte.cellIdentityLte.bands = bands;
12660 cellInfoLte.signalStrengthLte.base.signalStrength =
12661 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12662 cellInfoLte.signalStrengthLte.base.rsrp =
12663 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12664 cellInfoLte.signalStrengthLte.base.rsrq =
12665 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12666 cellInfoLte.signalStrengthLte.base.rssnr =
12667 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12668 cellInfoLte.signalStrengthLte.base.cqi =
12669 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12670 cellInfoLte.signalStrengthLte.base.timingAdvance =
12671 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12672 records[i].ratSpecificInfo.lte(cellInfoLte);
12673 break;
12674 }
12675
12676 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12677 V1_5::CellInfoTdscdma cellInfoTdscdma;
12678 cellInfoTdscdma.cellIdentityTdscdma.base.base.mcc =
12679 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12680 cellInfoTdscdma.cellIdentityTdscdma.base.base.mnc = ril::util::mnc::decode(
12681 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12682 cellInfoTdscdma.cellIdentityTdscdma.base.base.lac =
12683 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12684 cellInfoTdscdma.cellIdentityTdscdma.base.base.cid =
12685 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12686 cellInfoTdscdma.cellIdentityTdscdma.base.base.cpid =
12687 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12688 cellInfoTdscdma.signalStrengthTdscdma.rscp =
12689 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12690 records[i].ratSpecificInfo.tdscdma(cellInfoTdscdma);
12691 break;
12692 }
12693
12694 case RIL_CELL_INFO_TYPE_NR: {
12695 V1_6::CellInfoNr cellInfoNr;
12696 cellInfoNr.cellIdentityNr.base.mcc =
12697 std::to_string(rillCellInfo->CellInfo.nr.cellidentity.mcc);
12698 cellInfoNr.cellIdentityNr.base.mnc =
12699 ril::util::mnc::decode(rillCellInfo->CellInfo.nr.cellidentity.mnc);
12700 cellInfoNr.cellIdentityNr.base.nci = rillCellInfo->CellInfo.nr.cellidentity.nci;
12701 cellInfoNr.cellIdentityNr.base.pci = rillCellInfo->CellInfo.nr.cellidentity.pci;
12702 cellInfoNr.cellIdentityNr.base.tac = rillCellInfo->CellInfo.nr.cellidentity.tac;
12703 cellInfoNr.cellIdentityNr.base.nrarfcn =
12704 rillCellInfo->CellInfo.nr.cellidentity.nrarfcn;
12705 cellInfoNr.cellIdentityNr.base.operatorNames.alphaLong = convertCharPtrToHidlString(
12706 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaLong);
12707 cellInfoNr.cellIdentityNr.base.operatorNames.alphaShort =
12708 convertCharPtrToHidlString(
12709 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaShort);
12710
12711 cellInfoNr.signalStrengthNr.base.ssRsrp =
12712 rillCellInfo->CellInfo.nr.signalStrength.ssRsrp;
12713 cellInfoNr.signalStrengthNr.base.ssRsrq =
12714 rillCellInfo->CellInfo.nr.signalStrength.ssRsrq;
12715 cellInfoNr.signalStrengthNr.base.ssSinr =
12716 rillCellInfo->CellInfo.nr.signalStrength.ssSinr;
12717 cellInfoNr.signalStrengthNr.base.csiRsrp =
12718 rillCellInfo->CellInfo.nr.signalStrength.csiRsrp;
12719 cellInfoNr.signalStrengthNr.base.csiRsrq =
12720 rillCellInfo->CellInfo.nr.signalStrength.csiRsrq;
12721 cellInfoNr.signalStrengthNr.base.csiSinr =
12722 rillCellInfo->CellInfo.nr.signalStrength.csiSinr;
12723 records[i].ratSpecificInfo.nr(cellInfoNr);
12724 break;
12725 }
12726 default: {
12727 break;
12728 }
12729 }
12730 rillCellInfo += 1;
12731 }
12732 }
12733
cellInfoListInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12734 int radio_1_6::cellInfoListInd(int slotId,
12735 int indicationType, int token, RIL_Errno e, void *response,
12736 size_t responseLen) {
12737 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12738 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
12739 RLOGE("cellInfoListInd: invalid response");
12740 return 0;
12741 }
12742
12743 hidl_vec<CellInfo> records;
12744 convertRilCellInfoListToHal(response, responseLen, records);
12745
12746 #if VDBG
12747 RLOGD("cellInfoListInd");
12748 #endif
12749 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
12750 convertIntToRadioIndicationType(indicationType), records);
12751 radioService[slotId]->checkReturnStatus(retStatus);
12752 } else {
12753 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
12754 }
12755
12756 return 0;
12757 }
12758
imsNetworkStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12759 int radio_1_6::imsNetworkStateChangedInd(int slotId,
12760 int indicationType, int token, RIL_Errno e, void *response,
12761 size_t responseLen) {
12762 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12763 #if VDBG
12764 RLOGD("imsNetworkStateChangedInd");
12765 #endif
12766 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
12767 convertIntToRadioIndicationType(indicationType));
12768 radioService[slotId]->checkReturnStatus(retStatus);
12769 } else {
12770 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
12771 slotId);
12772 }
12773
12774 return 0;
12775 }
12776
subscriptionStatusChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12777 int radio_1_6::subscriptionStatusChangedInd(int slotId,
12778 int indicationType, int token, RIL_Errno e, void *response,
12779 size_t responseLen) {
12780 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12781 if (response == NULL || responseLen != sizeof(int)) {
12782 RLOGE("subscriptionStatusChangedInd: invalid response");
12783 return 0;
12784 }
12785 bool activate = ((int32_t *) response)[0];
12786 #if VDBG
12787 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
12788 #endif
12789 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
12790 convertIntToRadioIndicationType(indicationType), activate);
12791 radioService[slotId]->checkReturnStatus(retStatus);
12792 } else {
12793 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
12794 slotId);
12795 }
12796
12797 return 0;
12798 }
12799
srvccStateNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12800 int radio_1_6::srvccStateNotifyInd(int slotId,
12801 int indicationType, int token, RIL_Errno e, void *response,
12802 size_t responseLen) {
12803 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12804 if (response == NULL || responseLen != sizeof(int)) {
12805 RLOGE("srvccStateNotifyInd: invalid response");
12806 return 0;
12807 }
12808 int32_t state = ((int32_t *) response)[0];
12809 #if VDBG
12810 RLOGD("srvccStateNotifyInd: rat %d", state);
12811 #endif
12812 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
12813 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
12814 radioService[slotId]->checkReturnStatus(retStatus);
12815 } else {
12816 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
12817 }
12818
12819 return 0;
12820 }
12821
convertRilHardwareConfigListToHal(void * response,size_t responseLen,hidl_vec<HardwareConfig> & records)12822 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
12823 hidl_vec<HardwareConfig>& records) {
12824 int num = responseLen / sizeof(RIL_HardwareConfig);
12825 records.resize(num);
12826
12827 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
12828 for (int i = 0; i < num; i++) {
12829 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
12830 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
12831 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
12832 switch (rilHardwareConfig[i].type) {
12833 case RIL_HARDWARE_CONFIG_MODEM: {
12834 records[i].modem.resize(1);
12835 records[i].sim.resize(0);
12836 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
12837 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
12838 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
12839 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
12840 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
12841 break;
12842 }
12843
12844 case RIL_HARDWARE_CONFIG_SIM: {
12845 records[i].sim.resize(1);
12846 records[i].modem.resize(0);
12847 records[i].sim[0].modemUuid =
12848 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
12849 break;
12850 }
12851 }
12852 }
12853 }
12854
hardwareConfigChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12855 int radio_1_6::hardwareConfigChangedInd(int slotId,
12856 int indicationType, int token, RIL_Errno e, void *response,
12857 size_t responseLen) {
12858 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12859 if ((response == NULL && responseLen != 0)
12860 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
12861 RLOGE("hardwareConfigChangedInd: invalid response");
12862 return 0;
12863 }
12864
12865 hidl_vec<HardwareConfig> configs;
12866 convertRilHardwareConfigListToHal(response, responseLen, configs);
12867
12868 #if VDBG
12869 RLOGD("hardwareConfigChangedInd");
12870 #endif
12871 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
12872 convertIntToRadioIndicationType(indicationType), configs);
12873 radioService[slotId]->checkReturnStatus(retStatus);
12874 } else {
12875 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
12876 slotId);
12877 }
12878
12879 return 0;
12880 }
12881
convertRilRadioCapabilityToHal(void * response,size_t responseLen,RadioCapability & rc)12882 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
12883 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
12884 rc.session = rilRadioCapability->session;
12885 rc.phase = (V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
12886 rc.raf = rilRadioCapability->rat;
12887 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
12888 rc.status = (V1_0::RadioCapabilityStatus) rilRadioCapability->status;
12889 }
12890
radioCapabilityIndicationInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12891 int radio_1_6::radioCapabilityIndicationInd(int slotId,
12892 int indicationType, int token, RIL_Errno e, void *response,
12893 size_t responseLen) {
12894 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12895 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
12896 RLOGE("radioCapabilityIndicationInd: invalid response");
12897 return 0;
12898 }
12899
12900 RadioCapability rc = {};
12901 convertRilRadioCapabilityToHal(response, responseLen, rc);
12902
12903 #if VDBG
12904 RLOGD("radioCapabilityIndicationInd");
12905 #endif
12906 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
12907 convertIntToRadioIndicationType(indicationType), rc);
12908 radioService[slotId]->checkReturnStatus(retStatus);
12909 } else {
12910 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
12911 slotId);
12912 }
12913
12914 return 0;
12915 }
12916
isServiceTypeCfQuery(RIL_SsServiceType serType,RIL_SsRequestType reqType)12917 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
12918 if ((reqType == SS_INTERROGATION) &&
12919 (serType == SS_CFU ||
12920 serType == SS_CF_BUSY ||
12921 serType == SS_CF_NO_REPLY ||
12922 serType == SS_CF_NOT_REACHABLE ||
12923 serType == SS_CF_ALL ||
12924 serType == SS_CF_ALL_CONDITIONAL)) {
12925 return true;
12926 }
12927 return false;
12928 }
12929
onSupplementaryServiceIndicationInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12930 int radio_1_6::onSupplementaryServiceIndicationInd(int slotId,
12931 int indicationType, int token, RIL_Errno e,
12932 void *response, size_t responseLen) {
12933 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12934 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
12935 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
12936 return 0;
12937 }
12938
12939 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
12940 StkCcUnsolSsResult ss = {};
12941 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
12942 ss.requestType = (SsRequestType) rilSsResponse->requestType;
12943 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
12944 ss.serviceClass = rilSsResponse->serviceClass;
12945 ss.result = (RadioError) rilSsResponse->result;
12946
12947 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
12948 #if VDBG
12949 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
12950 rilSsResponse->cfData.numValidIndexes);
12951 #endif
12952 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
12953 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
12954 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
12955 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
12956 }
12957
12958 ss.cfData.resize(1);
12959 ss.ssInfo.resize(0);
12960
12961 /* number of call info's */
12962 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
12963
12964 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
12965 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
12966 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
12967
12968 cfInfo->status = (CallForwardInfoStatus) cf.status;
12969 cfInfo->reason = cf.reason;
12970 cfInfo->serviceClass = cf.serviceClass;
12971 cfInfo->toa = cf.toa;
12972 cfInfo->number = convertCharPtrToHidlString(cf.number);
12973 cfInfo->timeSeconds = cf.timeSeconds;
12974 #if VDBG
12975 RLOGD("onSupplementaryServiceIndicationInd: "
12976 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
12977 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
12978 #endif
12979 }
12980 } else {
12981 ss.ssInfo.resize(1);
12982 ss.cfData.resize(0);
12983
12984 /* each int */
12985 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
12986 for (int i = 0; i < SS_INFO_MAX; i++) {
12987 #if VDBG
12988 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
12989 rilSsResponse->ssInfo[i]);
12990 #endif
12991 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
12992 }
12993 }
12994
12995 #if VDBG
12996 RLOGD("onSupplementaryServiceIndicationInd");
12997 #endif
12998 Return<void> retStatus = radioService[slotId]->mRadioIndication->
12999 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
13000 ss);
13001 radioService[slotId]->checkReturnStatus(retStatus);
13002 } else {
13003 RLOGE("onSupplementaryServiceIndicationInd: "
13004 "radioService[%d]->mRadioIndication == NULL", slotId);
13005 }
13006
13007 return 0;
13008 }
13009
stkCallControlAlphaNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13010 int radio_1_6::stkCallControlAlphaNotifyInd(int slotId,
13011 int indicationType, int token, RIL_Errno e, void *response,
13012 size_t responseLen) {
13013 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13014 if (response == NULL || responseLen == 0) {
13015 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
13016 return 0;
13017 }
13018 #if VDBG
13019 RLOGD("stkCallControlAlphaNotifyInd");
13020 #endif
13021 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
13022 convertIntToRadioIndicationType(indicationType),
13023 convertCharPtrToHidlString((char *) response));
13024 radioService[slotId]->checkReturnStatus(retStatus);
13025 } else {
13026 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
13027 slotId);
13028 }
13029
13030 return 0;
13031 }
13032
convertRilLceDataInfoToHal(void * response,size_t responseLen,LceDataInfo & lce)13033 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
13034 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
13035 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
13036 lce.confidenceLevel = rilLceDataInfo->confidence_level;
13037 lce.lceSuspended = rilLceDataInfo->lce_suspended;
13038 }
13039
lceDataInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13040 int radio_1_6::lceDataInd(int slotId,
13041 int indicationType, int token, RIL_Errno e, void *response,
13042 size_t responseLen) {
13043 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13044 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
13045 RLOGE("lceDataInd: invalid response");
13046 return 0;
13047 }
13048
13049 LceDataInfo lce = {};
13050 convertRilLceDataInfoToHal(response, responseLen, lce);
13051 #if VDBG
13052 RLOGD("lceDataInd");
13053 #endif
13054 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
13055 convertIntToRadioIndicationType(indicationType), lce);
13056 radioService[slotId]->checkReturnStatus(retStatus);
13057 } else {
13058 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
13059 }
13060
13061 return 0;
13062 }
13063
pcoDataInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13064 int radio_1_6::pcoDataInd(int slotId,
13065 int indicationType, int token, RIL_Errno e, void *response,
13066 size_t responseLen) {
13067 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13068 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
13069 RLOGE("pcoDataInd: invalid response");
13070 return 0;
13071 }
13072
13073 PcoDataInfo pco = {};
13074 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
13075 pco.cid = rilPcoData->cid;
13076 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
13077 pco.pcoId = rilPcoData->pco_id;
13078 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
13079
13080 #if VDBG
13081 RLOGD("pcoDataInd");
13082 #endif
13083 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
13084 convertIntToRadioIndicationType(indicationType), pco);
13085 radioService[slotId]->checkReturnStatus(retStatus);
13086 } else {
13087 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
13088 }
13089
13090 return 0;
13091 }
13092
modemResetInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13093 int radio_1_6::modemResetInd(int slotId,
13094 int indicationType, int token, RIL_Errno e, void *response,
13095 size_t responseLen) {
13096 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13097 if (response == NULL || responseLen == 0) {
13098 RLOGE("modemResetInd: invalid response");
13099 return 0;
13100 }
13101 #if VDBG
13102 RLOGD("modemResetInd");
13103 #endif
13104 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
13105 convertIntToRadioIndicationType(indicationType),
13106 convertCharPtrToHidlString((char *) response));
13107 radioService[slotId]->checkReturnStatus(retStatus);
13108 } else {
13109 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
13110 }
13111
13112 return 0;
13113 }
13114
networkScanResultInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13115 int radio_1_6::networkScanResultInd(int slotId, int indicationType, int token, RIL_Errno e,
13116 void* response, size_t responseLen) {
13117 #if VDBG
13118 RLOGD("networkScanResultInd");
13119 #endif
13120 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndicationV1_6 != NULL ||
13121 radioService[slotId]->mRadioIndicationV1_5 != NULL ||
13122 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
13123 radioService[slotId]->mRadioIndicationV1_2 != NULL ||
13124 radioService[slotId]->mRadioIndicationV1_1 != NULL)) {
13125 if (response == NULL || responseLen == 0) {
13126 RLOGE("networkScanResultInd: invalid response");
13127 return 0;
13128 }
13129 RLOGD("networkScanResultInd");
13130
13131 RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
13132 Return<void> retStatus;
13133 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
13134 V1_6::NetworkScanResult result;
13135 result.status = (V1_1::ScanStatus)networkScanResult->status;
13136 result.error = (V1_6::RadioError)networkScanResult->error;
13137 convertRilCellInfoListToHal_1_6(
13138 networkScanResult->network_infos,
13139 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v16),
13140 result.networkInfos);
13141 retStatus = radioService[slotId]->mRadioIndicationV1_6->networkScanResult_1_6(
13142 convertIntToRadioIndicationType(indicationType), result);
13143 } else if (radioService[slotId]->mRadioIndicationV1_5 != NULL) {
13144 V1_5::NetworkScanResult result;
13145 result.status = (V1_1::ScanStatus)networkScanResult->status;
13146 result.error = (RadioError)networkScanResult->error;
13147 convertRilCellInfoListToHal_1_5(
13148 networkScanResult->network_infos,
13149 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
13150 result.networkInfos);
13151 retStatus = radioService[slotId]->mRadioIndicationV1_5->networkScanResult_1_5(
13152 convertIntToRadioIndicationType(indicationType), result);
13153 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
13154 V1_4::NetworkScanResult result;
13155 result.status = (V1_1::ScanStatus)networkScanResult->status;
13156 result.error = (RadioError)networkScanResult->error;
13157 convertRilCellInfoListToHal_1_4(
13158 networkScanResult->network_infos,
13159 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
13160 result.networkInfos);
13161 retStatus = radioService[slotId]->mRadioIndicationV1_4->networkScanResult_1_4(
13162 convertIntToRadioIndicationType(indicationType), result);
13163 } else if (radioService[slotId]->mRadioIndicationV1_2 != NULL) {
13164 V1_2::NetworkScanResult result;
13165 result.status = (V1_1::ScanStatus)networkScanResult->status;
13166 result.error = (RadioError)networkScanResult->error;
13167 convertRilCellInfoListToHal_1_2(
13168 networkScanResult->network_infos,
13169 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
13170 result.networkInfos);
13171 retStatus = radioService[slotId]->mRadioIndicationV1_2->networkScanResult_1_2(
13172 convertIntToRadioIndicationType(indicationType), result);
13173 } else {
13174 V1_1::NetworkScanResult result;
13175 result.status = (V1_1::ScanStatus)networkScanResult->status;
13176 result.error = (RadioError)networkScanResult->error;
13177 convertRilCellInfoListToHal(
13178 networkScanResult->network_infos,
13179 networkScanResult->network_infos_length * sizeof(RIL_CellInfo),
13180 result.networkInfos);
13181 retStatus = radioService[slotId]->mRadioIndicationV1_1->networkScanResult(
13182 convertIntToRadioIndicationType(indicationType), result);
13183 }
13184 radioService[slotId]->checkReturnStatus(retStatus);
13185 } else {
13186 RLOGE("networkScanResultInd: radioService[%d]->mRadioIndication == NULL", slotId);
13187 }
13188 return 0;
13189 }
13190
carrierInfoForImsiEncryption(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13191 int radio_1_6::carrierInfoForImsiEncryption(int slotId, int indicationType, int token, RIL_Errno e,
13192 void* response, size_t responseLen) {
13193 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndicationV1_2 != NULL)) {
13194 if (response == NULL || responseLen == 0) {
13195 RLOGE("carrierInfoForImsiEncryption: invalid response");
13196 return 0;
13197 }
13198 RLOGD("carrierInfoForImsiEncryption");
13199 Return<void> retStatus =
13200 radioService[slotId]->mRadioIndicationV1_2->carrierInfoForImsiEncryption(
13201 convertIntToRadioIndicationType(indicationType));
13202 radioService[slotId]->checkReturnStatus(retStatus);
13203 } else {
13204 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndication == NULL", slotId);
13205 }
13206
13207 return 0;
13208 }
13209
reportPhysicalChannelConfigs(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13210 int radio_1_6::reportPhysicalChannelConfigs(int slotId, int indicationType, int token, RIL_Errno e,
13211 void* response, size_t responseLen) {
13212 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndicationV1_6 != NULL ||
13213 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
13214 radioService[slotId]->mRadioIndicationV1_2 != NULL)) {
13215 int* configs = (int*)response;
13216 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
13217 hidl_vec<V1_6::PhysicalChannelConfig> physChanConfig;
13218 physChanConfig.resize(1);
13219 physChanConfig[0].status = (V1_2::CellConnectionStatus)configs[0];
13220 physChanConfig[0].cellBandwidthDownlinkKhz = configs[1];
13221 physChanConfig[0].rat = (V1_4::RadioTechnology)configs[2];
13222 physChanConfig[0].contextIds.resize(1);
13223 physChanConfig[0].contextIds[0] = configs[4];
13224 RLOGD("reportPhysicalChannelConfigs_1_6: %d %d %d %d %d", configs[0], configs[1],
13225 configs[2], configs[3], configs[4]);
13226 Return<void> retStatus =
13227 radioService[slotId]->mRadioIndicationV1_6->currentPhysicalChannelConfigs_1_6(
13228 RadioIndicationType::UNSOLICITED, physChanConfig);
13229 radioService[slotId]->checkReturnStatus(retStatus);
13230 {
13231 // Just send the link estimate along with physical channel config, as it has
13232 // at least the downlink bandwidth.
13233 // Note: the bandwidth is just some hardcoded value, as there is not way to get
13234 // that reliably on virtual devices, as of now.
13235 V1_6::LinkCapacityEstimate lce = {
13236 .downlinkCapacityKbps = static_cast<uint32_t>(configs[1]),
13237 .uplinkCapacityKbps = static_cast<uint32_t>(configs[1])};
13238 RLOGD("reporting link capacity estimate download: %d upload: %d",
13239 lce.downlinkCapacityKbps, lce.uplinkCapacityKbps);
13240 Return<void> retStatus =
13241 radioService[slotId]->mRadioIndicationV1_6->currentLinkCapacityEstimate_1_6(
13242 RadioIndicationType::UNSOLICITED, lce);
13243 radioService[slotId]->checkReturnStatus(retStatus);
13244 }
13245 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
13246 hidl_vec<PhysicalChannelConfigV1_4> physChanConfig;
13247 physChanConfig.resize(1);
13248 physChanConfig[0].base.status = (V1_2::CellConnectionStatus)configs[0];
13249 physChanConfig[0].base.cellBandwidthDownlink = configs[1];
13250 physChanConfig[0].rat = (V1_4::RadioTechnology)configs[2];
13251 physChanConfig[0].rfInfo.range((V1_4::FrequencyRange)configs[3]);
13252 physChanConfig[0].contextIds.resize(1);
13253 physChanConfig[0].contextIds[0] = configs[4];
13254 RLOGD("reportPhysicalChannelConfigs_1_4: %d %d %d %d %d", configs[0], configs[1],
13255 configs[2], configs[3], configs[4]);
13256 Return<void> retStatus =
13257 radioService[slotId]->mRadioIndicationV1_4->currentPhysicalChannelConfigs_1_4(
13258 RadioIndicationType::UNSOLICITED, physChanConfig);
13259 radioService[slotId]->checkReturnStatus(retStatus);
13260 {
13261 // Just send the link estimate along with physical channel config, as it has
13262 // at least the downlink bandwidth.
13263 // Note: the bandwidth is just some hardcoded value, as there is not way to get
13264 // that reliably on virtual devices, as of now.
13265 V1_2::LinkCapacityEstimate lce = {
13266 .downlinkCapacityKbps = static_cast<uint32_t>(configs[1]),
13267 .uplinkCapacityKbps = static_cast<uint32_t>(configs[1])};
13268 RLOGD("reporting link capacity estimate download: %d upload: %d",
13269 lce.downlinkCapacityKbps, lce.uplinkCapacityKbps);
13270 Return<void> retStatus =
13271 radioService[slotId]->mRadioIndicationV1_4->currentLinkCapacityEstimate(
13272 RadioIndicationType::UNSOLICITED, lce);
13273 radioService[slotId]->checkReturnStatus(retStatus);
13274 }
13275 } else {
13276 hidl_vec<V1_2::PhysicalChannelConfig> physChanConfig;
13277 physChanConfig.resize(1);
13278 physChanConfig[0].status = (V1_2::CellConnectionStatus)configs[0];
13279 physChanConfig[0].cellBandwidthDownlink = configs[1];
13280 RLOGD("reportPhysicalChannelConfigs_1_2: %d %d", configs[0], configs[1]);
13281 Return<void> retStatus =
13282 radioService[slotId]->mRadioIndicationV1_2->currentPhysicalChannelConfigs(
13283 RadioIndicationType::UNSOLICITED, physChanConfig);
13284 radioService[slotId]->checkReturnStatus(retStatus);
13285 {
13286 // Just send the link estimate along with physical channel config, as it has
13287 // at least the downlink bandwidth.
13288 // Note: the bandwidth is just some hardcoded value, as there is not way to get
13289 // that reliably on virtual devices, as of now.
13290 V1_2::LinkCapacityEstimate lce = {
13291 .downlinkCapacityKbps = static_cast<uint32_t>(configs[1]),
13292 .uplinkCapacityKbps = static_cast<uint32_t>(configs[1])};
13293 RLOGD("reporting link capacity estimate download: %d upload: %d",
13294 lce.downlinkCapacityKbps, lce.uplinkCapacityKbps);
13295 Return<void> retStatus =
13296 radioService[slotId]->mRadioIndicationV1_2->currentLinkCapacityEstimate(
13297 RadioIndicationType::UNSOLICITED, lce);
13298 radioService[slotId]->checkReturnStatus(retStatus);
13299 }
13300 }
13301 } else {
13302 RLOGE("reportPhysicalChannelConfigs: radioService[%d]->mRadioIndication == NULL", slotId);
13303 return -1;
13304 }
13305 return 0;
13306 }
13307
keepaliveStatusInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13308 int radio_1_6::keepaliveStatusInd(int slotId,
13309 int indicationType, int token, RIL_Errno e, void *response,
13310 size_t responseLen) {
13311 #if VDBG
13312 RLOGD("%s(): token=%d", __FUNCTION__, token);
13313 #endif
13314 if (radioService[slotId] == NULL || radioService[slotId]->mRadioIndication == NULL) {
13315 RLOGE("%s: radioService[%d]->mRadioIndication == NULL", __FUNCTION__, slotId);
13316 return 0;
13317 }
13318
13319 auto ret = V1_1::IRadioIndication::castFrom(
13320 radioService[slotId]->mRadioIndication);
13321 if (!ret.isOk()) {
13322 RLOGE("%s: ret.isOk() == false for radioService[%d]", __FUNCTION__, slotId);
13323 return 0;
13324 }
13325 sp<V1_1::IRadioIndication> radioIndicationV1_1 = ret;
13326
13327 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
13328 RLOGE("%s: invalid response", __FUNCTION__);
13329 return 0;
13330 }
13331
13332 V1_1::KeepaliveStatus ks;
13333 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
13334
13335 Return<void> retStatus = radioIndicationV1_1->keepaliveStatus(
13336 convertIntToRadioIndicationType(indicationType), ks);
13337 radioService[slotId]->checkReturnStatus(retStatus);
13338 return 0;
13339 }
13340
oemHookRawInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13341 int radio_1_6::oemHookRawInd(int slotId,
13342 int indicationType, int token, RIL_Errno e, void *response,
13343 size_t responseLen) {
13344 if (!kOemHookEnabled) return 0;
13345
13346 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
13347 if (response == NULL || responseLen == 0) {
13348 RLOGE("oemHookRawInd: invalid response");
13349 return 0;
13350 }
13351
13352 hidl_vec<uint8_t> data;
13353 data.setToExternal((uint8_t *) response, responseLen);
13354 #if VDBG
13355 RLOGD("oemHookRawInd");
13356 #endif
13357 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
13358 convertIntToRadioIndicationType(indicationType), data);
13359 checkReturnStatus(slotId, retStatus, false);
13360 } else {
13361 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
13362 }
13363
13364 return 0;
13365 }
13366
13367 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)13368 static void publishRadioHal(std::shared_ptr<compat::DriverContext> ctx, sp<V1_5::IRadio> hidlHal,
13369 std::shared_ptr<compat::CallbackManager> cm, const std::string& slot) {
13370 static std::vector<std::shared_ptr<ndk::ICInterface>> gPublishedHals;
13371
13372 const auto instance = T::descriptor + "/"s + slot;
13373 RLOGD("Publishing %s", instance.c_str());
13374
13375 auto aidlHal = ndk::SharedRefBase::make<T>(ctx, hidlHal, cm);
13376 gPublishedHals.push_back(aidlHal);
13377 const auto status = AServiceManager_addService(aidlHal->asBinder().get(), instance.c_str());
13378 CHECK_EQ(status, STATUS_OK);
13379 }
13380
registerService(RIL_RadioFunctions * callbacks,CommandInfo * commands)13381 void radio_1_6::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
13382 using namespace android::hardware;
13383 int simCount = 1;
13384 const char *serviceNames[] = {
13385 android::RIL_getServiceName()
13386 #if (SIM_COUNT >= 2)
13387 , RIL2_SERVICE_NAME
13388 #if (SIM_COUNT >= 3)
13389 , RIL3_SERVICE_NAME
13390 #if (SIM_COUNT >= 4)
13391 , RIL4_SERVICE_NAME
13392 #endif
13393 #endif
13394 #endif
13395 };
13396
13397 #if (SIM_COUNT >= 2)
13398 simCount = SIM_COUNT;
13399 #endif
13400
13401 s_vendorFunctions = callbacks;
13402 s_commands = commands;
13403
13404 for (int i = 0; i < simCount; i++) {
13405 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
13406 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
13407 CHECK_EQ(ret, 0);
13408
13409 RLOGD("sim i = %d registering ...", i);
13410
13411 radioService[i] = new RadioImpl_1_6;
13412 radioService[i]->mSlotId = i;
13413 RLOGD("registerService: initializing power state to POWER_UP");
13414 radioService[i]->mSimCardPowerState = V1_1::CardPowerState::POWER_UP;
13415 RLOGD("registerService: starting android::hardware::radio::V1_6::IRadio %s for slot %d",
13416 serviceNames[i], i);
13417
13418 // use a compat shim to convert HIDL interface to AIDL and publish it
13419 // PLEASE NOTE this is a temporary solution
13420 auto radioHidl = radioService[i];
13421 const auto slot = serviceNames[i];
13422 auto context = std::make_shared<compat::DriverContext>();
13423 auto callbackMgr = std::make_shared<compat::CallbackManager>(context, radioHidl);
13424 publishRadioHal<compat::RadioData>(context, radioHidl, callbackMgr, slot);
13425 publishRadioHal<compat::RadioMessaging>(context, radioHidl, callbackMgr, slot);
13426 publishRadioHal<compat::RadioModem>(context, radioHidl, callbackMgr, slot);
13427 publishRadioHal<cf::ril::RefRadioNetwork>(context, radioHidl, callbackMgr, slot);
13428 publishRadioHal<compat::RadioSim>(context, radioHidl, callbackMgr, slot);
13429 publishRadioHal<compat::RadioVoice>(context, radioHidl, callbackMgr, slot);
13430
13431 RLOGD("registerService: OemHook is enabled = %s", kOemHookEnabled ? "true" : "false");
13432 if (kOemHookEnabled) {
13433 oemHookService[i] = new OemHookImpl;
13434 oemHookService[i]->mSlotId = i;
13435 // status = oemHookService[i]->registerAsService(serviceNames[i]);
13436 }
13437
13438 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
13439 CHECK_EQ(ret, 0);
13440 }
13441 }
13442
rilc_thread_pool()13443 void rilc_thread_pool() {
13444 ABinderProcess_joinThreadPool();
13445 }
13446
getRadioServiceRwlock(int slotId)13447 pthread_rwlock_t * radio_1_6::getRadioServiceRwlock(int slotId) {
13448 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
13449
13450 #if (SIM_COUNT >= 2)
13451 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
13452 #if (SIM_COUNT >= 3)
13453 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
13454 #if (SIM_COUNT >= 4)
13455 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
13456 #endif
13457 #endif
13458 #endif
13459
13460 return radioServiceRwlockPtr;
13461 }
13462
13463 // should acquire write lock for the corresponding service before calling this
setNitzTimeReceived(int slotId,long timeReceived)13464 void radio_1_6::setNitzTimeReceived(int slotId, long timeReceived) {
13465 nitzTimeReceived[slotId] = timeReceived;
13466 }
13467