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 "RefRadioSim.h"
20 #include "RefImsMedia.h"
21 #include "RefRadioIms.h"
22 #include "RefRadioModem.h"
23 #include "RefRadioNetwork.h"
24
25 #include <android-base/logging.h>
26 #include <android/binder_manager.h>
27 #include <android/binder_process.h>
28 #include <android/hardware/radio/1.6/IRadio.h>
29 #include <android/hardware/radio/1.6/IRadioIndication.h>
30 #include <android/hardware/radio/1.6/IRadioResponse.h>
31 #include <android/hardware/radio/1.6/types.h>
32 #include <libradiocompat/CallbackManager.h>
33 #include <libradiocompat/RadioData.h>
34 #include <libradiocompat/RadioIms.h>
35 #include <libradiocompat/RadioImsMedia.h>
36 #include <libradiocompat/RadioMessaging.h>
37 #include <libradiocompat/RadioModem.h>
38 #include <libradiocompat/RadioSim.h>
39 #include <libradiocompat/RadioVoice.h>
40
41 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
42
43 #include <hwbinder/IPCThreadState.h>
44 #include <hwbinder/ProcessState.h>
45 #include <guest/hals/ril/reference-libril/ril.h>
46 #include <telephony/ril_mnc.h>
47 #include <guest/hals/ril/reference-libril/ril_service.h>
48 #include <hidl/HidlTransportSupport.h>
49 #include <utils/SystemClock.h>
50 #include <inttypes.h>
51
52 #define INVALID_HEX_CHAR 16
53
54 using namespace android::hardware::radio;
55 using namespace android::hardware::radio::V1_0;
56 using namespace android::hardware::radio::deprecated::V1_0;
57 using namespace std::string_literals;
58 namespace compat = android::hardware::radio::compat;
59 using ::android::hardware::Return;
60 using ::android::hardware::hidl_bitfield;
61 using ::android::hardware::hidl_string;
62 using ::android::hardware::hidl_vec;
63 using ::android::hardware::hidl_array;
64 using ::android::hardware::Void;
65 using android::CommandInfo;
66 using android::RequestInfo;
67 using android::requestToString;
68 using android::sp;
69
70 using RegStateResultV1_6 = android::hardware::radio::V1_6::RegStateResult;
71 using RegStateResultV1_5 = android::hardware::radio::V1_5::RegStateResult;
72 using PhysicalChannelConfigV1_4 =
73 android::hardware::radio::V1_4::PhysicalChannelConfig;
74 using RadioTechnologyV1_4 = android::hardware::radio::V1_4::RadioTechnology;
75
76 #define BOOL_TO_INT(x) (x ? 1 : 0)
77 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
78 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
79
80 #if defined(ANDROID_MULTI_SIM)
81 #define CALL_ONREQUEST(a, b, c, d, e) \
82 s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e)))
83 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a))
84 #else
85 #define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d))
86 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
87 #endif
88
89 #ifdef OEM_HOOK_DISABLED
90 constexpr bool kOemHookEnabled = false;
91 #else
92 constexpr bool kOemHookEnabled = true;
93 #endif
94
95 RIL_RadioFunctions *s_vendorFunctions = NULL;
96 static CommandInfo *s_commands;
97
98 struct RadioImpl_1_6;
99 struct OemHookImpl;
100
101 #if (SIM_COUNT >= 2)
102 sp<RadioImpl_1_6> radioService[SIM_COUNT];
103 sp<OemHookImpl> oemHookService[SIM_COUNT];
104 int64_t nitzTimeReceived[SIM_COUNT];
105 // counter used for synchronization. It is incremented every time response callbacks are updated.
106 volatile int32_t mCounterRadio[SIM_COUNT];
107 volatile int32_t mCounterOemHook[SIM_COUNT];
108 #else
109 sp<RadioImpl_1_6> radioService[1];
110 sp<OemHookImpl> oemHookService[1];
111 int64_t nitzTimeReceived[1];
112 // counter used for synchronization. It is incremented every time response callbacks are updated.
113 volatile int32_t mCounterRadio[1];
114 volatile int32_t mCounterOemHook[1];
115 hidl_vec<uint8_t> osAppIdVec;
116 #endif
117
118 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
119
120 #if (SIM_COUNT >= 2)
121 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
122 #if (SIM_COUNT >= 3)
123 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
124 #if (SIM_COUNT >= 4)
125 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
126 #endif
127 #endif
128 #endif
129
130 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
131 hidl_vec<HardwareConfig>& records);
132
133 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
134
135 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
136
137 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
138 SignalStrength& signalStrength);
139
140 void convertRilSignalStrengthToHal_1_2(void* response, size_t responseLen,
141 V1_2::SignalStrength& signalStrength);
142
143 void convertRilSignalStrengthToHal_1_4(void *response, size_t responseLen,
144 V1_4::SignalStrength& signalStrength);
145
146 void convertRilSignalStrengthToHal_1_6(void* response, size_t responseLen,
147 V1_6::SignalStrength& signalStrength);
148
149 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse, SetupDataCallResult& dcResult);
150
151 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
152 V1_4::SetupDataCallResult& dcResult);
153
154 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
155 V1_5::SetupDataCallResult& dcResult);
156
157 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
158 V1_6::SetupDataCallResult& dcResult);
159
160 void convertRilDataCallListToHal(void *response, size_t responseLen,
161 hidl_vec<SetupDataCallResult>& dcResultList);
162
163 void convertRilDataCallListToHal_1_4(void* response, size_t responseLen,
164 hidl_vec<V1_4::SetupDataCallResult>& dcResultList);
165
166 void convertRilDataCallListToHal_1_5(void* response, size_t responseLen,
167 hidl_vec<V1_5::SetupDataCallResult>& dcResultList);
168
169 void convertRilDataCallListToHal_1_6(void* response, size_t responseLen,
170 hidl_vec<V1_6::SetupDataCallResult>& dcResultList);
171
172 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
173 void convertRilCellInfoListToHal_1_2(void *response, size_t responseLen, hidl_vec<V1_2::CellInfo>& records);
174 void convertRilCellInfoListToHal_1_4(void* response, size_t responseLen,
175 hidl_vec<V1_4::CellInfo>& records);
176 void convertRilCellInfoListToHal_1_5(void* response, size_t responseLen,
177 hidl_vec<V1_5::CellInfo>& records);
178 void convertRilCellInfoListToHal_1_6(void* response, size_t responseLen,
179 hidl_vec<V1_6::CellInfo>& records);
180
181 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
182 RIL_Errno e);
183
184 void populateResponseInfo_1_6(
185 ::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo,
186 int serial, int responseType, RIL_Errno e);
187
188 struct RadioImpl_1_6 : public V1_6::IRadio {
189 int32_t mSlotId;
190 V1_1::CardPowerState mSimCardPowerState;
191 sp<IRadioResponse> mRadioResponse;
192 sp<IRadioIndication> mRadioIndication;
193 sp<V1_1::IRadioResponse> mRadioResponseV1_1;
194 sp<V1_1::IRadioIndication> mRadioIndicationV1_1;
195 sp<V1_2::IRadioResponse> mRadioResponseV1_2;
196 sp<V1_2::IRadioIndication> mRadioIndicationV1_2;
197 sp<V1_3::IRadioResponse> mRadioResponseV1_3;
198 sp<V1_3::IRadioIndication> mRadioIndicationV1_3;
199 sp<V1_4::IRadioResponse> mRadioResponseV1_4;
200 sp<V1_4::IRadioIndication> mRadioIndicationV1_4;
201 sp<V1_5::IRadioResponse> mRadioResponseV1_5;
202 sp<V1_5::IRadioIndication> mRadioIndicationV1_5;
203 sp<V1_6::IRadioResponse> mRadioResponseV1_6;
204 sp<V1_6::IRadioIndication> mRadioIndicationV1_6;
205
206 Return<void> setResponseFunctions(
207 const ::android::sp<IRadioResponse>& radioResponse,
208 const ::android::sp<IRadioIndication>& radioIndication);
209
210 Return<void> getIccCardStatus(int32_t serial);
211
212 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
213 const hidl_string& aid);
214
215 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
216 const hidl_string& pin, const hidl_string& aid);
217
218 Return<void> supplyIccPin2ForApp(int32_t serial,
219 const hidl_string& pin2,
220 const hidl_string& aid);
221
222 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
223 const hidl_string& pin2, const hidl_string& aid);
224
225 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
226 const hidl_string& newPin, const hidl_string& aid);
227
228 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
229 const hidl_string& newPin2, const hidl_string& aid);
230
231 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
232
233 Return<void> getCurrentCalls(int32_t serial);
234
235 Return<void> getCurrentCalls_1_6(int32_t serial);
236
237 Return<void> dial(int32_t serial, const Dial& dialInfo);
238
239 Return<void> getImsiForApp(int32_t serial,
240 const ::android::hardware::hidl_string& aid);
241
242 Return<void> hangup(int32_t serial, int32_t gsmIndex);
243
244 Return<void> hangupWaitingOrBackground(int32_t serial);
245
246 Return<void> hangupForegroundResumeBackground(int32_t serial);
247
248 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
249
250 Return<void> conference(int32_t serial);
251
252 Return<void> rejectCall(int32_t serial);
253
254 Return<void> getLastCallFailCause(int32_t serial);
255
256 Return<void> getSignalStrength(int32_t serial);
257
258 Return<void> getSignalStrength_1_6(int32_t serial);
259
260 Return<void> getVoiceRegistrationState(int32_t serial);
261
262 Return<void> getDataRegistrationState(int32_t serial);
263
264 Return<void> getOperator(int32_t serial);
265
266 Return<void> setRadioPower(int32_t serial, bool on);
267
268 Return<void> sendDtmf(int32_t serial,
269 const ::android::hardware::hidl_string& s);
270
271 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
272
273 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
274
275 Return<void> setupDataCall(int32_t serial,
276 RadioTechnology radioTechnology,
277 const DataProfileInfo& profileInfo,
278 bool modemCognitive,
279 bool roamingAllowed,
280 bool isRoaming);
281
282 Return<void> iccIOForApp(int32_t serial,
283 const IccIo& iccIo);
284
285 Return<void> sendUssd(int32_t serial,
286 const ::android::hardware::hidl_string& ussd);
287
288 Return<void> cancelPendingUssd(int32_t serial);
289
290 Return<void> getClir(int32_t serial);
291
292 Return<void> setClir(int32_t serial, int32_t status);
293
294 Return<void> getCallForwardStatus(int32_t serial,
295 const CallForwardInfo& callInfo);
296
297 Return<void> setCallForward(int32_t serial,
298 const CallForwardInfo& callInfo);
299
300 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
301
302 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
303
304 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
305 bool success, SmsAcknowledgeFailCause cause);
306
307 Return<void> acceptCall(int32_t serial);
308
309 Return<void> deactivateDataCall(int32_t serial,
310 int32_t cid, bool reasonRadioShutDown);
311
312 Return<void> getFacilityLockForApp(int32_t serial,
313 const ::android::hardware::hidl_string& facility,
314 const ::android::hardware::hidl_string& password,
315 int32_t serviceClass,
316 const ::android::hardware::hidl_string& appId);
317
318 Return<void> setFacilityLockForApp(int32_t serial,
319 const ::android::hardware::hidl_string& facility,
320 bool lockState,
321 const ::android::hardware::hidl_string& password,
322 int32_t serviceClass,
323 const ::android::hardware::hidl_string& appId);
324
325 Return<void> setBarringPassword(int32_t serial,
326 const ::android::hardware::hidl_string& facility,
327 const ::android::hardware::hidl_string& oldPassword,
328 const ::android::hardware::hidl_string& newPassword);
329
330 Return<void> getNetworkSelectionMode(int32_t serial);
331
332 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
333
334 Return<void> setNetworkSelectionModeManual(int32_t serial,
335 const ::android::hardware::hidl_string& operatorNumeric);
336
337 Return<void> getAvailableNetworks(int32_t serial);
338
339 Return<void> startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request);
340
341 Return<void> stopNetworkScan(int32_t serial);
342
343 Return<void> startDtmf(int32_t serial,
344 const ::android::hardware::hidl_string& s);
345
346 Return<void> stopDtmf(int32_t serial);
347
348 Return<void> getBasebandVersion(int32_t serial);
349
350 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
351
352 Return<void> setMute(int32_t serial, bool enable);
353
354 Return<void> getMute(int32_t serial);
355
356 Return<void> getClip(int32_t serial);
357
358 Return<void> getDataCallList(int32_t serial);
359
360 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
361
362 Return<void> writeSmsToSim(int32_t serial,
363 const SmsWriteArgs& smsWriteArgs);
364
365 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
366
367 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
368
369 Return<void> getAvailableBandModes(int32_t serial);
370
371 Return<void> sendEnvelope(int32_t serial,
372 const ::android::hardware::hidl_string& command);
373
374 Return<void> sendTerminalResponseToSim(int32_t serial,
375 const ::android::hardware::hidl_string& commandResponse);
376
377 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
378
379 Return<void> explicitCallTransfer(int32_t serial);
380
381 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
382
383 Return<void> getPreferredNetworkType(int32_t serial);
384
385 Return<void> getNeighboringCids(int32_t serial);
386
387 Return<void> setLocationUpdates(int32_t serial, bool enable);
388
389 Return<void> setCdmaSubscriptionSource(int32_t serial,
390 CdmaSubscriptionSource cdmaSub);
391
392 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
393
394 Return<void> getCdmaRoamingPreference(int32_t serial);
395
396 Return<void> setTTYMode(int32_t serial, TtyMode mode);
397
398 Return<void> getTTYMode(int32_t serial);
399
400 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
401
402 Return<void> getPreferredVoicePrivacy(int32_t serial);
403
404 Return<void> sendCDMAFeatureCode(int32_t serial,
405 const ::android::hardware::hidl_string& featureCode);
406
407 Return<void> sendBurstDtmf(int32_t serial,
408 const ::android::hardware::hidl_string& dtmf,
409 int32_t on,
410 int32_t off);
411
412 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
413
414 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
415 const CdmaSmsAck& smsAck);
416
417 Return<void> getGsmBroadcastConfig(int32_t serial);
418
419 Return<void> setGsmBroadcastConfig(int32_t serial,
420 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
421
422 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
423
424 Return<void> getCdmaBroadcastConfig(int32_t serial);
425
426 Return<void> setCdmaBroadcastConfig(int32_t serial,
427 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
428
429 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
430
431 Return<void> getCDMASubscription(int32_t serial);
432
433 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
434
435 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
436
437 Return<void> getDeviceIdentity(int32_t serial);
438
439 Return<void> exitEmergencyCallbackMode(int32_t serial);
440
441 Return<void> getSmscAddress(int32_t serial);
442
443 Return<void> setSmscAddress(int32_t serial,
444 const ::android::hardware::hidl_string& smsc);
445
446 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
447
448 Return<void> reportStkServiceIsRunning(int32_t serial);
449
450 Return<void> getCdmaSubscriptionSource(int32_t serial);
451
452 Return<void> requestIsimAuthentication(int32_t serial,
453 const ::android::hardware::hidl_string& challenge);
454
455 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
456 bool success,
457 const ::android::hardware::hidl_string& ackPdu);
458
459 Return<void> sendEnvelopeWithStatus(int32_t serial,
460 const ::android::hardware::hidl_string& contents);
461
462 Return<void> getVoiceRadioTechnology(int32_t serial);
463
464 Return<void> getCellInfoList(int32_t serial);
465
466 Return<void> getCellInfoList_1_6(int32_t serial);
467
468 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
469
470 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
471 bool modemCognitive, bool isRoaming);
472
473 Return<void> getImsRegistrationState(int32_t serial);
474
475 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
476
477 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
478
479 Return<void> iccOpenLogicalChannel(int32_t serial,
480 const ::android::hardware::hidl_string& aid, int32_t p2);
481
482 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
483
484 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
485
486 Return<void> nvReadItem(int32_t serial, NvItem itemId);
487
488 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
489
490 Return<void> nvWriteCdmaPrl(int32_t serial,
491 const ::android::hardware::hidl_vec<uint8_t>& prl);
492
493 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
494
495 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
496
497 Return<void> setDataAllowed(int32_t serial, bool allow);
498
499 Return<void> getHardwareConfig(int32_t serial);
500
501 Return<void> requestIccSimAuthentication(int32_t serial,
502 int32_t authContext,
503 const ::android::hardware::hidl_string& authData,
504 const ::android::hardware::hidl_string& aid);
505
506 Return<void> setDataProfile(int32_t serial,
507 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
508
509 Return<void> requestShutdown(int32_t serial);
510
511 Return<void> getRadioCapability(int32_t serial);
512
513 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
514
515 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
516
517 Return<void> stopLceService(int32_t serial);
518
519 Return<void> pullLceData(int32_t serial);
520
521 Return<void> getModemActivityInfo(int32_t serial);
522
523 Return<void> setAllowedCarriers(int32_t serial,
524 bool allAllowed,
525 const CarrierRestrictions& carriers);
526
527 Return<void> getAllowedCarriers(int32_t serial);
528
529 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
530
531 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
532
533 Return<void> startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive);
534
535 Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
536
537 Return<void> setSimCardPower(int32_t serial, bool powerUp);
538 Return<void> setSimCardPower_1_1(int32_t serial,
539 const V1_1::CardPowerState state);
540 Return<void> setSimCardPower_1_6(int32_t serial,
541 const V1_1::CardPowerState state);
542
543 Return<void> responseAcknowledgement();
544
545 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
546 const V1_1::ImsiEncryptionInfo& message);
547
548 void checkReturnStatus(Return<void>& ret);
549
550 // Methods from ::android::hardware::radio::V1_2::IRadio follow.
551 Return<void> startNetworkScan_1_2(int32_t serial,
552 const ::android::hardware::radio::V1_2::NetworkScanRequest& request);
553 Return<void> setIndicationFilter_1_2(int32_t serial,
554 hidl_bitfield<::android::hardware::radio::V1_2::IndicationFilter> indicationFilter);
555 Return<void> setSignalStrengthReportingCriteria(int32_t serial, int32_t hysteresisMs,
556 int32_t hysteresisDb, const hidl_vec<int32_t>& thresholdsDbm,
557 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork);
558 Return<void> setLinkCapacityReportingCriteria(int32_t serial, int32_t hysteresisMs,
559 int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
560 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
561 const hidl_vec<int32_t>& thresholdsUplinkKbps,
562 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork);
563 Return<void> setupDataCall_1_2(int32_t serial,
564 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork,
565 const ::android::hardware::radio::V1_0::DataProfileInfo& dataProfileInfo,
566 bool modemCognitive, bool roamingAllowed, bool isRoaming,
567 ::android::hardware::radio::V1_2::DataRequestReason reason,
568 const hidl_vec<hidl_string>& addresses, const hidl_vec<hidl_string>& dnses);
569 Return<void> deactivateDataCall_1_2(int32_t serial, int32_t cid,
570 ::android::hardware::radio::V1_2::DataRequestReason reason);
571
572 // Methods from ::android::hardware::radio::V1_3::IRadio follow.
573 Return<void> setSystemSelectionChannels(int32_t serial, bool specifyChannels,
574 const hidl_vec<::android::hardware::radio::V1_1::RadioAccessSpecifier>& specifiers);
575 Return<void> enableModem(int32_t serial, bool on);
576 Return<void> getModemStackStatus(int32_t serial);
577
578 // Methods from ::android::hardware::radio::V1_4::IRadio follow.
579 Return<void> setupDataCall_1_4(int32_t serial,
580 ::android::hardware::radio::V1_4::AccessNetwork accessNetwork,
581 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo,
582 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason reason,
583 const hidl_vec<hidl_string>& addresses, const hidl_vec<hidl_string>& dnses);
584 Return<void> setInitialAttachApn_1_4(int32_t serial,
585 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo);
586 Return<void> setDataProfile_1_4(int32_t serial,
587 const hidl_vec<::android::hardware::radio::V1_4::DataProfileInfo>& profiles);
588 Return<void> emergencyDial(int32_t serial,
589 const ::android::hardware::radio::V1_0::Dial& dialInfo,
590 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
591 const hidl_vec<hidl_string>& urns,
592 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
593 bool fromEmergencyDialer, bool isTesting);
594 Return<void> emergencyDial_1_6(int32_t serial,
595 const ::android::hardware::radio::V1_0::Dial& dialInfo,
596 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
597 const hidl_vec<hidl_string>& urns,
598 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
599 bool fromEmergencyDialer, bool isTesting);
600 Return<void> startNetworkScan_1_4(int32_t serial,
601 const ::android::hardware::radio::V1_2::NetworkScanRequest& request);
602 Return<void> getPreferredNetworkTypeBitmap(int32_t serial);
603 Return<void> setPreferredNetworkTypeBitmap(
604 int32_t serial, hidl_bitfield<RadioAccessFamily> networkTypeBitmap);
605 Return<void> setAllowedCarriers_1_4(int32_t serial,
606 const ::android::hardware::radio::V1_4::CarrierRestrictionsWithPriority& carriers,
607 ::android::hardware::radio::V1_4::SimLockMultiSimPolicy multiSimPolicy);
608 Return<void> getAllowedCarriers_1_4(int32_t serial);
609 Return<void> getSignalStrength_1_4(int32_t serial);
610
611 // Methods from ::android::hardware::radio::V1_5::IRadio follow.
612 Return<void> setSignalStrengthReportingCriteria_1_5(int32_t serial,
613 const ::android::hardware::radio::V1_5::SignalThresholdInfo& signalThresholdInfo,
614 const ::android::hardware::radio::V1_5::AccessNetwork accessNetwork);
615 Return<void> setLinkCapacityReportingCriteria_1_5(int32_t serial, int32_t hysteresisMs,
616 int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
617 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
618 const hidl_vec<int32_t>& thresholdsUplinkKbps,
619 V1_5::AccessNetwork accessNetwork);
620 Return<void> enableUiccApplications(int32_t serial, bool detach);
621 Return<void> areUiccApplicationsEnabled(int32_t serial);
622 Return<void> setSystemSelectionChannels_1_5(int32_t serial, bool specifyChannels,
623 const hidl_vec<::android::hardware::radio::V1_5::RadioAccessSpecifier>& specifiers);
624 Return<void> startNetworkScan_1_5(int32_t serial,
625 const ::android::hardware::radio::V1_5::NetworkScanRequest& request);
626 Return<void> setupDataCall_1_5(int32_t serial,
627 ::android::hardware::radio::V1_5::AccessNetwork accessNetwork,
628 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
629 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason reason,
630 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& addresses,
631 const hidl_vec<hidl_string>& dnses);
632 Return<void> setInitialAttachApn_1_5(int32_t serial,
633 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo);
634 Return<void> setDataProfile_1_5(int32_t serial,
635 const hidl_vec<::android::hardware::radio::V1_5::DataProfileInfo>& profiles);
636 Return<void> setRadioPower_1_5(int32_t serial, bool powerOn, bool forEmergencyCall,
637 bool preferredForEmergencyCall);
638 Return<void> setIndicationFilter_1_5(int32_t serial,
639 hidl_bitfield<::android::hardware::radio::V1_5::IndicationFilter> indicationFilter);
640 Return<void> getBarringInfo(int32_t serial);
641 Return<void> getVoiceRegistrationState_1_5(int32_t serial);
642 Return<void> getDataRegistrationState_1_5(int32_t serial);
643 Return<void> setNetworkSelectionModeManual_1_5(int32_t serial,
644 const hidl_string& operatorNumeric, V1_5::RadioAccessNetworks ran);
645 Return<void> sendCdmaSmsExpectMore(int32_t serial, const CdmaSmsMessage& sms);
646 Return<void> supplySimDepersonalization(int32_t serial, V1_5::PersoSubstate persoType,
647 const hidl_string& controlKey);
648 Return<void> setNrDualConnectivityState(int32_t serial,
649 V1_6::NrDualConnectivityState nrDualConnectivityState);
650 Return<void> isNrDualConnectivityEnabled(int32_t serial);
651
652 // Methods from ::android::hardware::radio::V1_6::IRadio follow.
653 Return<void> getDataCallList_1_6(int32_t serial);
654 Return<void> setupDataCall_1_6(int32_t serial,
655 ::android::hardware::radio::V1_5::AccessNetwork accessNetwork,
656 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
657 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason reason,
658 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& addresses,
659 const hidl_vec<hidl_string>& dnses,
660 int32_t pduSessionId,
661 const ::android::hardware::radio::V1_6::OptionalSliceInfo& sliceInfo,
662 const ::android::hardware::radio::V1_6::OptionalTrafficDescriptor& trafficDescriptor,
663 bool matchAllRuleAllowed);
664 Return<void> sendSms_1_6(int32_t serial, const GsmSmsMessage& message);
665 Return<void> sendSmsExpectMore_1_6(int32_t serial, const GsmSmsMessage& message);
666 Return<void> sendCdmaSms_1_6(int32_t serial, const CdmaSmsMessage& sms);
667 Return<void> sendCdmaSmsExpectMore_1_6(int32_t serial, const CdmaSmsMessage& sms);
668 Return<void> setRadioPower_1_6(int32_t serial, bool powerOn, bool forEmergencyCall,
669 bool preferredForEmergencyCall);
670 Return<void> allocatePduSessionId(int32_t serial);
671 Return<void> releasePduSessionId(int32_t serial, int32_t id);
672 Return<void> startHandover(int32_t serial, int32_t callId);
673 Return<void> cancelHandover(int32_t serial, int32_t callId);
674 Return<void> setAllowedNetworkTypesBitmap(uint32_t serial,
675 hidl_bitfield<::android::hardware::radio::V1_4::RadioAccessFamily> networkTypeBitmap);
676 Return<void> setDataThrottling(int32_t serial,
677 V1_6::DataThrottlingAction dataThrottlingAction,
678 int64_t completionDurationMillis);
679 Return<void> getSystemSelectionChannels(int32_t serial);
680 Return<void> getVoiceRegistrationState_1_6(int32_t serial);
681 Return<void> getDataRegistrationState_1_6(int32_t serial);
682 Return<void> getAllowedNetworkTypesBitmap(int32_t serial);
683 Return<void> getSlicingConfig(int32_t serial);
684 Return<void> setCarrierInfoForImsiEncryption_1_6(
685 int32_t serial,
686 const ::android::hardware::radio::V1_6::ImsiEncryptionInfo& imsiEncryptionInfo);
687 Return<void> getSimPhonebookRecords(int32_t serial);
688 Return<void> getSimPhonebookCapacity(int32_t serial);
689 Return<void> updateSimPhonebookRecords(
690 int32_t serial,
691 const ::android::hardware::radio::V1_6::PhonebookRecordInfo& recordInfo);
692 };
693
694 struct OemHookImpl : public IOemHook {
695 int32_t mSlotId;
696 sp<IOemHookResponse> mOemHookResponse;
697 sp<IOemHookIndication> mOemHookIndication;
698
699 Return<void> setResponseFunctions(
700 const ::android::sp<IOemHookResponse>& oemHookResponse,
701 const ::android::sp<IOemHookIndication>& oemHookIndication);
702
703 Return<void> sendRequestRaw(int32_t serial,
704 const ::android::hardware::hidl_vec<uint8_t>& data);
705
706 Return<void> sendRequestStrings(int32_t serial,
707 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
708 };
709
memsetAndFreeStrings(int numPointers,...)710 void memsetAndFreeStrings(int numPointers, ...) {
711 va_list ap;
712 va_start(ap, numPointers);
713 for (int i = 0; i < numPointers; i++) {
714 char *ptr = va_arg(ap, char *);
715 if (ptr) {
716 #ifdef MEMSET_FREED
717 #define MAX_STRING_LENGTH 4096
718 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
719 #endif
720 free(ptr);
721 }
722 }
723 va_end(ap);
724 }
725
sendErrorResponse(RequestInfo * pRI,RIL_Errno err)726 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
727 pRI->pCI->responseFunction((int) pRI->socket_id,
728 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
729 }
730
731 /**
732 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
733 * request with error RIL_E_NO_MEMORY. The size() method is used to determine the size of the
734 * destination buffer into which the HIDL string is copied. If there is a discrepancy between
735 * the string length reported by the size() method, and the length of the string returned by
736 * the c_str() method, the function will return false indicating a failure.
737 *
738 * Returns true on success, and false on failure.
739 */
copyHidlStringToRil(char ** dest,const hidl_string & src,RequestInfo * pRI,bool allowEmpty)740 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI, bool allowEmpty) {
741 size_t len = src.size();
742 if (len == 0 && !allowEmpty) {
743 *dest = NULL;
744 return true;
745 }
746 *dest = (char *) calloc(len + 1, sizeof(char));
747 if (*dest == NULL) {
748 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
749 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
750 return false;
751 }
752 if (strlcpy(*dest, src.c_str(), len + 1) >= (len + 1)) {
753 RLOGE("Copy of the HIDL string has been truncated, as "
754 "the string length reported by size() does not "
755 "match the length of string returned by c_str().");
756 free(*dest);
757 *dest = NULL;
758 sendErrorResponse(pRI, RIL_E_INTERNAL_ERR);
759 return false;
760 }
761 return true;
762 }
763
copyHidlStringToRil(char ** dest,const hidl_string & src,RequestInfo * pRI)764 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
765 return copyHidlStringToRil(dest, src, pRI, false);
766 }
767
convertCharPtrToHidlString(const char * ptr)768 hidl_string convertCharPtrToHidlString(const char *ptr) {
769 hidl_string ret;
770 if (ptr != NULL) {
771 // TODO: replace this with strnlen
772 ret.setToExternal(ptr, strlen(ptr));
773 }
774 return ret;
775 }
776
dispatchVoid(int serial,int slotId,int request)777 bool dispatchVoid(int serial, int slotId, int request) {
778 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
779 if (pRI == NULL) {
780 return false;
781 }
782 CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
783 return true;
784 }
785
dispatchString(int serial,int slotId,int request,const char * str)786 bool dispatchString(int serial, int slotId, int request, const char * str) {
787 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
788 if (pRI == NULL) {
789 return false;
790 }
791
792 char *pString;
793 if (!copyHidlStringToRil(&pString, str, pRI)) {
794 return false;
795 }
796
797 CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
798
799 memsetAndFreeStrings(1, pString);
800 return true;
801 }
802
dispatchStrings(int serial,int slotId,int request,bool allowEmpty,int countStrings,...)803 bool dispatchStrings(int serial, int slotId, int request, bool allowEmpty, int countStrings, ...) {
804 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
805 if (pRI == NULL) {
806 return false;
807 }
808
809 char **pStrings;
810 pStrings = (char **)calloc(countStrings, sizeof(char *));
811 if (pStrings == NULL) {
812 RLOGE("Memory allocation failed for request %s", requestToString(request));
813 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
814 return false;
815 }
816 va_list ap;
817 va_start(ap, countStrings);
818 for (int i = 0; i < countStrings; i++) {
819 const char* str = va_arg(ap, const char *);
820 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI, allowEmpty)) {
821 va_end(ap);
822 for (int j = 0; j < i; j++) {
823 memsetAndFreeStrings(1, pStrings[j]);
824 }
825 free(pStrings);
826 return false;
827 }
828 }
829 va_end(ap);
830
831 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
832
833 if (pStrings != NULL) {
834 for (int i = 0 ; i < countStrings ; i++) {
835 memsetAndFreeStrings(1, pStrings[i]);
836 }
837
838 #ifdef MEMSET_FREED
839 memset(pStrings, 0, countStrings * sizeof(char *));
840 #endif
841 free(pStrings);
842 }
843 return true;
844 }
845
dispatchStrings(int serial,int slotId,int request,const hidl_vec<hidl_string> & data)846 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
847 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
848 if (pRI == NULL) {
849 return false;
850 }
851
852 int countStrings = data.size();
853 char **pStrings;
854 pStrings = (char **)calloc(countStrings, sizeof(char *));
855 if (pStrings == NULL) {
856 RLOGE("Memory allocation failed for request %s", requestToString(request));
857 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
858 return false;
859 }
860
861 for (int i = 0; i < countStrings; i++) {
862 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
863 for (int j = 0; j < i; j++) {
864 memsetAndFreeStrings(1, pStrings[j]);
865 }
866 free(pStrings);
867 return false;
868 }
869 }
870
871 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
872
873 if (pStrings != NULL) {
874 for (int i = 0 ; i < countStrings ; i++) {
875 memsetAndFreeStrings(1, pStrings[i]);
876 }
877
878 #ifdef MEMSET_FREED
879 memset(pStrings, 0, countStrings * sizeof(char *));
880 #endif
881 free(pStrings);
882 }
883 return true;
884 }
885
dispatchInts(int serial,int slotId,int request,int countInts,...)886 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
887 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
888 if (pRI == NULL) {
889 return false;
890 }
891
892 int *pInts = (int *)calloc(countInts, sizeof(int));
893
894 if (pInts == NULL) {
895 RLOGE("Memory allocation failed for request %s", requestToString(request));
896 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
897 return false;
898 }
899 va_list ap;
900 va_start(ap, countInts);
901 for (int i = 0; i < countInts; i++) {
902 pInts[i] = va_arg(ap, int);
903 }
904 va_end(ap);
905
906 CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
907
908 if (pInts != NULL) {
909 #ifdef MEMSET_FREED
910 memset(pInts, 0, countInts * sizeof(int));
911 #endif
912 free(pInts);
913 }
914 return true;
915 }
916
dispatchCallForwardStatus(int serial,int slotId,int request,const CallForwardInfo & callInfo)917 bool dispatchCallForwardStatus(int serial, int slotId, int request,
918 const CallForwardInfo& callInfo) {
919 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
920 if (pRI == NULL) {
921 return false;
922 }
923
924 RIL_CallForwardInfo cf;
925 cf.status = (int) callInfo.status;
926 cf.reason = callInfo.reason;
927 cf.serviceClass = callInfo.serviceClass;
928 cf.toa = callInfo.toa;
929 cf.timeSeconds = callInfo.timeSeconds;
930
931 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
932 return false;
933 }
934
935 CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
936
937 memsetAndFreeStrings(1, cf.number);
938
939 return true;
940 }
941
dispatchRaw(int serial,int slotId,int request,const hidl_vec<uint8_t> & rawBytes)942 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
943 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
944 if (pRI == NULL) {
945 return false;
946 }
947
948 const uint8_t *uData = rawBytes.data();
949
950 CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
951
952 return true;
953 }
954
dispatchIccApdu(int serial,int slotId,int request,const SimApdu & message)955 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
956 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
957 if (pRI == NULL) {
958 return false;
959 }
960
961 RIL_SIM_APDU apdu = {};
962
963 apdu.sessionid = message.sessionId;
964 apdu.cla = message.cla;
965 apdu.instruction = message.instruction;
966 apdu.p1 = message.p1;
967 apdu.p2 = message.p2;
968 apdu.p3 = message.p3;
969
970 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
971 return false;
972 }
973
974 CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
975
976 memsetAndFreeStrings(1, apdu.data);
977
978 return true;
979 }
980
checkReturnStatus(int32_t slotId,Return<void> & ret,bool isRadioService)981 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
982 if (ret.isOk() == false) {
983 RLOGE("checkReturnStatus: unable to call response/indication callback");
984 // Remote process hosting the callbacks must be dead. Reset the callback objects;
985 // there's no other recovery to be done here. When the client process is back up, it will
986 // call setResponseFunctions()
987
988 // Caller should already hold rdlock, release that first
989 // note the current counter to avoid overwriting updates made by another thread before
990 // write lock is acquired.
991 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
992 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_6::getRadioServiceRwlock(slotId);
993 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
994 CHECK_EQ(ret, 0);
995
996 // acquire wrlock
997 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
998 CHECK_EQ(ret, 0);
999
1000 // make sure the counter value has not changed
1001 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
1002 if (isRadioService) {
1003 radioService[slotId]->mRadioResponse = NULL;
1004 radioService[slotId]->mRadioIndication = NULL;
1005 radioService[slotId]->mRadioResponseV1_2 = NULL;
1006 radioService[slotId]->mRadioIndicationV1_2 = NULL;
1007 radioService[slotId]->mRadioResponseV1_3 = NULL;
1008 radioService[slotId]->mRadioIndicationV1_3 = NULL;
1009 radioService[slotId]->mRadioResponseV1_4 = NULL;
1010 radioService[slotId]->mRadioIndicationV1_4 = NULL;
1011 radioService[slotId]->mRadioResponseV1_5 = NULL;
1012 radioService[slotId]->mRadioIndicationV1_5 = NULL;
1013 radioService[slotId]->mRadioResponseV1_6 = NULL;
1014 radioService[slotId]->mRadioIndicationV1_6 = NULL;
1015 } else {
1016 oemHookService[slotId]->mOemHookResponse = NULL;
1017 oemHookService[slotId]->mOemHookIndication = NULL;
1018 }
1019 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
1020 } else {
1021 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
1022 "got updated on another thread");
1023 }
1024
1025 // release wrlock
1026 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
1027 CHECK_EQ(ret, 0);
1028
1029 // Reacquire rdlock
1030 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
1031 CHECK_EQ(ret, 0);
1032 }
1033 }
1034
checkReturnStatus(Return<void> & ret)1035 void RadioImpl_1_6::checkReturnStatus(Return<void>& ret) {
1036 ::checkReturnStatus(mSlotId, ret, true);
1037 }
1038
setResponseFunctions(const::android::sp<IRadioResponse> & radioResponseParam,const::android::sp<IRadioIndication> & radioIndicationParam)1039 Return<void> RadioImpl_1_6::setResponseFunctions(
1040 const ::android::sp<IRadioResponse>& radioResponseParam,
1041 const ::android::sp<IRadioIndication>& radioIndicationParam) {
1042 RLOGD("setResponseFunctions");
1043
1044 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_6::getRadioServiceRwlock(mSlotId);
1045 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
1046 CHECK_EQ(ret, 0);
1047
1048 mRadioResponse = radioResponseParam;
1049 mRadioIndication = radioIndicationParam;
1050
1051 mRadioResponseV1_6 = V1_6::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1052 mRadioIndicationV1_6 = V1_6::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1053 if (mRadioResponseV1_6 == nullptr || mRadioIndicationV1_6 == nullptr) {
1054 mRadioResponseV1_6 = nullptr;
1055 mRadioIndicationV1_6 = nullptr;
1056 }
1057
1058 mRadioResponseV1_5 = V1_5::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1059 mRadioIndicationV1_5 = V1_5::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1060 if (mRadioResponseV1_5 == nullptr || mRadioIndicationV1_5 == nullptr) {
1061 mRadioResponseV1_5 = nullptr;
1062 mRadioIndicationV1_5 = nullptr;
1063 }
1064
1065 mRadioResponseV1_4 = V1_4::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1066 mRadioIndicationV1_4 = V1_4::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1067 if (mRadioResponseV1_4 == nullptr || mRadioIndicationV1_4 == nullptr) {
1068 mRadioResponseV1_4 = nullptr;
1069 mRadioIndicationV1_4 = nullptr;
1070 }
1071
1072 mRadioResponseV1_3 = V1_3::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1073 mRadioIndicationV1_3 = V1_3::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1074 if (mRadioResponseV1_3 == nullptr || mRadioIndicationV1_3 == nullptr) {
1075 mRadioResponseV1_3 = nullptr;
1076 mRadioIndicationV1_3 = nullptr;
1077 }
1078
1079 mRadioResponseV1_2 = V1_2::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1080 mRadioIndicationV1_2 = V1_2::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1081 if (mRadioResponseV1_2 == nullptr || mRadioIndicationV1_2 == nullptr) {
1082 mRadioResponseV1_2 = nullptr;
1083 mRadioIndicationV1_2 = nullptr;
1084 }
1085
1086 mRadioResponseV1_1 = V1_1::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
1087 mRadioIndicationV1_1 = V1_1::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
1088 if (mRadioResponseV1_1 == nullptr || mRadioIndicationV1_1 == nullptr) {
1089 mRadioResponseV1_1 = nullptr;
1090 mRadioIndicationV1_1 = nullptr;
1091 }
1092
1093 mCounterRadio[mSlotId]++;
1094
1095 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
1096 CHECK_EQ(ret, 0);
1097
1098 // client is connected. Send initial indications.
1099 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
1100
1101 return Void();
1102 }
1103
getIccCardStatus(int32_t serial)1104 Return<void> RadioImpl_1_6::getIccCardStatus(int32_t serial) {
1105 #if VDBG
1106 RLOGD("getIccCardStatus: serial %d", serial);
1107 #endif
1108 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
1109 return Void();
1110 }
1111
supplyIccPinForApp(int32_t serial,const hidl_string & pin,const hidl_string & aid)1112 Return<void> RadioImpl_1_6::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
1113 const hidl_string& aid) {
1114 #if VDBG
1115 RLOGD("supplyIccPinForApp: serial %d", serial);
1116 #endif
1117 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN, true,
1118 2, pin.c_str(), aid.c_str());
1119 return Void();
1120 }
1121
supplyIccPukForApp(int32_t serial,const hidl_string & puk,const hidl_string & pin,const hidl_string & aid)1122 Return<void> RadioImpl_1_6::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
1123 const hidl_string& pin, const hidl_string& aid) {
1124 #if VDBG
1125 RLOGD("supplyIccPukForApp: serial %d", serial);
1126 #endif
1127 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK, true,
1128 3, puk.c_str(), pin.c_str(), aid.c_str());
1129 return Void();
1130 }
1131
supplyIccPin2ForApp(int32_t serial,const hidl_string & pin2,const hidl_string & aid)1132 Return<void> RadioImpl_1_6::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
1133 const hidl_string& aid) {
1134 #if VDBG
1135 RLOGD("supplyIccPin2ForApp: serial %d", serial);
1136 #endif
1137 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2, true,
1138 2, pin2.c_str(), aid.c_str());
1139 return Void();
1140 }
1141
supplyIccPuk2ForApp(int32_t serial,const hidl_string & puk2,const hidl_string & pin2,const hidl_string & aid)1142 Return<void> RadioImpl_1_6::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
1143 const hidl_string& pin2, const hidl_string& aid) {
1144 #if VDBG
1145 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
1146 #endif
1147 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2, true,
1148 3, puk2.c_str(), pin2.c_str(), aid.c_str());
1149 return Void();
1150 }
1151
changeIccPinForApp(int32_t serial,const hidl_string & oldPin,const hidl_string & newPin,const hidl_string & aid)1152 Return<void> RadioImpl_1_6::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
1153 const hidl_string& newPin, const hidl_string& aid) {
1154 #if VDBG
1155 RLOGD("changeIccPinForApp: serial %d", serial);
1156 #endif
1157 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN, true,
1158 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
1159 return Void();
1160 }
1161
changeIccPin2ForApp(int32_t serial,const hidl_string & oldPin2,const hidl_string & newPin2,const hidl_string & aid)1162 Return<void> RadioImpl_1_6::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
1163 const hidl_string& newPin2, const hidl_string& aid) {
1164 #if VDBG
1165 RLOGD("changeIccPin2ForApp: serial %d", serial);
1166 #endif
1167 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2, true,
1168 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
1169 return Void();
1170 }
1171
supplyNetworkDepersonalization(int32_t serial,const hidl_string & netPin)1172 Return<void> RadioImpl_1_6::supplyNetworkDepersonalization(int32_t serial,
1173 const hidl_string& netPin) {
1174 #if VDBG
1175 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
1176 #endif
1177 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, true,
1178 1, netPin.c_str());
1179 return Void();
1180 }
1181
getCurrentCalls(int32_t serial)1182 Return<void> RadioImpl_1_6::getCurrentCalls(int32_t serial) {
1183 #if VDBG
1184 RLOGD("getCurrentCalls: serial %d", serial);
1185 #endif
1186 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
1187 return Void();
1188 }
1189
getCurrentCalls_1_6(int32_t serial)1190 Return<void> RadioImpl_1_6::getCurrentCalls_1_6(int32_t serial) {
1191 #if VDBG
1192 RLOGD("getCurrentCalls_1_6: serial %d", serial);
1193 #endif
1194 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
1195 return Void();
1196 }
1197
dial(int32_t serial,const Dial & dialInfo)1198 Return<void> RadioImpl_1_6::dial(int32_t serial, const Dial& dialInfo) {
1199 #if VDBG
1200 RLOGD("dial: serial %d", serial);
1201 #endif
1202 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
1203 if (pRI == NULL) {
1204 return Void();
1205 }
1206 RIL_Dial dial = {};
1207 RIL_UUS_Info uusInfo = {};
1208 int32_t sizeOfDial = sizeof(dial);
1209
1210 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
1211 return Void();
1212 }
1213 dial.clir = (int) dialInfo.clir;
1214
1215 if (dialInfo.uusInfo.size() != 0) {
1216 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
1217 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
1218
1219 if (dialInfo.uusInfo[0].uusData.size() == 0) {
1220 uusInfo.uusData = NULL;
1221 uusInfo.uusLength = 0;
1222 } else {
1223 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
1224 memsetAndFreeStrings(1, dial.address);
1225 return Void();
1226 }
1227 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
1228 }
1229
1230 dial.uusInfo = &uusInfo;
1231 }
1232
1233 CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
1234
1235 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1236
1237 return Void();
1238 }
1239
getImsiForApp(int32_t serial,const hidl_string & aid)1240 Return<void> RadioImpl_1_6::getImsiForApp(int32_t serial, const hidl_string& aid) {
1241 #if VDBG
1242 RLOGD("getImsiForApp: serial %d", serial);
1243 #endif
1244 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI, false,
1245 1, aid.c_str());
1246 return Void();
1247 }
1248
hangup(int32_t serial,int32_t gsmIndex)1249 Return<void> RadioImpl_1_6::hangup(int32_t serial, int32_t gsmIndex) {
1250 #if VDBG
1251 RLOGD("hangup: serial %d", serial);
1252 #endif
1253 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
1254 return Void();
1255 }
1256
hangupWaitingOrBackground(int32_t serial)1257 Return<void> RadioImpl_1_6::hangupWaitingOrBackground(int32_t serial) {
1258 #if VDBG
1259 RLOGD("hangupWaitingOrBackground: serial %d", serial);
1260 #endif
1261 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
1262 return Void();
1263 }
1264
hangupForegroundResumeBackground(int32_t serial)1265 Return<void> RadioImpl_1_6::hangupForegroundResumeBackground(int32_t serial) {
1266 #if VDBG
1267 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
1268 #endif
1269 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
1270 return Void();
1271 }
1272
switchWaitingOrHoldingAndActive(int32_t serial)1273 Return<void> RadioImpl_1_6::switchWaitingOrHoldingAndActive(int32_t serial) {
1274 #if VDBG
1275 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
1276 #endif
1277 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
1278 return Void();
1279 }
1280
conference(int32_t serial)1281 Return<void> RadioImpl_1_6::conference(int32_t serial) {
1282 #if VDBG
1283 RLOGD("conference: serial %d", serial);
1284 #endif
1285 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
1286 return Void();
1287 }
1288
rejectCall(int32_t serial)1289 Return<void> RadioImpl_1_6::rejectCall(int32_t serial) {
1290 #if VDBG
1291 RLOGD("rejectCall: serial %d", serial);
1292 #endif
1293 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
1294 return Void();
1295 }
1296
getLastCallFailCause(int32_t serial)1297 Return<void> RadioImpl_1_6::getLastCallFailCause(int32_t serial) {
1298 #if VDBG
1299 RLOGD("getLastCallFailCause: serial %d", serial);
1300 #endif
1301 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
1302 return Void();
1303 }
1304
getSignalStrength(int32_t serial)1305 Return<void> RadioImpl_1_6::getSignalStrength(int32_t serial) {
1306 #if VDBG
1307 RLOGD("getSignalStrength: serial %d", serial);
1308 #endif
1309 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
1310 return Void();
1311 }
1312
getVoiceRegistrationState(int32_t serial)1313 Return<void> RadioImpl_1_6::getVoiceRegistrationState(int32_t serial) {
1314 #if VDBG
1315 RLOGD("getVoiceRegistrationState: serial %d", serial);
1316 #endif
1317 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
1318 return Void();
1319 }
1320
getDataRegistrationState(int32_t serial)1321 Return<void> RadioImpl_1_6::getDataRegistrationState(int32_t serial) {
1322 #if VDBG
1323 RLOGD("getDataRegistrationState: serial %d", serial);
1324 #endif
1325 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1326 return Void();
1327 }
1328
getOperator(int32_t serial)1329 Return<void> RadioImpl_1_6::getOperator(int32_t serial) {
1330 #if VDBG
1331 RLOGD("getOperator: serial %d", serial);
1332 #endif
1333 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1334 return Void();
1335 }
1336
setRadioPower(int32_t serial,bool on)1337 Return<void> RadioImpl_1_6::setRadioPower(int32_t serial, bool on) {
1338 #if VDBG
1339 RLOGD("setRadioPower: serial %d on %d", serial, on);
1340 #endif
1341 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1342 return Void();
1343 }
1344
sendDtmf(int32_t serial,const hidl_string & s)1345 Return<void> RadioImpl_1_6::sendDtmf(int32_t serial, const hidl_string& s) {
1346 #if VDBG
1347 RLOGD("sendDtmf: serial %d", serial);
1348 #endif
1349 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1350 return Void();
1351 }
1352
sendSms(int32_t serial,const GsmSmsMessage & message)1353 Return<void> RadioImpl_1_6::sendSms(int32_t serial, const GsmSmsMessage& message) {
1354 #if VDBG
1355 RLOGD("sendSms: serial %d", serial);
1356 #endif
1357 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, false,
1358 2, message.smscPdu.c_str(), message.pdu.c_str());
1359 return Void();
1360 }
1361
sendSms_1_6(int32_t serial,const GsmSmsMessage & message)1362 Return<void> RadioImpl_1_6::sendSms_1_6(int32_t serial, const GsmSmsMessage& message) {
1363 #if VDBG
1364 RLOGD("sendSms: serial %d", serial);
1365 #endif
1366 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, false,
1367 2, message.smscPdu.c_str(), message.pdu.c_str());
1368 return Void();
1369 }
1370
sendSMSExpectMore(int32_t serial,const GsmSmsMessage & message)1371 Return<void> RadioImpl_1_6::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1372 #if VDBG
1373 RLOGD("sendSmsExpectMore: serial %d", serial);
1374 #endif
1375 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, false,
1376 2, message.smscPdu.c_str(), message.pdu.c_str());
1377 return Void();
1378 }
1379
sendSmsExpectMore_1_6(int32_t serial,const GsmSmsMessage & message)1380 Return<void> RadioImpl_1_6::sendSmsExpectMore_1_6(int32_t serial, const GsmSmsMessage& message) {
1381 #if VDBG
1382 RLOGD("sendSmsExpectMore: serial %d", serial);
1383 #endif
1384 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, false,
1385 2, message.smscPdu.c_str(), message.pdu.c_str());
1386 return Void();
1387 }
1388
convertMvnoTypeToString(MvnoType type,char * & str)1389 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1390 switch (type) {
1391 case MvnoType::IMSI:
1392 str = (char *)"imsi";
1393 return true;
1394 case MvnoType::GID:
1395 str = (char *)"gid";
1396 return true;
1397 case MvnoType::SPN:
1398 str = (char *)"spn";
1399 return true;
1400 case MvnoType::NONE:
1401 str = (char *)"";
1402 return true;
1403 }
1404 return false;
1405 }
1406
setupDataCall(int32_t serial,RadioTechnology radioTechnology,const DataProfileInfo & dataProfileInfo,bool modemCognitive,bool roamingAllowed,bool isRoaming)1407 Return<void> RadioImpl_1_6::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1408 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1409 bool roamingAllowed, bool isRoaming) {
1410
1411 #if VDBG
1412 RLOGD("setupDataCall: serial %d", serial);
1413 #endif
1414
1415 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1416 const hidl_string &protocol =
1417 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1418 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 7,
1419 std::to_string((int) radioTechnology + 2).c_str(),
1420 std::to_string((int) dataProfileInfo.profileId).c_str(),
1421 dataProfileInfo.apn.c_str(),
1422 dataProfileInfo.user.c_str(),
1423 dataProfileInfo.password.c_str(),
1424 std::to_string((int) dataProfileInfo.authType).c_str(),
1425 protocol.c_str());
1426 } else if (s_vendorFunctions->version == 15) {
1427 char *mvnoTypeStr = NULL;
1428 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1429 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1430 RIL_REQUEST_SETUP_DATA_CALL);
1431 if (pRI != NULL) {
1432 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1433 }
1434 return Void();
1435 }
1436 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
1437 std::to_string((int) radioTechnology + 2).c_str(),
1438 std::to_string((int) dataProfileInfo.profileId).c_str(),
1439 dataProfileInfo.apn.c_str(),
1440 dataProfileInfo.user.c_str(),
1441 dataProfileInfo.password.c_str(),
1442 std::to_string((int) dataProfileInfo.authType).c_str(),
1443 dataProfileInfo.protocol.c_str(),
1444 dataProfileInfo.roamingProtocol.c_str(),
1445 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1446 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1447 modemCognitive ? "1" : "0",
1448 std::to_string(dataProfileInfo.mtu).c_str(),
1449 mvnoTypeStr,
1450 dataProfileInfo.mvnoMatchData.c_str(),
1451 roamingAllowed ? "1" : "0");
1452 } else if (s_vendorFunctions->version >= 16) {
1453 char *mvnoTypeStr = NULL;
1454 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1455 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1456 RIL_REQUEST_SETUP_DATA_CALL);
1457 if (pRI != NULL) {
1458 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1459 }
1460 return Void();
1461 }
1462 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 16,
1463 std::to_string((int) radioTechnology + 2).c_str(),
1464 std::to_string((int) dataProfileInfo.profileId).c_str(),
1465 dataProfileInfo.apn.c_str(),
1466 dataProfileInfo.user.c_str(),
1467 dataProfileInfo.password.c_str(),
1468 std::to_string((int) dataProfileInfo.authType).c_str(),
1469 dataProfileInfo.protocol.c_str(),
1470 dataProfileInfo.roamingProtocol.c_str(),
1471 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1472 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1473 modemCognitive ? "1" : "0",
1474 std::to_string(dataProfileInfo.mtu).c_str(),
1475 mvnoTypeStr,
1476 dataProfileInfo.mvnoMatchData.c_str(),
1477 roamingAllowed ? "1" : "0",
1478 "-1",
1479 "");
1480 } else {
1481 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1482 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1483 RIL_REQUEST_SETUP_DATA_CALL);
1484 if (pRI != NULL) {
1485 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1486 }
1487 }
1488 return Void();
1489 }
1490
iccIOForApp(int32_t serial,const IccIo & iccIo)1491 Return<void> RadioImpl_1_6::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1492 #if VDBG
1493 RLOGD("iccIOForApp: serial %d", serial);
1494 #endif
1495 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1496 if (pRI == NULL) {
1497 return Void();
1498 }
1499
1500 RIL_SIM_IO_v6 rilIccIo = {};
1501 rilIccIo.command = iccIo.command;
1502 rilIccIo.fileid = iccIo.fileId;
1503 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1504 return Void();
1505 }
1506
1507 rilIccIo.p1 = iccIo.p1;
1508 rilIccIo.p2 = iccIo.p2;
1509 rilIccIo.p3 = iccIo.p3;
1510
1511 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1512 memsetAndFreeStrings(1, rilIccIo.path);
1513 return Void();
1514 }
1515
1516 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1517 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1518 return Void();
1519 }
1520
1521 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1522 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1523 return Void();
1524 }
1525
1526 CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1527
1528 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1529
1530 return Void();
1531 }
1532
sendUssd(int32_t serial,const hidl_string & ussd)1533 Return<void> RadioImpl_1_6::sendUssd(int32_t serial, const hidl_string& ussd) {
1534 #if VDBG
1535 RLOGD("sendUssd: serial %d", serial);
1536 #endif
1537 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1538 return Void();
1539 }
1540
cancelPendingUssd(int32_t serial)1541 Return<void> RadioImpl_1_6::cancelPendingUssd(int32_t serial) {
1542 #if VDBG
1543 RLOGD("cancelPendingUssd: serial %d", serial);
1544 #endif
1545 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1546 return Void();
1547 }
1548
getClir(int32_t serial)1549 Return<void> RadioImpl_1_6::getClir(int32_t serial) {
1550 #if VDBG
1551 RLOGD("getClir: serial %d", serial);
1552 #endif
1553 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1554 return Void();
1555 }
1556
setClir(int32_t serial,int32_t status)1557 Return<void> RadioImpl_1_6::setClir(int32_t serial, int32_t status) {
1558 #if VDBG
1559 RLOGD("setClir: serial %d", serial);
1560 #endif
1561 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1562 return Void();
1563 }
1564
getCallForwardStatus(int32_t serial,const CallForwardInfo & callInfo)1565 Return<void> RadioImpl_1_6::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1566 #if VDBG
1567 RLOGD("getCallForwardStatus: serial %d", serial);
1568 #endif
1569 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1570 callInfo);
1571 return Void();
1572 }
1573
setCallForward(int32_t serial,const CallForwardInfo & callInfo)1574 Return<void> RadioImpl_1_6::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1575 #if VDBG
1576 RLOGD("setCallForward: serial %d", serial);
1577 #endif
1578 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1579 callInfo);
1580 return Void();
1581 }
1582
getCallWaiting(int32_t serial,int32_t serviceClass)1583 Return<void> RadioImpl_1_6::getCallWaiting(int32_t serial, int32_t serviceClass) {
1584 #if VDBG
1585 RLOGD("getCallWaiting: serial %d", serial);
1586 #endif
1587 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1588 return Void();
1589 }
1590
setCallWaiting(int32_t serial,bool enable,int32_t serviceClass)1591 Return<void> RadioImpl_1_6::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1592 #if VDBG
1593 RLOGD("setCallWaiting: serial %d", serial);
1594 #endif
1595 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1596 serviceClass);
1597 return Void();
1598 }
1599
acknowledgeLastIncomingGsmSms(int32_t serial,bool success,SmsAcknowledgeFailCause cause)1600 Return<void> RadioImpl_1_6::acknowledgeLastIncomingGsmSms(int32_t serial,
1601 bool success, SmsAcknowledgeFailCause cause) {
1602 #if VDBG
1603 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1604 #endif
1605 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1606 cause);
1607 return Void();
1608 }
1609
acceptCall(int32_t serial)1610 Return<void> RadioImpl_1_6::acceptCall(int32_t serial) {
1611 #if VDBG
1612 RLOGD("acceptCall: serial %d", serial);
1613 #endif
1614 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1615 return Void();
1616 }
1617
deactivateDataCall(int32_t serial,int32_t cid,bool reasonRadioShutDown)1618 Return<void> RadioImpl_1_6::deactivateDataCall(int32_t serial,
1619 int32_t cid, bool reasonRadioShutDown) {
1620 #if VDBG
1621 RLOGD("deactivateDataCall: serial %d", serial);
1622 #endif
1623 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, false,
1624 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1625 return Void();
1626 }
1627
getFacilityLockForApp(int32_t serial,const hidl_string & facility,const hidl_string & password,int32_t serviceClass,const hidl_string & appId)1628 Return<void> RadioImpl_1_6::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1629 const hidl_string& password, int32_t serviceClass,
1630 const hidl_string& appId) {
1631 #if VDBG
1632 RLOGD("getFacilityLockForApp: serial %d", serial);
1633 #endif
1634 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK, true,
1635 4, facility.c_str(), password.c_str(),
1636 (std::to_string(serviceClass)).c_str(), appId.c_str());
1637 return Void();
1638 }
1639
setFacilityLockForApp(int32_t serial,const hidl_string & facility,bool lockState,const hidl_string & password,int32_t serviceClass,const hidl_string & appId)1640 Return<void> RadioImpl_1_6::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1641 bool lockState, const hidl_string& password,
1642 int32_t serviceClass, const hidl_string& appId) {
1643 #if VDBG
1644 RLOGD("setFacilityLockForApp: serial %d", serial);
1645 #endif
1646 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK, true,
1647 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1648 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1649 return Void();
1650 }
1651
setBarringPassword(int32_t serial,const hidl_string & facility,const hidl_string & oldPassword,const hidl_string & newPassword)1652 Return<void> RadioImpl_1_6::setBarringPassword(int32_t serial, const hidl_string& facility,
1653 const hidl_string& oldPassword,
1654 const hidl_string& newPassword) {
1655 #if VDBG
1656 RLOGD("setBarringPassword: serial %d", serial);
1657 #endif
1658 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD, true,
1659 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1660 return Void();
1661 }
1662
getNetworkSelectionMode(int32_t serial)1663 Return<void> RadioImpl_1_6::getNetworkSelectionMode(int32_t serial) {
1664 #if VDBG
1665 RLOGD("getNetworkSelectionMode: serial %d", serial);
1666 #endif
1667 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1668 return Void();
1669 }
1670
setNetworkSelectionModeAutomatic(int32_t serial)1671 Return<void> RadioImpl_1_6::setNetworkSelectionModeAutomatic(int32_t serial) {
1672 #if VDBG
1673 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1674 #endif
1675 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1676 return Void();
1677 }
1678
setNetworkSelectionModeManual(int32_t serial,const hidl_string & operatorNumeric)1679 Return<void> RadioImpl_1_6::setNetworkSelectionModeManual(int32_t serial,
1680 const hidl_string& operatorNumeric) {
1681 #if VDBG
1682 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1683 #endif
1684 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1685 RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL);
1686 if (pRI == NULL) {
1687 return Void();
1688 }
1689
1690 RIL_NetworkOperator networkOperator = {};
1691
1692 networkOperator.act = UNKNOWN;
1693 if (!copyHidlStringToRil(&networkOperator.operatorNumeric, operatorNumeric, pRI)) {
1694 return Void();
1695 }
1696 CALL_ONREQUEST(pRI->pCI->requestNumber, &networkOperator,
1697 sizeof(networkOperator), pRI, mSlotId);
1698
1699 return Void();
1700 }
1701
getAvailableNetworks(int32_t serial)1702 Return<void> RadioImpl_1_6::getAvailableNetworks(int32_t serial) {
1703 #if VDBG
1704 RLOGD("getAvailableNetworks: serial %d", serial);
1705 #endif
1706 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1707 return Void();
1708 }
1709
startNetworkScan(int32_t serial,const V1_1::NetworkScanRequest & request)1710 Return<void> RadioImpl_1_6::startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request) {
1711 #if VDBG
1712 RLOGD("startNetworkScan: serial %d", serial);
1713 #endif
1714
1715 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1716 if (pRI == NULL) {
1717 return Void();
1718 }
1719
1720 if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
1721 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1722 return Void();
1723 }
1724
1725 RIL_NetworkScanRequest scan_request = {};
1726
1727 scan_request.type = (RIL_ScanType) request.type;
1728 scan_request.interval = request.interval;
1729 scan_request.specifiers_length = request.specifiers.size();
1730 for (size_t i = 0; i < request.specifiers.size(); ++i) {
1731 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
1732 request.specifiers[i].utranBands.size() > MAX_BANDS ||
1733 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
1734 request.specifiers[i].channels.size() > MAX_CHANNELS) {
1735 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1736 return Void();
1737 }
1738 const V1_1::RadioAccessSpecifier& ras_from =
1739 request.specifiers[i];
1740 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
1741
1742 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
1743 ras_to.channels_length = ras_from.channels.size();
1744
1745 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
1746 const std::vector<uint32_t> * bands = nullptr;
1747 switch (request.specifiers[i].radioAccessNetwork) {
1748 case V1_1::RadioAccessNetworks::GERAN:
1749 ras_to.bands_length = ras_from.geranBands.size();
1750 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
1751 break;
1752 case V1_1::RadioAccessNetworks::UTRAN:
1753 ras_to.bands_length = ras_from.utranBands.size();
1754 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
1755 break;
1756 case V1_1::RadioAccessNetworks::EUTRAN:
1757 ras_to.bands_length = ras_from.eutranBands.size();
1758 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
1759 break;
1760 default:
1761 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1762 return Void();
1763 }
1764 // safe to copy to geran_bands because it's a union member
1765 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
1766 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
1767 }
1768 }
1769
1770 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
1771 mSlotId);
1772
1773 return Void();
1774 }
1775
stopNetworkScan(int32_t serial)1776 Return<void> RadioImpl_1_6::stopNetworkScan(int32_t serial) {
1777 #if VDBG
1778 RLOGD("stopNetworkScan: serial %d", serial);
1779 #endif
1780 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1781 return Void();
1782 }
1783
startDtmf(int32_t serial,const hidl_string & s)1784 Return<void> RadioImpl_1_6::startDtmf(int32_t serial, const hidl_string& s) {
1785 #if VDBG
1786 RLOGD("startDtmf: serial %d", serial);
1787 #endif
1788 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1789 s.c_str());
1790 return Void();
1791 }
1792
stopDtmf(int32_t serial)1793 Return<void> RadioImpl_1_6::stopDtmf(int32_t serial) {
1794 #if VDBG
1795 RLOGD("stopDtmf: serial %d", serial);
1796 #endif
1797 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1798 return Void();
1799 }
1800
getBasebandVersion(int32_t serial)1801 Return<void> RadioImpl_1_6::getBasebandVersion(int32_t serial) {
1802 #if VDBG
1803 RLOGD("getBasebandVersion: serial %d", serial);
1804 #endif
1805 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1806 return Void();
1807 }
1808
separateConnection(int32_t serial,int32_t gsmIndex)1809 Return<void> RadioImpl_1_6::separateConnection(int32_t serial, int32_t gsmIndex) {
1810 #if VDBG
1811 RLOGD("separateConnection: serial %d", serial);
1812 #endif
1813 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1814 return Void();
1815 }
1816
setMute(int32_t serial,bool enable)1817 Return<void> RadioImpl_1_6::setMute(int32_t serial, bool enable) {
1818 #if VDBG
1819 RLOGD("setMute: serial %d", serial);
1820 #endif
1821 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1822 return Void();
1823 }
1824
getMute(int32_t serial)1825 Return<void> RadioImpl_1_6::getMute(int32_t serial) {
1826 #if VDBG
1827 RLOGD("getMute: serial %d", serial);
1828 #endif
1829 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1830 return Void();
1831 }
1832
getClip(int32_t serial)1833 Return<void> RadioImpl_1_6::getClip(int32_t serial) {
1834 #if VDBG
1835 RLOGD("getClip: serial %d", serial);
1836 #endif
1837 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1838 return Void();
1839 }
1840
getDataCallList(int32_t serial)1841 Return<void> RadioImpl_1_6::getDataCallList(int32_t serial) {
1842 #if VDBG
1843 RLOGD("getDataCallList: serial %d", serial);
1844 #endif
1845 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1846 return Void();
1847 }
1848
getDataCallList_1_6(int32_t serial)1849 Return<void> RadioImpl_1_6::getDataCallList_1_6(int32_t serial) {
1850 #if VDBG
1851 RLOGD("getDataCallList_1_6: serial %d", serial);
1852 #endif
1853 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1854 return Void();
1855 }
1856
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)1857 Return<void> RadioImpl_1_6::emergencyDial_1_6(int32_t serial,
1858 const ::android::hardware::radio::V1_0::Dial& dialInfo,
1859 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
1860 const hidl_vec<hidl_string>& urns ,
1861 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
1862 bool fromEmergencyDialer, bool /* isTesting */) {
1863 #if VDBG
1864 RLOGD("emergencyDial: serial %d", serial);
1865 #endif
1866
1867 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_EMERGENCY_DIAL);
1868 if (pRI == NULL) {
1869 return Void();
1870 }
1871
1872 RIL_EmergencyDial eccDial = {};
1873 RIL_Dial& dial = eccDial.dialInfo;
1874 RIL_UUS_Info uusInfo = {};
1875
1876 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
1877 return Void();
1878 }
1879 dial.clir = (int) dialInfo.clir;
1880
1881 if (dialInfo.uusInfo.size() != 0) {
1882 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
1883 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
1884
1885 if (dialInfo.uusInfo[0].uusData.size() == 0) {
1886 uusInfo.uusData = NULL;
1887 uusInfo.uusLength = 0;
1888 } else {
1889 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
1890 memsetAndFreeStrings(1, dial.address);
1891 return Void();
1892 }
1893 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
1894 }
1895
1896 dial.uusInfo = &uusInfo;
1897 }
1898
1899 eccDial.urnsNumber = urns.size();
1900 if (eccDial.urnsNumber != 0) {
1901 char **ppUrns = (char **)calloc(eccDial.urnsNumber, sizeof(char *));
1902 if (ppUrns == NULL) {
1903 RLOGE("Memory allocation failed for request %s",
1904 requestToString(pRI->pCI->requestNumber));
1905 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1906 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1907 return Void();
1908 }
1909 for (uint32_t i = 0; i < eccDial.urnsNumber; i++) {
1910 if (!copyHidlStringToRil(&ppUrns[i], hidl_string(urns[i]), pRI)) {
1911 for (uint32_t j = 0; j < i; j++) {
1912 memsetAndFreeStrings(1, ppUrns[j]);
1913 }
1914 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1915 free(ppUrns);
1916 return Void();
1917 }
1918 }
1919 eccDial.urns = ppUrns;
1920 }
1921
1922 eccDial.categories = (RIL_EmergencyServiceCategory)categories;
1923 eccDial.routing = (RIL_EmergencyCallRouting)routing;
1924 eccDial.fromEmergencyDialer = fromEmergencyDialer;
1925
1926 CALL_ONREQUEST(RIL_REQUEST_EMERGENCY_DIAL, &eccDial, sizeof(RIL_EmergencyDial), pRI, mSlotId);
1927
1928 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1929 if (eccDial.urns != NULL) {
1930 for (size_t i = 0; i < eccDial.urnsNumber; i++) {
1931 memsetAndFreeStrings(1, eccDial.urns[i]);
1932 }
1933 free(eccDial.urns);
1934 }
1935 return Void();
1936 }
1937
setSuppServiceNotifications(int32_t serial,bool enable)1938 Return<void> RadioImpl_1_6::setSuppServiceNotifications(int32_t serial, bool enable) {
1939 #if VDBG
1940 RLOGD("setSuppServiceNotifications: serial %d", serial);
1941 #endif
1942 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1943 BOOL_TO_INT(enable));
1944 return Void();
1945 }
1946
writeSmsToSim(int32_t serial,const SmsWriteArgs & smsWriteArgs)1947 Return<void> RadioImpl_1_6::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1948 #if VDBG
1949 RLOGD("writeSmsToSim: serial %d", serial);
1950 #endif
1951 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1952 if (pRI == NULL) {
1953 return Void();
1954 }
1955
1956 RIL_SMS_WriteArgs args;
1957 args.status = (int) smsWriteArgs.status;
1958
1959 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1960 return Void();
1961 }
1962
1963 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1964 memsetAndFreeStrings(1, args.pdu);
1965 return Void();
1966 }
1967
1968 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
1969
1970 memsetAndFreeStrings(2, args.smsc, args.pdu);
1971
1972 return Void();
1973 }
1974
deleteSmsOnSim(int32_t serial,int32_t index)1975 Return<void> RadioImpl_1_6::deleteSmsOnSim(int32_t serial, int32_t index) {
1976 #if VDBG
1977 RLOGD("deleteSmsOnSim: serial %d", serial);
1978 #endif
1979 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1980 return Void();
1981 }
1982
setBandMode(int32_t serial,RadioBandMode mode)1983 Return<void> RadioImpl_1_6::setBandMode(int32_t serial, RadioBandMode mode) {
1984 #if VDBG
1985 RLOGD("setBandMode: serial %d", serial);
1986 #endif
1987 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1988 return Void();
1989 }
1990
getAvailableBandModes(int32_t serial)1991 Return<void> RadioImpl_1_6::getAvailableBandModes(int32_t serial) {
1992 #if VDBG
1993 RLOGD("getAvailableBandModes: serial %d", serial);
1994 #endif
1995 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1996 return Void();
1997 }
1998
sendEnvelope(int32_t serial,const hidl_string & command)1999 Return<void> RadioImpl_1_6::sendEnvelope(int32_t serial, const hidl_string& command) {
2000 #if VDBG
2001 RLOGD("sendEnvelope: serial %d", serial);
2002 #endif
2003 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
2004 command.c_str());
2005 return Void();
2006 }
2007
sendTerminalResponseToSim(int32_t serial,const hidl_string & commandResponse)2008 Return<void> RadioImpl_1_6::sendTerminalResponseToSim(int32_t serial,
2009 const hidl_string& commandResponse) {
2010 #if VDBG
2011 RLOGD("sendTerminalResponseToSim: serial %d", serial);
2012 #endif
2013 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
2014 commandResponse.c_str());
2015 return Void();
2016 }
2017
handleStkCallSetupRequestFromSim(int32_t serial,bool accept)2018 Return<void> RadioImpl_1_6::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
2019 #if VDBG
2020 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
2021 #endif
2022 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
2023 1, BOOL_TO_INT(accept));
2024 return Void();
2025 }
2026
explicitCallTransfer(int32_t serial)2027 Return<void> RadioImpl_1_6::explicitCallTransfer(int32_t serial) {
2028 #if VDBG
2029 RLOGD("explicitCallTransfer: serial %d", serial);
2030 #endif
2031 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
2032 return Void();
2033 }
2034
setPreferredNetworkType(int32_t serial,PreferredNetworkType nwType)2035 Return<void> RadioImpl_1_6::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
2036 #if VDBG
2037 RLOGD("setPreferredNetworkType: serial %d", serial);
2038 #endif
2039 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
2040 return Void();
2041 }
2042
getPreferredNetworkType(int32_t serial)2043 Return<void> RadioImpl_1_6::getPreferredNetworkType(int32_t serial) {
2044 #if VDBG
2045 RLOGD("getPreferredNetworkType: serial %d", serial);
2046 #endif
2047 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
2048 return Void();
2049 }
2050
getNeighboringCids(int32_t serial)2051 Return<void> RadioImpl_1_6::getNeighboringCids(int32_t serial) {
2052 #if VDBG
2053 RLOGD("getNeighboringCids: serial %d", serial);
2054 #endif
2055 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
2056 return Void();
2057 }
2058
setLocationUpdates(int32_t serial,bool enable)2059 Return<void> RadioImpl_1_6::setLocationUpdates(int32_t serial, bool enable) {
2060 #if VDBG
2061 RLOGD("setLocationUpdates: serial %d", serial);
2062 #endif
2063 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
2064 return Void();
2065 }
2066
setCdmaSubscriptionSource(int32_t serial,CdmaSubscriptionSource cdmaSub)2067 Return<void> RadioImpl_1_6::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
2068 #if VDBG
2069 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
2070 #endif
2071 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
2072 return Void();
2073 }
2074
setCdmaRoamingPreference(int32_t serial,CdmaRoamingType type)2075 Return<void> RadioImpl_1_6::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
2076 #if VDBG
2077 RLOGD("setCdmaRoamingPreference: serial %d", serial);
2078 #endif
2079 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
2080 return Void();
2081 }
2082
getCdmaRoamingPreference(int32_t serial)2083 Return<void> RadioImpl_1_6::getCdmaRoamingPreference(int32_t serial) {
2084 #if VDBG
2085 RLOGD("getCdmaRoamingPreference: serial %d", serial);
2086 #endif
2087 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
2088 return Void();
2089 }
2090
setTTYMode(int32_t serial,TtyMode mode)2091 Return<void> RadioImpl_1_6::setTTYMode(int32_t serial, TtyMode mode) {
2092 #if VDBG
2093 RLOGD("setTTYMode: serial %d", serial);
2094 #endif
2095 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
2096 return Void();
2097 }
2098
getTTYMode(int32_t serial)2099 Return<void> RadioImpl_1_6::getTTYMode(int32_t serial) {
2100 #if VDBG
2101 RLOGD("getTTYMode: serial %d", serial);
2102 #endif
2103 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
2104 return Void();
2105 }
2106
setPreferredVoicePrivacy(int32_t serial,bool enable)2107 Return<void> RadioImpl_1_6::setPreferredVoicePrivacy(int32_t serial, bool enable) {
2108 #if VDBG
2109 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
2110 #endif
2111 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
2112 1, BOOL_TO_INT(enable));
2113 return Void();
2114 }
2115
getPreferredVoicePrivacy(int32_t serial)2116 Return<void> RadioImpl_1_6::getPreferredVoicePrivacy(int32_t serial) {
2117 #if VDBG
2118 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
2119 #endif
2120 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
2121 return Void();
2122 }
2123
sendCDMAFeatureCode(int32_t serial,const hidl_string & featureCode)2124 Return<void> RadioImpl_1_6::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
2125 #if VDBG
2126 RLOGD("sendCDMAFeatureCode: serial %d", serial);
2127 #endif
2128 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
2129 featureCode.c_str());
2130 return Void();
2131 }
2132
sendBurstDtmf(int32_t serial,const hidl_string & dtmf,int32_t on,int32_t off)2133 Return<void> RadioImpl_1_6::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
2134 int32_t off) {
2135 #if VDBG
2136 RLOGD("sendBurstDtmf: serial %d", serial);
2137 #endif
2138 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF, false,
2139 3, dtmf.c_str(), (std::to_string(on)).c_str(),
2140 (std::to_string(off)).c_str());
2141 return Void();
2142 }
2143
constructCdmaSms(RIL_CDMA_SMS_Message & rcsm,const CdmaSmsMessage & sms)2144 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
2145 rcsm.uTeleserviceID = sms.teleserviceId;
2146 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
2147 rcsm.uServicecategory = sms.serviceCategory;
2148 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
2149 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
2150 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
2151 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
2152
2153 rcsm.sAddress.number_of_digits = sms.address.digits.size();
2154 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
2155 for (int i = 0; i < digitLimit; i++) {
2156 rcsm.sAddress.digits[i] = sms.address.digits[i];
2157 }
2158
2159 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
2160 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
2161
2162 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
2163 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
2164 for (int i = 0; i < digitLimit; i++) {
2165 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
2166 }
2167
2168 rcsm.uBearerDataLen = sms.bearerData.size();
2169 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
2170 for (int i = 0; i < digitLimit; i++) {
2171 rcsm.aBearerData[i] = sms.bearerData[i];
2172 }
2173 }
2174
sendCdmaSms(int32_t serial,const CdmaSmsMessage & sms)2175 Return<void> RadioImpl_1_6::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
2176 #if VDBG
2177 RLOGD("sendCdmaSms: serial %d", serial);
2178 #endif
2179 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
2180 if (pRI == NULL) {
2181 return Void();
2182 }
2183
2184 RIL_CDMA_SMS_Message rcsm = {};
2185 constructCdmaSms(rcsm, sms);
2186
2187 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
2188 return Void();
2189 }
2190
sendCdmaSms_1_6(int32_t serial,const CdmaSmsMessage & sms)2191 Return<void> RadioImpl_1_6::sendCdmaSms_1_6(int32_t serial, const CdmaSmsMessage& sms) {
2192 #if VDBG
2193 RLOGD("sendCdmaSms: serial %d", serial);
2194 #endif
2195 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
2196 if (pRI == NULL) {
2197 return Void();
2198 }
2199
2200 RIL_CDMA_SMS_Message rcsm = {};
2201 constructCdmaSms(rcsm, sms);
2202
2203 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
2204 return Void();
2205 }
2206
acknowledgeLastIncomingCdmaSms(int32_t serial,const CdmaSmsAck & smsAck)2207 Return<void> RadioImpl_1_6::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
2208 #if VDBG
2209 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
2210 #endif
2211 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
2212 if (pRI == NULL) {
2213 return Void();
2214 }
2215
2216 RIL_CDMA_SMS_Ack rcsa = {};
2217
2218 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
2219 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
2220
2221 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
2222 return Void();
2223 }
2224
getGsmBroadcastConfig(int32_t serial)2225 Return<void> RadioImpl_1_6::getGsmBroadcastConfig(int32_t serial) {
2226 #if VDBG
2227 RLOGD("getGsmBroadcastConfig: serial %d", serial);
2228 #endif
2229 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
2230 return Void();
2231 }
2232
setGsmBroadcastConfig(int32_t serial,const hidl_vec<GsmBroadcastSmsConfigInfo> & configInfo)2233 Return<void> RadioImpl_1_6::setGsmBroadcastConfig(int32_t serial,
2234 const hidl_vec<GsmBroadcastSmsConfigInfo>&
2235 configInfo) {
2236 #if VDBG
2237 RLOGD("setGsmBroadcastConfig: serial %d", serial);
2238 #endif
2239 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2240 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
2241 if (pRI == NULL) {
2242 return Void();
2243 }
2244
2245 int num = configInfo.size();
2246 if (num > MAX_BROADCAST_SMS_CONFIG_INFO) {
2247 RLOGE("setGsmBroadcastConfig: Invalid configInfo length %s",
2248 requestToString(pRI->pCI->requestNumber));
2249 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2250 return Void();
2251 }
2252 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
2253 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
2254
2255 for (int i = 0 ; i < num ; i++ ) {
2256 gsmBciPtrs[i] = &gsmBci[i];
2257 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
2258 gsmBci[i].toServiceId = configInfo[i].toServiceId;
2259 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
2260 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
2261 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
2262 }
2263
2264 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs,
2265 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
2266 return Void();
2267 }
2268
setGsmBroadcastActivation(int32_t serial,bool activate)2269 Return<void> RadioImpl_1_6::setGsmBroadcastActivation(int32_t serial, bool activate) {
2270 #if VDBG
2271 RLOGD("setGsmBroadcastActivation: serial %d", serial);
2272 #endif
2273 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
2274 1, BOOL_TO_INT(!activate));
2275 return Void();
2276 }
2277
getCdmaBroadcastConfig(int32_t serial)2278 Return<void> RadioImpl_1_6::getCdmaBroadcastConfig(int32_t serial) {
2279 #if VDBG
2280 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
2281 #endif
2282 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
2283 return Void();
2284 }
2285
setCdmaBroadcastConfig(int32_t serial,const hidl_vec<CdmaBroadcastSmsConfigInfo> & configInfo)2286 Return<void> RadioImpl_1_6::setCdmaBroadcastConfig(int32_t serial,
2287 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
2288 configInfo) {
2289 #if VDBG
2290 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
2291 #endif
2292 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2293 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
2294 if (pRI == NULL) {
2295 return Void();
2296 }
2297
2298 int num = configInfo.size();
2299 if (num > MAX_BROADCAST_SMS_CONFIG_INFO) {
2300 RLOGE("setCdmaBroadcastConfig: Invalid configInfo length %s",
2301 requestToString(pRI->pCI->requestNumber));
2302 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2303 return Void();
2304 }
2305 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
2306 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
2307
2308 for (int i = 0 ; i < num ; i++ ) {
2309 cdmaBciPtrs[i] = &cdmaBci[i];
2310 cdmaBci[i].service_category = configInfo[i].serviceCategory;
2311 cdmaBci[i].language = configInfo[i].language;
2312 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
2313 }
2314
2315 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs,
2316 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
2317 return Void();
2318 }
2319
setCdmaBroadcastActivation(int32_t serial,bool activate)2320 Return<void> RadioImpl_1_6::setCdmaBroadcastActivation(int32_t serial, bool activate) {
2321 #if VDBG
2322 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
2323 #endif
2324 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
2325 1, BOOL_TO_INT(!activate));
2326 return Void();
2327 }
2328
getCDMASubscription(int32_t serial)2329 Return<void> RadioImpl_1_6::getCDMASubscription(int32_t serial) {
2330 #if VDBG
2331 RLOGD("getCDMASubscription: serial %d", serial);
2332 #endif
2333 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
2334 return Void();
2335 }
2336
writeSmsToRuim(int32_t serial,const CdmaSmsWriteArgs & cdmaSms)2337 Return<void> RadioImpl_1_6::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
2338 #if VDBG
2339 RLOGD("writeSmsToRuim: serial %d", serial);
2340 #endif
2341 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2342 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
2343 if (pRI == NULL) {
2344 return Void();
2345 }
2346
2347 RIL_CDMA_SMS_WriteArgs rcsw = {};
2348 rcsw.status = (int) cdmaSms.status;
2349 constructCdmaSms(rcsw.message, cdmaSms.message);
2350
2351 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
2352 return Void();
2353 }
2354
deleteSmsOnRuim(int32_t serial,int32_t index)2355 Return<void> RadioImpl_1_6::deleteSmsOnRuim(int32_t serial, int32_t index) {
2356 #if VDBG
2357 RLOGD("deleteSmsOnRuim: serial %d", serial);
2358 #endif
2359 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
2360 return Void();
2361 }
2362
getDeviceIdentity(int32_t serial)2363 Return<void> RadioImpl_1_6::getDeviceIdentity(int32_t serial) {
2364 #if VDBG
2365 RLOGD("getDeviceIdentity: serial %d", serial);
2366 #endif
2367 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
2368 return Void();
2369 }
2370
exitEmergencyCallbackMode(int32_t serial)2371 Return<void> RadioImpl_1_6::exitEmergencyCallbackMode(int32_t serial) {
2372 #if VDBG
2373 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
2374 #endif
2375 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
2376 return Void();
2377 }
2378
getSmscAddress(int32_t serial)2379 Return<void> RadioImpl_1_6::getSmscAddress(int32_t serial) {
2380 #if VDBG
2381 RLOGD("getSmscAddress: serial %d", serial);
2382 #endif
2383 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
2384 return Void();
2385 }
2386
setSmscAddress(int32_t serial,const hidl_string & smsc)2387 Return<void> RadioImpl_1_6::setSmscAddress(int32_t serial, const hidl_string& smsc) {
2388 #if VDBG
2389 RLOGD("setSmscAddress: serial %d", serial);
2390 #endif
2391 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
2392 smsc.c_str());
2393 return Void();
2394 }
2395
reportSmsMemoryStatus(int32_t serial,bool available)2396 Return<void> RadioImpl_1_6::reportSmsMemoryStatus(int32_t serial, bool available) {
2397 #if VDBG
2398 RLOGD("reportSmsMemoryStatus: serial %d", serial);
2399 #endif
2400 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
2401 BOOL_TO_INT(available));
2402 return Void();
2403 }
2404
reportStkServiceIsRunning(int32_t serial)2405 Return<void> RadioImpl_1_6::reportStkServiceIsRunning(int32_t serial) {
2406 #if VDBG
2407 RLOGD("reportStkServiceIsRunning: serial %d", serial);
2408 #endif
2409 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
2410 return Void();
2411 }
2412
getCdmaSubscriptionSource(int32_t serial)2413 Return<void> RadioImpl_1_6::getCdmaSubscriptionSource(int32_t serial) {
2414 #if VDBG
2415 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
2416 #endif
2417 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
2418 return Void();
2419 }
2420
requestIsimAuthentication(int32_t serial,const hidl_string & challenge)2421 Return<void> RadioImpl_1_6::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
2422 #if VDBG
2423 RLOGD("requestIsimAuthentication: serial %d", serial);
2424 #endif
2425 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
2426 challenge.c_str());
2427 return Void();
2428 }
2429
acknowledgeIncomingGsmSmsWithPdu(int32_t serial,bool success,const hidl_string & ackPdu)2430 Return<void> RadioImpl_1_6::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
2431 const hidl_string& ackPdu) {
2432 #if VDBG
2433 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
2434 #endif
2435 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, false,
2436 2, success ? "1" : "0", ackPdu.c_str());
2437 return Void();
2438 }
2439
sendEnvelopeWithStatus(int32_t serial,const hidl_string & contents)2440 Return<void> RadioImpl_1_6::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
2441 #if VDBG
2442 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
2443 #endif
2444 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
2445 contents.c_str());
2446 return Void();
2447 }
2448
getVoiceRadioTechnology(int32_t serial)2449 Return<void> RadioImpl_1_6::getVoiceRadioTechnology(int32_t serial) {
2450 #if VDBG
2451 RLOGD("getVoiceRadioTechnology: serial %d", serial);
2452 #endif
2453 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
2454 return Void();
2455 }
2456
getCellInfoList(int32_t serial)2457 Return<void> RadioImpl_1_6::getCellInfoList(int32_t serial) {
2458 #if VDBG
2459 RLOGD("getCellInfoList: serial %d", serial);
2460 #endif
2461 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
2462 return Void();
2463 }
2464
getCellInfoList_1_6(int32_t serial)2465 Return<void> RadioImpl_1_6::getCellInfoList_1_6(int32_t serial) {
2466 #if VDBG
2467 RLOGD("getCellInfoList_1_6: serial %d", serial);
2468 #endif
2469 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST_1_6);
2470 return Void();
2471 }
2472
setCellInfoListRate(int32_t serial,int32_t rate)2473 Return<void> RadioImpl_1_6::setCellInfoListRate(int32_t serial, int32_t rate) {
2474 #if VDBG
2475 RLOGD("setCellInfoListRate: serial %d", serial);
2476 #endif
2477 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
2478 return Void();
2479 }
2480
setInitialAttachApn(int32_t serial,const DataProfileInfo & dataProfileInfo,bool modemCognitive,bool isRoaming)2481 Return<void> RadioImpl_1_6::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
2482 bool modemCognitive, bool isRoaming) {
2483 #if VDBG
2484 RLOGD("setInitialAttachApn: serial %d", serial);
2485 #endif
2486 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2487 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
2488 if (pRI == NULL) {
2489 return Void();
2490 }
2491
2492 if (s_vendorFunctions->version <= 14) {
2493 RIL_InitialAttachApn iaa = {};
2494
2495 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2496 return Void();
2497 }
2498
2499 const hidl_string &protocol =
2500 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
2501
2502 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
2503 memsetAndFreeStrings(1, iaa.apn);
2504 return Void();
2505 }
2506 iaa.authtype = (int) dataProfileInfo.authType;
2507 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2508 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2509 return Void();
2510 }
2511 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2512 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
2513 return Void();
2514 }
2515
2516 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2517
2518 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
2519 } else {
2520 RIL_InitialAttachApn_v15 iaa = {};
2521
2522 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2523 return Void();
2524 }
2525
2526 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
2527 memsetAndFreeStrings(1, iaa.apn);
2528 return Void();
2529 }
2530 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
2531 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2532 return Void();
2533 }
2534 iaa.authtype = (int) dataProfileInfo.authType;
2535 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2536 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
2537 return Void();
2538 }
2539 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2540 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
2541 return Void();
2542 }
2543 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
2544 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
2545 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
2546 iaa.mtu = dataProfileInfo.mtu;
2547
2548 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
2549 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2550 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2551 iaa.password);
2552 return Void();
2553 }
2554
2555 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
2556 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2557 iaa.password);
2558 return Void();
2559 }
2560
2561 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2562
2563 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2564 iaa.password, iaa.mvnoMatchData);
2565 }
2566
2567 return Void();
2568 }
2569
getImsRegistrationState(int32_t serial)2570 Return<void> RadioImpl_1_6::getImsRegistrationState(int32_t serial) {
2571 #if VDBG
2572 RLOGD("getImsRegistrationState: serial %d", serial);
2573 #endif
2574 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2575 return Void();
2576 }
2577
dispatchImsGsmSms(const ImsSmsMessage & message,RequestInfo * pRI)2578 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2579 RIL_IMS_SMS_Message rism = {};
2580 char **pStrings;
2581 int countStrings = 2;
2582 int dataLen = sizeof(char *) * countStrings;
2583
2584 rism.tech = RADIO_TECH_3GPP;
2585 rism.retry = BOOL_TO_INT(message.retry);
2586 rism.messageRef = message.messageRef;
2587
2588 if (message.gsmMessage.size() != 1) {
2589 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2590 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2591 return false;
2592 }
2593
2594 pStrings = (char **)calloc(countStrings, sizeof(char *));
2595 if (pStrings == NULL) {
2596 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2597 requestToString(pRI->pCI->requestNumber));
2598 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2599 return false;
2600 }
2601
2602 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2603 #ifdef MEMSET_FREED
2604 memset(pStrings, 0, dataLen);
2605 #endif
2606 free(pStrings);
2607 return false;
2608 }
2609
2610 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2611 memsetAndFreeStrings(1, pStrings[0]);
2612 #ifdef MEMSET_FREED
2613 memset(pStrings, 0, dataLen);
2614 #endif
2615 free(pStrings);
2616 return false;
2617 }
2618
2619 rism.message.gsmMessage = pStrings;
2620 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2621 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2622
2623 for (int i = 0 ; i < countStrings ; i++) {
2624 memsetAndFreeStrings(1, pStrings[i]);
2625 }
2626
2627 #ifdef MEMSET_FREED
2628 memset(pStrings, 0, dataLen);
2629 #endif
2630 free(pStrings);
2631
2632 return true;
2633 }
2634
2635 struct ImsCdmaSms {
2636 RIL_IMS_SMS_Message imsSms;
2637 RIL_CDMA_SMS_Message cdmaSms;
2638 };
2639
dispatchImsCdmaSms(const ImsSmsMessage & message,RequestInfo * pRI)2640 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2641 ImsCdmaSms temp = {};
2642
2643 if (message.cdmaMessage.size() != 1) {
2644 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2645 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2646 return false;
2647 }
2648
2649 temp.imsSms.tech = RADIO_TECH_3GPP2;
2650 temp.imsSms.retry = BOOL_TO_INT(message.retry);
2651 temp.imsSms.messageRef = message.messageRef;
2652 temp.imsSms.message.cdmaMessage = &temp.cdmaSms;
2653
2654 constructCdmaSms(temp.cdmaSms, message.cdmaMessage[0]);
2655
2656 // Vendor code expects payload length to include actual msg payload
2657 // (sizeof(RIL_CDMA_SMS_Message)) instead of (RIL_CDMA_SMS_Message *) + size of other fields in
2658 // RIL_IMS_SMS_Message
2659 int payloadLen = sizeof(RIL_RadioTechnologyFamily) + sizeof(uint8_t) + sizeof(int32_t)
2660 + sizeof(RIL_CDMA_SMS_Message);
2661
2662 CALL_ONREQUEST(pRI->pCI->requestNumber, &temp.imsSms, payloadLen, pRI, pRI->socket_id);
2663
2664 return true;
2665 }
2666
sendImsSms(int32_t serial,const ImsSmsMessage & message)2667 Return<void> RadioImpl_1_6::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2668 #if VDBG
2669 RLOGD("sendImsSms: serial %d", serial);
2670 #endif
2671 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2672 if (pRI == NULL) {
2673 return Void();
2674 }
2675
2676 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2677
2678 if (RADIO_TECH_3GPP == format) {
2679 dispatchImsGsmSms(message, pRI);
2680 } else if (RADIO_TECH_3GPP2 == format) {
2681 dispatchImsCdmaSms(message, pRI);
2682 } else {
2683 RLOGE("sendImsSms: Invalid radio tech %s",
2684 requestToString(pRI->pCI->requestNumber));
2685 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2686 }
2687 return Void();
2688 }
2689
iccTransmitApduBasicChannel(int32_t serial,const SimApdu & message)2690 Return<void> RadioImpl_1_6::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2691 #if VDBG
2692 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2693 #endif
2694 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2695 return Void();
2696 }
2697
iccOpenLogicalChannel(int32_t serial,const hidl_string & aid,int32_t p2)2698 Return<void> RadioImpl_1_6::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2699 #if VDBG
2700 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2701 #endif
2702 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2703 if (pRI == NULL) {
2704 return Void();
2705 }
2706
2707 RIL_OpenChannelParams params = {};
2708
2709 params.p2 = p2;
2710
2711 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2712 return Void();
2713 }
2714
2715 CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId);
2716
2717 memsetAndFreeStrings(1, params.aidPtr);
2718 return Void();
2719 }
2720
iccCloseLogicalChannel(int32_t serial,int32_t channelId)2721 Return<void> RadioImpl_1_6::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2722 #if VDBG
2723 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2724 #endif
2725 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2726 return Void();
2727 }
2728
iccTransmitApduLogicalChannel(int32_t serial,const SimApdu & message)2729 Return<void> RadioImpl_1_6::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2730 #if VDBG
2731 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2732 #endif
2733 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2734 return Void();
2735 }
2736
nvReadItem(int32_t serial,NvItem itemId)2737 Return<void> RadioImpl_1_6::nvReadItem(int32_t serial, NvItem itemId) {
2738 #if VDBG
2739 RLOGD("nvReadItem: serial %d", serial);
2740 #endif
2741 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2742 if (pRI == NULL) {
2743 return Void();
2744 }
2745
2746 RIL_NV_ReadItem nvri = {};
2747 nvri.itemID = (RIL_NV_Item) itemId;
2748
2749 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2750 return Void();
2751 }
2752
nvWriteItem(int32_t serial,const NvWriteItem & item)2753 Return<void> RadioImpl_1_6::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2754 #if VDBG
2755 RLOGD("nvWriteItem: serial %d", serial);
2756 #endif
2757 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2758 if (pRI == NULL) {
2759 return Void();
2760 }
2761
2762 RIL_NV_WriteItem nvwi = {};
2763
2764 nvwi.itemID = (RIL_NV_Item) item.itemId;
2765
2766 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2767 return Void();
2768 }
2769
2770 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2771
2772 memsetAndFreeStrings(1, nvwi.value);
2773 return Void();
2774 }
2775
nvWriteCdmaPrl(int32_t serial,const hidl_vec<uint8_t> & prl)2776 Return<void> RadioImpl_1_6::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2777 #if VDBG
2778 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2779 #endif
2780 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2781 return Void();
2782 }
2783
nvResetConfig(int32_t serial,ResetNvType resetType)2784 Return<void> RadioImpl_1_6::nvResetConfig(int32_t serial, ResetNvType resetType) {
2785 int rilResetType = -1;
2786 #if VDBG
2787 RLOGD("nvResetConfig: serial %d", serial);
2788 #endif
2789 /* Convert ResetNvType to RIL.h values
2790 * RIL_REQUEST_NV_RESET_CONFIG
2791 * 1 - reload all NV items
2792 * 2 - erase NV reset (SCRTN)
2793 * 3 - factory reset (RTN)
2794 */
2795 switch(resetType) {
2796 case ResetNvType::RELOAD:
2797 rilResetType = 1;
2798 break;
2799 case ResetNvType::ERASE:
2800 rilResetType = 2;
2801 break;
2802 case ResetNvType::FACTORY_RESET:
2803 rilResetType = 3;
2804 break;
2805 }
2806 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2807 return Void();
2808 }
2809
setUiccSubscription(int32_t serial,const SelectUiccSub & uiccSub)2810 Return<void> RadioImpl_1_6::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2811 #if VDBG
2812 RLOGD("setUiccSubscription: serial %d", serial);
2813 #endif
2814 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2815 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2816 if (pRI == NULL) {
2817 return Void();
2818 }
2819
2820 RIL_SelectUiccSub rilUiccSub = {};
2821
2822 rilUiccSub.slot = uiccSub.slot;
2823 rilUiccSub.app_index = uiccSub.appIndex;
2824 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2825 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2826
2827 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2828 return Void();
2829 }
2830
setDataAllowed(int32_t serial,bool allow)2831 Return<void> RadioImpl_1_6::setDataAllowed(int32_t serial, bool allow) {
2832 #if VDBG
2833 RLOGD("setDataAllowed: serial %d", serial);
2834 #endif
2835 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2836 return Void();
2837 }
2838
getHardwareConfig(int32_t serial)2839 Return<void> RadioImpl_1_6::getHardwareConfig(int32_t serial) {
2840 #if VDBG
2841 RLOGD("getHardwareConfig: serial %d", serial);
2842 #endif
2843 RLOGD("getHardwareConfig: serial %d, mSlotId = %d", serial, mSlotId);
2844 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2845 return Void();
2846 }
2847
requestIccSimAuthentication(int32_t serial,int32_t authContext,const hidl_string & authData,const hidl_string & aid)2848 Return<void> RadioImpl_1_6::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2849 const hidl_string& authData, const hidl_string& aid) {
2850 #if VDBG
2851 RLOGD("requestIccSimAuthentication: serial %d", serial);
2852 #endif
2853 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2854 if (pRI == NULL) {
2855 return Void();
2856 }
2857
2858 RIL_SimAuthentication pf = {};
2859
2860 pf.authContext = authContext;
2861
2862 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2863 return Void();
2864 }
2865
2866 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2867 memsetAndFreeStrings(1, pf.authData);
2868 return Void();
2869 }
2870
2871 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2872
2873 memsetAndFreeStrings(2, pf.authData, pf.aid);
2874 return Void();
2875 }
2876
2877 /**
2878 * @param numProfiles number of data profile
2879 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2880 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2881 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2882 * @param numfields number of string-type member in the data profile structure
2883 * @param ... the variadic parameters are pointers to each string-type member
2884 **/
2885 template <typename T>
freeSetDataProfileData(int numProfiles,T * dataProfiles,T ** dataProfilePtrs,int numfields,...)2886 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2887 int numfields, ...) {
2888 va_list args;
2889 va_start(args, numfields);
2890
2891 // Iterate through each string-type field that need to be free.
2892 for (int i = 0; i < numfields; i++) {
2893 // Iterate through each data profile and free that specific string-type field.
2894 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2895 char *T::*ptr = va_arg(args, char *T::*);
2896 for (int j = 0; j < numProfiles; j++) {
2897 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2898 }
2899 }
2900
2901 va_end(args);
2902
2903 #ifdef MEMSET_FREED
2904 memset(dataProfiles, 0, numProfiles * sizeof(T));
2905 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2906 #endif
2907 free(dataProfiles);
2908 free(dataProfilePtrs);
2909 }
2910
setDataProfile(int32_t serial,const hidl_vec<DataProfileInfo> & profiles,bool isRoaming)2911 Return<void> RadioImpl_1_6::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2912 bool isRoaming) {
2913 #if VDBG
2914 RLOGD("setDataProfile: serial %d", serial);
2915 #endif
2916 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2917 if (pRI == NULL) {
2918 return Void();
2919 }
2920
2921 size_t num = profiles.size();
2922 bool success = false;
2923
2924 if (s_vendorFunctions->version <= 14) {
2925
2926 RIL_DataProfileInfo *dataProfiles =
2927 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2928
2929 if (dataProfiles == NULL) {
2930 RLOGE("Memory allocation failed for request %s",
2931 requestToString(pRI->pCI->requestNumber));
2932 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2933 return Void();
2934 }
2935
2936 RIL_DataProfileInfo **dataProfilePtrs =
2937 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2938 if (dataProfilePtrs == NULL) {
2939 RLOGE("Memory allocation failed for request %s",
2940 requestToString(pRI->pCI->requestNumber));
2941 free(dataProfiles);
2942 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2943 return Void();
2944 }
2945
2946 for (size_t i = 0; i < num; i++) {
2947 dataProfilePtrs[i] = &dataProfiles[i];
2948
2949 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2950
2951 const hidl_string &protocol =
2952 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2953
2954 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI, true)) {
2955 success = false;
2956 }
2957
2958 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2959 true)) {
2960 success = false;
2961 }
2962 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2963 pRI, true)) {
2964 success = false;
2965 }
2966
2967 if (!success) {
2968 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2969 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2970 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2971 return Void();
2972 }
2973
2974 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2975 dataProfiles[i].authType = (int) profiles[i].authType;
2976 dataProfiles[i].type = (int) profiles[i].type;
2977 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2978 dataProfiles[i].maxConns = profiles[i].maxConns;
2979 dataProfiles[i].waitTime = profiles[i].waitTime;
2980 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2981 }
2982
2983 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2984 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2985
2986 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2987 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2988 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2989 } else {
2990 RIL_DataProfileInfo_v15 *dataProfiles =
2991 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2992
2993 if (dataProfiles == NULL) {
2994 RLOGE("Memory allocation failed for request %s",
2995 requestToString(pRI->pCI->requestNumber));
2996 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2997 return Void();
2998 }
2999
3000 RIL_DataProfileInfo_v15 **dataProfilePtrs =
3001 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
3002 if (dataProfilePtrs == NULL) {
3003 RLOGE("Memory allocation failed for request %s",
3004 requestToString(pRI->pCI->requestNumber));
3005 free(dataProfiles);
3006 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3007 return Void();
3008 }
3009
3010 for (size_t i = 0; i < num; i++) {
3011 dataProfilePtrs[i] = &dataProfiles[i];
3012
3013 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
3014 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
3015 pRI)) {
3016 success = false;
3017 }
3018 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
3019 profiles[i].roamingProtocol, pRI, true)) {
3020 success = false;
3021 }
3022 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
3023 true)) {
3024 success = false;
3025 }
3026 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
3027 pRI, true)) {
3028 success = false;
3029 }
3030 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
3031 profiles[i].mvnoMatchData, pRI, true)) {
3032 success = false;
3033 }
3034
3035 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
3036 dataProfiles[i].mvnoType)) {
3037 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3038 success = false;
3039 }
3040
3041 if (!success) {
3042 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
3043 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
3044 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
3045 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
3046 return Void();
3047 }
3048
3049 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
3050 dataProfiles[i].authType = (int) profiles[i].authType;
3051 dataProfiles[i].type = (int) profiles[i].type;
3052 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
3053 dataProfiles[i].maxConns = profiles[i].maxConns;
3054 dataProfiles[i].waitTime = profiles[i].waitTime;
3055 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
3056 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
3057 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
3058 dataProfiles[i].mtu = profiles[i].mtu;
3059 }
3060
3061 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
3062 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
3063
3064 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
3065 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
3066 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
3067 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
3068 }
3069
3070 return Void();
3071 }
3072
requestShutdown(int32_t serial)3073 Return<void> RadioImpl_1_6::requestShutdown(int32_t serial) {
3074 #if VDBG
3075 RLOGD("requestShutdown: serial %d", serial);
3076 #endif
3077 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
3078 return Void();
3079 }
3080
getRadioCapability(int32_t serial)3081 Return<void> RadioImpl_1_6::getRadioCapability(int32_t serial) {
3082 #if VDBG
3083 RLOGD("getRadioCapability: serial %d", serial);
3084 #endif
3085 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
3086 return Void();
3087 }
3088
setRadioCapability(int32_t serial,const RadioCapability & rc)3089 Return<void> RadioImpl_1_6::setRadioCapability(int32_t serial, const RadioCapability& rc) {
3090 #if VDBG
3091 RLOGD("setRadioCapability: serial %d", serial);
3092 #endif
3093 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
3094 if (pRI == NULL) {
3095 return Void();
3096 }
3097
3098 RIL_RadioCapability rilRc = {};
3099
3100 // TODO : set rilRc.version using HIDL version ?
3101 rilRc.session = rc.session;
3102 rilRc.phase = (int) rc.phase;
3103 rilRc.rat = (int) rc.raf;
3104 rilRc.status = (int) rc.status;
3105 strlcpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), sizeof(rilRc.logicalModemUuid));
3106
3107 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
3108
3109 return Void();
3110 }
3111
startLceService(int32_t serial,int32_t reportInterval,bool pullMode)3112 Return<void> RadioImpl_1_6::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
3113 #if VDBG
3114 RLOGD("startLceService: serial %d", serial);
3115 #endif
3116 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
3117 BOOL_TO_INT(pullMode));
3118 return Void();
3119 }
3120
stopLceService(int32_t serial)3121 Return<void> RadioImpl_1_6::stopLceService(int32_t serial) {
3122 #if VDBG
3123 RLOGD("stopLceService: serial %d", serial);
3124 #endif
3125 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
3126 return Void();
3127 }
3128
pullLceData(int32_t serial)3129 Return<void> RadioImpl_1_6::pullLceData(int32_t serial) {
3130 #if VDBG
3131 RLOGD("pullLceData: serial %d", serial);
3132 #endif
3133 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
3134 return Void();
3135 }
3136
getModemActivityInfo(int32_t serial)3137 Return<void> RadioImpl_1_6::getModemActivityInfo(int32_t serial) {
3138 #if VDBG
3139 RLOGD("getModemActivityInfo: serial %d", serial);
3140 #endif
3141 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
3142 return Void();
3143 }
3144
prepareCarrierRestrictions(RIL_CarrierRestrictions & request,bool allAllowed,const hidl_vec<Carrier> & allowedList,const hidl_vec<Carrier> & excludedList,RequestInfo * pRI)3145 int prepareCarrierRestrictions(RIL_CarrierRestrictions &request, bool allAllowed,
3146 const hidl_vec<Carrier>& allowedList,
3147 const hidl_vec<Carrier>& excludedList,
3148 RequestInfo *pRI) {
3149 RIL_Carrier *allowedCarriers = NULL;
3150 RIL_Carrier *excludedCarriers = NULL;
3151
3152 request.len_allowed_carriers = allowedList.size();
3153 allowedCarriers = (RIL_Carrier *)calloc(request.len_allowed_carriers, sizeof(RIL_Carrier));
3154 if (allowedCarriers == NULL) {
3155 RLOGE("prepareCarrierRestrictions: Memory allocation failed for request %s",
3156 requestToString(pRI->pCI->requestNumber));
3157 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3158 return -1;
3159 }
3160 request.allowed_carriers = allowedCarriers;
3161
3162 request.len_excluded_carriers = excludedList.size();
3163 excludedCarriers = (RIL_Carrier *)calloc(request.len_excluded_carriers, sizeof(RIL_Carrier));
3164 if (excludedCarriers == NULL) {
3165 RLOGE("prepareCarrierRestrictions: Memory allocation failed for request %s",
3166 requestToString(pRI->pCI->requestNumber));
3167 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3168 #ifdef MEMSET_FREED
3169 memset(allowedCarriers, 0, request.len_allowed_carriers * sizeof(RIL_Carrier));
3170 #endif
3171 free(allowedCarriers);
3172 return -1;
3173 }
3174 request.excluded_carriers = excludedCarriers;
3175
3176 for (int i = 0; i < request.len_allowed_carriers; i++) {
3177 allowedCarriers[i].mcc = allowedList[i].mcc.c_str();
3178 allowedCarriers[i].mnc = allowedList[i].mnc.c_str();
3179 allowedCarriers[i].match_type = (RIL_CarrierMatchType) allowedList[i].matchType;
3180 allowedCarriers[i].match_data = allowedList[i].matchData.c_str();
3181 }
3182
3183 for (int i = 0; i < request.len_excluded_carriers; i++) {
3184 excludedCarriers[i].mcc = excludedList[i].mcc.c_str();
3185 excludedCarriers[i].mnc = excludedList[i].mnc.c_str();
3186 excludedCarriers[i].match_type =
3187 (RIL_CarrierMatchType) excludedList[i].matchType;
3188 excludedCarriers[i].match_data = excludedList[i].matchData.c_str();
3189 }
3190
3191 return 0;
3192 }
3193
freeCarrierRestrictions(RIL_CarrierRestrictions & request)3194 void freeCarrierRestrictions(RIL_CarrierRestrictions &request) {
3195 if (request.allowed_carriers != NULL) {
3196 #ifdef MEMSET_FREED
3197 memset(request.allowed_carriers, 0, request.len_allowed_carriers * sizeof(RIL_Carrier));
3198 #endif
3199 free(request.allowed_carriers);
3200 }
3201 if (request.excluded_carriers != NULL) {
3202 #ifdef MEMSET_FREED
3203 memset(request.excluded_carriers, 0, request.len_excluded_carriers * sizeof(RIL_Carrier));
3204 #endif
3205 free(request.excluded_carriers);
3206 }
3207 }
3208
setAllowedCarriers(int32_t serial,bool allAllowed,const CarrierRestrictions & carriers)3209 Return<void> RadioImpl_1_6::setAllowedCarriers(int32_t serial, bool allAllowed,
3210 const CarrierRestrictions& carriers) {
3211 #if VDBG
3212 RLOGD("setAllowedCarriers: serial %d", serial);
3213 #endif
3214 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3215 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
3216 if (pRI == NULL) {
3217 return Void();
3218 }
3219
3220 RIL_CarrierRestrictions cr = {};
3221 if (prepareCarrierRestrictions(cr, allAllowed, carriers.allowedCarriers,
3222 carriers.excludedCarriers, pRI) < 0) {
3223 return Void();
3224 }
3225
3226 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
3227
3228 freeCarrierRestrictions(cr);
3229
3230 return Void();
3231 }
3232
getAllowedCarriers(int32_t serial)3233 Return<void> RadioImpl_1_6::getAllowedCarriers(int32_t serial) {
3234 #if VDBG
3235 RLOGD("getAllowedCarriers: serial %d", serial);
3236 #endif
3237 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
3238 return Void();
3239 }
3240
sendDeviceState(int32_t serial,DeviceStateType deviceStateType,bool state)3241 Return<void> RadioImpl_1_6::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
3242 bool state) {
3243 #if VDBG
3244 RLOGD("sendDeviceState: serial %d", serial);
3245 #endif
3246 if (s_vendorFunctions->version < 15) {
3247 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
3248 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
3249 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
3250 } else {
3251 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3252 RIL_REQUEST_SEND_DEVICE_STATE);
3253 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
3254 }
3255 return Void();
3256 }
3257 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
3258 BOOL_TO_INT(state));
3259 return Void();
3260 }
3261
setIndicationFilter(int32_t serial,int32_t indicationFilter)3262 Return<void> RadioImpl_1_6::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
3263 #if VDBG
3264 RLOGD("setIndicationFilter: serial %d", serial);
3265 #endif
3266 if (s_vendorFunctions->version < 15) {
3267 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3268 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
3269 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
3270 return Void();
3271 }
3272 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
3273 return Void();
3274 }
3275
setSimCardPower(int32_t serial,bool powerUp)3276 Return<void> RadioImpl_1_6::setSimCardPower(int32_t serial, bool powerUp) {
3277 #if VDBG
3278 RLOGD("setSimCardPower: serial %d", serial);
3279 #endif
3280 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
3281 return Void();
3282 }
3283
setSimCardPower_1_1(int32_t serial,const V1_1::CardPowerState state)3284 Return<void> RadioImpl_1_6::setSimCardPower_1_1(int32_t serial, const V1_1::CardPowerState state) {
3285 #if VDBG
3286 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
3287 #endif
3288 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
3289 return Void();
3290 }
3291
setSimCardPower_1_6(int32_t serial,const V1_1::CardPowerState state)3292 Return<void> RadioImpl_1_6::setSimCardPower_1_6(int32_t serial, const V1_1::CardPowerState state) {
3293 #if VDBG
3294 RLOGD("setSimCardPower_1_6: serial %d state %d", serial, state);
3295 #endif
3296 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
3297 mSimCardPowerState = state;
3298 return Void();
3299 }
3300
setCarrierInfoForImsiEncryption(int32_t serial,const V1_1::ImsiEncryptionInfo & data)3301 Return<void> RadioImpl_1_6::setCarrierInfoForImsiEncryption(int32_t serial,
3302 const V1_1::ImsiEncryptionInfo& data) {
3303 #if VDBG
3304 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
3305 #endif
3306 RequestInfo *pRI = android::addRequestToList(
3307 serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
3308 if (pRI == NULL) {
3309 return Void();
3310 }
3311
3312 RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
3313
3314 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
3315 return Void();
3316 }
3317 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
3318 memsetAndFreeStrings(1, imsiEncryption.mnc);
3319 return Void();
3320 }
3321 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
3322 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
3323 return Void();
3324 }
3325 imsiEncryption.carrierKeyLength = data.carrierKey.size();
3326 imsiEncryption.carrierKey = new uint8_t[imsiEncryption.carrierKeyLength];
3327 memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), imsiEncryption.carrierKeyLength);
3328 imsiEncryption.expirationTime = data.expirationTime;
3329 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
3330 sizeof(RIL_CarrierInfoForImsiEncryption), pRI, mSlotId);
3331 delete(imsiEncryption.carrierKey);
3332 return Void();
3333 }
3334
startKeepalive(int32_t serial,const V1_1::KeepaliveRequest & keepalive)3335 Return<void> RadioImpl_1_6::startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive) {
3336 #if VDBG
3337 RLOGD("%s(): %d", __FUNCTION__, serial);
3338 #endif
3339 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_KEEPALIVE);
3340 if (pRI == NULL) {
3341 return Void();
3342 }
3343
3344 RIL_KeepaliveRequest kaReq = {};
3345
3346 kaReq.type = static_cast<RIL_KeepaliveType>(keepalive.type);
3347 switch(kaReq.type) {
3348 case NATT_IPV4:
3349 if (keepalive.sourceAddress.size() != 4 ||
3350 keepalive.destinationAddress.size() != 4) {
3351 RLOGE("Invalid address for keepalive!");
3352 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3353 return Void();
3354 }
3355 break;
3356 case NATT_IPV6:
3357 if (keepalive.sourceAddress.size() != 16 ||
3358 keepalive.destinationAddress.size() != 16) {
3359 RLOGE("Invalid address for keepalive!");
3360 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3361 return Void();
3362 }
3363 break;
3364 default:
3365 RLOGE("Unknown packet keepalive type!");
3366 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3367 return Void();
3368 }
3369
3370 ::memcpy(kaReq.sourceAddress, keepalive.sourceAddress.data(), keepalive.sourceAddress.size());
3371 kaReq.sourcePort = keepalive.sourcePort;
3372
3373 ::memcpy(kaReq.destinationAddress,
3374 keepalive.destinationAddress.data(), keepalive.destinationAddress.size());
3375 kaReq.destinationPort = keepalive.destinationPort;
3376
3377 kaReq.maxKeepaliveIntervalMillis = keepalive.maxKeepaliveIntervalMillis;
3378 kaReq.cid = keepalive.cid; // This is the context ID of the data call
3379
3380 CALL_ONREQUEST(pRI->pCI->requestNumber, &kaReq, sizeof(RIL_KeepaliveRequest), pRI, mSlotId);
3381 return Void();
3382 }
3383
stopKeepalive(int32_t serial,int32_t sessionHandle)3384 Return<void> RadioImpl_1_6::stopKeepalive(int32_t serial, int32_t sessionHandle) {
3385 #if VDBG
3386 RLOGD("%s(): %d", __FUNCTION__, serial);
3387 #endif
3388 dispatchInts(serial, mSlotId, RIL_REQUEST_STOP_KEEPALIVE, 1, sessionHandle);
3389 return Void();
3390 }
3391
responseAcknowledgement()3392 Return<void> RadioImpl_1_6::responseAcknowledgement() {
3393 android::releaseWakeLock();
3394 return Void();
3395 }
3396
3397 // 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)3398 int prepareNetworkScanRequest_1_2(RIL_NetworkScanRequest &scan_request,
3399 const ::android::hardware::radio::V1_2::NetworkScanRequest& request,
3400 RequestInfo *pRI) {
3401
3402 scan_request.type = (RIL_ScanType) request.type;
3403 scan_request.interval = request.interval;
3404 scan_request.specifiers_length = request.specifiers.size();
3405
3406 int intervalLow = static_cast<int>(::android::hardware::radio::V1_2::ScanIntervalRange::MIN);
3407 int intervalHigh = static_cast<int>(::android::hardware::radio::V1_2::ScanIntervalRange::MAX);
3408 int maxSearchTimeLow =
3409 static_cast<int>(::android::hardware::radio::V1_2::MaxSearchTimeRange::MIN);
3410 int maxSearchTimeHigh =
3411 static_cast<int>(::android::hardware::radio::V1_2::MaxSearchTimeRange::MAX);
3412 int incrementalResultsPeriodicityRangeLow =
3413 static_cast<int>(::android::hardware::radio::V1_2::IncrementalResultsPeriodicityRange::MIN);
3414 int incrementalResultsPeriodicityRangeHigh =
3415 static_cast<int>(::android::hardware::radio::V1_2::IncrementalResultsPeriodicityRange::MAX);
3416 uint maxSpecifierSize =
3417 static_cast<uint>(::android::hardware::radio::V1_2::RadioConst
3418 ::RADIO_ACCESS_SPECIFIER_MAX_SIZE);
3419
3420 if (request.interval < intervalLow || request.interval > intervalHigh) {
3421 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3422 return -1;
3423 }
3424 // If defined, must fall in correct range.
3425 if (request.maxSearchTime != 0
3426 && (request.maxSearchTime < maxSearchTimeLow
3427 || request.maxSearchTime > maxSearchTimeHigh)) {
3428 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3429 return -1;
3430 }
3431 if (request.maxSearchTime != 0
3432 && (request.incrementalResultsPeriodicity < incrementalResultsPeriodicityRangeLow
3433 || request.incrementalResultsPeriodicity > incrementalResultsPeriodicityRangeHigh
3434 || request.incrementalResultsPeriodicity > request.maxSearchTime)) {
3435 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3436 return -1;
3437 }
3438 if (request.specifiers.size() == 0 || request.specifiers.size() > maxSpecifierSize) {
3439 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3440 return -1;
3441 }
3442
3443 for (size_t i = 0; i < request.specifiers.size(); ++i) {
3444 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
3445 request.specifiers[i].utranBands.size() > MAX_BANDS ||
3446 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
3447 request.specifiers[i].channels.size() > MAX_CHANNELS) {
3448 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3449 return -1;
3450 }
3451 const V1_1::RadioAccessSpecifier& ras_from =
3452 request.specifiers[i];
3453 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
3454
3455 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
3456 ras_to.channels_length = ras_from.channels.size();
3457
3458 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
3459 const std::vector<uint32_t> * bands = nullptr;
3460 switch (request.specifiers[i].radioAccessNetwork) {
3461 case V1_1::RadioAccessNetworks::GERAN:
3462 ras_to.bands_length = ras_from.geranBands.size();
3463 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
3464 break;
3465 case V1_1::RadioAccessNetworks::UTRAN:
3466 ras_to.bands_length = ras_from.utranBands.size();
3467 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
3468 break;
3469 case V1_1::RadioAccessNetworks::EUTRAN:
3470 ras_to.bands_length = ras_from.eutranBands.size();
3471 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
3472 break;
3473 default:
3474 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3475 return -1;
3476 }
3477 // safe to copy to geran_bands because it's a union member
3478 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
3479 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
3480 }
3481 }
3482
3483 return 0;
3484 }
3485
startNetworkScan_1_2(int32_t serial,const::android::hardware::radio::V1_2::NetworkScanRequest & request)3486 Return<void> RadioImpl_1_6::startNetworkScan_1_2(int32_t serial,
3487 const ::android::hardware::radio::V1_2::NetworkScanRequest& request) {
3488 #if VDBG
3489 RLOGD("startNetworkScan_1_2: serial %d", serial);
3490 #endif
3491
3492 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
3493 if (pRI == NULL) {
3494 return Void();
3495 }
3496
3497 RIL_NetworkScanRequest scan_request = {};
3498
3499 if (prepareNetworkScanRequest_1_2(scan_request, request, pRI) < 0) {
3500 return Void();
3501 }
3502
3503 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
3504 mSlotId);
3505
3506 return Void();
3507 }
3508
setIndicationFilter_1_2(int32_t serial,::android::hardware::hidl_bitfield<V1_2::IndicationFilter> indicationFilter)3509 Return<void> RadioImpl_1_6::setIndicationFilter_1_2(int32_t serial,
3510 ::android::hardware::hidl_bitfield<V1_2::IndicationFilter> indicationFilter) {
3511 #if VDBG
3512 RLOGD("setIndicationFilter_1_2: serial %d", serial);
3513 #endif
3514
3515 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3516 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
3517 sendErrorResponse(pRI, RIL_E_SUCCESS); // TODO: for vts
3518 return Void();
3519 }
3520
setSignalStrengthReportingCriteria(int32_t serial,int32_t hysteresisMs,int32_t hysteresisDb,const hidl_vec<int32_t> & thresholdsDbm,::android::hardware::radio::V1_2::AccessNetwork accessNetwork)3521 Return<void> RadioImpl_1_6::setSignalStrengthReportingCriteria(int32_t serial,
3522 int32_t hysteresisMs, int32_t hysteresisDb,
3523 const hidl_vec<int32_t>& thresholdsDbm,
3524 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork) {
3525 #if VDBG
3526 RLOGD("setSignalStrengthReportingCriteria: %d", serial);
3527 #endif
3528 RIL_Errno e;
3529 if (radioService[mSlotId]->mRadioResponseV1_2 != NULL) {
3530 RadioResponseInfo responseInfo = {};
3531 if (hysteresisDb >= 10) {
3532 e = RIL_E_INVALID_ARGUMENTS;
3533 } else {
3534 e = RIL_E_SUCCESS;
3535 }
3536 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, e);
3537 Return<void> retStatus =
3538 radioService[mSlotId]
3539 ->mRadioResponseV1_2->setSignalStrengthReportingCriteriaResponse(
3540 responseInfo);
3541 radioService[mSlotId]->checkReturnStatus(retStatus);
3542 } else {
3543 RLOGE("setSignalStrengthReportingCriteria: radioService[%d]->mRadioResponse == NULL",
3544 mSlotId);
3545 }
3546 return Void();
3547 }
3548
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)3549 Return<void> RadioImpl_1_6::setLinkCapacityReportingCriteria(int32_t serial,
3550 int32_t hysteresisMs, int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
3551 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
3552 const hidl_vec<int32_t>& thresholdsUplinkKbps,
3553 V1_2::AccessNetwork accessNetwork) {
3554 #if VDBG
3555 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3556 RLOGD("setLinkCapacityReportingCriteria: %d", serial);
3557 #endif
3558
3559 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3560 RIL_REQUEST_SET_LINK_CAPACITY_REPORTING_CRITERIA);
3561 if (pRI == NULL) {
3562 return Void();
3563 }
3564 // TODO: for vts. hysteresisDlKbps and hysteresisUlKbps range not confirmed
3565 if (hysteresisDlKbps >= 5000 || hysteresisUlKbps >= 1000) {
3566 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3567 return Void();
3568 } else {
3569 sendErrorResponse(pRI, RIL_E_SUCCESS);
3570 }
3571 return Void();
3572 }
3573
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)3574 Return<void> RadioImpl_1_6::setupDataCall_1_2(int32_t serial, V1_2::AccessNetwork accessNetwork,
3575 const V1_0::DataProfileInfo& dataProfileInfo, bool modemCognitive,
3576 bool roamingAllowed, bool isRoaming, V1_2::DataRequestReason reason,
3577 const hidl_vec<hidl_string>& addresses, const hidl_vec<hidl_string>& dnses) {
3578 #if VDBG
3579 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3580 RLOGD("setupDataCall_1_2: serial %d", serial);
3581 #endif
3582
3583 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
3584 const hidl_string &protocol =
3585 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
3586 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 7,
3587 std::to_string((int)accessNetwork).c_str(),
3588 std::to_string((int)dataProfileInfo.profileId).c_str(),
3589 dataProfileInfo.apn.c_str(),
3590 dataProfileInfo.user.c_str(),
3591 dataProfileInfo.password.c_str(),
3592 std::to_string((int)dataProfileInfo.authType).c_str(),
3593 protocol.c_str());
3594 } else if (s_vendorFunctions->version >= 15) {
3595 char *mvnoTypeStr = NULL;
3596 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
3597 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3598 RIL_REQUEST_SETUP_DATA_CALL);
3599 if (pRI != NULL) {
3600 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3601 }
3602 return Void();
3603 }
3604 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
3605 std::to_string((int)accessNetwork).c_str(),
3606 std::to_string((int)dataProfileInfo.profileId).c_str(),
3607 dataProfileInfo.apn.c_str(),
3608 dataProfileInfo.user.c_str(),
3609 dataProfileInfo.password.c_str(),
3610 std::to_string((int) dataProfileInfo.authType).c_str(),
3611 dataProfileInfo.protocol.c_str(),
3612 dataProfileInfo.roamingProtocol.c_str(),
3613 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
3614 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
3615 modemCognitive ? "1" : "0",
3616 std::to_string(dataProfileInfo.mtu).c_str(),
3617 mvnoTypeStr,
3618 dataProfileInfo.mvnoMatchData.c_str(),
3619 roamingAllowed ? "1" : "0");
3620 } else {
3621 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
3622 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3623 RIL_REQUEST_SETUP_DATA_CALL);
3624 if (pRI != NULL) {
3625 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
3626 }
3627 }
3628 return Void();
3629 }
3630
deactivateDataCall_1_2(int32_t serial,int32_t cid,::android::hardware::radio::V1_2::DataRequestReason reason)3631 Return<void> RadioImpl_1_6::deactivateDataCall_1_2(int32_t serial, int32_t cid,
3632 ::android::hardware::radio::V1_2::DataRequestReason reason) {
3633 #if VDBG
3634 RLOGD("deactivateDataCall_1_2: serial %d", serial);
3635 #endif
3636
3637 RIL_DataRequestReason dataRequestReason = (RIL_DataRequestReason)reason;
3638 const char *reasonStr = NULL;
3639 switch (dataRequestReason) {
3640 case DATA_REQ_REASOPN_NORMAL:
3641 reasonStr = "normal";
3642 break;
3643 case DATA_REQ_REASOPN_SHUTDOWN:
3644 reasonStr = "shutdown";
3645 break;
3646 case DATA_REQ_REASOPN_HANDOVER:
3647 reasonStr = "handover";
3648 break;
3649 default:
3650 reasonStr = "unknown";
3651 break;
3652 }
3653
3654 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, false,
3655 2, (std::to_string(cid)).c_str(), reasonStr);
3656 return Void();
3657 }
3658
3659 // Methods from ::android::hardware::radio::V1_3::IRadio follow.
setSystemSelectionChannels(int32_t serial,bool,const hidl_vec<::android::hardware::radio::V1_1::RadioAccessSpecifier> &)3660 Return<void> RadioImpl_1_6::setSystemSelectionChannels(int32_t serial, bool /* specifyChannels */,
3661 const hidl_vec<::android::hardware::radio::V1_1::RadioAccessSpecifier>& /* specifiers */) {
3662 #if VDBG
3663 RLOGD("setSystemSelectionChannels: serial %d", serial);
3664 #endif
3665 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS);
3666 return Void();
3667 }
3668
enableModem(int32_t serial,bool)3669 Return<void> RadioImpl_1_6::enableModem(int32_t serial, bool /* on */) {
3670 #if VDBG
3671 RLOGE("enableModem: serial = %d", serial);
3672 #endif
3673 dispatchVoid(serial, mSlotId, RIL_REQUEST_ENABLE_MODEM);
3674 return Void();
3675 }
3676
getModemStackStatus(int32_t serial)3677 Return<void> RadioImpl_1_6::getModemStackStatus(int32_t serial) {
3678 #if VDBG
3679 RLOGD("getModemStackStatus: serial %d", serial);
3680 #endif
3681 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MODEM_STACK_STATUS);
3682 return Void();
3683 }
3684
getProtocolString(const::android::hardware::radio::V1_4::PdpProtocolType protocolVal)3685 const char * getProtocolString(const ::android::hardware::radio::V1_4::PdpProtocolType protocolVal) {
3686 switch(protocolVal) {
3687 case ::android::hardware::radio::V1_4::PdpProtocolType::IP:
3688 return "IP";
3689 case ::android::hardware::radio::V1_4::PdpProtocolType::IPV6:
3690 return "IPV6";
3691 case ::android::hardware::radio::V1_4::PdpProtocolType::IPV4V6:
3692 return "IPV4V6";
3693 case ::android::hardware::radio::V1_4::PdpProtocolType::PPP:
3694 return "PPP";
3695 case ::android::hardware::radio::V1_4::PdpProtocolType::NON_IP:
3696 return "NON_IP";
3697 case ::android::hardware::radio::V1_4::PdpProtocolType::UNSTRUCTURED:
3698 return "UNSTRUCTURED";
3699 default:
3700 return "UNKNOWN";
3701 }
3702 }
3703
3704 // Methods from ::android::hardware::radio::V1_4::IRadio follow.
setAllowedCarriers_1_4(int32_t serial,const V1_4::CarrierRestrictionsWithPriority & carriers,V1_4::SimLockMultiSimPolicy multiSimPolicy)3705 Return<void> RadioImpl_1_6::setAllowedCarriers_1_4(int32_t serial,
3706 const V1_4::CarrierRestrictionsWithPriority& carriers,
3707 V1_4::SimLockMultiSimPolicy multiSimPolicy) {
3708 #if VDBG
3709 RLOGD("setAllowedCarriers_1_4: serial %d", serial);
3710 #endif
3711
3712 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3713 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
3714 if (pRI == NULL) {
3715 return Void();
3716 }
3717
3718 // Prepare legacy structure (defined in IRadio 1.0) to re-use existing code.
3719 RIL_CarrierRestrictions cr = {};
3720 if (prepareCarrierRestrictions(cr, false, carriers.allowedCarriers, carriers.excludedCarriers,
3721 pRI) < 0) {
3722 return Void();
3723 }
3724 // Copy the legacy structure into the new structure (defined in IRadio 1.4)
3725 RIL_CarrierRestrictionsWithPriority crExt = {};
3726 crExt.len_allowed_carriers = cr.len_allowed_carriers;
3727 crExt.allowed_carriers = cr.allowed_carriers;
3728 crExt.len_excluded_carriers = cr.len_excluded_carriers;
3729 crExt.excluded_carriers = cr.excluded_carriers;
3730 crExt.allowedCarriersPrioritized = BOOL_TO_INT(carriers.allowedCarriersPrioritized);
3731 crExt.multiSimPolicy = (RIL_SimLockMultiSimPolicy)multiSimPolicy;
3732
3733 CALL_ONREQUEST(pRI->pCI->requestNumber, &crExt, sizeof(RIL_CarrierRestrictionsWithPriority),
3734 pRI, mSlotId);
3735
3736 freeCarrierRestrictions(cr);
3737
3738 return Void();
3739 }
3740
getAllowedCarriers_1_4(int32_t serial)3741 Return<void> RadioImpl_1_6::getAllowedCarriers_1_4(int32_t serial) {
3742 #if VDBG
3743 RLOGD("getAllowedCarriers_1_4: serial %d", serial);
3744 #endif
3745 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
3746 return Void();
3747 }
3748
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> &)3749 Return<void> RadioImpl_1_6::setupDataCall_1_4(int32_t serial ,
3750 ::android::hardware::radio::V1_4::AccessNetwork /* accessNetwork */,
3751 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo,
3752 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
3753 const hidl_vec<hidl_string>& /* addresses */, const hidl_vec<hidl_string>& /* dnses */) {
3754
3755 #if VDBG
3756 RLOGD("setupDataCall_1_4: serial %d", serial);
3757 #endif
3758
3759 char *mvnoTypeStr = NULL;
3760 if (!convertMvnoTypeToString(MvnoType::IMSI, mvnoTypeStr)) {
3761 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3762 RIL_REQUEST_SETUP_DATA_CALL);
3763 if (pRI != NULL) {
3764 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3765 }
3766 return Void();
3767 }
3768 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 16,
3769 std::to_string((int) RadioTechnology::UNKNOWN + 2).c_str(),
3770 std::to_string((int) dataProfileInfo.profileId).c_str(),
3771 dataProfileInfo.apn.c_str(),
3772 dataProfileInfo.user.c_str(),
3773 dataProfileInfo.password.c_str(),
3774 std::to_string((int) dataProfileInfo.authType).c_str(),
3775 getProtocolString(dataProfileInfo.protocol),
3776 getProtocolString(dataProfileInfo.roamingProtocol),
3777 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
3778 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
3779 dataProfileInfo.persistent ? "1" : "0",
3780 std::to_string(dataProfileInfo.mtu).c_str(),
3781 mvnoTypeStr,
3782 "302720x94",
3783 roamingAllowed ? "1" : "0",
3784 "-1");
3785 return Void();
3786 }
3787
setInitialAttachApn_1_4(int32_t serial,const::android::hardware::radio::V1_4::DataProfileInfo & dataProfileInfo)3788 Return<void> RadioImpl_1_6::setInitialAttachApn_1_4(int32_t serial ,
3789 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo) {
3790 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3791 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
3792 if (pRI == NULL) {
3793 return Void();
3794 }
3795
3796 RadioResponseInfo responseInfo = {};
3797 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
3798
3799 if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
3800 Return<void> retStatus
3801 = radioService[mSlotId]->mRadioResponseV1_4->setInitialAttachApnResponse(responseInfo);
3802 radioService[mSlotId]->checkReturnStatus(retStatus);
3803 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
3804 Return<void> retStatus
3805 = radioService[mSlotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
3806 radioService[mSlotId]->checkReturnStatus(retStatus);
3807 } else {
3808 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
3809 }
3810
3811 return Void();
3812 }
3813
setDataProfile_1_4(int32_t serial,const hidl_vec<::android::hardware::radio::V1_4::DataProfileInfo> &)3814 Return<void> RadioImpl_1_6::setDataProfile_1_4(int32_t serial ,
3815 const hidl_vec<::android::hardware::radio::V1_4::DataProfileInfo>& /* profiles */) {
3816 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3817 RIL_REQUEST_SET_DATA_PROFILE);
3818 if (pRI == NULL) {
3819 return Void();
3820 }
3821
3822 RadioResponseInfo responseInfo = {};
3823 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
3824
3825 if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
3826 Return<void> retStatus
3827 = radioService[mSlotId]->mRadioResponseV1_4->setDataProfileResponse(responseInfo);
3828 radioService[mSlotId]->checkReturnStatus(retStatus);
3829 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
3830 Return<void> retStatus
3831 = radioService[mSlotId]->mRadioResponse->setDataProfileResponse(responseInfo);
3832 radioService[mSlotId]->checkReturnStatus(retStatus);
3833 } else {
3834 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
3835 }
3836
3837 return Void();
3838 }
3839
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)3840 Return<void> RadioImpl_1_6::emergencyDial(int32_t serial,
3841 const ::android::hardware::radio::V1_0::Dial& dialInfo,
3842 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
3843 const hidl_vec<hidl_string>& urns ,
3844 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
3845 bool fromEmergencyDialer, bool /* isTesting */) {
3846 #if VDBG
3847 RLOGD("emergencyDial: serial %d", serial);
3848 #endif
3849
3850 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_EMERGENCY_DIAL);
3851 if (pRI == NULL) {
3852 return Void();
3853 }
3854
3855 RIL_EmergencyDial eccDial = {};
3856 RIL_Dial& dial = eccDial.dialInfo;
3857 RIL_UUS_Info uusInfo = {};
3858
3859 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
3860 return Void();
3861 }
3862 dial.clir = (int) dialInfo.clir;
3863
3864 if (dialInfo.uusInfo.size() != 0) {
3865 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
3866 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
3867
3868 if (dialInfo.uusInfo[0].uusData.size() == 0) {
3869 uusInfo.uusData = NULL;
3870 uusInfo.uusLength = 0;
3871 } else {
3872 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
3873 memsetAndFreeStrings(1, dial.address);
3874 return Void();
3875 }
3876 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
3877 }
3878
3879 dial.uusInfo = &uusInfo;
3880 }
3881
3882 eccDial.urnsNumber = urns.size();
3883 if (eccDial.urnsNumber != 0) {
3884 char **ppUrns = (char **)calloc(eccDial.urnsNumber, sizeof(char *));
3885 if (ppUrns == NULL) {
3886 RLOGE("Memory allocation failed for request %s",
3887 requestToString(pRI->pCI->requestNumber));
3888 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
3889 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
3890 return Void();
3891 }
3892 for (uint32_t i = 0; i < eccDial.urnsNumber; i++) {
3893 if (!copyHidlStringToRil(&ppUrns[i], hidl_string(urns[i]), pRI)) {
3894 for (uint32_t j = 0; j < i; j++) {
3895 memsetAndFreeStrings(1, ppUrns[j]);
3896 }
3897 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
3898 free(ppUrns);
3899 return Void();
3900 }
3901 }
3902 eccDial.urns = ppUrns;
3903 }
3904
3905 eccDial.categories = (RIL_EmergencyServiceCategory)categories;
3906 eccDial.routing = (RIL_EmergencyCallRouting)routing;
3907 eccDial.fromEmergencyDialer = fromEmergencyDialer;
3908
3909 CALL_ONREQUEST(RIL_REQUEST_EMERGENCY_DIAL, &eccDial, sizeof(RIL_EmergencyDial), pRI, mSlotId);
3910
3911 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
3912 if (eccDial.urns != NULL) {
3913 for (size_t i = 0; i < eccDial.urnsNumber; i++) {
3914 memsetAndFreeStrings(1, eccDial.urns[i]);
3915 }
3916 free(eccDial.urns);
3917 }
3918 return Void();
3919 }
3920
startNetworkScan_1_4(int32_t serial,const::android::hardware::radio::V1_2::NetworkScanRequest & request)3921 Return<void> RadioImpl_1_6::startNetworkScan_1_4(int32_t serial,
3922 const ::android::hardware::radio::V1_2::NetworkScanRequest& request) {
3923 #if VDBG
3924 RLOGD("startNetworkScan_1_4: serial %d", serial);
3925 #endif
3926
3927 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
3928 if (pRI == NULL) {
3929 return Void();
3930 }
3931
3932 RIL_NetworkScanRequest scan_request = {};
3933
3934 if (prepareNetworkScanRequest_1_2(scan_request, request, pRI) < 0) {
3935 return Void();
3936 }
3937
3938 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
3939 mSlotId);
3940
3941 return Void();
3942 }
3943
getPreferredNetworkTypeBitmap(int32_t serial)3944 Return<void> RadioImpl_1_6::getPreferredNetworkTypeBitmap(int32_t serial ) {
3945 #if VDBG
3946 RLOGD("getPreferredNetworkTypeBitmap: serial %d", serial);
3947 #endif
3948 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE_BITMAP);
3949 return Void();
3950 }
3951
setPreferredNetworkTypeBitmap(int32_t serial,hidl_bitfield<RadioAccessFamily> networkTypeBitmap)3952 Return<void> RadioImpl_1_6::setPreferredNetworkTypeBitmap(
3953 int32_t serial, hidl_bitfield<RadioAccessFamily> networkTypeBitmap) {
3954 #if VDBG
3955 RLOGD("setPreferredNetworkTypeBitmap: serial %d", serial);
3956 #endif
3957 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE_BITMAP, 1, networkTypeBitmap);
3958 return Void();
3959 }
3960
setAllowedNetworkTypesBitmap(uint32_t serial,hidl_bitfield<RadioAccessFamily> networkTypeBitmap)3961 Return<void> RadioImpl_1_6::setAllowedNetworkTypesBitmap(
3962 uint32_t serial, hidl_bitfield<RadioAccessFamily> networkTypeBitmap) {
3963 #if VDBG
3964 RLOGD("setAllowedNetworkTypesBitmap: serial %d", serial);
3965 #endif
3966 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_ALLOWED_NETWORK_TYPES_BITMAP, 1, networkTypeBitmap);
3967 return Void();
3968 }
3969
getAllowedNetworkTypesBitmap(int32_t serial)3970 Return<void> RadioImpl_1_6::getAllowedNetworkTypesBitmap(int32_t serial) {
3971 #if VDBG
3972 RLOGD("getAllowedNetworkTypesBitmap: serial %d", serial);
3973 #endif
3974 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ALLOWED_NETWORK_TYPES_BITMAP);
3975 return Void();
3976 }
3977
getSignalStrength_1_4(int32_t serial)3978 Return<void> RadioImpl_1_6::getSignalStrength_1_4(int32_t serial) {
3979 #if VDBG
3980 RLOGD("getSignalStrength_1_4: serial %d", serial);
3981 #endif
3982 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
3983 return Void();
3984 }
3985
getSignalStrength_1_6(int32_t serial)3986 Return<void> RadioImpl_1_6::getSignalStrength_1_6(int32_t serial) {
3987 #if VDBG
3988 RLOGD("getSignalStrength_1_6: serial %d", serial);
3989 #endif
3990 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
3991 return Void();
3992 }
3993
3994 // Methods from ::android::hardware::radio::V1_5::IRadio follow.
setSignalStrengthReportingCriteria_1_5(int32_t serial,const V1_5::SignalThresholdInfo & signalThresholdInfo,V1_5::AccessNetwork accessNetwork)3995 Return<void> RadioImpl_1_6::setSignalStrengthReportingCriteria_1_5(int32_t serial,
3996 const V1_5::SignalThresholdInfo& signalThresholdInfo,
3997 V1_5::AccessNetwork accessNetwork) {
3998 #if VDBG
3999 RLOGD("setSignalStrengthReportingCriteria_1_5: %d", serial);
4000 #endif
4001
4002 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4003 RIL_REQUEST_SET_SIGNAL_STRENGTH_REPORTING_CRITERIA);
4004 if (pRI == NULL) {
4005 return Void();
4006 }
4007
4008 if (signalThresholdInfo.hysteresisDb >= 10) { // TODO: for vts. hysteresisDb range not checked
4009 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4010 return Void();
4011 }
4012
4013 RIL_SignalStrengthReportingCriteria_v1_5 *criteria = (RIL_SignalStrengthReportingCriteria_v1_5 *)
4014 calloc(1, sizeof(RIL_SignalStrengthReportingCriteria_v1_5));
4015 if (criteria == NULL) {
4016 RLOGE("Memory allocation failed for request %s",
4017 requestToString(pRI->pCI->requestNumber));
4018 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4019 return Void();
4020 }
4021
4022 criteria->signalMeasurement = (SignalMeasurementType)signalThresholdInfo.signalMeasurement;
4023 criteria->isEnabled = signalThresholdInfo.isEnabled;
4024 criteria->hysteresisMs = signalThresholdInfo.hysteresisMs;
4025 criteria->hysteresisDb = signalThresholdInfo.hysteresisDb;
4026 criteria->thresholdsDbmNumber = signalThresholdInfo.thresholds.size();
4027 criteria->thresholdsDbm = new int32_t[criteria->thresholdsDbmNumber];
4028 memcpy(criteria->thresholdsDbm, signalThresholdInfo.thresholds.data(),
4029 criteria->thresholdsDbmNumber * sizeof(int32_t));
4030 criteria->accessNetwork = (RIL_RadioAccessNetworks_v1_5)accessNetwork;
4031
4032 CALL_ONREQUEST(pRI->pCI->requestNumber, criteria,
4033 sizeof(RIL_SignalStrengthReportingCriteria_v1_5), pRI, mSlotId);
4034
4035 return Void();
4036 }
4037
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)4038 Return<void> RadioImpl_1_6::setLinkCapacityReportingCriteria_1_5(int32_t serial,
4039 int32_t hysteresisMs, int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
4040 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
4041 const hidl_vec<int32_t>& thresholdsUplinkKbps,
4042 V1_5::AccessNetwork accessNetwork) {
4043 #if VDBG
4044 RLOGD("setLinkCapacityReportingCriteria_1_5: %d", serial);
4045 #endif
4046
4047 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4048 RIL_REQUEST_SET_LINK_CAPACITY_REPORTING_CRITERIA);
4049 if (pRI == NULL) {
4050 return Void();
4051 }
4052 // TODO: for vts. hysteresisDlKbps and hysteresisUlKbps range not confirmed
4053 if (hysteresisDlKbps >= 5000 || hysteresisUlKbps >= 1000) {
4054 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4055 return Void();
4056 }
4057
4058 RIL_LinkCapacityReportingCriteria *criteria = (RIL_LinkCapacityReportingCriteria *)
4059 calloc(1, sizeof(RIL_LinkCapacityReportingCriteria));
4060 if (criteria == NULL) {
4061 RLOGE("Memory allocation failed for request %s",
4062 requestToString(pRI->pCI->requestNumber));
4063 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4064 return Void();
4065 }
4066
4067 criteria->hysteresisMs = hysteresisMs;
4068 criteria->hysteresisDlKbps = hysteresisDlKbps;
4069 criteria->hysteresisUlKbps = hysteresisUlKbps;
4070 criteria->thresholdsDownlinkKbpsLength = thresholdsDownlinkKbps.size();
4071 criteria->thresholdsUplinkKbpsLength = thresholdsUplinkKbps.size();
4072 criteria->thresholdsDownlinkKbps = new int32_t[criteria->thresholdsDownlinkKbpsLength];
4073 criteria->thresholdsUplinkKbps = new int32_t[criteria->thresholdsUplinkKbpsLength];
4074 memcpy(criteria->thresholdsDownlinkKbps, thresholdsDownlinkKbps.data(),
4075 criteria->thresholdsDownlinkKbpsLength * sizeof(int32_t));
4076 memcpy(criteria->thresholdsUplinkKbps, thresholdsUplinkKbps.data(),
4077 criteria->thresholdsUplinkKbpsLength * sizeof(int32_t));
4078 criteria->accessNetwork = (RIL_RadioAccessNetworks_v1_5)accessNetwork;
4079
4080 CALL_ONREQUEST(pRI->pCI->requestNumber, criteria,
4081 sizeof(RIL_LinkCapacityReportingCriteria), pRI, pRI->socket_id);
4082
4083 return Void();
4084 }
4085
enableUiccApplications(int32_t serial,bool enable)4086 Return<void> RadioImpl_1_6::enableUiccApplications(int32_t serial, bool enable) {
4087 #if VDBG
4088 RLOGD("enableUiccApplications: serial %d enable %d", serial, enable);
4089 #endif
4090 dispatchInts(serial, mSlotId, RIL_REQUEST_ENABLE_UICC_APPLICATIONS, 1, BOOL_TO_INT(enable));
4091 return Void();
4092 }
4093
setRadioPower_1_5(int32_t serial,bool powerOn,bool forEmergencyCall,bool preferredForEmergencyCall)4094 Return<void> RadioImpl_1_6::setRadioPower_1_5(int32_t serial, bool powerOn, bool forEmergencyCall,
4095 bool preferredForEmergencyCall) {
4096 #if VDBG
4097 RLOGD("setRadioPower_1_6: serial %d powerOn %d forEmergency %d preferredForEmergencyCall %d",
4098 serial, powerOn, forEmergencyCall, preferredForEmergencyCall);
4099 #endif
4100 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(powerOn));
4101 return Void();
4102 }
4103
setRadioPower_1_6(int32_t serial,bool powerOn,bool forEmergencyCall,bool preferredForEmergencyCall)4104 Return<void> RadioImpl_1_6::setRadioPower_1_6(int32_t serial, bool powerOn, bool forEmergencyCall,
4105 bool preferredForEmergencyCall) {
4106 #if VDBG
4107 RLOGD("setRadioPower_1_6: serial %d powerOn %d forEmergency %d preferredForEmergencyCall %d",
4108 serial, powerOn, forEmergencyCall, preferredForEmergencyCall);
4109 #endif
4110 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(powerOn));
4111 return Void();
4112 }
4113
areUiccApplicationsEnabled(int32_t serial)4114 Return<void> RadioImpl_1_6::areUiccApplicationsEnabled(int32_t serial) {
4115 #if VDBG
4116 RLOGD("areUiccApplicationsEnabled: serial %d", serial);
4117 #endif
4118 dispatchVoid(serial, mSlotId, RIL_REQUEST_ARE_UICC_APPLICATIONS_ENABLED);
4119 return Void();
4120 }
4121
getVoiceRegistrationState_1_5(int32_t serial)4122 Return<void> RadioImpl_1_6::getVoiceRegistrationState_1_5(int32_t serial) {
4123 #if VDBG
4124 RLOGD("getVoiceRegistrationState_1_5: serial %d", serial);
4125 #endif
4126 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
4127 return Void();
4128 }
4129
getDataRegistrationState_1_5(int32_t serial)4130 Return<void> RadioImpl_1_6::getDataRegistrationState_1_5(int32_t serial) {
4131 #if VDBG
4132 RLOGD("getDataRegistrationState_1_5: serial %d", serial);
4133 #endif
4134 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
4135 return Void();
4136 }
4137
getVoiceRegistrationState_1_6(int32_t serial)4138 Return<void> RadioImpl_1_6::getVoiceRegistrationState_1_6(int32_t serial) {
4139 #if VDBG
4140 RLOGD("getVoiceRegistrationState_1_6: serial %d", serial);
4141 #endif
4142 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
4143 return Void();
4144 }
4145
getDataRegistrationState_1_6(int32_t serial)4146 Return<void> RadioImpl_1_6::getDataRegistrationState_1_6(int32_t serial) {
4147 #if VDBG
4148 RLOGD("getDataRegistrationState_1_6: serial %d", serial);
4149 #endif
4150 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
4151 return Void();
4152 }
4153
setSystemSelectionChannels_1_5(int32_t serial,bool specifyChannels,const hidl_vec<V1_5::RadioAccessSpecifier> & specifiers)4154 Return<void> RadioImpl_1_6::setSystemSelectionChannels_1_5(int32_t serial,
4155 bool specifyChannels, const hidl_vec<V1_5::RadioAccessSpecifier>& specifiers) {
4156
4157 #if VDBG
4158 RLOGD("setSystemSelectionChannels_1_5: %d", serial);
4159 #endif
4160
4161 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4162 RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS);
4163 if (pRI == NULL) {
4164 return Void();
4165 }
4166
4167 if (specifiers.size() > RIL_RADIO_ACCESS_SPECIFIER_MAX_SIZE) {
4168 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4169 return Void();
4170 }
4171
4172 RIL_SystemSelectionChannels_v1_5 *sysSelectionChannels =
4173 (RIL_SystemSelectionChannels_v1_5 *)calloc(1, sizeof(RIL_SystemSelectionChannels_v1_5));
4174 if (sysSelectionChannels == NULL) {
4175 RLOGE("Memory allocation failed for request %s",
4176 requestToString(pRI->pCI->requestNumber));
4177 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4178 return Void();
4179 }
4180 sysSelectionChannels->specifyChannels = specifyChannels;
4181 sysSelectionChannels->specifiers_length = specifiers.size();
4182 for (size_t i = 0; i < specifiers.size(); ++i) {
4183 const V1_5::RadioAccessSpecifier& ras_from = specifiers[i];
4184 RIL_RadioAccessSpecifier_v1_5 &ras_to = sysSelectionChannels->specifiers[i];
4185
4186 ras_to.radio_access_network = (RIL_RadioAccessNetworks_v1_5)ras_from.radioAccessNetwork;
4187 ras_to.channels_length = ras_from.channels.size();
4188
4189 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
4190 const std::vector<uint32_t> * bands = nullptr;
4191 switch (specifiers[i].radioAccessNetwork) {
4192 case V1_5::RadioAccessNetworks::GERAN:
4193 ras_to.bands_length = ras_from.bands.geranBands().size();
4194 bands = (std::vector<uint32_t> *) &ras_from.bands.geranBands();
4195 break;
4196 case V1_5::RadioAccessNetworks::UTRAN:
4197 ras_to.bands_length = ras_from.bands.utranBands().size();
4198 bands = (std::vector<uint32_t> *) &ras_from.bands.utranBands();
4199 break;
4200 case V1_5::RadioAccessNetworks::EUTRAN:
4201 ras_to.bands_length = ras_from.bands.eutranBands().size();
4202 bands = (std::vector<uint32_t> *) &ras_from.bands.eutranBands();
4203 break;
4204 case V1_5::RadioAccessNetworks::NGRAN:
4205 ras_to.bands_length = ras_from.bands.ngranBands().size();
4206 bands = (std::vector<uint32_t> *) &ras_from.bands.ngranBands();
4207 break;
4208 default: {
4209 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4210 free(sysSelectionChannels);
4211 return Void();
4212 }
4213 }
4214 // safe to copy to geran_bands because it's a union member
4215 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4216 ras_to.bands.geran_bands[idx] = (RIL_GeranBands)(*bands)[idx];
4217 }
4218 }
4219
4220 CALL_ONREQUEST(RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS, sysSelectionChannels,
4221 sizeof(RIL_SystemSelectionChannels_v1_5), pRI, mSlotId);
4222
4223 return Void();
4224 }
4225
prepareNetworkScanRequest_1_5(RIL_NetworkScanRequest_v1_5 & scan_request,const V1_5::NetworkScanRequest & request,RequestInfo * pRI)4226 int prepareNetworkScanRequest_1_5(RIL_NetworkScanRequest_v1_5 &scan_request,
4227 const V1_5::NetworkScanRequest& request, RequestInfo *pRI) {
4228 scan_request.type = (RIL_ScanType) request.type;
4229 scan_request.interval = request.interval;
4230 scan_request.specifiers_length = request.specifiers.size();
4231 scan_request.maxSearchTime = request.maxSearchTime;
4232 scan_request.incrementalResults = request.incrementalResults;
4233 scan_request.incrementalResultsPeriodicity = request.incrementalResultsPeriodicity;
4234 scan_request.mccMncsNumbers = request.mccMncs.size();
4235
4236 int intervalLow = static_cast<int>(V1_2::ScanIntervalRange::MIN);
4237 int intervalHigh = static_cast<int>(V1_2::ScanIntervalRange::MAX);
4238 int maxSearchTimeLow = static_cast<int>(V1_2::MaxSearchTimeRange::MIN);
4239 int maxSearchTimeHigh = static_cast<int>(V1_2::MaxSearchTimeRange::MAX);
4240 int incrementalResultsPeriodicityRangeLow =
4241 static_cast<int>(V1_2::IncrementalResultsPeriodicityRange::MIN);
4242 int incrementalResultsPeriodicityRangeHigh =
4243 static_cast<int>(V1_2::IncrementalResultsPeriodicityRange::MAX);
4244 uint maxSpecifierSize = static_cast<uint>(V1_2::RadioConst::RADIO_ACCESS_SPECIFIER_MAX_SIZE);
4245
4246 if (request.interval < intervalLow || request.interval > intervalHigh) {
4247 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4248 return -1;
4249 }
4250 // If defined, must fall in correct range.
4251 if (request.maxSearchTime != 0 && (request.maxSearchTime < maxSearchTimeLow
4252 || request.maxSearchTime > maxSearchTimeHigh)) {
4253 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4254 return -1;
4255 }
4256 if (request.maxSearchTime != 0
4257 && (request.incrementalResultsPeriodicity < incrementalResultsPeriodicityRangeLow
4258 || request.incrementalResultsPeriodicity > incrementalResultsPeriodicityRangeHigh
4259 || request.incrementalResultsPeriodicity > request.maxSearchTime)) {
4260 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4261 return -1;
4262 }
4263 if (request.specifiers.size() == 0 || request.specifiers.size() > maxSpecifierSize) {
4264 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4265 return -1;
4266 }
4267
4268 for (size_t i = 0; i < request.specifiers.size(); ++i) {
4269 if (request.specifiers[i].channels.size() > MAX_CHANNELS) {
4270 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4271 return -1;
4272 }
4273 switch (request.specifiers[i].bands.getDiscriminator()) {
4274 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::geranBands:
4275 if (request.specifiers[i].bands.geranBands().size() > MAX_BANDS) {
4276 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4277 return -1;
4278 }
4279 break;
4280 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::utranBands:
4281 if (request.specifiers[i].bands.utranBands().size() > MAX_BANDS) {
4282 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4283 return -1;
4284 }
4285 break;
4286 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::eutranBands:
4287 if (request.specifiers[i].bands.eutranBands().size() > MAX_BANDS) {
4288 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4289 return -1;
4290 }
4291 break;
4292 case V1_5::RadioAccessSpecifier::Bands::hidl_discriminator::ngranBands:
4293 if (request.specifiers[i].bands.ngranBands().size() > MAX_BANDS) {
4294 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4295 return -1;
4296 }
4297 break;
4298 default:
4299 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4300 return -1;
4301 }
4302
4303 if (request.specifiers[i].channels.size() > MAX_CHANNELS) {
4304 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4305 return -1;
4306 }
4307
4308 const V1_5::RadioAccessSpecifier& ras_from = request.specifiers[i];
4309 RIL_RadioAccessSpecifier_v1_5& ras_to = scan_request.specifiers[i];
4310
4311 ras_to.radio_access_network = (RIL_RadioAccessNetworks_v1_5) ras_from.radioAccessNetwork;
4312 ras_to.channels_length = ras_from.channels.size();
4313
4314 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
4315 switch (request.specifiers[i].radioAccessNetwork) {
4316 case V1_5::RadioAccessNetworks::GERAN: {
4317 hidl_vec<V1_1::GeranBands> geranBands = ras_from.bands.geranBands();
4318 ras_to.bands_length = MIN(geranBands.size(), MAX_BANDS);
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] =
4322 static_cast<RIL_GeranBands>(geranBands[idx]);
4323 }
4324 break;
4325 }
4326 case V1_5::RadioAccessNetworks::UTRAN: {
4327 hidl_vec<V1_5::UtranBands> utranBands = ras_from.bands.utranBands();
4328 ras_to.bands_length = MIN(utranBands.size(), MAX_BANDS);
4329 // safe to copy to utran_bands because it's a union member
4330 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4331 ras_to.bands.utran_bands[idx] =
4332 static_cast<RIL_UtranBands>(utranBands[idx]);
4333 }
4334 break;
4335 }
4336 case V1_5::RadioAccessNetworks::EUTRAN: {
4337 hidl_vec<V1_5::EutranBands> eutranBands = ras_from.bands.eutranBands();
4338 ras_to.bands_length = MIN(eutranBands.size(), MAX_BANDS);
4339 // safe to copy to eutran_bands because it's a union member
4340 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4341 ras_to.bands.eutran_bands[idx] =
4342 static_cast<RIL_EutranBands>(eutranBands[idx]);
4343 }
4344 break;
4345 }
4346 case V1_5::RadioAccessNetworks::NGRAN: {
4347 hidl_vec<V1_5::NgranBands> ngranBands = ras_from.bands.ngranBands();
4348 ras_to.bands_length = MIN(ngranBands.size(), MAX_BANDS);
4349 // safe to copy to ngran_bands because it's a union member
4350 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
4351 ras_to.bands.ngran_bands[idx] =
4352 static_cast<RIL_NgranBands>(ngranBands[idx]);
4353 }
4354 break;
4355 }
4356 default:
4357 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4358 return -1;
4359 }
4360 }
4361 if (scan_request.mccMncsNumbers != 0) {
4362 char **pStrings = (char **)calloc(scan_request.mccMncsNumbers, sizeof(char *));
4363 if (pStrings == NULL) {
4364 RLOGE("Memory allocation failed for request %s",
4365 requestToString(pRI->pCI->requestNumber));
4366 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
4367 return -1;
4368 }
4369 for (size_t i = 0; i < request.mccMncs.size(); ++i) {
4370 if (!copyHidlStringToRil(&pStrings[i], hidl_string(request.mccMncs[i]), pRI)) {
4371 for (size_t j = 0; j < i; j++) {
4372 memsetAndFreeStrings(1, pStrings[j]);
4373 }
4374 free(pStrings);
4375 return -1;
4376 }
4377 }
4378 scan_request.mccMncs = pStrings;
4379 }
4380 return 0;
4381 }
4382
startNetworkScan_1_5(int32_t serial,const::android::hardware::radio::V1_5::NetworkScanRequest & request)4383 Return<void> RadioImpl_1_6::startNetworkScan_1_5(int32_t serial,
4384 const ::android::hardware::radio::V1_5::NetworkScanRequest& request) {
4385 #if VDBG
4386 RLOGD("startNetworkScan_1_6: serial %d", serial);
4387 #endif
4388
4389 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
4390 if (pRI == NULL) {
4391 return Void();
4392 }
4393
4394 RIL_NetworkScanRequest_v1_5 scan_request = {};
4395
4396 if (prepareNetworkScanRequest_1_5(scan_request, request, pRI) < 0) {
4397 return Void();
4398 }
4399
4400 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
4401 mSlotId);
4402
4403 return Void();
4404 }
4405
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> &)4406 Return<void> RadioImpl_1_6::setupDataCall_1_5(int32_t serial ,
4407 ::android::hardware::radio::V1_5::AccessNetwork /* accessNetwork */,
4408 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
4409 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
4410 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& /* addresses */,
4411 const hidl_vec<hidl_string>& /* dnses */) {
4412
4413 #if VDBG
4414 RLOGD("setupDataCall_1_5: serial %d", serial);
4415 #endif
4416
4417 char *mvnoTypeStr = NULL;
4418 if (!convertMvnoTypeToString(MvnoType::IMSI, mvnoTypeStr)) {
4419 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4420 RIL_REQUEST_SETUP_DATA_CALL);
4421 if (pRI != NULL) {
4422 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4423 }
4424 return Void();
4425 }
4426 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
4427 std::to_string((int) RadioTechnology::UNKNOWN + 2).c_str(),
4428 std::to_string((int) dataProfileInfo.profileId).c_str(),
4429 dataProfileInfo.apn.c_str(),
4430 dataProfileInfo.user.c_str(),
4431 dataProfileInfo.password.c_str(),
4432 std::to_string((int) dataProfileInfo.authType).c_str(),
4433 getProtocolString(dataProfileInfo.protocol),
4434 getProtocolString(dataProfileInfo.roamingProtocol),
4435 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
4436 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
4437 dataProfileInfo.persistent ? "1" : "0",
4438 std::to_string(dataProfileInfo.mtuV4).c_str(),
4439 std::to_string(dataProfileInfo.mtuV6).c_str(),
4440 mvnoTypeStr,
4441 "302720x94",
4442 roamingAllowed ? "1" : "0");
4443 return Void();
4444 }
4445
setupDataCall_1_6(int32_t serial,::android::hardware::radio::V1_5::AccessNetwork,const::android::hardware::radio::V1_5::DataProfileInfo & dataProfileInfo,bool roamingAllowed,::android::hardware::radio::V1_2::DataRequestReason,const hidl_vec<::android::hardware::radio::V1_5::LinkAddress> &,const hidl_vec<hidl_string> &,int32_t,const::android::hardware::radio::V1_6::OptionalSliceInfo &,const::android::hardware::radio::V1_6::OptionalTrafficDescriptor & trafficDescriptor,bool matchAllRuleAllowed)4446 Return<void> RadioImpl_1_6::setupDataCall_1_6(
4447 int32_t serial, ::android::hardware::radio::V1_5::AccessNetwork /* accessNetwork */,
4448 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
4449 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
4450 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& /* addresses */,
4451 const hidl_vec<hidl_string>& /* dnses */, int32_t /* pduSessionId */,
4452 const ::android::hardware::radio::V1_6::OptionalSliceInfo& /* sliceInfo */,
4453 const ::android::hardware::radio::V1_6::OptionalTrafficDescriptor& trafficDescriptor,
4454 bool matchAllRuleAllowed) {
4455 #if VDBG
4456 RLOGD("setupDataCall_1_6: serial %d", serial);
4457 #endif
4458
4459 char *mvnoTypeStr = NULL;
4460 if (!convertMvnoTypeToString(MvnoType::IMSI, mvnoTypeStr)) {
4461 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4462 RIL_REQUEST_SETUP_DATA_CALL);
4463 if (pRI != NULL) {
4464 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
4465 }
4466 return Void();
4467 }
4468
4469 if (trafficDescriptor.getDiscriminator() ==
4470 V1_6::OptionalTrafficDescriptor::hidl_discriminator::value &&
4471 trafficDescriptor.value().osAppId.getDiscriminator() ==
4472 V1_6::OptionalOsAppId::hidl_discriminator::value) {
4473 osAppIdVec = trafficDescriptor.value().osAppId.value().osAppId;
4474 } else {
4475 osAppIdVec = {};
4476 }
4477
4478 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 16,
4479 std::to_string((int) RadioTechnology::UNKNOWN + 2).c_str(),
4480 std::to_string((int) dataProfileInfo.profileId).c_str(),
4481 dataProfileInfo.apn.c_str(),
4482 dataProfileInfo.user.c_str(),
4483 dataProfileInfo.password.c_str(),
4484 std::to_string((int) dataProfileInfo.authType).c_str(),
4485 getProtocolString(dataProfileInfo.protocol),
4486 getProtocolString(dataProfileInfo.roamingProtocol),
4487 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
4488 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
4489 dataProfileInfo.persistent ? "1" : "0",
4490 std::to_string(dataProfileInfo.mtuV4).c_str(),
4491 std::to_string(dataProfileInfo.mtuV6).c_str(),
4492 mvnoTypeStr,
4493 "302720x94",
4494 roamingAllowed ? "1" : "0");
4495 return Void();
4496 }
4497
setInitialAttachApn_1_5(int32_t serial,const::android::hardware::radio::V1_5::DataProfileInfo & dataProfileInfo)4498 Return<void> RadioImpl_1_6::setInitialAttachApn_1_5(int32_t serial ,
4499 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo) {
4500 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4501 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
4502 if (pRI == NULL) {
4503 return Void();
4504 }
4505
4506 RadioResponseInfo responseInfo = {};
4507 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
4508
4509 if (radioService[mSlotId]->mRadioResponseV1_5 != NULL) {
4510 Return<void> retStatus =
4511 radioService[mSlotId]->mRadioResponseV1_5->setInitialAttachApnResponse_1_5(
4512 responseInfo);
4513 } else if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
4514 Return<void> retStatus
4515 = radioService[mSlotId]->mRadioResponseV1_4->setInitialAttachApnResponse(responseInfo);
4516 radioService[mSlotId]->checkReturnStatus(retStatus);
4517 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
4518 Return<void> retStatus
4519 = radioService[mSlotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
4520 radioService[mSlotId]->checkReturnStatus(retStatus);
4521 } else {
4522 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
4523 }
4524
4525 return Void();
4526 }
4527
setDataProfile_1_5(int32_t serial,const hidl_vec<::android::hardware::radio::V1_5::DataProfileInfo> &)4528 Return<void> RadioImpl_1_6::setDataProfile_1_5(int32_t serial ,
4529 const hidl_vec<::android::hardware::radio::V1_5::DataProfileInfo>& /* profiles */) {
4530 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4531 RIL_REQUEST_SET_DATA_PROFILE);
4532 if (pRI == NULL) {
4533 return Void();
4534 }
4535
4536 RadioResponseInfo responseInfo = {};
4537 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
4538
4539 if (radioService[mSlotId]->mRadioResponseV1_5 != NULL) {
4540 Return<void> retStatus =
4541 radioService[mSlotId]->mRadioResponseV1_5->setDataProfileResponse_1_5(responseInfo);
4542 } else if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
4543 Return<void> retStatus
4544 = radioService[mSlotId]->mRadioResponseV1_4->setDataProfileResponse(responseInfo);
4545 radioService[mSlotId]->checkReturnStatus(retStatus);
4546 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
4547 Return<void> retStatus
4548 = radioService[mSlotId]->mRadioResponse->setDataProfileResponse(responseInfo);
4549 radioService[mSlotId]->checkReturnStatus(retStatus);
4550 } else {
4551 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
4552 }
4553
4554 return Void();
4555 }
4556
setIndicationFilter_1_5(int32_t serial,hidl_bitfield<::android::hardware::radio::V1_5::IndicationFilter> indicationFilter)4557 Return<void> RadioImpl_1_6::setIndicationFilter_1_5(
4558 int32_t serial,
4559 hidl_bitfield<::android::hardware::radio::V1_5::IndicationFilter> indicationFilter) {
4560 #if VDBG
4561 RLOGE("setIndicationFilter_1_5: serial %d");
4562 #endif
4563 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
4564 return Void();
4565 }
4566
getBarringInfo(int32_t serial)4567 Return<void> RadioImpl_1_6::getBarringInfo(int32_t serial) {
4568 #if VDBG
4569 RLOGD("getBarringInfo: serial %d", serial);
4570 #endif
4571 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_BARRING_INFO);
4572 return Void();
4573 }
4574
setNetworkSelectionModeManual_1_5(int32_t serial,const hidl_string & operatorNumeric,V1_5::RadioAccessNetworks ran)4575 Return<void> RadioImpl_1_6::setNetworkSelectionModeManual_1_5(int32_t serial,
4576 const hidl_string& operatorNumeric, V1_5::RadioAccessNetworks ran) {
4577 #if VDBG
4578 RLOGD("setNetworkSelectionModeManual_1_6: serial %d", serial);
4579 #endif
4580 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4581 RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL);
4582 if (pRI == NULL) {
4583 return Void();
4584 }
4585
4586 RIL_NetworkOperator networkOperator = {};
4587
4588 networkOperator.act = (RIL_RadioAccessNetworks)ran;
4589 if (!copyHidlStringToRil(&networkOperator.operatorNumeric, operatorNumeric, pRI)) {
4590 return Void();
4591 }
4592 CALL_ONREQUEST(pRI->pCI->requestNumber, &networkOperator,
4593 sizeof(networkOperator), pRI, mSlotId);
4594
4595 return Void();
4596 }
4597
sendCdmaSmsExpectMore(int32_t serial,const CdmaSmsMessage & sms)4598 Return<void> RadioImpl_1_6::sendCdmaSmsExpectMore(int32_t serial, const CdmaSmsMessage& sms) {
4599 #if VDBG
4600 RLOGD("sendCdmaSmsExpectMore: serial %d", serial);
4601 #endif
4602 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4603 RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE);
4604 if (pRI == NULL) {
4605 return Void();
4606 }
4607
4608 RIL_CDMA_SMS_Message rcsm = {};
4609 constructCdmaSms(rcsm, sms);
4610
4611 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
4612 return Void();
4613 }
4614
4615 // Methods from ::android::hardware::radio::V1_6::IRadio follow.
sendCdmaSmsExpectMore_1_6(int32_t serial,const CdmaSmsMessage & sms)4616 Return<void> RadioImpl_1_6::sendCdmaSmsExpectMore_1_6(int32_t serial, const CdmaSmsMessage& sms) {
4617 #if VDBG
4618 RLOGD("sendCdmaSmsExpectMore: serial %d", serial);
4619 #endif
4620 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
4621 RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE);
4622 if (pRI == NULL) {
4623 return Void();
4624 }
4625
4626 RIL_CDMA_SMS_Message rcsm = {};
4627 constructCdmaSms(rcsm, sms);
4628
4629 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
4630 return Void();
4631 }
4632
supplySimDepersonalization(int32_t serial,V1_5::PersoSubstate persoType,const hidl_string & controlKey)4633 Return<void> RadioImpl_1_6::supplySimDepersonalization(int32_t serial,
4634 V1_5::PersoSubstate persoType, const hidl_string& controlKey) {
4635 #if VDBG
4636 RLOGD("supplySimDepersonalization: serial %d", serial);
4637 #endif
4638 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_DEPERSONALIZATION, true, 1,
4639 controlKey.c_str());
4640 return Void();
4641 }
4642
setNrDualConnectivityState(int32_t serial,V1_6::NrDualConnectivityState nrDualConnectivityState)4643 Return<void> RadioImpl_1_6::setNrDualConnectivityState(int32_t serial,
4644 V1_6::NrDualConnectivityState nrDualConnectivityState) {
4645 #if VDBG
4646 RLOGD("setNrDualConnectivityState: serial %d", serial);
4647 #endif
4648 dispatchInts(serial, mSlotId, RIL_REQUEST_ENABLE_NR_DUAL_CONNECTIVITY, 1,
4649 nrDualConnectivityState);
4650 return Void();
4651 }
4652
isNrDualConnectivityEnabled(int32_t serial)4653 Return<void> RadioImpl_1_6::isNrDualConnectivityEnabled(int32_t serial) {
4654 #if VDBG
4655 RLOGD("isNrDualConnectivityEnabled: serial %d", serial);
4656 #endif
4657 dispatchVoid(serial, mSlotId, RIL_REQUEST_IS_NR_DUAL_CONNECTIVITY_ENABLED);
4658 return Void();
4659 }
4660
allocatePduSessionId(int32_t serial)4661 Return<void> RadioImpl_1_6::allocatePduSessionId(int32_t serial) {
4662 #if VDBG
4663 RLOGD("allocatePduSessionId: serial %d", serial);
4664 #endif
4665 dispatchVoid(serial, mSlotId, RIL_REQUEST_ALLOCATE_PDU_SESSION_ID);
4666 return Void();
4667 }
4668
releasePduSessionId(int32_t serial,int32_t id)4669 Return<void> RadioImpl_1_6::releasePduSessionId(int32_t serial, int32_t id) {
4670 #if VDBG
4671 RLOGD("releasePduSessionId: serial %d, pduSessionId: %d", serial, id);
4672 #endif
4673 dispatchVoid(serial, mSlotId, RIL_REQUEST_RELEASE_PDU_SESSION_ID);
4674 return Void();
4675 }
4676
startHandover(int32_t serial,int32_t callId)4677 Return<void> RadioImpl_1_6::startHandover(int32_t serial, int32_t callId) {
4678 #if VDBG
4679 RLOGD("startHandover: serial %d, callId: %d", serial, callId);
4680 #endif
4681 dispatchVoid(serial, mSlotId, RIL_REQUEST_START_HANDOVER);
4682 return Void();
4683 }
4684
cancelHandover(int32_t serial,int32_t callId)4685 Return<void> RadioImpl_1_6::cancelHandover(int32_t serial, int32_t callId) {
4686 #if VDBG
4687 RLOGD("cancelHandover: serial %d, callId: %d", serial, callId);
4688 #endif
4689 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_HANDOVER);
4690 return Void();
4691 }
4692
4693
setDataThrottling(int32_t serial,V1_6::DataThrottlingAction dataThrottlingAction,int64_t completionDurationMillis)4694 Return<void> RadioImpl_1_6::setDataThrottling(int32_t serial, V1_6::DataThrottlingAction dataThrottlingAction, int64_t completionDurationMillis) {
4695 #if VDBG
4696 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
4697 #endif
4698 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_DATA_THROTTLING, 2,
4699 dataThrottlingAction, completionDurationMillis);
4700 return Void();
4701 }
4702
getSystemSelectionChannels(int32_t serial)4703 Return<void> RadioImpl_1_6::getSystemSelectionChannels(int32_t serial) {
4704 #if VDBG
4705 RLOGD("getSystemSelectionChannels: serial %d", serial);
4706 #endif
4707 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SYSTEM_SELECTION_CHANNELS);
4708 return Void();
4709 }
4710
getSlicingConfig(int32_t serial)4711 Return<void> RadioImpl_1_6::getSlicingConfig(int32_t serial) {
4712 #if VDBG
4713 RLOGD("getSlicingConfig: serial %d", serial);
4714 #endif
4715 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SLICING_CONFIG);
4716 return Void();
4717 }
4718
setCarrierInfoForImsiEncryption_1_6(int32_t serial,const V1_6::ImsiEncryptionInfo & data)4719 Return<void> RadioImpl_1_6::setCarrierInfoForImsiEncryption_1_6(
4720 int32_t serial, const V1_6::ImsiEncryptionInfo& data) {
4721 #if VDBG
4722 RLOGD("setCarrierInfoForImsiEncryption_1_6: serial %d", serial);
4723 #endif
4724 RequestInfo* pRI = android::addRequestToList(serial, mSlotId,
4725 RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
4726 if (pRI == NULL) {
4727 return Void();
4728 }
4729
4730 RIL_CarrierInfoForImsiEncryption_v16 imsiEncryption = {};
4731
4732 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.base.mnc, pRI)) {
4733 return Void();
4734 }
4735 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.base.mcc, pRI)) {
4736 memsetAndFreeStrings(1, imsiEncryption.mnc);
4737 return Void();
4738 }
4739 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.base.keyIdentifier, pRI)) {
4740 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
4741 return Void();
4742 }
4743 imsiEncryption.carrierKeyLength = data.base.carrierKey.size();
4744 imsiEncryption.carrierKey = new uint8_t[imsiEncryption.carrierKeyLength];
4745 memcpy(imsiEncryption.carrierKey, data.base.carrierKey.data(), imsiEncryption.carrierKeyLength);
4746 imsiEncryption.expirationTime = data.base.expirationTime;
4747 imsiEncryption.keyType = (RIL_PublicKeyType)data.keyType;
4748
4749 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
4750 sizeof(RIL_CarrierInfoForImsiEncryption_v16), pRI, mSlotId);
4751 delete (imsiEncryption.carrierKey);
4752 return Void();
4753 }
4754
4755
getSimPhonebookRecords(int32_t serial)4756 Return<void> RadioImpl_1_6::getSimPhonebookRecords(int32_t serial) {
4757 #if VDBG
4758 RLOGD("getSimPhonebookRecords: serial %d", serial);
4759 #endif
4760 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_PHONEBOOK_RECORDS);
4761 return Void();
4762 }
4763
getSimPhonebookCapacity(int32_t serial)4764 Return<void> RadioImpl_1_6::getSimPhonebookCapacity(int32_t serial) {
4765 #if VDBG
4766 RLOGD("getSimPhonebookCapacity: serial %d", serial);
4767 #endif
4768 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_PHONEBOOK_CAPACITY);
4769 return Void();
4770 }
4771
updateSimPhonebookRecords(int32_t serial,const::android::hardware::radio::V1_6::PhonebookRecordInfo & recordInfo)4772 Return<void> RadioImpl_1_6::updateSimPhonebookRecords(
4773 int32_t serial,
4774 const ::android::hardware::radio::V1_6::PhonebookRecordInfo& recordInfo) {
4775 #if VDBG
4776 RLOGD("updateSimPhonebookRecords: serial %d", serial);
4777 #endif
4778 dispatchVoid(serial, mSlotId, RIL_REQUEST_UPDATE_SIM_PHONEBOOK_RECORDS);
4779 return Void();
4780 }
4781
4782
4783 // OEM hook methods:
setResponseFunctions(const::android::sp<IOemHookResponse> & oemHookResponseParam,const::android::sp<IOemHookIndication> & oemHookIndicationParam)4784 Return<void> OemHookImpl::setResponseFunctions(
4785 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
4786 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
4787 #if VDBG
4788 RLOGD("OemHookImpl::setResponseFunctions");
4789 #endif
4790
4791 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_6::getRadioServiceRwlock(mSlotId);
4792 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
4793 CHECK_EQ(ret, 0);
4794
4795 mOemHookResponse = oemHookResponseParam;
4796 mOemHookIndication = oemHookIndicationParam;
4797 mCounterOemHook[mSlotId]++;
4798
4799 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
4800 CHECK_EQ(ret, 0);
4801
4802 return Void();
4803 }
4804
sendRequestRaw(int32_t serial,const hidl_vec<uint8_t> & data)4805 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
4806 #if VDBG
4807 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
4808 #endif
4809 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
4810 return Void();
4811 }
4812
sendRequestStrings(int32_t serial,const hidl_vec<hidl_string> & data)4813 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
4814 const hidl_vec<hidl_string>& data) {
4815 #if VDBG
4816 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
4817 #endif
4818 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
4819 return Void();
4820 }
4821
4822 /***************************************************************************************************
4823 * RESPONSE FUNCTIONS
4824 * Functions above are used for requests going from framework to vendor code. The ones below are
4825 * responses for those requests coming back from the vendor code.
4826 **************************************************************************************************/
4827
acknowledgeRequest(int slotId,int serial)4828 void radio_1_6::acknowledgeRequest(int slotId, int serial) {
4829 if (radioService[slotId]->mRadioResponse != NULL) {
4830 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
4831 radioService[slotId]->checkReturnStatus(retStatus);
4832 } else {
4833 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
4834 }
4835 }
4836
populateResponseInfo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e)4837 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
4838 RIL_Errno e) {
4839 responseInfo.serial = serial;
4840 switch (responseType) {
4841 case RESPONSE_SOLICITED:
4842 responseInfo.type = RadioResponseType::SOLICITED;
4843 break;
4844 case RESPONSE_SOLICITED_ACK_EXP:
4845 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
4846 break;
4847 }
4848 responseInfo.error = (RadioError) e;
4849 }
4850
populateResponseInfo_1_6(::android::hardware::radio::V1_6::RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e)4851 void populateResponseInfo_1_6(
4852 ::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo,
4853 int serial, int responseType, RIL_Errno e) {
4854 responseInfo.serial = serial;
4855 switch (responseType) {
4856 case RESPONSE_SOLICITED:
4857 responseInfo.type = RadioResponseType::SOLICITED;
4858 break;
4859 case RESPONSE_SOLICITED_ACK_EXP:
4860 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
4861 break;
4862 }
4863 responseInfo.error = (::android::hardware::radio::V1_6::RadioError)e;
4864 }
4865
responseIntOrEmpty(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)4866 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
4867 void *response, size_t responseLen) {
4868 populateResponseInfo(responseInfo, serial, responseType, e);
4869 int ret = -1;
4870
4871 if (response == NULL && responseLen == 0) {
4872 // Earlier RILs did not send a response for some cases although the interface
4873 // expected an integer as response. Do not return error if response is empty. Instead
4874 // Return -1 in those cases to maintain backward compatibility.
4875 } else if (response == NULL || responseLen != sizeof(int)) {
4876 RLOGE("responseIntOrEmpty: Invalid response");
4877 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4878 } else {
4879 int *p_int = (int *) response;
4880 ret = p_int[0];
4881 }
4882 return ret;
4883 }
4884
responseInt(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)4885 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
4886 void *response, size_t responseLen) {
4887 populateResponseInfo(responseInfo, serial, responseType, e);
4888 int ret = -1;
4889
4890 if (response == NULL || responseLen != sizeof(int)) {
4891 RLOGE("responseInt: Invalid response");
4892 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4893 } else {
4894 int *p_int = (int *) response;
4895 ret = p_int[0];
4896 }
4897 return ret;
4898 }
4899
responseInt_1_6(::android::hardware::radio::V1_6::RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)4900 int responseInt_1_6(::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo, int serial, int responseType, RIL_Errno e,
4901 void *response, size_t responseLen) {
4902 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
4903 int ret = -1;
4904
4905 if (response == NULL || responseLen != sizeof(int)) {
4906 RLOGE("responseInt_1_6: Invalid response");
4907 if (e == RIL_E_SUCCESS) responseInfo.error = ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
4908 } else {
4909 int *p_int = (int *) response;
4910 ret = p_int[0];
4911 }
4912 return ret;
4913 }
4914
getIccCardStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)4915 int radio_1_6::getIccCardStatusResponse(int slotId,
4916 int responseType, int serial, RIL_Errno e,
4917 void *response, size_t responseLen) {
4918 #if VDBG
4919 RLOGD("getIccCardStatusResponse: serial %d", serial);
4920 #endif
4921 if (radioService[slotId]->mRadioResponseV1_5 != NULL
4922 || radioService[slotId]->mRadioResponseV1_4 != NULL
4923 || radioService[slotId]->mRadioResponseV1_2 != NULL
4924 || radioService[slotId]->mRadioResponse != NULL) {
4925 RadioResponseInfo responseInfo = {};
4926 populateResponseInfo(responseInfo, serial, responseType, e);
4927 CardStatus cardStatus = {CardState::ABSENT, PinState::UNKNOWN, -1, -1, -1, {}};
4928 RIL_AppStatus *rilAppStatus = NULL;
4929 RIL_CardStatus_v1_5 *p_cur = ((RIL_CardStatus_v1_5 *) response);
4930 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v1_5)
4931 || p_cur->base.base.base.gsm_umts_subscription_app_index >= p_cur->base.base.base.num_applications
4932 || p_cur->base.base.base.cdma_subscription_app_index >= p_cur->base.base.base.num_applications
4933 || p_cur->base.base.base.ims_subscription_app_index >= p_cur->base.base.base.num_applications) {
4934 RLOGE("getIccCardStatusResponse: Invalid response");
4935 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4936 } else {
4937 cardStatus.cardState = (CardState) p_cur->base.base.base.card_state;
4938 cardStatus.universalPinState = (PinState) p_cur->base.base.base.universal_pin_state;
4939 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->base.base.base.gsm_umts_subscription_app_index;
4940 cardStatus.cdmaSubscriptionAppIndex = p_cur->base.base.base.cdma_subscription_app_index;
4941 cardStatus.imsSubscriptionAppIndex = p_cur->base.base.base.ims_subscription_app_index;
4942 rilAppStatus = p_cur->base.base.base.applications;
4943 cardStatus.applications.resize(p_cur->base.base.base.num_applications);
4944 AppStatus *appStatus = cardStatus.applications.data();
4945 #if VDBG
4946 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->base.base.base.num_applications);
4947 #endif
4948 for (int i = 0; i < p_cur->base.base.base.num_applications; i++) {
4949 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
4950 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
4951 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
4952 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
4953 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
4954 rilAppStatus[i].app_label_ptr);
4955 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
4956 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
4957 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
4958 }
4959 }
4960 if (p_cur && radioService[slotId]->mRadioResponseV1_5 != NULL) {
4961 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
4962 ::android::hardware::radio::V1_4::CardStatus cardStatusV1_4;
4963 ::android::hardware::radio::V1_5::CardStatus cardStatusV1_5;
4964 cardStatusV1_2.base = cardStatus;
4965 cardStatusV1_2.physicalSlotId = -1;
4966 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
4967 cardStatusV1_4.base = cardStatusV1_2;
4968 cardStatusV1_5.base = cardStatusV1_4;
4969 cardStatusV1_5.applications.resize(p_cur->base.base.base.num_applications);
4970 for (int i = 0; i < p_cur->base.base.base.num_applications; i++) {
4971 cardStatusV1_5.applications[i].base.appType = (AppType) rilAppStatus[i].app_type;
4972 cardStatusV1_5.applications[i].base.appState = (AppState) rilAppStatus[i].app_state;
4973 cardStatusV1_5.applications[i].base.persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
4974 cardStatusV1_5.applications[i].base.aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
4975 cardStatusV1_5.applications[i].base.appLabelPtr = convertCharPtrToHidlString(
4976 rilAppStatus[i].app_label_ptr);
4977 cardStatusV1_5.applications[i].base.pin1Replaced = rilAppStatus[i].pin1_replaced;
4978 cardStatusV1_5.applications[i].base.pin1 = (PinState) rilAppStatus[i].pin1;
4979 cardStatusV1_5.applications[i].base.pin2 = (PinState) rilAppStatus[i].pin2;
4980 cardStatusV1_5.applications[i].persoSubstate = (V1_5::PersoSubstate)rilAppStatus[i].perso_substate;
4981 }
4982
4983 // If POWER_DOWN then set applications to empty
4984 if (radioService[slotId]->mSimCardPowerState == V1_1::CardPowerState::POWER_DOWN) {
4985 RLOGD("getIccCardStatusResponse: state is POWER_DOWN so clearing apps");
4986 cardStatusV1_5.applications = {};
4987 }
4988 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5->
4989 getIccCardStatusResponse_1_5(responseInfo, cardStatusV1_5);
4990 radioService[slotId]->checkReturnStatus(retStatus);
4991 } else if (p_cur && radioService[slotId]->mRadioResponseV1_4 != NULL) {
4992 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
4993 ::android::hardware::radio::V1_4::CardStatus cardStatusV1_4;
4994 cardStatusV1_2.base = cardStatus;
4995 cardStatusV1_2.physicalSlotId = -1;
4996 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
4997 cardStatusV1_4.base = cardStatusV1_2;
4998 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4->
4999 getIccCardStatusResponse_1_4(responseInfo, cardStatusV1_4);
5000 radioService[slotId]->checkReturnStatus(retStatus);
5001 } else if (p_cur && radioService[slotId]->mRadioResponseV1_3 != NULL) {
5002 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
5003 cardStatusV1_2.base = cardStatus;
5004 cardStatusV1_2.physicalSlotId = -1;
5005 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
5006 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_3->
5007 getIccCardStatusResponse_1_2(responseInfo, cardStatusV1_2);
5008 radioService[slotId]->checkReturnStatus(retStatus);
5009 } else if (p_cur && radioService[slotId]->mRadioResponseV1_2 != NULL) {
5010 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
5011 cardStatusV1_2.base = cardStatus;
5012 cardStatusV1_2.physicalSlotId = -1;
5013 cardStatusV1_2.iccid = convertCharPtrToHidlString(p_cur->base.base.iccid);
5014 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2->
5015 getIccCardStatusResponse_1_2(responseInfo, cardStatusV1_2);
5016 radioService[slotId]->checkReturnStatus(retStatus);
5017 // TODO: add 1.1 if needed.
5018 } else {
5019 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5020 getIccCardStatusResponse(responseInfo, cardStatus);
5021 radioService[slotId]->checkReturnStatus(retStatus);
5022 }
5023 } else {
5024 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5025 }
5026 return 0;
5027 }
5028
supplyIccPinForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5029 int radio_1_6::supplyIccPinForAppResponse(int slotId,
5030 int responseType, int serial, RIL_Errno e,
5031 void *response, size_t responseLen) {
5032 #if VDBG
5033 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
5034 #endif
5035
5036 if (radioService[slotId]->mRadioResponse != NULL) {
5037 RadioResponseInfo responseInfo = {};
5038 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5039 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5040 supplyIccPinForAppResponse(responseInfo, ret);
5041 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
5042 radioService[slotId]->checkReturnStatus(retStatus);
5043 } else {
5044 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
5045 slotId);
5046 }
5047
5048 return 0;
5049 }
5050
supplyIccPukForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5051 int radio_1_6::supplyIccPukForAppResponse(int slotId,
5052 int responseType, int serial, RIL_Errno e,
5053 void *response, size_t responseLen) {
5054 #if VDBG
5055 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
5056 #endif
5057
5058 if (radioService[slotId]->mRadioResponse != NULL) {
5059 RadioResponseInfo responseInfo = {};
5060 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5061 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
5062 responseInfo, ret);
5063 radioService[slotId]->checkReturnStatus(retStatus);
5064 } else {
5065 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
5066 slotId);
5067 }
5068
5069 return 0;
5070 }
5071
supplyIccPin2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5072 int radio_1_6::supplyIccPin2ForAppResponse(int slotId,
5073 int responseType, int serial, RIL_Errno e,
5074 void *response, size_t responseLen) {
5075 #if VDBG
5076 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
5077 #endif
5078
5079 if (radioService[slotId]->mRadioResponse != NULL) {
5080 RadioResponseInfo responseInfo = {};
5081 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5082 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5083 supplyIccPin2ForAppResponse(responseInfo, ret);
5084 radioService[slotId]->checkReturnStatus(retStatus);
5085 } else {
5086 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
5087 slotId);
5088 }
5089
5090 return 0;
5091 }
5092
supplyIccPuk2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5093 int radio_1_6::supplyIccPuk2ForAppResponse(int slotId,
5094 int responseType, int serial, RIL_Errno e,
5095 void *response, size_t responseLen) {
5096 #if VDBG
5097 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
5098 #endif
5099
5100 if (radioService[slotId]->mRadioResponse != NULL) {
5101 RadioResponseInfo responseInfo = {};
5102 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5103 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5104 supplyIccPuk2ForAppResponse(responseInfo, ret);
5105 radioService[slotId]->checkReturnStatus(retStatus);
5106 } else {
5107 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
5108 slotId);
5109 }
5110
5111 return 0;
5112 }
5113
changeIccPinForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5114 int radio_1_6::changeIccPinForAppResponse(int slotId,
5115 int responseType, int serial, RIL_Errno e,
5116 void *response, size_t responseLen) {
5117 #if VDBG
5118 RLOGD("changeIccPinForAppResponse: serial %d", serial);
5119 #endif
5120
5121 if (radioService[slotId]->mRadioResponse != NULL) {
5122 RadioResponseInfo responseInfo = {};
5123 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5124 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5125 changeIccPinForAppResponse(responseInfo, ret);
5126 radioService[slotId]->checkReturnStatus(retStatus);
5127 } else {
5128 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
5129 slotId);
5130 }
5131
5132 return 0;
5133 }
5134
changeIccPin2ForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5135 int radio_1_6::changeIccPin2ForAppResponse(int slotId,
5136 int responseType, int serial, RIL_Errno e,
5137 void *response, size_t responseLen) {
5138 #if VDBG
5139 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
5140 #endif
5141
5142 if (radioService[slotId]->mRadioResponse != NULL) {
5143 RadioResponseInfo responseInfo = {};
5144 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5145 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5146 changeIccPin2ForAppResponse(responseInfo, ret);
5147 radioService[slotId]->checkReturnStatus(retStatus);
5148 } else {
5149 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
5150 slotId);
5151 }
5152
5153 return 0;
5154 }
5155
supplyNetworkDepersonalizationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5156 int radio_1_6::supplyNetworkDepersonalizationResponse(int slotId,
5157 int responseType, int serial, RIL_Errno e,
5158 void *response, size_t responseLen) {
5159 #if VDBG
5160 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
5161 #endif
5162
5163 if (radioService[slotId]->mRadioResponse != NULL) {
5164 RadioResponseInfo responseInfo = {};
5165 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5166 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5167 supplyNetworkDepersonalizationResponse(responseInfo, ret);
5168 radioService[slotId]->checkReturnStatus(retStatus);
5169 } else {
5170 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
5171 "NULL", slotId);
5172 }
5173
5174 return 0;
5175 }
5176
getCurrentCallsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5177 int radio_1_6::getCurrentCallsResponse(int slotId, int responseType, int serial, RIL_Errno e,
5178 void* response, size_t responseLen) {
5179 #if VDBG
5180 RLOGD("getCurrentCallsResponse: serial %d", serial);
5181 #endif
5182
5183 if (radioService[slotId]->mRadioResponseV1_6 != NULL ||
5184 radioService[slotId]->mRadioResponseV1_2 != NULL ||
5185 radioService[slotId]->mRadioResponse != NULL) {
5186 V1_6::RadioResponseInfo responseInfo16 = {};
5187 RadioResponseInfo responseInfo = {};
5188 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5189 populateResponseInfo_1_6(responseInfo16, serial, responseType, e);
5190 } else {
5191 populateResponseInfo(responseInfo, serial, responseType, e);
5192 }
5193 if ((response == NULL && responseLen != 0) || (responseLen % sizeof(RIL_Call*)) != 0) {
5194 RLOGE("getCurrentCallsResponse: Invalid response");
5195 if (e == RIL_E_SUCCESS) {
5196 responseInfo16.error = V1_6::RadioError::INVALID_RESPONSE;
5197 responseInfo.error = RadioError::INVALID_RESPONSE;
5198 }
5199 return 0;
5200 } else {
5201 Return<void> retStatus;
5202 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5203 hidl_vec<V1_6::Call> calls;
5204 int num = responseLen / sizeof(RIL_Call*);
5205 calls.resize(num);
5206
5207 for (int i = 0; i < num; i++) {
5208 RIL_Call* p_cur = ((RIL_Call**)response)[i];
5209 /* each call info */
5210 calls[i].base.base.state = (CallState)p_cur->state;
5211 calls[i].base.base.index = p_cur->index;
5212 calls[i].base.base.toa = p_cur->toa;
5213 calls[i].base.base.isMpty = p_cur->isMpty;
5214 calls[i].base.base.isMT = p_cur->isMT;
5215 calls[i].base.base.als = p_cur->als;
5216 calls[i].base.base.isVoice = p_cur->isVoice;
5217 calls[i].base.base.isVoicePrivacy = p_cur->isVoicePrivacy;
5218 calls[i].base.base.number = convertCharPtrToHidlString(p_cur->number);
5219 calls[i].base.base.numberPresentation =
5220 (CallPresentation)p_cur->numberPresentation;
5221 calls[i].base.base.name = convertCharPtrToHidlString(p_cur->name);
5222 calls[i].base.base.namePresentation = (CallPresentation)p_cur->namePresentation;
5223 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
5224 RIL_UUS_Info* uusInfo = p_cur->uusInfo;
5225 calls[i].base.base.uusInfo.resize(1);
5226 calls[i].base.base.uusInfo[0].uusType = (UusType)uusInfo->uusType;
5227 calls[i].base.base.uusInfo[0].uusDcs = (UusDcs)uusInfo->uusDcs;
5228 // convert uusInfo->uusData to a null-terminated string
5229 char* nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
5230 calls[i].base.base.uusInfo[0].uusData = nullTermStr;
5231 free(nullTermStr);
5232 }
5233 }
5234 retStatus = radioService[slotId]->mRadioResponseV1_6->getCurrentCallsResponse_1_6(
5235 responseInfo16, calls);
5236 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
5237 hidl_vec<V1_2::Call> calls;
5238 int num = responseLen / sizeof(RIL_Call*);
5239 calls.resize(num);
5240
5241 for (int i = 0; i < num; i++) {
5242 RIL_Call* p_cur = ((RIL_Call**)response)[i];
5243 /* each call info */
5244 calls[i].base.state = (CallState)p_cur->state;
5245 calls[i].base.index = p_cur->index;
5246 calls[i].base.toa = p_cur->toa;
5247 calls[i].base.isMpty = p_cur->isMpty;
5248 calls[i].base.isMT = p_cur->isMT;
5249 calls[i].base.als = p_cur->als;
5250 calls[i].base.isVoice = p_cur->isVoice;
5251 calls[i].base.isVoicePrivacy = p_cur->isVoicePrivacy;
5252 calls[i].base.number = convertCharPtrToHidlString(p_cur->number);
5253 calls[i].base.numberPresentation = (CallPresentation)p_cur->numberPresentation;
5254 calls[i].base.name = convertCharPtrToHidlString(p_cur->name);
5255 calls[i].base.namePresentation = (CallPresentation)p_cur->namePresentation;
5256 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
5257 RIL_UUS_Info* uusInfo = p_cur->uusInfo;
5258 calls[i].base.uusInfo.resize(1);
5259 calls[i].base.uusInfo[0].uusType = (UusType)uusInfo->uusType;
5260 calls[i].base.uusInfo[0].uusDcs = (UusDcs)uusInfo->uusDcs;
5261 // convert uusInfo->uusData to a null-terminated string
5262 char* nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
5263 calls[i].base.uusInfo[0].uusData = nullTermStr;
5264 free(nullTermStr);
5265 }
5266 }
5267 retStatus = radioService[slotId]->mRadioResponseV1_2->getCurrentCallsResponse_1_2(
5268 responseInfo, calls);
5269 } else {
5270 hidl_vec<Call> calls;
5271 int num = responseLen / sizeof(RIL_Call*);
5272 calls.resize(num);
5273
5274 for (int i = 0; i < num; i++) {
5275 RIL_Call* p_cur = ((RIL_Call**)response)[i];
5276 /* each call info */
5277 calls[i].state = (CallState)p_cur->state;
5278 calls[i].index = p_cur->index;
5279 calls[i].toa = p_cur->toa;
5280 calls[i].isMpty = p_cur->isMpty;
5281 calls[i].isMT = p_cur->isMT;
5282 calls[i].als = p_cur->als;
5283 calls[i].isVoice = p_cur->isVoice;
5284 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
5285 calls[i].number = convertCharPtrToHidlString(p_cur->number);
5286 calls[i].numberPresentation = (CallPresentation)p_cur->numberPresentation;
5287 calls[i].name = convertCharPtrToHidlString(p_cur->name);
5288 calls[i].namePresentation = (CallPresentation)p_cur->namePresentation;
5289 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
5290 RIL_UUS_Info* uusInfo = p_cur->uusInfo;
5291 calls[i].uusInfo.resize(1);
5292 calls[i].uusInfo[0].uusType = (UusType)uusInfo->uusType;
5293 calls[i].uusInfo[0].uusDcs = (UusDcs)uusInfo->uusDcs;
5294 // convert uusInfo->uusData to a null-terminated string
5295 char* nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
5296 calls[i].uusInfo[0].uusData = nullTermStr;
5297 free(nullTermStr);
5298 }
5299 }
5300 retStatus = radioService[slotId]->mRadioResponse->getCurrentCallsResponse(
5301 responseInfo, calls);
5302 }
5303 radioService[slotId]->checkReturnStatus(retStatus);
5304 }
5305 } else {
5306 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5307 }
5308
5309 return 0;
5310 }
5311
dialResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5312 int radio_1_6::dialResponse(int slotId,
5313 int responseType, int serial, RIL_Errno e, void *response,
5314 size_t responseLen) {
5315 #if VDBG
5316 RLOGD("dialResponse: serial %d", serial);
5317 #endif
5318
5319 if (radioService[slotId]->mRadioResponse != NULL) {
5320 RadioResponseInfo responseInfo = {};
5321 populateResponseInfo(responseInfo, serial, responseType, e);
5322 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
5323 radioService[slotId]->checkReturnStatus(retStatus);
5324 } else {
5325 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5326 }
5327
5328 return 0;
5329 }
5330
getIMSIForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5331 int radio_1_6::getIMSIForAppResponse(int slotId,
5332 int responseType, int serial, RIL_Errno e, void *response,
5333 size_t responseLen) {
5334 #if VDBG
5335 RLOGD("getIMSIForAppResponse: serial %d", serial);
5336 #endif
5337
5338 if (radioService[slotId]->mRadioResponse != NULL) {
5339 RadioResponseInfo responseInfo = {};
5340 populateResponseInfo(responseInfo, serial, responseType, e);
5341 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
5342 responseInfo, convertCharPtrToHidlString((char *) response));
5343 radioService[slotId]->checkReturnStatus(retStatus);
5344 } else {
5345 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
5346 slotId);
5347 }
5348
5349 return 0;
5350 }
5351
hangupConnectionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5352 int radio_1_6::hangupConnectionResponse(int slotId,
5353 int responseType, int serial, RIL_Errno e,
5354 void *response, size_t responseLen) {
5355 #if VDBG
5356 RLOGD("hangupConnectionResponse: serial %d", serial);
5357 #endif
5358
5359 if (radioService[slotId]->mRadioResponse != NULL) {
5360 RadioResponseInfo responseInfo = {};
5361 populateResponseInfo(responseInfo, serial, responseType, e);
5362 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
5363 responseInfo);
5364 radioService[slotId]->checkReturnStatus(retStatus);
5365 } else {
5366 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
5367 slotId);
5368 }
5369
5370 return 0;
5371 }
5372
hangupWaitingOrBackgroundResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5373 int radio_1_6::hangupWaitingOrBackgroundResponse(int slotId,
5374 int responseType, int serial, RIL_Errno e,
5375 void *response, size_t responseLen) {
5376 #if VDBG
5377 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
5378 #endif
5379
5380 if (radioService[slotId]->mRadioResponse != NULL) {
5381 RadioResponseInfo responseInfo = {};
5382 populateResponseInfo(responseInfo, serial, responseType, e);
5383 Return<void> retStatus =
5384 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
5385 responseInfo);
5386 radioService[slotId]->checkReturnStatus(retStatus);
5387 } else {
5388 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
5389 slotId);
5390 }
5391
5392 return 0;
5393 }
5394
hangupForegroundResumeBackgroundResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5395 int radio_1_6::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
5396 RIL_Errno e, void *response,
5397 size_t responseLen) {
5398 #if VDBG
5399 RLOGD("hangupForegroundResumeBackgroundResponse: serial %d", serial);
5400 #endif
5401
5402 if (radioService[slotId]->mRadioResponse != NULL) {
5403 RadioResponseInfo responseInfo = {};
5404 populateResponseInfo(responseInfo, serial, responseType, e);
5405 Return<void> retStatus =
5406 radioService[slotId]->mRadioResponse->hangupForegroundResumeBackgroundResponse(
5407 responseInfo);
5408 radioService[slotId]->checkReturnStatus(retStatus);
5409 } else {
5410 RLOGE("hangupForegroundResumeBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
5411 slotId);
5412 }
5413
5414 return 0;
5415 }
5416
switchWaitingOrHoldingAndActiveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5417 int radio_1_6::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
5418 RIL_Errno e, void *response,
5419 size_t responseLen) {
5420 #if VDBG
5421 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
5422 #endif
5423
5424 if (radioService[slotId]->mRadioResponse != NULL) {
5425 RadioResponseInfo responseInfo = {};
5426 populateResponseInfo(responseInfo, serial, responseType, e);
5427 Return<void> retStatus =
5428 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
5429 responseInfo);
5430 radioService[slotId]->checkReturnStatus(retStatus);
5431 } else {
5432 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
5433 "== NULL", slotId);
5434 }
5435
5436 return 0;
5437 }
5438
conferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5439 int radio_1_6::conferenceResponse(int slotId, int responseType,
5440 int serial, RIL_Errno e, void *response, size_t responseLen) {
5441 #if VDBG
5442 RLOGD("conferenceResponse: serial %d", serial);
5443 #endif
5444
5445 if (radioService[slotId]->mRadioResponse != NULL) {
5446 RadioResponseInfo responseInfo = {};
5447 populateResponseInfo(responseInfo, serial, responseType, e);
5448 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
5449 responseInfo);
5450 radioService[slotId]->checkReturnStatus(retStatus);
5451 } else {
5452 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
5453 slotId);
5454 }
5455
5456 return 0;
5457 }
5458
rejectCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5459 int radio_1_6::rejectCallResponse(int slotId, int responseType,
5460 int serial, RIL_Errno e, void *response, size_t responseLen) {
5461 #if VDBG
5462 RLOGD("rejectCallResponse: serial %d", serial);
5463 #endif
5464
5465 if (radioService[slotId]->mRadioResponse != NULL) {
5466 RadioResponseInfo responseInfo = {};
5467 populateResponseInfo(responseInfo, serial, responseType, e);
5468 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
5469 responseInfo);
5470 radioService[slotId]->checkReturnStatus(retStatus);
5471 } else {
5472 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
5473 slotId);
5474 }
5475
5476 return 0;
5477 }
5478
getLastCallFailCauseResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5479 int radio_1_6::getLastCallFailCauseResponse(int slotId,
5480 int responseType, int serial, RIL_Errno e, void *response,
5481 size_t responseLen) {
5482 #if VDBG
5483 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
5484 #endif
5485
5486 if (radioService[slotId]->mRadioResponse != NULL) {
5487 RadioResponseInfo responseInfo = {};
5488 populateResponseInfo(responseInfo, serial, responseType, e);
5489
5490 LastCallFailCauseInfo info = {};
5491 info.vendorCause = hidl_string();
5492 if (response == NULL) {
5493 RLOGE("getLastCallFailCauseResponse Invalid response: NULL");
5494 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5495 } else if (responseLen == sizeof(int)) {
5496 int *pInt = (int *) response;
5497 info.causeCode = (LastCallFailCause) pInt[0];
5498 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
5499 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
5500 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
5501 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
5502 } else {
5503 RLOGE("getLastCallFailCauseResponse Invalid response: NULL");
5504 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5505 }
5506
5507 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
5508 responseInfo, info);
5509 radioService[slotId]->checkReturnStatus(retStatus);
5510 } else {
5511 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
5512 slotId);
5513 }
5514
5515 return 0;
5516 }
5517
getSignalStrengthResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)5518 int radio_1_6::getSignalStrengthResponse(int slotId, int responseType, int serial, RIL_Errno e,
5519 void* response, size_t responseLen) {
5520 #if VDBG
5521 RLOGD("getSignalStrengthResponse: serial %d", serial);
5522 #endif
5523
5524 V1_6::RadioResponseInfo responseInfo16 = {};
5525 RadioResponseInfo responseInfo = {};
5526 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5527 populateResponseInfo_1_6(responseInfo16, serial, responseType, e);
5528 } else {
5529 populateResponseInfo(responseInfo, serial, responseType, e);
5530 }
5531
5532 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v12)) {
5533 RLOGE("getSignalStrengthResponse: Invalid response");
5534 if (e == RIL_E_SUCCESS) {
5535 responseInfo16.error = V1_6::RadioError::INVALID_RESPONSE;
5536 responseInfo.error = RadioError::INVALID_RESPONSE;
5537 }
5538 } else {
5539 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
5540 V1_6::SignalStrength signalStrength_1_6 = {};
5541 convertRilSignalStrengthToHal_1_6(response, responseLen, signalStrength_1_6);
5542 Return<void> retStatus =
5543 radioService[slotId]->mRadioResponseV1_6->getSignalStrengthResponse_1_6(
5544 responseInfo16, signalStrength_1_6);
5545 radioService[slotId]->checkReturnStatus(retStatus);
5546 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
5547 V1_4::SignalStrength signalStrength_1_4 = {};
5548 convertRilSignalStrengthToHal_1_4(response, responseLen, signalStrength_1_4);
5549 // TODO: future implementation needs to fill tdScdma, wcdma and nr signal strength.
5550 Return<void> retStatus =
5551 radioService[slotId]->mRadioResponseV1_4->getSignalStrengthResponse_1_4(
5552 responseInfo, signalStrength_1_4);
5553 radioService[slotId]->checkReturnStatus(retStatus);
5554 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
5555 V1_2::SignalStrength signalStrength_1_2 = {};
5556 convertRilSignalStrengthToHal_1_2(response, responseLen, signalStrength_1_2);
5557 Return<void> retStatus =
5558 radioService[slotId]->mRadioResponseV1_2->getSignalStrengthResponse_1_2(
5559 responseInfo, signalStrength_1_2);
5560 radioService[slotId]->checkReturnStatus(retStatus);
5561 } else if (radioService[slotId]->mRadioResponse != NULL) {
5562 SignalStrength signalStrength = {};
5563 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
5564 Return<void> retStatus =
5565 radioService[slotId]->mRadioResponse->getSignalStrengthResponse(responseInfo,
5566 signalStrength);
5567 radioService[slotId]->checkReturnStatus(retStatus);
5568 } else {
5569 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5570 }
5571 }
5572
5573 return 0;
5574 }
5575
getCellInfoTypeRadioTechnology(char * rat)5576 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
5577 if (rat == NULL) {
5578 return RIL_CELL_INFO_TYPE_NONE;
5579 }
5580
5581 int radioTech = atoi(rat);
5582
5583 switch(radioTech) {
5584
5585 case RADIO_TECH_GPRS:
5586 case RADIO_TECH_EDGE:
5587 case RADIO_TECH_GSM: {
5588 return RIL_CELL_INFO_TYPE_GSM;
5589 }
5590
5591 case RADIO_TECH_UMTS:
5592 case RADIO_TECH_HSDPA:
5593 case RADIO_TECH_HSUPA:
5594 case RADIO_TECH_HSPA:
5595 case RADIO_TECH_HSPAP: {
5596 return RIL_CELL_INFO_TYPE_WCDMA;
5597 }
5598
5599 case RADIO_TECH_IS95A:
5600 case RADIO_TECH_IS95B:
5601 case RADIO_TECH_1xRTT:
5602 case RADIO_TECH_EVDO_0:
5603 case RADIO_TECH_EVDO_A:
5604 case RADIO_TECH_EVDO_B:
5605 case RADIO_TECH_EHRPD: {
5606 return RIL_CELL_INFO_TYPE_CDMA;
5607 }
5608
5609 case RADIO_TECH_LTE:
5610 case RADIO_TECH_LTE_CA: {
5611 return RIL_CELL_INFO_TYPE_LTE;
5612 }
5613
5614 case RADIO_TECH_TD_SCDMA: {
5615 return RIL_CELL_INFO_TYPE_TD_SCDMA;
5616 }
5617
5618 default: {
5619 break;
5620 }
5621 }
5622
5623 return RIL_CELL_INFO_TYPE_NONE;
5624
5625 }
5626
fillCellIdentityResponse(CellIdentity & cellIdentity,RIL_CellIdentity_v16 & rilCellIdentity)5627 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
5628
5629 cellIdentity.cellIdentityGsm.resize(0);
5630 cellIdentity.cellIdentityWcdma.resize(0);
5631 cellIdentity.cellIdentityCdma.resize(0);
5632 cellIdentity.cellIdentityTdscdma.resize(0);
5633 cellIdentity.cellIdentityLte.resize(0);
5634 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
5635 switch(rilCellIdentity.cellInfoType) {
5636
5637 case RIL_CELL_INFO_TYPE_GSM: {
5638 cellIdentity.cellIdentityGsm.resize(1);
5639 cellIdentity.cellIdentityGsm[0].mcc =
5640 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5641 cellIdentity.cellIdentityGsm[0].mnc =
5642 ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
5643 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
5644 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
5645 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
5646 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
5647 break;
5648 }
5649
5650 case RIL_CELL_INFO_TYPE_WCDMA: {
5651 cellIdentity.cellIdentityWcdma.resize(1);
5652 cellIdentity.cellIdentityWcdma[0].mcc =
5653 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
5654 cellIdentity.cellIdentityWcdma[0].mnc =
5655 ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
5656 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
5657 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
5658 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
5659 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
5660 break;
5661 }
5662
5663 case RIL_CELL_INFO_TYPE_CDMA: {
5664 cellIdentity.cellIdentityCdma.resize(1);
5665 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
5666 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
5667 cellIdentity.cellIdentityCdma[0].baseStationId =
5668 rilCellIdentity.cellIdentityCdma.basestationId;
5669 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
5670 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
5671 break;
5672 }
5673
5674 case RIL_CELL_INFO_TYPE_LTE: {
5675 cellIdentity.cellIdentityLte.resize(1);
5676 cellIdentity.cellIdentityLte[0].mcc =
5677 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
5678 cellIdentity.cellIdentityLte[0].mnc =
5679 ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
5680 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
5681 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
5682 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
5683 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
5684 break;
5685 }
5686
5687 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
5688 cellIdentity.cellIdentityTdscdma.resize(1);
5689 cellIdentity.cellIdentityTdscdma[0].mcc =
5690 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
5691 cellIdentity.cellIdentityTdscdma[0].mnc =
5692 ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
5693 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
5694 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
5695 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
5696 break;
5697 }
5698
5699 default: {
5700 break;
5701 }
5702 }
5703 }
5704
fillCellIdentityResponse_1_5(V1_5::CellIdentity & cellIdentity,RIL_CellIdentity_v16 & rilCellIdentity)5705 void fillCellIdentityResponse_1_5(V1_5::CellIdentity &cellIdentity,
5706 RIL_CellIdentity_v16 &rilCellIdentity) {
5707
5708 switch (rilCellIdentity.cellInfoType) {
5709 case RIL_CELL_INFO_TYPE_GSM: {
5710 V1_5::CellIdentityGsm gsm;
5711 gsm.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5712 gsm.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
5713 if (gsm.base.base.mcc == "-1") {
5714 gsm.base.base.mcc = "";
5715 }
5716 gsm.base.base.lac = rilCellIdentity.cellIdentityGsm.lac;
5717 gsm.base.base.cid = rilCellIdentity.cellIdentityGsm.cid;
5718 gsm.base.base.arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
5719 gsm.base.base.bsic = rilCellIdentity.cellIdentityGsm.bsic;
5720 cellIdentity.gsm(gsm);
5721 break;
5722 }
5723
5724 case RIL_CELL_INFO_TYPE_WCDMA: {
5725 V1_5::CellIdentityWcdma wcdma;
5726 wcdma.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5727 wcdma.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
5728 if (wcdma.base.base.mcc == "-1") {
5729 wcdma.base.base.mcc = "";
5730 }
5731 wcdma.base.base.lac = rilCellIdentity.cellIdentityWcdma.lac;
5732 wcdma.base.base.cid = rilCellIdentity.cellIdentityWcdma.cid;
5733 wcdma.base.base.psc = rilCellIdentity.cellIdentityWcdma.psc;
5734 wcdma.base.base.uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
5735 cellIdentity.wcdma(wcdma);
5736 break;
5737 }
5738
5739 case RIL_CELL_INFO_TYPE_CDMA: {
5740 V1_2::CellIdentityCdma cdma;
5741 cdma.base.networkId = rilCellIdentity.cellIdentityCdma.networkId;
5742 cdma.base.systemId = rilCellIdentity.cellIdentityCdma.systemId;
5743 cdma.base.baseStationId =
5744 rilCellIdentity.cellIdentityCdma.basestationId;
5745 cdma.base.longitude = rilCellIdentity.cellIdentityCdma.longitude;
5746 cdma.base.latitude = rilCellIdentity.cellIdentityCdma.latitude;
5747 cellIdentity.cdma(cdma);
5748 break;
5749 }
5750
5751 case RIL_CELL_INFO_TYPE_LTE: {
5752 V1_5::CellIdentityLte lte;
5753 lte.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5754 lte.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
5755 if (lte.base.base.mcc == "-1") {
5756 lte.base.base.mcc = "";
5757 }
5758 lte.base.base.ci = rilCellIdentity.cellIdentityLte.ci;
5759 lte.base.base.pci = rilCellIdentity.cellIdentityLte.pci;
5760 lte.base.base.tac = rilCellIdentity.cellIdentityLte.tac;
5761 lte.base.base.earfcn = rilCellIdentity.cellIdentityLte.earfcn;
5762 cellIdentity.lte(lte);
5763 break;
5764 }
5765
5766 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
5767 V1_5::CellIdentityTdscdma tdscdma;
5768 tdscdma.base.base.mcc = std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5769 tdscdma.base.base.mnc = ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
5770 if (tdscdma.base.base.mcc == "-1") {
5771 tdscdma.base.base.mcc = "";
5772 }
5773 tdscdma.base.base.lac = rilCellIdentity.cellIdentityTdscdma.lac;
5774 tdscdma.base.base.cid = rilCellIdentity.cellIdentityTdscdma.cid;
5775 tdscdma.base.base.cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
5776 cellIdentity.tdscdma(tdscdma);
5777 break;
5778 }
5779
5780 default: {
5781 break;
5782 }
5783 }
5784 }
5785
fillCellIdentityResponse_1_2(V1_2::CellIdentity & cellIdentity,RIL_CellIdentity_v1_2 & rilCellIdentity)5786 void fillCellIdentityResponse_1_2(V1_2::CellIdentity &cellIdentity,
5787 RIL_CellIdentity_v1_2 &rilCellIdentity) {
5788 cellIdentity.cellIdentityGsm.resize(0);
5789 cellIdentity.cellIdentityWcdma.resize(0);
5790 cellIdentity.cellIdentityCdma.resize(0);
5791 cellIdentity.cellIdentityTdscdma.resize(0);
5792 cellIdentity.cellIdentityLte.resize(0);
5793 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
5794 switch(rilCellIdentity.cellInfoType) {
5795
5796 case RIL_CELL_INFO_TYPE_GSM: {
5797 cellIdentity.cellIdentityGsm.resize(1);
5798 cellIdentity.cellIdentityGsm[0].base.mcc =
5799 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
5800 cellIdentity.cellIdentityGsm[0].base.mnc =
5801 ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
5802
5803 if (cellIdentity.cellIdentityGsm[0].base.mcc == "-1") {
5804 cellIdentity.cellIdentityGsm[0].base.mcc = "";
5805 }
5806
5807 cellIdentity.cellIdentityGsm[0].base.lac = rilCellIdentity.cellIdentityGsm.lac;
5808 cellIdentity.cellIdentityGsm[0].base.cid = rilCellIdentity.cellIdentityGsm.cid;
5809 cellIdentity.cellIdentityGsm[0].base.arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
5810 cellIdentity.cellIdentityGsm[0].base.bsic = rilCellIdentity.cellIdentityGsm.bsic;
5811 break;
5812 }
5813
5814 case RIL_CELL_INFO_TYPE_WCDMA: {
5815 cellIdentity.cellIdentityWcdma.resize(1);
5816 cellIdentity.cellIdentityWcdma[0].base.mcc =
5817 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
5818 cellIdentity.cellIdentityWcdma[0].base.mnc =
5819 ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
5820
5821 if (cellIdentity.cellIdentityWcdma[0].base.mcc == "-1") {
5822 cellIdentity.cellIdentityWcdma[0].base.mcc = "";
5823 }
5824
5825 cellIdentity.cellIdentityWcdma[0].base.lac = rilCellIdentity.cellIdentityWcdma.lac;
5826 cellIdentity.cellIdentityWcdma[0].base.cid = rilCellIdentity.cellIdentityWcdma.cid;
5827 cellIdentity.cellIdentityWcdma[0].base.psc = rilCellIdentity.cellIdentityWcdma.psc;
5828 cellIdentity.cellIdentityWcdma[0].base.uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
5829 break;
5830 }
5831
5832 case RIL_CELL_INFO_TYPE_CDMA: {
5833 cellIdentity.cellIdentityCdma.resize(1);
5834 cellIdentity.cellIdentityCdma[0].base.networkId = rilCellIdentity.cellIdentityCdma.networkId;
5835 cellIdentity.cellIdentityCdma[0].base.systemId = rilCellIdentity.cellIdentityCdma.systemId;
5836 cellIdentity.cellIdentityCdma[0].base.baseStationId =
5837 rilCellIdentity.cellIdentityCdma.basestationId;
5838 cellIdentity.cellIdentityCdma[0].base.longitude = rilCellIdentity.cellIdentityCdma.longitude;
5839 cellIdentity.cellIdentityCdma[0].base.latitude = rilCellIdentity.cellIdentityCdma.latitude;
5840 break;
5841 }
5842
5843 case RIL_CELL_INFO_TYPE_LTE: {
5844 cellIdentity.cellIdentityLte.resize(1);
5845 cellIdentity.cellIdentityLte[0].base.mcc =
5846 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
5847 cellIdentity.cellIdentityLte[0].base.mnc =
5848 ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
5849
5850 if (cellIdentity.cellIdentityLte[0].base.mcc == "-1") {
5851 cellIdentity.cellIdentityLte[0].base.mcc = "";
5852 }
5853
5854 cellIdentity.cellIdentityLte[0].base.ci = rilCellIdentity.cellIdentityLte.ci;
5855 cellIdentity.cellIdentityLte[0].base.pci = rilCellIdentity.cellIdentityLte.pci;
5856 cellIdentity.cellIdentityLte[0].base.tac = rilCellIdentity.cellIdentityLte.tac;
5857 cellIdentity.cellIdentityLte[0].base.earfcn = rilCellIdentity.cellIdentityLte.earfcn;
5858 cellIdentity.cellIdentityLte[0].bandwidth = rilCellIdentity.cellIdentityLte.bandwidth;
5859 break;
5860 }
5861
5862 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
5863 cellIdentity.cellIdentityTdscdma.resize(1);
5864 cellIdentity.cellIdentityTdscdma[0].base.mcc =
5865 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
5866 cellIdentity.cellIdentityTdscdma[0].base.mnc =
5867 ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
5868
5869 if (cellIdentity.cellIdentityTdscdma[0].base.mcc == "-1") {
5870 cellIdentity.cellIdentityTdscdma[0].base.mcc = "";
5871 }
5872
5873 cellIdentity.cellIdentityTdscdma[0].base.lac = rilCellIdentity.cellIdentityTdscdma.lac;
5874 cellIdentity.cellIdentityTdscdma[0].base.cid = rilCellIdentity.cellIdentityTdscdma.cid;
5875 cellIdentity.cellIdentityTdscdma[0].base.cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
5876 cellIdentity.cellIdentityTdscdma[0].uarfcn = rilCellIdentity.cellIdentityTdscdma.uarfcn;
5877 break;
5878 }
5879
5880 default: {
5881 break;
5882 }
5883 }
5884 }
5885
convertResponseStringEntryToInt(char ** response,int index,int numStrings)5886 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
5887 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
5888 return atoi(response[index]);
5889 }
5890
5891 return -1;
5892 }
5893
convertResponseHexStringEntryToInt(char ** response,int index,int numStrings)5894 int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
5895 const int hexBase = 16;
5896 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
5897 return strtol(response[index], NULL, hexBase);
5898 }
5899
5900 return -1;
5901 }
5902
5903 /* Fill Cell Identity info from Voice Registration State Response.
5904 * This fucntion is applicable only for RIL Version < 15.
5905 * Response is a "char **".
5906 * First and Second entries are in hex string format
5907 * and rest are integers represented in ascii format. */
fillCellIdentityFromVoiceRegStateResponseString(V1_5::CellIdentity & cellIdentity,int numStrings,char ** response)5908 void fillCellIdentityFromVoiceRegStateResponseString(V1_5::CellIdentity &cellIdentity,
5909 int numStrings, char** response) {
5910
5911 RIL_CellIdentity_v16 rilCellIdentity;
5912 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
5913
5914 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
5915 switch(rilCellIdentity.cellInfoType) {
5916
5917 case RIL_CELL_INFO_TYPE_GSM: {
5918 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
5919 rilCellIdentity.cellIdentityGsm.lac =
5920 convertResponseHexStringEntryToInt(response, 1, numStrings);
5921
5922 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
5923 rilCellIdentity.cellIdentityGsm.cid =
5924 convertResponseHexStringEntryToInt(response, 2, numStrings);
5925
5926 if (numStrings > 15) {
5927 rilCellIdentity.cellIdentityGsm.mcc =
5928 convertResponseStringEntryToInt(response, 15, numStrings);
5929
5930 rilCellIdentity.cellIdentityGsm.mnc =
5931 convertResponseStringEntryToInt(response, 16, numStrings);
5932 }
5933 break;
5934 }
5935
5936 case RIL_CELL_INFO_TYPE_WCDMA: {
5937 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
5938 rilCellIdentity.cellIdentityWcdma.lac =
5939 convertResponseHexStringEntryToInt(response, 1, numStrings);
5940
5941 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
5942 rilCellIdentity.cellIdentityWcdma.cid =
5943 convertResponseHexStringEntryToInt(response, 2, numStrings);
5944 rilCellIdentity.cellIdentityWcdma.psc =
5945 convertResponseStringEntryToInt(response, 14, numStrings);
5946
5947 if (numStrings > 15) {
5948 rilCellIdentity.cellIdentityGsm.mcc =
5949 convertResponseStringEntryToInt(response, 15, numStrings);
5950
5951 rilCellIdentity.cellIdentityGsm.mnc =
5952 convertResponseStringEntryToInt(response, 16, numStrings);
5953 }
5954 break;
5955 }
5956
5957 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
5958 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
5959 rilCellIdentity.cellIdentityTdscdma.lac =
5960 convertResponseHexStringEntryToInt(response, 1, numStrings);
5961
5962 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
5963 rilCellIdentity.cellIdentityTdscdma.cid =
5964 convertResponseHexStringEntryToInt(response, 2, numStrings);
5965
5966 if (numStrings > 15) {
5967 rilCellIdentity.cellIdentityGsm.mcc =
5968 convertResponseStringEntryToInt(response, 15, numStrings);
5969
5970 rilCellIdentity.cellIdentityGsm.mnc =
5971 convertResponseStringEntryToInt(response, 16, numStrings);
5972 }
5973 break;
5974 }
5975
5976 case RIL_CELL_INFO_TYPE_CDMA:{
5977 rilCellIdentity.cellIdentityCdma.basestationId =
5978 convertResponseStringEntryToInt(response, 4, numStrings);
5979 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
5980 rilCellIdentity.cellIdentityCdma.latitude =
5981 convertResponseStringEntryToInt(response, 5, numStrings);
5982 rilCellIdentity.cellIdentityCdma.longitude =
5983 convertResponseStringEntryToInt(response, 6, numStrings);
5984 rilCellIdentity.cellIdentityCdma.systemId =
5985 convertResponseStringEntryToInt(response, 8, numStrings);
5986 rilCellIdentity.cellIdentityCdma.networkId =
5987 convertResponseStringEntryToInt(response, 9, numStrings);
5988 break;
5989 }
5990
5991 case RIL_CELL_INFO_TYPE_LTE:{
5992 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
5993 rilCellIdentity.cellIdentityLte.tac =
5994 convertResponseHexStringEntryToInt(response, 1, numStrings);
5995
5996 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
5997 rilCellIdentity.cellIdentityLte.ci =
5998 convertResponseHexStringEntryToInt(response, 2, numStrings);
5999
6000 if (numStrings > 15) {
6001 rilCellIdentity.cellIdentityGsm.mcc =
6002 convertResponseStringEntryToInt(response, 15, numStrings);
6003
6004 rilCellIdentity.cellIdentityGsm.mnc =
6005 convertResponseStringEntryToInt(response, 16, numStrings);
6006 }
6007 break;
6008 }
6009
6010 default: {
6011 break;
6012 }
6013 }
6014
6015 fillCellIdentityResponse_1_5(cellIdentity, rilCellIdentity);
6016 }
6017
fillCellIdentityFromVoiceRegStateResponseString_1_2(V1_2::CellIdentity & cellIdentity,int numStrings,char ** response)6018 void fillCellIdentityFromVoiceRegStateResponseString_1_2(V1_2::CellIdentity &cellIdentity,
6019 int numStrings, char** response) {
6020 RIL_CellIdentity_v1_2 rilCellIdentity;
6021 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v1_2));
6022
6023 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6024
6025 switch(rilCellIdentity.cellInfoType) {
6026 case RIL_CELL_INFO_TYPE_GSM: {
6027 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6028 rilCellIdentity.cellIdentityGsm.lac =
6029 convertResponseHexStringEntryToInt(response, 1, numStrings);
6030
6031 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6032 rilCellIdentity.cellIdentityGsm.cid =
6033 convertResponseHexStringEntryToInt(response, 2, numStrings);
6034
6035 if (numStrings > 15) {
6036 rilCellIdentity.cellIdentityGsm.mcc =
6037 convertResponseStringEntryToInt(response, 15, numStrings);
6038
6039 rilCellIdentity.cellIdentityGsm.mnc =
6040 convertResponseStringEntryToInt(response, 16, numStrings);
6041 }
6042 break;
6043 }
6044
6045 case RIL_CELL_INFO_TYPE_WCDMA: {
6046 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6047 rilCellIdentity.cellIdentityWcdma.lac =
6048 convertResponseHexStringEntryToInt(response, 1, numStrings);
6049
6050 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6051 rilCellIdentity.cellIdentityWcdma.cid =
6052 convertResponseHexStringEntryToInt(response, 2, numStrings);
6053 rilCellIdentity.cellIdentityWcdma.psc =
6054 convertResponseStringEntryToInt(response, 14, numStrings);
6055
6056 if (numStrings > 15) {
6057 rilCellIdentity.cellIdentityWcdma.mcc =
6058 convertResponseStringEntryToInt(response, 15, numStrings);
6059
6060 rilCellIdentity.cellIdentityWcdma.mnc =
6061 convertResponseStringEntryToInt(response, 16, numStrings);
6062 }
6063 break;
6064 }
6065
6066 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
6067 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6068 rilCellIdentity.cellIdentityTdscdma.lac =
6069 convertResponseHexStringEntryToInt(response, 1, numStrings);
6070
6071 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6072 rilCellIdentity.cellIdentityTdscdma.cid =
6073 convertResponseHexStringEntryToInt(response, 2, numStrings);
6074
6075 if (numStrings > 15) {
6076 rilCellIdentity.cellIdentityTdscdma.mcc =
6077 convertResponseStringEntryToInt(response, 15, numStrings);
6078
6079 rilCellIdentity.cellIdentityTdscdma.mnc =
6080 convertResponseStringEntryToInt(response, 16, numStrings);
6081 }
6082 break;
6083 }
6084
6085 case RIL_CELL_INFO_TYPE_CDMA:{
6086 rilCellIdentity.cellIdentityCdma.basestationId =
6087 convertResponseStringEntryToInt(response, 4, numStrings);
6088 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
6089 rilCellIdentity.cellIdentityCdma.latitude =
6090 convertResponseStringEntryToInt(response, 5, numStrings);
6091 rilCellIdentity.cellIdentityCdma.longitude =
6092 convertResponseStringEntryToInt(response, 6, numStrings);
6093 rilCellIdentity.cellIdentityCdma.systemId =
6094 convertResponseStringEntryToInt(response, 8, numStrings);
6095 rilCellIdentity.cellIdentityCdma.networkId =
6096 convertResponseStringEntryToInt(response, 9, numStrings);
6097 break;
6098 }
6099
6100 case RIL_CELL_INFO_TYPE_LTE:{
6101 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
6102 rilCellIdentity.cellIdentityLte.tac =
6103 convertResponseHexStringEntryToInt(response, 1, numStrings);
6104
6105 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6106 rilCellIdentity.cellIdentityLte.ci =
6107 convertResponseHexStringEntryToInt(response, 2, numStrings);
6108
6109 if (numStrings > 15) {
6110 rilCellIdentity.cellIdentityLte.mcc =
6111 convertResponseStringEntryToInt(response, 15, numStrings);
6112
6113 rilCellIdentity.cellIdentityLte.mnc =
6114 convertResponseStringEntryToInt(response, 16, numStrings);
6115 }
6116 rilCellIdentity.cellIdentityLte.bandwidth = INT_MAX;
6117 break;
6118 }
6119
6120 default: {
6121 break;
6122 }
6123 }
6124
6125 fillCellIdentityResponse_1_2(cellIdentity, rilCellIdentity);
6126 }
6127
6128 /* Fill Cell Identity info from Data Registration State Response.
6129 * This fucntion is applicable only for RIL Version < 15.
6130 * Response is a "char **".
6131 * First and Second entries are in hex string format
6132 * and rest are integers represented in ascii format. */
fillCellIdentityFromDataRegStateResponseString_1_5(V1_5::CellIdentity & cellIdentity,int numStrings,char ** response)6133 void fillCellIdentityFromDataRegStateResponseString_1_5(V1_5::CellIdentity &cellIdentity,
6134 int numStrings, char** response) {
6135
6136 RIL_CellIdentity_v16 rilCellIdentity;
6137 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
6138
6139 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6140 switch(rilCellIdentity.cellInfoType) {
6141 case RIL_CELL_INFO_TYPE_GSM: {
6142 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6143 rilCellIdentity.cellIdentityGsm.lac =
6144 convertResponseHexStringEntryToInt(response, 1, numStrings);
6145
6146 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6147 rilCellIdentity.cellIdentityGsm.cid =
6148 convertResponseHexStringEntryToInt(response, 2, numStrings);
6149
6150 if (numStrings >= 13) {
6151 rilCellIdentity.cellIdentityGsm.mcc =
6152 convertResponseStringEntryToInt(response, 11, numStrings);
6153
6154 rilCellIdentity.cellIdentityGsm.mnc =
6155 convertResponseStringEntryToInt(response, 12, numStrings);
6156 } else {
6157 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6158 rilCellIdentity.cellIdentityGsm.mnc = 0;
6159 rilCellIdentity.cellIdentityGsm.mcc = 0;
6160 }
6161 break;
6162 }
6163 case RIL_CELL_INFO_TYPE_WCDMA: {
6164 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6165 rilCellIdentity.cellIdentityWcdma.lac =
6166 convertResponseHexStringEntryToInt(response, 1, numStrings);
6167
6168 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6169 rilCellIdentity.cellIdentityWcdma.cid =
6170 convertResponseHexStringEntryToInt(response, 2, numStrings);
6171
6172 if (numStrings >= 13) {
6173 rilCellIdentity.cellIdentityWcdma.mcc =
6174 convertResponseStringEntryToInt(response, 11, numStrings);
6175
6176 rilCellIdentity.cellIdentityWcdma.mnc =
6177 convertResponseStringEntryToInt(response, 12, numStrings);
6178 } else {
6179 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6180 rilCellIdentity.cellIdentityWcdma.mnc = 0;
6181 rilCellIdentity.cellIdentityWcdma.mcc = 0;
6182 }
6183 break;
6184 }
6185 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
6186 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6187 rilCellIdentity.cellIdentityTdscdma.lac =
6188 convertResponseHexStringEntryToInt(response, 1, numStrings);
6189
6190 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6191 rilCellIdentity.cellIdentityTdscdma.cid =
6192 convertResponseHexStringEntryToInt(response, 2, numStrings);
6193
6194 if (numStrings >= 13) {
6195 rilCellIdentity.cellIdentityTdscdma.mcc =
6196 convertResponseStringEntryToInt(response, 11, numStrings);
6197
6198 rilCellIdentity.cellIdentityTdscdma.mnc =
6199 convertResponseStringEntryToInt(response, 12, numStrings);
6200 } else {
6201 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6202 rilCellIdentity.cellIdentityTdscdma.mnc = 0;
6203 rilCellIdentity.cellIdentityTdscdma.mcc = 0;
6204 }
6205 break;
6206 }
6207 case RIL_CELL_INFO_TYPE_LTE: {
6208 rilCellIdentity.cellIdentityLte.tac =
6209 convertResponseStringEntryToInt(response, 6, numStrings);
6210 rilCellIdentity.cellIdentityLte.pci =
6211 convertResponseStringEntryToInt(response, 7, numStrings);
6212 rilCellIdentity.cellIdentityLte.ci =
6213 convertResponseStringEntryToInt(response, 8, numStrings);
6214
6215 if (numStrings >= 13) {
6216 rilCellIdentity.cellIdentityLte.mcc =
6217 convertResponseStringEntryToInt(response, 11, numStrings);
6218
6219 rilCellIdentity.cellIdentityLte.mnc =
6220 convertResponseStringEntryToInt(response, 12, numStrings);
6221 } else {
6222 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6223 rilCellIdentity.cellIdentityLte.mnc = 0;
6224 rilCellIdentity.cellIdentityLte.mcc = 0;
6225 }
6226 break;
6227 }
6228 default: {
6229 break;
6230 }
6231 }
6232
6233 fillCellIdentityResponse_1_5(cellIdentity, rilCellIdentity);
6234 }
6235
fillCellIdentityFromDataRegStateResponseString_1_2(V1_2::CellIdentity & cellIdentity,int numStrings,char ** response)6236 void fillCellIdentityFromDataRegStateResponseString_1_2(V1_2::CellIdentity &cellIdentity,
6237 int numStrings, char** response) {
6238
6239 RIL_CellIdentity_v1_2 rilCellIdentity;
6240 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v1_2));
6241
6242 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6243 switch(rilCellIdentity.cellInfoType) {
6244 case RIL_CELL_INFO_TYPE_GSM: {
6245 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6246 rilCellIdentity.cellIdentityGsm.lac =
6247 convertResponseHexStringEntryToInt(response, 1, numStrings);
6248
6249 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6250 rilCellIdentity.cellIdentityGsm.cid =
6251 convertResponseHexStringEntryToInt(response, 2, numStrings);
6252
6253 if (numStrings >= 13) {
6254 rilCellIdentity.cellIdentityGsm.mcc =
6255 convertResponseStringEntryToInt(response, 11, numStrings);
6256
6257 rilCellIdentity.cellIdentityGsm.mnc =
6258 convertResponseStringEntryToInt(response, 12, numStrings);
6259 } else {
6260 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6261 rilCellIdentity.cellIdentityGsm.mnc = 0;
6262 rilCellIdentity.cellIdentityGsm.mcc = 0;
6263 }
6264 break;
6265 }
6266 case RIL_CELL_INFO_TYPE_WCDMA: {
6267 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6268 rilCellIdentity.cellIdentityWcdma.lac =
6269 convertResponseHexStringEntryToInt(response, 1, numStrings);
6270
6271 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6272 rilCellIdentity.cellIdentityWcdma.cid =
6273 convertResponseHexStringEntryToInt(response, 2, numStrings);
6274
6275 if (numStrings >= 13) {
6276 rilCellIdentity.cellIdentityWcdma.mcc =
6277 convertResponseStringEntryToInt(response, 11, numStrings);
6278
6279 rilCellIdentity.cellIdentityWcdma.mnc =
6280 convertResponseStringEntryToInt(response, 12, numStrings);
6281 } else {
6282 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6283 rilCellIdentity.cellIdentityWcdma.mnc = 0;
6284 rilCellIdentity.cellIdentityWcdma.mcc = 0;
6285 }
6286 break;
6287 }
6288 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
6289 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6290 rilCellIdentity.cellIdentityTdscdma.lac =
6291 convertResponseHexStringEntryToInt(response, 1, numStrings);
6292
6293 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6294 rilCellIdentity.cellIdentityTdscdma.cid =
6295 convertResponseHexStringEntryToInt(response, 2, numStrings);
6296
6297 if (numStrings >= 13) {
6298 rilCellIdentity.cellIdentityTdscdma.mcc =
6299 convertResponseStringEntryToInt(response, 11, numStrings);
6300
6301 rilCellIdentity.cellIdentityTdscdma.mnc =
6302 convertResponseStringEntryToInt(response, 12, numStrings);
6303 } else {
6304 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6305 rilCellIdentity.cellIdentityTdscdma.mnc = 0;
6306 rilCellIdentity.cellIdentityTdscdma.mcc = 0;
6307 }
6308 break;
6309 }
6310 case RIL_CELL_INFO_TYPE_LTE: {
6311 rilCellIdentity.cellIdentityLte.tac =
6312 convertResponseStringEntryToInt(response, 6, numStrings);
6313 rilCellIdentity.cellIdentityLte.pci =
6314 convertResponseStringEntryToInt(response, 7, numStrings);
6315 rilCellIdentity.cellIdentityLte.ci =
6316 convertResponseStringEntryToInt(response, 8, numStrings);
6317
6318 if (numStrings >= 13) {
6319 rilCellIdentity.cellIdentityLte.mcc =
6320 convertResponseStringEntryToInt(response, 11, numStrings);
6321
6322 rilCellIdentity.cellIdentityLte.mnc =
6323 convertResponseStringEntryToInt(response, 12, numStrings);
6324 } else {
6325 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6326 rilCellIdentity.cellIdentityLte.mnc = 0;
6327 rilCellIdentity.cellIdentityLte.mcc = 0;
6328 }
6329 break;
6330 }
6331 case RIL_CELL_INFO_TYPE_CDMA: {
6332 break;
6333 }
6334 default: {
6335 break;
6336 }
6337 }
6338
6339 fillCellIdentityResponse_1_2(cellIdentity, rilCellIdentity);
6340 }
6341
fillCellIdentityFromDataRegStateResponseString(CellIdentity & cellIdentity,int numStrings,char ** response)6342 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
6343 int numStrings, char** response) {
6344
6345 RIL_CellIdentity_v16 rilCellIdentity;
6346 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
6347
6348 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
6349 switch(rilCellIdentity.cellInfoType) {
6350 case RIL_CELL_INFO_TYPE_GSM: {
6351 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6352 rilCellIdentity.cellIdentityGsm.lac =
6353 convertResponseHexStringEntryToInt(response, 1, numStrings);
6354
6355 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6356 rilCellIdentity.cellIdentityGsm.cid =
6357 convertResponseHexStringEntryToInt(response, 2, numStrings);
6358
6359 if (numStrings >= 13) {
6360 rilCellIdentity.cellIdentityGsm.mcc =
6361 convertResponseStringEntryToInt(response, 11, numStrings);
6362
6363 rilCellIdentity.cellIdentityGsm.mnc =
6364 convertResponseStringEntryToInt(response, 12, numStrings);
6365 } else {
6366 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6367 rilCellIdentity.cellIdentityGsm.mnc = 0;
6368 rilCellIdentity.cellIdentityGsm.mcc = 0;
6369 }
6370 break;
6371 }
6372 case RIL_CELL_INFO_TYPE_WCDMA: {
6373 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6374 rilCellIdentity.cellIdentityWcdma.lac =
6375 convertResponseHexStringEntryToInt(response, 1, numStrings);
6376
6377 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6378 rilCellIdentity.cellIdentityWcdma.cid =
6379 convertResponseHexStringEntryToInt(response, 2, numStrings);
6380
6381 if (numStrings >= 13) {
6382 rilCellIdentity.cellIdentityWcdma.mcc =
6383 convertResponseStringEntryToInt(response, 11, numStrings);
6384
6385 rilCellIdentity.cellIdentityWcdma.mnc =
6386 convertResponseStringEntryToInt(response, 12, numStrings);
6387 } else {
6388 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6389 rilCellIdentity.cellIdentityWcdma.mnc = 0;
6390 rilCellIdentity.cellIdentityWcdma.mcc = 0;
6391 }
6392
6393 break;
6394 }
6395 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
6396 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
6397 rilCellIdentity.cellIdentityTdscdma.lac =
6398 convertResponseHexStringEntryToInt(response, 1, numStrings);
6399
6400 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
6401 rilCellIdentity.cellIdentityTdscdma.cid =
6402 convertResponseHexStringEntryToInt(response, 2, numStrings);
6403
6404 if (numStrings >= 13) {
6405 rilCellIdentity.cellIdentityTdscdma.mcc =
6406 convertResponseStringEntryToInt(response, 11, numStrings);
6407
6408 rilCellIdentity.cellIdentityTdscdma.mnc =
6409 convertResponseStringEntryToInt(response, 12, numStrings);
6410 } else {
6411 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6412 rilCellIdentity.cellIdentityTdscdma.mnc = 0;
6413 rilCellIdentity.cellIdentityTdscdma.mcc = 0;
6414 }
6415 break;
6416 }
6417 case RIL_CELL_INFO_TYPE_LTE: {
6418 rilCellIdentity.cellIdentityLte.tac =
6419 convertResponseHexStringEntryToInt(response, 1, numStrings);
6420 rilCellIdentity.cellIdentityLte.ci =
6421 convertResponseHexStringEntryToInt(response, 2, numStrings);
6422
6423 if (numStrings >= 13) {
6424 rilCellIdentity.cellIdentityLte.mcc =
6425 convertResponseStringEntryToInt(response, 11, numStrings);
6426
6427 rilCellIdentity.cellIdentityLte.mnc =
6428 convertResponseStringEntryToInt(response, 12, numStrings);
6429 } else {
6430 /* vts check the mcc [0, 999] and mnc [0, 999]. */
6431 rilCellIdentity.cellIdentityLte.mnc = 0;
6432 rilCellIdentity.cellIdentityLte.mcc = 0;
6433 }
6434 break;
6435 }
6436 // TODO add CDMA
6437 default: {
6438 break;
6439 }
6440 }
6441
6442 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
6443 }
6444
getVoiceRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6445 int radio_1_6::getVoiceRegistrationStateResponse(int slotId,
6446 int responseType, int serial, RIL_Errno e,
6447 void *response, size_t responseLen) {
6448 #if VDBG
6449 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
6450 #endif
6451
6452 if (radioService[slotId]->mRadioResponse != NULL ||
6453 radioService[slotId]->mRadioResponseV1_2 != NULL ||
6454 radioService[slotId]->mRadioResponseV1_5 != NULL ||
6455 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6456 RadioResponseInfo responseInfo = {};
6457 populateResponseInfo(responseInfo, serial, responseType, e);
6458
6459 VoiceRegStateResult voiceRegResponse = {};
6460 int numStrings = responseLen / sizeof(char *);
6461 if (response == NULL) {
6462 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
6463 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6464 } else if (s_vendorFunctions->version >= 15 &&
6465 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6466 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6467 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
6468 RegStateResultV1_6 regResponse = {};
6469 if (numStrings != 18) {
6470 RLOGE("getVoiceRegistrationStateResponse_1_6 Invalid response: NULL");
6471 if (e == RIL_E_SUCCESS) responseInfo_1_6.error =
6472 ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
6473 } else {
6474 char **resp = (char **) response;
6475 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6476 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6477 regResponse.rat = (V1_4::RadioTechnology)rat;
6478 if (rat == RADIO_TECH_EVDO_0 || rat == RADIO_TECH_EVDO_A ||
6479 rat == RADIO_TECH_EVDO_B || rat == RADIO_TECH_1xRTT ||
6480 rat == RADIO_TECH_IS95A || rat == RADIO_TECH_IS95B ||
6481 rat == RADIO_TECH_EHRPD) {
6482 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6483 Cdma2000RegistrationInfo cdmaInfo;
6484 cdmaInfo.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
6485 cdmaInfo.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
6486 cdmaInfo.systemIsInPrl = (V1_5::PrlIndicator)ATOI_NULL_HANDLED_DEF(resp[11], 0);
6487 cdmaInfo.defaultRoamingIndicator= ATOI_NULL_HANDLED_DEF(resp[12], 0);
6488 regResponse.accessTechnologySpecificInfo.cdmaInfo(cdmaInfo);
6489 } else if (rat == RADIO_TECH_NR) {
6490 // rat is NR only for NR SA
6491 V1_6::NrVopsInfo nrVopsInfo;
6492 nrVopsInfo.vopsSupported =
6493 ::android::hardware::radio::V1_6::VopsIndicator::VOPS_NOT_SUPPORTED;
6494 nrVopsInfo.emcSupported =
6495 ::android::hardware::radio::V1_6::EmcIndicator::EMC_NOT_SUPPORTED;
6496 nrVopsInfo.emfSupported =
6497 ::android::hardware::radio::V1_6::EmfIndicator::EMF_NOT_SUPPORTED;
6498 regResponse.accessTechnologySpecificInfo.ngranNrVopsInfo(nrVopsInfo);
6499
6500 } else {
6501 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6502 EutranRegistrationInfo eutranInfo;
6503 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA) {
6504 eutranInfo.lteVopsInfo.isVopsSupported = false;
6505 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6506 }
6507 eutranInfo.nrIndicators.isEndcAvailable = false;
6508 eutranInfo.nrIndicators.isDcNrRestricted = false;
6509 eutranInfo.nrIndicators.isEndcAvailable = false;
6510 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6511 }
6512 regResponse.reasonForDenial = (V1_5::RegistrationFailCause)
6513 ATOI_NULL_HANDLED_DEF(resp[13], 0);
6514 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[17]);
6515
6516 fillCellIdentityFromVoiceRegStateResponseString(regResponse.cellIdentity,
6517 numStrings, resp);
6518
6519 Return<void> retStatus =
6520 radioService[slotId]
6521 ->mRadioResponseV1_6
6522 ->getVoiceRegistrationStateResponse_1_6(
6523 responseInfo_1_6, regResponse);
6524 radioService[slotId]->checkReturnStatus(retStatus);
6525 }
6526 } else if (s_vendorFunctions->version <= 14 &&
6527 radioService[slotId]->mRadioResponseV1_5 != NULL) {
6528 RegStateResultV1_5 regResponse = {};
6529 if (numStrings != 18) {
6530 RLOGE("getVoiceRegistrationStateResponse_1_5 Invalid response: NULL");
6531 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6532 } else {
6533 char **resp = (char **) response;
6534 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6535 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6536 regResponse.rat = (V1_4::RadioTechnology)rat;
6537 if (rat == RADIO_TECH_EVDO_0 || rat == RADIO_TECH_EVDO_A ||
6538 rat == RADIO_TECH_EVDO_B || rat == RADIO_TECH_1xRTT ||
6539 rat == RADIO_TECH_IS95A || rat == RADIO_TECH_IS95B ||
6540 rat == RADIO_TECH_EHRPD) {
6541 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6542 Cdma2000RegistrationInfo cdmaInfo;
6543 cdmaInfo.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
6544 cdmaInfo.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
6545 cdmaInfo.systemIsInPrl = (V1_5::PrlIndicator)ATOI_NULL_HANDLED_DEF(resp[11], 0);
6546 cdmaInfo.defaultRoamingIndicator= ATOI_NULL_HANDLED_DEF(resp[12], 0);
6547 regResponse.accessTechnologySpecificInfo.cdmaInfo(cdmaInfo);
6548 } else {
6549 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6550 EutranRegistrationInfo eutranInfo;
6551 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA ||
6552 rat == RADIO_TECH_NR) {
6553 eutranInfo.lteVopsInfo.isVopsSupported = false;
6554 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6555 }
6556 eutranInfo.nrIndicators.isEndcAvailable = false;
6557 eutranInfo.nrIndicators.isDcNrRestricted = false;
6558 eutranInfo.nrIndicators.isEndcAvailable = false;
6559 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6560 }
6561 regResponse.reasonForDenial = (V1_5::RegistrationFailCause)
6562 ATOI_NULL_HANDLED_DEF(resp[13], 0);
6563 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[17]);
6564
6565 fillCellIdentityFromVoiceRegStateResponseString(regResponse.cellIdentity,
6566 numStrings, resp);
6567
6568 Return<void> retStatus =
6569 radioService[slotId]
6570 ->mRadioResponseV1_5
6571 ->getVoiceRegistrationStateResponse_1_5(
6572 responseInfo, regResponse);
6573 radioService[slotId]->checkReturnStatus(retStatus);
6574 }
6575 } else if (s_vendorFunctions->version <= 14 &&
6576 radioService[slotId]->mRadioResponseV1_2 != NULL) {
6577 V1_2::VoiceRegStateResult voiceRegResponse = {};
6578 int numStrings = responseLen / sizeof(char *);
6579 if (numStrings != 18) {
6580 RLOGE("getVoiceRegistrationStateResponse_1_21 Invalid response: NULL");
6581 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6582 } else {
6583 char **resp = (char **) response;
6584 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
6585 voiceRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6586 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
6587 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
6588 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
6589 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
6590 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
6591 fillCellIdentityFromVoiceRegStateResponseString_1_2(
6592 voiceRegResponse.cellIdentity, numStrings, resp);
6593 }
6594 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2->
6595 getVoiceRegistrationStateResponse_1_2(responseInfo, voiceRegResponse);
6596 radioService[slotId]->checkReturnStatus(retStatus);
6597 } else {
6598 RIL_VoiceRegistrationStateResponse *voiceRegState =
6599 (RIL_VoiceRegistrationStateResponse *)response;
6600 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
6601 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
6602 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6603 } else {
6604 voiceRegResponse.regState = (RegState) voiceRegState->regState;
6605 voiceRegResponse.rat = voiceRegState->rat;;
6606 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
6607 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
6608 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
6609 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
6610 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
6611 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
6612 voiceRegState->cellIdentity);
6613 }
6614 Return<void> retStatus =
6615 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
6616 responseInfo, voiceRegResponse);
6617 radioService[slotId]->checkReturnStatus(retStatus);
6618 }
6619
6620 } else {
6621 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
6622 slotId);
6623 }
6624 return 0;
6625 }
6626
getDataRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6627 int radio_1_6::getDataRegistrationStateResponse(int slotId, int responseType, int serial,
6628 RIL_Errno e, void* response, size_t responseLen) {
6629 #if VDBG
6630 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
6631 #endif
6632 if (radioService[slotId]->mRadioResponse != NULL ||
6633 radioService[slotId]->mRadioResponseV1_2 != NULL ||
6634 radioService[slotId]->mRadioResponseV1_5 != NULL ||
6635 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6636 RadioResponseInfo responseInfo = {};
6637 DataRegStateResult dataRegResponse = {};
6638 populateResponseInfo(responseInfo, serial, responseType, e);
6639 if (response == NULL) {
6640 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6641 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6642 } else if (s_vendorFunctions->version >= 15 &&
6643 radioService[slotId]->mRadioResponseV1_6 != NULL) {
6644 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6645 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
6646 RegStateResultV1_6 regResponse = {};
6647 int numStrings = responseLen / sizeof(char *);
6648 if ((numStrings != 6) && (numStrings != 11) && (numStrings != 14)) {
6649 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6650 if (e == RIL_E_SUCCESS) responseInfo_1_6.error =
6651 ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
6652 } else {
6653 char **resp = (char **) response;
6654 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6655 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6656 regResponse.rat = (V1_4::RadioTechnology)rat;
6657 regResponse.reasonForDenial =
6658 (V1_5::RegistrationFailCause)ATOI_NULL_HANDLED(resp[4]);
6659 if (numStrings > 13) {
6660 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[13]);
6661 }
6662
6663 fillCellIdentityFromDataRegStateResponseString_1_5(regResponse.cellIdentity,
6664 numStrings, resp);
6665 if (rat == RADIO_TECH_NR) {
6666 // rat is NR only for NR SA
6667 V1_6::NrVopsInfo nrVopsInfo;
6668 nrVopsInfo.vopsSupported =
6669 ::android::hardware::radio::V1_6::VopsIndicator::VOPS_NOT_SUPPORTED;
6670 nrVopsInfo.emcSupported =
6671 ::android::hardware::radio::V1_6::EmcIndicator::EMC_NOT_SUPPORTED;
6672 nrVopsInfo.emfSupported =
6673 ::android::hardware::radio::V1_6::EmfIndicator::EMF_NOT_SUPPORTED;
6674 regResponse.accessTechnologySpecificInfo.ngranNrVopsInfo(nrVopsInfo);
6675
6676 } else {
6677 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6678 EutranRegistrationInfo eutranInfo;
6679 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA) {
6680 eutranInfo.lteVopsInfo.isVopsSupported = false;
6681 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6682 }
6683 eutranInfo.nrIndicators.isEndcAvailable = false;
6684 eutranInfo.nrIndicators.isDcNrRestricted = false;
6685 eutranInfo.nrIndicators.isEndcAvailable = false;
6686 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6687 }
6688
6689 Return<void> retStatus =
6690 radioService[slotId]
6691 ->mRadioResponseV1_6->getDataRegistrationStateResponse_1_6(
6692 responseInfo_1_6, regResponse);
6693 radioService[slotId]->checkReturnStatus(retStatus);
6694 return 0;
6695 }
6696 } else if (s_vendorFunctions->version <= 14 &&
6697 radioService[slotId]->mRadioResponseV1_5 != NULL) {
6698 RegStateResultV1_5 regResponse = {};
6699 int numStrings = responseLen / sizeof(char *);
6700 if ((numStrings != 6) && (numStrings != 11) && (numStrings != 14)) {
6701 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6702 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6703 } else {
6704 char **resp = (char **) response;
6705 int rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6706 regResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6707 regResponse.rat = (V1_4::RadioTechnology)rat;
6708 regResponse.reasonForDenial =
6709 (V1_5::RegistrationFailCause)ATOI_NULL_HANDLED(resp[4]);
6710 if (numStrings > 13) {
6711 regResponse.registeredPlmn = convertCharPtrToHidlString(resp[13]);
6712 }
6713
6714 V1_5::RegStateResult::AccessTechnologySpecificInfo::
6715 EutranRegistrationInfo eutranInfo;
6716 if (rat == RADIO_TECH_LTE || rat == RADIO_TECH_LTE_CA ||
6717 rat == RADIO_TECH_NR) {
6718 eutranInfo.lteVopsInfo.isVopsSupported = false;
6719 eutranInfo.lteVopsInfo.isEmcBearerSupported = false;
6720 }
6721 eutranInfo.nrIndicators.isEndcAvailable = false;
6722 eutranInfo.nrIndicators.isDcNrRestricted = false;
6723 eutranInfo.nrIndicators.isEndcAvailable = false;
6724 regResponse.accessTechnologySpecificInfo.eutranInfo(eutranInfo);
6725
6726 fillCellIdentityFromDataRegStateResponseString_1_5(regResponse.cellIdentity,
6727 numStrings, resp);
6728
6729 Return<void> retStatus =
6730 radioService[slotId]
6731 ->mRadioResponseV1_5->getDataRegistrationStateResponse_1_5(
6732 responseInfo, regResponse);
6733 radioService[slotId]->checkReturnStatus(retStatus);
6734 return 0;
6735 }
6736 } else if (s_vendorFunctions->version <= 14 &&
6737 radioService[slotId]->mRadioResponseV1_2 != NULL) {
6738 V1_2::DataRegStateResult dataRegResponse = {};
6739 int numStrings = responseLen / sizeof(char *);
6740 if ((numStrings != 11) && (numStrings != 13) && (numStrings != 14)) {
6741 RLOGE("getDataRegistrationStateResponse_1_2 Invalid response: NULL");
6742 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6743 } else {
6744 char **resp = (char **)response;
6745 dataRegResponse.regState = (RegState)ATOI_NULL_HANDLED_DEF(resp[0], 4);
6746 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6747 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
6748 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
6749 fillCellIdentityFromDataRegStateResponseString_1_2(dataRegResponse.cellIdentity,
6750 numStrings, resp);
6751 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2->
6752 getDataRegistrationStateResponse_1_2(responseInfo, dataRegResponse);
6753 radioService[slotId]->checkReturnStatus(retStatus);
6754 return 0;
6755 }
6756 } else if (s_vendorFunctions->version <= 14) {
6757 int numStrings = responseLen / sizeof(char *);
6758 if ((numStrings != 11) && (numStrings != 13) && (numStrings != 14)) {
6759 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6760 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6761 } else {
6762 char **resp = (char **) response;
6763 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
6764 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
6765 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
6766 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
6767 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
6768 numStrings, resp);
6769 }
6770 } else {
6771 RIL_DataRegistrationStateResponse *dataRegState =
6772 (RIL_DataRegistrationStateResponse *)response;
6773
6774 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
6775 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
6776 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6777 } else {
6778 dataRegResponse.regState = (RegState) dataRegState->regState;
6779 dataRegResponse.rat = dataRegState->rat;
6780 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
6781 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
6782 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
6783 }
6784 }
6785
6786 Return<void> retStatus =
6787 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(
6788 responseInfo, dataRegResponse);
6789 radioService[slotId]->checkReturnStatus(retStatus);
6790 } else {
6791 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
6792 slotId);
6793 }
6794
6795 return 0;
6796 }
6797
getOperatorResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6798 int radio_1_6::getOperatorResponse(int slotId,
6799 int responseType, int serial, RIL_Errno e, void *response,
6800 size_t responseLen) {
6801 #if VDBG
6802 RLOGD("getOperatorResponse: serial %d", serial);
6803 #endif
6804
6805 if (radioService[slotId]->mRadioResponse != NULL) {
6806 RadioResponseInfo responseInfo = {};
6807 populateResponseInfo(responseInfo, serial, responseType, e);
6808 hidl_string longName;
6809 hidl_string shortName;
6810 hidl_string numeric;
6811 int numStrings = responseLen / sizeof(char *);
6812 if (response == NULL || numStrings != 3) {
6813 RLOGE("getOperatorResponse Invalid response: NULL");
6814 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6815
6816 } else {
6817 char **resp = (char **) response;
6818 longName = convertCharPtrToHidlString(resp[0]);
6819 shortName = convertCharPtrToHidlString(resp[1]);
6820 numeric = convertCharPtrToHidlString(resp[2]);
6821 }
6822 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
6823 responseInfo, longName, shortName, numeric);
6824 radioService[slotId]->checkReturnStatus(retStatus);
6825 } else {
6826 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
6827 slotId);
6828 }
6829
6830 return 0;
6831 }
6832
setRadioPowerResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6833 int radio_1_6::setRadioPowerResponse(int slotId,
6834 int responseType, int serial, RIL_Errno e, void *response,
6835 size_t responseLen) {
6836 #if VDBG
6837 RLOGD("setRadioPowerResponse: serial %d", serial);
6838 #endif
6839 RadioResponseInfo responseInfo = {};
6840 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6841 populateResponseInfo(responseInfo, serial, responseType, e);
6842 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
6843
6844 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
6845 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
6846 ->setRadioPowerResponse_1_6(responseInfo_1_6);
6847 radioService[slotId]->checkReturnStatus(retStatus);
6848 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
6849 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
6850 ->setRadioPowerResponse_1_5(responseInfo);
6851 radioService[slotId]->checkReturnStatus(retStatus);
6852 } else if (radioService[slotId]->mRadioResponse != NULL) {
6853 Return<void> retStatus = radioService[slotId]->mRadioResponse
6854 ->setRadioPowerResponse(responseInfo);
6855 radioService[slotId]->checkReturnStatus(retStatus);
6856 } else {
6857 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6858 }
6859
6860 return 0;
6861 }
6862
sendDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6863 int radio_1_6::sendDtmfResponse(int slotId,
6864 int responseType, int serial, RIL_Errno e, void *response,
6865 size_t responseLen) {
6866 #if VDBG
6867 RLOGD("sendDtmfResponse: serial %d", serial);
6868 #endif
6869
6870 if (radioService[slotId]->mRadioResponse != NULL) {
6871 RadioResponseInfo responseInfo = {};
6872 populateResponseInfo(responseInfo, serial, responseType, e);
6873 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
6874 responseInfo);
6875 radioService[slotId]->checkReturnStatus(retStatus);
6876 } else {
6877 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
6878 slotId);
6879 }
6880
6881 return 0;
6882 }
6883
makeSendSmsResult(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)6884 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
6885 RIL_Errno e, void *response, size_t responseLen) {
6886 populateResponseInfo(responseInfo, serial, responseType, e);
6887 SendSmsResult result = {};
6888
6889 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
6890 RLOGE("Invalid response: NULL");
6891 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6892 result.ackPDU = hidl_string();
6893 } else {
6894 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
6895 result.messageRef = resp->messageRef;
6896 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
6897 result.errorCode = resp->errorCode;
6898 }
6899 return result;
6900 }
6901
makeSendSmsResult_1_6(::android::hardware::radio::V1_6::RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)6902 SendSmsResult makeSendSmsResult_1_6(
6903 ::android::hardware::radio::V1_6::RadioResponseInfo &responseInfo, int serial,
6904 int responseType, RIL_Errno e, void *response, size_t responseLen) {
6905 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
6906 SendSmsResult result = {};
6907
6908 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
6909 RLOGE("Invalid response: NULL");
6910 if (e == RIL_E_SUCCESS) {
6911 responseInfo.error = ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
6912 }
6913 result.ackPDU = hidl_string();
6914 } else {
6915 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
6916 result.messageRef = resp->messageRef;
6917 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
6918 result.errorCode = resp->errorCode;
6919 }
6920 return result;
6921 }
6922
sendSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6923 int radio_1_6::sendSmsResponse(int slotId,
6924 int responseType, int serial, RIL_Errno e, void *response,
6925 size_t responseLen) {
6926 #if VDBG
6927 RLOGD("sendSmsResponse: serial %d", serial);
6928 #endif
6929
6930 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
6931 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6932 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e, response,
6933 responseLen);
6934
6935 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
6936 ->sendSmsResponse_1_6(responseInfo_1_6, result);
6937 radioService[slotId]->checkReturnStatus(retStatus);
6938 } else if (radioService[slotId]->mRadioResponse != NULL) {
6939 RadioResponseInfo responseInfo = {};
6940 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
6941 responseLen);
6942
6943 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
6944 result);
6945 radioService[slotId]->checkReturnStatus(retStatus);
6946 } else {
6947 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6948 }
6949
6950 return 0;
6951 }
6952
sendSmsExpectMoreResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6953 int radio_1_6::sendSmsExpectMoreResponse(int slotId,
6954 int responseType, int serial, RIL_Errno e, void *response,
6955 size_t responseLen) {
6956 #if VDBG
6957 RLOGD("sendSmsExpectMoreResponse: serial %d", serial);
6958 #endif
6959
6960 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
6961 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6962 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e, response,
6963 responseLen);
6964
6965 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
6966 ->sendSmsExpectMoreResponse_1_6(responseInfo_1_6, result);
6967 radioService[slotId]->checkReturnStatus(retStatus);
6968 } else if (radioService[slotId]->mRadioResponse != NULL) {
6969 RadioResponseInfo responseInfo = {};
6970 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
6971 responseLen);
6972
6973 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
6974 responseInfo, result);
6975 radioService[slotId]->checkReturnStatus(retStatus);
6976 } else {
6977 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6978 }
6979
6980 return 0;
6981 }
6982
setupDataCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)6983 int radio_1_6::setupDataCallResponse(int slotId,
6984 int responseType, int serial, RIL_Errno e, void *response,
6985 size_t responseLen) {
6986 #if VDBG
6987 RLOGD("setupDataCallResponse: serial %d", serial);
6988 #endif
6989 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
6990 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
6991 populateResponseInfo_1_6(responseInfo_1_6, serial, responseType, e);
6992 ::android::hardware::radio::V1_6::SetupDataCallResult result;
6993 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
6994 if (response != NULL) {
6995 RLOGE("setupDataCallResponse_1_6: Invalid response");
6996 if (e == RIL_E_SUCCESS) responseInfo_1_6.error =
6997 ::android::hardware::radio::V1_6::RadioError::INVALID_RESPONSE;
6998 }
6999 result.cause = ::android::hardware::radio::V1_6::DataCallFailCause::ERROR_UNSPECIFIED;
7000 result.type = ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
7001 result.ifname = hidl_string();
7002 result.addresses = hidl_vec<::android::hardware::radio::V1_5::LinkAddress>();
7003 result.dnses = hidl_vec<hidl_string>();
7004 result.gateways = hidl_vec<hidl_string>();
7005 result.pcscf = hidl_vec<hidl_string>();
7006 result.trafficDescriptors =
7007 hidl_vec<::android::hardware::radio::V1_6::TrafficDescriptor>();
7008 } else {
7009 convertRilDataCallToHal((RIL_Data_Call_Response_v11*)response, result);
7010 }
7011
7012 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6->setupDataCallResponse_1_6(
7013 responseInfo_1_6, result);
7014 radioService[slotId]->checkReturnStatus(retStatus);
7015 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7016 RadioResponseInfo responseInfo = {};
7017 populateResponseInfo(responseInfo, serial, responseType, e);
7018 ::android::hardware::radio::V1_5::SetupDataCallResult result;
7019 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
7020 if (response != NULL) {
7021 RLOGE("setupDataCallResponse_1_5: Invalid response");
7022 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7023 }
7024 result.cause = ::android::hardware::radio::V1_4::DataCallFailCause::ERROR_UNSPECIFIED;
7025 result.type = ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
7026 result.ifname = hidl_string();
7027 result.addresses = hidl_vec<::android::hardware::radio::V1_5::LinkAddress>();
7028 result.dnses = hidl_vec<hidl_string>();
7029 result.gateways = hidl_vec<hidl_string>();
7030 result.pcscf = hidl_vec<hidl_string>();
7031 } else {
7032 convertRilDataCallToHal((RIL_Data_Call_Response_v11*)response, result);
7033 }
7034
7035 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5->setupDataCallResponse_1_5(
7036 responseInfo, result);
7037 radioService[slotId]->checkReturnStatus(retStatus);
7038 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7039 RadioResponseInfo responseInfo = {};
7040 populateResponseInfo(responseInfo, serial, responseType, e);
7041 ::android::hardware::radio::V1_4::SetupDataCallResult result;
7042 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
7043 if (response != NULL) {
7044 RLOGE("setupDataCallResponse_1_4: Invalid response");
7045 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7046 }
7047 result.cause = ::android::hardware::radio::V1_4::DataCallFailCause::ERROR_UNSPECIFIED;
7048 result.type = ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
7049 result.ifname = hidl_string();
7050 result.addresses = hidl_vec<hidl_string>();
7051 result.dnses = hidl_vec<hidl_string>();
7052 result.gateways = hidl_vec<hidl_string>();
7053 result.pcscf = hidl_vec<hidl_string>();
7054 } else {
7055 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
7056 }
7057
7058 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4->setupDataCallResponse_1_4(
7059 responseInfo, result);
7060 radioService[slotId]->checkReturnStatus(retStatus);
7061 } else if (radioService[slotId]->mRadioResponse != NULL) {
7062 RadioResponseInfo responseInfo = {};
7063 populateResponseInfo(responseInfo, serial, responseType, e);
7064
7065 SetupDataCallResult result = {};
7066 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
7067 if (response != NULL) {
7068 RLOGE("setupDataCallResponse: Invalid response");
7069 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7070 }
7071 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
7072 result.type = hidl_string();
7073 result.ifname = hidl_string();
7074 result.addresses = hidl_string();
7075 result.dnses = hidl_string();
7076 result.gateways = hidl_string();
7077 result.pcscf = hidl_string();
7078 } else {
7079 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
7080 }
7081
7082 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
7083 responseInfo, result);
7084 radioService[slotId]->checkReturnStatus(retStatus);
7085 } else {
7086 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7087 }
7088
7089 return 0;
7090 }
7091
responseIccIo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)7092 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
7093 RIL_Errno e, void *response, size_t responseLen) {
7094 populateResponseInfo(responseInfo, serial, responseType, e);
7095 IccIoResult result = {};
7096
7097 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
7098 RLOGE("Invalid response: NULL");
7099 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7100 result.simResponse = hidl_string();
7101 } else {
7102 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
7103 result.sw1 = resp->sw1;
7104 result.sw2 = resp->sw2;
7105 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
7106 }
7107 return result;
7108 }
7109
iccIOForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7110 int radio_1_6::iccIOForAppResponse(int slotId,
7111 int responseType, int serial, RIL_Errno e, void *response,
7112 size_t responseLen) {
7113 #if VDBG
7114 RLOGD("iccIOForAppResponse: serial %d", serial);
7115 #endif
7116
7117 if (radioService[slotId]->mRadioResponse != NULL) {
7118 RadioResponseInfo responseInfo = {};
7119 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
7120 responseLen);
7121
7122 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
7123 responseInfo, result);
7124 radioService[slotId]->checkReturnStatus(retStatus);
7125 } else {
7126 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7127 }
7128
7129 return 0;
7130 }
7131
sendUssdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7132 int radio_1_6::sendUssdResponse(int slotId,
7133 int responseType, int serial, RIL_Errno e, void *response,
7134 size_t responseLen) {
7135 #if VDBG
7136 RLOGD("sendUssdResponse: serial %d", serial);
7137 #endif
7138
7139 if (radioService[slotId]->mRadioResponse != NULL) {
7140 RadioResponseInfo responseInfo = {};
7141 populateResponseInfo(responseInfo, serial, responseType, e);
7142 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
7143 responseInfo);
7144 radioService[slotId]->checkReturnStatus(retStatus);
7145 } else {
7146 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
7147 slotId);
7148 }
7149
7150 return 0;
7151 }
7152
cancelPendingUssdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7153 int radio_1_6::cancelPendingUssdResponse(int slotId,
7154 int responseType, int serial, RIL_Errno e, void *response,
7155 size_t responseLen) {
7156 #if VDBG
7157 RLOGD("cancelPendingUssdResponse: serial %d", serial);
7158 #endif
7159
7160 if (radioService[slotId]->mRadioResponse != NULL) {
7161 RadioResponseInfo responseInfo = {};
7162 populateResponseInfo(responseInfo, serial, responseType, e);
7163 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
7164 responseInfo);
7165 radioService[slotId]->checkReturnStatus(retStatus);
7166 } else {
7167 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
7168 slotId);
7169 }
7170
7171 return 0;
7172 }
7173
getClirResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7174 int radio_1_6::getClirResponse(int slotId,
7175 int responseType, int serial, RIL_Errno e, void *response,
7176 size_t responseLen) {
7177 #if VDBG
7178 RLOGD("getClirResponse: serial %d", serial);
7179 #endif
7180
7181 if (radioService[slotId]->mRadioResponse != NULL) {
7182 RadioResponseInfo responseInfo = {};
7183 populateResponseInfo(responseInfo, serial, responseType, e);
7184 int n = -1, m = -1;
7185 int numInts = responseLen / sizeof(int);
7186 if (response == NULL || numInts != 2) {
7187 RLOGE("getClirResponse Invalid response: NULL");
7188 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7189 } else {
7190 int *pInt = (int *) response;
7191 n = pInt[0];
7192 m = pInt[1];
7193 }
7194 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
7195 n, m);
7196 radioService[slotId]->checkReturnStatus(retStatus);
7197 } else {
7198 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7199 }
7200
7201 return 0;
7202 }
7203
setClirResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7204 int radio_1_6::setClirResponse(int slotId,
7205 int responseType, int serial, RIL_Errno e, void *response,
7206 size_t responseLen) {
7207 #if VDBG
7208 RLOGD("setClirResponse: serial %d", serial);
7209 #endif
7210
7211 if (radioService[slotId]->mRadioResponse != NULL) {
7212 RadioResponseInfo responseInfo = {};
7213 populateResponseInfo(responseInfo, serial, responseType, e);
7214 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
7215 responseInfo);
7216 radioService[slotId]->checkReturnStatus(retStatus);
7217 } else {
7218 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7219 }
7220
7221 return 0;
7222 }
7223
getCallForwardStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7224 int radio_1_6::getCallForwardStatusResponse(int slotId,
7225 int responseType, int serial, RIL_Errno e,
7226 void *response, size_t responseLen) {
7227 #if VDBG
7228 RLOGD("getCallForwardStatusResponse: serial %d", serial);
7229 #endif
7230
7231 if (radioService[slotId]->mRadioResponse != NULL) {
7232 RadioResponseInfo responseInfo = {};
7233 populateResponseInfo(responseInfo, serial, responseType, e);
7234 hidl_vec<CallForwardInfo> callForwardInfos;
7235
7236 if ((response == NULL && responseLen != 0)
7237 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
7238 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
7239 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7240 } else {
7241 int num = responseLen / sizeof(RIL_CallForwardInfo *);
7242 callForwardInfos.resize(num);
7243 for (int i = 0 ; i < num; i++) {
7244 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
7245 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
7246 callForwardInfos[i].reason = resp->reason;
7247 callForwardInfos[i].serviceClass = resp->serviceClass;
7248 callForwardInfos[i].toa = resp->toa;
7249 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
7250 callForwardInfos[i].timeSeconds = resp->timeSeconds;
7251 }
7252 }
7253
7254 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
7255 responseInfo, callForwardInfos);
7256 radioService[slotId]->checkReturnStatus(retStatus);
7257 } else {
7258 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
7259 slotId);
7260 }
7261
7262 return 0;
7263 }
7264
setCallForwardResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7265 int radio_1_6::setCallForwardResponse(int slotId,
7266 int responseType, int serial, RIL_Errno e, void *response,
7267 size_t responseLen) {
7268 #if VDBG
7269 RLOGD("setCallForwardResponse: serial %d", serial);
7270 #endif
7271
7272 if (radioService[slotId]->mRadioResponse != NULL) {
7273 RadioResponseInfo responseInfo = {};
7274 populateResponseInfo(responseInfo, serial, responseType, e);
7275 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
7276 responseInfo);
7277 radioService[slotId]->checkReturnStatus(retStatus);
7278 } else {
7279 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7280 }
7281
7282 return 0;
7283 }
7284
getCallWaitingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7285 int radio_1_6::getCallWaitingResponse(int slotId,
7286 int responseType, int serial, RIL_Errno e, void *response,
7287 size_t responseLen) {
7288 #if VDBG
7289 RLOGD("getCallWaitingResponse: serial %d", serial);
7290 #endif
7291
7292 if (radioService[slotId]->mRadioResponse != NULL) {
7293 RadioResponseInfo responseInfo = {};
7294 populateResponseInfo(responseInfo, serial, responseType, e);
7295 bool enable = false;
7296 int serviceClass = -1;
7297 int numInts = responseLen / sizeof(int);
7298 if (response == NULL || numInts != 2) {
7299 RLOGE("getCallWaitingResponse Invalid response: NULL");
7300 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7301 } else {
7302 int *pInt = (int *) response;
7303 enable = pInt[0] == 1 ? true : false;
7304 serviceClass = pInt[1];
7305 }
7306 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
7307 responseInfo, enable, serviceClass);
7308 radioService[slotId]->checkReturnStatus(retStatus);
7309 } else {
7310 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7311 }
7312
7313 return 0;
7314 }
7315
setCallWaitingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7316 int radio_1_6::setCallWaitingResponse(int slotId,
7317 int responseType, int serial, RIL_Errno e, void *response,
7318 size_t responseLen) {
7319 #if VDBG
7320 RLOGD("setCallWaitingResponse: serial %d", serial);
7321 #endif
7322
7323 if (radioService[slotId]->mRadioResponse != NULL) {
7324 RadioResponseInfo responseInfo = {};
7325 populateResponseInfo(responseInfo, serial, responseType, e);
7326 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
7327 responseInfo);
7328 radioService[slotId]->checkReturnStatus(retStatus);
7329 } else {
7330 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7331 }
7332
7333 return 0;
7334 }
7335
acknowledgeLastIncomingGsmSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7336 int radio_1_6::acknowledgeLastIncomingGsmSmsResponse(int slotId,
7337 int responseType, int serial, RIL_Errno e,
7338 void *response, size_t responseLen) {
7339 #if VDBG
7340 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
7341 #endif
7342
7343 if (radioService[slotId]->mRadioResponse != NULL) {
7344 RadioResponseInfo responseInfo = {};
7345 populateResponseInfo(responseInfo, serial, responseType, e);
7346 Return<void> retStatus =
7347 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
7348 responseInfo);
7349 radioService[slotId]->checkReturnStatus(retStatus);
7350 } else {
7351 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
7352 "== NULL", slotId);
7353 }
7354
7355 return 0;
7356 }
7357
acceptCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7358 int radio_1_6::acceptCallResponse(int slotId,
7359 int responseType, int serial, RIL_Errno e,
7360 void *response, size_t responseLen) {
7361 #if VDBG
7362 RLOGD("acceptCallResponse: serial %d", serial);
7363 #endif
7364
7365 if (radioService[slotId]->mRadioResponse != NULL) {
7366 RadioResponseInfo responseInfo = {};
7367 populateResponseInfo(responseInfo, serial, responseType, e);
7368 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
7369 responseInfo);
7370 radioService[slotId]->checkReturnStatus(retStatus);
7371 } else {
7372 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
7373 slotId);
7374 }
7375
7376 return 0;
7377 }
7378
deactivateDataCallResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7379 int radio_1_6::deactivateDataCallResponse(int slotId,
7380 int responseType, int serial, RIL_Errno e,
7381 void *response, size_t responseLen) {
7382 #if VDBG
7383 RLOGD("deactivateDataCallResponse: serial %d", serial);
7384 #endif
7385
7386 if (radioService[slotId]->mRadioResponse != NULL) {
7387 RadioResponseInfo responseInfo = {};
7388 populateResponseInfo(responseInfo, serial, responseType, e);
7389 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
7390 responseInfo);
7391 radioService[slotId]->checkReturnStatus(retStatus);
7392 } else {
7393 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
7394 slotId);
7395 }
7396
7397 return 0;
7398 }
7399
getFacilityLockForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7400 int radio_1_6::getFacilityLockForAppResponse(int slotId,
7401 int responseType, int serial, RIL_Errno e,
7402 void *response, size_t responseLen) {
7403 #if VDBG
7404 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
7405 #endif
7406
7407 if (radioService[slotId]->mRadioResponse != NULL) {
7408 RadioResponseInfo responseInfo = {};
7409 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
7410 Return<void> retStatus = radioService[slotId]->mRadioResponse->
7411 getFacilityLockForAppResponse(responseInfo, ret);
7412 radioService[slotId]->checkReturnStatus(retStatus);
7413 } else {
7414 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
7415 slotId);
7416 }
7417
7418 return 0;
7419 }
7420
setFacilityLockForAppResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7421 int radio_1_6::setFacilityLockForAppResponse(int slotId,
7422 int responseType, int serial, RIL_Errno e,
7423 void *response, size_t responseLen) {
7424 #if VDBG
7425 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
7426 #endif
7427
7428 if (radioService[slotId]->mRadioResponse != NULL) {
7429 RadioResponseInfo responseInfo = {};
7430 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
7431 Return<void> retStatus
7432 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
7433 ret);
7434 radioService[slotId]->checkReturnStatus(retStatus);
7435 } else {
7436 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
7437 slotId);
7438 }
7439
7440 return 0;
7441 }
7442
setBarringPasswordResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7443 int radio_1_6::setBarringPasswordResponse(int slotId,
7444 int responseType, int serial, RIL_Errno e,
7445 void *response, size_t responseLen) {
7446 #if VDBG
7447 RLOGD("acceptCallResponse: serial %d", serial);
7448 #endif
7449
7450 if (radioService[slotId]->mRadioResponse != NULL) {
7451 RadioResponseInfo responseInfo = {};
7452 populateResponseInfo(responseInfo, serial, responseType, e);
7453 Return<void> retStatus
7454 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
7455 radioService[slotId]->checkReturnStatus(retStatus);
7456 } else {
7457 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
7458 slotId);
7459 }
7460
7461 return 0;
7462 }
7463
getNetworkSelectionModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7464 int radio_1_6::getNetworkSelectionModeResponse(int slotId,
7465 int responseType, int serial, RIL_Errno e, void *response,
7466 size_t responseLen) {
7467 #if VDBG
7468 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
7469 #endif
7470
7471 if (radioService[slotId]->mRadioResponse != NULL) {
7472 RadioResponseInfo responseInfo = {};
7473 populateResponseInfo(responseInfo, serial, responseType, e);
7474 bool manual = false;
7475 if (response == NULL || responseLen != sizeof(int)) {
7476 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
7477 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7478 } else {
7479 int *pInt = (int *) response;
7480 manual = pInt[0] == 1 ? true : false;
7481 }
7482 Return<void> retStatus
7483 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
7484 responseInfo,
7485 manual);
7486 radioService[slotId]->checkReturnStatus(retStatus);
7487 } else {
7488 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
7489 slotId);
7490 }
7491
7492 return 0;
7493 }
7494
setNetworkSelectionModeAutomaticResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7495 int radio_1_6::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
7496 RIL_Errno e, void *response,
7497 size_t responseLen) {
7498 #if VDBG
7499 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
7500 #endif
7501
7502 if (radioService[slotId]->mRadioResponse != NULL) {
7503 RadioResponseInfo responseInfo = {};
7504 populateResponseInfo(responseInfo, serial, responseType, e);
7505 Return<void> retStatus
7506 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
7507 responseInfo);
7508 radioService[slotId]->checkReturnStatus(retStatus);
7509 } else {
7510 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
7511 "== NULL", slotId);
7512 }
7513
7514 return 0;
7515 }
7516
setNetworkSelectionModeManualResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7517 int radio_1_6::setNetworkSelectionModeManualResponse(int slotId,
7518 int responseType, int serial, RIL_Errno e,
7519 void *response, size_t responseLen) {
7520 #if VDBG
7521 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
7522 #endif
7523 RadioResponseInfo responseInfo = {};
7524 populateResponseInfo(responseInfo, serial, responseType, e);
7525
7526 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7527 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
7528 ->setNetworkSelectionModeManualResponse_1_5(responseInfo);
7529 radioService[slotId]->checkReturnStatus(retStatus);
7530 } else if (radioService[slotId]->mRadioResponse != NULL) {
7531 Return<void> retStatus = radioService[slotId]->mRadioResponse
7532 ->setNetworkSelectionModeManualResponse(responseInfo);
7533 radioService[slotId]->checkReturnStatus(retStatus);
7534 } else {
7535 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
7536 "== NULL", slotId);
7537 }
7538
7539 return 0;
7540 }
7541
convertOperatorStatusToInt(const char * str)7542 int convertOperatorStatusToInt(const char *str) {
7543 if (strncmp("unknown", str, 9) == 0) {
7544 return (int) OperatorStatus::UNKNOWN;
7545 } else if (strncmp("available", str, 9) == 0) {
7546 return (int) OperatorStatus::AVAILABLE;
7547 } else if (strncmp("current", str, 9) == 0) {
7548 return (int) OperatorStatus::CURRENT;
7549 } else if (strncmp("forbidden", str, 9) == 0) {
7550 return (int) OperatorStatus::FORBIDDEN;
7551 } else {
7552 return -1;
7553 }
7554 }
7555
getAvailableNetworksResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7556 int radio_1_6::getAvailableNetworksResponse(int slotId,
7557 int responseType, int serial, RIL_Errno e, void *response,
7558 size_t responseLen) {
7559 #if VDBG
7560 RLOGD("getAvailableNetworksResponse: serial %d", serial);
7561 #endif
7562
7563 if (radioService[slotId]->mRadioResponse != NULL) {
7564 RadioResponseInfo responseInfo = {};
7565 populateResponseInfo(responseInfo, serial, responseType, e);
7566 hidl_vec<OperatorInfo> networks;
7567 if ((response == NULL && responseLen != 0)
7568 || responseLen % (4 * sizeof(char *))!= 0) {
7569 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
7570 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7571 } else {
7572 char **resp = (char **) response;
7573 int numStrings = responseLen / sizeof(char *);
7574 networks.resize(numStrings/4);
7575 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
7576 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
7577 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
7578 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
7579 int status = convertOperatorStatusToInt(resp[i + 3]);
7580 if (status == -1) {
7581 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7582 } else {
7583 networks[j].status = (OperatorStatus) status;
7584 }
7585 }
7586 }
7587 Return<void> retStatus
7588 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
7589 networks);
7590 radioService[slotId]->checkReturnStatus(retStatus);
7591 } else {
7592 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
7593 slotId);
7594 }
7595
7596 return 0;
7597 }
7598
startDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7599 int radio_1_6::startDtmfResponse(int slotId,
7600 int responseType, int serial, RIL_Errno e,
7601 void *response, size_t responseLen) {
7602 #if VDBG
7603 RLOGD("startDtmfResponse: serial %d", serial);
7604 #endif
7605
7606 if (radioService[slotId]->mRadioResponse != NULL) {
7607 RadioResponseInfo responseInfo = {};
7608 populateResponseInfo(responseInfo, serial, responseType, e);
7609 Return<void> retStatus
7610 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
7611 radioService[slotId]->checkReturnStatus(retStatus);
7612 } else {
7613 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7614 }
7615
7616 return 0;
7617 }
7618
stopDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7619 int radio_1_6::stopDtmfResponse(int slotId,
7620 int responseType, int serial, RIL_Errno e,
7621 void *response, size_t responseLen) {
7622 #if VDBG
7623 RLOGD("stopDtmfResponse: serial %d", serial);
7624 #endif
7625
7626 if (radioService[slotId]->mRadioResponse != NULL) {
7627 RadioResponseInfo responseInfo = {};
7628 populateResponseInfo(responseInfo, serial, responseType, e);
7629 Return<void> retStatus
7630 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
7631 radioService[slotId]->checkReturnStatus(retStatus);
7632 } else {
7633 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7634 }
7635
7636 return 0;
7637 }
7638
getBasebandVersionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7639 int radio_1_6::getBasebandVersionResponse(int slotId,
7640 int responseType, int serial, RIL_Errno e,
7641 void *response, size_t responseLen) {
7642 #if VDBG
7643 RLOGD("getBasebandVersionResponse: serial %d", serial);
7644 #endif
7645
7646 if (radioService[slotId]->mRadioResponse != NULL) {
7647 RadioResponseInfo responseInfo = {};
7648 populateResponseInfo(responseInfo, serial, responseType, e);
7649 Return<void> retStatus
7650 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
7651 convertCharPtrToHidlString((char *) response));
7652 radioService[slotId]->checkReturnStatus(retStatus);
7653 } else {
7654 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7655 }
7656
7657 return 0;
7658 }
7659
separateConnectionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7660 int radio_1_6::separateConnectionResponse(int slotId,
7661 int responseType, int serial, RIL_Errno e,
7662 void *response, size_t responseLen) {
7663 #if VDBG
7664 RLOGD("separateConnectionResponse: serial %d", serial);
7665 #endif
7666
7667 if (radioService[slotId]->mRadioResponse != NULL) {
7668 RadioResponseInfo responseInfo = {};
7669 populateResponseInfo(responseInfo, serial, responseType, e);
7670 Return<void> retStatus
7671 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
7672 radioService[slotId]->checkReturnStatus(retStatus);
7673 } else {
7674 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
7675 slotId);
7676 }
7677
7678 return 0;
7679 }
7680
setMuteResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7681 int radio_1_6::setMuteResponse(int slotId,
7682 int responseType, int serial, RIL_Errno e,
7683 void *response, size_t responseLen) {
7684 #if VDBG
7685 RLOGD("setMuteResponse: serial %d", serial);
7686 #endif
7687
7688 if (radioService[slotId]->mRadioResponse != NULL) {
7689 RadioResponseInfo responseInfo = {};
7690 populateResponseInfo(responseInfo, serial, responseType, e);
7691 Return<void> retStatus
7692 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
7693 radioService[slotId]->checkReturnStatus(retStatus);
7694 } else {
7695 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7696 }
7697
7698 return 0;
7699 }
7700
getMuteResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7701 int radio_1_6::getMuteResponse(int slotId,
7702 int responseType, int serial, RIL_Errno e, void *response,
7703 size_t responseLen) {
7704 #if VDBG
7705 RLOGD("getMuteResponse: serial %d", serial);
7706 #endif
7707
7708 if (radioService[slotId]->mRadioResponse != NULL) {
7709 RadioResponseInfo responseInfo = {};
7710 populateResponseInfo(responseInfo, serial, responseType, e);
7711 bool enable = false;
7712 if (response == NULL || responseLen != sizeof(int)) {
7713 RLOGE("getMuteResponse Invalid response: NULL");
7714 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7715 } else {
7716 int *pInt = (int *) response;
7717 enable = pInt[0] == 1 ? true : false;
7718 }
7719 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
7720 enable);
7721 radioService[slotId]->checkReturnStatus(retStatus);
7722 } else {
7723 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7724 }
7725
7726 return 0;
7727 }
7728
getClipResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7729 int radio_1_6::getClipResponse(int slotId,
7730 int responseType, int serial, RIL_Errno e,
7731 void *response, size_t responseLen) {
7732 #if VDBG
7733 RLOGD("getClipResponse: serial %d", serial);
7734 #endif
7735
7736 if (radioService[slotId]->mRadioResponse != NULL) {
7737 RadioResponseInfo responseInfo = {};
7738 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
7739 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
7740 (ClipStatus) ret);
7741 radioService[slotId]->checkReturnStatus(retStatus);
7742 } else {
7743 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7744 }
7745
7746 return 0;
7747 }
7748
getDataCallListResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7749 int radio_1_6::getDataCallListResponse(int slotId, int responseType, int serial, RIL_Errno e,
7750 void* response, size_t responseLen) {
7751 #if VDBG
7752 RLOGD("getDataCallListResponse: serial %d", serial);
7753 #endif
7754
7755 if (radioService[slotId]->mRadioResponse != NULL ||
7756 radioService[slotId]->mRadioResponseV1_4 != NULL ||
7757 radioService[slotId]->mRadioResponseV1_5 != NULL ||
7758 radioService[slotId]->mRadioResponseV1_6 != NULL) {
7759 V1_6::RadioResponseInfo responseInfo16 = {};
7760 RadioResponseInfo responseInfo = {};
7761 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
7762 populateResponseInfo_1_6(responseInfo16, serial, responseType, e);
7763 } else {
7764 populateResponseInfo(responseInfo, serial, responseType, e);
7765 }
7766
7767 if ((response == NULL && responseLen != 0)
7768 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
7769 RLOGE("getDataCallListResponse: invalid response");
7770 if (e == RIL_E_SUCCESS) {
7771 responseInfo16.error = V1_6::RadioError::INVALID_RESPONSE;
7772 responseInfo.error = RadioError::INVALID_RESPONSE;
7773 }
7774 } else {
7775 Return<void> retStatus;
7776 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
7777 hidl_vec<V1_6::SetupDataCallResult> ret;
7778 convertRilDataCallListToHal_1_6(response, responseLen, ret);
7779 retStatus = radioService[slotId]->mRadioResponseV1_6->getDataCallListResponse_1_6(
7780 responseInfo16, ret);
7781 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7782 hidl_vec<V1_5::SetupDataCallResult> ret;
7783 convertRilDataCallListToHal_1_5(response, responseLen, ret);
7784 retStatus = radioService[slotId]->mRadioResponseV1_5->getDataCallListResponse_1_5(
7785 responseInfo, ret);
7786 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7787 hidl_vec<V1_4::SetupDataCallResult> ret;
7788 convertRilDataCallListToHal_1_4(response, responseLen, ret);
7789 retStatus = radioService[slotId]->mRadioResponseV1_4->getDataCallListResponse_1_4(
7790 responseInfo, ret);
7791 } else {
7792 hidl_vec<SetupDataCallResult> ret;
7793 convertRilDataCallListToHal(response, responseLen, ret);
7794 retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
7795 responseInfo, ret);
7796 }
7797 radioService[slotId]->checkReturnStatus(retStatus);
7798 }
7799 } else {
7800 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7801 }
7802
7803 return 0;
7804 }
7805
setSuppServiceNotificationsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7806 int radio_1_6::setSuppServiceNotificationsResponse(int slotId,
7807 int responseType, int serial, RIL_Errno e,
7808 void *response, size_t responseLen) {
7809 #if VDBG
7810 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
7811 #endif
7812
7813 if (radioService[slotId]->mRadioResponse != NULL) {
7814 RadioResponseInfo responseInfo = {};
7815 populateResponseInfo(responseInfo, serial, responseType, e);
7816 Return<void> retStatus
7817 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
7818 responseInfo);
7819 radioService[slotId]->checkReturnStatus(retStatus);
7820 } else {
7821 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
7822 "== NULL", slotId);
7823 }
7824
7825 return 0;
7826 }
7827
deleteSmsOnSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7828 int radio_1_6::deleteSmsOnSimResponse(int slotId,
7829 int responseType, int serial, RIL_Errno e,
7830 void *response, size_t responseLen) {
7831 #if VDBG
7832 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
7833 #endif
7834
7835 if (radioService[slotId]->mRadioResponse != NULL) {
7836 RadioResponseInfo responseInfo = {};
7837 populateResponseInfo(responseInfo, serial, responseType, e);
7838 Return<void> retStatus
7839 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
7840 radioService[slotId]->checkReturnStatus(retStatus);
7841 } else {
7842 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7843 }
7844
7845 return 0;
7846 }
7847
setBandModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7848 int radio_1_6::setBandModeResponse(int slotId,
7849 int responseType, int serial, RIL_Errno e,
7850 void *response, size_t responseLen) {
7851 #if VDBG
7852 RLOGD("setBandModeResponse: serial %d", serial);
7853 #endif
7854
7855 if (radioService[slotId]->mRadioResponse != NULL) {
7856 RadioResponseInfo responseInfo = {};
7857 populateResponseInfo(responseInfo, serial, responseType, e);
7858 Return<void> retStatus
7859 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
7860 radioService[slotId]->checkReturnStatus(retStatus);
7861 } else {
7862 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7863 }
7864
7865 return 0;
7866 }
7867
writeSmsToSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7868 int radio_1_6::writeSmsToSimResponse(int slotId,
7869 int responseType, int serial, RIL_Errno e,
7870 void *response, size_t responseLen) {
7871 #if VDBG
7872 RLOGD("writeSmsToSimResponse: serial %d", serial);
7873 #endif
7874
7875 if (radioService[slotId]->mRadioResponse != NULL) {
7876 RadioResponseInfo responseInfo = {};
7877 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
7878 Return<void> retStatus
7879 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
7880 radioService[slotId]->checkReturnStatus(retStatus);
7881 } else {
7882 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7883 }
7884
7885 return 0;
7886 }
7887
getAvailableBandModesResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7888 int radio_1_6::getAvailableBandModesResponse(int slotId,
7889 int responseType, int serial, RIL_Errno e, void *response,
7890 size_t responseLen) {
7891 #if VDBG
7892 RLOGD("getAvailableBandModesResponse: serial %d", serial);
7893 #endif
7894
7895 if (radioService[slotId]->mRadioResponse != NULL) {
7896 RadioResponseInfo responseInfo = {};
7897 populateResponseInfo(responseInfo, serial, responseType, e);
7898 hidl_vec<RadioBandMode> modes;
7899 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
7900 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
7901 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7902 } else {
7903 int *pInt = (int *) response;
7904 int numInts = responseLen / sizeof(int);
7905 modes.resize(numInts);
7906 for (int i = 0; i < numInts; i++) {
7907 modes[i] = (RadioBandMode) pInt[i];
7908 }
7909 }
7910 Return<void> retStatus
7911 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
7912 modes);
7913 radioService[slotId]->checkReturnStatus(retStatus);
7914 } else {
7915 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
7916 slotId);
7917 }
7918
7919 return 0;
7920 }
7921
sendEnvelopeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7922 int radio_1_6::sendEnvelopeResponse(int slotId,
7923 int responseType, int serial, RIL_Errno e,
7924 void *response, size_t responseLen) {
7925 #if VDBG
7926 RLOGD("sendEnvelopeResponse: serial %d", serial);
7927 #endif
7928
7929 if (radioService[slotId]->mRadioResponse != NULL) {
7930 RadioResponseInfo responseInfo = {};
7931 populateResponseInfo(responseInfo, serial, responseType, e);
7932 Return<void> retStatus
7933 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
7934 convertCharPtrToHidlString((char *) response));
7935 radioService[slotId]->checkReturnStatus(retStatus);
7936 } else {
7937 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7938 }
7939
7940 return 0;
7941 }
7942
sendTerminalResponseToSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7943 int radio_1_6::sendTerminalResponseToSimResponse(int slotId,
7944 int responseType, int serial, RIL_Errno e,
7945 void *response, size_t responseLen) {
7946 #if VDBG
7947 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
7948 #endif
7949
7950 if (radioService[slotId]->mRadioResponse != NULL) {
7951 RadioResponseInfo responseInfo = {};
7952 populateResponseInfo(responseInfo, serial, responseType, e);
7953 Return<void> retStatus
7954 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
7955 responseInfo);
7956 radioService[slotId]->checkReturnStatus(retStatus);
7957 } else {
7958 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
7959 slotId);
7960 }
7961
7962 return 0;
7963 }
7964
handleStkCallSetupRequestFromSimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7965 int radio_1_6::handleStkCallSetupRequestFromSimResponse(int slotId,
7966 int responseType, int serial,
7967 RIL_Errno e, void *response,
7968 size_t responseLen) {
7969 #if VDBG
7970 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
7971 #endif
7972
7973 if (radioService[slotId]->mRadioResponse != NULL) {
7974 RadioResponseInfo responseInfo = {};
7975 populateResponseInfo(responseInfo, serial, responseType, e);
7976 Return<void> retStatus
7977 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
7978 responseInfo);
7979 radioService[slotId]->checkReturnStatus(retStatus);
7980 } else {
7981 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
7982 "== NULL", slotId);
7983 }
7984
7985 return 0;
7986 }
7987
explicitCallTransferResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)7988 int radio_1_6::explicitCallTransferResponse(int slotId,
7989 int responseType, int serial, RIL_Errno e,
7990 void *response, size_t responseLen) {
7991 #if VDBG
7992 RLOGD("explicitCallTransferResponse: serial %d", serial);
7993 #endif
7994
7995 if (radioService[slotId]->mRadioResponse != NULL) {
7996 RadioResponseInfo responseInfo = {};
7997 populateResponseInfo(responseInfo, serial, responseType, e);
7998 Return<void> retStatus
7999 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
8000 radioService[slotId]->checkReturnStatus(retStatus);
8001 } else {
8002 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
8003 slotId);
8004 }
8005
8006 return 0;
8007 }
8008
setPreferredNetworkTypeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8009 int radio_1_6::setPreferredNetworkTypeResponse(int slotId,
8010 int responseType, int serial, RIL_Errno e,
8011 void *response, size_t responseLen) {
8012 #if VDBG
8013 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
8014 #endif
8015
8016 if (radioService[slotId]->mRadioResponse != NULL) {
8017 RadioResponseInfo responseInfo = {};
8018 populateResponseInfo(responseInfo, serial, responseType, e);
8019 Return<void> retStatus
8020 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
8021 responseInfo);
8022 radioService[slotId]->checkReturnStatus(retStatus);
8023 } else {
8024 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
8025 slotId);
8026 }
8027
8028 return 0;
8029 }
8030
setAllowedNetworkTypesBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8031 int radio_1_6::setAllowedNetworkTypesBitmapResponse(int slotId,
8032 int responseType, int serial, RIL_Errno e,
8033 void *response, size_t responseLen) {
8034 #if VDBG
8035 RLOGD("setAllowedNetworkTypesBitmapResponse: serial %d", serial);
8036 #endif
8037
8038 V1_6::RadioResponseInfo responseInfo = {};
8039 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
8040
8041 // If we don't have a radio service, there's nothing we can do
8042 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
8043 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
8044 return 0;
8045 }
8046
8047 Return<void> retStatus =
8048 radioService[slotId]->mRadioResponseV1_6->setAllowedNetworkTypesBitmapResponse(
8049 responseInfo);
8050 radioService[slotId]->checkReturnStatus(retStatus);
8051 return 0;
8052 }
8053
getAllowedNetworkTypesBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8054 int radio_1_6::getAllowedNetworkTypesBitmapResponse(int slotId,
8055 int responseType, int serial, RIL_Errno e,
8056 void *response, size_t responseLen) {
8057 #if VDBG
8058 RLOGD("getAllowedNetworkTypesBitmapResponse: serial %d", serial);
8059 #endif
8060
8061 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
8062 V1_6::RadioResponseInfo responseInfo = {};
8063 int ret = responseInt_1_6(responseInfo, serial, responseType, e, response, responseLen);
8064 Return<void> retStatus
8065 = radioService[slotId]->mRadioResponseV1_6->getAllowedNetworkTypesBitmapResponse(
8066 responseInfo,
8067 (const ::android::hardware::hidl_bitfield<
8068 ::android::hardware::radio::V1_4::RadioAccessFamily>) ret);
8069 radioService[slotId]->checkReturnStatus(retStatus);
8070 } else {
8071 RLOGE("getAllowedNetworkTypesBitmapResponse: radioService[%d]->mRadioResponseV1_6 == NULL",
8072 slotId);
8073 }
8074
8075 return 0;
8076 }
8077
getPreferredNetworkTypeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8078 int radio_1_6::getPreferredNetworkTypeResponse(int slotId,
8079 int responseType, int serial, RIL_Errno e,
8080 void *response, size_t responseLen) {
8081 #if VDBG
8082 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
8083 #endif
8084
8085 if (radioService[slotId]->mRadioResponse != NULL) {
8086 RadioResponseInfo responseInfo = {};
8087 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8088 Return<void> retStatus
8089 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
8090 responseInfo, (PreferredNetworkType) ret);
8091 radioService[slotId]->checkReturnStatus(retStatus);
8092 } else {
8093 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
8094 slotId);
8095 }
8096
8097 return 0;
8098 }
8099
setPreferredNetworkTypeBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8100 int radio_1_6::setPreferredNetworkTypeBitmapResponse(int slotId,
8101 int responseType, int serial, RIL_Errno e,
8102 void *response, size_t responseLen) {
8103 #if VDBG
8104 RLOGD("setPreferredNetworkTypeBitmapResponse: serial %d", serial);
8105 #endif
8106
8107 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
8108 RadioResponseInfo responseInfo = {};
8109 populateResponseInfo(responseInfo, serial, responseType, e);
8110 Return<void> retStatus
8111 = radioService[slotId]->mRadioResponseV1_4->setPreferredNetworkTypeBitmapResponse(
8112 responseInfo);
8113 radioService[slotId]->checkReturnStatus(retStatus);
8114 } else {
8115 RLOGE("setPreferredNetworkTypeBitmapResponse: radioService[%d]->mRadioResponseV1_4 == NULL",
8116 slotId);
8117 }
8118
8119 return 0;
8120 }
8121
8122
getPreferredNetworkTypeBitmapResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8123 int radio_1_6::getPreferredNetworkTypeBitmapResponse(int slotId,
8124 int responseType, int serial, RIL_Errno e,
8125 void *response, size_t responseLen) {
8126 #if VDBG
8127 RLOGD("getPreferredNetworkTypeBitmapResponse: serial %d", serial);
8128 #endif
8129
8130 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
8131 RadioResponseInfo responseInfo = {};
8132 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8133 Return<void> retStatus
8134 = radioService[slotId]->mRadioResponseV1_4->getPreferredNetworkTypeBitmapResponse(
8135 responseInfo,
8136 (const ::android::hardware::hidl_bitfield<
8137 ::android::hardware::radio::V1_4::RadioAccessFamily>) ret);
8138 radioService[slotId]->checkReturnStatus(retStatus);
8139 } else {
8140 RLOGE("getPreferredNetworkTypeBitmapResponse: radioService[%d]->mRadioResponseV1_4 == NULL",
8141 slotId);
8142 }
8143
8144 return 0;
8145 }
8146
getNeighboringCidsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8147 int radio_1_6::getNeighboringCidsResponse(int slotId,
8148 int responseType, int serial, RIL_Errno e,
8149 void *response, size_t responseLen) {
8150 #if VDBG
8151 RLOGD("getNeighboringCidsResponse: serial %d", serial);
8152 #endif
8153
8154 if (radioService[slotId]->mRadioResponse != NULL) {
8155 RadioResponseInfo responseInfo = {};
8156 populateResponseInfo(responseInfo, serial, responseType, e);
8157 hidl_vec<NeighboringCell> cells;
8158
8159 if ((response == NULL && responseLen != 0)
8160 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
8161 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
8162 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8163 } else {
8164 int num = responseLen / sizeof(RIL_NeighboringCell *);
8165 cells.resize(num);
8166 for (int i = 0 ; i < num; i++) {
8167 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
8168 cells[i].cid = convertCharPtrToHidlString(resp->cid);
8169 cells[i].rssi = resp->rssi;
8170 }
8171 }
8172
8173 Return<void> retStatus
8174 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
8175 cells);
8176 radioService[slotId]->checkReturnStatus(retStatus);
8177 } else {
8178 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
8179 slotId);
8180 }
8181
8182 return 0;
8183 }
8184
setLocationUpdatesResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8185 int radio_1_6::setLocationUpdatesResponse(int slotId,
8186 int responseType, int serial, RIL_Errno e,
8187 void *response, size_t responseLen) {
8188 #if VDBG
8189 RLOGD("setLocationUpdatesResponse: serial %d", serial);
8190 #endif
8191
8192 if (radioService[slotId]->mRadioResponse != NULL) {
8193 RadioResponseInfo responseInfo = {};
8194 populateResponseInfo(responseInfo, serial, responseType, e);
8195 Return<void> retStatus
8196 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
8197 radioService[slotId]->checkReturnStatus(retStatus);
8198 } else {
8199 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
8200 slotId);
8201 }
8202
8203 return 0;
8204 }
8205
setCdmaSubscriptionSourceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8206 int radio_1_6::setCdmaSubscriptionSourceResponse(int slotId,
8207 int responseType, int serial, RIL_Errno e,
8208 void *response, size_t responseLen) {
8209 #if VDBG
8210 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
8211 #endif
8212
8213 if (radioService[slotId]->mRadioResponse != NULL) {
8214 RadioResponseInfo responseInfo = {};
8215 populateResponseInfo(responseInfo, serial, responseType, e);
8216 Return<void> retStatus
8217 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
8218 responseInfo);
8219 radioService[slotId]->checkReturnStatus(retStatus);
8220 } else {
8221 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
8222 slotId);
8223 }
8224
8225 return 0;
8226 }
8227
setCdmaRoamingPreferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8228 int radio_1_6::setCdmaRoamingPreferenceResponse(int slotId,
8229 int responseType, int serial, RIL_Errno e,
8230 void *response, size_t responseLen) {
8231 #if VDBG
8232 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
8233 #endif
8234
8235 if (radioService[slotId]->mRadioResponse != NULL) {
8236 RadioResponseInfo responseInfo = {};
8237 populateResponseInfo(responseInfo, serial, responseType, e);
8238 Return<void> retStatus
8239 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
8240 responseInfo);
8241 radioService[slotId]->checkReturnStatus(retStatus);
8242 } else {
8243 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
8244 slotId);
8245 }
8246
8247 return 0;
8248 }
8249
getCdmaRoamingPreferenceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8250 int radio_1_6::getCdmaRoamingPreferenceResponse(int slotId,
8251 int responseType, int serial, RIL_Errno e,
8252 void *response, size_t responseLen) {
8253 #if VDBG
8254 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
8255 #endif
8256
8257 if (radioService[slotId]->mRadioResponse != NULL) {
8258 RadioResponseInfo responseInfo = {};
8259 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8260 Return<void> retStatus
8261 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
8262 responseInfo, (CdmaRoamingType) ret);
8263 radioService[slotId]->checkReturnStatus(retStatus);
8264 } else {
8265 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
8266 slotId);
8267 }
8268
8269 return 0;
8270 }
8271
setTTYModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8272 int radio_1_6::setTTYModeResponse(int slotId,
8273 int responseType, int serial, RIL_Errno e,
8274 void *response, size_t responseLen) {
8275 #if VDBG
8276 RLOGD("setTTYModeResponse: serial %d", serial);
8277 #endif
8278
8279 if (radioService[slotId]->mRadioResponse != NULL) {
8280 RadioResponseInfo responseInfo = {};
8281 populateResponseInfo(responseInfo, serial, responseType, e);
8282 Return<void> retStatus
8283 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
8284 radioService[slotId]->checkReturnStatus(retStatus);
8285 } else {
8286 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8287 }
8288
8289 return 0;
8290 }
8291
getTTYModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8292 int radio_1_6::getTTYModeResponse(int slotId,
8293 int responseType, int serial, RIL_Errno e,
8294 void *response, size_t responseLen) {
8295 #if VDBG
8296 RLOGD("getTTYModeResponse: serial %d", serial);
8297 #endif
8298
8299 if (radioService[slotId]->mRadioResponse != NULL) {
8300 RadioResponseInfo responseInfo = {};
8301 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8302 Return<void> retStatus
8303 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
8304 (TtyMode) ret);
8305 radioService[slotId]->checkReturnStatus(retStatus);
8306 } else {
8307 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8308 }
8309
8310 return 0;
8311 }
8312
setPreferredVoicePrivacyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8313 int radio_1_6::setPreferredVoicePrivacyResponse(int slotId,
8314 int responseType, int serial, RIL_Errno e,
8315 void *response, size_t responseLen) {
8316 #if VDBG
8317 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
8318 #endif
8319
8320 if (radioService[slotId]->mRadioResponse != NULL) {
8321 RadioResponseInfo responseInfo = {};
8322 populateResponseInfo(responseInfo, serial, responseType, e);
8323 Return<void> retStatus
8324 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
8325 responseInfo);
8326 radioService[slotId]->checkReturnStatus(retStatus);
8327 } else {
8328 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
8329 slotId);
8330 }
8331
8332 return 0;
8333 }
8334
getPreferredVoicePrivacyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8335 int radio_1_6::getPreferredVoicePrivacyResponse(int slotId,
8336 int responseType, int serial, RIL_Errno e,
8337 void *response, size_t responseLen) {
8338 #if VDBG
8339 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
8340 #endif
8341
8342 if (radioService[slotId]->mRadioResponse != NULL) {
8343 RadioResponseInfo responseInfo = {};
8344 populateResponseInfo(responseInfo, serial, responseType, e);
8345 bool enable = false;
8346 int numInts = responseLen / sizeof(int);
8347 if (response == NULL || numInts != 1) {
8348 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
8349 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8350 } else {
8351 int *pInt = (int *) response;
8352 enable = pInt[0] == 1 ? true : false;
8353 }
8354 Return<void> retStatus
8355 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
8356 responseInfo, enable);
8357 radioService[slotId]->checkReturnStatus(retStatus);
8358 } else {
8359 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
8360 slotId);
8361 }
8362
8363 return 0;
8364 }
8365
sendCDMAFeatureCodeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8366 int radio_1_6::sendCDMAFeatureCodeResponse(int slotId,
8367 int responseType, int serial, RIL_Errno e,
8368 void *response, size_t responseLen) {
8369 #if VDBG
8370 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
8371 #endif
8372
8373 if (radioService[slotId]->mRadioResponse != NULL) {
8374 RadioResponseInfo responseInfo = {};
8375 populateResponseInfo(responseInfo, serial, responseType, e);
8376 Return<void> retStatus
8377 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
8378 radioService[slotId]->checkReturnStatus(retStatus);
8379 } else {
8380 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
8381 slotId);
8382 }
8383
8384 return 0;
8385 }
8386
sendBurstDtmfResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8387 int radio_1_6::sendBurstDtmfResponse(int slotId,
8388 int responseType, int serial, RIL_Errno e,
8389 void *response, size_t responseLen) {
8390 #if VDBG
8391 RLOGD("sendBurstDtmfResponse: serial %d", serial);
8392 #endif
8393
8394 if (radioService[slotId]->mRadioResponse != NULL) {
8395 RadioResponseInfo responseInfo = {};
8396 populateResponseInfo(responseInfo, serial, responseType, e);
8397 Return<void> retStatus
8398 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
8399 radioService[slotId]->checkReturnStatus(retStatus);
8400 } else {
8401 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8402 }
8403
8404 return 0;
8405 }
8406
sendCdmaSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8407 int radio_1_6::sendCdmaSmsResponse(int slotId,
8408 int responseType, int serial, RIL_Errno e, void *response,
8409 size_t responseLen) {
8410 #if VDBG
8411 RLOGD("sendCdmaSmsResponse: serial %d", serial);
8412 #endif
8413
8414 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
8415 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
8416 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e,
8417 response, responseLen);
8418
8419 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
8420 ->sendCdmaSmsResponse_1_6(responseInfo_1_6, result);
8421 radioService[slotId]->checkReturnStatus(retStatus);
8422 } else if (radioService[slotId]->mRadioResponse != NULL) {
8423 RadioResponseInfo responseInfo = {};
8424 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
8425 responseLen);
8426
8427 Return<void> retStatus
8428 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
8429 radioService[slotId]->checkReturnStatus(retStatus);
8430 } else {
8431 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8432 }
8433
8434 return 0;
8435 }
8436
acknowledgeLastIncomingCdmaSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8437 int radio_1_6::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
8438 int responseType, int serial, RIL_Errno e,
8439 void *response, size_t responseLen) {
8440 #if VDBG
8441 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
8442 #endif
8443
8444 if (radioService[slotId]->mRadioResponse != NULL) {
8445 RadioResponseInfo responseInfo = {};
8446 populateResponseInfo(responseInfo, serial, responseType, e);
8447 Return<void> retStatus
8448 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
8449 responseInfo);
8450 radioService[slotId]->checkReturnStatus(retStatus);
8451 } else {
8452 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
8453 "== NULL", slotId);
8454 }
8455
8456 return 0;
8457 }
8458
getGsmBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8459 int radio_1_6::getGsmBroadcastConfigResponse(int slotId,
8460 int responseType, int serial, RIL_Errno e,
8461 void *response, size_t responseLen) {
8462 #if VDBG
8463 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
8464 #endif
8465
8466 if (radioService[slotId]->mRadioResponse != NULL) {
8467 RadioResponseInfo responseInfo = {};
8468 populateResponseInfo(responseInfo, serial, responseType, e);
8469 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
8470
8471 if ((response == NULL && responseLen != 0)
8472 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
8473 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
8474 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8475 } else {
8476 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
8477 configs.resize(num);
8478 for (int i = 0 ; i < num; i++) {
8479 RIL_GSM_BroadcastSmsConfigInfo *resp =
8480 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
8481 configs[i].fromServiceId = resp->fromServiceId;
8482 configs[i].toServiceId = resp->toServiceId;
8483 configs[i].fromCodeScheme = resp->fromCodeScheme;
8484 configs[i].toCodeScheme = resp->toCodeScheme;
8485 configs[i].selected = resp->selected == 1 ? true : false;
8486 }
8487 }
8488
8489 Return<void> retStatus
8490 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
8491 configs);
8492 radioService[slotId]->checkReturnStatus(retStatus);
8493 } else {
8494 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8495 slotId);
8496 }
8497
8498 return 0;
8499 }
8500
setGsmBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8501 int radio_1_6::setGsmBroadcastConfigResponse(int slotId,
8502 int responseType, int serial, RIL_Errno e,
8503 void *response, size_t responseLen) {
8504 #if VDBG
8505 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
8506 #endif
8507
8508 if (radioService[slotId]->mRadioResponse != NULL) {
8509 RadioResponseInfo responseInfo = {};
8510 populateResponseInfo(responseInfo, serial, responseType, e);
8511 Return<void> retStatus
8512 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
8513 radioService[slotId]->checkReturnStatus(retStatus);
8514 } else {
8515 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8516 slotId);
8517 }
8518
8519 return 0;
8520 }
8521
setGsmBroadcastActivationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8522 int radio_1_6::setGsmBroadcastActivationResponse(int slotId,
8523 int responseType, int serial, RIL_Errno e,
8524 void *response, size_t responseLen) {
8525 #if VDBG
8526 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
8527 #endif
8528
8529 if (radioService[slotId]->mRadioResponse != NULL) {
8530 RadioResponseInfo responseInfo = {};
8531 populateResponseInfo(responseInfo, serial, responseType, e);
8532 Return<void> retStatus
8533 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
8534 responseInfo);
8535 radioService[slotId]->checkReturnStatus(retStatus);
8536 } else {
8537 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
8538 slotId);
8539 }
8540
8541 return 0;
8542 }
8543
getCdmaBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8544 int radio_1_6::getCdmaBroadcastConfigResponse(int slotId,
8545 int responseType, int serial, RIL_Errno e,
8546 void *response, size_t responseLen) {
8547 #if VDBG
8548 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
8549 #endif
8550
8551 if (radioService[slotId]->mRadioResponse != NULL) {
8552 RadioResponseInfo responseInfo = {};
8553 populateResponseInfo(responseInfo, serial, responseType, e);
8554 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
8555
8556 if ((response == NULL && responseLen != 0)
8557 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
8558 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
8559 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8560 } else {
8561 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
8562 configs.resize(num);
8563 for (int i = 0 ; i < num; i++) {
8564 RIL_CDMA_BroadcastSmsConfigInfo *resp =
8565 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
8566 configs[i].serviceCategory = resp->service_category;
8567 configs[i].language = resp->language;
8568 configs[i].selected = resp->selected == 1 ? true : false;
8569 }
8570 }
8571
8572 Return<void> retStatus
8573 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
8574 configs);
8575 radioService[slotId]->checkReturnStatus(retStatus);
8576 } else {
8577 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8578 slotId);
8579 }
8580
8581 return 0;
8582 }
8583
setCdmaBroadcastConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8584 int radio_1_6::setCdmaBroadcastConfigResponse(int slotId,
8585 int responseType, int serial, RIL_Errno e,
8586 void *response, size_t responseLen) {
8587 #if VDBG
8588 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
8589 #endif
8590
8591 if (radioService[slotId]->mRadioResponse != NULL) {
8592 RadioResponseInfo responseInfo = {};
8593 populateResponseInfo(responseInfo, serial, responseType, e);
8594 Return<void> retStatus
8595 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
8596 responseInfo);
8597 radioService[slotId]->checkReturnStatus(retStatus);
8598 } else {
8599 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
8600 slotId);
8601 }
8602
8603 return 0;
8604 }
8605
setCdmaBroadcastActivationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8606 int radio_1_6::setCdmaBroadcastActivationResponse(int slotId,
8607 int responseType, int serial, RIL_Errno e,
8608 void *response, size_t responseLen) {
8609 #if VDBG
8610 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
8611 #endif
8612
8613 if (radioService[slotId]->mRadioResponse != NULL) {
8614 RadioResponseInfo responseInfo = {};
8615 populateResponseInfo(responseInfo, serial, responseType, e);
8616 Return<void> retStatus
8617 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
8618 responseInfo);
8619 radioService[slotId]->checkReturnStatus(retStatus);
8620 } else {
8621 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
8622 slotId);
8623 }
8624
8625 return 0;
8626 }
8627
getCDMASubscriptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8628 int radio_1_6::getCDMASubscriptionResponse(int slotId,
8629 int responseType, int serial, RIL_Errno e, void *response,
8630 size_t responseLen) {
8631 #if VDBG
8632 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
8633 #endif
8634
8635 if (radioService[slotId]->mRadioResponse != NULL) {
8636 RadioResponseInfo responseInfo = {};
8637 populateResponseInfo(responseInfo, serial, responseType, e);
8638
8639 int numStrings = responseLen / sizeof(char *);
8640 hidl_string emptyString;
8641 if (response == NULL || numStrings != 5) {
8642 RLOGE("getOperatorResponse Invalid response: NULL");
8643 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8644 Return<void> retStatus
8645 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
8646 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
8647 radioService[slotId]->checkReturnStatus(retStatus);
8648 } else {
8649 char **resp = (char **) response;
8650 Return<void> retStatus
8651 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
8652 responseInfo,
8653 convertCharPtrToHidlString(resp[0]),
8654 convertCharPtrToHidlString(resp[1]),
8655 convertCharPtrToHidlString(resp[2]),
8656 convertCharPtrToHidlString(resp[3]),
8657 convertCharPtrToHidlString(resp[4]));
8658 radioService[slotId]->checkReturnStatus(retStatus);
8659 }
8660 } else {
8661 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
8662 slotId);
8663 }
8664
8665 return 0;
8666 }
8667
writeSmsToRuimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8668 int radio_1_6::writeSmsToRuimResponse(int slotId,
8669 int responseType, int serial, RIL_Errno e,
8670 void *response, size_t responseLen) {
8671 #if VDBG
8672 RLOGD("writeSmsToRuimResponse: serial %d", serial);
8673 #endif
8674
8675 if (radioService[slotId]->mRadioResponse != NULL) {
8676 RadioResponseInfo responseInfo = {};
8677 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8678 Return<void> retStatus
8679 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
8680 radioService[slotId]->checkReturnStatus(retStatus);
8681 } else {
8682 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8683 }
8684
8685 return 0;
8686 }
8687
deleteSmsOnRuimResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8688 int radio_1_6::deleteSmsOnRuimResponse(int slotId,
8689 int responseType, int serial, RIL_Errno e,
8690 void *response, size_t responseLen) {
8691 #if VDBG
8692 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
8693 #endif
8694
8695 if (radioService[slotId]->mRadioResponse != NULL) {
8696 RadioResponseInfo responseInfo = {};
8697 populateResponseInfo(responseInfo, serial, responseType, e);
8698 Return<void> retStatus
8699 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
8700 radioService[slotId]->checkReturnStatus(retStatus);
8701 } else {
8702 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8703 }
8704
8705 return 0;
8706 }
8707
getDeviceIdentityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8708 int radio_1_6::getDeviceIdentityResponse(int slotId,
8709 int responseType, int serial, RIL_Errno e, void *response,
8710 size_t responseLen) {
8711 #if VDBG
8712 RLOGD("getDeviceIdentityResponse: serial %d", serial);
8713 #endif
8714
8715 if (radioService[slotId]->mRadioResponse != NULL) {
8716 RadioResponseInfo responseInfo = {};
8717 populateResponseInfo(responseInfo, serial, responseType, e);
8718
8719 int numStrings = responseLen / sizeof(char *);
8720 hidl_string emptyString;
8721 if (response == NULL || numStrings != 4) {
8722 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
8723 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8724 Return<void> retStatus
8725 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
8726 emptyString, emptyString, emptyString, emptyString);
8727 radioService[slotId]->checkReturnStatus(retStatus);
8728 } else {
8729 char **resp = (char **) response;
8730 Return<void> retStatus
8731 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
8732 convertCharPtrToHidlString(resp[0]),
8733 convertCharPtrToHidlString(resp[1]),
8734 convertCharPtrToHidlString(resp[2]),
8735 convertCharPtrToHidlString(resp[3]));
8736 radioService[slotId]->checkReturnStatus(retStatus);
8737 }
8738 } else {
8739 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
8740 slotId);
8741 }
8742
8743 return 0;
8744 }
8745
exitEmergencyCallbackModeResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8746 int radio_1_6::exitEmergencyCallbackModeResponse(int slotId,
8747 int responseType, int serial, RIL_Errno e,
8748 void *response, size_t responseLen) {
8749 #if VDBG
8750 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
8751 #endif
8752
8753 if (radioService[slotId]->mRadioResponse != NULL) {
8754 RadioResponseInfo responseInfo = {};
8755 populateResponseInfo(responseInfo, serial, responseType, e);
8756 Return<void> retStatus
8757 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
8758 responseInfo);
8759 radioService[slotId]->checkReturnStatus(retStatus);
8760 } else {
8761 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
8762 slotId);
8763 }
8764
8765 return 0;
8766 }
8767
getSmscAddressResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8768 int radio_1_6::getSmscAddressResponse(int slotId,
8769 int responseType, int serial, RIL_Errno e,
8770 void *response, size_t responseLen) {
8771 #if VDBG
8772 RLOGD("getSmscAddressResponse: serial %d", serial);
8773 #endif
8774
8775 if (radioService[slotId]->mRadioResponse != NULL) {
8776 RadioResponseInfo responseInfo = {};
8777 populateResponseInfo(responseInfo, serial, responseType, e);
8778 Return<void> retStatus
8779 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
8780 convertCharPtrToHidlString((char *) response));
8781 radioService[slotId]->checkReturnStatus(retStatus);
8782 } else {
8783 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8784 }
8785
8786 return 0;
8787 }
8788
setSmscAddressResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8789 int radio_1_6::setSmscAddressResponse(int slotId,
8790 int responseType, int serial, RIL_Errno e,
8791 void *response, size_t responseLen) {
8792 #if VDBG
8793 RLOGD("setSmscAddressResponse: serial %d", serial);
8794 #endif
8795
8796 if (radioService[slotId]->mRadioResponse != NULL) {
8797 RadioResponseInfo responseInfo = {};
8798 populateResponseInfo(responseInfo, serial, responseType, e);
8799 Return<void> retStatus
8800 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
8801 radioService[slotId]->checkReturnStatus(retStatus);
8802 } else {
8803 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8804 }
8805
8806 return 0;
8807 }
8808
reportSmsMemoryStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8809 int radio_1_6::reportSmsMemoryStatusResponse(int slotId,
8810 int responseType, int serial, RIL_Errno e,
8811 void *response, size_t responseLen) {
8812 #if VDBG
8813 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
8814 #endif
8815
8816 if (radioService[slotId]->mRadioResponse != NULL) {
8817 RadioResponseInfo responseInfo = {};
8818 populateResponseInfo(responseInfo, serial, responseType, e);
8819 Return<void> retStatus
8820 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
8821 radioService[slotId]->checkReturnStatus(retStatus);
8822 } else {
8823 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
8824 slotId);
8825 }
8826
8827 return 0;
8828 }
8829
reportStkServiceIsRunningResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8830 int radio_1_6::reportStkServiceIsRunningResponse(int slotId,
8831 int responseType, int serial, RIL_Errno e,
8832 void *response, size_t responseLen) {
8833 #if VDBG
8834 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
8835 #endif
8836
8837 if (radioService[slotId]->mRadioResponse != NULL) {
8838 RadioResponseInfo responseInfo = {};
8839 populateResponseInfo(responseInfo, serial, responseType, e);
8840 Return<void> retStatus = radioService[slotId]->mRadioResponse->
8841 reportStkServiceIsRunningResponse(responseInfo);
8842 radioService[slotId]->checkReturnStatus(retStatus);
8843 } else {
8844 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
8845 slotId);
8846 }
8847
8848 return 0;
8849 }
8850
getCdmaSubscriptionSourceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8851 int radio_1_6::getCdmaSubscriptionSourceResponse(int slotId,
8852 int responseType, int serial, RIL_Errno e,
8853 void *response, size_t responseLen) {
8854 #if VDBG
8855 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
8856 #endif
8857
8858 if (radioService[slotId]->mRadioResponse != NULL) {
8859 RadioResponseInfo responseInfo = {};
8860 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8861 Return<void> retStatus
8862 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
8863 responseInfo, (CdmaSubscriptionSource) ret);
8864 radioService[slotId]->checkReturnStatus(retStatus);
8865 } else {
8866 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
8867 slotId);
8868 }
8869
8870 return 0;
8871 }
8872
requestIsimAuthenticationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8873 int radio_1_6::requestIsimAuthenticationResponse(int slotId,
8874 int responseType, int serial, RIL_Errno e,
8875 void *response, size_t responseLen) {
8876 #if VDBG
8877 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
8878 #endif
8879
8880 if (radioService[slotId]->mRadioResponse != NULL) {
8881 RadioResponseInfo responseInfo = {};
8882 populateResponseInfo(responseInfo, serial, responseType, e);
8883 Return<void> retStatus
8884 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
8885 responseInfo,
8886 convertCharPtrToHidlString((char *) response));
8887 radioService[slotId]->checkReturnStatus(retStatus);
8888 } else {
8889 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
8890 slotId);
8891 }
8892
8893 return 0;
8894 }
8895
acknowledgeIncomingGsmSmsWithPduResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8896 int radio_1_6::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
8897 int responseType,
8898 int serial, RIL_Errno e, void *response,
8899 size_t responseLen) {
8900 #if VDBG
8901 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
8902 #endif
8903
8904 if (radioService[slotId]->mRadioResponse != NULL) {
8905 RadioResponseInfo responseInfo = {};
8906 populateResponseInfo(responseInfo, serial, responseType, e);
8907 Return<void> retStatus
8908 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
8909 responseInfo);
8910 radioService[slotId]->checkReturnStatus(retStatus);
8911 } else {
8912 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
8913 "== NULL", slotId);
8914 }
8915
8916 return 0;
8917 }
8918
sendEnvelopeWithStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8919 int radio_1_6::sendEnvelopeWithStatusResponse(int slotId,
8920 int responseType, int serial, RIL_Errno e, void *response,
8921 size_t responseLen) {
8922 #if VDBG
8923 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
8924 #endif
8925
8926 if (radioService[slotId]->mRadioResponse != NULL) {
8927 RadioResponseInfo responseInfo = {};
8928 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
8929 response, responseLen);
8930
8931 Return<void> retStatus
8932 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
8933 result);
8934 radioService[slotId]->checkReturnStatus(retStatus);
8935 } else {
8936 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
8937 slotId);
8938 }
8939
8940 return 0;
8941 }
8942
getVoiceRadioTechnologyResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8943 int radio_1_6::getVoiceRadioTechnologyResponse(int slotId,
8944 int responseType, int serial, RIL_Errno e,
8945 void *response, size_t responseLen) {
8946 #if VDBG
8947 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
8948 #endif
8949
8950 if (radioService[slotId]->mRadioResponse != NULL) {
8951 RadioResponseInfo responseInfo = {};
8952 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
8953 Return<void> retStatus
8954 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
8955 responseInfo, (RadioTechnology) ret);
8956 radioService[slotId]->checkReturnStatus(retStatus);
8957 } else {
8958 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
8959 slotId);
8960 }
8961
8962 return 0;
8963 }
8964
getCellInfoListResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)8965 int radio_1_6::getCellInfoListResponse(int slotId, int responseType, int serial, RIL_Errno e,
8966 void* response, size_t responseLen) {
8967 #if VDBG
8968 RLOGD("getCellInfoListResponse: serial %d", serial);
8969 #endif
8970 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
8971 V1_6::RadioResponseInfo responseInfo = {};
8972 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
8973 hidl_vec<V1_6::CellInfo> ret;
8974 Return<void> retStatus;
8975 if (response != NULL && responseLen != 0 && responseLen % sizeof(RIL_CellInfo_v16) == 0) {
8976 convertRilCellInfoListToHal_1_6(response, responseLen, ret);
8977 } else {
8978 RLOGE("getCellInfoListResponse_1_6: Invalid response");
8979 if (e == RIL_E_SUCCESS) responseInfo.error = V1_6::RadioError::INVALID_RESPONSE;
8980 }
8981 retStatus = radioService[slotId]->mRadioResponseV1_6->getCellInfoListResponse_1_6(
8982 responseInfo, ret);
8983 radioService[slotId]->checkReturnStatus(retStatus);
8984 } else if (radioService[slotId]->mRadioResponse != NULL ||
8985 radioService[slotId]->mRadioResponseV1_2 != NULL ||
8986 radioService[slotId]->mRadioResponseV1_4 != NULL ||
8987 radioService[slotId]->mRadioResponseV1_5 != NULL) {
8988 RadioResponseInfo responseInfo = {};
8989 populateResponseInfo(responseInfo, serial, responseType, e);
8990 bool error = response == NULL && responseLen != 0;
8991 Return<void> retStatus;
8992 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
8993 hidl_vec<V1_5::CellInfo> ret;
8994 if (!error && responseLen % sizeof(RIL_CellInfo_v16) != 0) {
8995 convertRilCellInfoListToHal_1_5(response, responseLen, ret);
8996 } else {
8997 RLOGE("getCellInfoListResponse_1_5: Invalid response");
8998 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8999 }
9000 retStatus = radioService[slotId]->mRadioResponseV1_5->getCellInfoListResponse_1_5(
9001 responseInfo, ret);
9002 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9003 hidl_vec<V1_4::CellInfo> ret;
9004 if (!error && responseLen % sizeof(RIL_CellInfo_v16) != 0) {
9005 convertRilCellInfoListToHal_1_4(response, responseLen, ret);
9006 } else {
9007 RLOGE("getCellInfoListResponse_1_4: Invalid response");
9008 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9009 }
9010 radioService[slotId]->mRadioResponseV1_4->getCellInfoListResponse_1_4(responseInfo,
9011 ret);
9012 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
9013 hidl_vec<V1_2::CellInfo> ret;
9014 if (!error && responseLen % sizeof(RIL_CellInfo_v12) != 0) {
9015 convertRilCellInfoListToHal_1_2(response, responseLen, ret);
9016 } else {
9017 RLOGE("getCellInfoListResponse_1_2: Invalid response");
9018 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9019 }
9020 radioService[slotId]->mRadioResponseV1_2->getCellInfoListResponse_1_2(responseInfo,
9021 ret);
9022 } else {
9023 hidl_vec<CellInfo> ret;
9024 if (!error && responseLen % sizeof(RIL_CellInfo) != 0) {
9025 convertRilCellInfoListToHal(response, responseLen, ret);
9026 } else {
9027 RLOGE("getCellInfoListResponse: Invalid response");
9028 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9029 }
9030 radioService[slotId]->mRadioResponse->getCellInfoListResponse(responseInfo, ret);
9031 }
9032 radioService[slotId]->checkReturnStatus(retStatus);
9033 } else {
9034 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9035 }
9036
9037 return 0;
9038 }
9039
setCellInfoListRateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9040 int radio_1_6::setCellInfoListRateResponse(int slotId,
9041 int responseType,
9042 int serial, RIL_Errno e, void *response,
9043 size_t responseLen) {
9044 #if VDBG
9045 RLOGD("setCellInfoListRateResponse: serial %d", serial);
9046 #endif
9047
9048 if (radioService[slotId]->mRadioResponse != NULL) {
9049 RadioResponseInfo responseInfo = {};
9050 populateResponseInfo(responseInfo, serial, responseType, e);
9051 Return<void> retStatus
9052 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
9053 radioService[slotId]->checkReturnStatus(retStatus);
9054 } else {
9055 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
9056 slotId);
9057 }
9058
9059 return 0;
9060 }
9061
setInitialAttachApnResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9062 int radio_1_6::setInitialAttachApnResponse(int slotId, int responseType, int serial, RIL_Errno e,
9063 void* response, size_t responseLen) {
9064 #if VDBG
9065 RLOGD("setInitialAttachApnResponse: serial %d", serial);
9066 #endif
9067
9068 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
9069 RadioResponseInfo responseInfo = {};
9070 populateResponseInfo(responseInfo, serial, responseType, e);
9071 Return<void> retStatus =
9072 radioService[slotId]->mRadioResponseV1_5->setInitialAttachApnResponse_1_5(
9073 responseInfo);
9074 radioService[slotId]->checkReturnStatus(retStatus);
9075 } else if (radioService[slotId]->mRadioResponse != NULL) {
9076 RadioResponseInfo responseInfo = {};
9077 populateResponseInfo(responseInfo, serial, responseType, e);
9078 Return<void> retStatus =
9079 radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
9080 radioService[slotId]->checkReturnStatus(retStatus);
9081 } else {
9082 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9083 }
9084
9085 return 0;
9086 }
9087
getImsRegistrationStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9088 int radio_1_6::getImsRegistrationStateResponse(int slotId,
9089 int responseType, int serial, RIL_Errno e,
9090 void *response, size_t responseLen) {
9091 #if VDBG
9092 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
9093 #endif
9094
9095 if (radioService[slotId]->mRadioResponse != NULL) {
9096 RadioResponseInfo responseInfo = {};
9097 populateResponseInfo(responseInfo, serial, responseType, e);
9098 bool isRegistered = false;
9099 int ratFamily = 0;
9100 int numInts = responseLen / sizeof(int);
9101 if (response == NULL || numInts != 2) {
9102 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
9103 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9104 } else {
9105 int *pInt = (int *) response;
9106 isRegistered = pInt[0] == 1 ? true : false;
9107 ratFamily = pInt[1];
9108 }
9109 Return<void> retStatus
9110 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
9111 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
9112 radioService[slotId]->checkReturnStatus(retStatus);
9113 } else {
9114 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
9115 slotId);
9116 }
9117
9118 return 0;
9119 }
9120
sendImsSmsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9121 int radio_1_6::sendImsSmsResponse(int slotId,
9122 int responseType, int serial, RIL_Errno e, void *response,
9123 size_t responseLen) {
9124 #if VDBG
9125 RLOGD("sendImsSmsResponse: serial %d", serial);
9126 #endif
9127
9128 if (radioService[slotId]->mRadioResponse != NULL) {
9129 RadioResponseInfo responseInfo = {};
9130 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
9131 responseLen);
9132
9133 Return<void> retStatus
9134 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
9135 radioService[slotId]->checkReturnStatus(retStatus);
9136 } else {
9137 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9138 }
9139
9140 return 0;
9141 }
9142
iccTransmitApduBasicChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9143 int radio_1_6::iccTransmitApduBasicChannelResponse(int slotId,
9144 int responseType, int serial, RIL_Errno e,
9145 void *response, size_t responseLen) {
9146 #if VDBG
9147 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
9148 #endif
9149
9150 if (radioService[slotId]->mRadioResponse != NULL) {
9151 RadioResponseInfo responseInfo = {};
9152 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
9153 responseLen);
9154
9155 Return<void> retStatus
9156 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
9157 responseInfo, result);
9158 radioService[slotId]->checkReturnStatus(retStatus);
9159 } else {
9160 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
9161 "== NULL", slotId);
9162 }
9163
9164 return 0;
9165 }
9166
iccOpenLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9167 int radio_1_6::iccOpenLogicalChannelResponse(int slotId,
9168 int responseType, int serial, RIL_Errno e, void *response,
9169 size_t responseLen) {
9170 #if VDBG
9171 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
9172 #endif
9173
9174 if (radioService[slotId]->mRadioResponse != NULL) {
9175 RadioResponseInfo responseInfo = {};
9176 populateResponseInfo(responseInfo, serial, responseType, e);
9177 int channelId = -1;
9178 hidl_vec<int8_t> selectResponse;
9179 int numInts = responseLen / sizeof(int);
9180 if (response == NULL || responseLen % sizeof(int) != 0) {
9181 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
9182 if (response != NULL) {
9183 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9184 }
9185 } else {
9186 int *pInt = (int *) response;
9187 channelId = pInt[0];
9188 selectResponse.resize(numInts - 1);
9189 for (int i = 1; i < numInts; i++) {
9190 selectResponse[i - 1] = (int8_t) pInt[i];
9191 }
9192 }
9193 Return<void> retStatus
9194 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
9195 channelId, selectResponse);
9196 radioService[slotId]->checkReturnStatus(retStatus);
9197 } else {
9198 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
9199 slotId);
9200 }
9201
9202 return 0;
9203 }
9204
iccCloseLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9205 int radio_1_6::iccCloseLogicalChannelResponse(int slotId,
9206 int responseType, int serial, RIL_Errno e,
9207 void *response, size_t responseLen) {
9208 #if VDBG
9209 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
9210 #endif
9211
9212 if (radioService[slotId]->mRadioResponse != NULL) {
9213 RadioResponseInfo responseInfo = {};
9214 populateResponseInfo(responseInfo, serial, responseType, e);
9215 Return<void> retStatus
9216 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
9217 responseInfo);
9218 radioService[slotId]->checkReturnStatus(retStatus);
9219 } else {
9220 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
9221 slotId);
9222 }
9223
9224 return 0;
9225 }
9226
iccTransmitApduLogicalChannelResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9227 int radio_1_6::iccTransmitApduLogicalChannelResponse(int slotId,
9228 int responseType, int serial, RIL_Errno e,
9229 void *response, size_t responseLen) {
9230 #if VDBG
9231 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
9232 #endif
9233
9234 if (radioService[slotId]->mRadioResponse != NULL) {
9235 RadioResponseInfo responseInfo = {};
9236 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
9237 responseLen);
9238
9239 Return<void> retStatus
9240 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
9241 responseInfo, result);
9242 radioService[slotId]->checkReturnStatus(retStatus);
9243 } else {
9244 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
9245 "== NULL", slotId);
9246 }
9247
9248 return 0;
9249 }
9250
nvReadItemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9251 int radio_1_6::nvReadItemResponse(int slotId,
9252 int responseType, int serial, RIL_Errno e,
9253 void *response, size_t responseLen) {
9254 #if VDBG
9255 RLOGD("nvReadItemResponse: serial %d", serial);
9256 #endif
9257
9258 if (radioService[slotId]->mRadioResponse != NULL) {
9259 RadioResponseInfo responseInfo = {};
9260 populateResponseInfo(responseInfo, serial, responseType, e);
9261 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
9262 responseInfo,
9263 convertCharPtrToHidlString((char *) response));
9264 radioService[slotId]->checkReturnStatus(retStatus);
9265 } else {
9266 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9267 }
9268
9269 return 0;
9270 }
9271
nvWriteItemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9272 int radio_1_6::nvWriteItemResponse(int slotId,
9273 int responseType, int serial, RIL_Errno e,
9274 void *response, size_t responseLen) {
9275 #if VDBG
9276 RLOGD("nvWriteItemResponse: serial %d", serial);
9277 #endif
9278
9279 if (radioService[slotId]->mRadioResponse != NULL) {
9280 RadioResponseInfo responseInfo = {};
9281 populateResponseInfo(responseInfo, serial, responseType, e);
9282 Return<void> retStatus
9283 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
9284 radioService[slotId]->checkReturnStatus(retStatus);
9285 } else {
9286 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9287 }
9288
9289 return 0;
9290 }
9291
nvWriteCdmaPrlResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9292 int radio_1_6::nvWriteCdmaPrlResponse(int slotId,
9293 int responseType, int serial, RIL_Errno e,
9294 void *response, size_t responseLen) {
9295 #if VDBG
9296 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
9297 #endif
9298
9299 if (radioService[slotId]->mRadioResponse != NULL) {
9300 RadioResponseInfo responseInfo = {};
9301 populateResponseInfo(responseInfo, serial, responseType, e);
9302 Return<void> retStatus
9303 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
9304 radioService[slotId]->checkReturnStatus(retStatus);
9305 } else {
9306 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9307 }
9308
9309 return 0;
9310 }
9311
nvResetConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9312 int radio_1_6::nvResetConfigResponse(int slotId,
9313 int responseType, int serial, RIL_Errno e,
9314 void *response, size_t responseLen) {
9315 #if VDBG
9316 RLOGD("nvResetConfigResponse: serial %d", serial);
9317 #endif
9318
9319 if (radioService[slotId]->mRadioResponse != NULL) {
9320 RadioResponseInfo responseInfo = {};
9321 populateResponseInfo(responseInfo, serial, responseType, e);
9322 Return<void> retStatus
9323 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
9324 radioService[slotId]->checkReturnStatus(retStatus);
9325 } else {
9326 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9327 }
9328
9329 return 0;
9330 }
9331
setUiccSubscriptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9332 int radio_1_6::setUiccSubscriptionResponse(int slotId,
9333 int responseType, int serial, RIL_Errno e,
9334 void *response, size_t responseLen) {
9335 #if VDBG
9336 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
9337 #endif
9338
9339 if (radioService[slotId]->mRadioResponse != NULL) {
9340 RadioResponseInfo responseInfo = {};
9341 populateResponseInfo(responseInfo, serial, responseType, e);
9342 Return<void> retStatus
9343 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
9344 radioService[slotId]->checkReturnStatus(retStatus);
9345 } else {
9346 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
9347 slotId);
9348 }
9349
9350 return 0;
9351 }
9352
setDataAllowedResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9353 int radio_1_6::setDataAllowedResponse(int slotId,
9354 int responseType, int serial, RIL_Errno e,
9355 void *response, size_t responseLen) {
9356 #if VDBG
9357 RLOGD("setDataAllowedResponse: serial %d", serial);
9358 #endif
9359
9360 if (radioService[slotId]->mRadioResponse != NULL) {
9361 RadioResponseInfo responseInfo = {};
9362 populateResponseInfo(responseInfo, serial, responseType, e);
9363 Return<void> retStatus
9364 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
9365 radioService[slotId]->checkReturnStatus(retStatus);
9366 } else {
9367 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9368 }
9369
9370 return 0;
9371 }
9372
getHardwareConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9373 int radio_1_6::getHardwareConfigResponse(int slotId,
9374 int responseType, int serial, RIL_Errno e,
9375 void *response, size_t responseLen) {
9376 #if VDBG
9377 RLOGD("getHardwareConfigResponse: serial %d", serial);
9378 #endif
9379
9380 if (radioService[slotId]->mRadioResponse != NULL) {
9381 RadioResponseInfo responseInfo = {};
9382 populateResponseInfo(responseInfo, serial, responseType, e);
9383
9384 hidl_vec<HardwareConfig> result;
9385 if ((response == NULL && responseLen != 0)
9386 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
9387 RLOGE("hardwareConfigChangedInd: invalid response");
9388 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9389 } else {
9390 convertRilHardwareConfigListToHal(response, responseLen, result);
9391 }
9392
9393 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
9394 responseInfo, result);
9395 radioService[slotId]->checkReturnStatus(retStatus);
9396 } else {
9397 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9398 }
9399
9400 return 0;
9401 }
9402
requestIccSimAuthenticationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9403 int radio_1_6::requestIccSimAuthenticationResponse(int slotId,
9404 int responseType, int serial, RIL_Errno e,
9405 void *response, size_t responseLen) {
9406 #if VDBG
9407 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
9408 #endif
9409
9410 if (radioService[slotId]->mRadioResponse != NULL) {
9411 RadioResponseInfo responseInfo = {};
9412 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
9413 responseLen);
9414
9415 Return<void> retStatus
9416 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
9417 responseInfo, result);
9418 radioService[slotId]->checkReturnStatus(retStatus);
9419 } else {
9420 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
9421 "== NULL", slotId);
9422 }
9423
9424 return 0;
9425 }
9426
setDataProfileResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9427 int radio_1_6::setDataProfileResponse(int slotId,
9428 int responseType, int serial, RIL_Errno e,
9429 void *response, size_t responseLen) {
9430 #if VDBG
9431 RLOGD("setDataProfileResponse: serial %d", serial);
9432 #endif
9433
9434 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
9435 RadioResponseInfo responseInfo = {};
9436 populateResponseInfo(responseInfo, serial, responseType, e);
9437 Return<void> retStatus
9438 = radioService[slotId]->mRadioResponseV1_5->setDataProfileResponse_1_5(
9439 responseInfo);
9440 } else if (radioService[slotId]->mRadioResponse != NULL) {
9441 RadioResponseInfo responseInfo = {};
9442 populateResponseInfo(responseInfo, serial, responseType, e);
9443 Return<void> retStatus
9444 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
9445 radioService[slotId]->checkReturnStatus(retStatus);
9446 } else {
9447 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9448 }
9449
9450 return 0;
9451 }
9452
requestShutdownResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9453 int radio_1_6::requestShutdownResponse(int slotId,
9454 int responseType, int serial, RIL_Errno e,
9455 void *response, size_t responseLen) {
9456 #if VDBG
9457 RLOGD("requestShutdownResponse: serial %d", serial);
9458 #endif
9459
9460 if (radioService[slotId]->mRadioResponse != NULL) {
9461 RadioResponseInfo responseInfo = {};
9462 populateResponseInfo(responseInfo, serial, responseType, e);
9463 Return<void> retStatus
9464 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
9465 radioService[slotId]->checkReturnStatus(retStatus);
9466 } else {
9467 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9468 }
9469
9470 return 0;
9471 }
9472
responseRadioCapability(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen,RadioCapability & rc)9473 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
9474 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
9475 populateResponseInfo(responseInfo, serial, responseType, e);
9476
9477 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
9478 RLOGE("responseRadioCapability: Invalid response");
9479 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9480 rc.logicalModemUuid = hidl_string();
9481 } else {
9482 convertRilRadioCapabilityToHal(response, responseLen, rc);
9483 }
9484 }
9485
getRadioCapabilityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9486 int radio_1_6::getRadioCapabilityResponse(int slotId,
9487 int responseType, int serial, RIL_Errno e,
9488 void *response, size_t responseLen) {
9489 #if VDBG
9490 RLOGD("getRadioCapabilityResponse: serial %d", serial);
9491 #endif
9492
9493 if (radioService[slotId]->mRadioResponse != NULL) {
9494 RadioResponseInfo responseInfo = {};
9495 RadioCapability result = {};
9496 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
9497 result);
9498 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
9499 responseInfo, result);
9500 radioService[slotId]->checkReturnStatus(retStatus);
9501 } else {
9502 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9503 }
9504
9505 return 0;
9506 }
9507
setRadioCapabilityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9508 int radio_1_6::setRadioCapabilityResponse(int slotId,
9509 int responseType, int serial, RIL_Errno e,
9510 void *response, size_t responseLen) {
9511 #if VDBG
9512 RLOGD("setRadioCapabilityResponse: serial %d", serial);
9513 #endif
9514
9515 if (radioService[slotId]->mRadioResponse != NULL) {
9516 RadioResponseInfo responseInfo = {};
9517 RadioCapability result = {};
9518 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
9519 result);
9520 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
9521 responseInfo, result);
9522 radioService[slotId]->checkReturnStatus(retStatus);
9523 } else {
9524 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9525 }
9526
9527 return 0;
9528 }
9529
responseLceStatusInfo(RadioResponseInfo & responseInfo,int serial,int responseType,RIL_Errno e,void * response,size_t responseLen)9530 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
9531 RIL_Errno e, void *response, size_t responseLen) {
9532 populateResponseInfo(responseInfo, serial, responseType, e);
9533 LceStatusInfo result = {};
9534
9535 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
9536 RLOGE("Invalid response: NULL");
9537 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9538 } else {
9539 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
9540 result.lceStatus = (LceStatus) resp->lce_status;
9541 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
9542 }
9543 return result;
9544 }
9545
startLceServiceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9546 int radio_1_6::startLceServiceResponse(int slotId,
9547 int responseType, int serial, RIL_Errno e,
9548 void *response, size_t responseLen) {
9549 #if VDBG
9550 RLOGD("startLceServiceResponse: serial %d", serial);
9551 #endif
9552
9553 if (radioService[slotId]->mRadioResponse != NULL) {
9554 RadioResponseInfo responseInfo = {};
9555 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
9556 response, responseLen);
9557
9558 Return<void> retStatus
9559 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
9560 result);
9561 radioService[slotId]->checkReturnStatus(retStatus);
9562 } else {
9563 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9564 }
9565
9566 return 0;
9567 }
9568
stopLceServiceResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9569 int radio_1_6::stopLceServiceResponse(int slotId,
9570 int responseType, int serial, RIL_Errno e,
9571 void *response, size_t responseLen) {
9572 #if VDBG
9573 RLOGD("stopLceServiceResponse: serial %d", serial);
9574 #endif
9575
9576 if (radioService[slotId]->mRadioResponse != NULL) {
9577 RadioResponseInfo responseInfo = {};
9578 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
9579 response, responseLen);
9580
9581 Return<void> retStatus
9582 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
9583 result);
9584 radioService[slotId]->checkReturnStatus(retStatus);
9585 } else {
9586 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9587 }
9588
9589 return 0;
9590 }
9591
pullLceDataResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9592 int radio_1_6::pullLceDataResponse(int slotId,
9593 int responseType, int serial, RIL_Errno e,
9594 void *response, size_t responseLen) {
9595 #if VDBG
9596 RLOGD("pullLceDataResponse: serial %d", serial);
9597 #endif
9598
9599 if (radioService[slotId]->mRadioResponse != NULL) {
9600 RadioResponseInfo responseInfo = {};
9601 populateResponseInfo(responseInfo, serial, responseType, e);
9602
9603 LceDataInfo result = {};
9604 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
9605 RLOGE("pullLceDataResponse: Invalid response");
9606 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9607 } else {
9608 convertRilLceDataInfoToHal(response, responseLen, result);
9609 }
9610
9611 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
9612 responseInfo, result);
9613 radioService[slotId]->checkReturnStatus(retStatus);
9614 } else {
9615 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9616 }
9617
9618 return 0;
9619 }
9620
getModemActivityInfoResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9621 int radio_1_6::getModemActivityInfoResponse(int slotId,
9622 int responseType, int serial, RIL_Errno e,
9623 void *response, size_t responseLen) {
9624 #if VDBG
9625 RLOGD("getModemActivityInfoResponse: serial %d", serial);
9626 #endif
9627
9628 if (radioService[slotId]->mRadioResponse != NULL) {
9629 RadioResponseInfo responseInfo = {};
9630 populateResponseInfo(responseInfo, serial, responseType, e);
9631 ActivityStatsInfo info;
9632 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
9633 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
9634 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9635 } else {
9636 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
9637 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
9638 info.idleModeTimeMs = resp->idle_mode_time_ms;
9639 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
9640 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
9641 }
9642 info.rxModeTimeMs = resp->rx_mode_time_ms;
9643 }
9644
9645 Return<void> retStatus
9646 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
9647 info);
9648 radioService[slotId]->checkReturnStatus(retStatus);
9649 } else {
9650 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
9651 slotId);
9652 }
9653
9654 return 0;
9655 }
9656
setAllowedCarriersResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9657 int radio_1_6::setAllowedCarriersResponse(int slotId,
9658 int responseType, int serial, RIL_Errno e,
9659 void *response, size_t responseLen) {
9660 #if VDBG
9661 RLOGD("setAllowedCarriersResponse: serial %d", serial);
9662 #endif
9663 RadioResponseInfo responseInfo = {};
9664 populateResponseInfo(responseInfo, serial, responseType, e);
9665
9666 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9667 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
9668 ->setAllowedCarriersResponse_1_4(responseInfo);
9669 radioService[slotId]->checkReturnStatus(retStatus);
9670 } else if (radioService[slotId]->mRadioResponse != NULL) {
9671 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
9672 Return<void> retStatus = radioService[slotId]->mRadioResponse
9673 ->setAllowedCarriersResponse(responseInfo, ret);
9674 radioService[slotId]->checkReturnStatus(retStatus);
9675 } else {
9676 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9677 }
9678
9679 return 0;
9680 }
9681
prepareCarrierRestrictionsResponse(hidl_vec<Carrier> & allowedCarriers,hidl_vec<Carrier> & excludedCarriers,bool & allAllowed,const RIL_CarrierRestrictions * pCr)9682 void prepareCarrierRestrictionsResponse(hidl_vec<Carrier>& allowedCarriers,
9683 hidl_vec<Carrier>& excludedCarriers,
9684 bool& allAllowed,
9685 const RIL_CarrierRestrictions* pCr) {
9686 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
9687 allAllowed = false;
9688 }
9689 allowedCarriers.resize(pCr->len_allowed_carriers);
9690 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
9691 RIL_Carrier *carrier = pCr->allowed_carriers + i;
9692 allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
9693 allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
9694 allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
9695 allowedCarriers[i].matchData =
9696 convertCharPtrToHidlString(carrier->match_data);
9697 }
9698
9699 excludedCarriers.resize(pCr->len_excluded_carriers);
9700 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
9701 RIL_Carrier *carrier = pCr->excluded_carriers + i;
9702 excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
9703 excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
9704 excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
9705 excludedCarriers[i].matchData =
9706 convertCharPtrToHidlString(carrier->match_data);
9707 }
9708 }
9709
getAllowedCarriersResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9710 int radio_1_6::getAllowedCarriersResponse(int slotId,
9711 int responseType, int serial, RIL_Errno e,
9712 void *response, size_t responseLen) {
9713 #if VDBG
9714 RLOGD("getAllowedCarriersResponse: serial %d", serial);
9715 #endif
9716 RadioResponseInfo responseInfo = {};
9717 populateResponseInfo(responseInfo, serial, responseType, e);
9718
9719 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9720 V1_4::CarrierRestrictionsWithPriority carrierInfo = {};
9721 V1_4::SimLockMultiSimPolicy multiSimPolicy =
9722 V1_4::SimLockMultiSimPolicy::NO_MULTISIM_POLICY;
9723 bool allAllowed = true;
9724
9725 if (response == NULL) {
9726 #if VDBG
9727 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
9728 #endif
9729 carrierInfo.allowedCarriers.resize(0);
9730 carrierInfo.excludedCarriers.resize(0);
9731 carrierInfo.allowedCarriersPrioritized = false;
9732 } else if (responseLen != sizeof(RIL_CarrierRestrictionsWithPriority)) {
9733 RLOGE("getAllowedCarriersResponse Invalid response");
9734 if (e == RIL_E_SUCCESS) {
9735 responseInfo.error = RadioError::INVALID_RESPONSE;
9736 }
9737 } else {
9738 RIL_CarrierRestrictionsWithPriority *pCrExt =
9739 (RIL_CarrierRestrictionsWithPriority *)response;
9740
9741 // Convert into the structure used in IRadio 1.0 to re-use existing code
9742 RIL_CarrierRestrictions cr = {};
9743 cr.len_allowed_carriers = pCrExt->len_allowed_carriers;
9744 cr.len_excluded_carriers = pCrExt->len_excluded_carriers;
9745 cr.allowed_carriers = pCrExt->allowed_carriers;
9746 cr.excluded_carriers = pCrExt->excluded_carriers;
9747 prepareCarrierRestrictionsResponse(carrierInfo.allowedCarriers,
9748 carrierInfo.excludedCarriers, allAllowed, &cr);
9749
9750 carrierInfo.allowedCarriersPrioritized = (bool)pCrExt->allowedCarriersPrioritized;
9751 multiSimPolicy = (V1_4::SimLockMultiSimPolicy)pCrExt->multiSimPolicy;
9752 }
9753
9754 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
9755 ->getAllowedCarriersResponse_1_4(responseInfo, carrierInfo, multiSimPolicy);
9756 radioService[slotId]->checkReturnStatus(retStatus);
9757 } else if (radioService[slotId]->mRadioResponse != NULL) {
9758 CarrierRestrictions carrierInfo = {};
9759 bool allAllowed = true;
9760 if (response == NULL) {
9761 #if VDBG
9762 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
9763 #endif
9764 carrierInfo.allowedCarriers.resize(0);
9765 carrierInfo.excludedCarriers.resize(0);
9766 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
9767 RLOGE("getAllowedCarriersResponse Invalid response");
9768 if (e == RIL_E_SUCCESS) {
9769 responseInfo.error = RadioError::INVALID_RESPONSE;
9770 }
9771 } else {
9772 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
9773 prepareCarrierRestrictionsResponse(carrierInfo.allowedCarriers,
9774 carrierInfo.excludedCarriers, allAllowed, pCr);
9775 }
9776
9777 Return<void> retStatus = radioService[slotId]->mRadioResponse
9778 ->getAllowedCarriersResponse(responseInfo, allAllowed, carrierInfo);
9779 radioService[slotId]->checkReturnStatus(retStatus);
9780 } else {
9781 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9782 }
9783
9784 return 0;
9785 }
9786
sendDeviceStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)9787 int radio_1_6::sendDeviceStateResponse(int slotId,
9788 int responseType, int serial, RIL_Errno e,
9789 void *response, size_t responselen) {
9790 #if VDBG
9791 RLOGD("sendDeviceStateResponse: serial %d", serial);
9792 #endif
9793
9794 if (radioService[slotId]->mRadioResponse != NULL) {
9795 RadioResponseInfo responseInfo = {};
9796 populateResponseInfo(responseInfo, serial, responseType, e);
9797 Return<void> retStatus
9798 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
9799 radioService[slotId]->checkReturnStatus(retStatus);
9800 } else {
9801 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9802 }
9803
9804 return 0;
9805 }
9806
setCarrierInfoForImsiEncryptionResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9807 int radio_1_6::setCarrierInfoForImsiEncryptionResponse(int slotId,
9808 int responseType, int serial, RIL_Errno e,
9809 void *response, size_t responseLen) {
9810 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
9811 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
9812 RadioResponseInfo responseInfo = {};
9813 populateResponseInfo(responseInfo, serial, responseType, e);
9814 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
9815 setCarrierInfoForImsiEncryptionResponse(responseInfo);
9816 radioService[slotId]->checkReturnStatus(retStatus);
9817 } else {
9818 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponseV1_1 == "
9819 "NULL", slotId);
9820 }
9821 return 0;
9822 }
9823
setIndicationFilterResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)9824 int radio_1_6::setIndicationFilterResponse(int slotId,
9825 int responseType, int serial, RIL_Errno e,
9826 void *response, size_t responselen) {
9827 #if VDBG
9828 RLOGD("setIndicationFilterResponse: serial %d", serial);
9829 #endif
9830 RadioResponseInfo responseInfo = {};
9831 populateResponseInfo(responseInfo, serial, responseType, e);
9832
9833 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
9834 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
9835 ->setIndicationFilterResponse_1_5(responseInfo);
9836 radioService[slotId]->checkReturnStatus(retStatus);
9837 } else if (radioService[slotId]->mRadioResponse != NULL) {
9838 Return<void> retStatus = radioService[slotId]->mRadioResponse
9839 ->setIndicationFilterResponse(responseInfo);
9840 radioService[slotId]->checkReturnStatus(retStatus);
9841 } else {
9842 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL", slotId);
9843 }
9844
9845 return 0;
9846 }
9847
setSimCardPowerResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9848 int radio_1_6::setSimCardPowerResponse(int slotId,
9849 int responseType, int serial, RIL_Errno e,
9850 void *response, size_t responseLen) {
9851 #if VDBG
9852 RLOGD("setSimCardPowerResponse: serial %d", serial);
9853 #endif
9854
9855 if (radioService[slotId]->mRadioResponse != NULL
9856 || radioService[slotId]->mRadioResponseV1_1 != NULL
9857 || radioService[slotId]->mRadioResponseV1_6 != NULL) {
9858 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
9859 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo = {};
9860 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
9861 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6->
9862 setSimCardPowerResponse_1_6(responseInfo);
9863 radioService[slotId]->checkReturnStatus(retStatus);
9864 } else if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
9865 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_6 == NULL", slotId);
9866 RadioResponseInfo responseInfo = {};
9867 populateResponseInfo(responseInfo, serial, responseType, e);
9868 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
9869 setSimCardPowerResponse_1_1(responseInfo);
9870 radioService[slotId]->checkReturnStatus(retStatus);
9871 } else {
9872 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_6 and V1_1 == NULL",
9873 slotId);
9874 RadioResponseInfo responseInfo = {};
9875 populateResponseInfo(responseInfo, serial, responseType, e);
9876 Return<void> retStatus = radioService[slotId]->mRadioResponse
9877 ->setSimCardPowerResponse(responseInfo);
9878 radioService[slotId]->checkReturnStatus(retStatus);
9879 }
9880 } else {
9881 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL && "
9882 "radioService[%d]->mRadioResponseV1_1 and V1_6 == NULL", slotId, slotId);
9883 }
9884 return 0;
9885 }
9886
startNetworkScanResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9887 int radio_1_6::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
9888 void *response, size_t responseLen) {
9889 #if VDBG
9890 RLOGD("startNetworkScanResponse: serial %d", serial);
9891 #endif
9892
9893 if (radioService[slotId]->mRadioResponseV1_1 != NULL ||
9894 radioService[slotId]->mRadioResponseV1_2 != NULL ||
9895 radioService[slotId]->mRadioResponseV1_4 != NULL ||
9896 radioService[slotId]->mRadioResponseV1_6 != NULL) {
9897 RadioResponseInfo responseInfo = {};
9898 populateResponseInfo(responseInfo, serial, responseType, e);
9899
9900 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
9901 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
9902 ->startNetworkScanResponse_1_5(responseInfo);
9903 radioService[slotId]->checkReturnStatus(retStatus);
9904 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9905 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
9906 ->startNetworkScanResponse_1_4(responseInfo);
9907 radioService[slotId]->checkReturnStatus(retStatus);
9908 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
9909 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2
9910 ->startNetworkScanResponse(responseInfo);
9911 radioService[slotId]->checkReturnStatus(retStatus);
9912 } else if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
9913 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1
9914 ->startNetworkScanResponse(responseInfo);
9915 radioService[slotId]->checkReturnStatus(retStatus);
9916 } else {
9917 RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL or "
9918 "radioService[%d]->mRadioResponseV1_4 == NULL", slotId, slotId);
9919 }
9920 }
9921
9922 return 0;
9923 }
9924
stopNetworkScanResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9925 int radio_1_6::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
9926 void *response, size_t responseLen) {
9927 #if VDBG
9928 RLOGD("stopNetworkScanResponse: serial %d", serial);
9929 #endif
9930
9931 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
9932 RadioResponseInfo responseInfo = {};
9933 populateResponseInfo(responseInfo, serial, responseType, e);
9934 Return<void> retStatus
9935 = radioService[slotId]->mRadioResponseV1_1->stopNetworkScanResponse(responseInfo);
9936 radioService[slotId]->checkReturnStatus(retStatus);
9937 } else {
9938 RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
9939 }
9940
9941 return 0;
9942 }
9943
emergencyDialResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9944 int radio_1_6::emergencyDialResponse(int slotId, int responseType, int serial, RIL_Errno e,
9945 void *response, size_t responseLen) {
9946 #if VDBG
9947 RLOGD("emergencyDialResponse: serial %d", serial);
9948 #endif
9949
9950 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
9951 RadioResponseInfo responseInfo = {};
9952 populateResponseInfo(responseInfo, serial, responseType, e);
9953 Return<void> retStatus
9954 = radioService[slotId]->mRadioResponseV1_4->emergencyDialResponse(responseInfo);
9955 radioService[slotId]->checkReturnStatus(retStatus);
9956 } else {
9957 RLOGE("emergencyDialResponse: radioService[%d]->mRadioResponseV1_4 == NULL", slotId);
9958 }
9959 return 0;
9960 }
9961
convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus * rilStatus,V1_1::KeepaliveStatus & halStatus)9962 void convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus *rilStatus,
9963 V1_1::KeepaliveStatus& halStatus) {
9964 halStatus.sessionHandle = rilStatus->sessionHandle;
9965 halStatus.code = static_cast<V1_1::KeepaliveStatusCode>(rilStatus->code);
9966 }
9967
startKeepaliveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9968 int radio_1_6::startKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
9969 void *response, size_t responseLen) {
9970 #if VDBG
9971 RLOGD("%s(): %d", __FUNCTION__, serial);
9972 #endif
9973 RadioResponseInfo responseInfo = {};
9974 populateResponseInfo(responseInfo, serial, responseType, e);
9975
9976 // If we don't have a radio service, there's nothing we can do
9977 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
9978 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
9979 return 0;
9980 }
9981
9982 V1_1::KeepaliveStatus ks = {};
9983 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
9984 RLOGE("%s: invalid response - %d", __FUNCTION__, static_cast<int>(e));
9985 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
9986 } else {
9987 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
9988 }
9989
9990 Return<void> retStatus =
9991 radioService[slotId]->mRadioResponseV1_1->startKeepaliveResponse(responseInfo, ks);
9992 radioService[slotId]->checkReturnStatus(retStatus);
9993 return 0;
9994 }
9995
stopKeepaliveResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)9996 int radio_1_6::stopKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
9997 void *response, size_t responseLen) {
9998 #if VDBG
9999 RLOGD("%s(): %d", __FUNCTION__, serial);
10000 #endif
10001 RadioResponseInfo responseInfo = {};
10002 populateResponseInfo(responseInfo, serial, responseType, e);
10003
10004 // If we don't have a radio service, there's nothing we can do
10005 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
10006 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
10007 return 0;
10008 }
10009
10010 Return<void> retStatus =
10011 radioService[slotId]->mRadioResponseV1_1->stopKeepaliveResponse(responseInfo);
10012 radioService[slotId]->checkReturnStatus(retStatus);
10013 return 0;
10014 }
10015
getModemStackStatusResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10016 int radio_1_6::getModemStackStatusResponse(int slotId, int responseType, int serial, RIL_Errno e,
10017 void *response, size_t responseLen) {
10018 #if VDBG
10019 RLOGD("%s(): %d", __FUNCTION__, serial);
10020 #endif
10021 RadioResponseInfo responseInfo = {};
10022 populateResponseInfo(responseInfo, serial, responseType, e);
10023
10024 // If we don't have a radio service, there's nothing we can do
10025 if (radioService[slotId]->mRadioResponseV1_3 == NULL) {
10026 RLOGE("%s: radioService[%d]->mRadioResponseV1_3 == NULL", __FUNCTION__, slotId);
10027 return 0;
10028 }
10029
10030 Return<void> retStatus =
10031 radioService[slotId]->mRadioResponseV1_3->getModemStackStatusResponse(
10032 responseInfo, true);
10033 radioService[slotId]->checkReturnStatus(retStatus);
10034 return 0;
10035 }
10036
enableModemResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10037 int radio_1_6::enableModemResponse(int slotId, int responseType, int serial, RIL_Errno e,
10038 void *response, size_t responseLen) {
10039 #if VDBG
10040 RLOGD("%s(): %d", __FUNCTION__, serial);
10041 #endif
10042 RadioResponseInfo responseInfo = {};
10043 populateResponseInfo(responseInfo, serial, responseType, e);
10044
10045 // If we don't have a radio service, there's nothing we can do
10046 if (radioService[slotId]->mRadioResponseV1_3 == NULL) {
10047 RLOGE("%s: radioService[%d]->mRadioResponseV1_3 == NULL", __FUNCTION__, slotId);
10048 return 0;
10049 }
10050
10051 Return<void> retStatus =
10052 radioService[slotId]->mRadioResponseV1_3->enableModemResponse(responseInfo);
10053 radioService[slotId]->checkReturnStatus(retStatus);
10054 return 0;
10055 }
10056
sendRequestRawResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10057 int radio_1_6::sendRequestRawResponse(int slotId,
10058 int responseType, int serial, RIL_Errno e,
10059 void *response, size_t responseLen) {
10060 #if VDBG
10061 RLOGD("sendRequestRawResponse: serial %d", serial);
10062 #endif
10063
10064 if (!kOemHookEnabled) return 0;
10065
10066 if (oemHookService[slotId]->mOemHookResponse != NULL) {
10067 RadioResponseInfo responseInfo = {};
10068 populateResponseInfo(responseInfo, serial, responseType, e);
10069 hidl_vec<uint8_t> data;
10070
10071 if (response == NULL) {
10072 RLOGE("sendRequestRawResponse: Invalid response");
10073 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
10074 } else {
10075 data.setToExternal((uint8_t *) response, responseLen);
10076 }
10077 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
10078 sendRequestRawResponse(responseInfo, data);
10079 checkReturnStatus(slotId, retStatus, false);
10080 } else {
10081 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
10082 slotId);
10083 }
10084
10085 return 0;
10086 }
10087
sendRequestStringsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10088 int radio_1_6::sendRequestStringsResponse(int slotId,
10089 int responseType, int serial, RIL_Errno e,
10090 void *response, size_t responseLen) {
10091 #if VDBG
10092 RLOGD("sendRequestStringsResponse: serial %d", serial);
10093 #endif
10094
10095 if (!kOemHookEnabled) return 0;
10096
10097 if (oemHookService[slotId]->mOemHookResponse != NULL) {
10098 RadioResponseInfo responseInfo = {};
10099 populateResponseInfo(responseInfo, serial, responseType, e);
10100 hidl_vec<hidl_string> data;
10101
10102 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
10103 RLOGE("sendRequestStringsResponse Invalid response: NULL");
10104 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
10105 } else {
10106 char **resp = (char **) response;
10107 int numStrings = responseLen / sizeof(char *);
10108 data.resize(numStrings);
10109 for (int i = 0; i < numStrings; i++) {
10110 data[i] = convertCharPtrToHidlString(resp[i]);
10111 }
10112 }
10113 Return<void> retStatus
10114 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
10115 responseInfo, data);
10116 checkReturnStatus(slotId, retStatus, false);
10117 } else {
10118 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
10119 "NULL", slotId);
10120 }
10121
10122 return 0;
10123 }
10124
setSystemSelectionChannelsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10125 int radio_1_6::setSystemSelectionChannelsResponse(int slotId, int responseType, int serial,
10126 RIL_Errno e, void* response, size_t responseLen) {
10127 #if VDBG
10128 RLOGD("setSystemSelectionChannelsResponse: serial %d", serial);
10129 #endif
10130 RadioResponseInfo responseInfo = {};
10131 populateResponseInfo(responseInfo, serial, responseType, e);
10132
10133 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10134 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10135 ->setSystemSelectionChannelsResponse_1_5(responseInfo);
10136 radioService[slotId]->checkReturnStatus(retStatus);
10137 } else if (radioService[slotId]->mRadioResponseV1_3 != NULL) {
10138 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_3
10139 ->setSystemSelectionChannelsResponse(responseInfo);
10140 radioService[slotId]->checkReturnStatus(retStatus);
10141 } else {
10142 RLOGE("setSystemSelectionChannelsResponse: radioService[%d]->mRadioResponse == NULL",
10143 slotId);
10144 }
10145
10146 return 0;
10147 }
10148
getSystemSelectionChannelsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10149 int radio_1_6::getSystemSelectionChannelsResponse(int slotId, int responseType, int serial,
10150 RIL_Errno e, void* response, size_t responseLen) {
10151 #if VDBG
10152 RLOGD("getSystemSelectionChannelsResponse: serial %d", serial);
10153 #endif
10154 V1_6::RadioResponseInfo responseInfo = {};
10155 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10156
10157 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10158 hidl_vec<::android::hardware::radio::V1_5::RadioAccessSpecifier> ret;
10159 Return<void> retStatus =
10160 radioService[slotId]
10161 ->mRadioResponseV1_6->getSystemSelectionChannelsResponse(
10162 responseInfo, ret);
10163 radioService[slotId]->checkReturnStatus(retStatus);
10164 } else {
10165 RLOGE("getSystemSelectionChannelsResponse: radioService[%d]->mRadioResponse == NULL",
10166 slotId);
10167 }
10168
10169 return 0;
10170 }
10171
setSignalStrengthReportingCriteriaResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10172 int radio_1_6::setSignalStrengthReportingCriteriaResponse(int slotId, int responseType, int serial,
10173 RIL_Errno e, void* response, size_t responseLen) {
10174 #if VDBG
10175 RLOGD("setSignalStrengthReportingCriteriaResponse: serial %d", serial);
10176 #endif
10177 RadioResponseInfo responseInfo = {};
10178 populateResponseInfo(responseInfo, serial, responseType, e);
10179
10180 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10181 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10182 ->setSignalStrengthReportingCriteriaResponse_1_5(responseInfo);
10183 radioService[slotId]->checkReturnStatus(retStatus);
10184 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
10185 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2
10186 ->setSignalStrengthReportingCriteriaResponse(responseInfo);
10187 radioService[slotId]->checkReturnStatus(retStatus);
10188 } else {
10189 RLOGE("setSignalStrengthReportingCriteriaResponse: radioService[%d]->mRadioResponse "
10190 "== NULL", slotId);
10191 }
10192
10193 return 0;
10194 }
10195
setLinkCapacityReportingCriteriaResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10196 int radio_1_6::setLinkCapacityReportingCriteriaResponse(int slotId, int responseType, int serial,
10197 RIL_Errno e, void* response, size_t responseLen) {
10198 #if VDBG
10199 RLOGD("setLinkCapacityReportingCriteriaResponse: serial %d", serial);
10200 #endif
10201 RadioResponseInfo responseInfo = {};
10202 populateResponseInfo(responseInfo, serial, responseType, e);
10203
10204 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10205 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10206 ->setLinkCapacityReportingCriteriaResponse_1_5(responseInfo);
10207 radioService[slotId]->checkReturnStatus(retStatus);
10208 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
10209 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2
10210 ->setLinkCapacityReportingCriteriaResponse(responseInfo);
10211 radioService[slotId]->checkReturnStatus(retStatus);
10212 } else {
10213 RLOGE("setLinkCapacityReportingCriteriaResponse: radioService[%d]->mRadioResponse "
10214 "== NULL", slotId);
10215 }
10216
10217 return 0;
10218 }
10219
enableUiccApplicationsResponse(int slotId,int responseType,int serial,RIL_Errno e,void *,size_t responseLen)10220 int radio_1_6::enableUiccApplicationsResponse(int slotId, int responseType, int serial,
10221 RIL_Errno e, void* /* response */, size_t responseLen) {
10222 #if VDBG
10223 RLOGD("%s(): %d", __FUNCTION__, serial);
10224 #endif
10225 RadioResponseInfo responseInfo = {};
10226 populateResponseInfo(responseInfo, serial, responseType, e);
10227
10228 // If we don't have a radio service, there's nothing we can do
10229 if (radioService[slotId]->mRadioResponseV1_5 == NULL) {
10230 RLOGE("%s: radioService[%d]->mRadioResponseV1_5 == NULL", __FUNCTION__, slotId);
10231 return 0;
10232 }
10233
10234 Return<void> retStatus =
10235 radioService[slotId]->mRadioResponseV1_5->enableUiccApplicationsResponse(
10236 responseInfo);
10237 radioService[slotId]->checkReturnStatus(retStatus);
10238 return 0;
10239 }
10240
areUiccApplicationsEnabledResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10241 int radio_1_6::areUiccApplicationsEnabledResponse(int slotId, int responseType, int serial,
10242 RIL_Errno e, void* response, size_t responseLen) {
10243 #if VDBG
10244 RLOGD("%s(): %d", __FUNCTION__, serial);
10245 #endif
10246 RadioResponseInfo responseInfo = {};
10247 populateResponseInfo(responseInfo, serial, responseType, e);
10248
10249 // If we don't have a radio service, there's nothing we can do
10250 if (radioService[slotId]->mRadioResponseV1_5 == NULL) {
10251 RLOGE("%s: radioService[%d]->mRadioResponseV1_5 == NULL", __FUNCTION__, slotId);
10252 return 0;
10253 }
10254
10255 bool enable = false;
10256 if (response == NULL || responseLen != sizeof(bool)) {
10257 RLOGE("isSimDetachedFromNetwork Invalid response.");
10258 } else {
10259 enable = (*((bool *) response));
10260 }
10261
10262 Return<void> retStatus =
10263 radioService[slotId]->mRadioResponseV1_5->areUiccApplicationsEnabledResponse(
10264 responseInfo, enable);
10265 radioService[slotId]->checkReturnStatus(retStatus);
10266 return 0;
10267 }
10268
getBarringInfoResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)10269 int radio_1_6::getBarringInfoResponse(int slotId,
10270 int responseType, int serial, RIL_Errno e,
10271 void *response, size_t responselen) {
10272 #if VDBG
10273 RLOGD("getBarringInfoResponse: serial %d", serial);
10274 #endif
10275
10276 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10277 RadioResponseInfo responseInfo = {};
10278 populateResponseInfo(responseInfo, serial, responseType, e);
10279 ::android::hardware::radio::V1_5::CellIdentity cellIdentity;
10280 hidl_vec<::android::hardware::radio::V1_5::BarringInfo> barringInfos = {};
10281
10282 if (response == NULL) { /* data for vts */
10283 V1_5::BarringInfo barringInfo = {};
10284 barringInfo.serviceType = V1_5::BarringInfo::ServiceType::CS_SERVICE;
10285 barringInfo.barringType = V1_5::BarringInfo::BarringType::NONE;
10286
10287 V1_5::CellIdentityLte cellIdentityLte = {};
10288 cellIdentity.lte(cellIdentityLte);
10289 barringInfos.resize(1);
10290 barringInfos[0] = barringInfo;
10291
10292 Return<void> retStatus
10293 = radioService[slotId]->mRadioResponseV1_5->
10294 getBarringInfoResponse(responseInfo, cellIdentity, barringInfos);
10295 radioService[slotId]->checkReturnStatus(retStatus);
10296 } else {
10297 RLOGE("getBarringInfoResponse: radioService[%d]->mRadioResponse == NULL",
10298 slotId);
10299 }
10300 }
10301 return 0;
10302 }
10303
sendCdmaSmsExpectMoreResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10304 int radio_1_6::sendCdmaSmsExpectMoreResponse(int slotId, int responseType, int serial, RIL_Errno e,
10305 void *response, size_t responseLen) {
10306 #if VDBG
10307 RLOGD("sendCdmaSmsExpectMoreResponse: serial %d", serial);
10308 #endif
10309
10310 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10311 ::android::hardware::radio::V1_6::RadioResponseInfo responseInfo_1_6 = {};
10312 SendSmsResult result = makeSendSmsResult_1_6(responseInfo_1_6, serial, responseType, e,
10313 response, responseLen);
10314
10315 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6
10316 ->sendCdmaSmsExpectMoreResponse_1_6(responseInfo_1_6, result);
10317 radioService[slotId]->checkReturnStatus(retStatus);
10318 } else if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10319 RadioResponseInfo responseInfo = {};
10320 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
10321 responseLen);
10322
10323 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10324 ->sendCdmaSmsExpectMoreResponse(responseInfo, result);
10325 radioService[slotId]->checkReturnStatus(retStatus);
10326 } else {
10327 RLOGE("sendCdmaSmsExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10328 }
10329
10330 return 0;
10331 }
10332
supplySimDepersonalizationResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10333 int radio_1_6::supplySimDepersonalizationResponse(int slotId, int responseType, int serial,
10334 RIL_Errno e, void *response, size_t responseLen) {
10335 #if VDBG
10336 RLOGD("supplySimDepersonalizationResponse: serial %d", serial);
10337 #endif
10338
10339 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
10340 RadioResponseInfo responseInfo = {};
10341 int persoType = -1, remainingRetries = -1;
10342 int numInts = responseLen / sizeof(int);
10343 if (response == NULL || numInts != 2) {
10344 RLOGE("getClirResponse Invalid response: NULL");
10345 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
10346 } else {
10347 int *pInt = (int *) response;
10348 persoType = pInt[0];
10349 remainingRetries = pInt[1];
10350 }
10351 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
10352 ->supplySimDepersonalizationResponse(responseInfo, (V1_5::PersoSubstate) persoType,
10353 remainingRetries);
10354 radioService[slotId]->checkReturnStatus(retStatus);
10355 } else {
10356 RLOGE("supplySimDepersonalizationResponse: radioService[%d]->mRadioResponseV1_5 == "
10357 "NULL", slotId);
10358 }
10359
10360 return 0;
10361 }
10362
setNrDualConnectivityStateResponse(int slotId,int responseType,int serial,RIL_Errno e,void *,size_t responseLen)10363 int radio_1_6::setNrDualConnectivityStateResponse(int slotId, int responseType, int serial,
10364 RIL_Errno e, void* /* response */, size_t responseLen) {
10365 #if VDBG
10366 RLOGD("%s(): %d", __FUNCTION__, serial);
10367 #endif
10368 V1_6::RadioResponseInfo responseInfo = {};
10369 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10370
10371 // If we don't have a radio service, there's nothing we can do
10372 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10373 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10374 return 0;
10375 }
10376
10377 Return<void> retStatus =
10378 radioService[slotId]->mRadioResponseV1_6->setNrDualConnectivityStateResponse(
10379 responseInfo);
10380 radioService[slotId]->checkReturnStatus(retStatus);
10381 return 0;
10382 }
10383
isNrDualConnectivityEnabledResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10384 int radio_1_6::isNrDualConnectivityEnabledResponse(int slotId, int responseType, int serial,
10385 RIL_Errno e, void* response, size_t responseLen) {
10386 #if VDBG
10387 RLOGD("%s(): %d", __FUNCTION__, serial);
10388 #endif
10389 V1_6::RadioResponseInfo responseInfo = {};
10390 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10391
10392 // If we don't have a radio service, there's nothing we can do
10393 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10394 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10395 return 0;
10396 }
10397
10398 bool enable = false;
10399 if (response == NULL || responseLen != sizeof(bool)) {
10400 RLOGE("isNrDualConnectivityEnabledResponseInvalid response.");
10401 } else {
10402 enable = (*((bool *) response));
10403 }
10404
10405 Return<void> retStatus =
10406 radioService[slotId]->mRadioResponseV1_6->isNrDualConnectivityEnabledResponse(
10407 responseInfo, enable);
10408 radioService[slotId]->checkReturnStatus(retStatus);
10409 return 0;
10410 }
10411
allocatePduSessionIdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10412 int radio_1_6::allocatePduSessionIdResponse(int slotId, int responseType, int serial,
10413 RIL_Errno e, void* response, size_t responseLen) {
10414 #if VDBG
10415 RLOGD("%s(): %d", __FUNCTION__, serial);
10416 #endif
10417 // If we don't have a radio service, there's nothing we can do
10418 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10419 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10420 return 0;
10421 }
10422 V1_6::RadioResponseInfo responseInfo = {};
10423 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10424
10425 Return<void> retStatus =
10426 radioService[slotId]->mRadioResponseV1_6->allocatePduSessionIdResponse(responseInfo, -1);
10427 radioService[slotId]->checkReturnStatus(retStatus);
10428 return 0;
10429 }
10430
releasePduSessionIdResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10431 int radio_1_6::releasePduSessionIdResponse(int slotId, int responseType, int serial,
10432 RIL_Errno e, void* response, size_t responseLen) {
10433 #if VDBG
10434 RLOGD("%s(): %d", __FUNCTION__, serial);
10435 #endif
10436 // If we don't have a radio service, there's nothing we can do
10437 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10438 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10439 return 0;
10440 }
10441
10442 V1_6::RadioResponseInfo responseInfo = {};
10443 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10444
10445 Return<void> retStatus =
10446 radioService[slotId]->mRadioResponseV1_6->releasePduSessionIdResponse(responseInfo);
10447 radioService[slotId]->checkReturnStatus(retStatus);
10448 return 0;
10449 }
10450
startHandoverResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10451 int radio_1_6::startHandoverResponse(int slotId, int responseType, int serial,
10452 RIL_Errno e, void* response, size_t responseLen) {
10453 // If we don't have a radio service, there's nothing we can do
10454 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10455 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10456 return 0;
10457 }
10458 V1_6::RadioResponseInfo responseInfo = {};
10459 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10460
10461 Return<void> retStatus =
10462 radioService[slotId]->mRadioResponseV1_6->startHandoverResponse(responseInfo);
10463
10464 #if VDBG
10465 RLOGD("%s(): %d", __FUNCTION__, serial);
10466 #endif
10467 return 0;
10468 }
10469
cancelHandoverResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10470 int radio_1_6::cancelHandoverResponse(int slotId, int responseType, int serial,
10471 RIL_Errno e, void* response, size_t responseLen) {
10472 // If we don't have a radio service, there's nothing we can do
10473 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10474 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10475 return 0;
10476 }
10477 V1_6::RadioResponseInfo responseInfo = {};
10478 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10479
10480 Return<void> retStatus =
10481 radioService[slotId]->mRadioResponseV1_6->cancelHandoverResponse(responseInfo);
10482
10483 #if VDBG
10484 RLOGD("%s(): %d", __FUNCTION__, serial);
10485 #endif
10486 return 0;
10487 }
10488
10489
setDataThrottlingResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responselen)10490 int radio_1_6::setDataThrottlingResponse(int slotId, int responseType,
10491 int serial, RIL_Errno e, void *response, size_t responselen) {
10492 #if VDBG
10493 RLOGD("setDataThrottlingResponse: serial %d", serial);
10494 #endif
10495
10496 if (radioService[slotId]->mRadioResponseV1_6 == NULL) {
10497 RLOGE("%s: radioService[%d]->mRadioResponseV1_6 == NULL", __FUNCTION__, slotId);
10498 return 0;
10499 }
10500
10501 V1_6::RadioResponseInfo responseInfo = {};
10502 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10503
10504
10505 Return<void> retstatus =
10506 radioService[slotId]->mRadioResponseV1_6->setDataThrottlingResponse(
10507 responseInfo);
10508 radioService[slotId]->checkReturnStatus(retstatus);
10509 return 0;
10510 }
10511
getSlicingConfigResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10512 int radio_1_6::getSlicingConfigResponse(int slotId, int responseType, int serial,
10513 RIL_Errno e, void* response, size_t responseLen) {
10514 #if VDBG
10515 RLOGD("getSlicingConfigResponse: serial %d", serial);
10516 #endif
10517
10518 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10519 V1_6::RadioResponseInfo responseInfo = {};
10520 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10521
10522 V1_6::SlicingConfig slicingConfig = {};
10523 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_6->
10524 getSlicingConfigResponse(responseInfo, slicingConfig);
10525 radioService[slotId]->checkReturnStatus(retStatus);
10526 } else {
10527 RLOGE("getSlicingConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10528 }
10529
10530 return 0;
10531 }
10532
getSimPhonebookRecordsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10533 int radio_1_6::getSimPhonebookRecordsResponse(int slotId, int responseType, int serial,
10534 RIL_Errno e, void *response, size_t responseLen) {
10535 #if VDBG
10536 RLOGD("getSimPhonebookRecordsResponse: serial %d", serial);
10537 #endif
10538
10539 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10540 V1_6::RadioResponseInfo responseInfo = {};
10541 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10542
10543 Return<void> retStatus =
10544 radioService[slotId]->mRadioResponseV1_6->getSimPhonebookRecordsResponse(
10545 responseInfo);
10546 radioService[slotId]->checkReturnStatus(retStatus);
10547 } else {
10548 RLOGE("getSimPhonebookRecordsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10549 }
10550
10551 return 0;
10552 }
10553
getSimPhonebookCapacityResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10554 int radio_1_6::getSimPhonebookCapacityResponse(int slotId, int responseType, int serial,
10555 RIL_Errno e, void *response, size_t responseLen) {
10556 #if VDBG
10557 RLOGD("getSimPhonebookCapacityResponse: serial %d", serial);
10558 #endif
10559
10560 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10561 V1_6::RadioResponseInfo responseInfo = {};
10562 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10563
10564 V1_6::PhonebookCapacity phonebookCapacity = {};
10565 Return<void> retStatus =
10566 radioService[slotId]->mRadioResponseV1_6->getSimPhonebookCapacityResponse(
10567 responseInfo, phonebookCapacity);
10568 radioService[slotId]->checkReturnStatus(retStatus);
10569 } else {
10570 RLOGE("getSimPhonebookCapacityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
10571 }
10572
10573 return 0;
10574 }
10575
updateSimPhonebookRecordsResponse(int slotId,int responseType,int serial,RIL_Errno e,void * response,size_t responseLen)10576 int radio_1_6::updateSimPhonebookRecordsResponse(int slotId, int responseType, int serial,
10577 RIL_Errno e, void *response, size_t responseLen) {
10578 #if VDBG
10579 RLOGD("updateSimPhonebookRecordsResponse: serial %d", serial);
10580 #endif
10581
10582 if (radioService[slotId]->mRadioResponseV1_6 != NULL) {
10583 V1_6::RadioResponseInfo responseInfo = {};
10584 populateResponseInfo_1_6(responseInfo, serial, responseType, e);
10585
10586 int32_t updatedRecordIndex = 0;
10587 Return<void> retStatus =
10588 radioService[slotId]->mRadioResponseV1_6->updateSimPhonebookRecordsResponse(
10589 responseInfo, updatedRecordIndex);
10590 radioService[slotId]->checkReturnStatus(retStatus);
10591 } else {
10592 RLOGE("updateSimPhonebookRecordsResponse: radioService[%d]->mRadioResponse == NULL",
10593 slotId);
10594 }
10595
10596 return 0;
10597 }
10598
10599 /***************************************************************************************************
10600 * INDICATION FUNCTIONS
10601 * The below function handle unsolicited messages coming from the Radio
10602 * (messages for which there is no pending request)
10603 **************************************************************************************************/
10604
convertIntToRadioIndicationType(int indicationType)10605 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
10606 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
10607 (RadioIndicationType::UNSOLICITED_ACK_EXP);
10608 }
10609
radioStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10610 int radio_1_6::radioStateChangedInd(int slotId,
10611 int indicationType, int token, RIL_Errno e, void *response,
10612 size_t responseLen) {
10613 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10614 RadioState radioState =
10615 (RadioState) CALL_ONSTATEREQUEST(slotId);
10616 RLOGD("radioStateChangedInd: radioState %d", radioState);
10617 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
10618 convertIntToRadioIndicationType(indicationType), radioState);
10619 radioService[slotId]->checkReturnStatus(retStatus);
10620 } else {
10621 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
10622 }
10623
10624 return 0;
10625 }
10626
callStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10627 int radio_1_6::callStateChangedInd(int slotId,
10628 int indicationType, int token, RIL_Errno e, void *response,
10629 size_t responseLen) {
10630 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10631 #if VDBG
10632 RLOGD("callStateChangedInd");
10633 #endif
10634 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
10635 convertIntToRadioIndicationType(indicationType));
10636 radioService[slotId]->checkReturnStatus(retStatus);
10637 } else {
10638 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
10639 }
10640
10641 return 0;
10642 }
10643
networkStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10644 int radio_1_6::networkStateChangedInd(int slotId,
10645 int indicationType, int token, RIL_Errno e, void *response,
10646 size_t responseLen) {
10647 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10648 #if VDBG
10649 RLOGD("networkStateChangedInd");
10650 #endif
10651 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
10652 convertIntToRadioIndicationType(indicationType));
10653 radioService[slotId]->checkReturnStatus(retStatus);
10654 } else {
10655 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
10656 slotId);
10657 }
10658
10659 return 0;
10660 }
10661
hexCharToInt(uint8_t c)10662 extern "C" uint8_t hexCharToInt(uint8_t c) {
10663 if (c >= '0' && c <= '9') return (c - '0');
10664 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
10665 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
10666
10667 return INVALID_HEX_CHAR;
10668 }
10669
convertHexStringToBytes(void * response,size_t responseLen)10670 extern "C" uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
10671 if (responseLen % 2 != 0) {
10672 return NULL;
10673 }
10674
10675 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
10676 if (bytes == NULL) {
10677 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
10678 return NULL;
10679 }
10680 uint8_t *hexString = (uint8_t *)response;
10681
10682 for (size_t i = 0; i < responseLen; i += 2) {
10683 uint8_t hexChar1 = hexCharToInt(hexString[i]);
10684 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
10685
10686 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
10687 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
10688 hexString[i], hexString[i + 1]);
10689 free(bytes);
10690 return NULL;
10691 }
10692 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
10693 }
10694
10695 return bytes;
10696 }
10697
newSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10698 int radio_1_6::newSmsInd(int slotId, int indicationType,
10699 int token, RIL_Errno e, void *response, size_t responseLen) {
10700 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10701 if (response == NULL || responseLen == 0) {
10702 RLOGE("newSmsInd: invalid response");
10703 return 0;
10704 }
10705
10706 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
10707 if (bytes == NULL) {
10708 RLOGE("newSmsInd: convertHexStringToBytes failed");
10709 return 0;
10710 }
10711
10712 hidl_vec<uint8_t> pdu;
10713 pdu.setToExternal(bytes, responseLen/2);
10714 #if VDBG
10715 RLOGD("newSmsInd");
10716 #endif
10717 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
10718 convertIntToRadioIndicationType(indicationType), pdu);
10719 radioService[slotId]->checkReturnStatus(retStatus);
10720 free(bytes);
10721 } else {
10722 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
10723 }
10724
10725 return 0;
10726 }
10727
newSmsStatusReportInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10728 int radio_1_6::newSmsStatusReportInd(int slotId,
10729 int indicationType, int token, RIL_Errno e, void *response,
10730 size_t responseLen) {
10731 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10732 if (response == NULL || responseLen == 0) {
10733 RLOGE("newSmsStatusReportInd: invalid response");
10734 return 0;
10735 }
10736
10737 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
10738 if (bytes == NULL) {
10739 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
10740 return 0;
10741 }
10742
10743 hidl_vec<uint8_t> pdu;
10744 pdu.setToExternal(bytes, responseLen/2);
10745 #if VDBG
10746 RLOGD("newSmsStatusReportInd");
10747 #endif
10748 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
10749 convertIntToRadioIndicationType(indicationType), pdu);
10750 radioService[slotId]->checkReturnStatus(retStatus);
10751 free(bytes);
10752 } else {
10753 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
10754 }
10755
10756 return 0;
10757 }
10758
newSmsOnSimInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10759 int radio_1_6::newSmsOnSimInd(int slotId, int indicationType,
10760 int token, RIL_Errno e, void *response, size_t responseLen) {
10761 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10762 if (response == NULL || responseLen != sizeof(int)) {
10763 RLOGE("newSmsOnSimInd: invalid response");
10764 return 0;
10765 }
10766 int32_t recordNumber = ((int32_t *) response)[0];
10767 #if VDBG
10768 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
10769 #endif
10770 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
10771 convertIntToRadioIndicationType(indicationType), recordNumber);
10772 radioService[slotId]->checkReturnStatus(retStatus);
10773 } else {
10774 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
10775 }
10776
10777 return 0;
10778 }
10779
onUssdInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10780 int radio_1_6::onUssdInd(int slotId, int indicationType,
10781 int token, RIL_Errno e, void *response, size_t responseLen) {
10782 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10783 if (response == NULL || responseLen != 2 * sizeof(char *)) {
10784 RLOGE("onUssdInd: invalid response");
10785 return 0;
10786 }
10787 char **strings = (char **) response;
10788 char *mode = strings[0];
10789 hidl_string msg = convertCharPtrToHidlString(strings[1]);
10790 UssdModeType modeType = (UssdModeType) atoi(mode);
10791 #if VDBG
10792 RLOGD("onUssdInd: mode %s", mode);
10793 #endif
10794 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
10795 convertIntToRadioIndicationType(indicationType), modeType, msg);
10796 radioService[slotId]->checkReturnStatus(retStatus);
10797 } else {
10798 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
10799 }
10800
10801 return 0;
10802 }
10803
nitzTimeReceivedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10804 int radio_1_6::nitzTimeReceivedInd(int slotId,
10805 int indicationType, int token, RIL_Errno e, void *response,
10806 size_t responseLen) {
10807 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
10808 if (response == NULL || responseLen == 0) {
10809 RLOGE("nitzTimeReceivedInd: invalid response");
10810 return 0;
10811 }
10812 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
10813 #if VDBG
10814 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
10815 nitzTimeReceived[slotId]);
10816 #endif
10817 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
10818 convertIntToRadioIndicationType(indicationType), nitzTime,
10819 nitzTimeReceived[slotId]);
10820 radioService[slotId]->checkReturnStatus(retStatus);
10821 } else {
10822 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
10823 return -1;
10824 }
10825
10826 return 0;
10827 }
10828
convertRilSignalStrengthToHal(void * response,size_t responseLen,SignalStrength & signalStrength)10829 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
10830 SignalStrength& signalStrength) {
10831 RIL_SignalStrength_v12 *rilSignalStrength = (RIL_SignalStrength_v12 *) response;
10832
10833 // Fixup LTE for backwards compatibility
10834 // signalStrength: -1 -> 99
10835 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
10836 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
10837 }
10838 // rsrp: -1 -> INT_MAX all other negative value to positive.
10839 // So remap here
10840 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
10841 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
10842 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
10843 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
10844 }
10845 // rsrq: -1 -> INT_MAX
10846 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
10847 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
10848 }
10849 // Not remapping rssnr is already using INT_MAX
10850 // cqi: -1 -> INT_MAX
10851 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
10852 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
10853 }
10854
10855 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
10856 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
10857 // RIL_SignalStrength_v10 not support gw.timingAdvance. Set to INT_MAX as
10858 // invalid value.
10859 signalStrength.gw.timingAdvance = INT_MAX;
10860
10861 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
10862 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
10863 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
10864 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
10865 signalStrength.evdo.signalNoiseRatio =
10866 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
10867 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
10868 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
10869 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
10870 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
10871 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
10872 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
10873 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
10874 }
10875
convertRilSignalStrengthToHal_1_2(void * response,size_t responseLen,V1_2::SignalStrength & signalStrength_1_2)10876 void convertRilSignalStrengthToHal_1_2(void* response, size_t responseLen,
10877 V1_2::SignalStrength& signalStrength_1_2) {
10878 SignalStrength signalStrength = {};
10879 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
10880 signalStrength_1_2.gsm = signalStrength.gw;
10881 signalStrength_1_2.cdma = signalStrength.cdma;
10882 signalStrength_1_2.evdo = signalStrength.evdo;
10883 signalStrength_1_2.lte = signalStrength.lte;
10884
10885 RIL_SignalStrength_v12* rilSignalStrength = (RIL_SignalStrength_v12*)response;
10886 signalStrength_1_2.wcdma.base.signalStrength =
10887 rilSignalStrength->WCDMA_SignalStrength.signalStrength;
10888 signalStrength_1_2.wcdma.base.bitErrorRate =
10889 rilSignalStrength->WCDMA_SignalStrength.bitErrorRate;
10890 signalStrength_1_2.wcdma.rscp = INT_MAX;
10891 signalStrength_1_2.wcdma.ecno = INT_MAX;
10892
10893 signalStrength_1_2.tdScdma.rscp = INT_MAX;
10894 }
10895
convertRilSignalStrengthToHal_1_4(void * response,size_t responseLen,V1_4::SignalStrength & signalStrength_1_4)10896 void convertRilSignalStrengthToHal_1_4(void *response, size_t responseLen,
10897 V1_4::SignalStrength& signalStrength_1_4) {
10898 SignalStrength signalStrength = {};
10899 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
10900 signalStrength_1_4.gsm = signalStrength.gw;
10901 signalStrength_1_4.cdma = signalStrength.cdma;
10902 signalStrength_1_4.evdo = signalStrength.evdo;
10903 signalStrength_1_4.lte = signalStrength.lte;
10904
10905 RIL_SignalStrength_v12 *rilSignalStrength = (RIL_SignalStrength_v12 *) response;
10906 signalStrength_1_4.wcdma.base.signalStrength =
10907 rilSignalStrength->WCDMA_SignalStrength.signalStrength;
10908 signalStrength_1_4.wcdma.base.bitErrorRate =
10909 rilSignalStrength->WCDMA_SignalStrength.bitErrorRate;
10910 signalStrength_1_4.wcdma.rscp = INT_MAX;
10911 signalStrength_1_4.wcdma.ecno = INT_MAX;
10912
10913 signalStrength_1_4.tdscdma.signalStrength = INT_MAX;
10914 signalStrength_1_4.tdscdma.bitErrorRate = INT_MAX;
10915 signalStrength_1_4.tdscdma.rscp = INT_MAX;
10916
10917 signalStrength_1_4.nr.ssRsrp = rilSignalStrength->NR_SignalStrength.ssRsrp;
10918 signalStrength_1_4.nr.ssRsrq = rilSignalStrength->NR_SignalStrength.ssRsrq;
10919 signalStrength_1_4.nr.ssSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
10920 signalStrength_1_4.nr.csiRsrp = rilSignalStrength->NR_SignalStrength.csiRsrp;
10921 signalStrength_1_4.nr.csiRsrq = rilSignalStrength->NR_SignalStrength.csiRsrq;
10922 signalStrength_1_4.nr.csiSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
10923 }
10924
convertRilSignalStrengthToHal_1_6(void * response,size_t responseLen,V1_6::SignalStrength & signalStrength_1_6)10925 void convertRilSignalStrengthToHal_1_6(void* response, size_t responseLen,
10926 V1_6::SignalStrength& signalStrength_1_6) {
10927 SignalStrength signalStrength = {};
10928 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
10929 signalStrength_1_6.gsm = signalStrength.gw;
10930 signalStrength_1_6.cdma = signalStrength.cdma;
10931 signalStrength_1_6.evdo = signalStrength.evdo;
10932 signalStrength_1_6.lte.base = signalStrength.lte;
10933
10934 RIL_SignalStrength_v12* rilSignalStrength = (RIL_SignalStrength_v12*)response;
10935 signalStrength_1_6.wcdma.base.signalStrength =
10936 rilSignalStrength->WCDMA_SignalStrength.signalStrength;
10937 signalStrength_1_6.wcdma.base.bitErrorRate =
10938 rilSignalStrength->WCDMA_SignalStrength.bitErrorRate;
10939 signalStrength_1_6.wcdma.rscp = INT_MAX;
10940 signalStrength_1_6.wcdma.ecno = INT_MAX;
10941
10942 signalStrength_1_6.tdscdma.signalStrength = INT_MAX;
10943 signalStrength_1_6.tdscdma.bitErrorRate = INT_MAX;
10944 signalStrength_1_6.tdscdma.rscp = INT_MAX;
10945
10946 signalStrength_1_6.nr.base.ssRsrp = rilSignalStrength->NR_SignalStrength.ssRsrp;
10947 signalStrength_1_6.nr.base.ssRsrq = rilSignalStrength->NR_SignalStrength.ssRsrq;
10948 signalStrength_1_6.nr.base.ssSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
10949 signalStrength_1_6.nr.base.csiRsrp = rilSignalStrength->NR_SignalStrength.csiRsrp;
10950 signalStrength_1_6.nr.base.csiRsrq = rilSignalStrength->NR_SignalStrength.csiRsrq;
10951 signalStrength_1_6.nr.base.csiSinr = rilSignalStrength->NR_SignalStrength.ssSinr;
10952 }
10953
currentSignalStrengthInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)10954 int radio_1_6::currentSignalStrengthInd(int slotId, int indicationType, int token, RIL_Errno e,
10955 void* response, size_t responseLen) {
10956 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndication != NULL ||
10957 radioService[slotId]->mRadioIndicationV1_2 != NULL ||
10958 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
10959 radioService[slotId]->mRadioIndicationV1_6 != NULL)) {
10960 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v12)) {
10961 RLOGE("currentSignalStrengthInd: invalid response");
10962 return 0;
10963 }
10964
10965 #if VDBG
10966 RLOGD("currentSignalStrengthInd");
10967 #endif
10968 Return<void> retStatus;
10969 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
10970 V1_6::SignalStrength signalStrength_1_6 = {};
10971 convertRilSignalStrengthToHal_1_6(response, responseLen, signalStrength_1_6);
10972 retStatus = radioService[slotId]->mRadioIndicationV1_6->currentSignalStrength_1_6(
10973 convertIntToRadioIndicationType(indicationType), signalStrength_1_6);
10974 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
10975 V1_4::SignalStrength signalStrength_1_4 = {};
10976 convertRilSignalStrengthToHal_1_4(response, responseLen, signalStrength_1_4);
10977 retStatus = radioService[slotId]->mRadioIndicationV1_4->currentSignalStrength_1_4(
10978 convertIntToRadioIndicationType(indicationType), signalStrength_1_4);
10979 } else if (radioService[slotId]->mRadioIndicationV1_2 != NULL) {
10980 V1_2::SignalStrength signalStrength_1_2 = {};
10981 convertRilSignalStrengthToHal_1_2(response, responseLen, signalStrength_1_2);
10982 retStatus = radioService[slotId]->mRadioIndicationV1_2->currentSignalStrength_1_2(
10983 convertIntToRadioIndicationType(indicationType), signalStrength_1_2);
10984 } else {
10985 SignalStrength signalStrength = {};
10986 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
10987 retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
10988 convertIntToRadioIndicationType(indicationType), signalStrength);
10989 }
10990 radioService[slotId]->checkReturnStatus(retStatus);
10991 } else {
10992 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
10993 slotId);
10994 }
10995
10996 return 0;
10997 }
10998
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,SetupDataCallResult & dcResult)10999 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
11000 SetupDataCallResult& dcResult) {
11001 dcResult.status = (DataCallFailCause) dcResponse->status;
11002 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
11003 dcResult.cid = dcResponse->cid;
11004 dcResult.active = dcResponse->active;
11005 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
11006 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
11007 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
11008 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
11009 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
11010 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
11011 dcResult.mtu = dcResponse->mtu;
11012 }
11013
split(hidl_string str)11014 hidl_vec<hidl_string> split(hidl_string str) {
11015 std::vector<hidl_string> ret;
11016 std::stringstream ss(static_cast<std::string>(str));
11017
11018 std::string tok;
11019
11020 while(getline(ss, tok, ' ')) {
11021 ret.push_back(hidl_string(tok));
11022 }
11023
11024 return ret;
11025 }
11026
convertToPdpProtocolType(hidl_string str)11027 ::android::hardware::radio::V1_4::PdpProtocolType convertToPdpProtocolType(hidl_string str) {
11028 if (strncmp("IP", str.c_str(), 2) == 0) {
11029 return ::android::hardware::radio::V1_4::PdpProtocolType::IP;
11030 } else if (strncmp("IPV6", str.c_str(), 4) == 0) {
11031 return ::android::hardware::radio::V1_4::PdpProtocolType::IPV6;
11032 } else if (strncmp("IPV4V6", str.c_str(), 6) == 0) {
11033 return ::android::hardware::radio::V1_4::PdpProtocolType::IPV4V6;
11034 } else if (strncmp("PPP", str.c_str(), 3) == 0) {
11035 return ::android::hardware::radio::V1_4::PdpProtocolType::PPP;
11036 } else if (strncmp("NON_IP", str.c_str(), 6) == 0) {
11037 return ::android::hardware::radio::V1_4::PdpProtocolType::NON_IP;
11038 } else if (strncmp("UNSTRUCTURED", str.c_str(), 12) == 0) {
11039 return ::android::hardware::radio::V1_4::PdpProtocolType::UNSTRUCTURED;
11040 } else {
11041 return ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
11042 }
11043 }
11044
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,::android::hardware::radio::V1_4::SetupDataCallResult & dcResult)11045 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
11046 ::android::hardware::radio::V1_4::SetupDataCallResult& dcResult) {
11047 dcResult.cause = (::android::hardware::radio::V1_4::DataCallFailCause) dcResponse->status;
11048 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
11049 dcResult.cid = dcResponse->cid;
11050 dcResult.active = (::android::hardware::radio::V1_4::DataConnActiveStatus)dcResponse->active;
11051 dcResult.type = convertToPdpProtocolType(convertCharPtrToHidlString(dcResponse->type));
11052 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
11053 dcResult.addresses = split(convertCharPtrToHidlString(dcResponse->addresses));
11054 dcResult.dnses = split(convertCharPtrToHidlString(dcResponse->dnses));
11055 dcResult.gateways = split(convertCharPtrToHidlString(dcResponse->gateways));
11056 dcResult.pcscf = split(convertCharPtrToHidlString(dcResponse->pcscf));
11057 dcResult.mtu = dcResponse->mtu;
11058 }
11059
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,::android::hardware::radio::V1_5::SetupDataCallResult & dcResult)11060 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
11061 ::android::hardware::radio::V1_5::SetupDataCallResult& dcResult) {
11062 dcResult.cause = (::android::hardware::radio::V1_4::DataCallFailCause) dcResponse->status;
11063 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
11064 dcResult.cid = dcResponse->cid;
11065 dcResult.active = (::android::hardware::radio::V1_4::DataConnActiveStatus)dcResponse->active;
11066 dcResult.type = convertToPdpProtocolType(convertCharPtrToHidlString(dcResponse->type));
11067 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
11068
11069 std::vector<::android::hardware::radio::V1_5::LinkAddress> linkAddresses;
11070 std::stringstream ss(static_cast<std::string>(dcResponse->addresses));
11071 std::string tok;
11072 while(getline(ss, tok, ' ')) {
11073 ::android::hardware::radio::V1_5::LinkAddress la;
11074 la.address = hidl_string(tok);
11075 la.properties = 0;
11076 la.deprecationTime = INT64_MAX; // LinkAddress.java LIFETIME_PERMANENT = Long.MAX_VALUE
11077 la.expirationTime = INT64_MAX; // --"--
11078 linkAddresses.push_back(la);
11079 }
11080
11081 dcResult.addresses = linkAddresses;
11082 dcResult.dnses = split(convertCharPtrToHidlString(dcResponse->dnses));
11083 dcResult.gateways = split(convertCharPtrToHidlString(dcResponse->gateways));
11084 dcResult.pcscf = split(convertCharPtrToHidlString(dcResponse->pcscf));
11085 dcResult.mtuV4 = dcResponse->mtu;
11086 dcResult.mtuV6 = dcResponse->mtu;
11087 }
11088
convertRilDataCallToHal(RIL_Data_Call_Response_v11 * dcResponse,::android::hardware::radio::V1_6::SetupDataCallResult & dcResult)11089 void convertRilDataCallToHal(RIL_Data_Call_Response_v11* dcResponse,
11090 ::android::hardware::radio::V1_6::SetupDataCallResult& dcResult) {
11091 dcResult.cause = (::android::hardware::radio::V1_6::DataCallFailCause) dcResponse->status;
11092 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
11093 dcResult.cid = dcResponse->cid;
11094 dcResult.active = (::android::hardware::radio::V1_4::DataConnActiveStatus)dcResponse->active;
11095 dcResult.type = convertToPdpProtocolType(convertCharPtrToHidlString(dcResponse->type));
11096 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
11097
11098 std::vector<::android::hardware::radio::V1_5::LinkAddress> linkAddresses;
11099 std::stringstream ss(static_cast<std::string>(dcResponse->addresses));
11100 std::string tok;
11101 while(getline(ss, tok, ' ')) {
11102 ::android::hardware::radio::V1_5::LinkAddress la;
11103 la.address = hidl_string(tok);
11104 la.properties = 0;
11105 la.deprecationTime = INT64_MAX; // LinkAddress.java LIFETIME_PERMANENT = Long.MAX_VALUE
11106 la.expirationTime = INT64_MAX; // --"--
11107 linkAddresses.push_back(la);
11108 }
11109
11110 dcResult.addresses = linkAddresses;
11111 dcResult.dnses = split(convertCharPtrToHidlString(dcResponse->dnses));
11112 dcResult.gateways = split(convertCharPtrToHidlString(dcResponse->gateways));
11113 dcResult.pcscf = split(convertCharPtrToHidlString(dcResponse->pcscf));
11114 dcResult.mtuV4 = dcResponse->mtu;
11115 dcResult.mtuV6 = dcResponse->mtu;
11116
11117 std::vector<::android::hardware::radio::V1_6::TrafficDescriptor> trafficDescriptors;
11118 ::android::hardware::radio::V1_6::TrafficDescriptor trafficDescriptor;
11119 ::android::hardware::radio::V1_6::OsAppId osAppId;
11120 osAppId.osAppId = osAppIdVec;
11121 trafficDescriptor.osAppId.value(osAppId);
11122 trafficDescriptors.push_back(trafficDescriptor);
11123 dcResult.trafficDescriptors = trafficDescriptors;
11124 }
11125
convertRilDataCallListToHal(void * response,size_t responseLen,hidl_vec<SetupDataCallResult> & dcResultList)11126 void convertRilDataCallListToHal(void *response, size_t responseLen,
11127 hidl_vec<SetupDataCallResult>& dcResultList) {
11128 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11129
11130 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
11131 dcResultList.resize(num);
11132 for (int i = 0; i < num; i++) {
11133 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11134 }
11135 }
11136
convertRilDataCallListToHal_1_4(void * response,size_t responseLen,hidl_vec<V1_4::SetupDataCallResult> & dcResultList)11137 void convertRilDataCallListToHal_1_4(void* response, size_t responseLen,
11138 hidl_vec<V1_4::SetupDataCallResult>& dcResultList) {
11139 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11140
11141 RIL_Data_Call_Response_v11* dcResponse = (RIL_Data_Call_Response_v11*)response;
11142 dcResultList.resize(num);
11143 for (int i = 0; i < num; i++) {
11144 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11145 }
11146 }
11147
convertRilDataCallListToHal_1_5(void * response,size_t responseLen,hidl_vec<V1_5::SetupDataCallResult> & dcResultList)11148 void convertRilDataCallListToHal_1_5(void* response, size_t responseLen,
11149 hidl_vec<V1_5::SetupDataCallResult>& dcResultList) {
11150 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11151
11152 RIL_Data_Call_Response_v11* dcResponse = (RIL_Data_Call_Response_v11*)response;
11153 dcResultList.resize(num);
11154 for (int i = 0; i < num; i++) {
11155 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11156 }
11157 }
11158
convertRilDataCallListToHal_1_6(void * response,size_t responseLen,hidl_vec<V1_6::SetupDataCallResult> & dcResultList)11159 void convertRilDataCallListToHal_1_6(void* response, size_t responseLen,
11160 hidl_vec<V1_6::SetupDataCallResult>& dcResultList) {
11161 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
11162
11163 RIL_Data_Call_Response_v11* dcResponse = (RIL_Data_Call_Response_v11*)response;
11164 dcResultList.resize(num);
11165 for (int i = 0; i < num; i++) {
11166 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
11167 }
11168 }
11169
dataCallListChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11170 int radio_1_6::dataCallListChangedInd(int slotId,
11171 int indicationType, int token, RIL_Errno e, void *response,
11172 size_t responseLen) {
11173 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndication != NULL ||
11174 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
11175 radioService[slotId]->mRadioIndicationV1_5 != NULL ||
11176 radioService[slotId]->mRadioIndicationV1_6 != NULL)) {
11177 if ((response == NULL && responseLen != 0)
11178 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
11179 RLOGE("dataCallListChangedInd: invalid response");
11180 return 0;
11181 }
11182 #if VDBG
11183 RLOGD("dataCallListChangedInd");
11184 #endif
11185 Return<void> retStatus;
11186 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
11187 hidl_vec<V1_6::SetupDataCallResult> dcList;
11188 convertRilDataCallListToHal_1_6(response, responseLen, dcList);
11189 retStatus = radioService[slotId]->mRadioIndicationV1_6->dataCallListChanged_1_6(
11190 convertIntToRadioIndicationType(indicationType), dcList);
11191 } else if (radioService[slotId]->mRadioIndicationV1_5 != NULL) {
11192 hidl_vec<V1_5::SetupDataCallResult> dcList;
11193 convertRilDataCallListToHal_1_5(response, responseLen, dcList);
11194 retStatus = radioService[slotId]->mRadioIndicationV1_5->dataCallListChanged_1_5(
11195 convertIntToRadioIndicationType(indicationType), dcList);
11196 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
11197 hidl_vec<V1_4::SetupDataCallResult> dcList;
11198 convertRilDataCallListToHal_1_4(response, responseLen, dcList);
11199 retStatus = radioService[slotId]->mRadioIndicationV1_4->dataCallListChanged_1_4(
11200 convertIntToRadioIndicationType(indicationType), dcList);
11201 } else {
11202 hidl_vec<SetupDataCallResult> dcList;
11203 convertRilDataCallListToHal(response, responseLen, dcList);
11204 retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
11205 convertIntToRadioIndicationType(indicationType), dcList);
11206 }
11207 radioService[slotId]->checkReturnStatus(retStatus);
11208 } else {
11209 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
11210 }
11211
11212 return 0;
11213 }
11214
suppSvcNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11215 int radio_1_6::suppSvcNotifyInd(int slotId, int indicationType,
11216 int token, RIL_Errno e, void *response, size_t responseLen) {
11217 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11218 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
11219 RLOGE("suppSvcNotifyInd: invalid response");
11220 return 0;
11221 }
11222
11223 SuppSvcNotification suppSvc = {};
11224 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
11225 suppSvc.isMT = ssn->notificationType;
11226 suppSvc.code = ssn->code;
11227 suppSvc.index = ssn->index;
11228 suppSvc.type = ssn->type;
11229 suppSvc.number = convertCharPtrToHidlString(ssn->number);
11230
11231 #if VDBG
11232 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
11233 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
11234 #endif
11235 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
11236 convertIntToRadioIndicationType(indicationType), suppSvc);
11237 radioService[slotId]->checkReturnStatus(retStatus);
11238 } else {
11239 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
11240 }
11241
11242 return 0;
11243 }
11244
stkSessionEndInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11245 int radio_1_6::stkSessionEndInd(int slotId, int indicationType,
11246 int token, RIL_Errno e, void *response, size_t responseLen) {
11247 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11248 #if VDBG
11249 RLOGD("stkSessionEndInd");
11250 #endif
11251 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
11252 convertIntToRadioIndicationType(indicationType));
11253 radioService[slotId]->checkReturnStatus(retStatus);
11254 } else {
11255 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
11256 }
11257
11258 return 0;
11259 }
11260
stkProactiveCommandInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11261 int radio_1_6::stkProactiveCommandInd(int slotId,
11262 int indicationType, int token, RIL_Errno e, void *response,
11263 size_t responseLen) {
11264 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11265 if (response == NULL || responseLen == 0) {
11266 RLOGE("stkProactiveCommandInd: invalid response");
11267 return 0;
11268 }
11269 #if VDBG
11270 RLOGD("stkProactiveCommandInd");
11271 #endif
11272 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
11273 convertIntToRadioIndicationType(indicationType),
11274 convertCharPtrToHidlString((char *) response));
11275 radioService[slotId]->checkReturnStatus(retStatus);
11276 } else {
11277 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
11278 }
11279
11280 return 0;
11281 }
11282
stkEventNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11283 int radio_1_6::stkEventNotifyInd(int slotId, int indicationType,
11284 int token, RIL_Errno e, void *response, size_t responseLen) {
11285 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11286 if (response == NULL || responseLen == 0) {
11287 RLOGE("stkEventNotifyInd: invalid response");
11288 return 0;
11289 }
11290 #if VDBG
11291 RLOGD("stkEventNotifyInd");
11292 #endif
11293 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
11294 convertIntToRadioIndicationType(indicationType),
11295 convertCharPtrToHidlString((char *) response));
11296 radioService[slotId]->checkReturnStatus(retStatus);
11297 } else {
11298 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
11299 }
11300
11301 return 0;
11302 }
11303
stkCallSetupInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11304 int radio_1_6::stkCallSetupInd(int slotId, int indicationType,
11305 int token, RIL_Errno e, void *response, size_t responseLen) {
11306 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11307 if (response == NULL || responseLen != sizeof(int)) {
11308 RLOGE("stkCallSetupInd: invalid response");
11309 return 0;
11310 }
11311 int32_t timeout = ((int32_t *) response)[0];
11312 #if VDBG
11313 RLOGD("stkCallSetupInd: timeout %d", timeout);
11314 #endif
11315 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
11316 convertIntToRadioIndicationType(indicationType), timeout);
11317 radioService[slotId]->checkReturnStatus(retStatus);
11318 } else {
11319 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
11320 }
11321
11322 return 0;
11323 }
11324
simSmsStorageFullInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11325 int radio_1_6::simSmsStorageFullInd(int slotId,
11326 int indicationType, int token, RIL_Errno e, void *response,
11327 size_t responseLen) {
11328 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11329 #if VDBG
11330 RLOGD("simSmsStorageFullInd");
11331 #endif
11332 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
11333 convertIntToRadioIndicationType(indicationType));
11334 radioService[slotId]->checkReturnStatus(retStatus);
11335 } else {
11336 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
11337 }
11338
11339 return 0;
11340 }
11341
simRefreshInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11342 int radio_1_6::simRefreshInd(int slotId, int indicationType,
11343 int token, RIL_Errno e, void *response, size_t responseLen) {
11344 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11345 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
11346 RLOGE("simRefreshInd: invalid response");
11347 return 0;
11348 }
11349
11350 SimRefreshResult refreshResult = {};
11351 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
11352 refreshResult.type =
11353 (V1_0::SimRefreshType) simRefreshResponse->result;
11354 refreshResult.efId = simRefreshResponse->ef_id;
11355 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
11356
11357 #if VDBG
11358 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
11359 #endif
11360 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
11361 convertIntToRadioIndicationType(indicationType), refreshResult);
11362 radioService[slotId]->checkReturnStatus(retStatus);
11363 } else {
11364 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
11365 }
11366
11367 return 0;
11368 }
11369
convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord * signalInfoRecord,CdmaSignalInfoRecord & record)11370 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
11371 CdmaSignalInfoRecord& record) {
11372 record.isPresent = signalInfoRecord->isPresent;
11373 record.signalType = signalInfoRecord->signalType;
11374 record.alertPitch = signalInfoRecord->alertPitch;
11375 record.signal = signalInfoRecord->signal;
11376 }
11377
callRingInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11378 int radio_1_6::callRingInd(int slotId, int indicationType,
11379 int token, RIL_Errno e, void *response, size_t responseLen) {
11380 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11381 bool isGsm;
11382 CdmaSignalInfoRecord record = {};
11383 if (response == NULL || responseLen == 0) {
11384 isGsm = true;
11385 } else {
11386 isGsm = false;
11387 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
11388 RLOGE("callRingInd: invalid response");
11389 return 0;
11390 }
11391 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
11392 }
11393
11394 #if VDBG
11395 RLOGD("callRingInd: isGsm %d", isGsm);
11396 #endif
11397 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
11398 convertIntToRadioIndicationType(indicationType), isGsm, record);
11399 radioService[slotId]->checkReturnStatus(retStatus);
11400 } else {
11401 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
11402 }
11403
11404 return 0;
11405 }
11406
simStatusChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11407 int radio_1_6::simStatusChangedInd(int slotId,
11408 int indicationType, int token, RIL_Errno e, void *response,
11409 size_t responseLen) {
11410 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11411 #if VDBG
11412 RLOGD("simStatusChangedInd");
11413 #endif
11414 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
11415 convertIntToRadioIndicationType(indicationType));
11416 radioService[slotId]->checkReturnStatus(retStatus);
11417 } else {
11418 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
11419 }
11420
11421 return 0;
11422 }
11423
cdmaNewSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11424 int radio_1_6::cdmaNewSmsInd(int slotId, int indicationType,
11425 int token, RIL_Errno e, void *response, size_t responseLen) {
11426 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11427 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
11428 RLOGE("cdmaNewSmsInd: invalid response");
11429 return 0;
11430 }
11431
11432 CdmaSmsMessage msg = {};
11433 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
11434 msg.teleserviceId = rilMsg->uTeleserviceID;
11435 msg.isServicePresent = rilMsg->bIsServicePresent;
11436 msg.serviceCategory = rilMsg->uServicecategory;
11437 msg.address.digitMode =
11438 (V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
11439 msg.address.numberMode =
11440 (V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
11441 msg.address.numberType =
11442 (V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
11443 msg.address.numberPlan =
11444 (V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
11445
11446 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
11447 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
11448
11449 msg.subAddress.subaddressType = (V1_0::CdmaSmsSubaddressType)
11450 rilMsg->sSubAddress.subaddressType;
11451 msg.subAddress.odd = rilMsg->sSubAddress.odd;
11452
11453 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
11454 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
11455
11456 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
11457 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
11458
11459 #if VDBG
11460 RLOGD("cdmaNewSmsInd");
11461 #endif
11462 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
11463 convertIntToRadioIndicationType(indicationType), msg);
11464 radioService[slotId]->checkReturnStatus(retStatus);
11465 } else {
11466 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
11467 }
11468
11469 return 0;
11470 }
11471
newBroadcastSmsInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11472 int radio_1_6::newBroadcastSmsInd(int slotId,
11473 int indicationType, int token, RIL_Errno e, void *response,
11474 size_t responseLen) {
11475 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11476 if (response == NULL || responseLen == 0) {
11477 RLOGE("newBroadcastSmsInd: invalid response");
11478 return 0;
11479 }
11480
11481 hidl_vec<uint8_t> data;
11482 data.setToExternal((uint8_t *) response, responseLen);
11483 #if VDBG
11484 RLOGD("newBroadcastSmsInd");
11485 #endif
11486 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
11487 convertIntToRadioIndicationType(indicationType), data);
11488 radioService[slotId]->checkReturnStatus(retStatus);
11489 } else {
11490 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
11491 }
11492
11493 return 0;
11494 }
11495
cdmaRuimSmsStorageFullInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11496 int radio_1_6::cdmaRuimSmsStorageFullInd(int slotId,
11497 int indicationType, int token, RIL_Errno e, void *response,
11498 size_t responseLen) {
11499 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11500 #if VDBG
11501 RLOGD("cdmaRuimSmsStorageFullInd");
11502 #endif
11503 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
11504 convertIntToRadioIndicationType(indicationType));
11505 radioService[slotId]->checkReturnStatus(retStatus);
11506 } else {
11507 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
11508 slotId);
11509 }
11510
11511 return 0;
11512 }
11513
restrictedStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11514 int radio_1_6::restrictedStateChangedInd(int slotId,
11515 int indicationType, int token, RIL_Errno e, void *response,
11516 size_t responseLen) {
11517 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11518 if (response == NULL || responseLen != sizeof(int)) {
11519 RLOGE("restrictedStateChangedInd: invalid response");
11520 return 0;
11521 }
11522 int32_t state = ((int32_t *) response)[0];
11523 #if VDBG
11524 RLOGD("restrictedStateChangedInd: state %d", state);
11525 #endif
11526 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
11527 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
11528 radioService[slotId]->checkReturnStatus(retStatus);
11529 } else {
11530 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
11531 slotId);
11532 }
11533
11534 return 0;
11535 }
11536
enterEmergencyCallbackModeInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11537 int radio_1_6::enterEmergencyCallbackModeInd(int slotId,
11538 int indicationType, int token, RIL_Errno e, void *response,
11539 size_t responseLen) {
11540 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11541 #if VDBG
11542 RLOGD("enterEmergencyCallbackModeInd");
11543 #endif
11544 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
11545 convertIntToRadioIndicationType(indicationType));
11546 radioService[slotId]->checkReturnStatus(retStatus);
11547 } else {
11548 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
11549 slotId);
11550 }
11551
11552 return 0;
11553 }
11554
cdmaCallWaitingInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11555 int radio_1_6::cdmaCallWaitingInd(int slotId,
11556 int indicationType, int token, RIL_Errno e, void *response,
11557 size_t responseLen) {
11558 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11559 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
11560 RLOGE("cdmaCallWaitingInd: invalid response");
11561 return 0;
11562 }
11563
11564 CdmaCallWaiting callWaitingRecord = {};
11565 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
11566 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
11567 callWaitingRecord.numberPresentation =
11568 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
11569 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
11570 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
11571 callWaitingRecord.signalInfoRecord);
11572 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
11573 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
11574
11575 #if VDBG
11576 RLOGD("cdmaCallWaitingInd");
11577 #endif
11578 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
11579 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
11580 radioService[slotId]->checkReturnStatus(retStatus);
11581 } else {
11582 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
11583 }
11584
11585 return 0;
11586 }
11587
cdmaOtaProvisionStatusInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11588 int radio_1_6::cdmaOtaProvisionStatusInd(int slotId,
11589 int indicationType, int token, RIL_Errno e, void *response,
11590 size_t responseLen) {
11591 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11592 if (response == NULL || responseLen != sizeof(int)) {
11593 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
11594 return 0;
11595 }
11596 int32_t status = ((int32_t *) response)[0];
11597 #if VDBG
11598 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
11599 #endif
11600 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
11601 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
11602 radioService[slotId]->checkReturnStatus(retStatus);
11603 } else {
11604 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
11605 slotId);
11606 }
11607
11608 return 0;
11609 }
11610
cdmaInfoRecInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11611 int radio_1_6::cdmaInfoRecInd(int slotId,
11612 int indicationType, int token, RIL_Errno e, void *response,
11613 size_t responseLen) {
11614 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11615 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
11616 RLOGE("cdmaInfoRecInd: invalid response");
11617 return 0;
11618 }
11619
11620 CdmaInformationRecords records = {};
11621 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
11622
11623 char* string8 = NULL;
11624 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
11625 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
11626 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
11627 "additional ones", recordsRil->numberOfInfoRecs,
11628 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
11629 }
11630 records.infoRec.resize(num);
11631 for (int i = 0 ; i < num ; i++) {
11632 CdmaInformationRecord *record = &records.infoRec[i];
11633 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
11634 record->name = (CdmaInfoRecName) infoRec->name;
11635 // All vectors should be size 0 except one which will be size 1. Set everything to
11636 // size 0 initially.
11637 record->display.resize(0);
11638 record->number.resize(0);
11639 record->signal.resize(0);
11640 record->redir.resize(0);
11641 record->lineCtrl.resize(0);
11642 record->clir.resize(0);
11643 record->audioCtrl.resize(0);
11644 switch (infoRec->name) {
11645 case RIL_CDMA_DISPLAY_INFO_REC:
11646 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
11647 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
11648 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
11649 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
11650 CDMA_ALPHA_INFO_BUFFER_LENGTH);
11651 return 0;
11652 }
11653 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
11654 if (string8 == NULL) {
11655 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
11656 "responseCdmaInformationRecords");
11657 return 0;
11658 }
11659 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
11660 string8[(int)infoRec->rec.display.alpha_len] = '\0';
11661
11662 record->display.resize(1);
11663 record->display[0].alphaBuf = string8;
11664 free(string8);
11665 string8 = NULL;
11666 break;
11667 }
11668
11669 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
11670 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
11671 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
11672 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
11673 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
11674 "expected not more than %d", (int) infoRec->rec.number.len,
11675 CDMA_NUMBER_INFO_BUFFER_LENGTH);
11676 return 0;
11677 }
11678 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
11679 if (string8 == NULL) {
11680 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
11681 "responseCdmaInformationRecords");
11682 return 0;
11683 }
11684 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
11685 string8[(int)infoRec->rec.number.len] = '\0';
11686
11687 record->number.resize(1);
11688 record->number[0].number = string8;
11689 free(string8);
11690 string8 = NULL;
11691 record->number[0].numberType = infoRec->rec.number.number_type;
11692 record->number[0].numberPlan = infoRec->rec.number.number_plan;
11693 record->number[0].pi = infoRec->rec.number.pi;
11694 record->number[0].si = infoRec->rec.number.si;
11695 break;
11696 }
11697
11698 case RIL_CDMA_SIGNAL_INFO_REC: {
11699 record->signal.resize(1);
11700 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
11701 record->signal[0].signalType = infoRec->rec.signal.signalType;
11702 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
11703 record->signal[0].signal = infoRec->rec.signal.signal;
11704 break;
11705 }
11706
11707 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
11708 if (infoRec->rec.redir.redirectingNumber.len >
11709 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
11710 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
11711 "expected not more than %d\n",
11712 (int)infoRec->rec.redir.redirectingNumber.len,
11713 CDMA_NUMBER_INFO_BUFFER_LENGTH);
11714 return 0;
11715 }
11716 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
11717 sizeof(char));
11718 if (string8 == NULL) {
11719 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
11720 "responseCdmaInformationRecords");
11721 return 0;
11722 }
11723 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
11724 infoRec->rec.redir.redirectingNumber.len);
11725 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
11726
11727 record->redir.resize(1);
11728 record->redir[0].redirectingNumber.number = string8;
11729 free(string8);
11730 string8 = NULL;
11731 record->redir[0].redirectingNumber.numberType =
11732 infoRec->rec.redir.redirectingNumber.number_type;
11733 record->redir[0].redirectingNumber.numberPlan =
11734 infoRec->rec.redir.redirectingNumber.number_plan;
11735 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
11736 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
11737 record->redir[0].redirectingReason =
11738 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
11739 break;
11740 }
11741
11742 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
11743 record->lineCtrl.resize(1);
11744 record->lineCtrl[0].lineCtrlPolarityIncluded =
11745 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
11746 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
11747 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
11748 record->lineCtrl[0].lineCtrlPowerDenial =
11749 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
11750 break;
11751 }
11752
11753 case RIL_CDMA_T53_CLIR_INFO_REC: {
11754 record->clir.resize(1);
11755 record->clir[0].cause = infoRec->rec.clir.cause;
11756 break;
11757 }
11758
11759 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
11760 record->audioCtrl.resize(1);
11761 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
11762 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
11763 break;
11764 }
11765
11766 case RIL_CDMA_T53_RELEASE_INFO_REC:
11767 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
11768 return 0;
11769
11770 default:
11771 RLOGE("cdmaInfoRecInd: Incorrect name value");
11772 return 0;
11773 }
11774 }
11775
11776 #if VDBG
11777 RLOGD("cdmaInfoRecInd");
11778 #endif
11779 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
11780 convertIntToRadioIndicationType(indicationType), records);
11781 radioService[slotId]->checkReturnStatus(retStatus);
11782 } else {
11783 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
11784 }
11785
11786 return 0;
11787 }
11788
indicateRingbackToneInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11789 int radio_1_6::indicateRingbackToneInd(int slotId,
11790 int indicationType, int token, RIL_Errno e, void *response,
11791 size_t responseLen) {
11792 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11793 if (response == NULL || responseLen != sizeof(int)) {
11794 RLOGE("indicateRingbackToneInd: invalid response");
11795 return 0;
11796 }
11797 bool start = ((int32_t *) response)[0];
11798 #if VDBG
11799 RLOGD("indicateRingbackToneInd: start %d", start);
11800 #endif
11801 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
11802 convertIntToRadioIndicationType(indicationType), start);
11803 radioService[slotId]->checkReturnStatus(retStatus);
11804 } else {
11805 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
11806 }
11807
11808 return 0;
11809 }
11810
resendIncallMuteInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11811 int radio_1_6::resendIncallMuteInd(int slotId,
11812 int indicationType, int token, RIL_Errno e, void *response,
11813 size_t responseLen) {
11814 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11815 #if VDBG
11816 RLOGD("resendIncallMuteInd");
11817 #endif
11818 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
11819 convertIntToRadioIndicationType(indicationType));
11820 radioService[slotId]->checkReturnStatus(retStatus);
11821 } else {
11822 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
11823 }
11824
11825 return 0;
11826 }
11827
cdmaSubscriptionSourceChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11828 int radio_1_6::cdmaSubscriptionSourceChangedInd(int slotId,
11829 int indicationType, int token, RIL_Errno e,
11830 void *response, size_t responseLen) {
11831 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11832 if (response == NULL || responseLen != sizeof(int)) {
11833 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
11834 return 0;
11835 }
11836 int32_t cdmaSource = ((int32_t *) response)[0];
11837 #if VDBG
11838 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
11839 #endif
11840 Return<void> retStatus = radioService[slotId]->mRadioIndication->
11841 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
11842 (CdmaSubscriptionSource) cdmaSource);
11843 radioService[slotId]->checkReturnStatus(retStatus);
11844 } else {
11845 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
11846 slotId);
11847 }
11848
11849 return 0;
11850 }
11851
cdmaPrlChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11852 int radio_1_6::cdmaPrlChangedInd(int slotId,
11853 int indicationType, int token, RIL_Errno e, void *response,
11854 size_t responseLen) {
11855 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11856 if (response == NULL || responseLen != sizeof(int)) {
11857 RLOGE("cdmaPrlChangedInd: invalid response");
11858 return 0;
11859 }
11860 int32_t version = ((int32_t *) response)[0];
11861 #if VDBG
11862 RLOGD("cdmaPrlChangedInd: version %d", version);
11863 #endif
11864 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
11865 convertIntToRadioIndicationType(indicationType), version);
11866 radioService[slotId]->checkReturnStatus(retStatus);
11867 } else {
11868 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
11869 }
11870
11871 return 0;
11872 }
11873
exitEmergencyCallbackModeInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11874 int radio_1_6::exitEmergencyCallbackModeInd(int slotId,
11875 int indicationType, int token, RIL_Errno e, void *response,
11876 size_t responseLen) {
11877 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11878 #if VDBG
11879 RLOGD("exitEmergencyCallbackModeInd");
11880 #endif
11881 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
11882 convertIntToRadioIndicationType(indicationType));
11883 radioService[slotId]->checkReturnStatus(retStatus);
11884 } else {
11885 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
11886 slotId);
11887 }
11888
11889 return 0;
11890 }
11891
rilConnectedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11892 int radio_1_6::rilConnectedInd(int slotId,
11893 int indicationType, int token, RIL_Errno e, void *response,
11894 size_t responseLen) {
11895 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11896 RLOGD("rilConnectedInd");
11897 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
11898 convertIntToRadioIndicationType(indicationType));
11899 radioService[slotId]->checkReturnStatus(retStatus);
11900 } else {
11901 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
11902 }
11903
11904 return 0;
11905 }
11906
voiceRadioTechChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)11907 int radio_1_6::voiceRadioTechChangedInd(int slotId,
11908 int indicationType, int token, RIL_Errno e, void *response,
11909 size_t responseLen) {
11910 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
11911 if (response == NULL || responseLen != sizeof(int)) {
11912 RLOGE("voiceRadioTechChangedInd: invalid response");
11913 return 0;
11914 }
11915 int32_t rat = ((int32_t *) response)[0];
11916 #if VDBG
11917 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
11918 #endif
11919 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
11920 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
11921 radioService[slotId]->checkReturnStatus(retStatus);
11922 } else {
11923 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
11924 slotId);
11925 }
11926
11927 return 0;
11928 }
11929
convertRilCellInfoListToHal(void * response,size_t responseLen,hidl_vec<CellInfo> & records)11930 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
11931 int num = responseLen / sizeof(RIL_CellInfo_v12);
11932 records.resize(num);
11933
11934 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
11935 for (int i = 0; i < num; i++) {
11936 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
11937 records[i].registered = rillCellInfo->registered;
11938 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
11939 records[i].timeStamp = rillCellInfo->timeStamp;
11940 // All vectors should be size 0 except one which will be size 1. Set everything to
11941 // size 0 initially.
11942 records[i].gsm.resize(0);
11943 records[i].wcdma.resize(0);
11944 records[i].cdma.resize(0);
11945 records[i].lte.resize(0);
11946 records[i].tdscdma.resize(0);
11947 switch(rillCellInfo->cellInfoType) {
11948 case RIL_CELL_INFO_TYPE_GSM: {
11949 records[i].gsm.resize(1);
11950 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
11951 cellInfoGsm->cellIdentityGsm.mcc =
11952 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
11953 cellInfoGsm->cellIdentityGsm.mnc =
11954 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
11955 cellInfoGsm->cellIdentityGsm.lac =
11956 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
11957 cellInfoGsm->cellIdentityGsm.cid =
11958 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
11959 cellInfoGsm->cellIdentityGsm.arfcn =
11960 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
11961 cellInfoGsm->cellIdentityGsm.bsic =
11962 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
11963 cellInfoGsm->signalStrengthGsm.signalStrength =
11964 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
11965 cellInfoGsm->signalStrengthGsm.bitErrorRate =
11966 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
11967 cellInfoGsm->signalStrengthGsm.timingAdvance =
11968 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
11969 break;
11970 }
11971
11972 case RIL_CELL_INFO_TYPE_WCDMA: {
11973 records[i].wcdma.resize(1);
11974 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
11975 cellInfoWcdma->cellIdentityWcdma.mcc =
11976 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
11977 cellInfoWcdma->cellIdentityWcdma.mnc =
11978 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
11979 cellInfoWcdma->cellIdentityWcdma.lac =
11980 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
11981 cellInfoWcdma->cellIdentityWcdma.cid =
11982 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
11983 cellInfoWcdma->cellIdentityWcdma.psc =
11984 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
11985 cellInfoWcdma->cellIdentityWcdma.uarfcn =
11986 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
11987 cellInfoWcdma->signalStrengthWcdma.signalStrength =
11988 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
11989 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
11990 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
11991 break;
11992 }
11993
11994 case RIL_CELL_INFO_TYPE_CDMA: {
11995 records[i].cdma.resize(1);
11996 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
11997 cellInfoCdma->cellIdentityCdma.networkId =
11998 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
11999 cellInfoCdma->cellIdentityCdma.systemId =
12000 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12001 cellInfoCdma->cellIdentityCdma.baseStationId =
12002 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12003 cellInfoCdma->cellIdentityCdma.longitude =
12004 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12005 cellInfoCdma->cellIdentityCdma.latitude =
12006 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12007 cellInfoCdma->signalStrengthCdma.dbm =
12008 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12009 cellInfoCdma->signalStrengthCdma.ecio =
12010 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12011 cellInfoCdma->signalStrengthEvdo.dbm =
12012 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12013 cellInfoCdma->signalStrengthEvdo.ecio =
12014 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12015 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
12016 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12017 break;
12018 }
12019
12020 case RIL_CELL_INFO_TYPE_LTE: {
12021 records[i].lte.resize(1);
12022 CellInfoLte *cellInfoLte = &records[i].lte[0];
12023 cellInfoLte->cellIdentityLte.mcc =
12024 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12025 cellInfoLte->cellIdentityLte.mnc =
12026 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12027 cellInfoLte->cellIdentityLte.ci =
12028 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12029 cellInfoLte->cellIdentityLte.pci =
12030 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12031 cellInfoLte->cellIdentityLte.tac =
12032 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12033 cellInfoLte->cellIdentityLte.earfcn =
12034 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12035 cellInfoLte->signalStrengthLte.signalStrength =
12036 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12037 cellInfoLte->signalStrengthLte.rsrp =
12038 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12039 cellInfoLte->signalStrengthLte.rsrq =
12040 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12041 cellInfoLte->signalStrengthLte.rssnr =
12042 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12043 cellInfoLte->signalStrengthLte.cqi =
12044 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12045 cellInfoLte->signalStrengthLte.timingAdvance =
12046 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12047 break;
12048 }
12049
12050 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12051 records[i].tdscdma.resize(1);
12052 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
12053 cellInfoTdscdma->cellIdentityTdscdma.mcc =
12054 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12055 cellInfoTdscdma->cellIdentityTdscdma.mnc =
12056 ril::util::mnc::decode(
12057 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12058 cellInfoTdscdma->cellIdentityTdscdma.lac =
12059 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12060 cellInfoTdscdma->cellIdentityTdscdma.cid =
12061 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12062 cellInfoTdscdma->cellIdentityTdscdma.cpid =
12063 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12064 cellInfoTdscdma->signalStrengthTdscdma.rscp =
12065 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12066 break;
12067 }
12068 default: {
12069 break;
12070 }
12071 }
12072 rillCellInfo += 1;
12073 }
12074 }
12075
convertRilCellInfoListToHal_1_2(void * response,size_t responseLen,hidl_vec<V1_2::CellInfo> & records)12076 void convertRilCellInfoListToHal_1_2(void *response, size_t responseLen, hidl_vec<V1_2::CellInfo>& records) {
12077 int num = responseLen / sizeof(RIL_CellInfo_v12);
12078 records.resize(num);
12079 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
12080 for (int i = 0; i < num; i++) {
12081 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
12082 records[i].registered = rillCellInfo->registered;
12083 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
12084 records[i].timeStamp = rillCellInfo->timeStamp;
12085 records[i].connectionStatus =(V1_2::CellConnectionStatus)0;
12086 // All vectors should be size 0 except one which will be size 1. Set everything to
12087 // size 0 initially.
12088 records[i].gsm.resize(0);
12089 records[i].wcdma.resize(0);
12090 records[i].cdma.resize(0);
12091 records[i].lte.resize(0);
12092 records[i].tdscdma.resize(0);
12093 switch(rillCellInfo->cellInfoType) {
12094 case RIL_CELL_INFO_TYPE_GSM: {
12095 records[i].gsm.resize(1);
12096 V1_2::CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
12097 cellInfoGsm->cellIdentityGsm.base.mcc =
12098 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12099 cellInfoGsm->cellIdentityGsm.base.mnc =
12100 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12101 cellInfoGsm->cellIdentityGsm.base.lac =
12102 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12103 cellInfoGsm->cellIdentityGsm.base.cid =
12104 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12105 cellInfoGsm->cellIdentityGsm.base.arfcn =
12106 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12107 cellInfoGsm->cellIdentityGsm.base.bsic =
12108 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12109 cellInfoGsm->signalStrengthGsm.signalStrength =
12110 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12111 cellInfoGsm->signalStrengthGsm.bitErrorRate =
12112 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12113 cellInfoGsm->signalStrengthGsm.timingAdvance =
12114 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12115 break;
12116 }
12117
12118 case RIL_CELL_INFO_TYPE_WCDMA: {
12119 records[i].wcdma.resize(1);
12120 V1_2::CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
12121 cellInfoWcdma->cellIdentityWcdma.base.mcc =
12122 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12123 cellInfoWcdma->cellIdentityWcdma.base.mnc =
12124 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12125 cellInfoWcdma->cellIdentityWcdma.base.lac =
12126 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12127 cellInfoWcdma->cellIdentityWcdma.base.cid =
12128 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12129 cellInfoWcdma->cellIdentityWcdma.base.psc =
12130 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12131 cellInfoWcdma->cellIdentityWcdma.base.uarfcn =
12132 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12133 cellInfoWcdma->signalStrengthWcdma.base.signalStrength =
12134 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12135 cellInfoWcdma->signalStrengthWcdma.base.bitErrorRate =
12136 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12137 break;
12138 }
12139
12140 case RIL_CELL_INFO_TYPE_CDMA: {
12141 records[i].cdma.resize(1);
12142 V1_2::CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
12143 cellInfoCdma->cellIdentityCdma.base.networkId =
12144 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12145 cellInfoCdma->cellIdentityCdma.base.systemId =
12146 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12147 cellInfoCdma->cellIdentityCdma.base.baseStationId =
12148 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12149 cellInfoCdma->cellIdentityCdma.base.longitude =
12150 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12151 cellInfoCdma->cellIdentityCdma.base.latitude =
12152 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12153 cellInfoCdma->signalStrengthCdma.dbm =
12154 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12155 cellInfoCdma->signalStrengthCdma.ecio =
12156 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12157 cellInfoCdma->signalStrengthEvdo.dbm =
12158 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12159 cellInfoCdma->signalStrengthEvdo.ecio =
12160 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12161 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
12162 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12163 break;
12164 }
12165
12166 case RIL_CELL_INFO_TYPE_LTE: {
12167 records[i].lte.resize(1);
12168 V1_2::CellInfoLte *cellInfoLte = &records[i].lte[0];
12169 cellInfoLte->cellIdentityLte.base.mcc =
12170 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12171 cellInfoLte->cellIdentityLte.base.mnc =
12172 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12173 cellInfoLte->cellIdentityLte.base.ci =
12174 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12175 cellInfoLte->cellIdentityLte.base.pci =
12176 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12177 cellInfoLte->cellIdentityLte.base.tac =
12178 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12179 cellInfoLte->cellIdentityLte.base.earfcn =
12180 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12181 cellInfoLte->signalStrengthLte.signalStrength =
12182 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12183 cellInfoLte->signalStrengthLte.rsrp =
12184 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12185 cellInfoLte->signalStrengthLte.rsrq =
12186 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12187 cellInfoLte->signalStrengthLte.rssnr =
12188 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12189 cellInfoLte->signalStrengthLte.cqi =
12190 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12191 cellInfoLte->signalStrengthLte.timingAdvance =
12192 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12193 break;
12194 }
12195
12196 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12197 records[i].tdscdma.resize(1);
12198 V1_2::CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
12199 cellInfoTdscdma->cellIdentityTdscdma.base.mcc =
12200 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12201 cellInfoTdscdma->cellIdentityTdscdma.base.mnc =
12202 ril::util::mnc::decode(
12203 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12204 cellInfoTdscdma->cellIdentityTdscdma.base.lac =
12205 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12206 cellInfoTdscdma->cellIdentityTdscdma.base.cid =
12207 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12208 cellInfoTdscdma->cellIdentityTdscdma.base.cpid =
12209 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12210 cellInfoTdscdma->signalStrengthTdscdma.rscp =
12211 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12212 break;
12213 }
12214 default: {
12215 break;
12216 }
12217 }
12218 rillCellInfo += 1;
12219 }
12220 }
12221
convertRilCellInfoListToHal_1_4(void * response,size_t responseLen,hidl_vec<V1_4::CellInfo> & records)12222 void convertRilCellInfoListToHal_1_4(void *response, size_t responseLen, hidl_vec<V1_4::CellInfo>& records) {
12223 int num = responseLen / sizeof(RIL_CellInfo_v16);
12224 records.resize(num);
12225 RIL_CellInfo_v16 *rillCellInfo = (RIL_CellInfo_v16 *) response;
12226 for (int i = 0; i < num; i++) {
12227 records[i].isRegistered = rillCellInfo->registered;
12228 records[i].connectionStatus = (V1_2::CellConnectionStatus)rillCellInfo->connectionStatus;
12229
12230 switch(rillCellInfo->cellInfoType) {
12231 case RIL_CELL_INFO_TYPE_GSM: {
12232 V1_2::CellInfoGsm cellInfoGsm;
12233 cellInfoGsm.cellIdentityGsm.base.mcc =
12234 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12235 cellInfoGsm.cellIdentityGsm.base.mnc =
12236 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12237 cellInfoGsm.cellIdentityGsm.base.lac =
12238 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12239 cellInfoGsm.cellIdentityGsm.base.cid =
12240 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12241 cellInfoGsm.cellIdentityGsm.base.arfcn =
12242 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12243 cellInfoGsm.cellIdentityGsm.base.bsic =
12244 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12245 cellInfoGsm.signalStrengthGsm.signalStrength =
12246 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12247 cellInfoGsm.signalStrengthGsm.bitErrorRate =
12248 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12249 cellInfoGsm.signalStrengthGsm.timingAdvance =
12250 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12251 records[i].info.gsm(cellInfoGsm);
12252 break;
12253 }
12254
12255 case RIL_CELL_INFO_TYPE_WCDMA: {
12256 V1_2::CellInfoWcdma cellInfoWcdma;
12257 cellInfoWcdma.cellIdentityWcdma.base.mcc =
12258 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12259 cellInfoWcdma.cellIdentityWcdma.base.mnc =
12260 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12261 cellInfoWcdma.cellIdentityWcdma.base.lac =
12262 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12263 cellInfoWcdma.cellIdentityWcdma.base.cid =
12264 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12265 cellInfoWcdma.cellIdentityWcdma.base.psc =
12266 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12267 cellInfoWcdma.cellIdentityWcdma.base.uarfcn =
12268 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12269 cellInfoWcdma.signalStrengthWcdma.base.signalStrength =
12270 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12271 cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate =
12272 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12273 records[i].info.wcdma(cellInfoWcdma);
12274 break;
12275 }
12276
12277 case RIL_CELL_INFO_TYPE_CDMA: {
12278 V1_2::CellInfoCdma cellInfoCdma;
12279 cellInfoCdma.cellIdentityCdma.base.networkId =
12280 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12281 cellInfoCdma.cellIdentityCdma.base.systemId =
12282 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12283 cellInfoCdma.cellIdentityCdma.base.baseStationId =
12284 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12285 cellInfoCdma.cellIdentityCdma.base.longitude =
12286 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12287 cellInfoCdma.cellIdentityCdma.base.latitude =
12288 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12289 cellInfoCdma.signalStrengthCdma.dbm =
12290 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12291 cellInfoCdma.signalStrengthCdma.ecio =
12292 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12293 cellInfoCdma.signalStrengthEvdo.dbm =
12294 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12295 cellInfoCdma.signalStrengthEvdo.ecio =
12296 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12297 cellInfoCdma.signalStrengthEvdo.signalNoiseRatio =
12298 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12299 records[i].info.cdma(cellInfoCdma);
12300 break;
12301 }
12302
12303 case RIL_CELL_INFO_TYPE_LTE: {
12304 V1_4::CellInfoLte cellInfoLte;
12305 cellInfoLte.base.cellIdentityLte.base.mcc =
12306 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12307 cellInfoLte.base.cellIdentityLte.base.mnc =
12308 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12309 cellInfoLte.base.cellIdentityLte.base.ci =
12310 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12311 cellInfoLte.base.cellIdentityLte.base.pci =
12312 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12313 cellInfoLte.base.cellIdentityLte.base.tac =
12314 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12315 cellInfoLte.base.cellIdentityLte.base.earfcn =
12316 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12317 cellInfoLte.base.signalStrengthLte.signalStrength =
12318 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12319 cellInfoLte.base.signalStrengthLte.rsrp =
12320 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12321 cellInfoLte.base.signalStrengthLte.rsrq =
12322 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12323 cellInfoLte.base.signalStrengthLte.rssnr =
12324 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12325 cellInfoLte.base.signalStrengthLte.cqi =
12326 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12327 cellInfoLte.base.signalStrengthLte.timingAdvance =
12328 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12329 records[i].info.lte(cellInfoLte);
12330 break;
12331 }
12332
12333 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12334 V1_2::CellInfoTdscdma cellInfoTdscdma;
12335 cellInfoTdscdma.cellIdentityTdscdma.base.mcc =
12336 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12337 cellInfoTdscdma.cellIdentityTdscdma.base.mnc =
12338 ril::util::mnc::decode(
12339 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12340 cellInfoTdscdma.cellIdentityTdscdma.base.lac =
12341 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12342 cellInfoTdscdma.cellIdentityTdscdma.base.cid =
12343 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12344 cellInfoTdscdma.cellIdentityTdscdma.base.cpid =
12345 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12346 cellInfoTdscdma.signalStrengthTdscdma.rscp =
12347 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12348 records[i].info.tdscdma(cellInfoTdscdma);
12349 break;
12350 }
12351
12352 case RIL_CELL_INFO_TYPE_NR: {
12353 V1_4::CellInfoNr cellInfoNr;
12354 cellInfoNr.cellidentity.mcc =
12355 std::to_string(rillCellInfo->CellInfo.nr.cellidentity.mcc);
12356 cellInfoNr.cellidentity.mnc =
12357 ril::util::mnc::decode(
12358 rillCellInfo->CellInfo.nr.cellidentity.mnc);
12359 cellInfoNr.cellidentity.nci =
12360 rillCellInfo->CellInfo.nr.cellidentity.nci;
12361 cellInfoNr.cellidentity.pci =
12362 rillCellInfo->CellInfo.nr.cellidentity.pci;
12363 cellInfoNr.cellidentity.tac =
12364 rillCellInfo->CellInfo.nr.cellidentity.tac;
12365 cellInfoNr.cellidentity.nrarfcn =
12366 rillCellInfo->CellInfo.nr.cellidentity.nrarfcn;
12367 cellInfoNr.cellidentity.operatorNames.alphaLong =
12368 convertCharPtrToHidlString(rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaLong);
12369 cellInfoNr.cellidentity.operatorNames.alphaShort =
12370 convertCharPtrToHidlString(rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaShort);
12371
12372 cellInfoNr.signalStrength.ssRsrp =
12373 rillCellInfo->CellInfo.nr.signalStrength.ssRsrp;
12374 cellInfoNr.signalStrength.ssRsrq =
12375 rillCellInfo->CellInfo.nr.signalStrength.ssRsrq;
12376 cellInfoNr.signalStrength.ssSinr =
12377 rillCellInfo->CellInfo.nr.signalStrength.ssSinr;
12378 cellInfoNr.signalStrength.csiRsrp =
12379 rillCellInfo->CellInfo.nr.signalStrength.csiRsrp;
12380 cellInfoNr.signalStrength.csiRsrq =
12381 rillCellInfo->CellInfo.nr.signalStrength.csiRsrq;
12382 cellInfoNr.signalStrength.csiSinr =
12383 rillCellInfo->CellInfo.nr.signalStrength.csiSinr;
12384 records[i].info.nr(cellInfoNr);
12385 break;
12386 }
12387 default: {
12388 break;
12389 }
12390 }
12391 rillCellInfo += 1;
12392 }
12393 }
12394
convertRilCellInfoListToHal_1_5(void * response,size_t responseLen,hidl_vec<V1_5::CellInfo> & records)12395 void convertRilCellInfoListToHal_1_5(void* response, size_t responseLen,
12396 hidl_vec<V1_5::CellInfo>& records) {
12397 int num = responseLen / sizeof(RIL_CellInfo_v16);
12398 records.resize(num);
12399 RIL_CellInfo_v16* rillCellInfo = (RIL_CellInfo_v16*)response;
12400 for (int i = 0; i < num; i++) {
12401 records[i].registered = rillCellInfo->registered;
12402 records[i].connectionStatus = (V1_2::CellConnectionStatus)rillCellInfo->connectionStatus;
12403
12404 switch (rillCellInfo->cellInfoType) {
12405 case RIL_CELL_INFO_TYPE_GSM: {
12406 V1_5::CellInfoGsm cellInfoGsm;
12407 cellInfoGsm.cellIdentityGsm.base.base.mcc =
12408 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12409 cellInfoGsm.cellIdentityGsm.base.base.mnc =
12410 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12411 cellInfoGsm.cellIdentityGsm.base.base.lac =
12412 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12413 cellInfoGsm.cellIdentityGsm.base.base.cid =
12414 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12415 cellInfoGsm.cellIdentityGsm.base.base.arfcn =
12416 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12417 cellInfoGsm.cellIdentityGsm.base.base.bsic =
12418 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12419 cellInfoGsm.signalStrengthGsm.signalStrength =
12420 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12421 cellInfoGsm.signalStrengthGsm.bitErrorRate =
12422 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12423 cellInfoGsm.signalStrengthGsm.timingAdvance =
12424 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12425 records[i].ratSpecificInfo.gsm(cellInfoGsm);
12426 break;
12427 }
12428
12429 case RIL_CELL_INFO_TYPE_WCDMA: {
12430 V1_5::CellInfoWcdma cellInfoWcdma;
12431 cellInfoWcdma.cellIdentityWcdma.base.base.mcc =
12432 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12433 cellInfoWcdma.cellIdentityWcdma.base.base.mnc =
12434 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12435 cellInfoWcdma.cellIdentityWcdma.base.base.lac =
12436 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12437 cellInfoWcdma.cellIdentityWcdma.base.base.cid =
12438 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12439 cellInfoWcdma.cellIdentityWcdma.base.base.psc =
12440 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12441 cellInfoWcdma.cellIdentityWcdma.base.base.uarfcn =
12442 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12443 cellInfoWcdma.signalStrengthWcdma.base.signalStrength =
12444 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12445 cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate =
12446 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12447 records[i].ratSpecificInfo.wcdma(cellInfoWcdma);
12448 break;
12449 }
12450
12451 case RIL_CELL_INFO_TYPE_CDMA: {
12452 V1_2::CellInfoCdma cellInfoCdma;
12453 cellInfoCdma.cellIdentityCdma.base.networkId =
12454 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12455 cellInfoCdma.cellIdentityCdma.base.systemId =
12456 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12457 cellInfoCdma.cellIdentityCdma.base.baseStationId =
12458 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12459 cellInfoCdma.cellIdentityCdma.base.longitude =
12460 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12461 cellInfoCdma.cellIdentityCdma.base.latitude =
12462 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12463 cellInfoCdma.signalStrengthCdma.dbm =
12464 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12465 cellInfoCdma.signalStrengthCdma.ecio =
12466 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12467 cellInfoCdma.signalStrengthEvdo.dbm =
12468 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12469 cellInfoCdma.signalStrengthEvdo.ecio =
12470 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12471 cellInfoCdma.signalStrengthEvdo.signalNoiseRatio =
12472 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12473 records[i].ratSpecificInfo.cdma(cellInfoCdma);
12474 break;
12475 }
12476
12477 case RIL_CELL_INFO_TYPE_LTE: {
12478 V1_5::CellInfoLte cellInfoLte;
12479 cellInfoLte.cellIdentityLte.base.base.mcc =
12480 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12481 cellInfoLte.cellIdentityLte.base.base.mnc =
12482 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12483 cellInfoLte.cellIdentityLte.base.base.ci =
12484 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12485 cellInfoLte.cellIdentityLte.base.base.pci =
12486 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12487 cellInfoLte.cellIdentityLte.base.base.tac =
12488 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12489 cellInfoLte.cellIdentityLte.base.base.earfcn =
12490 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12491 cellInfoLte.signalStrengthLte.signalStrength =
12492 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12493 cellInfoLte.signalStrengthLte.rsrp =
12494 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12495 cellInfoLte.signalStrengthLte.rsrq =
12496 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12497 cellInfoLte.signalStrengthLte.rssnr =
12498 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12499 cellInfoLte.signalStrengthLte.cqi =
12500 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12501 cellInfoLte.signalStrengthLte.timingAdvance =
12502 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12503 records[i].ratSpecificInfo.lte(cellInfoLte);
12504 break;
12505 }
12506
12507 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12508 V1_5::CellInfoTdscdma cellInfoTdscdma;
12509 cellInfoTdscdma.cellIdentityTdscdma.base.base.mcc =
12510 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12511 cellInfoTdscdma.cellIdentityTdscdma.base.base.mnc = ril::util::mnc::decode(
12512 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12513 cellInfoTdscdma.cellIdentityTdscdma.base.base.lac =
12514 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12515 cellInfoTdscdma.cellIdentityTdscdma.base.base.cid =
12516 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12517 cellInfoTdscdma.cellIdentityTdscdma.base.base.cpid =
12518 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12519 cellInfoTdscdma.signalStrengthTdscdma.rscp =
12520 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12521 records[i].ratSpecificInfo.tdscdma(cellInfoTdscdma);
12522 break;
12523 }
12524
12525 case RIL_CELL_INFO_TYPE_NR: {
12526 V1_5::CellInfoNr cellInfoNr;
12527 cellInfoNr.cellIdentityNr.base.mcc =
12528 std::to_string(rillCellInfo->CellInfo.nr.cellidentity.mcc);
12529 cellInfoNr.cellIdentityNr.base.mnc =
12530 ril::util::mnc::decode(rillCellInfo->CellInfo.nr.cellidentity.mnc);
12531 cellInfoNr.cellIdentityNr.base.nci = rillCellInfo->CellInfo.nr.cellidentity.nci;
12532 cellInfoNr.cellIdentityNr.base.pci = rillCellInfo->CellInfo.nr.cellidentity.pci;
12533 cellInfoNr.cellIdentityNr.base.tac = rillCellInfo->CellInfo.nr.cellidentity.tac;
12534 cellInfoNr.cellIdentityNr.base.nrarfcn =
12535 rillCellInfo->CellInfo.nr.cellidentity.nrarfcn;
12536 cellInfoNr.cellIdentityNr.base.operatorNames.alphaLong = convertCharPtrToHidlString(
12537 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaLong);
12538 cellInfoNr.cellIdentityNr.base.operatorNames.alphaShort =
12539 convertCharPtrToHidlString(
12540 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaShort);
12541
12542 cellInfoNr.signalStrengthNr.ssRsrp =
12543 rillCellInfo->CellInfo.nr.signalStrength.ssRsrp;
12544 cellInfoNr.signalStrengthNr.ssRsrq =
12545 rillCellInfo->CellInfo.nr.signalStrength.ssRsrq;
12546 cellInfoNr.signalStrengthNr.ssSinr =
12547 rillCellInfo->CellInfo.nr.signalStrength.ssSinr;
12548 cellInfoNr.signalStrengthNr.csiRsrp =
12549 rillCellInfo->CellInfo.nr.signalStrength.csiRsrp;
12550 cellInfoNr.signalStrengthNr.csiRsrq =
12551 rillCellInfo->CellInfo.nr.signalStrength.csiRsrq;
12552 cellInfoNr.signalStrengthNr.csiSinr =
12553 rillCellInfo->CellInfo.nr.signalStrength.csiSinr;
12554 records[i].ratSpecificInfo.nr(cellInfoNr);
12555 break;
12556 }
12557 default: {
12558 break;
12559 }
12560 }
12561 rillCellInfo += 1;
12562 }
12563 }
12564
convertRilCellInfoListToHal_1_6(void * response,size_t responseLen,hidl_vec<V1_6::CellInfo> & records)12565 void convertRilCellInfoListToHal_1_6(void* response, size_t responseLen,
12566 hidl_vec<V1_6::CellInfo>& records) {
12567 int num = responseLen / sizeof(RIL_CellInfo_v16);
12568 records.resize(num);
12569 RIL_CellInfo_v16* rillCellInfo = (RIL_CellInfo_v16*)response;
12570 for (int i = 0; i < num; i++) {
12571 records[i].registered = rillCellInfo->registered;
12572 records[i].connectionStatus = (V1_2::CellConnectionStatus)rillCellInfo->connectionStatus;
12573
12574 switch (rillCellInfo->cellInfoType) {
12575 case RIL_CELL_INFO_TYPE_GSM: {
12576 V1_5::CellInfoGsm cellInfoGsm;
12577 cellInfoGsm.cellIdentityGsm.base.base.mcc =
12578 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
12579 cellInfoGsm.cellIdentityGsm.base.base.mnc =
12580 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
12581 cellInfoGsm.cellIdentityGsm.base.base.lac =
12582 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
12583 cellInfoGsm.cellIdentityGsm.base.base.cid =
12584 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
12585 cellInfoGsm.cellIdentityGsm.base.base.arfcn =
12586 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
12587 cellInfoGsm.cellIdentityGsm.base.base.bsic =
12588 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
12589 cellInfoGsm.signalStrengthGsm.signalStrength =
12590 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
12591 cellInfoGsm.signalStrengthGsm.bitErrorRate =
12592 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
12593 cellInfoGsm.signalStrengthGsm.timingAdvance =
12594 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
12595 records[i].ratSpecificInfo.gsm(cellInfoGsm);
12596 break;
12597 }
12598
12599 case RIL_CELL_INFO_TYPE_WCDMA: {
12600 V1_5::CellInfoWcdma cellInfoWcdma;
12601 cellInfoWcdma.cellIdentityWcdma.base.base.mcc =
12602 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
12603 cellInfoWcdma.cellIdentityWcdma.base.base.mnc =
12604 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
12605 cellInfoWcdma.cellIdentityWcdma.base.base.lac =
12606 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
12607 cellInfoWcdma.cellIdentityWcdma.base.base.cid =
12608 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
12609 cellInfoWcdma.cellIdentityWcdma.base.base.psc =
12610 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
12611 cellInfoWcdma.cellIdentityWcdma.base.base.uarfcn =
12612 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
12613 cellInfoWcdma.signalStrengthWcdma.base.signalStrength =
12614 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
12615 cellInfoWcdma.signalStrengthWcdma.base.bitErrorRate =
12616 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
12617 records[i].ratSpecificInfo.wcdma(cellInfoWcdma);
12618 break;
12619 }
12620
12621 case RIL_CELL_INFO_TYPE_CDMA: {
12622 V1_2::CellInfoCdma cellInfoCdma;
12623 cellInfoCdma.cellIdentityCdma.base.networkId =
12624 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
12625 cellInfoCdma.cellIdentityCdma.base.systemId =
12626 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
12627 cellInfoCdma.cellIdentityCdma.base.baseStationId =
12628 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
12629 cellInfoCdma.cellIdentityCdma.base.longitude =
12630 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
12631 cellInfoCdma.cellIdentityCdma.base.latitude =
12632 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
12633 cellInfoCdma.signalStrengthCdma.dbm =
12634 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
12635 cellInfoCdma.signalStrengthCdma.ecio =
12636 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
12637 cellInfoCdma.signalStrengthEvdo.dbm =
12638 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
12639 cellInfoCdma.signalStrengthEvdo.ecio =
12640 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
12641 cellInfoCdma.signalStrengthEvdo.signalNoiseRatio =
12642 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
12643 records[i].ratSpecificInfo.cdma(cellInfoCdma);
12644 break;
12645 }
12646
12647 case RIL_CELL_INFO_TYPE_LTE: {
12648 V1_6::CellInfoLte cellInfoLte;
12649 cellInfoLte.cellIdentityLte.base.base.mcc =
12650 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
12651 cellInfoLte.cellIdentityLte.base.base.mnc =
12652 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
12653 cellInfoLte.cellIdentityLte.base.base.ci =
12654 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
12655 cellInfoLte.cellIdentityLte.base.base.pci =
12656 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
12657 cellInfoLte.cellIdentityLte.base.base.tac =
12658 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
12659 cellInfoLte.cellIdentityLte.base.base.earfcn =
12660 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
12661 cellInfoLte.cellIdentityLte.base.bandwidth = INT_MAX;
12662 hidl_vec<V1_5::EutranBands> bands;
12663 bands.resize(1);
12664 bands[0] = V1_5::EutranBands::BAND_1;
12665 cellInfoLte.cellIdentityLte.bands = bands;
12666 cellInfoLte.signalStrengthLte.base.signalStrength =
12667 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
12668 cellInfoLte.signalStrengthLte.base.rsrp =
12669 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
12670 cellInfoLte.signalStrengthLte.base.rsrq =
12671 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
12672 cellInfoLte.signalStrengthLte.base.rssnr =
12673 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
12674 cellInfoLte.signalStrengthLte.base.cqi =
12675 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
12676 cellInfoLte.signalStrengthLte.base.timingAdvance =
12677 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
12678 records[i].ratSpecificInfo.lte(cellInfoLte);
12679 break;
12680 }
12681
12682 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
12683 V1_5::CellInfoTdscdma cellInfoTdscdma;
12684 cellInfoTdscdma.cellIdentityTdscdma.base.base.mcc =
12685 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
12686 cellInfoTdscdma.cellIdentityTdscdma.base.base.mnc = ril::util::mnc::decode(
12687 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
12688 cellInfoTdscdma.cellIdentityTdscdma.base.base.lac =
12689 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
12690 cellInfoTdscdma.cellIdentityTdscdma.base.base.cid =
12691 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
12692 cellInfoTdscdma.cellIdentityTdscdma.base.base.cpid =
12693 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
12694 cellInfoTdscdma.signalStrengthTdscdma.rscp =
12695 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
12696 records[i].ratSpecificInfo.tdscdma(cellInfoTdscdma);
12697 break;
12698 }
12699
12700 case RIL_CELL_INFO_TYPE_NR: {
12701 V1_6::CellInfoNr cellInfoNr;
12702 cellInfoNr.cellIdentityNr.base.mcc =
12703 std::to_string(rillCellInfo->CellInfo.nr.cellidentity.mcc);
12704 cellInfoNr.cellIdentityNr.base.mnc =
12705 ril::util::mnc::decode(rillCellInfo->CellInfo.nr.cellidentity.mnc);
12706 cellInfoNr.cellIdentityNr.base.nci = rillCellInfo->CellInfo.nr.cellidentity.nci;
12707 cellInfoNr.cellIdentityNr.base.pci = rillCellInfo->CellInfo.nr.cellidentity.pci;
12708 cellInfoNr.cellIdentityNr.base.tac = rillCellInfo->CellInfo.nr.cellidentity.tac;
12709 cellInfoNr.cellIdentityNr.base.nrarfcn =
12710 rillCellInfo->CellInfo.nr.cellidentity.nrarfcn;
12711 cellInfoNr.cellIdentityNr.base.operatorNames.alphaLong = convertCharPtrToHidlString(
12712 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaLong);
12713 cellInfoNr.cellIdentityNr.base.operatorNames.alphaShort =
12714 convertCharPtrToHidlString(
12715 rillCellInfo->CellInfo.nr.cellidentity.operatorNames.alphaShort);
12716
12717 cellInfoNr.signalStrengthNr.base.ssRsrp =
12718 rillCellInfo->CellInfo.nr.signalStrength.ssRsrp;
12719 cellInfoNr.signalStrengthNr.base.ssRsrq =
12720 rillCellInfo->CellInfo.nr.signalStrength.ssRsrq;
12721 cellInfoNr.signalStrengthNr.base.ssSinr =
12722 rillCellInfo->CellInfo.nr.signalStrength.ssSinr;
12723 cellInfoNr.signalStrengthNr.base.csiRsrp =
12724 rillCellInfo->CellInfo.nr.signalStrength.csiRsrp;
12725 cellInfoNr.signalStrengthNr.base.csiRsrq =
12726 rillCellInfo->CellInfo.nr.signalStrength.csiRsrq;
12727 cellInfoNr.signalStrengthNr.base.csiSinr =
12728 rillCellInfo->CellInfo.nr.signalStrength.csiSinr;
12729 records[i].ratSpecificInfo.nr(cellInfoNr);
12730 break;
12731 }
12732 default: {
12733 break;
12734 }
12735 }
12736 rillCellInfo += 1;
12737 }
12738 }
12739
cellInfoListInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12740 int radio_1_6::cellInfoListInd(int slotId,
12741 int indicationType, int token, RIL_Errno e, void *response,
12742 size_t responseLen) {
12743 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12744 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
12745 RLOGE("cellInfoListInd: invalid response");
12746 return 0;
12747 }
12748
12749 hidl_vec<CellInfo> records;
12750 convertRilCellInfoListToHal(response, responseLen, records);
12751
12752 #if VDBG
12753 RLOGD("cellInfoListInd");
12754 #endif
12755 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
12756 convertIntToRadioIndicationType(indicationType), records);
12757 radioService[slotId]->checkReturnStatus(retStatus);
12758 } else {
12759 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
12760 }
12761
12762 return 0;
12763 }
12764
imsNetworkStateChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12765 int radio_1_6::imsNetworkStateChangedInd(int slotId,
12766 int indicationType, int token, RIL_Errno e, void *response,
12767 size_t responseLen) {
12768 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12769 #if VDBG
12770 RLOGD("imsNetworkStateChangedInd");
12771 #endif
12772 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
12773 convertIntToRadioIndicationType(indicationType));
12774 radioService[slotId]->checkReturnStatus(retStatus);
12775 } else {
12776 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
12777 slotId);
12778 }
12779
12780 return 0;
12781 }
12782
subscriptionStatusChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12783 int radio_1_6::subscriptionStatusChangedInd(int slotId,
12784 int indicationType, int token, RIL_Errno e, void *response,
12785 size_t responseLen) {
12786 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12787 if (response == NULL || responseLen != sizeof(int)) {
12788 RLOGE("subscriptionStatusChangedInd: invalid response");
12789 return 0;
12790 }
12791 bool activate = ((int32_t *) response)[0];
12792 #if VDBG
12793 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
12794 #endif
12795 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
12796 convertIntToRadioIndicationType(indicationType), activate);
12797 radioService[slotId]->checkReturnStatus(retStatus);
12798 } else {
12799 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
12800 slotId);
12801 }
12802
12803 return 0;
12804 }
12805
srvccStateNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12806 int radio_1_6::srvccStateNotifyInd(int slotId,
12807 int indicationType, int token, RIL_Errno e, void *response,
12808 size_t responseLen) {
12809 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12810 if (response == NULL || responseLen != sizeof(int)) {
12811 RLOGE("srvccStateNotifyInd: invalid response");
12812 return 0;
12813 }
12814 int32_t state = ((int32_t *) response)[0];
12815 #if VDBG
12816 RLOGD("srvccStateNotifyInd: rat %d", state);
12817 #endif
12818 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
12819 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
12820 radioService[slotId]->checkReturnStatus(retStatus);
12821 } else {
12822 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
12823 }
12824
12825 return 0;
12826 }
12827
convertRilHardwareConfigListToHal(void * response,size_t responseLen,hidl_vec<HardwareConfig> & records)12828 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
12829 hidl_vec<HardwareConfig>& records) {
12830 int num = responseLen / sizeof(RIL_HardwareConfig);
12831 records.resize(num);
12832
12833 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
12834 for (int i = 0; i < num; i++) {
12835 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
12836 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
12837 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
12838 switch (rilHardwareConfig[i].type) {
12839 case RIL_HARDWARE_CONFIG_MODEM: {
12840 records[i].modem.resize(1);
12841 records[i].sim.resize(0);
12842 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
12843 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
12844 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
12845 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
12846 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
12847 break;
12848 }
12849
12850 case RIL_HARDWARE_CONFIG_SIM: {
12851 records[i].sim.resize(1);
12852 records[i].modem.resize(0);
12853 records[i].sim[0].modemUuid =
12854 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
12855 break;
12856 }
12857 }
12858 }
12859 }
12860
hardwareConfigChangedInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12861 int radio_1_6::hardwareConfigChangedInd(int slotId,
12862 int indicationType, int token, RIL_Errno e, void *response,
12863 size_t responseLen) {
12864 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12865 if ((response == NULL && responseLen != 0)
12866 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
12867 RLOGE("hardwareConfigChangedInd: invalid response");
12868 return 0;
12869 }
12870
12871 hidl_vec<HardwareConfig> configs;
12872 convertRilHardwareConfigListToHal(response, responseLen, configs);
12873
12874 #if VDBG
12875 RLOGD("hardwareConfigChangedInd");
12876 #endif
12877 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
12878 convertIntToRadioIndicationType(indicationType), configs);
12879 radioService[slotId]->checkReturnStatus(retStatus);
12880 } else {
12881 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
12882 slotId);
12883 }
12884
12885 return 0;
12886 }
12887
convertRilRadioCapabilityToHal(void * response,size_t responseLen,RadioCapability & rc)12888 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
12889 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
12890 rc.session = rilRadioCapability->session;
12891 rc.phase = (V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
12892 rc.raf = rilRadioCapability->rat;
12893 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
12894 rc.status = (V1_0::RadioCapabilityStatus) rilRadioCapability->status;
12895 }
12896
radioCapabilityIndicationInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12897 int radio_1_6::radioCapabilityIndicationInd(int slotId,
12898 int indicationType, int token, RIL_Errno e, void *response,
12899 size_t responseLen) {
12900 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12901 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
12902 RLOGE("radioCapabilityIndicationInd: invalid response");
12903 return 0;
12904 }
12905
12906 RadioCapability rc = {};
12907 convertRilRadioCapabilityToHal(response, responseLen, rc);
12908
12909 #if VDBG
12910 RLOGD("radioCapabilityIndicationInd");
12911 #endif
12912 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
12913 convertIntToRadioIndicationType(indicationType), rc);
12914 radioService[slotId]->checkReturnStatus(retStatus);
12915 } else {
12916 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
12917 slotId);
12918 }
12919
12920 return 0;
12921 }
12922
isServiceTypeCfQuery(RIL_SsServiceType serType,RIL_SsRequestType reqType)12923 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
12924 if ((reqType == SS_INTERROGATION) &&
12925 (serType == SS_CFU ||
12926 serType == SS_CF_BUSY ||
12927 serType == SS_CF_NO_REPLY ||
12928 serType == SS_CF_NOT_REACHABLE ||
12929 serType == SS_CF_ALL ||
12930 serType == SS_CF_ALL_CONDITIONAL)) {
12931 return true;
12932 }
12933 return false;
12934 }
12935
onSupplementaryServiceIndicationInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)12936 int radio_1_6::onSupplementaryServiceIndicationInd(int slotId,
12937 int indicationType, int token, RIL_Errno e,
12938 void *response, size_t responseLen) {
12939 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
12940 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
12941 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
12942 return 0;
12943 }
12944
12945 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
12946 StkCcUnsolSsResult ss = {};
12947 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
12948 ss.requestType = (SsRequestType) rilSsResponse->requestType;
12949 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
12950 ss.serviceClass = rilSsResponse->serviceClass;
12951 ss.result = (RadioError) rilSsResponse->result;
12952
12953 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
12954 #if VDBG
12955 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
12956 rilSsResponse->cfData.numValidIndexes);
12957 #endif
12958 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
12959 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
12960 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
12961 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
12962 }
12963
12964 ss.cfData.resize(1);
12965 ss.ssInfo.resize(0);
12966
12967 /* number of call info's */
12968 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
12969
12970 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
12971 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
12972 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
12973
12974 cfInfo->status = (CallForwardInfoStatus) cf.status;
12975 cfInfo->reason = cf.reason;
12976 cfInfo->serviceClass = cf.serviceClass;
12977 cfInfo->toa = cf.toa;
12978 cfInfo->number = convertCharPtrToHidlString(cf.number);
12979 cfInfo->timeSeconds = cf.timeSeconds;
12980 #if VDBG
12981 RLOGD("onSupplementaryServiceIndicationInd: "
12982 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
12983 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
12984 #endif
12985 }
12986 } else {
12987 ss.ssInfo.resize(1);
12988 ss.cfData.resize(0);
12989
12990 /* each int */
12991 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
12992 for (int i = 0; i < SS_INFO_MAX; i++) {
12993 #if VDBG
12994 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
12995 rilSsResponse->ssInfo[i]);
12996 #endif
12997 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
12998 }
12999 }
13000
13001 #if VDBG
13002 RLOGD("onSupplementaryServiceIndicationInd");
13003 #endif
13004 Return<void> retStatus = radioService[slotId]->mRadioIndication->
13005 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
13006 ss);
13007 radioService[slotId]->checkReturnStatus(retStatus);
13008 } else {
13009 RLOGE("onSupplementaryServiceIndicationInd: "
13010 "radioService[%d]->mRadioIndication == NULL", slotId);
13011 }
13012
13013 return 0;
13014 }
13015
stkCallControlAlphaNotifyInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13016 int radio_1_6::stkCallControlAlphaNotifyInd(int slotId,
13017 int indicationType, int token, RIL_Errno e, void *response,
13018 size_t responseLen) {
13019 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13020 if (response == NULL || responseLen == 0) {
13021 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
13022 return 0;
13023 }
13024 #if VDBG
13025 RLOGD("stkCallControlAlphaNotifyInd");
13026 #endif
13027 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
13028 convertIntToRadioIndicationType(indicationType),
13029 convertCharPtrToHidlString((char *) response));
13030 radioService[slotId]->checkReturnStatus(retStatus);
13031 } else {
13032 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
13033 slotId);
13034 }
13035
13036 return 0;
13037 }
13038
convertRilLceDataInfoToHal(void * response,size_t responseLen,LceDataInfo & lce)13039 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
13040 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
13041 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
13042 lce.confidenceLevel = rilLceDataInfo->confidence_level;
13043 lce.lceSuspended = rilLceDataInfo->lce_suspended;
13044 }
13045
lceDataInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13046 int radio_1_6::lceDataInd(int slotId,
13047 int indicationType, int token, RIL_Errno e, void *response,
13048 size_t responseLen) {
13049 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13050 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
13051 RLOGE("lceDataInd: invalid response");
13052 return 0;
13053 }
13054
13055 LceDataInfo lce = {};
13056 convertRilLceDataInfoToHal(response, responseLen, lce);
13057 #if VDBG
13058 RLOGD("lceDataInd");
13059 #endif
13060 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
13061 convertIntToRadioIndicationType(indicationType), lce);
13062 radioService[slotId]->checkReturnStatus(retStatus);
13063 } else {
13064 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
13065 }
13066
13067 return 0;
13068 }
13069
pcoDataInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13070 int radio_1_6::pcoDataInd(int slotId,
13071 int indicationType, int token, RIL_Errno e, void *response,
13072 size_t responseLen) {
13073 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13074 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
13075 RLOGE("pcoDataInd: invalid response");
13076 return 0;
13077 }
13078
13079 PcoDataInfo pco = {};
13080 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
13081 pco.cid = rilPcoData->cid;
13082 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
13083 pco.pcoId = rilPcoData->pco_id;
13084 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
13085
13086 #if VDBG
13087 RLOGD("pcoDataInd");
13088 #endif
13089 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
13090 convertIntToRadioIndicationType(indicationType), pco);
13091 radioService[slotId]->checkReturnStatus(retStatus);
13092 } else {
13093 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
13094 }
13095
13096 return 0;
13097 }
13098
modemResetInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13099 int radio_1_6::modemResetInd(int slotId,
13100 int indicationType, int token, RIL_Errno e, void *response,
13101 size_t responseLen) {
13102 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
13103 if (response == NULL || responseLen == 0) {
13104 RLOGE("modemResetInd: invalid response");
13105 return 0;
13106 }
13107 #if VDBG
13108 RLOGD("modemResetInd");
13109 #endif
13110 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
13111 convertIntToRadioIndicationType(indicationType),
13112 convertCharPtrToHidlString((char *) response));
13113 radioService[slotId]->checkReturnStatus(retStatus);
13114 } else {
13115 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
13116 }
13117
13118 return 0;
13119 }
13120
networkScanResultInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13121 int radio_1_6::networkScanResultInd(int slotId, int indicationType, int token, RIL_Errno e,
13122 void* response, size_t responseLen) {
13123 #if VDBG
13124 RLOGD("networkScanResultInd");
13125 #endif
13126 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndicationV1_6 != NULL ||
13127 radioService[slotId]->mRadioIndicationV1_5 != NULL ||
13128 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
13129 radioService[slotId]->mRadioIndicationV1_2 != NULL ||
13130 radioService[slotId]->mRadioIndicationV1_1 != NULL)) {
13131 if (response == NULL || responseLen == 0) {
13132 RLOGE("networkScanResultInd: invalid response");
13133 return 0;
13134 }
13135 RLOGD("networkScanResultInd");
13136
13137 RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
13138 Return<void> retStatus;
13139 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
13140 V1_6::NetworkScanResult result;
13141 result.status = (V1_1::ScanStatus)networkScanResult->status;
13142 result.error = (V1_6::RadioError)networkScanResult->error;
13143 convertRilCellInfoListToHal_1_6(
13144 networkScanResult->network_infos,
13145 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v16),
13146 result.networkInfos);
13147 retStatus = radioService[slotId]->mRadioIndicationV1_6->networkScanResult_1_6(
13148 convertIntToRadioIndicationType(indicationType), result);
13149 } else if (radioService[slotId]->mRadioIndicationV1_5 != NULL) {
13150 V1_5::NetworkScanResult result;
13151 result.status = (V1_1::ScanStatus)networkScanResult->status;
13152 result.error = (RadioError)networkScanResult->error;
13153 convertRilCellInfoListToHal_1_5(
13154 networkScanResult->network_infos,
13155 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
13156 result.networkInfos);
13157 retStatus = radioService[slotId]->mRadioIndicationV1_5->networkScanResult_1_5(
13158 convertIntToRadioIndicationType(indicationType), result);
13159 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
13160 V1_4::NetworkScanResult result;
13161 result.status = (V1_1::ScanStatus)networkScanResult->status;
13162 result.error = (RadioError)networkScanResult->error;
13163 convertRilCellInfoListToHal_1_4(
13164 networkScanResult->network_infos,
13165 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
13166 result.networkInfos);
13167 retStatus = radioService[slotId]->mRadioIndicationV1_4->networkScanResult_1_4(
13168 convertIntToRadioIndicationType(indicationType), result);
13169 } else if (radioService[slotId]->mRadioIndicationV1_2 != NULL) {
13170 V1_2::NetworkScanResult result;
13171 result.status = (V1_1::ScanStatus)networkScanResult->status;
13172 result.error = (RadioError)networkScanResult->error;
13173 convertRilCellInfoListToHal_1_2(
13174 networkScanResult->network_infos,
13175 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
13176 result.networkInfos);
13177 retStatus = radioService[slotId]->mRadioIndicationV1_2->networkScanResult_1_2(
13178 convertIntToRadioIndicationType(indicationType), result);
13179 } else {
13180 V1_1::NetworkScanResult result;
13181 result.status = (V1_1::ScanStatus)networkScanResult->status;
13182 result.error = (RadioError)networkScanResult->error;
13183 convertRilCellInfoListToHal(
13184 networkScanResult->network_infos,
13185 networkScanResult->network_infos_length * sizeof(RIL_CellInfo),
13186 result.networkInfos);
13187 retStatus = radioService[slotId]->mRadioIndicationV1_1->networkScanResult(
13188 convertIntToRadioIndicationType(indicationType), result);
13189 }
13190 radioService[slotId]->checkReturnStatus(retStatus);
13191 } else {
13192 RLOGE("networkScanResultInd: radioService[%d]->mRadioIndication == NULL", slotId);
13193 }
13194 return 0;
13195 }
13196
carrierInfoForImsiEncryption(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13197 int radio_1_6::carrierInfoForImsiEncryption(int slotId, int indicationType, int token, RIL_Errno e,
13198 void* response, size_t responseLen) {
13199 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndicationV1_2 != NULL)) {
13200 if (response == NULL || responseLen == 0) {
13201 RLOGE("carrierInfoForImsiEncryption: invalid response");
13202 return 0;
13203 }
13204 RLOGD("carrierInfoForImsiEncryption");
13205 Return<void> retStatus =
13206 radioService[slotId]->mRadioIndicationV1_2->carrierInfoForImsiEncryption(
13207 convertIntToRadioIndicationType(indicationType));
13208 radioService[slotId]->checkReturnStatus(retStatus);
13209 } else {
13210 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndication == NULL", slotId);
13211 }
13212
13213 return 0;
13214 }
13215
reportPhysicalChannelConfigs(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13216 int radio_1_6::reportPhysicalChannelConfigs(int slotId, int indicationType, int token, RIL_Errno e,
13217 void* response, size_t responseLen) {
13218 if (radioService[slotId] != NULL && (radioService[slotId]->mRadioIndicationV1_6 != NULL ||
13219 radioService[slotId]->mRadioIndicationV1_4 != NULL ||
13220 radioService[slotId]->mRadioIndicationV1_2 != NULL)) {
13221 int* configs = (int*)response;
13222 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
13223 hidl_vec<V1_6::PhysicalChannelConfig> physChanConfig;
13224 physChanConfig.resize(1);
13225 physChanConfig[0].status = (V1_2::CellConnectionStatus)configs[0];
13226 physChanConfig[0].cellBandwidthDownlinkKhz = configs[1];
13227 physChanConfig[0].rat = (V1_4::RadioTechnology)configs[2];
13228 physChanConfig[0].contextIds.resize(1);
13229 physChanConfig[0].contextIds[0] = configs[4];
13230 RLOGD("reportPhysicalChannelConfigs_1_6: %d %d %d %d %d", configs[0], configs[1],
13231 configs[2], configs[3], configs[4]);
13232 Return<void> retStatus =
13233 radioService[slotId]->mRadioIndicationV1_6->currentPhysicalChannelConfigs_1_6(
13234 RadioIndicationType::UNSOLICITED, physChanConfig);
13235 radioService[slotId]->checkReturnStatus(retStatus);
13236 // checkReturnStatus() call might set mRadioIndicationV1_6 to NULL
13237 if (radioService[slotId]->mRadioIndicationV1_6 != NULL) {
13238 // Just send the link estimate along with physical channel config, as it has
13239 // at least the downlink bandwidth.
13240 // Note: the bandwidth is just some hardcoded value, as there is not way to get
13241 // that reliably on virtual devices, as of now.
13242 V1_6::LinkCapacityEstimate lce = {
13243 .downlinkCapacityKbps = static_cast<uint32_t>(configs[1]),
13244 .uplinkCapacityKbps = static_cast<uint32_t>(configs[1])};
13245 RLOGD("reporting link capacity estimate download: %d upload: %d",
13246 lce.downlinkCapacityKbps, lce.uplinkCapacityKbps);
13247 Return<void> retStatus =
13248 radioService[slotId]->mRadioIndicationV1_6->currentLinkCapacityEstimate_1_6(
13249 RadioIndicationType::UNSOLICITED, lce);
13250 radioService[slotId]->checkReturnStatus(retStatus);
13251 }
13252 } else if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
13253 hidl_vec<PhysicalChannelConfigV1_4> physChanConfig;
13254 physChanConfig.resize(1);
13255 physChanConfig[0].base.status = (V1_2::CellConnectionStatus)configs[0];
13256 physChanConfig[0].base.cellBandwidthDownlink = configs[1];
13257 physChanConfig[0].rat = (V1_4::RadioTechnology)configs[2];
13258 physChanConfig[0].rfInfo.range((V1_4::FrequencyRange)configs[3]);
13259 physChanConfig[0].contextIds.resize(1);
13260 physChanConfig[0].contextIds[0] = configs[4];
13261 RLOGD("reportPhysicalChannelConfigs_1_4: %d %d %d %d %d", configs[0], configs[1],
13262 configs[2], configs[3], configs[4]);
13263 Return<void> retStatus =
13264 radioService[slotId]->mRadioIndicationV1_4->currentPhysicalChannelConfigs_1_4(
13265 RadioIndicationType::UNSOLICITED, physChanConfig);
13266 radioService[slotId]->checkReturnStatus(retStatus);
13267 // checkReturnStatus() call might set mRadioIndicationV1_4 to NULL
13268 if (radioService[slotId]->mRadioIndicationV1_4 != NULL) {
13269 // Just send the link estimate along with physical channel config, as it has
13270 // at least the downlink bandwidth.
13271 // Note: the bandwidth is just some hardcoded value, as there is not way to get
13272 // that reliably on virtual devices, as of now.
13273 V1_2::LinkCapacityEstimate lce = {
13274 .downlinkCapacityKbps = static_cast<uint32_t>(configs[1]),
13275 .uplinkCapacityKbps = static_cast<uint32_t>(configs[1])};
13276 RLOGD("reporting link capacity estimate download: %d upload: %d",
13277 lce.downlinkCapacityKbps, lce.uplinkCapacityKbps);
13278 Return<void> retStatus =
13279 radioService[slotId]->mRadioIndicationV1_4->currentLinkCapacityEstimate(
13280 RadioIndicationType::UNSOLICITED, lce);
13281 radioService[slotId]->checkReturnStatus(retStatus);
13282 }
13283 } else if (radioService[slotId]->mRadioIndicationV1_2 != NULL) {
13284 hidl_vec<V1_2::PhysicalChannelConfig> physChanConfig;
13285 physChanConfig.resize(1);
13286 physChanConfig[0].status = (V1_2::CellConnectionStatus)configs[0];
13287 physChanConfig[0].cellBandwidthDownlink = configs[1];
13288 RLOGD("reportPhysicalChannelConfigs_1_2: %d %d", configs[0], configs[1]);
13289 Return<void> retStatus =
13290 radioService[slotId]->mRadioIndicationV1_2->currentPhysicalChannelConfigs(
13291 RadioIndicationType::UNSOLICITED, physChanConfig);
13292 radioService[slotId]->checkReturnStatus(retStatus);
13293 // checkReturnStatus() call might set mRadioIndicationV1_2 to NULL
13294 if (radioService[slotId]->mRadioIndicationV1_2 != NULL) {
13295 // Just send the link estimate along with physical channel config, as it has
13296 // at least the downlink bandwidth.
13297 // Note: the bandwidth is just some hardcoded value, as there is not way to get
13298 // that reliably on virtual devices, as of now.
13299 V1_2::LinkCapacityEstimate lce = {
13300 .downlinkCapacityKbps = static_cast<uint32_t>(configs[1]),
13301 .uplinkCapacityKbps = static_cast<uint32_t>(configs[1])};
13302 RLOGD("reporting link capacity estimate download: %d upload: %d",
13303 lce.downlinkCapacityKbps, lce.uplinkCapacityKbps);
13304 Return<void> retStatus =
13305 radioService[slotId]->mRadioIndicationV1_2->currentLinkCapacityEstimate(
13306 RadioIndicationType::UNSOLICITED, lce);
13307 radioService[slotId]->checkReturnStatus(retStatus);
13308 }
13309 }
13310 } else {
13311 RLOGE("reportPhysicalChannelConfigs: radioService[%d]->mRadioIndication == NULL", slotId);
13312 return -1;
13313 }
13314 return 0;
13315 }
13316
keepaliveStatusInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13317 int radio_1_6::keepaliveStatusInd(int slotId,
13318 int indicationType, int token, RIL_Errno e, void *response,
13319 size_t responseLen) {
13320 #if VDBG
13321 RLOGD("%s(): token=%d", __FUNCTION__, token);
13322 #endif
13323 if (radioService[slotId] == NULL || radioService[slotId]->mRadioIndication == NULL) {
13324 RLOGE("%s: radioService[%d]->mRadioIndication == NULL", __FUNCTION__, slotId);
13325 return 0;
13326 }
13327
13328 auto ret = V1_1::IRadioIndication::castFrom(
13329 radioService[slotId]->mRadioIndication);
13330 if (!ret.isOk()) {
13331 RLOGE("%s: ret.isOk() == false for radioService[%d]", __FUNCTION__, slotId);
13332 return 0;
13333 }
13334 sp<V1_1::IRadioIndication> radioIndicationV1_1 = ret;
13335
13336 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
13337 RLOGE("%s: invalid response", __FUNCTION__);
13338 return 0;
13339 }
13340
13341 V1_1::KeepaliveStatus ks;
13342 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
13343
13344 Return<void> retStatus = radioIndicationV1_1->keepaliveStatus(
13345 convertIntToRadioIndicationType(indicationType), ks);
13346 radioService[slotId]->checkReturnStatus(retStatus);
13347 return 0;
13348 }
13349
oemHookRawInd(int slotId,int indicationType,int token,RIL_Errno e,void * response,size_t responseLen)13350 int radio_1_6::oemHookRawInd(int slotId,
13351 int indicationType, int token, RIL_Errno e, void *response,
13352 size_t responseLen) {
13353 if (!kOemHookEnabled) return 0;
13354
13355 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
13356 if (response == NULL || responseLen == 0) {
13357 RLOGE("oemHookRawInd: invalid response");
13358 return 0;
13359 }
13360
13361 hidl_vec<uint8_t> data;
13362 data.setToExternal((uint8_t *) response, responseLen);
13363 #if VDBG
13364 RLOGD("oemHookRawInd");
13365 #endif
13366 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
13367 convertIntToRadioIndicationType(indicationType), data);
13368 checkReturnStatus(slotId, retStatus, false);
13369 } else {
13370 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
13371 }
13372
13373 return 0;
13374 }
13375
13376 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)13377 static void publishRadioHal(std::shared_ptr<compat::DriverContext> ctx, sp<V1_5::IRadio> hidlHal,
13378 std::shared_ptr<compat::CallbackManager> cm, const std::string& slot) {
13379 static std::vector<std::shared_ptr<ndk::ICInterface>> gPublishedHals;
13380
13381 const auto instance = T::descriptor + "/"s + slot;
13382 RLOGD("Publishing %s", instance.c_str());
13383
13384 auto aidlHal = ndk::SharedRefBase::make<T>(ctx, hidlHal, cm);
13385 gPublishedHals.push_back(aidlHal);
13386 const auto status = AServiceManager_addService(aidlHal->asBinder().get(), instance.c_str());
13387 CHECK_EQ(status, STATUS_OK);
13388 }
13389
registerService(RIL_RadioFunctions * callbacks,CommandInfo * commands)13390 void radio_1_6::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
13391 using namespace android::hardware;
13392 int simCount = 1;
13393 const char *serviceNames[] = {
13394 android::RIL_getServiceName()
13395 #if (SIM_COUNT >= 2)
13396 , RIL2_SERVICE_NAME
13397 #if (SIM_COUNT >= 3)
13398 , RIL3_SERVICE_NAME
13399 #if (SIM_COUNT >= 4)
13400 , RIL4_SERVICE_NAME
13401 #endif
13402 #endif
13403 #endif
13404 };
13405
13406 #if (SIM_COUNT >= 2)
13407 simCount = SIM_COUNT;
13408 #endif
13409
13410 s_vendorFunctions = callbacks;
13411 s_commands = commands;
13412
13413 for (int i = 0; i < simCount; i++) {
13414 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
13415 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
13416 CHECK_EQ(ret, 0);
13417
13418 RLOGD("sim i = %d registering ...", i);
13419
13420 radioService[i] = new RadioImpl_1_6;
13421 radioService[i]->mSlotId = i;
13422 RLOGD("registerService: initializing power state to POWER_UP");
13423 radioService[i]->mSimCardPowerState = V1_1::CardPowerState::POWER_UP;
13424 RLOGD("registerService: starting android::hardware::radio::V1_6::IRadio %s for slot %d",
13425 serviceNames[i], i);
13426
13427 // use a compat shim to convert HIDL interface to AIDL and publish it
13428 // TODO(bug 220004469): replace with a full AIDL implementation
13429 auto radioHidl = radioService[i];
13430 const auto slot = serviceNames[i];
13431 auto context = std::make_shared<compat::DriverContext>();
13432 auto callbackMgr = std::make_shared<compat::CallbackManager>(context, radioHidl);
13433 publishRadioHal<compat::RadioData>(context, radioHidl, callbackMgr, slot);
13434 publishRadioHal<compat::RadioMessaging>(context, radioHidl, callbackMgr, slot);
13435 publishRadioHal<compat::RadioModem>(context, radioHidl, callbackMgr, slot);
13436 publishRadioHal<cf::ril::RefRadioNetwork>(context, radioHidl, callbackMgr, slot);
13437 publishRadioHal<compat::RadioSim>(context, radioHidl, callbackMgr, slot);
13438 publishRadioHal<compat::RadioVoice>(context, radioHidl, callbackMgr, slot);
13439 publishRadioHal<cf::ril::RefRadioIms>(context, radioHidl, callbackMgr, slot);
13440 publishRadioHal<cf::ril::RefImsMedia>(context, radioHidl, callbackMgr,
13441 std::string("default"));
13442 publishRadioHal<cf::ril::RefRadioModem>(context, radioHidl, callbackMgr, slot);
13443 publishRadioHal<cf::ril::RefRadioSim>(context, radioHidl, callbackMgr, slot);
13444 RLOGD("registerService: OemHook is enabled = %s", kOemHookEnabled ? "true" : "false");
13445 if (kOemHookEnabled) {
13446 oemHookService[i] = new OemHookImpl;
13447 oemHookService[i]->mSlotId = i;
13448 // status = oemHookService[i]->registerAsService(serviceNames[i]);
13449 }
13450 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
13451 CHECK_EQ(ret, 0);
13452 }
13453 }
13454
rilc_thread_pool()13455 void rilc_thread_pool() {
13456 ABinderProcess_joinThreadPool();
13457 }
13458
getRadioServiceRwlock(int slotId)13459 pthread_rwlock_t * radio_1_6::getRadioServiceRwlock(int slotId) {
13460 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
13461
13462 #if (SIM_COUNT >= 2)
13463 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
13464 #if (SIM_COUNT >= 3)
13465 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
13466 #if (SIM_COUNT >= 4)
13467 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
13468 #endif
13469 #endif
13470 #endif
13471
13472 return radioServiceRwlockPtr;
13473 }
13474
13475 // should acquire write lock for the corresponding service before calling this
setNitzTimeReceived(int slotId,long timeReceived)13476 void radio_1_6::setNitzTimeReceived(int slotId, long timeReceived) {
13477 nitzTimeReceived[slotId] = timeReceived;
13478 }
13479