blob: 709203759030e6360f4fb9c426e42f3e289a9d15 [file] [log] [blame]
paulye91d34712019-02-07 19:02:02 -08001/*
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
Malcolm Chen6b9984e2019-10-10 14:44:58 -070019#include <android/hardware/radio/1.5/IRadio.h>
20#include <android/hardware/radio/1.5/IRadioResponse.h>
21#include <android/hardware/radio/1.5/IRadioIndication.h>
22#include <android/hardware/radio/1.5/types.h>
paulye91d34712019-02-07 19:02:02 -080023
24#include <android/hardware/radio/deprecated/1.0/IOemHook.h>
25
26#include <hwbinder/IPCThreadState.h>
27#include <hwbinder/ProcessState.h>
28#include <guest/hals/ril/libril/ril.h>
29#include <telephony/ril_mnc.h>
30#include <guest/hals/ril/libril/ril_service.h>
31#include <hidl/HidlTransportSupport.h>
32#include <utils/SystemClock.h>
33#include <inttypes.h>
34
35#define INVALID_HEX_CHAR 16
36
37using namespace android::hardware::radio;
38using namespace android::hardware::radio::V1_0;
39using namespace android::hardware::radio::deprecated::V1_0;
40using ::android::hardware::configureRpcThreadpool;
41using ::android::hardware::joinRpcThreadpool;
42using ::android::hardware::Return;
43using ::android::hardware::hidl_bitfield;
44using ::android::hardware::hidl_string;
45using ::android::hardware::hidl_vec;
46using ::android::hardware::hidl_array;
47using ::android::hardware::Void;
48using android::CommandInfo;
49using android::RequestInfo;
50using android::requestToString;
51using android::sp;
52
53#define BOOL_TO_INT(x) (x ? 1 : 0)
54#define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
55#define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
56
57#if defined(ANDROID_MULTI_SIM)
58#define CALL_ONREQUEST(a, b, c, d, e) \
59 s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e)))
60#define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a))
61#else
62#define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d))
63#define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
64#endif
65
66#ifdef OEM_HOOK_DISABLED
67constexpr bool kOemHookEnabled = false;
68#else
69constexpr bool kOemHookEnabled = true;
70#endif
71
72RIL_RadioFunctions *s_vendorFunctions = NULL;
73static CommandInfo *s_commands;
74
Malcolm Chen6b9984e2019-10-10 14:44:58 -070075struct RadioImpl_1_5;
paulye91d34712019-02-07 19:02:02 -080076struct OemHookImpl;
77
78#if (SIM_COUNT >= 2)
Malcolm Chen6b9984e2019-10-10 14:44:58 -070079sp<RadioImpl_1_5> radioService[SIM_COUNT];
paulye91d34712019-02-07 19:02:02 -080080sp<OemHookImpl> oemHookService[SIM_COUNT];
81int64_t nitzTimeReceived[SIM_COUNT];
82// counter used for synchronization. It is incremented every time response callbacks are updated.
83volatile int32_t mCounterRadio[SIM_COUNT];
84volatile int32_t mCounterOemHook[SIM_COUNT];
85#else
Malcolm Chen6b9984e2019-10-10 14:44:58 -070086sp<RadioImpl_1_5> radioService[1];
paulye91d34712019-02-07 19:02:02 -080087sp<OemHookImpl> oemHookService[1];
88int64_t nitzTimeReceived[1];
89// counter used for synchronization. It is incremented every time response callbacks are updated.
90volatile int32_t mCounterRadio[1];
91volatile int32_t mCounterOemHook[1];
92#endif
93
94static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
95
96#if (SIM_COUNT >= 2)
97static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
98#if (SIM_COUNT >= 3)
99static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
100#if (SIM_COUNT >= 4)
101static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
102#endif
103#endif
104#endif
105
106void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
107 hidl_vec<HardwareConfig>& records);
108
109void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
110
111void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
112
113void convertRilSignalStrengthToHal(void *response, size_t responseLen,
114 SignalStrength& signalStrength);
115
116void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
117 SetupDataCallResult& dcResult);
118
Jack Yud5a67ed2019-03-06 14:59:36 -0800119void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
120 ::android::hardware::radio::V1_4::SetupDataCallResult& dcResult);
121
Sarah Chin9ecfc322020-01-16 10:35:02 -0800122void convertRilDataCallToHal(RIL_Data_Call_Response_v12 *dcResponse,
Jack Yufd2ea3f2019-12-14 10:43:41 -0800123 ::android::hardware::radio::V1_5::SetupDataCallResult& dcResult);
124
paulye91d34712019-02-07 19:02:02 -0800125void convertRilDataCallListToHal(void *response, size_t responseLen,
126 hidl_vec<SetupDataCallResult>& dcResultList);
127
128void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
129
Jack Yud5a67ed2019-03-06 14:59:36 -0800130void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
131 RIL_Errno e);
132
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700133struct RadioImpl_1_5 : public V1_5::IRadio {
paulye91d34712019-02-07 19:02:02 -0800134 int32_t mSlotId;
135 sp<IRadioResponse> mRadioResponse;
136 sp<IRadioIndication> mRadioIndication;
Malcolm Chen4bb42072019-02-22 18:21:48 -0800137 sp<V1_2::IRadioResponse> mRadioResponseV1_2;
138 sp<V1_2::IRadioIndication> mRadioIndicationV1_2;
139 sp<V1_3::IRadioResponse> mRadioResponseV1_3;
140 sp<V1_3::IRadioIndication> mRadioIndicationV1_3;
paulye91d34712019-02-07 19:02:02 -0800141 sp<V1_4::IRadioResponse> mRadioResponseV1_4;
142 sp<V1_4::IRadioIndication> mRadioIndicationV1_4;
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700143 sp<V1_5::IRadioResponse> mRadioResponseV1_5;
144 sp<V1_5::IRadioIndication> mRadioIndicationV1_5;
paulye91d34712019-02-07 19:02:02 -0800145
146 Return<void> setResponseFunctions(
147 const ::android::sp<IRadioResponse>& radioResponse,
148 const ::android::sp<IRadioIndication>& radioIndication);
149
150 Return<void> getIccCardStatus(int32_t serial);
151
152 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
153 const hidl_string& aid);
154
155 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
156 const hidl_string& pin, const hidl_string& aid);
157
158 Return<void> supplyIccPin2ForApp(int32_t serial,
159 const hidl_string& pin2,
160 const hidl_string& aid);
161
162 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
163 const hidl_string& pin2, const hidl_string& aid);
164
165 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
166 const hidl_string& newPin, const hidl_string& aid);
167
168 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
169 const hidl_string& newPin2, const hidl_string& aid);
170
171 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
172
173 Return<void> getCurrentCalls(int32_t serial);
174
175 Return<void> dial(int32_t serial, const Dial& dialInfo);
176
177 Return<void> getImsiForApp(int32_t serial,
178 const ::android::hardware::hidl_string& aid);
179
180 Return<void> hangup(int32_t serial, int32_t gsmIndex);
181
182 Return<void> hangupWaitingOrBackground(int32_t serial);
183
184 Return<void> hangupForegroundResumeBackground(int32_t serial);
185
186 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
187
188 Return<void> conference(int32_t serial);
189
190 Return<void> rejectCall(int32_t serial);
191
192 Return<void> getLastCallFailCause(int32_t serial);
193
194 Return<void> getSignalStrength(int32_t serial);
195
196 Return<void> getVoiceRegistrationState(int32_t serial);
197
198 Return<void> getDataRegistrationState(int32_t serial);
199
200 Return<void> getOperator(int32_t serial);
201
202 Return<void> setRadioPower(int32_t serial, bool on);
203
204 Return<void> sendDtmf(int32_t serial,
205 const ::android::hardware::hidl_string& s);
206
207 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
208
209 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
210
211 Return<void> setupDataCall(int32_t serial,
212 RadioTechnology radioTechnology,
213 const DataProfileInfo& profileInfo,
214 bool modemCognitive,
215 bool roamingAllowed,
216 bool isRoaming);
217
218 Return<void> iccIOForApp(int32_t serial,
219 const IccIo& iccIo);
220
221 Return<void> sendUssd(int32_t serial,
222 const ::android::hardware::hidl_string& ussd);
223
224 Return<void> cancelPendingUssd(int32_t serial);
225
226 Return<void> getClir(int32_t serial);
227
228 Return<void> setClir(int32_t serial, int32_t status);
229
230 Return<void> getCallForwardStatus(int32_t serial,
231 const CallForwardInfo& callInfo);
232
233 Return<void> setCallForward(int32_t serial,
234 const CallForwardInfo& callInfo);
235
236 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
237
238 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
239
240 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
241 bool success, SmsAcknowledgeFailCause cause);
242
243 Return<void> acceptCall(int32_t serial);
244
245 Return<void> deactivateDataCall(int32_t serial,
246 int32_t cid, bool reasonRadioShutDown);
247
248 Return<void> getFacilityLockForApp(int32_t serial,
249 const ::android::hardware::hidl_string& facility,
250 const ::android::hardware::hidl_string& password,
251 int32_t serviceClass,
252 const ::android::hardware::hidl_string& appId);
253
254 Return<void> setFacilityLockForApp(int32_t serial,
255 const ::android::hardware::hidl_string& facility,
256 bool lockState,
257 const ::android::hardware::hidl_string& password,
258 int32_t serviceClass,
259 const ::android::hardware::hidl_string& appId);
260
261 Return<void> setBarringPassword(int32_t serial,
262 const ::android::hardware::hidl_string& facility,
263 const ::android::hardware::hidl_string& oldPassword,
264 const ::android::hardware::hidl_string& newPassword);
265
266 Return<void> getNetworkSelectionMode(int32_t serial);
267
268 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
269
270 Return<void> setNetworkSelectionModeManual(int32_t serial,
271 const ::android::hardware::hidl_string& operatorNumeric);
272
273 Return<void> getAvailableNetworks(int32_t serial);
274
275 Return<void> startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request);
276
277 Return<void> stopNetworkScan(int32_t serial);
278
279 Return<void> startDtmf(int32_t serial,
280 const ::android::hardware::hidl_string& s);
281
282 Return<void> stopDtmf(int32_t serial);
283
284 Return<void> getBasebandVersion(int32_t serial);
285
286 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
287
288 Return<void> setMute(int32_t serial, bool enable);
289
290 Return<void> getMute(int32_t serial);
291
292 Return<void> getClip(int32_t serial);
293
294 Return<void> getDataCallList(int32_t serial);
295
296 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
297
298 Return<void> writeSmsToSim(int32_t serial,
299 const SmsWriteArgs& smsWriteArgs);
300
301 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
302
303 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
304
305 Return<void> getAvailableBandModes(int32_t serial);
306
307 Return<void> sendEnvelope(int32_t serial,
308 const ::android::hardware::hidl_string& command);
309
310 Return<void> sendTerminalResponseToSim(int32_t serial,
311 const ::android::hardware::hidl_string& commandResponse);
312
313 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
314
315 Return<void> explicitCallTransfer(int32_t serial);
316
317 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
318
319 Return<void> getPreferredNetworkType(int32_t serial);
320
321 Return<void> getNeighboringCids(int32_t serial);
322
323 Return<void> setLocationUpdates(int32_t serial, bool enable);
324
325 Return<void> setCdmaSubscriptionSource(int32_t serial,
326 CdmaSubscriptionSource cdmaSub);
327
328 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
329
330 Return<void> getCdmaRoamingPreference(int32_t serial);
331
332 Return<void> setTTYMode(int32_t serial, TtyMode mode);
333
334 Return<void> getTTYMode(int32_t serial);
335
336 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
337
338 Return<void> getPreferredVoicePrivacy(int32_t serial);
339
340 Return<void> sendCDMAFeatureCode(int32_t serial,
341 const ::android::hardware::hidl_string& featureCode);
342
343 Return<void> sendBurstDtmf(int32_t serial,
344 const ::android::hardware::hidl_string& dtmf,
345 int32_t on,
346 int32_t off);
347
348 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
349
350 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
351 const CdmaSmsAck& smsAck);
352
353 Return<void> getGsmBroadcastConfig(int32_t serial);
354
355 Return<void> setGsmBroadcastConfig(int32_t serial,
356 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
357
358 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
359
360 Return<void> getCdmaBroadcastConfig(int32_t serial);
361
362 Return<void> setCdmaBroadcastConfig(int32_t serial,
363 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
364
365 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
366
367 Return<void> getCDMASubscription(int32_t serial);
368
369 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
370
371 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
372
373 Return<void> getDeviceIdentity(int32_t serial);
374
375 Return<void> exitEmergencyCallbackMode(int32_t serial);
376
377 Return<void> getSmscAddress(int32_t serial);
378
379 Return<void> setSmscAddress(int32_t serial,
380 const ::android::hardware::hidl_string& smsc);
381
382 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
383
384 Return<void> reportStkServiceIsRunning(int32_t serial);
385
386 Return<void> getCdmaSubscriptionSource(int32_t serial);
387
388 Return<void> requestIsimAuthentication(int32_t serial,
389 const ::android::hardware::hidl_string& challenge);
390
391 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
392 bool success,
393 const ::android::hardware::hidl_string& ackPdu);
394
395 Return<void> sendEnvelopeWithStatus(int32_t serial,
396 const ::android::hardware::hidl_string& contents);
397
398 Return<void> getVoiceRadioTechnology(int32_t serial);
399
400 Return<void> getCellInfoList(int32_t serial);
401
402 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
403
404 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
405 bool modemCognitive, bool isRoaming);
406
407 Return<void> getImsRegistrationState(int32_t serial);
408
409 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
410
411 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
412
413 Return<void> iccOpenLogicalChannel(int32_t serial,
414 const ::android::hardware::hidl_string& aid, int32_t p2);
415
416 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
417
418 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
419
420 Return<void> nvReadItem(int32_t serial, NvItem itemId);
421
422 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
423
424 Return<void> nvWriteCdmaPrl(int32_t serial,
425 const ::android::hardware::hidl_vec<uint8_t>& prl);
426
427 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
428
429 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
430
431 Return<void> setDataAllowed(int32_t serial, bool allow);
432
433 Return<void> getHardwareConfig(int32_t serial);
434
435 Return<void> requestIccSimAuthentication(int32_t serial,
436 int32_t authContext,
437 const ::android::hardware::hidl_string& authData,
438 const ::android::hardware::hidl_string& aid);
439
440 Return<void> setDataProfile(int32_t serial,
441 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
442
443 Return<void> requestShutdown(int32_t serial);
444
445 Return<void> getRadioCapability(int32_t serial);
446
447 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
448
449 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
450
451 Return<void> stopLceService(int32_t serial);
452
453 Return<void> pullLceData(int32_t serial);
454
455 Return<void> getModemActivityInfo(int32_t serial);
456
457 Return<void> setAllowedCarriers(int32_t serial,
458 bool allAllowed,
459 const CarrierRestrictions& carriers);
460
461 Return<void> getAllowedCarriers(int32_t serial);
462
463 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
464
465 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
466
467 Return<void> startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive);
468
469 Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
470
471 Return<void> setSimCardPower(int32_t serial, bool powerUp);
472 Return<void> setSimCardPower_1_1(int32_t serial,
473 const V1_1::CardPowerState state);
474
475 Return<void> responseAcknowledgement();
476
477 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
478 const V1_1::ImsiEncryptionInfo& message);
479
480 void checkReturnStatus(Return<void>& ret);
481
482 // Methods from ::android::hardware::radio::V1_2::IRadio follow.
483 Return<void> startNetworkScan_1_2(int32_t serial,
484 const ::android::hardware::radio::V1_2::NetworkScanRequest& request);
485 Return<void> setIndicationFilter_1_2(int32_t serial,
486 hidl_bitfield<::android::hardware::radio::V1_2::IndicationFilter> indicationFilter);
487 Return<void> setSignalStrengthReportingCriteria(int32_t serial, int32_t hysteresisMs,
488 int32_t hysteresisDb, const hidl_vec<int32_t>& thresholdsDbm,
489 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork);
490 Return<void> setLinkCapacityReportingCriteria(int32_t serial, int32_t hysteresisMs,
491 int32_t hysteresisDlKbps, int32_t hysteresisUlKbps,
492 const hidl_vec<int32_t>& thresholdsDownlinkKbps,
493 const hidl_vec<int32_t>& thresholdsUplinkKbps,
494 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork);
495 Return<void> setupDataCall_1_2(int32_t serial,
496 ::android::hardware::radio::V1_2::AccessNetwork accessNetwork,
497 const ::android::hardware::radio::V1_0::DataProfileInfo& dataProfileInfo,
498 bool modemCognitive, bool roamingAllowed, bool isRoaming,
499 ::android::hardware::radio::V1_2::DataRequestReason reason,
500 const hidl_vec<hidl_string>& addresses, const hidl_vec<hidl_string>& dnses);
501 Return<void> deactivateDataCall_1_2(int32_t serial, int32_t cid,
502 ::android::hardware::radio::V1_2::DataRequestReason reason);
503
504 // Methods from ::android::hardware::radio::V1_3::IRadio follow.
505 Return<void> setSystemSelectionChannels(int32_t serial, bool specifyChannels,
Sarah Chinbb757c62019-11-06 12:46:42 -0800506 const hidl_vec<::android::hardware::radio::V1_1::RadioAccessSpecifier>& specifiers);
paulye91d34712019-02-07 19:02:02 -0800507 Return<void> enableModem(int32_t serial, bool on);
508 Return<void> getModemStackStatus(int32_t serial);
509
510 // Methods from ::android::hardware::radio::V1_4::IRadio follow.
511 Return<void> setupDataCall_1_4(int32_t serial,
512 ::android::hardware::radio::V1_4::AccessNetwork accessNetwork,
513 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo,
514 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason reason,
515 const hidl_vec<hidl_string>& addresses, const hidl_vec<hidl_string>& dnses);
516 Return<void> setInitialAttachApn_1_4(int32_t serial,
517 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo);
518 Return<void> setDataProfile_1_4(int32_t serial,
519 const hidl_vec<::android::hardware::radio::V1_4::DataProfileInfo>& profiles);
520 Return<void> emergencyDial(int32_t serial,
521 const ::android::hardware::radio::V1_0::Dial& dialInfo,
522 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> categories,
523 const hidl_vec<hidl_string>& urns,
524 ::android::hardware::radio::V1_4::EmergencyCallRouting routing,
525 bool fromEmergencyDialer, bool isTesting);
526 Return<void> startNetworkScan_1_4(int32_t serial,
527 const ::android::hardware::radio::V1_2::NetworkScanRequest& request);
528 Return<void> getPreferredNetworkTypeBitmap(int32_t serial);
529 Return<void> setPreferredNetworkTypeBitmap(
530 int32_t serial, hidl_bitfield<RadioAccessFamily> networkTypeBitmap);
531 Return<void> setAllowedCarriers_1_4(int32_t serial,
532 const ::android::hardware::radio::V1_4::CarrierRestrictionsWithPriority& carriers,
533 ::android::hardware::radio::V1_4::SimLockMultiSimPolicy multiSimPolicy);
534 Return<void> getAllowedCarriers_1_4(int32_t serial);
535 Return<void> getSignalStrength_1_4(int32_t serial);
Shuo Qian4fffb032019-11-08 17:59:42 -0800536
537 // Methods from ::android::hardware::radio::V1_5::IRadio follow.
538 Return<void> setSignalStrengthReportingCriteria_1_5(int32_t serial,
539 const ::android::hardware::radio::V1_5::SignalThresholdInfo& signalThresholdInfo,
540 const ::android::hardware::radio::V1_5::AccessNetwork accessNetwork);
Malcolm Chenc2008a22019-11-12 18:43:09 -0800541 Return<void> enableUiccApplications(int32_t serial, bool detach);
542 Return<void> areUiccApplicationsEnabled(int32_t serial);
Sarah Chinbb757c62019-11-06 12:46:42 -0800543 Return<void> setSystemSelectionChannels_1_5(int32_t serial, bool specifyChannels,
544 const hidl_vec<::android::hardware::radio::V1_5::RadioAccessSpecifier>& specifiers);
545 Return<void> startNetworkScan_1_5(int32_t serial,
546 const ::android::hardware::radio::V1_5::NetworkScanRequest& request);
Sarah Chin75b299c2019-12-11 10:57:28 -0800547 Return<void> setupDataCall_1_5(int32_t serial,
548 ::android::hardware::radio::V1_5::AccessNetwork accessNetwork,
549 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
550 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason reason,
Jack Yufd2ea3f2019-12-14 10:43:41 -0800551 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& addresses,
552 const hidl_vec<hidl_string>& dnses);
Sarah Chin75b299c2019-12-11 10:57:28 -0800553 Return<void> setInitialAttachApn_1_5(int32_t serial,
554 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo);
555 Return<void> setDataProfile_1_5(int32_t serial,
556 const hidl_vec<::android::hardware::radio::V1_5::DataProfileInfo>& profiles);
Malcolm Chenad6b0972019-12-17 15:52:16 -0800557 Return<void> setRadioPower_1_5(int32_t serial, bool powerOn, bool forEmergencyCall,
558 bool preferredForEmergencyCall);
Nathan Harold30a7d092020-01-02 15:08:37 -0800559 Return<void> setIndicationFilter_1_5(int32_t serial,
560 hidl_bitfield<::android::hardware::radio::V1_5::IndicationFilter> indicationFilter);
Nathan Harold8a9283c2020-01-02 15:31:41 -0800561 Return<void> getBarringInfo(int32_t serial);
Nathan Harold229840b2020-01-17 19:12:37 -0800562 Return<void> getVoiceRegistrationState_1_5(int32_t serial);
563 Return<void> getDataRegistrationState_1_5(int32_t serial);
Sarah Chin65f1d7f2019-12-18 17:07:39 -0800564 Return<void> setNetworkSelectionModeManual_1_5(int32_t serial,
565 const hidl_string& operatorNumeric, V1_5::RadioAccessNetworks ran);
Sarah Chinef7f9222020-01-30 10:37:08 -0800566 Return<void> sendCdmaSmsExpectMore(int32_t serial, const CdmaSmsMessage& sms);
567 Return<void> supplySimDepersonalization(int32_t serial, V1_5::PersoSubstate persoType,
568 const hidl_string& controlKey);
paulye91d34712019-02-07 19:02:02 -0800569};
570
571struct OemHookImpl : public IOemHook {
572 int32_t mSlotId;
573 sp<IOemHookResponse> mOemHookResponse;
574 sp<IOemHookIndication> mOemHookIndication;
575
576 Return<void> setResponseFunctions(
577 const ::android::sp<IOemHookResponse>& oemHookResponse,
578 const ::android::sp<IOemHookIndication>& oemHookIndication);
579
580 Return<void> sendRequestRaw(int32_t serial,
581 const ::android::hardware::hidl_vec<uint8_t>& data);
582
583 Return<void> sendRequestStrings(int32_t serial,
584 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
585};
586
587void memsetAndFreeStrings(int numPointers, ...) {
588 va_list ap;
589 va_start(ap, numPointers);
590 for (int i = 0; i < numPointers; i++) {
591 char *ptr = va_arg(ap, char *);
592 if (ptr) {
593#ifdef MEMSET_FREED
594#define MAX_STRING_LENGTH 4096
595 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
596#endif
597 free(ptr);
598 }
599 }
600 va_end(ap);
601}
602
603void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
604 pRI->pCI->responseFunction((int) pRI->socket_id,
605 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
606}
607
608/**
609 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
610 * request with error RIL_E_NO_MEMORY. The size() method is used to determine the size of the
611 * destination buffer into which the HIDL string is copied. If there is a discrepancy between
612 * the string length reported by the size() method, and the length of the string returned by
613 * the c_str() method, the function will return false indicating a failure.
614 *
615 * Returns true on success, and false on failure.
616 */
617bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI, bool allowEmpty) {
618 size_t len = src.size();
619 if (len == 0 && !allowEmpty) {
620 *dest = NULL;
621 return true;
622 }
623 *dest = (char *) calloc(len + 1, sizeof(char));
624 if (*dest == NULL) {
625 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
626 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
627 return false;
628 }
629 if (strlcpy(*dest, src.c_str(), len + 1) >= (len + 1)) {
630 RLOGE("Copy of the HIDL string has been truncated, as "
631 "the string length reported by size() does not "
632 "match the length of string returned by c_str().");
633 free(*dest);
634 *dest = NULL;
635 sendErrorResponse(pRI, RIL_E_INTERNAL_ERR);
636 return false;
637 }
638 return true;
639}
640
641bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
642 return copyHidlStringToRil(dest, src, pRI, false);
643}
644
645hidl_string convertCharPtrToHidlString(const char *ptr) {
646 hidl_string ret;
647 if (ptr != NULL) {
648 // TODO: replace this with strnlen
649 ret.setToExternal(ptr, strlen(ptr));
650 }
651 return ret;
652}
653
654bool dispatchVoid(int serial, int slotId, int request) {
655 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
656 if (pRI == NULL) {
657 return false;
658 }
659 CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
660 return true;
661}
662
663bool dispatchString(int serial, int slotId, int request, const char * str) {
664 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
665 if (pRI == NULL) {
666 return false;
667 }
668
669 char *pString;
670 if (!copyHidlStringToRil(&pString, str, pRI)) {
671 return false;
672 }
673
674 CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
675
676 memsetAndFreeStrings(1, pString);
677 return true;
678}
679
680bool dispatchStrings(int serial, int slotId, int request, bool allowEmpty, int countStrings, ...) {
681 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
682 if (pRI == NULL) {
683 return false;
684 }
685
686 char **pStrings;
687 pStrings = (char **)calloc(countStrings, sizeof(char *));
688 if (pStrings == NULL) {
689 RLOGE("Memory allocation failed for request %s", requestToString(request));
690 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
691 return false;
692 }
693 va_list ap;
694 va_start(ap, countStrings);
695 for (int i = 0; i < countStrings; i++) {
696 const char* str = va_arg(ap, const char *);
697 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI, allowEmpty)) {
698 va_end(ap);
699 for (int j = 0; j < i; j++) {
700 memsetAndFreeStrings(1, pStrings[j]);
701 }
702 free(pStrings);
703 return false;
704 }
705 }
706 va_end(ap);
707
708 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
709
710 if (pStrings != NULL) {
711 for (int i = 0 ; i < countStrings ; i++) {
712 memsetAndFreeStrings(1, pStrings[i]);
713 }
714
715#ifdef MEMSET_FREED
716 memset(pStrings, 0, countStrings * sizeof(char *));
717#endif
718 free(pStrings);
719 }
720 return true;
721}
722
723bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
724 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
725 if (pRI == NULL) {
726 return false;
727 }
728
729 int countStrings = data.size();
730 char **pStrings;
731 pStrings = (char **)calloc(countStrings, sizeof(char *));
732 if (pStrings == NULL) {
733 RLOGE("Memory allocation failed for request %s", requestToString(request));
734 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
735 return false;
736 }
737
738 for (int i = 0; i < countStrings; i++) {
739 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
740 for (int j = 0; j < i; j++) {
741 memsetAndFreeStrings(1, pStrings[j]);
742 }
743 free(pStrings);
744 return false;
745 }
746 }
747
748 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
749
750 if (pStrings != NULL) {
751 for (int i = 0 ; i < countStrings ; i++) {
752 memsetAndFreeStrings(1, pStrings[i]);
753 }
754
755#ifdef MEMSET_FREED
756 memset(pStrings, 0, countStrings * sizeof(char *));
757#endif
758 free(pStrings);
759 }
760 return true;
761}
762
763bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
764 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
765 if (pRI == NULL) {
766 return false;
767 }
768
769 int *pInts = (int *)calloc(countInts, sizeof(int));
770
771 if (pInts == NULL) {
772 RLOGE("Memory allocation failed for request %s", requestToString(request));
773 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
774 return false;
775 }
776 va_list ap;
777 va_start(ap, countInts);
778 for (int i = 0; i < countInts; i++) {
779 pInts[i] = va_arg(ap, int);
780 }
781 va_end(ap);
782
783 CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
784
785 if (pInts != NULL) {
786#ifdef MEMSET_FREED
787 memset(pInts, 0, countInts * sizeof(int));
788#endif
789 free(pInts);
790 }
791 return true;
792}
793
794bool dispatchCallForwardStatus(int serial, int slotId, int request,
795 const CallForwardInfo& callInfo) {
796 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
797 if (pRI == NULL) {
798 return false;
799 }
800
801 RIL_CallForwardInfo cf;
802 cf.status = (int) callInfo.status;
803 cf.reason = callInfo.reason;
804 cf.serviceClass = callInfo.serviceClass;
805 cf.toa = callInfo.toa;
806 cf.timeSeconds = callInfo.timeSeconds;
807
808 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
809 return false;
810 }
811
812 CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
813
814 memsetAndFreeStrings(1, cf.number);
815
816 return true;
817}
818
819bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
820 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
821 if (pRI == NULL) {
822 return false;
823 }
824
825 const uint8_t *uData = rawBytes.data();
826
827 CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
828
829 return true;
830}
831
832bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
833 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
834 if (pRI == NULL) {
835 return false;
836 }
837
838 RIL_SIM_APDU apdu = {};
839
840 apdu.sessionid = message.sessionId;
841 apdu.cla = message.cla;
842 apdu.instruction = message.instruction;
843 apdu.p1 = message.p1;
844 apdu.p2 = message.p2;
845 apdu.p3 = message.p3;
846
847 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
848 return false;
849 }
850
851 CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
852
853 memsetAndFreeStrings(1, apdu.data);
854
855 return true;
856}
857
858void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
paulye91d34712019-02-07 19:02:02 -0800859 if (ret.isOk() == false) {
860 RLOGE("checkReturnStatus: unable to call response/indication callback");
861 // Remote process hosting the callbacks must be dead. Reset the callback objects;
862 // there's no other recovery to be done here. When the client process is back up, it will
863 // call setResponseFunctions()
864
865 // Caller should already hold rdlock, release that first
866 // note the current counter to avoid overwriting updates made by another thread before
867 // write lock is acquired.
868 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700869 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_5::getRadioServiceRwlock(slotId);
paulye91d34712019-02-07 19:02:02 -0800870 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
871 assert(ret == 0);
872
873 // acquire wrlock
874 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
875 assert(ret == 0);
876
877 // make sure the counter value has not changed
878 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
879 if (isRadioService) {
880 radioService[slotId]->mRadioResponse = NULL;
881 radioService[slotId]->mRadioIndication = NULL;
Malcolm Chen4bb42072019-02-22 18:21:48 -0800882 radioService[slotId]->mRadioResponseV1_2 = NULL;
883 radioService[slotId]->mRadioIndicationV1_2 = NULL;
884 radioService[slotId]->mRadioResponseV1_3 = NULL;
885 radioService[slotId]->mRadioIndicationV1_3 = NULL;
paulye91d34712019-02-07 19:02:02 -0800886 radioService[slotId]->mRadioResponseV1_4 = NULL;
887 radioService[slotId]->mRadioIndicationV1_4 = NULL;
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700888 radioService[slotId]->mRadioResponseV1_5 = NULL;
889 radioService[slotId]->mRadioIndicationV1_5 = NULL;
paulye91d34712019-02-07 19:02:02 -0800890 } else {
891 oemHookService[slotId]->mOemHookResponse = NULL;
892 oemHookService[slotId]->mOemHookIndication = NULL;
893 }
894 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
895 } else {
896 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
897 "got updated on another thread");
898 }
899
900 // release wrlock
901 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
902 assert(ret == 0);
903
904 // Reacquire rdlock
905 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
906 assert(ret == 0);
907 }
908}
909
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700910void RadioImpl_1_5::checkReturnStatus(Return<void>& ret) {
paulye91d34712019-02-07 19:02:02 -0800911 ::checkReturnStatus(mSlotId, ret, true);
912}
913
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700914Return<void> RadioImpl_1_5::setResponseFunctions(
paulye91d34712019-02-07 19:02:02 -0800915 const ::android::sp<IRadioResponse>& radioResponseParam,
916 const ::android::sp<IRadioIndication>& radioIndicationParam) {
917 RLOGD("setResponseFunctions");
918
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700919 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_5::getRadioServiceRwlock(mSlotId);
paulye91d34712019-02-07 19:02:02 -0800920 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
921 assert(ret == 0);
922
923 mRadioResponse = radioResponseParam;
924 mRadioIndication = radioIndicationParam;
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700925
926 mRadioResponseV1_5 = V1_5::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
927 mRadioIndicationV1_5 = V1_5::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
928 if (mRadioResponseV1_5 == nullptr || mRadioIndicationV1_5 == nullptr) {
929 mRadioResponseV1_5 = nullptr;
930 mRadioIndicationV1_5 = nullptr;
931 }
932
paulye91d34712019-02-07 19:02:02 -0800933 mRadioResponseV1_4 = V1_4::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
934 mRadioIndicationV1_4 = V1_4::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
935 if (mRadioResponseV1_4 == nullptr || mRadioIndicationV1_4 == nullptr) {
936 mRadioResponseV1_4 = nullptr;
937 mRadioIndicationV1_4 = nullptr;
938 }
939
Malcolm Chen4bb42072019-02-22 18:21:48 -0800940 mRadioResponseV1_3 = V1_3::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
941 mRadioIndicationV1_3 = V1_3::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
942 if (mRadioResponseV1_3 == nullptr || mRadioIndicationV1_3 == nullptr) {
943 mRadioResponseV1_3 = nullptr;
944 mRadioIndicationV1_3 = nullptr;
945 }
946
947 mRadioResponseV1_2 = V1_2::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
948 mRadioIndicationV1_2 = V1_2::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
949 if (mRadioResponseV1_2 == nullptr || mRadioIndicationV1_2 == nullptr) {
950 mRadioResponseV1_2 = nullptr;
951 mRadioIndicationV1_2 = nullptr;
952 }
953
paulye91d34712019-02-07 19:02:02 -0800954 mCounterRadio[mSlotId]++;
955
956 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
957 assert(ret == 0);
958
959 // client is connected. Send initial indications.
960 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
961
962 return Void();
963}
964
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700965Return<void> RadioImpl_1_5::getIccCardStatus(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -0800966#if VDBG
967 RLOGD("getIccCardStatus: serial %d", serial);
968#endif
969 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
970 return Void();
971}
972
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700973Return<void> RadioImpl_1_5::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
paulye91d34712019-02-07 19:02:02 -0800974 const hidl_string& aid) {
975#if VDBG
976 RLOGD("supplyIccPinForApp: serial %d", serial);
977#endif
978 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN, true,
979 2, pin.c_str(), aid.c_str());
980 return Void();
981}
982
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700983Return<void> RadioImpl_1_5::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
paulye91d34712019-02-07 19:02:02 -0800984 const hidl_string& pin, const hidl_string& aid) {
985#if VDBG
986 RLOGD("supplyIccPukForApp: serial %d", serial);
987#endif
988 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK, true,
989 3, puk.c_str(), pin.c_str(), aid.c_str());
990 return Void();
991}
992
Malcolm Chen6b9984e2019-10-10 14:44:58 -0700993Return<void> RadioImpl_1_5::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
paulye91d34712019-02-07 19:02:02 -0800994 const hidl_string& aid) {
995#if VDBG
996 RLOGD("supplyIccPin2ForApp: serial %d", serial);
997#endif
998 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2, true,
999 2, pin2.c_str(), aid.c_str());
1000 return Void();
1001}
1002
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001003Return<void> RadioImpl_1_5::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
paulye91d34712019-02-07 19:02:02 -08001004 const hidl_string& pin2, const hidl_string& aid) {
1005#if VDBG
1006 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
1007#endif
1008 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2, true,
1009 3, puk2.c_str(), pin2.c_str(), aid.c_str());
1010 return Void();
1011}
1012
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001013Return<void> RadioImpl_1_5::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
paulye91d34712019-02-07 19:02:02 -08001014 const hidl_string& newPin, const hidl_string& aid) {
1015#if VDBG
1016 RLOGD("changeIccPinForApp: serial %d", serial);
1017#endif
1018 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN, true,
1019 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
1020 return Void();
1021}
1022
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001023Return<void> RadioImpl_1_5::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
paulye91d34712019-02-07 19:02:02 -08001024 const hidl_string& newPin2, const hidl_string& aid) {
1025#if VDBG
1026 RLOGD("changeIccPin2ForApp: serial %d", serial);
1027#endif
1028 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2, true,
1029 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
1030 return Void();
1031}
1032
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001033Return<void> RadioImpl_1_5::supplyNetworkDepersonalization(int32_t serial,
paulye91d34712019-02-07 19:02:02 -08001034 const hidl_string& netPin) {
1035#if VDBG
1036 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
1037#endif
1038 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, true,
1039 1, netPin.c_str());
1040 return Void();
1041}
1042
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001043Return<void> RadioImpl_1_5::getCurrentCalls(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001044#if VDBG
1045 RLOGD("getCurrentCalls: serial %d", serial);
1046#endif
1047 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
1048 return Void();
1049}
1050
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001051Return<void> RadioImpl_1_5::dial(int32_t serial, const Dial& dialInfo) {
paulye91d34712019-02-07 19:02:02 -08001052#if VDBG
1053 RLOGD("dial: serial %d", serial);
1054#endif
1055 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
1056 if (pRI == NULL) {
1057 return Void();
1058 }
1059 RIL_Dial dial = {};
1060 RIL_UUS_Info uusInfo = {};
1061 int32_t sizeOfDial = sizeof(dial);
1062
1063 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
1064 return Void();
1065 }
1066 dial.clir = (int) dialInfo.clir;
1067
1068 if (dialInfo.uusInfo.size() != 0) {
1069 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
1070 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
1071
1072 if (dialInfo.uusInfo[0].uusData.size() == 0) {
1073 uusInfo.uusData = NULL;
1074 uusInfo.uusLength = 0;
1075 } else {
1076 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
1077 memsetAndFreeStrings(1, dial.address);
1078 return Void();
1079 }
1080 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
1081 }
1082
1083 dial.uusInfo = &uusInfo;
1084 }
1085
1086 CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
1087
1088 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
1089
1090 return Void();
1091}
1092
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001093Return<void> RadioImpl_1_5::getImsiForApp(int32_t serial, const hidl_string& aid) {
paulye91d34712019-02-07 19:02:02 -08001094#if VDBG
1095 RLOGD("getImsiForApp: serial %d", serial);
1096#endif
1097 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI, false,
1098 1, aid.c_str());
1099 return Void();
1100}
1101
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001102Return<void> RadioImpl_1_5::hangup(int32_t serial, int32_t gsmIndex) {
paulye91d34712019-02-07 19:02:02 -08001103#if VDBG
1104 RLOGD("hangup: serial %d", serial);
1105#endif
1106 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
1107 return Void();
1108}
1109
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001110Return<void> RadioImpl_1_5::hangupWaitingOrBackground(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001111#if VDBG
1112 RLOGD("hangupWaitingOrBackground: serial %d", serial);
1113#endif
1114 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
1115 return Void();
1116}
1117
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001118Return<void> RadioImpl_1_5::hangupForegroundResumeBackground(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001119#if VDBG
1120 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
1121#endif
1122 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
1123 return Void();
1124}
1125
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001126Return<void> RadioImpl_1_5::switchWaitingOrHoldingAndActive(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001127#if VDBG
1128 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
1129#endif
1130 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
1131 return Void();
1132}
1133
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001134Return<void> RadioImpl_1_5::conference(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001135#if VDBG
1136 RLOGD("conference: serial %d", serial);
1137#endif
1138 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
1139 return Void();
1140}
1141
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001142Return<void> RadioImpl_1_5::rejectCall(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001143#if VDBG
1144 RLOGD("rejectCall: serial %d", serial);
1145#endif
1146 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
1147 return Void();
1148}
1149
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001150Return<void> RadioImpl_1_5::getLastCallFailCause(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001151#if VDBG
1152 RLOGD("getLastCallFailCause: serial %d", serial);
1153#endif
1154 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
1155 return Void();
1156}
1157
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001158Return<void> RadioImpl_1_5::getSignalStrength(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001159#if VDBG
1160 RLOGD("getSignalStrength: serial %d", serial);
1161#endif
1162 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
1163 return Void();
1164}
1165
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001166Return<void> RadioImpl_1_5::getVoiceRegistrationState(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001167#if VDBG
1168 RLOGD("getVoiceRegistrationState: serial %d", serial);
1169#endif
1170 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
1171 return Void();
1172}
1173
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001174Return<void> RadioImpl_1_5::getDataRegistrationState(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001175#if VDBG
1176 RLOGD("getDataRegistrationState: serial %d", serial);
1177#endif
1178 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1179 return Void();
1180}
1181
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001182Return<void> RadioImpl_1_5::getOperator(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001183#if VDBG
1184 RLOGD("getOperator: serial %d", serial);
1185#endif
1186 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1187 return Void();
1188}
1189
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001190Return<void> RadioImpl_1_5::setRadioPower(int32_t serial, bool on) {
Sarah Chinef7f9222020-01-30 10:37:08 -08001191#if VDBG
paulye91d34712019-02-07 19:02:02 -08001192 RLOGD("setRadioPower: serial %d on %d", serial, on);
Sarah Chinef7f9222020-01-30 10:37:08 -08001193#endif
paulye91d34712019-02-07 19:02:02 -08001194 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1195 return Void();
1196}
1197
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001198Return<void> RadioImpl_1_5::sendDtmf(int32_t serial, const hidl_string& s) {
paulye91d34712019-02-07 19:02:02 -08001199#if VDBG
1200 RLOGD("sendDtmf: serial %d", serial);
1201#endif
1202 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1203 return Void();
1204}
1205
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001206Return<void> RadioImpl_1_5::sendSms(int32_t serial, const GsmSmsMessage& message) {
paulye91d34712019-02-07 19:02:02 -08001207#if VDBG
1208 RLOGD("sendSms: serial %d", serial);
1209#endif
1210 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, false,
1211 2, message.smscPdu.c_str(), message.pdu.c_str());
1212 return Void();
1213}
1214
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001215Return<void> RadioImpl_1_5::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
paulye91d34712019-02-07 19:02:02 -08001216#if VDBG
1217 RLOGD("sendSMSExpectMore: serial %d", serial);
1218#endif
1219 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, false,
1220 2, message.smscPdu.c_str(), message.pdu.c_str());
1221 return Void();
1222}
1223
1224static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1225 switch (type) {
1226 case MvnoType::IMSI:
1227 str = (char *)"imsi";
1228 return true;
1229 case MvnoType::GID:
1230 str = (char *)"gid";
1231 return true;
1232 case MvnoType::SPN:
1233 str = (char *)"spn";
1234 return true;
1235 case MvnoType::NONE:
1236 str = (char *)"";
1237 return true;
1238 }
1239 return false;
1240}
1241
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001242Return<void> RadioImpl_1_5::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
paulye91d34712019-02-07 19:02:02 -08001243 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1244 bool roamingAllowed, bool isRoaming) {
1245
1246#if VDBG
1247 RLOGD("setupDataCall: serial %d", serial);
1248#endif
1249
1250 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1251 const hidl_string &protocol =
1252 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1253 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 7,
1254 std::to_string((int) radioTechnology + 2).c_str(),
1255 std::to_string((int) dataProfileInfo.profileId).c_str(),
1256 dataProfileInfo.apn.c_str(),
1257 dataProfileInfo.user.c_str(),
1258 dataProfileInfo.password.c_str(),
1259 std::to_string((int) dataProfileInfo.authType).c_str(),
1260 protocol.c_str());
1261 } else if (s_vendorFunctions->version >= 15) {
1262 char *mvnoTypeStr = NULL;
1263 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1264 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1265 RIL_REQUEST_SETUP_DATA_CALL);
1266 if (pRI != NULL) {
1267 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1268 }
1269 return Void();
1270 }
1271 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
1272 std::to_string((int) radioTechnology + 2).c_str(),
1273 std::to_string((int) dataProfileInfo.profileId).c_str(),
1274 dataProfileInfo.apn.c_str(),
1275 dataProfileInfo.user.c_str(),
1276 dataProfileInfo.password.c_str(),
1277 std::to_string((int) dataProfileInfo.authType).c_str(),
1278 dataProfileInfo.protocol.c_str(),
1279 dataProfileInfo.roamingProtocol.c_str(),
1280 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1281 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1282 modemCognitive ? "1" : "0",
1283 std::to_string(dataProfileInfo.mtu).c_str(),
1284 mvnoTypeStr,
1285 dataProfileInfo.mvnoMatchData.c_str(),
1286 roamingAllowed ? "1" : "0");
1287 } else {
1288 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1289 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1290 RIL_REQUEST_SETUP_DATA_CALL);
1291 if (pRI != NULL) {
1292 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1293 }
1294 }
1295 return Void();
1296}
1297
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001298Return<void> RadioImpl_1_5::iccIOForApp(int32_t serial, const IccIo& iccIo) {
paulye91d34712019-02-07 19:02:02 -08001299#if VDBG
1300 RLOGD("iccIOForApp: serial %d", serial);
1301#endif
1302 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1303 if (pRI == NULL) {
1304 return Void();
1305 }
1306
1307 RIL_SIM_IO_v6 rilIccIo = {};
1308 rilIccIo.command = iccIo.command;
1309 rilIccIo.fileid = iccIo.fileId;
1310 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1311 return Void();
1312 }
1313
1314 rilIccIo.p1 = iccIo.p1;
1315 rilIccIo.p2 = iccIo.p2;
1316 rilIccIo.p3 = iccIo.p3;
1317
1318 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1319 memsetAndFreeStrings(1, rilIccIo.path);
1320 return Void();
1321 }
1322
1323 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1324 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1325 return Void();
1326 }
1327
1328 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1329 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1330 return Void();
1331 }
1332
1333 CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1334
1335 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1336
1337 return Void();
1338}
1339
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001340Return<void> RadioImpl_1_5::sendUssd(int32_t serial, const hidl_string& ussd) {
paulye91d34712019-02-07 19:02:02 -08001341#if VDBG
1342 RLOGD("sendUssd: serial %d", serial);
1343#endif
1344 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1345 return Void();
1346}
1347
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001348Return<void> RadioImpl_1_5::cancelPendingUssd(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001349#if VDBG
1350 RLOGD("cancelPendingUssd: serial %d", serial);
1351#endif
1352 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1353 return Void();
1354}
1355
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001356Return<void> RadioImpl_1_5::getClir(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001357#if VDBG
1358 RLOGD("getClir: serial %d", serial);
1359#endif
1360 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1361 return Void();
1362}
1363
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001364Return<void> RadioImpl_1_5::setClir(int32_t serial, int32_t status) {
paulye91d34712019-02-07 19:02:02 -08001365#if VDBG
1366 RLOGD("setClir: serial %d", serial);
1367#endif
1368 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1369 return Void();
1370}
1371
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001372Return<void> RadioImpl_1_5::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
paulye91d34712019-02-07 19:02:02 -08001373#if VDBG
1374 RLOGD("getCallForwardStatus: serial %d", serial);
1375#endif
1376 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1377 callInfo);
1378 return Void();
1379}
1380
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001381Return<void> RadioImpl_1_5::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
paulye91d34712019-02-07 19:02:02 -08001382#if VDBG
1383 RLOGD("setCallForward: serial %d", serial);
1384#endif
1385 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1386 callInfo);
1387 return Void();
1388}
1389
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001390Return<void> RadioImpl_1_5::getCallWaiting(int32_t serial, int32_t serviceClass) {
paulye91d34712019-02-07 19:02:02 -08001391#if VDBG
1392 RLOGD("getCallWaiting: serial %d", serial);
1393#endif
1394 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1395 return Void();
1396}
1397
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001398Return<void> RadioImpl_1_5::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
paulye91d34712019-02-07 19:02:02 -08001399#if VDBG
1400 RLOGD("setCallWaiting: serial %d", serial);
1401#endif
1402 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1403 serviceClass);
1404 return Void();
1405}
1406
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001407Return<void> RadioImpl_1_5::acknowledgeLastIncomingGsmSms(int32_t serial,
paulye91d34712019-02-07 19:02:02 -08001408 bool success, SmsAcknowledgeFailCause cause) {
1409#if VDBG
1410 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1411#endif
1412 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1413 cause);
1414 return Void();
1415}
1416
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001417Return<void> RadioImpl_1_5::acceptCall(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001418#if VDBG
1419 RLOGD("acceptCall: serial %d", serial);
1420#endif
1421 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1422 return Void();
1423}
1424
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001425Return<void> RadioImpl_1_5::deactivateDataCall(int32_t serial,
paulye91d34712019-02-07 19:02:02 -08001426 int32_t cid, bool reasonRadioShutDown) {
1427#if VDBG
1428 RLOGD("deactivateDataCall: serial %d", serial);
1429#endif
1430 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, false,
1431 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1432 return Void();
1433}
1434
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001435Return<void> RadioImpl_1_5::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
paulye91d34712019-02-07 19:02:02 -08001436 const hidl_string& password, int32_t serviceClass,
1437 const hidl_string& appId) {
1438#if VDBG
1439 RLOGD("getFacilityLockForApp: serial %d", serial);
1440#endif
1441 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK, true,
1442 4, facility.c_str(), password.c_str(),
1443 (std::to_string(serviceClass)).c_str(), appId.c_str());
1444 return Void();
1445}
1446
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001447Return<void> RadioImpl_1_5::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
paulye91d34712019-02-07 19:02:02 -08001448 bool lockState, const hidl_string& password,
1449 int32_t serviceClass, const hidl_string& appId) {
1450#if VDBG
1451 RLOGD("setFacilityLockForApp: serial %d", serial);
1452#endif
1453 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK, true,
1454 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1455 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1456 return Void();
1457}
1458
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001459Return<void> RadioImpl_1_5::setBarringPassword(int32_t serial, const hidl_string& facility,
paulye91d34712019-02-07 19:02:02 -08001460 const hidl_string& oldPassword,
1461 const hidl_string& newPassword) {
1462#if VDBG
1463 RLOGD("setBarringPassword: serial %d", serial);
1464#endif
1465 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD, true,
1466 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1467 return Void();
1468}
1469
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001470Return<void> RadioImpl_1_5::getNetworkSelectionMode(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001471#if VDBG
1472 RLOGD("getNetworkSelectionMode: serial %d", serial);
1473#endif
1474 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1475 return Void();
1476}
1477
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001478Return<void> RadioImpl_1_5::setNetworkSelectionModeAutomatic(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001479#if VDBG
1480 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1481#endif
1482 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1483 return Void();
1484}
1485
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001486Return<void> RadioImpl_1_5::setNetworkSelectionModeManual(int32_t serial,
paulye91d34712019-02-07 19:02:02 -08001487 const hidl_string& operatorNumeric) {
1488#if VDBG
1489 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1490#endif
1491 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1492 operatorNumeric.c_str());
1493 return Void();
1494}
1495
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001496Return<void> RadioImpl_1_5::getAvailableNetworks(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001497#if VDBG
1498 RLOGD("getAvailableNetworks: serial %d", serial);
1499#endif
1500 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1501 return Void();
1502}
1503
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001504Return<void> RadioImpl_1_5::startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request) {
paulye91d34712019-02-07 19:02:02 -08001505#if VDBG
1506 RLOGD("startNetworkScan: serial %d", serial);
1507#endif
1508
1509 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1510 if (pRI == NULL) {
1511 return Void();
1512 }
1513
1514 if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
1515 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1516 return Void();
1517 }
1518
1519 RIL_NetworkScanRequest scan_request = {};
1520
1521 scan_request.type = (RIL_ScanType) request.type;
1522 scan_request.interval = request.interval;
1523 scan_request.specifiers_length = request.specifiers.size();
1524 for (size_t i = 0; i < request.specifiers.size(); ++i) {
1525 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
1526 request.specifiers[i].utranBands.size() > MAX_BANDS ||
1527 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
1528 request.specifiers[i].channels.size() > MAX_CHANNELS) {
1529 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1530 return Void();
1531 }
1532 const V1_1::RadioAccessSpecifier& ras_from =
1533 request.specifiers[i];
1534 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
1535
1536 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
1537 ras_to.channels_length = ras_from.channels.size();
1538
1539 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
1540 const std::vector<uint32_t> * bands = nullptr;
1541 switch (request.specifiers[i].radioAccessNetwork) {
1542 case V1_1::RadioAccessNetworks::GERAN:
1543 ras_to.bands_length = ras_from.geranBands.size();
1544 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
1545 break;
1546 case V1_1::RadioAccessNetworks::UTRAN:
1547 ras_to.bands_length = ras_from.utranBands.size();
1548 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
1549 break;
1550 case V1_1::RadioAccessNetworks::EUTRAN:
1551 ras_to.bands_length = ras_from.eutranBands.size();
1552 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
1553 break;
1554 default:
1555 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1556 return Void();
1557 }
1558 // safe to copy to geran_bands because it's a union member
1559 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
1560 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
1561 }
1562 }
1563
1564 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
1565 mSlotId);
1566
1567 return Void();
1568}
1569
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001570Return<void> RadioImpl_1_5::stopNetworkScan(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001571#if VDBG
1572 RLOGD("stopNetworkScan: serial %d", serial);
1573#endif
1574 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1575 return Void();
1576}
1577
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001578Return<void> RadioImpl_1_5::startDtmf(int32_t serial, const hidl_string& s) {
paulye91d34712019-02-07 19:02:02 -08001579#if VDBG
1580 RLOGD("startDtmf: serial %d", serial);
1581#endif
1582 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1583 s.c_str());
1584 return Void();
1585}
1586
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001587Return<void> RadioImpl_1_5::stopDtmf(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001588#if VDBG
1589 RLOGD("stopDtmf: serial %d", serial);
1590#endif
1591 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1592 return Void();
1593}
1594
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001595Return<void> RadioImpl_1_5::getBasebandVersion(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001596#if VDBG
1597 RLOGD("getBasebandVersion: serial %d", serial);
1598#endif
1599 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1600 return Void();
1601}
1602
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001603Return<void> RadioImpl_1_5::separateConnection(int32_t serial, int32_t gsmIndex) {
paulye91d34712019-02-07 19:02:02 -08001604#if VDBG
1605 RLOGD("separateConnection: serial %d", serial);
1606#endif
1607 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1608 return Void();
1609}
1610
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001611Return<void> RadioImpl_1_5::setMute(int32_t serial, bool enable) {
paulye91d34712019-02-07 19:02:02 -08001612#if VDBG
1613 RLOGD("setMute: serial %d", serial);
1614#endif
1615 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1616 return Void();
1617}
1618
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001619Return<void> RadioImpl_1_5::getMute(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001620#if VDBG
1621 RLOGD("getMute: serial %d", serial);
1622#endif
1623 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1624 return Void();
1625}
1626
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001627Return<void> RadioImpl_1_5::getClip(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001628#if VDBG
1629 RLOGD("getClip: serial %d", serial);
1630#endif
1631 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1632 return Void();
1633}
1634
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001635Return<void> RadioImpl_1_5::getDataCallList(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001636#if VDBG
1637 RLOGD("getDataCallList: serial %d", serial);
1638#endif
1639 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1640 return Void();
1641}
1642
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001643Return<void> RadioImpl_1_5::setSuppServiceNotifications(int32_t serial, bool enable) {
paulye91d34712019-02-07 19:02:02 -08001644#if VDBG
1645 RLOGD("setSuppServiceNotifications: serial %d", serial);
1646#endif
1647 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1648 BOOL_TO_INT(enable));
1649 return Void();
1650}
1651
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001652Return<void> RadioImpl_1_5::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
paulye91d34712019-02-07 19:02:02 -08001653#if VDBG
1654 RLOGD("writeSmsToSim: serial %d", serial);
1655#endif
1656 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1657 if (pRI == NULL) {
1658 return Void();
1659 }
1660
1661 RIL_SMS_WriteArgs args;
1662 args.status = (int) smsWriteArgs.status;
1663
1664 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1665 return Void();
1666 }
1667
1668 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1669 memsetAndFreeStrings(1, args.pdu);
1670 return Void();
1671 }
1672
1673 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
1674
1675 memsetAndFreeStrings(2, args.smsc, args.pdu);
1676
1677 return Void();
1678}
1679
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001680Return<void> RadioImpl_1_5::deleteSmsOnSim(int32_t serial, int32_t index) {
paulye91d34712019-02-07 19:02:02 -08001681#if VDBG
1682 RLOGD("deleteSmsOnSim: serial %d", serial);
1683#endif
1684 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1685 return Void();
1686}
1687
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001688Return<void> RadioImpl_1_5::setBandMode(int32_t serial, RadioBandMode mode) {
paulye91d34712019-02-07 19:02:02 -08001689#if VDBG
1690 RLOGD("setBandMode: serial %d", serial);
1691#endif
1692 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1693 return Void();
1694}
1695
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001696Return<void> RadioImpl_1_5::getAvailableBandModes(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001697#if VDBG
1698 RLOGD("getAvailableBandModes: serial %d", serial);
1699#endif
1700 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1701 return Void();
1702}
1703
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001704Return<void> RadioImpl_1_5::sendEnvelope(int32_t serial, const hidl_string& command) {
paulye91d34712019-02-07 19:02:02 -08001705#if VDBG
1706 RLOGD("sendEnvelope: serial %d", serial);
1707#endif
1708 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1709 command.c_str());
1710 return Void();
1711}
1712
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001713Return<void> RadioImpl_1_5::sendTerminalResponseToSim(int32_t serial,
paulye91d34712019-02-07 19:02:02 -08001714 const hidl_string& commandResponse) {
1715#if VDBG
1716 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1717#endif
1718 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1719 commandResponse.c_str());
1720 return Void();
1721}
1722
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001723Return<void> RadioImpl_1_5::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
paulye91d34712019-02-07 19:02:02 -08001724#if VDBG
1725 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1726#endif
1727 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1728 1, BOOL_TO_INT(accept));
1729 return Void();
1730}
1731
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001732Return<void> RadioImpl_1_5::explicitCallTransfer(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001733#if VDBG
1734 RLOGD("explicitCallTransfer: serial %d", serial);
1735#endif
1736 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1737 return Void();
1738}
1739
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001740Return<void> RadioImpl_1_5::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
paulye91d34712019-02-07 19:02:02 -08001741#if VDBG
1742 RLOGD("setPreferredNetworkType: serial %d", serial);
1743#endif
1744 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1745 return Void();
1746}
1747
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001748Return<void> RadioImpl_1_5::getPreferredNetworkType(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001749#if VDBG
1750 RLOGD("getPreferredNetworkType: serial %d", serial);
1751#endif
1752 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1753 return Void();
1754}
1755
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001756Return<void> RadioImpl_1_5::getNeighboringCids(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001757#if VDBG
1758 RLOGD("getNeighboringCids: serial %d", serial);
1759#endif
1760 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1761 return Void();
1762}
1763
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001764Return<void> RadioImpl_1_5::setLocationUpdates(int32_t serial, bool enable) {
paulye91d34712019-02-07 19:02:02 -08001765#if VDBG
1766 RLOGD("setLocationUpdates: serial %d", serial);
1767#endif
1768 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1769 return Void();
1770}
1771
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001772Return<void> RadioImpl_1_5::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
paulye91d34712019-02-07 19:02:02 -08001773#if VDBG
1774 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1775#endif
1776 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1777 return Void();
1778}
1779
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001780Return<void> RadioImpl_1_5::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
paulye91d34712019-02-07 19:02:02 -08001781#if VDBG
1782 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1783#endif
1784 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1785 return Void();
1786}
1787
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001788Return<void> RadioImpl_1_5::getCdmaRoamingPreference(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001789#if VDBG
1790 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1791#endif
1792 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1793 return Void();
1794}
1795
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001796Return<void> RadioImpl_1_5::setTTYMode(int32_t serial, TtyMode mode) {
paulye91d34712019-02-07 19:02:02 -08001797#if VDBG
1798 RLOGD("setTTYMode: serial %d", serial);
1799#endif
1800 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1801 return Void();
1802}
1803
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001804Return<void> RadioImpl_1_5::getTTYMode(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001805#if VDBG
1806 RLOGD("getTTYMode: serial %d", serial);
1807#endif
1808 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1809 return Void();
1810}
1811
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001812Return<void> RadioImpl_1_5::setPreferredVoicePrivacy(int32_t serial, bool enable) {
paulye91d34712019-02-07 19:02:02 -08001813#if VDBG
1814 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1815#endif
1816 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1817 1, BOOL_TO_INT(enable));
1818 return Void();
1819}
1820
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001821Return<void> RadioImpl_1_5::getPreferredVoicePrivacy(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001822#if VDBG
1823 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1824#endif
1825 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1826 return Void();
1827}
1828
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001829Return<void> RadioImpl_1_5::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
paulye91d34712019-02-07 19:02:02 -08001830#if VDBG
1831 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1832#endif
1833 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1834 featureCode.c_str());
1835 return Void();
1836}
1837
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001838Return<void> RadioImpl_1_5::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
paulye91d34712019-02-07 19:02:02 -08001839 int32_t off) {
1840#if VDBG
1841 RLOGD("sendBurstDtmf: serial %d", serial);
1842#endif
1843 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF, false,
1844 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1845 (std::to_string(off)).c_str());
1846 return Void();
1847}
1848
1849void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1850 rcsm.uTeleserviceID = sms.teleserviceId;
1851 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1852 rcsm.uServicecategory = sms.serviceCategory;
1853 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1854 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1855 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1856 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1857
1858 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1859 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1860 for (int i = 0; i < digitLimit; i++) {
1861 rcsm.sAddress.digits[i] = sms.address.digits[i];
1862 }
1863
1864 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1865 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1866
1867 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1868 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1869 for (int i = 0; i < digitLimit; i++) {
1870 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1871 }
1872
1873 rcsm.uBearerDataLen = sms.bearerData.size();
1874 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1875 for (int i = 0; i < digitLimit; i++) {
1876 rcsm.aBearerData[i] = sms.bearerData[i];
1877 }
1878}
1879
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001880Return<void> RadioImpl_1_5::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
paulye91d34712019-02-07 19:02:02 -08001881#if VDBG
1882 RLOGD("sendCdmaSms: serial %d", serial);
1883#endif
1884 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1885 if (pRI == NULL) {
1886 return Void();
1887 }
1888
1889 RIL_CDMA_SMS_Message rcsm = {};
1890 constructCdmaSms(rcsm, sms);
1891
1892 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
1893 return Void();
1894}
1895
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001896Return<void> RadioImpl_1_5::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
paulye91d34712019-02-07 19:02:02 -08001897#if VDBG
1898 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1899#endif
1900 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1901 if (pRI == NULL) {
1902 return Void();
1903 }
1904
1905 RIL_CDMA_SMS_Ack rcsa = {};
1906
1907 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1908 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1909
1910 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
1911 return Void();
1912}
1913
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001914Return<void> RadioImpl_1_5::getGsmBroadcastConfig(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001915#if VDBG
1916 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1917#endif
1918 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1919 return Void();
1920}
1921
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001922Return<void> RadioImpl_1_5::setGsmBroadcastConfig(int32_t serial,
paulye91d34712019-02-07 19:02:02 -08001923 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1924 configInfo) {
1925#if VDBG
1926 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1927#endif
1928 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1929 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1930 if (pRI == NULL) {
1931 return Void();
1932 }
1933
1934 int num = configInfo.size();
1935 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1936 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1937
1938 for (int i = 0 ; i < num ; i++ ) {
1939 gsmBciPtrs[i] = &gsmBci[i];
1940 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1941 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1942 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1943 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1944 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1945 }
1946
1947 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs,
1948 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
1949 return Void();
1950}
1951
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001952Return<void> RadioImpl_1_5::setGsmBroadcastActivation(int32_t serial, bool activate) {
paulye91d34712019-02-07 19:02:02 -08001953#if VDBG
1954 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1955#endif
1956 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1957 1, BOOL_TO_INT(!activate));
1958 return Void();
1959}
1960
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001961Return<void> RadioImpl_1_5::getCdmaBroadcastConfig(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08001962#if VDBG
1963 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1964#endif
1965 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1966 return Void();
1967}
1968
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001969Return<void> RadioImpl_1_5::setCdmaBroadcastConfig(int32_t serial,
paulye91d34712019-02-07 19:02:02 -08001970 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1971 configInfo) {
1972#if VDBG
1973 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1974#endif
1975 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1976 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1977 if (pRI == NULL) {
1978 return Void();
1979 }
1980
1981 int num = configInfo.size();
1982 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1983 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1984
1985 for (int i = 0 ; i < num ; i++ ) {
1986 cdmaBciPtrs[i] = &cdmaBci[i];
1987 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1988 cdmaBci[i].language = configInfo[i].language;
1989 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1990 }
1991
1992 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs,
1993 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
1994 return Void();
1995}
1996
Malcolm Chen6b9984e2019-10-10 14:44:58 -07001997Return<void> RadioImpl_1_5::setCdmaBroadcastActivation(int32_t serial, bool activate) {
paulye91d34712019-02-07 19:02:02 -08001998#if VDBG
1999 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
2000#endif
2001 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
2002 1, BOOL_TO_INT(!activate));
2003 return Void();
2004}
2005
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002006Return<void> RadioImpl_1_5::getCDMASubscription(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002007#if VDBG
2008 RLOGD("getCDMASubscription: serial %d", serial);
2009#endif
2010 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
2011 return Void();
2012}
2013
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002014Return<void> RadioImpl_1_5::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
paulye91d34712019-02-07 19:02:02 -08002015#if VDBG
2016 RLOGD("writeSmsToRuim: serial %d", serial);
2017#endif
2018 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2019 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
2020 if (pRI == NULL) {
2021 return Void();
2022 }
2023
2024 RIL_CDMA_SMS_WriteArgs rcsw = {};
2025 rcsw.status = (int) cdmaSms.status;
2026 constructCdmaSms(rcsw.message, cdmaSms.message);
2027
2028 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
2029 return Void();
2030}
2031
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002032Return<void> RadioImpl_1_5::deleteSmsOnRuim(int32_t serial, int32_t index) {
paulye91d34712019-02-07 19:02:02 -08002033#if VDBG
2034 RLOGD("deleteSmsOnRuim: serial %d", serial);
2035#endif
2036 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
2037 return Void();
2038}
2039
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002040Return<void> RadioImpl_1_5::getDeviceIdentity(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002041#if VDBG
2042 RLOGD("getDeviceIdentity: serial %d", serial);
2043#endif
2044 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
2045 return Void();
2046}
2047
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002048Return<void> RadioImpl_1_5::exitEmergencyCallbackMode(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002049#if VDBG
2050 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
2051#endif
2052 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
2053 return Void();
2054}
2055
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002056Return<void> RadioImpl_1_5::getSmscAddress(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002057#if VDBG
2058 RLOGD("getSmscAddress: serial %d", serial);
2059#endif
2060 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
2061 return Void();
2062}
2063
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002064Return<void> RadioImpl_1_5::setSmscAddress(int32_t serial, const hidl_string& smsc) {
paulye91d34712019-02-07 19:02:02 -08002065#if VDBG
2066 RLOGD("setSmscAddress: serial %d", serial);
2067#endif
2068 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
2069 smsc.c_str());
2070 return Void();
2071}
2072
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002073Return<void> RadioImpl_1_5::reportSmsMemoryStatus(int32_t serial, bool available) {
paulye91d34712019-02-07 19:02:02 -08002074#if VDBG
2075 RLOGD("reportSmsMemoryStatus: serial %d", serial);
2076#endif
2077 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
2078 BOOL_TO_INT(available));
2079 return Void();
2080}
2081
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002082Return<void> RadioImpl_1_5::reportStkServiceIsRunning(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002083#if VDBG
2084 RLOGD("reportStkServiceIsRunning: serial %d", serial);
2085#endif
2086 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
2087 return Void();
2088}
2089
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002090Return<void> RadioImpl_1_5::getCdmaSubscriptionSource(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002091#if VDBG
2092 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
2093#endif
2094 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
2095 return Void();
2096}
2097
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002098Return<void> RadioImpl_1_5::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
paulye91d34712019-02-07 19:02:02 -08002099#if VDBG
2100 RLOGD("requestIsimAuthentication: serial %d", serial);
2101#endif
2102 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
2103 challenge.c_str());
2104 return Void();
2105}
2106
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002107Return<void> RadioImpl_1_5::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
paulye91d34712019-02-07 19:02:02 -08002108 const hidl_string& ackPdu) {
2109#if VDBG
2110 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
2111#endif
2112 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, false,
2113 2, success ? "1" : "0", ackPdu.c_str());
2114 return Void();
2115}
2116
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002117Return<void> RadioImpl_1_5::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
paulye91d34712019-02-07 19:02:02 -08002118#if VDBG
2119 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
2120#endif
2121 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
2122 contents.c_str());
2123 return Void();
2124}
2125
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002126Return<void> RadioImpl_1_5::getVoiceRadioTechnology(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002127#if VDBG
2128 RLOGD("getVoiceRadioTechnology: serial %d", serial);
2129#endif
2130 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
2131 return Void();
2132}
2133
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002134Return<void> RadioImpl_1_5::getCellInfoList(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002135#if VDBG
2136 RLOGD("getCellInfoList: serial %d", serial);
2137#endif
2138 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
2139 return Void();
2140}
2141
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002142Return<void> RadioImpl_1_5::setCellInfoListRate(int32_t serial, int32_t rate) {
paulye91d34712019-02-07 19:02:02 -08002143#if VDBG
2144 RLOGD("setCellInfoListRate: serial %d", serial);
2145#endif
2146 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
2147 return Void();
2148}
2149
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002150Return<void> RadioImpl_1_5::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
paulye91d34712019-02-07 19:02:02 -08002151 bool modemCognitive, bool isRoaming) {
2152#if VDBG
2153 RLOGD("setInitialAttachApn: serial %d", serial);
2154#endif
2155 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2156 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
2157 if (pRI == NULL) {
2158 return Void();
2159 }
2160
2161 if (s_vendorFunctions->version <= 14) {
2162 RIL_InitialAttachApn iaa = {};
2163
2164 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2165 return Void();
2166 }
2167
2168 const hidl_string &protocol =
2169 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
2170
2171 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
2172 memsetAndFreeStrings(1, iaa.apn);
2173 return Void();
2174 }
2175 iaa.authtype = (int) dataProfileInfo.authType;
2176 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2177 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2178 return Void();
2179 }
2180 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2181 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
2182 return Void();
2183 }
2184
2185 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2186
2187 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
2188 } else {
2189 RIL_InitialAttachApn_v15 iaa = {};
2190
2191 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2192 return Void();
2193 }
2194
2195 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
2196 memsetAndFreeStrings(1, iaa.apn);
2197 return Void();
2198 }
2199 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
2200 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2201 return Void();
2202 }
2203 iaa.authtype = (int) dataProfileInfo.authType;
2204 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2205 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
2206 return Void();
2207 }
2208 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2209 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
2210 return Void();
2211 }
2212 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
2213 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
2214 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
2215 iaa.mtu = dataProfileInfo.mtu;
2216
2217 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
2218 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2219 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2220 iaa.password);
2221 return Void();
2222 }
2223
2224 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
2225 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2226 iaa.password);
2227 return Void();
2228 }
2229
2230 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2231
2232 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2233 iaa.password, iaa.mvnoMatchData);
2234 }
2235
2236 return Void();
2237}
2238
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002239Return<void> RadioImpl_1_5::getImsRegistrationState(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002240#if VDBG
2241 RLOGD("getImsRegistrationState: serial %d", serial);
2242#endif
2243 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2244 return Void();
2245}
2246
2247bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2248 RIL_IMS_SMS_Message rism = {};
2249 char **pStrings;
2250 int countStrings = 2;
2251 int dataLen = sizeof(char *) * countStrings;
2252
2253 rism.tech = RADIO_TECH_3GPP;
2254 rism.retry = BOOL_TO_INT(message.retry);
2255 rism.messageRef = message.messageRef;
2256
2257 if (message.gsmMessage.size() != 1) {
2258 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2259 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2260 return false;
2261 }
2262
2263 pStrings = (char **)calloc(countStrings, sizeof(char *));
2264 if (pStrings == NULL) {
2265 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2266 requestToString(pRI->pCI->requestNumber));
2267 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2268 return false;
2269 }
2270
2271 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2272#ifdef MEMSET_FREED
2273 memset(pStrings, 0, dataLen);
2274#endif
2275 free(pStrings);
2276 return false;
2277 }
2278
2279 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2280 memsetAndFreeStrings(1, pStrings[0]);
2281#ifdef MEMSET_FREED
2282 memset(pStrings, 0, dataLen);
2283#endif
2284 free(pStrings);
2285 return false;
2286 }
2287
2288 rism.message.gsmMessage = pStrings;
2289 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2290 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2291
2292 for (int i = 0 ; i < countStrings ; i++) {
2293 memsetAndFreeStrings(1, pStrings[i]);
2294 }
2295
2296#ifdef MEMSET_FREED
2297 memset(pStrings, 0, dataLen);
2298#endif
2299 free(pStrings);
2300
2301 return true;
2302}
2303
2304struct ImsCdmaSms {
2305 RIL_IMS_SMS_Message imsSms;
2306 RIL_CDMA_SMS_Message cdmaSms;
2307};
2308
2309bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2310 ImsCdmaSms temp = {};
2311
2312 if (message.cdmaMessage.size() != 1) {
2313 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2314 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2315 return false;
2316 }
2317
2318 temp.imsSms.tech = RADIO_TECH_3GPP2;
2319 temp.imsSms.retry = BOOL_TO_INT(message.retry);
2320 temp.imsSms.messageRef = message.messageRef;
2321 temp.imsSms.message.cdmaMessage = &temp.cdmaSms;
2322
2323 constructCdmaSms(temp.cdmaSms, message.cdmaMessage[0]);
2324
2325 // Vendor code expects payload length to include actual msg payload
2326 // (sizeof(RIL_CDMA_SMS_Message)) instead of (RIL_CDMA_SMS_Message *) + size of other fields in
2327 // RIL_IMS_SMS_Message
2328 int payloadLen = sizeof(RIL_RadioTechnologyFamily) + sizeof(uint8_t) + sizeof(int32_t)
2329 + sizeof(RIL_CDMA_SMS_Message);
2330
2331 CALL_ONREQUEST(pRI->pCI->requestNumber, &temp.imsSms, payloadLen, pRI, pRI->socket_id);
2332
2333 return true;
2334}
2335
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002336Return<void> RadioImpl_1_5::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
paulye91d34712019-02-07 19:02:02 -08002337#if VDBG
2338 RLOGD("sendImsSms: serial %d", serial);
2339#endif
2340 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2341 if (pRI == NULL) {
2342 return Void();
2343 }
2344
2345 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2346
2347 if (RADIO_TECH_3GPP == format) {
2348 dispatchImsGsmSms(message, pRI);
2349 } else if (RADIO_TECH_3GPP2 == format) {
2350 dispatchImsCdmaSms(message, pRI);
2351 } else {
2352 RLOGE("sendImsSms: Invalid radio tech %s",
2353 requestToString(pRI->pCI->requestNumber));
2354 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2355 }
2356 return Void();
2357}
2358
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002359Return<void> RadioImpl_1_5::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
paulye91d34712019-02-07 19:02:02 -08002360#if VDBG
2361 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2362#endif
2363 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2364 return Void();
2365}
2366
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002367Return<void> RadioImpl_1_5::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
paulye91d34712019-02-07 19:02:02 -08002368#if VDBG
2369 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2370#endif
2371 if (s_vendorFunctions->version < 15) {
2372 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2373 } else {
2374 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2375 if (pRI == NULL) {
2376 return Void();
2377 }
2378
2379 RIL_OpenChannelParams params = {};
2380
2381 params.p2 = p2;
2382
2383 if (!copyHidlStringToRil(&params.aidPtr, aid, pRI)) {
2384 return Void();
2385 }
2386
2387 CALL_ONREQUEST(pRI->pCI->requestNumber, &params, sizeof(params), pRI, mSlotId);
2388
2389 memsetAndFreeStrings(1, params.aidPtr);
2390 }
2391 return Void();
2392}
2393
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002394Return<void> RadioImpl_1_5::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
paulye91d34712019-02-07 19:02:02 -08002395#if VDBG
2396 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2397#endif
2398 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2399 return Void();
2400}
2401
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002402Return<void> RadioImpl_1_5::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
paulye91d34712019-02-07 19:02:02 -08002403#if VDBG
2404 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2405#endif
2406 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2407 return Void();
2408}
2409
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002410Return<void> RadioImpl_1_5::nvReadItem(int32_t serial, NvItem itemId) {
paulye91d34712019-02-07 19:02:02 -08002411#if VDBG
2412 RLOGD("nvReadItem: serial %d", serial);
2413#endif
2414 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2415 if (pRI == NULL) {
2416 return Void();
2417 }
2418
2419 RIL_NV_ReadItem nvri = {};
2420 nvri.itemID = (RIL_NV_Item) itemId;
2421
2422 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2423 return Void();
2424}
2425
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002426Return<void> RadioImpl_1_5::nvWriteItem(int32_t serial, const NvWriteItem& item) {
paulye91d34712019-02-07 19:02:02 -08002427#if VDBG
2428 RLOGD("nvWriteItem: serial %d", serial);
2429#endif
2430 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2431 if (pRI == NULL) {
2432 return Void();
2433 }
2434
2435 RIL_NV_WriteItem nvwi = {};
2436
2437 nvwi.itemID = (RIL_NV_Item) item.itemId;
2438
2439 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2440 return Void();
2441 }
2442
2443 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2444
2445 memsetAndFreeStrings(1, nvwi.value);
2446 return Void();
2447}
2448
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002449Return<void> RadioImpl_1_5::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
paulye91d34712019-02-07 19:02:02 -08002450#if VDBG
2451 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2452#endif
2453 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2454 return Void();
2455}
2456
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002457Return<void> RadioImpl_1_5::nvResetConfig(int32_t serial, ResetNvType resetType) {
paulye91d34712019-02-07 19:02:02 -08002458 int rilResetType = -1;
2459#if VDBG
2460 RLOGD("nvResetConfig: serial %d", serial);
2461#endif
2462 /* Convert ResetNvType to RIL.h values
2463 * RIL_REQUEST_NV_RESET_CONFIG
2464 * 1 - reload all NV items
2465 * 2 - erase NV reset (SCRTN)
2466 * 3 - factory reset (RTN)
2467 */
2468 switch(resetType) {
2469 case ResetNvType::RELOAD:
2470 rilResetType = 1;
2471 break;
2472 case ResetNvType::ERASE:
2473 rilResetType = 2;
2474 break;
2475 case ResetNvType::FACTORY_RESET:
2476 rilResetType = 3;
2477 break;
2478 }
2479 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2480 return Void();
2481}
2482
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002483Return<void> RadioImpl_1_5::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
paulye91d34712019-02-07 19:02:02 -08002484#if VDBG
2485 RLOGD("setUiccSubscription: serial %d", serial);
2486#endif
2487 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2488 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2489 if (pRI == NULL) {
2490 return Void();
2491 }
2492
2493 RIL_SelectUiccSub rilUiccSub = {};
2494
2495 rilUiccSub.slot = uiccSub.slot;
2496 rilUiccSub.app_index = uiccSub.appIndex;
2497 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2498 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2499
2500 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2501 return Void();
2502}
2503
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002504Return<void> RadioImpl_1_5::setDataAllowed(int32_t serial, bool allow) {
paulye91d34712019-02-07 19:02:02 -08002505#if VDBG
2506 RLOGD("setDataAllowed: serial %d", serial);
2507#endif
2508 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2509 return Void();
2510}
2511
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002512Return<void> RadioImpl_1_5::getHardwareConfig(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002513#if VDBG
2514 RLOGD("getHardwareConfig: serial %d", serial);
2515#endif
2516 RLOGD("getHardwareConfig: serial %d, mSlotId = %d", serial, mSlotId);
2517 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2518 return Void();
2519}
2520
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002521Return<void> RadioImpl_1_5::requestIccSimAuthentication(int32_t serial, int32_t authContext,
paulye91d34712019-02-07 19:02:02 -08002522 const hidl_string& authData, const hidl_string& aid) {
2523#if VDBG
2524 RLOGD("requestIccSimAuthentication: serial %d", serial);
2525#endif
2526 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2527 if (pRI == NULL) {
2528 return Void();
2529 }
2530
2531 RIL_SimAuthentication pf = {};
2532
2533 pf.authContext = authContext;
2534
2535 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2536 return Void();
2537 }
2538
2539 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2540 memsetAndFreeStrings(1, pf.authData);
2541 return Void();
2542 }
2543
2544 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2545
2546 memsetAndFreeStrings(2, pf.authData, pf.aid);
2547 return Void();
2548}
2549
2550/**
2551 * @param numProfiles number of data profile
2552 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2553 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2554 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2555 * @param numfields number of string-type member in the data profile structure
2556 * @param ... the variadic parameters are pointers to each string-type member
2557 **/
2558template <typename T>
2559void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2560 int numfields, ...) {
2561 va_list args;
2562 va_start(args, numfields);
2563
2564 // Iterate through each string-type field that need to be free.
2565 for (int i = 0; i < numfields; i++) {
2566 // Iterate through each data profile and free that specific string-type field.
2567 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2568 char *T::*ptr = va_arg(args, char *T::*);
2569 for (int j = 0; j < numProfiles; j++) {
2570 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2571 }
2572 }
2573
2574 va_end(args);
2575
2576#ifdef MEMSET_FREED
2577 memset(dataProfiles, 0, numProfiles * sizeof(T));
2578 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2579#endif
2580 free(dataProfiles);
2581 free(dataProfilePtrs);
2582}
2583
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002584Return<void> RadioImpl_1_5::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
paulye91d34712019-02-07 19:02:02 -08002585 bool isRoaming) {
2586#if VDBG
2587 RLOGD("setDataProfile: serial %d", serial);
2588#endif
2589 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2590 if (pRI == NULL) {
2591 return Void();
2592 }
2593
2594 size_t num = profiles.size();
2595 bool success = false;
2596
2597 if (s_vendorFunctions->version <= 14) {
2598
2599 RIL_DataProfileInfo *dataProfiles =
2600 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2601
2602 if (dataProfiles == NULL) {
2603 RLOGE("Memory allocation failed for request %s",
2604 requestToString(pRI->pCI->requestNumber));
2605 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2606 return Void();
2607 }
2608
2609 RIL_DataProfileInfo **dataProfilePtrs =
2610 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2611 if (dataProfilePtrs == NULL) {
2612 RLOGE("Memory allocation failed for request %s",
2613 requestToString(pRI->pCI->requestNumber));
2614 free(dataProfiles);
2615 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2616 return Void();
2617 }
2618
2619 for (size_t i = 0; i < num; i++) {
2620 dataProfilePtrs[i] = &dataProfiles[i];
2621
2622 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2623
2624 const hidl_string &protocol =
2625 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2626
2627 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI, true)) {
2628 success = false;
2629 }
2630
2631 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2632 true)) {
2633 success = false;
2634 }
2635 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2636 pRI, true)) {
2637 success = false;
2638 }
2639
2640 if (!success) {
2641 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2642 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2643 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2644 return Void();
2645 }
2646
2647 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2648 dataProfiles[i].authType = (int) profiles[i].authType;
2649 dataProfiles[i].type = (int) profiles[i].type;
2650 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2651 dataProfiles[i].maxConns = profiles[i].maxConns;
2652 dataProfiles[i].waitTime = profiles[i].waitTime;
2653 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2654 }
2655
2656 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2657 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2658
2659 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2660 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2661 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2662 } else {
2663 RIL_DataProfileInfo_v15 *dataProfiles =
2664 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2665
2666 if (dataProfiles == NULL) {
2667 RLOGE("Memory allocation failed for request %s",
2668 requestToString(pRI->pCI->requestNumber));
2669 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2670 return Void();
2671 }
2672
2673 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2674 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2675 if (dataProfilePtrs == NULL) {
2676 RLOGE("Memory allocation failed for request %s",
2677 requestToString(pRI->pCI->requestNumber));
2678 free(dataProfiles);
2679 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2680 return Void();
2681 }
2682
2683 for (size_t i = 0; i < num; i++) {
2684 dataProfilePtrs[i] = &dataProfiles[i];
2685
2686 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2687 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2688 pRI)) {
2689 success = false;
2690 }
2691 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2692 profiles[i].roamingProtocol, pRI, true)) {
2693 success = false;
2694 }
2695 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2696 true)) {
2697 success = false;
2698 }
2699 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2700 pRI, true)) {
2701 success = false;
2702 }
2703 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2704 profiles[i].mvnoMatchData, pRI, true)) {
2705 success = false;
2706 }
2707
2708 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2709 dataProfiles[i].mvnoType)) {
2710 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2711 success = false;
2712 }
2713
2714 if (!success) {
2715 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2716 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2717 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2718 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2719 return Void();
2720 }
2721
2722 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2723 dataProfiles[i].authType = (int) profiles[i].authType;
2724 dataProfiles[i].type = (int) profiles[i].type;
2725 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2726 dataProfiles[i].maxConns = profiles[i].maxConns;
2727 dataProfiles[i].waitTime = profiles[i].waitTime;
2728 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2729 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2730 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2731 dataProfiles[i].mtu = profiles[i].mtu;
2732 }
2733
2734 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2735 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
2736
2737 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2738 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2739 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2740 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2741 }
2742
2743 return Void();
2744}
2745
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002746Return<void> RadioImpl_1_5::requestShutdown(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002747#if VDBG
2748 RLOGD("requestShutdown: serial %d", serial);
2749#endif
2750 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2751 return Void();
2752}
2753
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002754Return<void> RadioImpl_1_5::getRadioCapability(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002755#if VDBG
2756 RLOGD("getRadioCapability: serial %d", serial);
2757#endif
2758 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2759 return Void();
2760}
2761
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002762Return<void> RadioImpl_1_5::setRadioCapability(int32_t serial, const RadioCapability& rc) {
paulye91d34712019-02-07 19:02:02 -08002763#if VDBG
2764 RLOGD("setRadioCapability: serial %d", serial);
2765#endif
2766 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2767 if (pRI == NULL) {
2768 return Void();
2769 }
2770
2771 RIL_RadioCapability rilRc = {};
2772
2773 // TODO : set rilRc.version using HIDL version ?
2774 rilRc.session = rc.session;
2775 rilRc.phase = (int) rc.phase;
2776 rilRc.rat = (int) rc.raf;
2777 rilRc.status = (int) rc.status;
2778 strlcpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), sizeof(rilRc.logicalModemUuid));
2779
2780 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
2781
2782 return Void();
2783}
2784
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002785Return<void> RadioImpl_1_5::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
paulye91d34712019-02-07 19:02:02 -08002786#if VDBG
2787 RLOGD("startLceService: serial %d", serial);
2788#endif
2789 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2790 BOOL_TO_INT(pullMode));
2791 return Void();
2792}
2793
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002794Return<void> RadioImpl_1_5::stopLceService(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002795#if VDBG
2796 RLOGD("stopLceService: serial %d", serial);
2797#endif
2798 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2799 return Void();
2800}
2801
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002802Return<void> RadioImpl_1_5::pullLceData(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002803#if VDBG
2804 RLOGD("pullLceData: serial %d", serial);
2805#endif
2806 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2807 return Void();
2808}
2809
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002810Return<void> RadioImpl_1_5::getModemActivityInfo(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002811#if VDBG
2812 RLOGD("getModemActivityInfo: serial %d", serial);
2813#endif
2814 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2815 return Void();
2816}
2817
Michelee218c362019-02-27 22:48:48 -08002818int prepareCarrierRestrictions(RIL_CarrierRestrictions &request, bool allAllowed,
2819 const hidl_vec<Carrier>& allowedList,
2820 const hidl_vec<Carrier>& excludedList,
2821 RequestInfo *pRI) {
2822 RIL_Carrier *allowedCarriers = NULL;
2823 RIL_Carrier *excludedCarriers = NULL;
2824
2825 request.len_allowed_carriers = allowedList.size();
2826 allowedCarriers = (RIL_Carrier *)calloc(request.len_allowed_carriers, sizeof(RIL_Carrier));
2827 if (allowedCarriers == NULL) {
2828 RLOGE("prepareCarrierRestrictions: Memory allocation failed for request %s",
2829 requestToString(pRI->pCI->requestNumber));
2830 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2831 return -1;
2832 }
2833 request.allowed_carriers = allowedCarriers;
2834
2835 request.len_excluded_carriers = excludedList.size();
2836 excludedCarriers = (RIL_Carrier *)calloc(request.len_excluded_carriers, sizeof(RIL_Carrier));
2837 if (excludedCarriers == NULL) {
2838 RLOGE("prepareCarrierRestrictions: Memory allocation failed for request %s",
2839 requestToString(pRI->pCI->requestNumber));
2840 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2841#ifdef MEMSET_FREED
2842 memset(allowedCarriers, 0, request.len_allowed_carriers * sizeof(RIL_Carrier));
2843#endif
2844 free(allowedCarriers);
2845 return -1;
2846 }
2847 request.excluded_carriers = excludedCarriers;
2848
2849 for (int i = 0; i < request.len_allowed_carriers; i++) {
2850 allowedCarriers[i].mcc = allowedList[i].mcc.c_str();
2851 allowedCarriers[i].mnc = allowedList[i].mnc.c_str();
2852 allowedCarriers[i].match_type = (RIL_CarrierMatchType) allowedList[i].matchType;
2853 allowedCarriers[i].match_data = allowedList[i].matchData.c_str();
2854 }
2855
2856 for (int i = 0; i < request.len_excluded_carriers; i++) {
2857 excludedCarriers[i].mcc = excludedList[i].mcc.c_str();
2858 excludedCarriers[i].mnc = excludedList[i].mnc.c_str();
2859 excludedCarriers[i].match_type =
2860 (RIL_CarrierMatchType) excludedList[i].matchType;
2861 excludedCarriers[i].match_data = excludedList[i].matchData.c_str();
2862 }
2863
2864 return 0;
2865}
2866
2867void freeCarrierRestrictions(RIL_CarrierRestrictions &request) {
2868 if (request.allowed_carriers != NULL) {
2869#ifdef MEMSET_FREED
2870 memset(request.allowed_carriers, 0, request.len_allowed_carriers * sizeof(RIL_Carrier));
2871#endif
2872 free(request.allowed_carriers);
2873 }
2874 if (request.excluded_carriers != NULL) {
2875#ifdef MEMSET_FREED
2876 memset(request.excluded_carriers, 0, request.len_excluded_carriers * sizeof(RIL_Carrier));
2877#endif
2878 free(request.excluded_carriers);
2879 }
2880}
2881
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002882Return<void> RadioImpl_1_5::setAllowedCarriers(int32_t serial, bool allAllowed,
paulye91d34712019-02-07 19:02:02 -08002883 const CarrierRestrictions& carriers) {
2884#if VDBG
2885 RLOGD("setAllowedCarriers: serial %d", serial);
2886#endif
2887 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2888 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2889 if (pRI == NULL) {
2890 return Void();
2891 }
2892
2893 RIL_CarrierRestrictions cr = {};
Michelee218c362019-02-27 22:48:48 -08002894 if (prepareCarrierRestrictions(cr, allAllowed, carriers.allowedCarriers,
2895 carriers.excludedCarriers, pRI) < 0) {
paulye91d34712019-02-07 19:02:02 -08002896 return Void();
2897 }
paulye91d34712019-02-07 19:02:02 -08002898
2899 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
2900
Michelee218c362019-02-27 22:48:48 -08002901 freeCarrierRestrictions(cr);
2902
2903 return Void();
2904}
2905
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002906Return<void> RadioImpl_1_5::getAllowedCarriers(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08002907#if VDBG
2908 RLOGD("getAllowedCarriers: serial %d", serial);
2909#endif
2910 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2911 return Void();
2912}
2913
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002914Return<void> RadioImpl_1_5::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
paulye91d34712019-02-07 19:02:02 -08002915 bool state) {
2916#if VDBG
2917 RLOGD("sendDeviceState: serial %d", serial);
2918#endif
2919 if (s_vendorFunctions->version < 15) {
2920 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2921 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2922 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2923 } else {
2924 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2925 RIL_REQUEST_SEND_DEVICE_STATE);
2926 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2927 }
2928 return Void();
2929 }
2930 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2931 BOOL_TO_INT(state));
2932 return Void();
2933}
2934
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002935Return<void> RadioImpl_1_5::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
paulye91d34712019-02-07 19:02:02 -08002936#if VDBG
2937 RLOGD("setIndicationFilter: serial %d", serial);
2938#endif
2939 if (s_vendorFunctions->version < 15) {
2940 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2941 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2942 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2943 return Void();
2944 }
2945 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2946 return Void();
2947}
2948
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002949Return<void> RadioImpl_1_5::setSimCardPower(int32_t serial, bool powerUp) {
paulye91d34712019-02-07 19:02:02 -08002950#if VDBG
2951 RLOGD("setSimCardPower: serial %d", serial);
2952#endif
2953 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2954 return Void();
2955}
2956
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002957Return<void> RadioImpl_1_5::setSimCardPower_1_1(int32_t serial, const V1_1::CardPowerState state) {
paulye91d34712019-02-07 19:02:02 -08002958#if VDBG
2959 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
2960#endif
2961 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
2962 return Void();
2963}
2964
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002965Return<void> RadioImpl_1_5::setCarrierInfoForImsiEncryption(int32_t serial,
paulye91d34712019-02-07 19:02:02 -08002966 const V1_1::ImsiEncryptionInfo& data) {
2967#if VDBG
2968 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
2969#endif
2970 RequestInfo *pRI = android::addRequestToList(
2971 serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
2972 if (pRI == NULL) {
2973 return Void();
2974 }
2975
2976 RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
2977
2978 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
2979 return Void();
2980 }
2981 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
2982 memsetAndFreeStrings(1, imsiEncryption.mnc);
2983 return Void();
2984 }
2985 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
2986 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
2987 return Void();
2988 }
2989 imsiEncryption.carrierKeyLength = data.carrierKey.size();
2990 imsiEncryption.carrierKey = new uint8_t[imsiEncryption.carrierKeyLength];
2991 memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), imsiEncryption.carrierKeyLength);
2992 imsiEncryption.expirationTime = data.expirationTime;
2993 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
2994 sizeof(RIL_CarrierInfoForImsiEncryption), pRI, mSlotId);
2995 delete(imsiEncryption.carrierKey);
2996 return Void();
2997}
2998
Malcolm Chen6b9984e2019-10-10 14:44:58 -07002999Return<void> RadioImpl_1_5::startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive) {
paulye91d34712019-02-07 19:02:02 -08003000#if VDBG
3001 RLOGD("%s(): %d", __FUNCTION__, serial);
3002#endif
3003 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_KEEPALIVE);
3004 if (pRI == NULL) {
3005 return Void();
3006 }
3007
3008 RIL_KeepaliveRequest kaReq = {};
3009
3010 kaReq.type = static_cast<RIL_KeepaliveType>(keepalive.type);
3011 switch(kaReq.type) {
3012 case NATT_IPV4:
3013 if (keepalive.sourceAddress.size() != 4 ||
3014 keepalive.destinationAddress.size() != 4) {
3015 RLOGE("Invalid address for keepalive!");
3016 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3017 return Void();
3018 }
3019 break;
3020 case NATT_IPV6:
3021 if (keepalive.sourceAddress.size() != 16 ||
3022 keepalive.destinationAddress.size() != 16) {
3023 RLOGE("Invalid address for keepalive!");
3024 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3025 return Void();
3026 }
3027 break;
3028 default:
3029 RLOGE("Unknown packet keepalive type!");
3030 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3031 return Void();
3032 }
3033
3034 ::memcpy(kaReq.sourceAddress, keepalive.sourceAddress.data(), keepalive.sourceAddress.size());
3035 kaReq.sourcePort = keepalive.sourcePort;
3036
3037 ::memcpy(kaReq.destinationAddress,
3038 keepalive.destinationAddress.data(), keepalive.destinationAddress.size());
3039 kaReq.destinationPort = keepalive.destinationPort;
3040
3041 kaReq.maxKeepaliveIntervalMillis = keepalive.maxKeepaliveIntervalMillis;
3042 kaReq.cid = keepalive.cid; // This is the context ID of the data call
3043
3044 CALL_ONREQUEST(pRI->pCI->requestNumber, &kaReq, sizeof(RIL_KeepaliveRequest), pRI, mSlotId);
3045 return Void();
3046}
3047
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003048Return<void> RadioImpl_1_5::stopKeepalive(int32_t serial, int32_t sessionHandle) {
paulye91d34712019-02-07 19:02:02 -08003049#if VDBG
3050 RLOGD("%s(): %d", __FUNCTION__, serial);
3051#endif
3052 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_STOP_KEEPALIVE);
3053 if (pRI == NULL) {
3054 return Void();
3055 }
3056
3057 CALL_ONREQUEST(pRI->pCI->requestNumber, &sessionHandle, sizeof(uint32_t), pRI, mSlotId);
3058 return Void();
3059}
3060
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003061Return<void> RadioImpl_1_5::responseAcknowledgement() {
paulye91d34712019-02-07 19:02:02 -08003062 android::releaseWakeLock();
3063 return Void();
3064}
3065
Sarah Chinef7f9222020-01-30 10:37:08 -08003066// Methods from ::android::hardware::radio::V1_2::IRadio follow.
paulye91d34712019-02-07 19:02:02 -08003067int prepareNetworkScanRequest_1_2(RIL_NetworkScanRequest &scan_request,
3068 const ::android::hardware::radio::V1_2::NetworkScanRequest& request,
3069 RequestInfo *pRI) {
3070
paulyef2dd42e2019-02-19 20:28:19 -08003071 scan_request.type = (RIL_ScanType) request.type;
3072 scan_request.interval = request.interval;
3073 scan_request.specifiers_length = request.specifiers.size();
3074
3075 int intervalLow = static_cast<int>(::android::hardware::radio::V1_2::ScanIntervalRange::MIN);
3076 int intervalHigh = static_cast<int>(::android::hardware::radio::V1_2::ScanIntervalRange::MAX);
3077 int maxSearchTimeLow =
3078 static_cast<int>(::android::hardware::radio::V1_2::MaxSearchTimeRange::MIN);
3079 int maxSearchTimeHigh =
3080 static_cast<int>(::android::hardware::radio::V1_2::MaxSearchTimeRange::MAX);
3081 int incrementalResultsPeriodicityRangeLow =
3082 static_cast<int>(::android::hardware::radio::V1_2::IncrementalResultsPeriodicityRange::MIN);
3083 int incrementalResultsPeriodicityRangeHigh =
3084 static_cast<int>(::android::hardware::radio::V1_2::IncrementalResultsPeriodicityRange::MAX);
3085 uint maxSpecifierSize =
3086 static_cast<uint>(::android::hardware::radio::V1_2::RadioConst
3087 ::RADIO_ACCESS_SPECIFIER_MAX_SIZE);
3088
3089 if (request.interval < intervalLow || request.interval > intervalHigh) {
3090 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3091 return -1;
3092 }
3093 // If defined, must fall in correct range.
3094 if (request.maxSearchTime != 0
3095 && (request.maxSearchTime < maxSearchTimeLow
3096 || request.maxSearchTime > maxSearchTimeHigh)) {
3097 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3098 return -1;
3099 }
3100 if (request.maxSearchTime != 0
3101 && (request.incrementalResultsPeriodicity < incrementalResultsPeriodicityRangeLow
3102 || request.incrementalResultsPeriodicity > incrementalResultsPeriodicityRangeHigh
3103 || request.incrementalResultsPeriodicity > request.maxSearchTime)) {
3104 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3105 return -1;
3106 }
3107 if (request.specifiers.size() == 0 || request.specifiers.size() > maxSpecifierSize) {
paulye91d34712019-02-07 19:02:02 -08003108 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3109 return -1;
3110 }
3111
paulye91d34712019-02-07 19:02:02 -08003112 for (size_t i = 0; i < request.specifiers.size(); ++i) {
3113 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
3114 request.specifiers[i].utranBands.size() > MAX_BANDS ||
3115 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
3116 request.specifiers[i].channels.size() > MAX_CHANNELS) {
3117 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3118 return -1;
3119 }
3120 const V1_1::RadioAccessSpecifier& ras_from =
3121 request.specifiers[i];
3122 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
3123
3124 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
3125 ras_to.channels_length = ras_from.channels.size();
3126
3127 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
3128 const std::vector<uint32_t> * bands = nullptr;
3129 switch (request.specifiers[i].radioAccessNetwork) {
3130 case V1_1::RadioAccessNetworks::GERAN:
3131 ras_to.bands_length = ras_from.geranBands.size();
3132 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
3133 break;
3134 case V1_1::RadioAccessNetworks::UTRAN:
3135 ras_to.bands_length = ras_from.utranBands.size();
3136 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
3137 break;
3138 case V1_1::RadioAccessNetworks::EUTRAN:
3139 ras_to.bands_length = ras_from.eutranBands.size();
3140 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
3141 break;
3142 default:
3143 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3144 return -1;
3145 }
3146 // safe to copy to geran_bands because it's a union member
3147 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
3148 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
3149 }
3150 }
3151
3152 return 0;
3153}
3154
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003155Return<void> RadioImpl_1_5::startNetworkScan_1_2(int32_t serial,
paulye91d34712019-02-07 19:02:02 -08003156 const ::android::hardware::radio::V1_2::NetworkScanRequest& request) {
3157#if VDBG
3158 RLOGD("startNetworkScan_1_2: serial %d", serial);
3159#endif
3160
3161 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
3162 if (pRI == NULL) {
3163 return Void();
3164 }
3165
paulye91d34712019-02-07 19:02:02 -08003166 RIL_NetworkScanRequest scan_request = {};
3167
3168 if (prepareNetworkScanRequest_1_2(scan_request, request, pRI) < 0) {
3169 return Void();
3170 }
3171
3172 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
3173 mSlotId);
3174
3175 return Void();
3176}
3177
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003178Return<void> RadioImpl_1_5::setIndicationFilter_1_2(int32_t /* serial */,
paulye91d34712019-02-07 19:02:02 -08003179 hidl_bitfield<::android::hardware::radio::V1_2::IndicationFilter> /* indicationFilter */) {
3180 // TODO implement
3181#if VDBG
3182 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3183#endif
3184 return Void();
3185}
3186
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003187Return<void> RadioImpl_1_5::setSignalStrengthReportingCriteria(int32_t /* serial */,
paulye91d34712019-02-07 19:02:02 -08003188 int32_t /* hysteresisMs */, int32_t /* hysteresisDb */,
3189 const hidl_vec<int32_t>& /* thresholdsDbm */,
3190 ::android::hardware::radio::V1_2::AccessNetwork /* accessNetwork */) {
3191 // TODO implement
3192#if VDBG
3193 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3194#endif
3195 return Void();
3196}
3197
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003198Return<void> RadioImpl_1_5::setLinkCapacityReportingCriteria(int32_t /* serial */,
paulye91d34712019-02-07 19:02:02 -08003199 int32_t /* hysteresisMs */, int32_t /* hysteresisDlKbps */, int32_t /* hysteresisUlKbps */,
3200 const hidl_vec<int32_t>& /* thresholdsDownlinkKbps */,
3201 const hidl_vec<int32_t>& /* thresholdsUplinkKbps */,
3202 ::android::hardware::radio::V1_2::AccessNetwork /* accessNetwork */) {
3203 // TODO implement
3204#if VDBG
3205 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3206#endif
3207 return Void();
3208}
3209
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003210Return<void> RadioImpl_1_5::setupDataCall_1_2(int32_t /* serial */,
paulye91d34712019-02-07 19:02:02 -08003211 ::android::hardware::radio::V1_2::AccessNetwork /* accessNetwork */,
3212 const ::android::hardware::radio::V1_0::DataProfileInfo& /* dataProfileInfo */,
3213 bool /* modemCognitive */, bool /* roamingAllowed */, bool /* isRoaming */,
3214 ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
3215 const hidl_vec<hidl_string>& /* addresses */, const hidl_vec<hidl_string>& /* dnses */) {
3216 // TODO implement
3217#if VDBG
3218 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3219#endif
3220 return Void();
3221}
3222
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003223Return<void> RadioImpl_1_5::deactivateDataCall_1_2(int32_t /* serial */, int32_t /* cid */,
paulye91d34712019-02-07 19:02:02 -08003224 ::android::hardware::radio::V1_2::DataRequestReason /* reason */) {
3225 // TODO implement
3226#if VDBG
3227 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3228#endif
3229 return Void();
3230}
3231
3232// Methods from ::android::hardware::radio::V1_3::IRadio follow.
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003233Return<void> RadioImpl_1_5::setSystemSelectionChannels(int32_t serial, bool /* specifyChannels */,
paulye91d34712019-02-07 19:02:02 -08003234 const hidl_vec<::android::hardware::radio::V1_1::RadioAccessSpecifier>& /* specifiers */) {
paulye91d34712019-02-07 19:02:02 -08003235#if VDBG
Malcolm Chen4bb42072019-02-22 18:21:48 -08003236 RLOGD("setSystemSelectionChannels: serial %d", serial);
paulye91d34712019-02-07 19:02:02 -08003237#endif
Malcolm Chen4bb42072019-02-22 18:21:48 -08003238 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS);
paulye91d34712019-02-07 19:02:02 -08003239 return Void();
3240}
3241
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003242Return<void> RadioImpl_1_5::enableModem(int32_t serial, bool /* on */) {
paulye91d34712019-02-07 19:02:02 -08003243#if VDBG
Nazanin Bakhshi42acd932019-02-27 15:05:39 -08003244 RLOGE("enableModem: serial = %d, enable = %s", serial, on);
paulye91d34712019-02-07 19:02:02 -08003245#endif
Nazanin Bakhshi42acd932019-02-27 15:05:39 -08003246 dispatchVoid(serial, mSlotId, RIL_REQUEST_ENABLE_MODEM);
paulye91d34712019-02-07 19:02:02 -08003247 return Void();
3248}
3249
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003250Return<void> RadioImpl_1_5::getModemStackStatus(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08003251#if VDBG
Nazanin Bakhshi25443002019-02-21 16:52:32 -08003252 RLOGD("getModemStackStatus: serial %d", serial);
paulye91d34712019-02-07 19:02:02 -08003253#endif
Nazanin Bakhshi25443002019-02-21 16:52:32 -08003254 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MODEM_STACK_STATUS);
paulye91d34712019-02-07 19:02:02 -08003255 return Void();
3256}
3257
3258const char * getProtocolString(const ::android::hardware::radio::V1_4::PdpProtocolType protocolVal) {
3259 switch(protocolVal) {
3260 case ::android::hardware::radio::V1_4::PdpProtocolType::IP:
3261 return "IP";
3262 case ::android::hardware::radio::V1_4::PdpProtocolType::IPV6:
3263 return "IPV6";
3264 case ::android::hardware::radio::V1_4::PdpProtocolType::IPV4V6:
3265 return "IPV4V6";
3266 case ::android::hardware::radio::V1_4::PdpProtocolType::PPP:
3267 return "PPP";
3268 case ::android::hardware::radio::V1_4::PdpProtocolType::NON_IP:
3269 return "NON_IP";
3270 case ::android::hardware::radio::V1_4::PdpProtocolType::UNSTRUCTURED:
3271 return "UNSTRUCTURED";
3272 default:
3273 return "UNKNOWN";
3274 }
3275}
3276
3277// Methods from ::android::hardware::radio::V1_4::IRadio follow.
Sarah Chinef7f9222020-01-30 10:37:08 -08003278Return<void> RadioImpl_1_5::setAllowedCarriers_1_4(int32_t serial,
3279 const V1_4::CarrierRestrictionsWithPriority& carriers,
3280 V1_4::SimLockMultiSimPolicy multiSimPolicy) {
3281#if VDBG
3282 RLOGD("setAllowedCarriers_1_4: serial %d", serial);
3283#endif
3284
3285 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3286 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
3287 if (pRI == NULL) {
3288 return Void();
3289 }
3290
3291 // Prepare legacy structure (defined in IRadio 1.0) to re-use existing code.
3292 RIL_CarrierRestrictions cr = {};
3293 if (prepareCarrierRestrictions(cr, false, carriers.allowedCarriers, carriers.excludedCarriers,
3294 pRI) < 0) {
3295 return Void();
3296 }
3297 // Copy the legacy structure into the new structure (defined in IRadio 1.4)
3298 RIL_CarrierRestrictionsWithPriority crExt = {};
3299 crExt.len_allowed_carriers = cr.len_allowed_carriers;
3300 crExt.allowed_carriers = cr.allowed_carriers;
3301 crExt.len_excluded_carriers = cr.len_excluded_carriers;
3302 crExt.excluded_carriers = cr.excluded_carriers;
3303 crExt.allowedCarriersPrioritized = BOOL_TO_INT(carriers.allowedCarriersPrioritized);
3304 crExt.multiSimPolicy = (RIL_SimLockMultiSimPolicy)multiSimPolicy;
3305
3306 CALL_ONREQUEST(pRI->pCI->requestNumber, &crExt, sizeof(RIL_CarrierRestrictionsWithPriority),
3307 pRI, mSlotId);
3308
3309 freeCarrierRestrictions(cr);
3310
3311 return Void();
3312}
3313
3314Return<void> RadioImpl_1_5::getAllowedCarriers_1_4(int32_t serial) {
3315#if VDBG
3316 RLOGD("getAllowedCarriers_1_4: serial %d", serial);
3317#endif
3318 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
3319 return Void();
3320}
3321
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003322Return<void> RadioImpl_1_5::setupDataCall_1_4(int32_t serial ,
paulye91d34712019-02-07 19:02:02 -08003323 ::android::hardware::radio::V1_4::AccessNetwork /* accessNetwork */,
3324 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo,
3325 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
3326 const hidl_vec<hidl_string>& /* addresses */, const hidl_vec<hidl_string>& /* dnses */) {
3327
3328#if VDBG
3329 RLOGD("setupDataCall_1_4: serial %d", serial);
3330#endif
3331
3332 char *mvnoTypeStr = NULL;
3333 if (!convertMvnoTypeToString(MvnoType::IMSI, mvnoTypeStr)) {
3334 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3335 RIL_REQUEST_SETUP_DATA_CALL);
3336 if (pRI != NULL) {
3337 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3338 }
3339 return Void();
3340 }
3341 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
3342 std::to_string((int) RadioTechnology::UNKNOWN + 2).c_str(),
3343 std::to_string((int) dataProfileInfo.profileId).c_str(),
3344 dataProfileInfo.apn.c_str(),
3345 dataProfileInfo.user.c_str(),
3346 dataProfileInfo.password.c_str(),
3347 std::to_string((int) dataProfileInfo.authType).c_str(),
3348 getProtocolString(dataProfileInfo.protocol),
3349 getProtocolString(dataProfileInfo.roamingProtocol),
3350 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
3351 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
3352 dataProfileInfo.persistent ? "1" : "0",
3353 std::to_string(dataProfileInfo.mtu).c_str(),
3354 mvnoTypeStr,
3355 "302720x94",
3356 roamingAllowed ? "1" : "0");
3357 return Void();
3358}
3359
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003360Return<void> RadioImpl_1_5::setInitialAttachApn_1_4(int32_t serial ,
Jack Yud5a67ed2019-03-06 14:59:36 -08003361 const ::android::hardware::radio::V1_4::DataProfileInfo& dataProfileInfo) {
3362 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3363 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
3364 if (pRI == NULL) {
3365 return Void();
3366 }
3367
3368 RadioResponseInfo responseInfo = {};
3369 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
3370
3371 if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
3372 Return<void> retStatus
3373 = radioService[mSlotId]->mRadioResponseV1_4->setInitialAttachApnResponse(responseInfo);
3374 radioService[mSlotId]->checkReturnStatus(retStatus);
3375 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
3376 Return<void> retStatus
3377 = radioService[mSlotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
3378 radioService[mSlotId]->checkReturnStatus(retStatus);
3379 } else {
3380 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
3381 }
3382
paulye91d34712019-02-07 19:02:02 -08003383 return Void();
3384}
3385
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003386Return<void> RadioImpl_1_5::setDataProfile_1_4(int32_t serial ,
paulye91d34712019-02-07 19:02:02 -08003387 const hidl_vec<::android::hardware::radio::V1_4::DataProfileInfo>& /* profiles */) {
Jack Yud5a67ed2019-03-06 14:59:36 -08003388 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3389 RIL_REQUEST_SET_DATA_PROFILE);
3390 if (pRI == NULL) {
3391 return Void();
3392 }
3393
3394 RadioResponseInfo responseInfo = {};
3395 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
3396
3397 if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
3398 Return<void> retStatus
3399 = radioService[mSlotId]->mRadioResponseV1_4->setDataProfileResponse(responseInfo);
3400 radioService[mSlotId]->checkReturnStatus(retStatus);
3401 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
3402 Return<void> retStatus
3403 = radioService[mSlotId]->mRadioResponse->setDataProfileResponse(responseInfo);
3404 radioService[mSlotId]->checkReturnStatus(retStatus);
3405 } else {
3406 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
3407 }
3408
paulye91d34712019-02-07 19:02:02 -08003409 return Void();
3410}
3411
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003412Return<void> RadioImpl_1_5::emergencyDial(int32_t serial,
sqian2e6e6c62019-02-26 16:55:02 -08003413 const ::android::hardware::radio::V1_0::Dial& dialInfo,
paulye91d34712019-02-07 19:02:02 -08003414 hidl_bitfield<android::hardware::radio::V1_4::EmergencyServiceCategory> /* categories */,
3415 const hidl_vec<hidl_string>& /* urns */,
3416 ::android::hardware::radio::V1_4::EmergencyCallRouting /* routing */,
3417 bool /* fromEmergencyDialer */, bool /* isTesting */) {
3418#if VDBG
3419 RLOGD("emergencyDial: serial %d", serial);
3420#endif
sqian2e6e6c62019-02-26 16:55:02 -08003421
3422 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_EMERGENCY_DIAL);
3423 if (pRI == NULL) {
3424 return Void();
3425 }
3426 RIL_Dial dial = {};
3427 RIL_UUS_Info uusInfo = {};
3428 int32_t sizeOfDial = sizeof(dial);
3429
3430 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
3431 return Void();
3432 }
3433 dial.clir = (int) dialInfo.clir;
3434
3435 if (dialInfo.uusInfo.size() != 0) {
3436 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
3437 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
3438
3439 if (dialInfo.uusInfo[0].uusData.size() == 0) {
3440 uusInfo.uusData = NULL;
3441 uusInfo.uusLength = 0;
3442 } else {
3443 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
3444 memsetAndFreeStrings(1, dial.address);
3445 return Void();
3446 }
3447 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
3448 }
3449
3450 dial.uusInfo = &uusInfo;
3451 }
3452
3453 CALL_ONREQUEST(RIL_REQUEST_EMERGENCY_DIAL, &dial, sizeOfDial, pRI, mSlotId);
3454
3455 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
3456
paulye91d34712019-02-07 19:02:02 -08003457 return Void();
3458}
3459
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003460Return<void> RadioImpl_1_5::startNetworkScan_1_4(int32_t serial,
paulye91d34712019-02-07 19:02:02 -08003461 const ::android::hardware::radio::V1_2::NetworkScanRequest& request) {
3462#if VDBG
3463 RLOGD("startNetworkScan_1_4: serial %d", serial);
3464#endif
3465
Sarah Chinef7f9222020-01-30 10:37:08 -08003466 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
paulye91d34712019-02-07 19:02:02 -08003467 if (pRI == NULL) {
3468 return Void();
3469 }
3470
paulye91d34712019-02-07 19:02:02 -08003471 RIL_NetworkScanRequest scan_request = {};
3472
3473 if (prepareNetworkScanRequest_1_2(scan_request, request, pRI) < 0) {
3474 return Void();
3475 }
3476
Sarah Chinef7f9222020-01-30 10:37:08 -08003477 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
paulye91d34712019-02-07 19:02:02 -08003478 mSlotId);
3479
3480 return Void();
3481}
3482
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003483Return<void> RadioImpl_1_5::getPreferredNetworkTypeBitmap(int32_t serial ) {
paulye91d34712019-02-07 19:02:02 -08003484#if VDBG
paulyeff378952019-02-25 12:40:45 -08003485 RLOGD("getPreferredNetworkTypeBitmap: serial %d", serial);
paulye91d34712019-02-07 19:02:02 -08003486#endif
paulyeff378952019-02-25 12:40:45 -08003487 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE_BITMAP);
paulye91d34712019-02-07 19:02:02 -08003488 return Void();
3489}
3490
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003491Return<void> RadioImpl_1_5::setPreferredNetworkTypeBitmap(
paulyeff378952019-02-25 12:40:45 -08003492 int32_t serial, hidl_bitfield<RadioAccessFamily> networkTypeBitmap) {
paulye91d34712019-02-07 19:02:02 -08003493#if VDBG
paulyeff378952019-02-25 12:40:45 -08003494 RLOGD("setPreferredNetworkTypeBitmap: serial %d", serial);
paulye91d34712019-02-07 19:02:02 -08003495#endif
paulyeff378952019-02-25 12:40:45 -08003496 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE_BITMAP, 1, networkTypeBitmap);
paulye91d34712019-02-07 19:02:02 -08003497 return Void();
3498}
3499
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003500Return<void> RadioImpl_1_5::getSignalStrength_1_4(int32_t serial) {
paulye91d34712019-02-07 19:02:02 -08003501#if VDBG
paulye8d2d9452019-02-25 15:17:16 -08003502 RLOGD("getSignalStrength_1_4: serial %d", serial);
paulye91d34712019-02-07 19:02:02 -08003503#endif
paulye8d2d9452019-02-25 15:17:16 -08003504 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
paulye91d34712019-02-07 19:02:02 -08003505 return Void();
3506}
3507
Sarah Chin75b299c2019-12-11 10:57:28 -08003508// Methods from ::android::hardware::radio::V1_5::IRadio follow.
Sarah Chinbb757c62019-11-06 12:46:42 -08003509Return<void> RadioImpl_1_5::setSignalStrengthReportingCriteria_1_5(int32_t /* serial */,
3510 const ::android::hardware::radio::V1_5::SignalThresholdInfo& /* signalThresholdInfo */,
3511 const ::android::hardware::radio::V1_5::AccessNetwork /* accessNetwork */) {
3512 // TODO implement
3513#if VDBG
3514 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3515#endif
3516 return Void();
3517}
3518
Malcolm Chenc2008a22019-11-12 18:43:09 -08003519Return<void> RadioImpl_1_5::enableUiccApplications(int32_t serial, bool enable) {
3520#if VDBG
3521 RLOGD("enableUiccApplications: serial %d enable %d", serial, enable);
3522#endif
3523 dispatchInts(serial, mSlotId, RIL_REQUEST_ENABLE_UICC_APPLICATIONS, 1, BOOL_TO_INT(enable));
3524 return Void();
3525}
3526
Malcolm Chenad6b0972019-12-17 15:52:16 -08003527Return<void> RadioImpl_1_5::setRadioPower_1_5(int32_t serial, bool powerOn, bool forEmergencyCall,
3528 bool preferredForEmergencyCall) {
3529#if VDBG
3530 RLOGD("setRadioPower_1_5: serial %d powerOn %d forEmergency %d preferredForEmergencyCall %d",
3531 serial, powerOn, forEmergencyCall, preferredForEmergencyCall);
3532#endif
Sarah Chinef7f9222020-01-30 10:37:08 -08003533 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_RADIO_POWER);
Malcolm Chenad6b0972019-12-17 15:52:16 -08003534 return Void();
3535}
3536
Malcolm Chenc2008a22019-11-12 18:43:09 -08003537Return<void> RadioImpl_1_5::areUiccApplicationsEnabled(int32_t serial) {
3538#if VDBG
3539 RLOGD("areUiccApplicationsEnabled: serial %d", serial);
3540#endif
3541 dispatchVoid(serial, mSlotId, RIL_REQUEST_ARE_UICC_APPLICATIONS_ENABLED);
3542 return Void();
3543}
3544
Sarah Chinef7f9222020-01-30 10:37:08 -08003545Return<void> RadioImpl_1_5::getVoiceRegistrationState_1_5(int32_t serial) {
3546#if VDBG
3547 RLOGD("getVoiceRegistrationState: serial %d", serial);
3548#endif
3549 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
3550 return Void();
3551}
3552
3553Return<void> RadioImpl_1_5::getDataRegistrationState_1_5(int32_t serial) {
3554#if VDBG
3555 RLOGD("getDataRegistrationState: serial %d", serial);
3556#endif
3557 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
3558 return Void();
3559}
3560
3561Return<void> RadioImpl_1_5::setSystemSelectionChannels_1_5(int32_t serial,
3562 bool /* specifyChannels */, const hidl_vec<V1_5::RadioAccessSpecifier>& /* specifiers */) {
Sarah Chinbb757c62019-11-06 12:46:42 -08003563#if VDBG
3564 RLOGD("setSystemSelectionChannels_1_5: serial %d", serial);
3565#endif
Sarah Chinef7f9222020-01-30 10:37:08 -08003566 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_SYSTEM_SELECTION_CHANNELS);
Sarah Chinbb757c62019-11-06 12:46:42 -08003567 return Void();
3568}
3569
Sarah Chinef7f9222020-01-30 10:37:08 -08003570int prepareNetworkScanRequest_1_5(RIL_NetworkScanRequest &scan_request,
3571 const V1_5::NetworkScanRequest& request, RequestInfo *pRI) {
3572 scan_request.type = (RIL_ScanType) request.type;
3573 scan_request.interval = request.interval;
3574 scan_request.specifiers_length = request.specifiers.size();
3575
3576 int intervalLow = static_cast<int>(V1_2::ScanIntervalRange::MIN);
3577 int intervalHigh = static_cast<int>(V1_2::ScanIntervalRange::MAX);
3578 int maxSearchTimeLow = static_cast<int>(V1_2::MaxSearchTimeRange::MIN);
3579 int maxSearchTimeHigh = static_cast<int>(V1_2::MaxSearchTimeRange::MAX);
3580 int incrementalResultsPeriodicityRangeLow =
3581 static_cast<int>(V1_2::IncrementalResultsPeriodicityRange::MIN);
3582 int incrementalResultsPeriodicityRangeHigh =
3583 static_cast<int>(V1_2::IncrementalResultsPeriodicityRange::MAX);
3584 uint maxSpecifierSize = static_cast<uint>(V1_2::RadioConst::RADIO_ACCESS_SPECIFIER_MAX_SIZE);
3585
3586 if (request.interval < intervalLow || request.interval > intervalHigh) {
3587 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3588 return -1;
3589 }
3590 // If defined, must fall in correct range.
3591 if (request.maxSearchTime != 0 && (request.maxSearchTime < maxSearchTimeLow
3592 || request.maxSearchTime > maxSearchTimeHigh)) {
3593 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3594 return -1;
3595 }
3596 if (request.maxSearchTime != 0
3597 && (request.incrementalResultsPeriodicity < incrementalResultsPeriodicityRangeLow
3598 || request.incrementalResultsPeriodicity > incrementalResultsPeriodicityRangeHigh
3599 || request.incrementalResultsPeriodicity > request.maxSearchTime)) {
3600 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3601 return -1;
3602 }
3603 if (request.specifiers.size() == 0 || request.specifiers.size() > maxSpecifierSize) {
3604 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3605 return -1;
3606 }
3607
3608 for (size_t i = 0; i < request.specifiers.size(); ++i) {
3609 if (request.specifiers[i].bands.geranBands().size() > MAX_BANDS
3610 || request.specifiers[i].bands.utranBands().size() > MAX_BANDS
3611 || request.specifiers[i].bands.eutranBands().size() > MAX_BANDS
3612 || request.specifiers[i].bands.ngranBands().size() > MAX_BANDS
3613 || request.specifiers[i].channels.size() > MAX_CHANNELS) {
3614 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3615 return -1;
3616 }
3617 const V1_5::RadioAccessSpecifier& ras_from = request.specifiers[i];
3618 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
3619
3620 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
3621 ras_to.channels_length = ras_from.channels.size();
3622
3623 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
3624 const std::vector<uint32_t> * bands = nullptr;
3625 switch (request.specifiers[i].radioAccessNetwork) {
3626 case V1_5::RadioAccessNetworks::GERAN:
3627 ras_to.bands_length = ras_from.bands.geranBands().size();
3628 bands = (std::vector<uint32_t> *) &ras_from.bands;
3629 break;
3630 case V1_5::RadioAccessNetworks::UTRAN:
3631 ras_to.bands_length = ras_from.bands.utranBands().size();
3632 bands = (std::vector<uint32_t> *) &ras_from.bands;
3633 break;
3634 case V1_5::RadioAccessNetworks::EUTRAN:
3635 ras_to.bands_length = ras_from.bands.eutranBands().size();
3636 bands = (std::vector<uint32_t> *) &ras_from.bands;
3637 break;
3638 case V1_5::RadioAccessNetworks::NGRAN:
3639 ras_to.bands_length = ras_from.bands.ngranBands().size();
3640 bands = (std::vector<uint32_t> *) &ras_from.bands;
3641 break;
3642 default:
3643 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3644 return -1;
3645 }
3646 // safe to copy to geran_bands because it's a union member
3647 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
3648 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
3649 }
3650 }
3651
3652 return 0;
3653}
3654
Sarah Chinbb757c62019-11-06 12:46:42 -08003655Return<void> RadioImpl_1_5::startNetworkScan_1_5(int32_t serial,
3656 const ::android::hardware::radio::V1_5::NetworkScanRequest& request) {
3657#if VDBG
3658 RLOGD("startNetworkScan_1_5: serial %d", serial);
3659#endif
3660
Sarah Chinef7f9222020-01-30 10:37:08 -08003661 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
Sarah Chinbb757c62019-11-06 12:46:42 -08003662 if (pRI == NULL) {
3663 return Void();
3664 }
3665
Sarah Chinbb757c62019-11-06 12:46:42 -08003666 RIL_NetworkScanRequest scan_request = {};
3667
3668 if (prepareNetworkScanRequest_1_5(scan_request, request, pRI) < 0) {
3669 return Void();
3670 }
3671
Sarah Chinef7f9222020-01-30 10:37:08 -08003672 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
Sarah Chinbb757c62019-11-06 12:46:42 -08003673 mSlotId);
3674
3675 return Void();
3676}
3677
Sarah Chin75b299c2019-12-11 10:57:28 -08003678Return<void> RadioImpl_1_5::setupDataCall_1_5(int32_t serial ,
3679 ::android::hardware::radio::V1_5::AccessNetwork /* accessNetwork */,
3680 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo,
3681 bool roamingAllowed, ::android::hardware::radio::V1_2::DataRequestReason /* reason */,
Jack Yufd2ea3f2019-12-14 10:43:41 -08003682 const hidl_vec<::android::hardware::radio::V1_5::LinkAddress>& /* addresses */,
3683 const hidl_vec<hidl_string>& /* dnses */) {
Sarah Chin75b299c2019-12-11 10:57:28 -08003684
3685#if VDBG
3686 RLOGD("setupDataCall_1_5: serial %d", serial);
3687#endif
3688
3689 char *mvnoTypeStr = NULL;
3690 if (!convertMvnoTypeToString(MvnoType::IMSI, mvnoTypeStr)) {
3691 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3692 RIL_REQUEST_SETUP_DATA_CALL);
3693 if (pRI != NULL) {
3694 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
3695 }
3696 return Void();
3697 }
3698 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
3699 std::to_string((int) RadioTechnology::UNKNOWN + 2).c_str(),
Sarah Chin9ecfc322020-01-16 10:35:02 -08003700 std::to_string((int) dataProfileInfo.profileId).c_str(),
3701 dataProfileInfo.apn.c_str(),
3702 dataProfileInfo.user.c_str(),
3703 dataProfileInfo.password.c_str(),
3704 std::to_string((int) dataProfileInfo.authType).c_str(),
3705 getProtocolString(dataProfileInfo.protocol),
3706 getProtocolString(dataProfileInfo.roamingProtocol),
Sarah Chin75b299c2019-12-11 10:57:28 -08003707 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
Sarah Chin9ecfc322020-01-16 10:35:02 -08003708 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
3709 dataProfileInfo.persistent ? "1" : "0",
3710 std::to_string(dataProfileInfo.mtuV4).c_str(),
3711 std::to_string(dataProfileInfo.mtuV6).c_str(),
Sarah Chin75b299c2019-12-11 10:57:28 -08003712 mvnoTypeStr,
3713 "302720x94",
3714 roamingAllowed ? "1" : "0");
3715 return Void();
3716}
3717
3718Return<void> RadioImpl_1_5::setInitialAttachApn_1_5(int32_t serial ,
3719 const ::android::hardware::radio::V1_5::DataProfileInfo& dataProfileInfo) {
3720 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3721 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
3722 if (pRI == NULL) {
3723 return Void();
3724 }
3725
3726 RadioResponseInfo responseInfo = {};
3727 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
3728
3729 if (radioService[mSlotId]->mRadioResponseV1_5 != NULL) {
3730 Return<void> retStatus
3731 = radioService[mSlotId]->mRadioResponseV1_5->setInitialAttachApnResponse(responseInfo);
3732 } else if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
3733 Return<void> retStatus
3734 = radioService[mSlotId]->mRadioResponseV1_4->setInitialAttachApnResponse(responseInfo);
3735 radioService[mSlotId]->checkReturnStatus(retStatus);
3736 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
3737 Return<void> retStatus
3738 = radioService[mSlotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
3739 radioService[mSlotId]->checkReturnStatus(retStatus);
3740 } else {
3741 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
3742 }
3743
3744 return Void();
3745}
3746
3747Return<void> RadioImpl_1_5::setDataProfile_1_5(int32_t serial ,
3748 const hidl_vec<::android::hardware::radio::V1_5::DataProfileInfo>& /* profiles */) {
3749 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3750 RIL_REQUEST_SET_DATA_PROFILE);
3751 if (pRI == NULL) {
3752 return Void();
3753 }
3754
3755 RadioResponseInfo responseInfo = {};
3756 populateResponseInfo(responseInfo, serial, RESPONSE_SOLICITED, RIL_E_SUCCESS);
3757
3758 if (radioService[mSlotId]->mRadioResponseV1_5 != NULL) {
3759 Return<void> retStatus
3760 = radioService[mSlotId]->mRadioResponseV1_5->setDataProfileResponse(responseInfo);
3761 } else if (radioService[mSlotId]->mRadioResponseV1_4 != NULL) {
3762 Return<void> retStatus
3763 = radioService[mSlotId]->mRadioResponseV1_4->setDataProfileResponse(responseInfo);
3764 radioService[mSlotId]->checkReturnStatus(retStatus);
3765 } else if (radioService[mSlotId]->mRadioResponse != NULL) {
3766 Return<void> retStatus
3767 = radioService[mSlotId]->mRadioResponse->setDataProfileResponse(responseInfo);
3768 radioService[mSlotId]->checkReturnStatus(retStatus);
3769 } else {
3770 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", mSlotId);
3771 }
3772
3773 return Void();
3774}
3775
Nathan Harold30a7d092020-01-02 15:08:37 -08003776Return<void> RadioImpl_1_5::setIndicationFilter_1_5(int32_t /* serial */,
3777 hidl_bitfield<::android::hardware::radio::V1_5::IndicationFilter> /* indicationFilter */) {
3778 // TODO implement
3779#if VDBG
3780 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3781#endif
3782 return Void();
3783}
3784
Nathan Harold8a9283c2020-01-02 15:31:41 -08003785Return<void> RadioImpl_1_5::getBarringInfo(int32_t /* serial */) {
3786 // TODO implement
3787#if VDBG
3788 RLOGE("[%04d]< %s", serial, "Method is not implemented");
3789#endif
3790 return Void();
3791}
3792
Sarah Chin65f1d7f2019-12-18 17:07:39 -08003793Return<void> RadioImpl_1_5::setNetworkSelectionModeManual_1_5(int32_t serial,
3794 const hidl_string& operatorNumeric, V1_5::RadioAccessNetworks ran) {
3795#if VDBG
3796 RLOGD("setNetworkSelectionModeManual_1_5: serial %d", serial);
3797#endif
3798 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL);
3799 return Void();
3800}
3801
Sarah Chinef7f9222020-01-30 10:37:08 -08003802Return<void> RadioImpl_1_5::sendCdmaSmsExpectMore(int32_t serial, const CdmaSmsMessage& sms) {
3803#if VDBG
3804 RLOGD("sendCdmaSmsExpectMore: serial %d", serial);
3805#endif
3806 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
3807 RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE);
3808 if (pRI == NULL) {
3809 return Void();
3810 }
3811
3812 RIL_CDMA_SMS_Message rcsm = {};
3813 constructCdmaSms(rcsm, sms);
3814
3815 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
3816 return Void();
3817}
3818
3819Return<void> RadioImpl_1_5::supplySimDepersonalization(int32_t serial,
3820 V1_5::PersoSubstate persoType, const hidl_string& controlKey) {
3821#if VDBG
3822 RLOGD("supplySimDepersonalization: serial %d", serial);
3823#endif
3824 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_DEPERSONALIZATION, true, 1,
3825 controlKey.c_str());
3826 return Void();
3827}
3828
Malcolm Chenc2008a22019-11-12 18:43:09 -08003829// OEM hook methods:
paulye91d34712019-02-07 19:02:02 -08003830Return<void> OemHookImpl::setResponseFunctions(
3831 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
3832 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
3833#if VDBG
3834 RLOGD("OemHookImpl::setResponseFunctions");
3835#endif
3836
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003837 pthread_rwlock_t *radioServiceRwlockPtr = radio_1_5::getRadioServiceRwlock(mSlotId);
paulye91d34712019-02-07 19:02:02 -08003838 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
3839 assert(ret == 0);
3840
3841 mOemHookResponse = oemHookResponseParam;
3842 mOemHookIndication = oemHookIndicationParam;
3843 mCounterOemHook[mSlotId]++;
3844
3845 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
3846 assert(ret == 0);
3847
3848 return Void();
3849}
3850
3851Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
3852#if VDBG
3853 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
3854#endif
3855 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
3856 return Void();
3857}
3858
3859Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
3860 const hidl_vec<hidl_string>& data) {
3861#if VDBG
3862 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
3863#endif
3864 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
3865 return Void();
3866}
3867
3868/***************************************************************************************************
3869 * RESPONSE FUNCTIONS
3870 * Functions above are used for requests going from framework to vendor code. The ones below are
3871 * responses for those requests coming back from the vendor code.
3872 **************************************************************************************************/
3873
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003874void radio_1_5::acknowledgeRequest(int slotId, int serial) {
paulye91d34712019-02-07 19:02:02 -08003875 if (radioService[slotId]->mRadioResponse != NULL) {
3876 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
3877 radioService[slotId]->checkReturnStatus(retStatus);
3878 } else {
3879 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
3880 }
3881}
3882
3883void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
3884 RIL_Errno e) {
3885 responseInfo.serial = serial;
3886 switch (responseType) {
3887 case RESPONSE_SOLICITED:
3888 responseInfo.type = RadioResponseType::SOLICITED;
3889 break;
3890 case RESPONSE_SOLICITED_ACK_EXP:
3891 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
3892 break;
3893 }
3894 responseInfo.error = (RadioError) e;
3895}
3896
3897int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
3898 void *response, size_t responseLen) {
3899 populateResponseInfo(responseInfo, serial, responseType, e);
3900 int ret = -1;
3901
3902 if (response == NULL && responseLen == 0) {
3903 // Earlier RILs did not send a response for some cases although the interface
3904 // expected an integer as response. Do not return error if response is empty. Instead
3905 // Return -1 in those cases to maintain backward compatibility.
3906 } else if (response == NULL || responseLen != sizeof(int)) {
3907 RLOGE("responseIntOrEmpty: Invalid response");
3908 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3909 } else {
3910 int *p_int = (int *) response;
3911 ret = p_int[0];
3912 }
3913 return ret;
3914}
3915
3916int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
3917 void *response, size_t responseLen) {
3918 populateResponseInfo(responseInfo, serial, responseType, e);
3919 int ret = -1;
3920
3921 if (response == NULL || responseLen != sizeof(int)) {
3922 RLOGE("responseInt: Invalid response");
3923 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3924 } else {
3925 int *p_int = (int *) response;
3926 ret = p_int[0];
3927 }
3928 return ret;
3929}
3930
Malcolm Chen6b9984e2019-10-10 14:44:58 -07003931int radio_1_5::getIccCardStatusResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08003932 int responseType, int serial, RIL_Errno e,
3933 void *response, size_t responseLen) {
paulye8d2d9452019-02-25 15:17:16 -08003934 if (radioService[slotId]->mRadioResponseV1_4 != NULL
Malcolm Chen4bb42072019-02-22 18:21:48 -08003935 || radioService[slotId]->mRadioResponseV1_2 != NULL
paulye8d2d9452019-02-25 15:17:16 -08003936 || radioService[slotId]->mRadioResponse != NULL) {
paulye91d34712019-02-07 19:02:02 -08003937 RadioResponseInfo responseInfo = {};
3938 populateResponseInfo(responseInfo, serial, responseType, e);
3939 CardStatus cardStatus = {CardState::ABSENT, PinState::UNKNOWN, -1, -1, -1, {}};
3940 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
3941 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)
3942 || p_cur->gsm_umts_subscription_app_index >= p_cur->num_applications
3943 || p_cur->cdma_subscription_app_index >= p_cur->num_applications
3944 || p_cur->ims_subscription_app_index >= p_cur->num_applications) {
3945 RLOGE("getIccCardStatusResponse: Invalid response");
3946 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3947 } else {
3948 cardStatus.cardState = (CardState) p_cur->card_state;
3949 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
3950 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
3951 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
3952 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
3953
3954 RIL_AppStatus *rilAppStatus = p_cur->applications;
3955 cardStatus.applications.resize(p_cur->num_applications);
3956 AppStatus *appStatus = cardStatus.applications.data();
3957#if VDBG
3958 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
3959#endif
3960 for (int i = 0; i < p_cur->num_applications; i++) {
3961 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
3962 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
3963 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
3964 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
3965 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
3966 rilAppStatus[i].app_label_ptr);
3967 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
3968 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
3969 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
3970 }
3971 }
3972
paulye8d2d9452019-02-25 15:17:16 -08003973 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
3974 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
3975 ::android::hardware::radio::V1_4::CardStatus cardStatusV1_4;
3976 cardStatusV1_2.base = cardStatus;
3977 cardStatusV1_2.physicalSlotId = -1;
3978 cardStatusV1_4.base = cardStatusV1_2;
3979 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4->
3980 getIccCardStatusResponse_1_4(responseInfo, cardStatusV1_4);
3981 radioService[slotId]->checkReturnStatus(retStatus);
Malcolm Chen4bb42072019-02-22 18:21:48 -08003982 } else if (radioService[slotId]->mRadioResponseV1_3 != NULL) {
3983 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
3984 cardStatusV1_2.base = cardStatus;
3985 cardStatusV1_2.physicalSlotId = -1;
3986 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_3->
3987 getIccCardStatusResponse_1_2(responseInfo, cardStatusV1_2);
3988 radioService[slotId]->checkReturnStatus(retStatus);
3989 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
3990 ::android::hardware::radio::V1_2::CardStatus cardStatusV1_2;
3991 cardStatusV1_2.base = cardStatus;
3992 cardStatusV1_2.physicalSlotId = -1;
3993 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2->
3994 getIccCardStatusResponse_1_2(responseInfo, cardStatusV1_2);
3995 radioService[slotId]->checkReturnStatus(retStatus);
3996 // TODO: add 1.1 if needed.
paulye8d2d9452019-02-25 15:17:16 -08003997 } else {
3998 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3999 getIccCardStatusResponse(responseInfo, cardStatus);
4000 radioService[slotId]->checkReturnStatus(retStatus);
4001 }
paulye91d34712019-02-07 19:02:02 -08004002 } else {
4003 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4004 }
4005
4006 return 0;
4007}
4008
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004009int radio_1_5::supplyIccPinForAppResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004010 int responseType, int serial, RIL_Errno e,
4011 void *response, size_t responseLen) {
4012#if VDBG
4013 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
4014#endif
4015
4016 if (radioService[slotId]->mRadioResponse != NULL) {
4017 RadioResponseInfo responseInfo = {};
4018 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4019 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4020 supplyIccPinForAppResponse(responseInfo, ret);
4021 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
4022 radioService[slotId]->checkReturnStatus(retStatus);
4023 } else {
4024 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
4025 slotId);
4026 }
4027
4028 return 0;
4029}
4030
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004031int radio_1_5::supplyIccPukForAppResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004032 int responseType, int serial, RIL_Errno e,
4033 void *response, size_t responseLen) {
4034#if VDBG
4035 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
4036#endif
4037
4038 if (radioService[slotId]->mRadioResponse != NULL) {
4039 RadioResponseInfo responseInfo = {};
4040 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4041 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
4042 responseInfo, ret);
4043 radioService[slotId]->checkReturnStatus(retStatus);
4044 } else {
4045 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
4046 slotId);
4047 }
4048
4049 return 0;
4050}
4051
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004052int radio_1_5::supplyIccPin2ForAppResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004053 int responseType, int serial, RIL_Errno e,
4054 void *response, size_t responseLen) {
4055#if VDBG
4056 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
4057#endif
4058
4059 if (radioService[slotId]->mRadioResponse != NULL) {
4060 RadioResponseInfo responseInfo = {};
4061 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4062 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4063 supplyIccPin2ForAppResponse(responseInfo, ret);
4064 radioService[slotId]->checkReturnStatus(retStatus);
4065 } else {
4066 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
4067 slotId);
4068 }
4069
4070 return 0;
4071}
4072
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004073int radio_1_5::supplyIccPuk2ForAppResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004074 int responseType, int serial, RIL_Errno e,
4075 void *response, size_t responseLen) {
4076#if VDBG
4077 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
4078#endif
4079
4080 if (radioService[slotId]->mRadioResponse != NULL) {
4081 RadioResponseInfo responseInfo = {};
4082 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4083 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4084 supplyIccPuk2ForAppResponse(responseInfo, ret);
4085 radioService[slotId]->checkReturnStatus(retStatus);
4086 } else {
4087 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
4088 slotId);
4089 }
4090
4091 return 0;
4092}
4093
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004094int radio_1_5::changeIccPinForAppResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004095 int responseType, int serial, RIL_Errno e,
4096 void *response, size_t responseLen) {
4097#if VDBG
4098 RLOGD("changeIccPinForAppResponse: serial %d", serial);
4099#endif
4100
4101 if (radioService[slotId]->mRadioResponse != NULL) {
4102 RadioResponseInfo responseInfo = {};
4103 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4104 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4105 changeIccPinForAppResponse(responseInfo, ret);
4106 radioService[slotId]->checkReturnStatus(retStatus);
4107 } else {
4108 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
4109 slotId);
4110 }
4111
4112 return 0;
4113}
4114
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004115int radio_1_5::changeIccPin2ForAppResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004116 int responseType, int serial, RIL_Errno e,
4117 void *response, size_t responseLen) {
4118#if VDBG
4119 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
4120#endif
4121
4122 if (radioService[slotId]->mRadioResponse != NULL) {
4123 RadioResponseInfo responseInfo = {};
4124 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4125 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4126 changeIccPin2ForAppResponse(responseInfo, ret);
4127 radioService[slotId]->checkReturnStatus(retStatus);
4128 } else {
4129 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
4130 slotId);
4131 }
4132
4133 return 0;
4134}
4135
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004136int radio_1_5::supplyNetworkDepersonalizationResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004137 int responseType, int serial, RIL_Errno e,
4138 void *response, size_t responseLen) {
4139#if VDBG
4140 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
4141#endif
4142
4143 if (radioService[slotId]->mRadioResponse != NULL) {
4144 RadioResponseInfo responseInfo = {};
4145 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4146 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4147 supplyNetworkDepersonalizationResponse(responseInfo, ret);
4148 radioService[slotId]->checkReturnStatus(retStatus);
4149 } else {
4150 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
4151 "NULL", slotId);
4152 }
4153
4154 return 0;
4155}
4156
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004157int radio_1_5::getCurrentCallsResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004158 int responseType, int serial, RIL_Errno e,
4159 void *response, size_t responseLen) {
4160#if VDBG
4161 RLOGD("getCurrentCallsResponse: serial %d", serial);
4162#endif
4163
4164 if (radioService[slotId]->mRadioResponse != NULL) {
4165 RadioResponseInfo responseInfo = {};
4166 populateResponseInfo(responseInfo, serial, responseType, e);
4167
4168 hidl_vec<Call> calls;
4169 if ((response == NULL && responseLen != 0)
4170 || (responseLen % sizeof(RIL_Call *)) != 0) {
4171 RLOGE("getCurrentCallsResponse: Invalid response");
4172 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4173 } else {
4174 int num = responseLen / sizeof(RIL_Call *);
4175 calls.resize(num);
4176
4177 for (int i = 0 ; i < num ; i++) {
4178 RIL_Call *p_cur = ((RIL_Call **) response)[i];
4179 /* each call info */
4180 calls[i].state = (CallState) p_cur->state;
4181 calls[i].index = p_cur->index;
4182 calls[i].toa = p_cur->toa;
4183 calls[i].isMpty = p_cur->isMpty;
4184 calls[i].isMT = p_cur->isMT;
4185 calls[i].als = p_cur->als;
4186 calls[i].isVoice = p_cur->isVoice;
4187 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
4188 calls[i].number = convertCharPtrToHidlString(p_cur->number);
4189 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
4190 calls[i].name = convertCharPtrToHidlString(p_cur->name);
4191 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
4192 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
4193 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
4194 calls[i].uusInfo.resize(1);
4195 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
4196 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
4197 // convert uusInfo->uusData to a null-terminated string
4198 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
4199 calls[i].uusInfo[0].uusData = nullTermStr;
4200 free(nullTermStr);
4201 }
4202 }
4203 }
4204
4205 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4206 getCurrentCallsResponse(responseInfo, calls);
4207 radioService[slotId]->checkReturnStatus(retStatus);
4208 } else {
4209 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4210 }
4211
4212 return 0;
4213}
4214
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004215int radio_1_5::dialResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004216 int responseType, int serial, RIL_Errno e, void *response,
4217 size_t responseLen) {
4218#if VDBG
4219 RLOGD("dialResponse: serial %d", serial);
4220#endif
4221
4222 if (radioService[slotId]->mRadioResponse != NULL) {
4223 RadioResponseInfo responseInfo = {};
4224 populateResponseInfo(responseInfo, serial, responseType, e);
4225 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
4226 radioService[slotId]->checkReturnStatus(retStatus);
4227 } else {
4228 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4229 }
4230
4231 return 0;
4232}
4233
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004234int radio_1_5::getIMSIForAppResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004235 int responseType, int serial, RIL_Errno e, void *response,
4236 size_t responseLen) {
4237#if VDBG
4238 RLOGD("getIMSIForAppResponse: serial %d", serial);
4239#endif
4240
4241 if (radioService[slotId]->mRadioResponse != NULL) {
4242 RadioResponseInfo responseInfo = {};
4243 populateResponseInfo(responseInfo, serial, responseType, e);
4244 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
4245 responseInfo, convertCharPtrToHidlString((char *) response));
4246 radioService[slotId]->checkReturnStatus(retStatus);
4247 } else {
4248 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
4249 slotId);
4250 }
4251
4252 return 0;
4253}
4254
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004255int radio_1_5::hangupConnectionResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004256 int responseType, int serial, RIL_Errno e,
4257 void *response, size_t responseLen) {
4258#if VDBG
4259 RLOGD("hangupConnectionResponse: serial %d", serial);
4260#endif
4261
4262 if (radioService[slotId]->mRadioResponse != NULL) {
4263 RadioResponseInfo responseInfo = {};
4264 populateResponseInfo(responseInfo, serial, responseType, e);
4265 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
4266 responseInfo);
4267 radioService[slotId]->checkReturnStatus(retStatus);
4268 } else {
4269 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4270 slotId);
4271 }
4272
4273 return 0;
4274}
4275
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004276int radio_1_5::hangupWaitingOrBackgroundResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004277 int responseType, int serial, RIL_Errno e,
4278 void *response, size_t responseLen) {
4279#if VDBG
4280 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
4281#endif
4282
4283 if (radioService[slotId]->mRadioResponse != NULL) {
4284 RadioResponseInfo responseInfo = {};
4285 populateResponseInfo(responseInfo, serial, responseType, e);
4286 Return<void> retStatus =
4287 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
4288 responseInfo);
4289 radioService[slotId]->checkReturnStatus(retStatus);
4290 } else {
4291 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
4292 slotId);
4293 }
4294
4295 return 0;
4296}
4297
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004298int radio_1_5::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
paulye91d34712019-02-07 19:02:02 -08004299 RIL_Errno e, void *response,
4300 size_t responseLen) {
4301#if VDBG
4302 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
4303#endif
4304
4305 if (radioService[slotId]->mRadioResponse != NULL) {
4306 RadioResponseInfo responseInfo = {};
4307 populateResponseInfo(responseInfo, serial, responseType, e);
4308 Return<void> retStatus =
4309 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
4310 responseInfo);
4311 radioService[slotId]->checkReturnStatus(retStatus);
4312 } else {
4313 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
4314 slotId);
4315 }
4316
4317 return 0;
4318}
4319
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004320int radio_1_5::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
paulye91d34712019-02-07 19:02:02 -08004321 RIL_Errno e, void *response,
4322 size_t responseLen) {
4323#if VDBG
4324 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
4325#endif
4326
4327 if (radioService[slotId]->mRadioResponse != NULL) {
4328 RadioResponseInfo responseInfo = {};
4329 populateResponseInfo(responseInfo, serial, responseType, e);
4330 Return<void> retStatus =
4331 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
4332 responseInfo);
4333 radioService[slotId]->checkReturnStatus(retStatus);
4334 } else {
4335 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
4336 "== NULL", slotId);
4337 }
4338
4339 return 0;
4340}
4341
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004342int radio_1_5::conferenceResponse(int slotId, int responseType,
paulye91d34712019-02-07 19:02:02 -08004343 int serial, RIL_Errno e, void *response, size_t responseLen) {
4344#if VDBG
4345 RLOGD("conferenceResponse: serial %d", serial);
4346#endif
4347
4348 if (radioService[slotId]->mRadioResponse != NULL) {
4349 RadioResponseInfo responseInfo = {};
4350 populateResponseInfo(responseInfo, serial, responseType, e);
4351 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
4352 responseInfo);
4353 radioService[slotId]->checkReturnStatus(retStatus);
4354 } else {
4355 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
4356 slotId);
4357 }
4358
4359 return 0;
4360}
4361
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004362int radio_1_5::rejectCallResponse(int slotId, int responseType,
paulye91d34712019-02-07 19:02:02 -08004363 int serial, RIL_Errno e, void *response, size_t responseLen) {
4364#if VDBG
4365 RLOGD("rejectCallResponse: serial %d", serial);
4366#endif
4367
4368 if (radioService[slotId]->mRadioResponse != NULL) {
4369 RadioResponseInfo responseInfo = {};
4370 populateResponseInfo(responseInfo, serial, responseType, e);
4371 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
4372 responseInfo);
4373 radioService[slotId]->checkReturnStatus(retStatus);
4374 } else {
4375 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
4376 slotId);
4377 }
4378
4379 return 0;
4380}
4381
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004382int radio_1_5::getLastCallFailCauseResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004383 int responseType, int serial, RIL_Errno e, void *response,
4384 size_t responseLen) {
4385#if VDBG
4386 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
4387#endif
4388
4389 if (radioService[slotId]->mRadioResponse != NULL) {
4390 RadioResponseInfo responseInfo = {};
4391 populateResponseInfo(responseInfo, serial, responseType, e);
4392
4393 LastCallFailCauseInfo info = {};
4394 info.vendorCause = hidl_string();
4395 if (response == NULL) {
4396 RLOGE("getCurrentCallsResponse Invalid response: NULL");
4397 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4398 } else if (responseLen == sizeof(int)) {
4399 int *pInt = (int *) response;
4400 info.causeCode = (LastCallFailCause) pInt[0];
4401 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
4402 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
4403 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
4404 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
4405 } else {
4406 RLOGE("getCurrentCallsResponse Invalid response: NULL");
4407 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4408 }
4409
4410 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
4411 responseInfo, info);
4412 radioService[slotId]->checkReturnStatus(retStatus);
4413 } else {
4414 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
4415 slotId);
4416 }
4417
4418 return 0;
4419}
4420
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004421int radio_1_5::getSignalStrengthResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004422 int responseType, int serial, RIL_Errno e,
4423 void *response, size_t responseLen) {
4424#if VDBG
4425 RLOGD("getSignalStrengthResponse: serial %d", serial);
4426#endif
4427
paulye8d2d9452019-02-25 15:17:16 -08004428 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
4429 RadioResponseInfo responseInfo = {};
4430 populateResponseInfo(responseInfo, serial, responseType, e);
4431 SignalStrength signalStrength = {};
4432 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
4433 RLOGE("getSignalStrengthResponse: Invalid response");
4434 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4435 } else {
4436 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
4437 }
4438
4439 ::android::hardware::radio::V1_4::SignalStrength signalStrength_1_4;
4440 signalStrength_1_4.gsm = signalStrength.gw;
4441 signalStrength_1_4.cdma = signalStrength.cdma;
4442 signalStrength_1_4.evdo = signalStrength.evdo;
4443 signalStrength_1_4.lte = signalStrength.lte;
4444 //TODO: future implementation needs to fill tdScdma, wcdma and nr signal strength.
4445
4446 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4->
4447 getSignalStrengthResponse_1_4(responseInfo, signalStrength_1_4);
4448 radioService[slotId]->checkReturnStatus(retStatus);
4449 } else if (radioService[slotId]->mRadioResponse != NULL) {
paulye91d34712019-02-07 19:02:02 -08004450 RadioResponseInfo responseInfo = {};
4451 populateResponseInfo(responseInfo, serial, responseType, e);
4452 SignalStrength signalStrength = {};
4453 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
4454 RLOGE("getSignalStrengthResponse: Invalid response");
4455 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4456 } else {
4457 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
4458 }
4459
4460 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
4461 responseInfo, signalStrength);
4462 radioService[slotId]->checkReturnStatus(retStatus);
4463 } else {
4464 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
4465 slotId);
4466 }
4467
4468 return 0;
4469}
4470
4471RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
4472 if (rat == NULL) {
4473 return RIL_CELL_INFO_TYPE_NONE;
4474 }
4475
4476 int radioTech = atoi(rat);
4477
4478 switch(radioTech) {
4479
4480 case RADIO_TECH_GPRS:
4481 case RADIO_TECH_EDGE:
4482 case RADIO_TECH_GSM: {
4483 return RIL_CELL_INFO_TYPE_GSM;
4484 }
4485
4486 case RADIO_TECH_UMTS:
4487 case RADIO_TECH_HSDPA:
4488 case RADIO_TECH_HSUPA:
4489 case RADIO_TECH_HSPA:
4490 case RADIO_TECH_HSPAP: {
4491 return RIL_CELL_INFO_TYPE_WCDMA;
4492 }
4493
4494 case RADIO_TECH_IS95A:
4495 case RADIO_TECH_IS95B:
4496 case RADIO_TECH_1xRTT:
4497 case RADIO_TECH_EVDO_0:
4498 case RADIO_TECH_EVDO_A:
4499 case RADIO_TECH_EVDO_B:
4500 case RADIO_TECH_EHRPD: {
4501 return RIL_CELL_INFO_TYPE_CDMA;
4502 }
4503
4504 case RADIO_TECH_LTE:
4505 case RADIO_TECH_LTE_CA: {
4506 return RIL_CELL_INFO_TYPE_LTE;
4507 }
4508
4509 case RADIO_TECH_TD_SCDMA: {
4510 return RIL_CELL_INFO_TYPE_TD_SCDMA;
4511 }
4512
4513 default: {
4514 break;
4515 }
4516 }
4517
4518 return RIL_CELL_INFO_TYPE_NONE;
4519
4520}
4521
4522void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
4523
4524 cellIdentity.cellIdentityGsm.resize(0);
4525 cellIdentity.cellIdentityWcdma.resize(0);
4526 cellIdentity.cellIdentityCdma.resize(0);
4527 cellIdentity.cellIdentityTdscdma.resize(0);
4528 cellIdentity.cellIdentityLte.resize(0);
4529 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
4530 switch(rilCellIdentity.cellInfoType) {
4531
4532 case RIL_CELL_INFO_TYPE_GSM: {
4533 cellIdentity.cellIdentityGsm.resize(1);
4534 cellIdentity.cellIdentityGsm[0].mcc =
4535 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
4536 cellIdentity.cellIdentityGsm[0].mnc =
4537 ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
4538 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
4539 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
4540 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
4541 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
4542 break;
4543 }
4544
4545 case RIL_CELL_INFO_TYPE_WCDMA: {
4546 cellIdentity.cellIdentityWcdma.resize(1);
4547 cellIdentity.cellIdentityWcdma[0].mcc =
4548 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
4549 cellIdentity.cellIdentityWcdma[0].mnc =
4550 ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
4551 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
4552 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
4553 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
4554 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
4555 break;
4556 }
4557
4558 case RIL_CELL_INFO_TYPE_CDMA: {
4559 cellIdentity.cellIdentityCdma.resize(1);
4560 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
4561 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
4562 cellIdentity.cellIdentityCdma[0].baseStationId =
4563 rilCellIdentity.cellIdentityCdma.basestationId;
4564 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
4565 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
4566 break;
4567 }
4568
4569 case RIL_CELL_INFO_TYPE_LTE: {
4570 cellIdentity.cellIdentityLte.resize(1);
4571 cellIdentity.cellIdentityLte[0].mcc =
4572 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
4573 cellIdentity.cellIdentityLte[0].mnc =
4574 ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
4575 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
4576 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
4577 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
4578 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
4579 break;
4580 }
4581
4582 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
4583 cellIdentity.cellIdentityTdscdma.resize(1);
4584 cellIdentity.cellIdentityTdscdma[0].mcc =
4585 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
4586 cellIdentity.cellIdentityTdscdma[0].mnc =
4587 ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
4588 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
4589 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
4590 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
4591 break;
4592 }
4593
4594 default: {
4595 break;
4596 }
4597 }
4598}
4599
4600int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
4601 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
4602 return atoi(response[index]);
4603 }
4604
4605 return -1;
4606}
4607
4608int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
4609 const int hexBase = 16;
4610 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
4611 return strtol(response[index], NULL, hexBase);
4612 }
4613
4614 return -1;
4615}
4616
4617/* Fill Cell Identity info from Voice Registration State Response.
4618 * This fucntion is applicable only for RIL Version < 15.
4619 * Response is a "char **".
4620 * First and Second entries are in hex string format
4621 * and rest are integers represented in ascii format. */
4622void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
4623 int numStrings, char** response) {
4624
4625 RIL_CellIdentity_v16 rilCellIdentity;
4626 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
4627
4628 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
4629 switch(rilCellIdentity.cellInfoType) {
4630
4631 case RIL_CELL_INFO_TYPE_GSM: {
4632 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
4633 rilCellIdentity.cellIdentityGsm.lac =
4634 convertResponseHexStringEntryToInt(response, 1, numStrings);
4635
4636 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
4637 rilCellIdentity.cellIdentityGsm.cid =
4638 convertResponseHexStringEntryToInt(response, 2, numStrings);
4639 break;
4640 }
4641
4642 case RIL_CELL_INFO_TYPE_WCDMA: {
4643 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
4644 rilCellIdentity.cellIdentityWcdma.lac =
4645 convertResponseHexStringEntryToInt(response, 1, numStrings);
4646
4647 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
4648 rilCellIdentity.cellIdentityWcdma.cid =
4649 convertResponseHexStringEntryToInt(response, 2, numStrings);
4650 rilCellIdentity.cellIdentityWcdma.psc =
4651 convertResponseStringEntryToInt(response, 14, numStrings);
4652 break;
4653 }
4654
4655 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
4656 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
4657 rilCellIdentity.cellIdentityTdscdma.lac =
4658 convertResponseHexStringEntryToInt(response, 1, numStrings);
4659
4660 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
4661 rilCellIdentity.cellIdentityTdscdma.cid =
4662 convertResponseHexStringEntryToInt(response, 2, numStrings);
4663 break;
4664 }
4665
4666 case RIL_CELL_INFO_TYPE_CDMA:{
4667 rilCellIdentity.cellIdentityCdma.basestationId =
4668 convertResponseStringEntryToInt(response, 4, numStrings);
4669 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
4670 rilCellIdentity.cellIdentityCdma.latitude =
4671 convertResponseStringEntryToInt(response, 5, numStrings);
4672 rilCellIdentity.cellIdentityCdma.longitude =
4673 convertResponseStringEntryToInt(response, 6, numStrings);
4674 rilCellIdentity.cellIdentityCdma.systemId =
4675 convertResponseStringEntryToInt(response, 8, numStrings);
4676 rilCellIdentity.cellIdentityCdma.networkId =
4677 convertResponseStringEntryToInt(response, 9, numStrings);
4678 break;
4679 }
4680
4681 case RIL_CELL_INFO_TYPE_LTE:{
4682 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
4683 rilCellIdentity.cellIdentityLte.tac =
4684 convertResponseHexStringEntryToInt(response, 1, numStrings);
4685
4686 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
4687 rilCellIdentity.cellIdentityLte.ci =
4688 convertResponseHexStringEntryToInt(response, 2, numStrings);
4689 break;
4690 }
4691
4692 default: {
4693 break;
4694 }
4695 }
4696
4697 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
4698}
4699
4700/* Fill Cell Identity info from Data Registration State Response.
4701 * This fucntion is applicable only for RIL Version < 15.
4702 * Response is a "char **".
4703 * First and Second entries are in hex string format
4704 * and rest are integers represented in ascii format. */
4705void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
4706 int numStrings, char** response) {
4707
4708 RIL_CellIdentity_v16 rilCellIdentity;
4709 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
4710
4711 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
4712 switch(rilCellIdentity.cellInfoType) {
4713 case RIL_CELL_INFO_TYPE_GSM: {
4714 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
4715 rilCellIdentity.cellIdentityGsm.lac =
4716 convertResponseHexStringEntryToInt(response, 1, numStrings);
4717
4718 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
4719 rilCellIdentity.cellIdentityGsm.cid =
4720 convertResponseHexStringEntryToInt(response, 2, numStrings);
4721 break;
4722 }
4723 case RIL_CELL_INFO_TYPE_WCDMA: {
4724 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
4725 rilCellIdentity.cellIdentityWcdma.lac =
4726 convertResponseHexStringEntryToInt(response, 1, numStrings);
4727
4728 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
4729 rilCellIdentity.cellIdentityWcdma.cid =
4730 convertResponseHexStringEntryToInt(response, 2, numStrings);
4731 break;
4732 }
4733 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
4734 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
4735 rilCellIdentity.cellIdentityTdscdma.lac =
4736 convertResponseHexStringEntryToInt(response, 1, numStrings);
4737
4738 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
4739 rilCellIdentity.cellIdentityTdscdma.cid =
4740 convertResponseHexStringEntryToInt(response, 2, numStrings);
4741 break;
4742 }
4743 case RIL_CELL_INFO_TYPE_LTE: {
4744 rilCellIdentity.cellIdentityLte.tac =
4745 convertResponseStringEntryToInt(response, 6, numStrings);
4746 rilCellIdentity.cellIdentityLte.pci =
4747 convertResponseStringEntryToInt(response, 7, numStrings);
4748 rilCellIdentity.cellIdentityLte.ci =
4749 convertResponseStringEntryToInt(response, 8, numStrings);
4750 break;
4751 }
4752 default: {
4753 break;
4754 }
4755 }
4756
4757 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
4758}
4759
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004760int radio_1_5::getVoiceRegistrationStateResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004761 int responseType, int serial, RIL_Errno e,
4762 void *response, size_t responseLen) {
4763#if VDBG
4764 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
4765#endif
4766
4767 if (radioService[slotId]->mRadioResponse != NULL) {
4768 RadioResponseInfo responseInfo = {};
4769 populateResponseInfo(responseInfo, serial, responseType, e);
4770
4771 VoiceRegStateResult voiceRegResponse = {};
4772 int numStrings = responseLen / sizeof(char *);
4773 if (response == NULL) {
4774 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
4775 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4776 } else if (s_vendorFunctions->version <= 14) {
4777 if (numStrings != 15) {
4778 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
4779 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4780 } else {
4781 char **resp = (char **) response;
4782 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
4783 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
4784 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
4785 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
4786 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
4787 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
4788 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
4789 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
4790 numStrings, resp);
4791 }
4792 } else {
4793 RIL_VoiceRegistrationStateResponse *voiceRegState =
4794 (RIL_VoiceRegistrationStateResponse *)response;
4795
4796 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
4797 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
4798 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4799 } else {
4800 voiceRegResponse.regState = (RegState) voiceRegState->regState;
4801 voiceRegResponse.rat = voiceRegState->rat;;
4802 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
4803 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
4804 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
4805 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
4806 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
4807 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
4808 voiceRegState->cellIdentity);
4809 }
4810 }
4811
4812 Return<void> retStatus =
4813 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
4814 responseInfo, voiceRegResponse);
4815 radioService[slotId]->checkReturnStatus(retStatus);
4816 } else {
4817 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
4818 slotId);
4819 }
4820
4821 return 0;
4822}
4823
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004824int radio_1_5::getDataRegistrationStateResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004825 int responseType, int serial, RIL_Errno e,
4826 void *response, size_t responseLen) {
4827#if VDBG
4828 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
4829#endif
4830
4831 if (radioService[slotId]->mRadioResponse != NULL) {
4832 RadioResponseInfo responseInfo = {};
4833 populateResponseInfo(responseInfo, serial, responseType, e);
4834 DataRegStateResult dataRegResponse = {};
4835 if (response == NULL) {
4836 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
4837 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4838 } else if (s_vendorFunctions->version <= 14) {
4839 int numStrings = responseLen / sizeof(char *);
4840 if ((numStrings != 6) && (numStrings != 11)) {
4841 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
4842 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4843 } else {
4844 char **resp = (char **) response;
4845 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
4846 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
4847 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
4848 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
4849 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
4850 numStrings, resp);
4851 }
4852 } else {
4853 RIL_DataRegistrationStateResponse *dataRegState =
4854 (RIL_DataRegistrationStateResponse *)response;
4855
4856 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
4857 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
4858 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4859 } else {
4860 dataRegResponse.regState = (RegState) dataRegState->regState;
Nathan Harold229840b2020-01-17 19:12:37 -08004861 dataRegResponse.rat = dataRegState->rat;
paulye91d34712019-02-07 19:02:02 -08004862 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
4863 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
4864 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
4865 }
4866 }
4867
4868 Return<void> retStatus =
Nathan Harold229840b2020-01-17 19:12:37 -08004869 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(
4870 responseInfo, dataRegResponse);
paulye91d34712019-02-07 19:02:02 -08004871 radioService[slotId]->checkReturnStatus(retStatus);
4872 } else {
4873 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
4874 slotId);
4875 }
4876
4877 return 0;
4878}
4879
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004880int radio_1_5::getOperatorResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004881 int responseType, int serial, RIL_Errno e, void *response,
4882 size_t responseLen) {
4883#if VDBG
4884 RLOGD("getOperatorResponse: serial %d", serial);
4885#endif
4886
4887 if (radioService[slotId]->mRadioResponse != NULL) {
4888 RadioResponseInfo responseInfo = {};
4889 populateResponseInfo(responseInfo, serial, responseType, e);
4890 hidl_string longName;
4891 hidl_string shortName;
4892 hidl_string numeric;
4893 int numStrings = responseLen / sizeof(char *);
4894 if (response == NULL || numStrings != 3) {
4895 RLOGE("getOperatorResponse Invalid response: NULL");
4896 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4897
4898 } else {
4899 char **resp = (char **) response;
4900 longName = convertCharPtrToHidlString(resp[0]);
4901 shortName = convertCharPtrToHidlString(resp[1]);
4902 numeric = convertCharPtrToHidlString(resp[2]);
4903 }
4904 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
4905 responseInfo, longName, shortName, numeric);
4906 radioService[slotId]->checkReturnStatus(retStatus);
4907 } else {
4908 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
4909 slotId);
4910 }
4911
4912 return 0;
4913}
4914
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004915int radio_1_5::setRadioPowerResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004916 int responseType, int serial, RIL_Errno e, void *response,
4917 size_t responseLen) {
Sarah Chinef7f9222020-01-30 10:37:08 -08004918#if VDBG
paulye91d34712019-02-07 19:02:02 -08004919 RLOGD("setRadioPowerResponse: serial %d", serial);
Sarah Chinef7f9222020-01-30 10:37:08 -08004920#endif
4921 RadioResponseInfo responseInfo = {};
4922 populateResponseInfo(responseInfo, serial, responseType, e);
paulye91d34712019-02-07 19:02:02 -08004923
Sarah Chinef7f9222020-01-30 10:37:08 -08004924 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
4925 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
4926 ->setRadioPowerResponse_1_5(responseInfo);
4927 radioService[slotId]->checkReturnStatus(retStatus);
4928 } else if (radioService[slotId]->mRadioResponse != NULL) {
4929 Return<void> retStatus = radioService[slotId]->mRadioResponse
4930 ->setRadioPowerResponse(responseInfo);
paulye91d34712019-02-07 19:02:02 -08004931 radioService[slotId]->checkReturnStatus(retStatus);
4932 } else {
Sarah Chinef7f9222020-01-30 10:37:08 -08004933 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
paulye91d34712019-02-07 19:02:02 -08004934 }
4935
4936 return 0;
4937}
4938
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004939int radio_1_5::sendDtmfResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004940 int responseType, int serial, RIL_Errno e, void *response,
4941 size_t responseLen) {
4942#if VDBG
4943 RLOGD("sendDtmfResponse: serial %d", serial);
4944#endif
4945
4946 if (radioService[slotId]->mRadioResponse != NULL) {
4947 RadioResponseInfo responseInfo = {};
4948 populateResponseInfo(responseInfo, serial, responseType, e);
4949 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
4950 responseInfo);
4951 radioService[slotId]->checkReturnStatus(retStatus);
4952 } else {
4953 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
4954 slotId);
4955 }
4956
4957 return 0;
4958}
4959
4960SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
4961 RIL_Errno e, void *response, size_t responseLen) {
4962 populateResponseInfo(responseInfo, serial, responseType, e);
4963 SendSmsResult result = {};
4964
4965 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
4966 RLOGE("Invalid response: NULL");
4967 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4968 result.ackPDU = hidl_string();
4969 } else {
4970 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
4971 result.messageRef = resp->messageRef;
4972 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
4973 result.errorCode = resp->errorCode;
4974 }
4975 return result;
4976}
4977
Malcolm Chen6b9984e2019-10-10 14:44:58 -07004978int radio_1_5::sendSmsResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08004979 int responseType, int serial, RIL_Errno e, void *response,
4980 size_t responseLen) {
4981#if VDBG
4982 RLOGD("sendSmsResponse: serial %d", serial);
4983#endif
4984
4985 if (radioService[slotId]->mRadioResponse != NULL) {
4986 RadioResponseInfo responseInfo = {};
4987 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4988 responseLen);
4989
4990 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
4991 result);
4992 radioService[slotId]->checkReturnStatus(retStatus);
4993 } else {
4994 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4995 }
4996
4997 return 0;
4998}
4999
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005000int radio_1_5::sendSMSExpectMoreResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005001 int responseType, int serial, RIL_Errno e, void *response,
5002 size_t responseLen) {
5003#if VDBG
5004 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
5005#endif
5006
5007 if (radioService[slotId]->mRadioResponse != NULL) {
5008 RadioResponseInfo responseInfo = {};
5009 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5010 responseLen);
5011
5012 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
5013 responseInfo, result);
5014 radioService[slotId]->checkReturnStatus(retStatus);
5015 } else {
5016 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5017 }
5018
5019 return 0;
5020}
5021
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005022int radio_1_5::setupDataCallResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005023 int responseType, int serial, RIL_Errno e, void *response,
5024 size_t responseLen) {
5025#if VDBG
5026 RLOGD("setupDataCallResponse: serial %d", serial);
5027#endif
Sarah Chin75b299c2019-12-11 10:57:28 -08005028 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
paulye91d34712019-02-07 19:02:02 -08005029 RadioResponseInfo responseInfo = {};
5030 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yufd2ea3f2019-12-14 10:43:41 -08005031 ::android::hardware::radio::V1_5::SetupDataCallResult result;
paulye91d34712019-02-07 19:02:02 -08005032 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
5033 if (response != NULL) {
Sarah Chin75b299c2019-12-11 10:57:28 -08005034 RLOGE("setupDataCallResponse_1_5: Invalid response");
5035 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5036 }
5037 result.cause = ::android::hardware::radio::V1_4::DataCallFailCause::ERROR_UNSPECIFIED;
5038 result.type = ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
5039 result.ifname = hidl_string();
Jack Yufd2ea3f2019-12-14 10:43:41 -08005040 result.addresses = hidl_vec<::android::hardware::radio::V1_5::LinkAddress>();
Sarah Chin75b299c2019-12-11 10:57:28 -08005041 result.dnses = hidl_vec<hidl_string>();
5042 result.gateways = hidl_vec<hidl_string>();
5043 result.pcscf = hidl_vec<hidl_string>();
5044 } else {
Sarah Chin9ecfc322020-01-16 10:35:02 -08005045 convertRilDataCallToHal((RIL_Data_Call_Response_v12 *) response, result);
Sarah Chin75b299c2019-12-11 10:57:28 -08005046 }
5047
5048 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5->setupDataCallResponse_1_5(
5049 responseInfo, result);
5050 radioService[slotId]->checkReturnStatus(retStatus);
5051 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
5052 RadioResponseInfo responseInfo = {};
5053 populateResponseInfo(responseInfo, serial, responseType, e);
5054 ::android::hardware::radio::V1_4::SetupDataCallResult result;
5055 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
5056 if (response != NULL) {
5057 RLOGE("setupDataCallResponse_1_4: Invalid response");
paulye91d34712019-02-07 19:02:02 -08005058 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5059 }
Jack Yud5a67ed2019-03-06 14:59:36 -08005060 result.cause = ::android::hardware::radio::V1_4::DataCallFailCause::ERROR_UNSPECIFIED;
5061 result.type = ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
paulye91d34712019-02-07 19:02:02 -08005062 result.ifname = hidl_string();
Jack Yud5a67ed2019-03-06 14:59:36 -08005063 result.addresses = hidl_vec<hidl_string>();
5064 result.dnses = hidl_vec<hidl_string>();
5065 result.gateways = hidl_vec<hidl_string>();
5066 result.pcscf = hidl_vec<hidl_string>();
paulye91d34712019-02-07 19:02:02 -08005067 } else {
5068 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
5069 }
5070
Jack Yud5a67ed2019-03-06 14:59:36 -08005071 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4->setupDataCallResponse_1_4(
paulye91d34712019-02-07 19:02:02 -08005072 responseInfo, result);
5073 radioService[slotId]->checkReturnStatus(retStatus);
Jack Yud5a67ed2019-03-06 14:59:36 -08005074 } else if (radioService[slotId]->mRadioResponse != NULL) {
5075 RadioResponseInfo responseInfo = {};
5076 populateResponseInfo(responseInfo, serial, responseType, e);
5077
5078 SetupDataCallResult result = {};
5079 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
5080 if (response != NULL) {
5081 RLOGE("setupDataCallResponse: Invalid response");
5082 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5083 }
5084 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
5085 result.type = hidl_string();
5086 result.ifname = hidl_string();
5087 result.addresses = hidl_string();
5088 result.dnses = hidl_string();
5089 result.gateways = hidl_string();
5090 result.pcscf = hidl_string();
5091 } else {
5092 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
5093 }
5094
5095 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
5096 responseInfo, result);
5097 radioService[slotId]->checkReturnStatus(retStatus);
paulye91d34712019-02-07 19:02:02 -08005098 } else {
5099 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5100 }
5101
5102 return 0;
5103}
5104
5105IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
5106 RIL_Errno e, void *response, size_t responseLen) {
5107 populateResponseInfo(responseInfo, serial, responseType, e);
5108 IccIoResult result = {};
5109
5110 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
5111 RLOGE("Invalid response: NULL");
5112 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5113 result.simResponse = hidl_string();
5114 } else {
5115 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
5116 result.sw1 = resp->sw1;
5117 result.sw2 = resp->sw2;
5118 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
5119 }
5120 return result;
5121}
5122
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005123int radio_1_5::iccIOForAppResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005124 int responseType, int serial, RIL_Errno e, void *response,
5125 size_t responseLen) {
5126#if VDBG
5127 RLOGD("iccIOForAppResponse: serial %d", serial);
5128#endif
5129
5130 if (radioService[slotId]->mRadioResponse != NULL) {
5131 RadioResponseInfo responseInfo = {};
5132 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5133 responseLen);
5134
5135 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
5136 responseInfo, result);
5137 radioService[slotId]->checkReturnStatus(retStatus);
5138 } else {
5139 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5140 }
5141
5142 return 0;
5143}
5144
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005145int radio_1_5::sendUssdResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005146 int responseType, int serial, RIL_Errno e, void *response,
5147 size_t responseLen) {
5148#if VDBG
5149 RLOGD("sendUssdResponse: serial %d", serial);
5150#endif
5151
5152 if (radioService[slotId]->mRadioResponse != NULL) {
5153 RadioResponseInfo responseInfo = {};
5154 populateResponseInfo(responseInfo, serial, responseType, e);
5155 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
5156 responseInfo);
5157 radioService[slotId]->checkReturnStatus(retStatus);
5158 } else {
5159 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
5160 slotId);
5161 }
5162
5163 return 0;
5164}
5165
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005166int radio_1_5::cancelPendingUssdResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005167 int responseType, int serial, RIL_Errno e, void *response,
5168 size_t responseLen) {
5169#if VDBG
5170 RLOGD("cancelPendingUssdResponse: serial %d", serial);
5171#endif
5172
5173 if (radioService[slotId]->mRadioResponse != NULL) {
5174 RadioResponseInfo responseInfo = {};
5175 populateResponseInfo(responseInfo, serial, responseType, e);
5176 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
5177 responseInfo);
5178 radioService[slotId]->checkReturnStatus(retStatus);
5179 } else {
5180 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
5181 slotId);
5182 }
5183
5184 return 0;
5185}
5186
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005187int radio_1_5::getClirResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005188 int responseType, int serial, RIL_Errno e, void *response,
5189 size_t responseLen) {
5190#if VDBG
5191 RLOGD("getClirResponse: serial %d", serial);
5192#endif
5193
5194 if (radioService[slotId]->mRadioResponse != NULL) {
5195 RadioResponseInfo responseInfo = {};
5196 populateResponseInfo(responseInfo, serial, responseType, e);
5197 int n = -1, m = -1;
5198 int numInts = responseLen / sizeof(int);
5199 if (response == NULL || numInts != 2) {
5200 RLOGE("getClirResponse Invalid response: NULL");
5201 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5202 } else {
5203 int *pInt = (int *) response;
5204 n = pInt[0];
5205 m = pInt[1];
5206 }
5207 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
5208 n, m);
5209 radioService[slotId]->checkReturnStatus(retStatus);
5210 } else {
5211 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5212 }
5213
5214 return 0;
5215}
5216
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005217int radio_1_5::setClirResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005218 int responseType, int serial, RIL_Errno e, void *response,
5219 size_t responseLen) {
5220#if VDBG
5221 RLOGD("setClirResponse: serial %d", serial);
5222#endif
5223
5224 if (radioService[slotId]->mRadioResponse != NULL) {
5225 RadioResponseInfo responseInfo = {};
5226 populateResponseInfo(responseInfo, serial, responseType, e);
5227 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
5228 responseInfo);
5229 radioService[slotId]->checkReturnStatus(retStatus);
5230 } else {
5231 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5232 }
5233
5234 return 0;
5235}
5236
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005237int radio_1_5::getCallForwardStatusResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005238 int responseType, int serial, RIL_Errno e,
5239 void *response, size_t responseLen) {
5240#if VDBG
5241 RLOGD("getCallForwardStatusResponse: serial %d", serial);
5242#endif
5243
5244 if (radioService[slotId]->mRadioResponse != NULL) {
5245 RadioResponseInfo responseInfo = {};
5246 populateResponseInfo(responseInfo, serial, responseType, e);
5247 hidl_vec<CallForwardInfo> callForwardInfos;
5248
5249 if ((response == NULL && responseLen != 0)
5250 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
5251 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
5252 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5253 } else {
5254 int num = responseLen / sizeof(RIL_CallForwardInfo *);
5255 callForwardInfos.resize(num);
5256 for (int i = 0 ; i < num; i++) {
5257 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
5258 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
5259 callForwardInfos[i].reason = resp->reason;
5260 callForwardInfos[i].serviceClass = resp->serviceClass;
5261 callForwardInfos[i].toa = resp->toa;
5262 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
5263 callForwardInfos[i].timeSeconds = resp->timeSeconds;
5264 }
5265 }
5266
5267 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
5268 responseInfo, callForwardInfos);
5269 radioService[slotId]->checkReturnStatus(retStatus);
5270 } else {
5271 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
5272 slotId);
5273 }
5274
5275 return 0;
5276}
5277
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005278int radio_1_5::setCallForwardResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005279 int responseType, int serial, RIL_Errno e, void *response,
5280 size_t responseLen) {
5281#if VDBG
5282 RLOGD("setCallForwardResponse: serial %d", serial);
5283#endif
5284
5285 if (radioService[slotId]->mRadioResponse != NULL) {
5286 RadioResponseInfo responseInfo = {};
5287 populateResponseInfo(responseInfo, serial, responseType, e);
5288 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
5289 responseInfo);
5290 radioService[slotId]->checkReturnStatus(retStatus);
5291 } else {
5292 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5293 }
5294
5295 return 0;
5296}
5297
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005298int radio_1_5::getCallWaitingResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005299 int responseType, int serial, RIL_Errno e, void *response,
5300 size_t responseLen) {
5301#if VDBG
5302 RLOGD("getCallWaitingResponse: serial %d", serial);
5303#endif
5304
5305 if (radioService[slotId]->mRadioResponse != NULL) {
5306 RadioResponseInfo responseInfo = {};
5307 populateResponseInfo(responseInfo, serial, responseType, e);
5308 bool enable = false;
5309 int serviceClass = -1;
5310 int numInts = responseLen / sizeof(int);
5311 if (response == NULL || numInts != 2) {
5312 RLOGE("getCallWaitingResponse Invalid response: NULL");
5313 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5314 } else {
5315 int *pInt = (int *) response;
5316 enable = pInt[0] == 1 ? true : false;
5317 serviceClass = pInt[1];
5318 }
5319 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
5320 responseInfo, enable, serviceClass);
5321 radioService[slotId]->checkReturnStatus(retStatus);
5322 } else {
5323 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5324 }
5325
5326 return 0;
5327}
5328
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005329int radio_1_5::setCallWaitingResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005330 int responseType, int serial, RIL_Errno e, void *response,
5331 size_t responseLen) {
5332#if VDBG
5333 RLOGD("setCallWaitingResponse: serial %d", serial);
5334#endif
5335
5336 if (radioService[slotId]->mRadioResponse != NULL) {
5337 RadioResponseInfo responseInfo = {};
5338 populateResponseInfo(responseInfo, serial, responseType, e);
5339 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
5340 responseInfo);
5341 radioService[slotId]->checkReturnStatus(retStatus);
5342 } else {
5343 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5344 }
5345
5346 return 0;
5347}
5348
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005349int radio_1_5::acknowledgeLastIncomingGsmSmsResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005350 int responseType, int serial, RIL_Errno e,
5351 void *response, size_t responseLen) {
5352#if VDBG
5353 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
5354#endif
5355
5356 if (radioService[slotId]->mRadioResponse != NULL) {
5357 RadioResponseInfo responseInfo = {};
5358 populateResponseInfo(responseInfo, serial, responseType, e);
5359 Return<void> retStatus =
5360 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
5361 responseInfo);
5362 radioService[slotId]->checkReturnStatus(retStatus);
5363 } else {
5364 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
5365 "== NULL", slotId);
5366 }
5367
5368 return 0;
5369}
5370
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005371int radio_1_5::acceptCallResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005372 int responseType, int serial, RIL_Errno e,
5373 void *response, size_t responseLen) {
5374#if VDBG
5375 RLOGD("acceptCallResponse: serial %d", serial);
5376#endif
5377
5378 if (radioService[slotId]->mRadioResponse != NULL) {
5379 RadioResponseInfo responseInfo = {};
5380 populateResponseInfo(responseInfo, serial, responseType, e);
5381 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
5382 responseInfo);
5383 radioService[slotId]->checkReturnStatus(retStatus);
5384 } else {
5385 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
5386 slotId);
5387 }
5388
5389 return 0;
5390}
5391
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005392int radio_1_5::deactivateDataCallResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005393 int responseType, int serial, RIL_Errno e,
5394 void *response, size_t responseLen) {
5395#if VDBG
5396 RLOGD("deactivateDataCallResponse: serial %d", serial);
5397#endif
5398
5399 if (radioService[slotId]->mRadioResponse != NULL) {
5400 RadioResponseInfo responseInfo = {};
5401 populateResponseInfo(responseInfo, serial, responseType, e);
5402 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
5403 responseInfo);
5404 radioService[slotId]->checkReturnStatus(retStatus);
5405 } else {
5406 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
5407 slotId);
5408 }
5409
5410 return 0;
5411}
5412
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005413int radio_1_5::getFacilityLockForAppResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005414 int responseType, int serial, RIL_Errno e,
5415 void *response, size_t responseLen) {
5416#if VDBG
5417 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
5418#endif
5419
5420 if (radioService[slotId]->mRadioResponse != NULL) {
5421 RadioResponseInfo responseInfo = {};
5422 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5423 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5424 getFacilityLockForAppResponse(responseInfo, ret);
5425 radioService[slotId]->checkReturnStatus(retStatus);
5426 } else {
5427 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
5428 slotId);
5429 }
5430
5431 return 0;
5432}
5433
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005434int radio_1_5::setFacilityLockForAppResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005435 int responseType, int serial, RIL_Errno e,
5436 void *response, size_t responseLen) {
5437#if VDBG
5438 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
5439#endif
5440
5441 if (radioService[slotId]->mRadioResponse != NULL) {
5442 RadioResponseInfo responseInfo = {};
5443 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
5444 Return<void> retStatus
5445 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
5446 ret);
5447 radioService[slotId]->checkReturnStatus(retStatus);
5448 } else {
5449 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
5450 slotId);
5451 }
5452
5453 return 0;
5454}
5455
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005456int radio_1_5::setBarringPasswordResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005457 int responseType, int serial, RIL_Errno e,
5458 void *response, size_t responseLen) {
5459#if VDBG
5460 RLOGD("acceptCallResponse: serial %d", serial);
5461#endif
5462
5463 if (radioService[slotId]->mRadioResponse != NULL) {
5464 RadioResponseInfo responseInfo = {};
5465 populateResponseInfo(responseInfo, serial, responseType, e);
5466 Return<void> retStatus
5467 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
5468 radioService[slotId]->checkReturnStatus(retStatus);
5469 } else {
5470 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
5471 slotId);
5472 }
5473
5474 return 0;
5475}
5476
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005477int radio_1_5::getNetworkSelectionModeResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005478 int responseType, int serial, RIL_Errno e, void *response,
5479 size_t responseLen) {
5480#if VDBG
5481 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
5482#endif
5483
5484 if (radioService[slotId]->mRadioResponse != NULL) {
5485 RadioResponseInfo responseInfo = {};
5486 populateResponseInfo(responseInfo, serial, responseType, e);
5487 bool manual = false;
5488 if (response == NULL || responseLen != sizeof(int)) {
5489 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
5490 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5491 } else {
5492 int *pInt = (int *) response;
5493 manual = pInt[0] == 1 ? true : false;
5494 }
5495 Return<void> retStatus
5496 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
5497 responseInfo,
5498 manual);
5499 radioService[slotId]->checkReturnStatus(retStatus);
5500 } else {
5501 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
5502 slotId);
5503 }
5504
5505 return 0;
5506}
5507
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005508int radio_1_5::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
paulye91d34712019-02-07 19:02:02 -08005509 RIL_Errno e, void *response,
5510 size_t responseLen) {
5511#if VDBG
5512 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
5513#endif
5514
5515 if (radioService[slotId]->mRadioResponse != NULL) {
5516 RadioResponseInfo responseInfo = {};
5517 populateResponseInfo(responseInfo, serial, responseType, e);
5518 Return<void> retStatus
5519 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
5520 responseInfo);
5521 radioService[slotId]->checkReturnStatus(retStatus);
5522 } else {
5523 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
5524 "== NULL", slotId);
5525 }
5526
5527 return 0;
5528}
5529
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005530int radio_1_5::setNetworkSelectionModeManualResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005531 int responseType, int serial, RIL_Errno e,
5532 void *response, size_t responseLen) {
5533#if VDBG
5534 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
5535#endif
Sarah Chinef7f9222020-01-30 10:37:08 -08005536 RadioResponseInfo responseInfo = {};
5537 populateResponseInfo(responseInfo, serial, responseType, e);
paulye91d34712019-02-07 19:02:02 -08005538
Sarah Chinef7f9222020-01-30 10:37:08 -08005539 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
5540 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
5541 ->setNetworkSelectionModeManualResponse_1_5(responseInfo);
5542 radioService[slotId]->checkReturnStatus(retStatus);
5543 } else if (radioService[slotId]->mRadioResponse != NULL) {
5544 Return<void> retStatus = radioService[slotId]->mRadioResponse
5545 ->setNetworkSelectionModeManualResponse(responseInfo);
paulye91d34712019-02-07 19:02:02 -08005546 radioService[slotId]->checkReturnStatus(retStatus);
5547 } else {
5548 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
5549 "== NULL", slotId);
5550 }
5551
5552 return 0;
5553}
5554
5555int convertOperatorStatusToInt(const char *str) {
5556 if (strncmp("unknown", str, 9) == 0) {
5557 return (int) OperatorStatus::UNKNOWN;
5558 } else if (strncmp("available", str, 9) == 0) {
5559 return (int) OperatorStatus::AVAILABLE;
5560 } else if (strncmp("current", str, 9) == 0) {
5561 return (int) OperatorStatus::CURRENT;
5562 } else if (strncmp("forbidden", str, 9) == 0) {
5563 return (int) OperatorStatus::FORBIDDEN;
5564 } else {
5565 return -1;
5566 }
5567}
5568
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005569int radio_1_5::getAvailableNetworksResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005570 int responseType, int serial, RIL_Errno e, void *response,
5571 size_t responseLen) {
5572#if VDBG
5573 RLOGD("getAvailableNetworksResponse: serial %d", serial);
5574#endif
5575
5576 if (radioService[slotId]->mRadioResponse != NULL) {
5577 RadioResponseInfo responseInfo = {};
5578 populateResponseInfo(responseInfo, serial, responseType, e);
5579 hidl_vec<OperatorInfo> networks;
5580 if ((response == NULL && responseLen != 0)
5581 || responseLen % (4 * sizeof(char *))!= 0) {
5582 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
5583 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5584 } else {
5585 char **resp = (char **) response;
5586 int numStrings = responseLen / sizeof(char *);
5587 networks.resize(numStrings/4);
5588 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
5589 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
5590 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
5591 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
5592 int status = convertOperatorStatusToInt(resp[i + 3]);
5593 if (status == -1) {
5594 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5595 } else {
5596 networks[j].status = (OperatorStatus) status;
5597 }
5598 }
5599 }
5600 Return<void> retStatus
5601 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
5602 networks);
5603 radioService[slotId]->checkReturnStatus(retStatus);
5604 } else {
5605 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
5606 slotId);
5607 }
5608
5609 return 0;
5610}
5611
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005612int radio_1_5::startDtmfResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005613 int responseType, int serial, RIL_Errno e,
5614 void *response, size_t responseLen) {
5615#if VDBG
5616 RLOGD("startDtmfResponse: serial %d", serial);
5617#endif
5618
5619 if (radioService[slotId]->mRadioResponse != NULL) {
5620 RadioResponseInfo responseInfo = {};
5621 populateResponseInfo(responseInfo, serial, responseType, e);
5622 Return<void> retStatus
5623 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
5624 radioService[slotId]->checkReturnStatus(retStatus);
5625 } else {
5626 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5627 }
5628
5629 return 0;
5630}
5631
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005632int radio_1_5::stopDtmfResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005633 int responseType, int serial, RIL_Errno e,
5634 void *response, size_t responseLen) {
5635#if VDBG
5636 RLOGD("stopDtmfResponse: serial %d", serial);
5637#endif
5638
5639 if (radioService[slotId]->mRadioResponse != NULL) {
5640 RadioResponseInfo responseInfo = {};
5641 populateResponseInfo(responseInfo, serial, responseType, e);
5642 Return<void> retStatus
5643 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
5644 radioService[slotId]->checkReturnStatus(retStatus);
5645 } else {
5646 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5647 }
5648
5649 return 0;
5650}
5651
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005652int radio_1_5::getBasebandVersionResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005653 int responseType, int serial, RIL_Errno e,
5654 void *response, size_t responseLen) {
5655#if VDBG
5656 RLOGD("getBasebandVersionResponse: serial %d", serial);
5657#endif
5658
5659 if (radioService[slotId]->mRadioResponse != NULL) {
5660 RadioResponseInfo responseInfo = {};
5661 populateResponseInfo(responseInfo, serial, responseType, e);
5662 Return<void> retStatus
5663 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
5664 convertCharPtrToHidlString((char *) response));
5665 radioService[slotId]->checkReturnStatus(retStatus);
5666 } else {
5667 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5668 }
5669
5670 return 0;
5671}
5672
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005673int radio_1_5::separateConnectionResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005674 int responseType, int serial, RIL_Errno e,
5675 void *response, size_t responseLen) {
5676#if VDBG
5677 RLOGD("separateConnectionResponse: serial %d", serial);
5678#endif
5679
5680 if (radioService[slotId]->mRadioResponse != NULL) {
5681 RadioResponseInfo responseInfo = {};
5682 populateResponseInfo(responseInfo, serial, responseType, e);
5683 Return<void> retStatus
5684 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
5685 radioService[slotId]->checkReturnStatus(retStatus);
5686 } else {
5687 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
5688 slotId);
5689 }
5690
5691 return 0;
5692}
5693
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005694int radio_1_5::setMuteResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005695 int responseType, int serial, RIL_Errno e,
5696 void *response, size_t responseLen) {
5697#if VDBG
5698 RLOGD("setMuteResponse: serial %d", serial);
5699#endif
5700
5701 if (radioService[slotId]->mRadioResponse != NULL) {
5702 RadioResponseInfo responseInfo = {};
5703 populateResponseInfo(responseInfo, serial, responseType, e);
5704 Return<void> retStatus
5705 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
5706 radioService[slotId]->checkReturnStatus(retStatus);
5707 } else {
5708 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5709 }
5710
5711 return 0;
5712}
5713
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005714int radio_1_5::getMuteResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005715 int responseType, int serial, RIL_Errno e, void *response,
5716 size_t responseLen) {
5717#if VDBG
5718 RLOGD("getMuteResponse: serial %d", serial);
5719#endif
5720
5721 if (radioService[slotId]->mRadioResponse != NULL) {
5722 RadioResponseInfo responseInfo = {};
5723 populateResponseInfo(responseInfo, serial, responseType, e);
5724 bool enable = false;
5725 if (response == NULL || responseLen != sizeof(int)) {
5726 RLOGE("getMuteResponse Invalid response: NULL");
5727 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5728 } else {
5729 int *pInt = (int *) response;
5730 enable = pInt[0] == 1 ? true : false;
5731 }
5732 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
5733 enable);
5734 radioService[slotId]->checkReturnStatus(retStatus);
5735 } else {
5736 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5737 }
5738
5739 return 0;
5740}
5741
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005742int radio_1_5::getClipResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005743 int responseType, int serial, RIL_Errno e,
5744 void *response, size_t responseLen) {
5745#if VDBG
5746 RLOGD("getClipResponse: serial %d", serial);
5747#endif
5748
5749 if (radioService[slotId]->mRadioResponse != NULL) {
5750 RadioResponseInfo responseInfo = {};
5751 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5752 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
5753 (ClipStatus) ret);
5754 radioService[slotId]->checkReturnStatus(retStatus);
5755 } else {
5756 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5757 }
5758
5759 return 0;
5760}
5761
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005762int radio_1_5::getDataCallListResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005763 int responseType, int serial, RIL_Errno e,
5764 void *response, size_t responseLen) {
5765#if VDBG
5766 RLOGD("getDataCallListResponse: serial %d", serial);
5767#endif
5768
5769 if (radioService[slotId]->mRadioResponse != NULL) {
5770 RadioResponseInfo responseInfo = {};
5771 populateResponseInfo(responseInfo, serial, responseType, e);
5772
5773 hidl_vec<SetupDataCallResult> ret;
5774 if ((response == NULL && responseLen != 0)
5775 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
5776 RLOGE("getDataCallListResponse: invalid response");
5777 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5778 } else {
5779 convertRilDataCallListToHal(response, responseLen, ret);
5780 }
5781
5782 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
5783 responseInfo, ret);
5784 radioService[slotId]->checkReturnStatus(retStatus);
5785 } else {
5786 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5787 }
5788
5789 return 0;
5790}
5791
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005792int radio_1_5::setSuppServiceNotificationsResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005793 int responseType, int serial, RIL_Errno e,
5794 void *response, size_t responseLen) {
5795#if VDBG
5796 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
5797#endif
5798
5799 if (radioService[slotId]->mRadioResponse != NULL) {
5800 RadioResponseInfo responseInfo = {};
5801 populateResponseInfo(responseInfo, serial, responseType, e);
5802 Return<void> retStatus
5803 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
5804 responseInfo);
5805 radioService[slotId]->checkReturnStatus(retStatus);
5806 } else {
5807 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
5808 "== NULL", slotId);
5809 }
5810
5811 return 0;
5812}
5813
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005814int radio_1_5::deleteSmsOnSimResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005815 int responseType, int serial, RIL_Errno e,
5816 void *response, size_t responseLen) {
5817#if VDBG
5818 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
5819#endif
5820
5821 if (radioService[slotId]->mRadioResponse != NULL) {
5822 RadioResponseInfo responseInfo = {};
5823 populateResponseInfo(responseInfo, serial, responseType, e);
5824 Return<void> retStatus
5825 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
5826 radioService[slotId]->checkReturnStatus(retStatus);
5827 } else {
5828 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5829 }
5830
5831 return 0;
5832}
5833
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005834int radio_1_5::setBandModeResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005835 int responseType, int serial, RIL_Errno e,
5836 void *response, size_t responseLen) {
5837#if VDBG
5838 RLOGD("setBandModeResponse: serial %d", serial);
5839#endif
5840
5841 if (radioService[slotId]->mRadioResponse != NULL) {
5842 RadioResponseInfo responseInfo = {};
5843 populateResponseInfo(responseInfo, serial, responseType, e);
5844 Return<void> retStatus
5845 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
5846 radioService[slotId]->checkReturnStatus(retStatus);
5847 } else {
5848 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5849 }
5850
5851 return 0;
5852}
5853
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005854int radio_1_5::writeSmsToSimResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005855 int responseType, int serial, RIL_Errno e,
5856 void *response, size_t responseLen) {
5857#if VDBG
5858 RLOGD("writeSmsToSimResponse: serial %d", serial);
5859#endif
5860
5861 if (radioService[slotId]->mRadioResponse != NULL) {
5862 RadioResponseInfo responseInfo = {};
5863 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5864 Return<void> retStatus
5865 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
5866 radioService[slotId]->checkReturnStatus(retStatus);
5867 } else {
5868 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5869 }
5870
5871 return 0;
5872}
5873
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005874int radio_1_5::getAvailableBandModesResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005875 int responseType, int serial, RIL_Errno e, void *response,
5876 size_t responseLen) {
5877#if VDBG
5878 RLOGD("getAvailableBandModesResponse: serial %d", serial);
5879#endif
5880
5881 if (radioService[slotId]->mRadioResponse != NULL) {
5882 RadioResponseInfo responseInfo = {};
5883 populateResponseInfo(responseInfo, serial, responseType, e);
5884 hidl_vec<RadioBandMode> modes;
5885 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
5886 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
5887 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5888 } else {
5889 int *pInt = (int *) response;
5890 int numInts = responseLen / sizeof(int);
5891 modes.resize(numInts);
5892 for (int i = 0; i < numInts; i++) {
5893 modes[i] = (RadioBandMode) pInt[i];
5894 }
5895 }
5896 Return<void> retStatus
5897 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
5898 modes);
5899 radioService[slotId]->checkReturnStatus(retStatus);
5900 } else {
5901 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
5902 slotId);
5903 }
5904
5905 return 0;
5906}
5907
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005908int radio_1_5::sendEnvelopeResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005909 int responseType, int serial, RIL_Errno e,
5910 void *response, size_t responseLen) {
5911#if VDBG
5912 RLOGD("sendEnvelopeResponse: serial %d", serial);
5913#endif
5914
5915 if (radioService[slotId]->mRadioResponse != NULL) {
5916 RadioResponseInfo responseInfo = {};
5917 populateResponseInfo(responseInfo, serial, responseType, e);
5918 Return<void> retStatus
5919 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
5920 convertCharPtrToHidlString((char *) response));
5921 radioService[slotId]->checkReturnStatus(retStatus);
5922 } else {
5923 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5924 }
5925
5926 return 0;
5927}
5928
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005929int radio_1_5::sendTerminalResponseToSimResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005930 int responseType, int serial, RIL_Errno e,
5931 void *response, size_t responseLen) {
5932#if VDBG
5933 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
5934#endif
5935
5936 if (radioService[slotId]->mRadioResponse != NULL) {
5937 RadioResponseInfo responseInfo = {};
5938 populateResponseInfo(responseInfo, serial, responseType, e);
5939 Return<void> retStatus
5940 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
5941 responseInfo);
5942 radioService[slotId]->checkReturnStatus(retStatus);
5943 } else {
5944 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
5945 slotId);
5946 }
5947
5948 return 0;
5949}
5950
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005951int radio_1_5::handleStkCallSetupRequestFromSimResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005952 int responseType, int serial,
5953 RIL_Errno e, void *response,
5954 size_t responseLen) {
5955#if VDBG
5956 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
5957#endif
5958
5959 if (radioService[slotId]->mRadioResponse != NULL) {
5960 RadioResponseInfo responseInfo = {};
5961 populateResponseInfo(responseInfo, serial, responseType, e);
5962 Return<void> retStatus
5963 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
5964 responseInfo);
5965 radioService[slotId]->checkReturnStatus(retStatus);
5966 } else {
5967 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
5968 "== NULL", slotId);
5969 }
5970
5971 return 0;
5972}
5973
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005974int radio_1_5::explicitCallTransferResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005975 int responseType, int serial, RIL_Errno e,
5976 void *response, size_t responseLen) {
5977#if VDBG
5978 RLOGD("explicitCallTransferResponse: serial %d", serial);
5979#endif
5980
5981 if (radioService[slotId]->mRadioResponse != NULL) {
5982 RadioResponseInfo responseInfo = {};
5983 populateResponseInfo(responseInfo, serial, responseType, e);
5984 Return<void> retStatus
5985 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
5986 radioService[slotId]->checkReturnStatus(retStatus);
5987 } else {
5988 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
5989 slotId);
5990 }
5991
5992 return 0;
5993}
5994
Malcolm Chen6b9984e2019-10-10 14:44:58 -07005995int radio_1_5::setPreferredNetworkTypeResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08005996 int responseType, int serial, RIL_Errno e,
5997 void *response, size_t responseLen) {
5998#if VDBG
5999 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
6000#endif
6001
6002 if (radioService[slotId]->mRadioResponse != NULL) {
6003 RadioResponseInfo responseInfo = {};
6004 populateResponseInfo(responseInfo, serial, responseType, e);
6005 Return<void> retStatus
6006 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
6007 responseInfo);
6008 radioService[slotId]->checkReturnStatus(retStatus);
6009 } else {
6010 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
6011 slotId);
6012 }
6013
6014 return 0;
6015}
6016
6017
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006018int radio_1_5::getPreferredNetworkTypeResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006019 int responseType, int serial, RIL_Errno e,
6020 void *response, size_t responseLen) {
6021#if VDBG
6022 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
6023#endif
6024
6025 if (radioService[slotId]->mRadioResponse != NULL) {
6026 RadioResponseInfo responseInfo = {};
6027 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6028 Return<void> retStatus
6029 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
6030 responseInfo, (PreferredNetworkType) ret);
6031 radioService[slotId]->checkReturnStatus(retStatus);
6032 } else {
6033 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
6034 slotId);
6035 }
6036
6037 return 0;
6038}
6039
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006040int radio_1_5::setPreferredNetworkTypeBitmapResponse(int slotId,
paulyeff378952019-02-25 12:40:45 -08006041 int responseType, int serial, RIL_Errno e,
6042 void *response, size_t responseLen) {
6043#if VDBG
6044 RLOGD("setPreferredNetworkTypeBitmapResponse: serial %d", serial);
6045#endif
6046
6047 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
6048 RadioResponseInfo responseInfo = {};
6049 populateResponseInfo(responseInfo, serial, responseType, e);
6050 Return<void> retStatus
6051 = radioService[slotId]->mRadioResponseV1_4->setPreferredNetworkTypeBitmapResponse(
6052 responseInfo);
6053 radioService[slotId]->checkReturnStatus(retStatus);
6054 } else {
6055 RLOGE("setPreferredNetworkTypeBitmapResponse: radioService[%d]->mRadioResponseV1_4 == NULL",
6056 slotId);
6057 }
6058
6059 return 0;
6060}
6061
6062
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006063int radio_1_5::getPreferredNetworkTypeBitmapResponse(int slotId,
paulyeff378952019-02-25 12:40:45 -08006064 int responseType, int serial, RIL_Errno e,
6065 void *response, size_t responseLen) {
6066#if VDBG
6067 RLOGD("getPreferredNetworkTypeBitmapResponse: serial %d", serial);
6068#endif
6069
6070 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
6071 RadioResponseInfo responseInfo = {};
6072 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6073 Return<void> retStatus
6074 = radioService[slotId]->mRadioResponseV1_4->getPreferredNetworkTypeBitmapResponse(
6075 responseInfo,
6076 (const ::android::hardware::hidl_bitfield<
6077 ::android::hardware::radio::V1_4::RadioAccessFamily>) ret);
6078 radioService[slotId]->checkReturnStatus(retStatus);
6079 } else {
6080 RLOGE("getPreferredNetworkTypeBitmapResponse: radioService[%d]->mRadioResponseV1_4 == NULL",
6081 slotId);
6082 }
6083
6084 return 0;
6085}
6086
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006087int radio_1_5::getNeighboringCidsResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006088 int responseType, int serial, RIL_Errno e,
6089 void *response, size_t responseLen) {
6090#if VDBG
6091 RLOGD("getNeighboringCidsResponse: serial %d", serial);
6092#endif
6093
6094 if (radioService[slotId]->mRadioResponse != NULL) {
6095 RadioResponseInfo responseInfo = {};
6096 populateResponseInfo(responseInfo, serial, responseType, e);
6097 hidl_vec<NeighboringCell> cells;
6098
6099 if ((response == NULL && responseLen != 0)
6100 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
6101 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
6102 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6103 } else {
6104 int num = responseLen / sizeof(RIL_NeighboringCell *);
6105 cells.resize(num);
6106 for (int i = 0 ; i < num; i++) {
6107 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
6108 cells[i].cid = convertCharPtrToHidlString(resp->cid);
6109 cells[i].rssi = resp->rssi;
6110 }
6111 }
6112
6113 Return<void> retStatus
6114 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
6115 cells);
6116 radioService[slotId]->checkReturnStatus(retStatus);
6117 } else {
6118 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
6119 slotId);
6120 }
6121
6122 return 0;
6123}
6124
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006125int radio_1_5::setLocationUpdatesResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006126 int responseType, int serial, RIL_Errno e,
6127 void *response, size_t responseLen) {
6128#if VDBG
6129 RLOGD("setLocationUpdatesResponse: serial %d", serial);
6130#endif
6131
6132 if (radioService[slotId]->mRadioResponse != NULL) {
6133 RadioResponseInfo responseInfo = {};
6134 populateResponseInfo(responseInfo, serial, responseType, e);
6135 Return<void> retStatus
6136 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
6137 radioService[slotId]->checkReturnStatus(retStatus);
6138 } else {
6139 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
6140 slotId);
6141 }
6142
6143 return 0;
6144}
6145
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006146int radio_1_5::setCdmaSubscriptionSourceResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006147 int responseType, int serial, RIL_Errno e,
6148 void *response, size_t responseLen) {
6149#if VDBG
6150 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
6151#endif
6152
6153 if (radioService[slotId]->mRadioResponse != NULL) {
6154 RadioResponseInfo responseInfo = {};
6155 populateResponseInfo(responseInfo, serial, responseType, e);
6156 Return<void> retStatus
6157 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
6158 responseInfo);
6159 radioService[slotId]->checkReturnStatus(retStatus);
6160 } else {
6161 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
6162 slotId);
6163 }
6164
6165 return 0;
6166}
6167
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006168int radio_1_5::setCdmaRoamingPreferenceResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006169 int responseType, int serial, RIL_Errno e,
6170 void *response, size_t responseLen) {
6171#if VDBG
6172 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
6173#endif
6174
6175 if (radioService[slotId]->mRadioResponse != NULL) {
6176 RadioResponseInfo responseInfo = {};
6177 populateResponseInfo(responseInfo, serial, responseType, e);
6178 Return<void> retStatus
6179 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
6180 responseInfo);
6181 radioService[slotId]->checkReturnStatus(retStatus);
6182 } else {
6183 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
6184 slotId);
6185 }
6186
6187 return 0;
6188}
6189
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006190int radio_1_5::getCdmaRoamingPreferenceResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006191 int responseType, int serial, RIL_Errno e,
6192 void *response, size_t responseLen) {
6193#if VDBG
6194 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
6195#endif
6196
6197 if (radioService[slotId]->mRadioResponse != NULL) {
6198 RadioResponseInfo responseInfo = {};
6199 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6200 Return<void> retStatus
6201 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
6202 responseInfo, (CdmaRoamingType) ret);
6203 radioService[slotId]->checkReturnStatus(retStatus);
6204 } else {
6205 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
6206 slotId);
6207 }
6208
6209 return 0;
6210}
6211
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006212int radio_1_5::setTTYModeResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006213 int responseType, int serial, RIL_Errno e,
6214 void *response, size_t responseLen) {
6215#if VDBG
6216 RLOGD("setTTYModeResponse: serial %d", serial);
6217#endif
6218
6219 if (radioService[slotId]->mRadioResponse != NULL) {
6220 RadioResponseInfo responseInfo = {};
6221 populateResponseInfo(responseInfo, serial, responseType, e);
6222 Return<void> retStatus
6223 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
6224 radioService[slotId]->checkReturnStatus(retStatus);
6225 } else {
6226 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6227 }
6228
6229 return 0;
6230}
6231
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006232int radio_1_5::getTTYModeResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006233 int responseType, int serial, RIL_Errno e,
6234 void *response, size_t responseLen) {
6235#if VDBG
6236 RLOGD("getTTYModeResponse: serial %d", serial);
6237#endif
6238
6239 if (radioService[slotId]->mRadioResponse != NULL) {
6240 RadioResponseInfo responseInfo = {};
6241 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6242 Return<void> retStatus
6243 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
6244 (TtyMode) ret);
6245 radioService[slotId]->checkReturnStatus(retStatus);
6246 } else {
6247 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6248 }
6249
6250 return 0;
6251}
6252
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006253int radio_1_5::setPreferredVoicePrivacyResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006254 int responseType, int serial, RIL_Errno e,
6255 void *response, size_t responseLen) {
6256#if VDBG
6257 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
6258#endif
6259
6260 if (radioService[slotId]->mRadioResponse != NULL) {
6261 RadioResponseInfo responseInfo = {};
6262 populateResponseInfo(responseInfo, serial, responseType, e);
6263 Return<void> retStatus
6264 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
6265 responseInfo);
6266 radioService[slotId]->checkReturnStatus(retStatus);
6267 } else {
6268 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
6269 slotId);
6270 }
6271
6272 return 0;
6273}
6274
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006275int radio_1_5::getPreferredVoicePrivacyResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006276 int responseType, int serial, RIL_Errno e,
6277 void *response, size_t responseLen) {
6278#if VDBG
6279 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
6280#endif
6281
6282 if (radioService[slotId]->mRadioResponse != NULL) {
6283 RadioResponseInfo responseInfo = {};
6284 populateResponseInfo(responseInfo, serial, responseType, e);
6285 bool enable = false;
6286 int numInts = responseLen / sizeof(int);
6287 if (response == NULL || numInts != 1) {
6288 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
6289 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6290 } else {
6291 int *pInt = (int *) response;
6292 enable = pInt[0] == 1 ? true : false;
6293 }
6294 Return<void> retStatus
6295 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
6296 responseInfo, enable);
6297 radioService[slotId]->checkReturnStatus(retStatus);
6298 } else {
6299 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
6300 slotId);
6301 }
6302
6303 return 0;
6304}
6305
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006306int radio_1_5::sendCDMAFeatureCodeResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006307 int responseType, int serial, RIL_Errno e,
6308 void *response, size_t responseLen) {
6309#if VDBG
6310 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
6311#endif
6312
6313 if (radioService[slotId]->mRadioResponse != NULL) {
6314 RadioResponseInfo responseInfo = {};
6315 populateResponseInfo(responseInfo, serial, responseType, e);
6316 Return<void> retStatus
6317 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
6318 radioService[slotId]->checkReturnStatus(retStatus);
6319 } else {
6320 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
6321 slotId);
6322 }
6323
6324 return 0;
6325}
6326
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006327int radio_1_5::sendBurstDtmfResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006328 int responseType, int serial, RIL_Errno e,
6329 void *response, size_t responseLen) {
6330#if VDBG
6331 RLOGD("sendBurstDtmfResponse: serial %d", serial);
6332#endif
6333
6334 if (radioService[slotId]->mRadioResponse != NULL) {
6335 RadioResponseInfo responseInfo = {};
6336 populateResponseInfo(responseInfo, serial, responseType, e);
6337 Return<void> retStatus
6338 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
6339 radioService[slotId]->checkReturnStatus(retStatus);
6340 } else {
6341 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6342 }
6343
6344 return 0;
6345}
6346
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006347int radio_1_5::sendCdmaSmsResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006348 int responseType, int serial, RIL_Errno e, void *response,
6349 size_t responseLen) {
6350#if VDBG
6351 RLOGD("sendCdmaSmsResponse: serial %d", serial);
6352#endif
6353
6354 if (radioService[slotId]->mRadioResponse != NULL) {
6355 RadioResponseInfo responseInfo = {};
6356 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
6357 responseLen);
6358
6359 Return<void> retStatus
6360 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
6361 radioService[slotId]->checkReturnStatus(retStatus);
6362 } else {
6363 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6364 }
6365
6366 return 0;
6367}
6368
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006369int radio_1_5::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006370 int responseType, int serial, RIL_Errno e,
6371 void *response, size_t responseLen) {
6372#if VDBG
6373 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
6374#endif
6375
6376 if (radioService[slotId]->mRadioResponse != NULL) {
6377 RadioResponseInfo responseInfo = {};
6378 populateResponseInfo(responseInfo, serial, responseType, e);
6379 Return<void> retStatus
6380 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
6381 responseInfo);
6382 radioService[slotId]->checkReturnStatus(retStatus);
6383 } else {
6384 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
6385 "== NULL", slotId);
6386 }
6387
6388 return 0;
6389}
6390
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006391int radio_1_5::getGsmBroadcastConfigResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006392 int responseType, int serial, RIL_Errno e,
6393 void *response, size_t responseLen) {
6394#if VDBG
6395 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
6396#endif
6397
6398 if (radioService[slotId]->mRadioResponse != NULL) {
6399 RadioResponseInfo responseInfo = {};
6400 populateResponseInfo(responseInfo, serial, responseType, e);
6401 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
6402
6403 if ((response == NULL && responseLen != 0)
6404 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
6405 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
6406 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6407 } else {
6408 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
6409 configs.resize(num);
6410 for (int i = 0 ; i < num; i++) {
6411 RIL_GSM_BroadcastSmsConfigInfo *resp =
6412 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
6413 configs[i].fromServiceId = resp->fromServiceId;
6414 configs[i].toServiceId = resp->toServiceId;
6415 configs[i].fromCodeScheme = resp->fromCodeScheme;
6416 configs[i].toCodeScheme = resp->toCodeScheme;
6417 configs[i].selected = resp->selected == 1 ? true : false;
6418 }
6419 }
6420
6421 Return<void> retStatus
6422 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
6423 configs);
6424 radioService[slotId]->checkReturnStatus(retStatus);
6425 } else {
6426 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
6427 slotId);
6428 }
6429
6430 return 0;
6431}
6432
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006433int radio_1_5::setGsmBroadcastConfigResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006434 int responseType, int serial, RIL_Errno e,
6435 void *response, size_t responseLen) {
6436#if VDBG
6437 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
6438#endif
6439
6440 if (radioService[slotId]->mRadioResponse != NULL) {
6441 RadioResponseInfo responseInfo = {};
6442 populateResponseInfo(responseInfo, serial, responseType, e);
6443 Return<void> retStatus
6444 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
6445 radioService[slotId]->checkReturnStatus(retStatus);
6446 } else {
6447 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
6448 slotId);
6449 }
6450
6451 return 0;
6452}
6453
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006454int radio_1_5::setGsmBroadcastActivationResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006455 int responseType, int serial, RIL_Errno e,
6456 void *response, size_t responseLen) {
6457#if VDBG
6458 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
6459#endif
6460
6461 if (radioService[slotId]->mRadioResponse != NULL) {
6462 RadioResponseInfo responseInfo = {};
6463 populateResponseInfo(responseInfo, serial, responseType, e);
6464 Return<void> retStatus
6465 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
6466 responseInfo);
6467 radioService[slotId]->checkReturnStatus(retStatus);
6468 } else {
6469 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
6470 slotId);
6471 }
6472
6473 return 0;
6474}
6475
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006476int radio_1_5::getCdmaBroadcastConfigResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006477 int responseType, int serial, RIL_Errno e,
6478 void *response, size_t responseLen) {
6479#if VDBG
6480 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
6481#endif
6482
6483 if (radioService[slotId]->mRadioResponse != NULL) {
6484 RadioResponseInfo responseInfo = {};
6485 populateResponseInfo(responseInfo, serial, responseType, e);
6486 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
6487
6488 if ((response == NULL && responseLen != 0)
6489 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
6490 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
6491 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6492 } else {
6493 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
6494 configs.resize(num);
6495 for (int i = 0 ; i < num; i++) {
6496 RIL_CDMA_BroadcastSmsConfigInfo *resp =
6497 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
6498 configs[i].serviceCategory = resp->service_category;
6499 configs[i].language = resp->language;
6500 configs[i].selected = resp->selected == 1 ? true : false;
6501 }
6502 }
6503
6504 Return<void> retStatus
6505 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
6506 configs);
6507 radioService[slotId]->checkReturnStatus(retStatus);
6508 } else {
6509 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
6510 slotId);
6511 }
6512
6513 return 0;
6514}
6515
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006516int radio_1_5::setCdmaBroadcastConfigResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006517 int responseType, int serial, RIL_Errno e,
6518 void *response, size_t responseLen) {
6519#if VDBG
6520 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
6521#endif
6522
6523 if (radioService[slotId]->mRadioResponse != NULL) {
6524 RadioResponseInfo responseInfo = {};
6525 populateResponseInfo(responseInfo, serial, responseType, e);
6526 Return<void> retStatus
6527 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
6528 responseInfo);
6529 radioService[slotId]->checkReturnStatus(retStatus);
6530 } else {
6531 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
6532 slotId);
6533 }
6534
6535 return 0;
6536}
6537
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006538int radio_1_5::setCdmaBroadcastActivationResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006539 int responseType, int serial, RIL_Errno e,
6540 void *response, size_t responseLen) {
6541#if VDBG
6542 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
6543#endif
6544
6545 if (radioService[slotId]->mRadioResponse != NULL) {
6546 RadioResponseInfo responseInfo = {};
6547 populateResponseInfo(responseInfo, serial, responseType, e);
6548 Return<void> retStatus
6549 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
6550 responseInfo);
6551 radioService[slotId]->checkReturnStatus(retStatus);
6552 } else {
6553 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
6554 slotId);
6555 }
6556
6557 return 0;
6558}
6559
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006560int radio_1_5::getCDMASubscriptionResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006561 int responseType, int serial, RIL_Errno e, void *response,
6562 size_t responseLen) {
6563#if VDBG
6564 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
6565#endif
6566
6567 if (radioService[slotId]->mRadioResponse != NULL) {
6568 RadioResponseInfo responseInfo = {};
6569 populateResponseInfo(responseInfo, serial, responseType, e);
6570
6571 int numStrings = responseLen / sizeof(char *);
6572 hidl_string emptyString;
6573 if (response == NULL || numStrings != 5) {
6574 RLOGE("getOperatorResponse Invalid response: NULL");
6575 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6576 Return<void> retStatus
6577 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
6578 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
6579 radioService[slotId]->checkReturnStatus(retStatus);
6580 } else {
6581 char **resp = (char **) response;
6582 Return<void> retStatus
6583 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
6584 responseInfo,
6585 convertCharPtrToHidlString(resp[0]),
6586 convertCharPtrToHidlString(resp[1]),
6587 convertCharPtrToHidlString(resp[2]),
6588 convertCharPtrToHidlString(resp[3]),
6589 convertCharPtrToHidlString(resp[4]));
6590 radioService[slotId]->checkReturnStatus(retStatus);
6591 }
6592 } else {
6593 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
6594 slotId);
6595 }
6596
6597 return 0;
6598}
6599
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006600int radio_1_5::writeSmsToRuimResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006601 int responseType, int serial, RIL_Errno e,
6602 void *response, size_t responseLen) {
6603#if VDBG
6604 RLOGD("writeSmsToRuimResponse: serial %d", serial);
6605#endif
6606
6607 if (radioService[slotId]->mRadioResponse != NULL) {
6608 RadioResponseInfo responseInfo = {};
6609 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6610 Return<void> retStatus
6611 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
6612 radioService[slotId]->checkReturnStatus(retStatus);
6613 } else {
6614 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6615 }
6616
6617 return 0;
6618}
6619
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006620int radio_1_5::deleteSmsOnRuimResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006621 int responseType, int serial, RIL_Errno e,
6622 void *response, size_t responseLen) {
6623#if VDBG
6624 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
6625#endif
6626
6627 if (radioService[slotId]->mRadioResponse != NULL) {
6628 RadioResponseInfo responseInfo = {};
6629 populateResponseInfo(responseInfo, serial, responseType, e);
6630 Return<void> retStatus
6631 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
6632 radioService[slotId]->checkReturnStatus(retStatus);
6633 } else {
6634 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6635 }
6636
6637 return 0;
6638}
6639
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006640int radio_1_5::getDeviceIdentityResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006641 int responseType, int serial, RIL_Errno e, void *response,
6642 size_t responseLen) {
6643#if VDBG
6644 RLOGD("getDeviceIdentityResponse: serial %d", serial);
6645#endif
6646
6647 if (radioService[slotId]->mRadioResponse != NULL) {
6648 RadioResponseInfo responseInfo = {};
6649 populateResponseInfo(responseInfo, serial, responseType, e);
6650
6651 int numStrings = responseLen / sizeof(char *);
6652 hidl_string emptyString;
6653 if (response == NULL || numStrings != 4) {
6654 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
6655 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6656 Return<void> retStatus
6657 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
6658 emptyString, emptyString, emptyString, emptyString);
6659 radioService[slotId]->checkReturnStatus(retStatus);
6660 } else {
6661 char **resp = (char **) response;
6662 Return<void> retStatus
6663 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
6664 convertCharPtrToHidlString(resp[0]),
6665 convertCharPtrToHidlString(resp[1]),
6666 convertCharPtrToHidlString(resp[2]),
6667 convertCharPtrToHidlString(resp[3]));
6668 radioService[slotId]->checkReturnStatus(retStatus);
6669 }
6670 } else {
6671 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
6672 slotId);
6673 }
6674
6675 return 0;
6676}
6677
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006678int radio_1_5::exitEmergencyCallbackModeResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006679 int responseType, int serial, RIL_Errno e,
6680 void *response, size_t responseLen) {
6681#if VDBG
6682 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
6683#endif
6684
6685 if (radioService[slotId]->mRadioResponse != NULL) {
6686 RadioResponseInfo responseInfo = {};
6687 populateResponseInfo(responseInfo, serial, responseType, e);
6688 Return<void> retStatus
6689 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
6690 responseInfo);
6691 radioService[slotId]->checkReturnStatus(retStatus);
6692 } else {
6693 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
6694 slotId);
6695 }
6696
6697 return 0;
6698}
6699
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006700int radio_1_5::getSmscAddressResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006701 int responseType, int serial, RIL_Errno e,
6702 void *response, size_t responseLen) {
6703#if VDBG
6704 RLOGD("getSmscAddressResponse: serial %d", serial);
6705#endif
6706
6707 if (radioService[slotId]->mRadioResponse != NULL) {
6708 RadioResponseInfo responseInfo = {};
6709 populateResponseInfo(responseInfo, serial, responseType, e);
6710 Return<void> retStatus
6711 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
6712 convertCharPtrToHidlString((char *) response));
6713 radioService[slotId]->checkReturnStatus(retStatus);
6714 } else {
6715 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6716 }
6717
6718 return 0;
6719}
6720
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006721int radio_1_5::setSmscAddressResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006722 int responseType, int serial, RIL_Errno e,
6723 void *response, size_t responseLen) {
6724#if VDBG
6725 RLOGD("setSmscAddressResponse: serial %d", serial);
6726#endif
6727
6728 if (radioService[slotId]->mRadioResponse != NULL) {
6729 RadioResponseInfo responseInfo = {};
6730 populateResponseInfo(responseInfo, serial, responseType, e);
6731 Return<void> retStatus
6732 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
6733 radioService[slotId]->checkReturnStatus(retStatus);
6734 } else {
6735 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6736 }
6737
6738 return 0;
6739}
6740
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006741int radio_1_5::reportSmsMemoryStatusResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006742 int responseType, int serial, RIL_Errno e,
6743 void *response, size_t responseLen) {
6744#if VDBG
6745 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
6746#endif
6747
6748 if (radioService[slotId]->mRadioResponse != NULL) {
6749 RadioResponseInfo responseInfo = {};
6750 populateResponseInfo(responseInfo, serial, responseType, e);
6751 Return<void> retStatus
6752 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
6753 radioService[slotId]->checkReturnStatus(retStatus);
6754 } else {
6755 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
6756 slotId);
6757 }
6758
6759 return 0;
6760}
6761
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006762int radio_1_5::reportStkServiceIsRunningResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006763 int responseType, int serial, RIL_Errno e,
6764 void *response, size_t responseLen) {
6765#if VDBG
6766 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
6767#endif
6768
6769 if (radioService[slotId]->mRadioResponse != NULL) {
6770 RadioResponseInfo responseInfo = {};
6771 populateResponseInfo(responseInfo, serial, responseType, e);
6772 Return<void> retStatus = radioService[slotId]->mRadioResponse->
6773 reportStkServiceIsRunningResponse(responseInfo);
6774 radioService[slotId]->checkReturnStatus(retStatus);
6775 } else {
6776 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
6777 slotId);
6778 }
6779
6780 return 0;
6781}
6782
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006783int radio_1_5::getCdmaSubscriptionSourceResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006784 int responseType, int serial, RIL_Errno e,
6785 void *response, size_t responseLen) {
6786#if VDBG
6787 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
6788#endif
6789
6790 if (radioService[slotId]->mRadioResponse != NULL) {
6791 RadioResponseInfo responseInfo = {};
6792 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6793 Return<void> retStatus
6794 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
6795 responseInfo, (CdmaSubscriptionSource) ret);
6796 radioService[slotId]->checkReturnStatus(retStatus);
6797 } else {
6798 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
6799 slotId);
6800 }
6801
6802 return 0;
6803}
6804
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006805int radio_1_5::requestIsimAuthenticationResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006806 int responseType, int serial, RIL_Errno e,
6807 void *response, size_t responseLen) {
6808#if VDBG
6809 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
6810#endif
6811
6812 if (radioService[slotId]->mRadioResponse != NULL) {
6813 RadioResponseInfo responseInfo = {};
6814 populateResponseInfo(responseInfo, serial, responseType, e);
6815 Return<void> retStatus
6816 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
6817 responseInfo,
6818 convertCharPtrToHidlString((char *) response));
6819 radioService[slotId]->checkReturnStatus(retStatus);
6820 } else {
6821 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
6822 slotId);
6823 }
6824
6825 return 0;
6826}
6827
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006828int radio_1_5::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006829 int responseType,
6830 int serial, RIL_Errno e, void *response,
6831 size_t responseLen) {
6832#if VDBG
6833 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
6834#endif
6835
6836 if (radioService[slotId]->mRadioResponse != NULL) {
6837 RadioResponseInfo responseInfo = {};
6838 populateResponseInfo(responseInfo, serial, responseType, e);
6839 Return<void> retStatus
6840 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
6841 responseInfo);
6842 radioService[slotId]->checkReturnStatus(retStatus);
6843 } else {
6844 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
6845 "== NULL", slotId);
6846 }
6847
6848 return 0;
6849}
6850
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006851int radio_1_5::sendEnvelopeWithStatusResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006852 int responseType, int serial, RIL_Errno e, void *response,
6853 size_t responseLen) {
6854#if VDBG
6855 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
6856#endif
6857
6858 if (radioService[slotId]->mRadioResponse != NULL) {
6859 RadioResponseInfo responseInfo = {};
6860 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
6861 response, responseLen);
6862
6863 Return<void> retStatus
6864 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
6865 result);
6866 radioService[slotId]->checkReturnStatus(retStatus);
6867 } else {
6868 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
6869 slotId);
6870 }
6871
6872 return 0;
6873}
6874
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006875int radio_1_5::getVoiceRadioTechnologyResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006876 int responseType, int serial, RIL_Errno e,
6877 void *response, size_t responseLen) {
6878#if VDBG
6879 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
6880#endif
6881
6882 if (radioService[slotId]->mRadioResponse != NULL) {
6883 RadioResponseInfo responseInfo = {};
6884 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6885 Return<void> retStatus
6886 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
6887 responseInfo, (RadioTechnology) ret);
6888 radioService[slotId]->checkReturnStatus(retStatus);
6889 } else {
6890 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
6891 slotId);
6892 }
6893
6894 return 0;
6895}
6896
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006897int radio_1_5::getCellInfoListResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006898 int responseType,
6899 int serial, RIL_Errno e, void *response,
6900 size_t responseLen) {
6901#if VDBG
6902 RLOGD("getCellInfoListResponse: serial %d", serial);
6903#endif
6904
6905 if (radioService[slotId]->mRadioResponse != NULL) {
6906 RadioResponseInfo responseInfo = {};
6907 populateResponseInfo(responseInfo, serial, responseType, e);
6908
6909 hidl_vec<CellInfo> ret;
6910 if ((response == NULL && responseLen != 0)
6911 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
6912 RLOGE("getCellInfoListResponse: Invalid response");
6913 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6914 } else {
6915 convertRilCellInfoListToHal(response, responseLen, ret);
6916 }
6917
6918 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
6919 responseInfo, ret);
6920 radioService[slotId]->checkReturnStatus(retStatus);
6921 } else {
6922 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6923 }
6924
6925 return 0;
6926}
6927
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006928int radio_1_5::setCellInfoListRateResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006929 int responseType,
6930 int serial, RIL_Errno e, void *response,
6931 size_t responseLen) {
6932#if VDBG
6933 RLOGD("setCellInfoListRateResponse: serial %d", serial);
6934#endif
6935
6936 if (radioService[slotId]->mRadioResponse != NULL) {
6937 RadioResponseInfo responseInfo = {};
6938 populateResponseInfo(responseInfo, serial, responseType, e);
6939 Return<void> retStatus
6940 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
6941 radioService[slotId]->checkReturnStatus(retStatus);
6942 } else {
6943 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
6944 slotId);
6945 }
6946
6947 return 0;
6948}
6949
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006950int radio_1_5::setInitialAttachApnResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006951 int responseType, int serial, RIL_Errno e,
6952 void *response, size_t responseLen) {
6953#if VDBG
6954 RLOGD("setInitialAttachApnResponse: serial %d", serial);
6955#endif
6956
Sarah Chin75b299c2019-12-11 10:57:28 -08006957 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
6958 RadioResponseInfo responseInfo = {};
6959 populateResponseInfo(responseInfo, serial, responseType, e);
6960 Return<void> retStatus
6961 = radioService[slotId]->mRadioResponseV1_5->setInitialAttachApnResponse_1_5(
6962 responseInfo);
6963 } else if (radioService[slotId]->mRadioResponse != NULL) {
paulye91d34712019-02-07 19:02:02 -08006964 RadioResponseInfo responseInfo = {};
6965 populateResponseInfo(responseInfo, serial, responseType, e);
6966 Return<void> retStatus
6967 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
6968 radioService[slotId]->checkReturnStatus(retStatus);
6969 } else {
6970 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
6971 slotId);
6972 }
6973
6974 return 0;
6975}
6976
Malcolm Chen6b9984e2019-10-10 14:44:58 -07006977int radio_1_5::getImsRegistrationStateResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08006978 int responseType, int serial, RIL_Errno e,
6979 void *response, size_t responseLen) {
6980#if VDBG
6981 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
6982#endif
6983
6984 if (radioService[slotId]->mRadioResponse != NULL) {
6985 RadioResponseInfo responseInfo = {};
6986 populateResponseInfo(responseInfo, serial, responseType, e);
6987 bool isRegistered = false;
6988 int ratFamily = 0;
6989 int numInts = responseLen / sizeof(int);
6990 if (response == NULL || numInts != 2) {
6991 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
6992 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6993 } else {
6994 int *pInt = (int *) response;
6995 isRegistered = pInt[0] == 1 ? true : false;
6996 ratFamily = pInt[1];
6997 }
6998 Return<void> retStatus
6999 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
7000 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
7001 radioService[slotId]->checkReturnStatus(retStatus);
7002 } else {
7003 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
7004 slotId);
7005 }
7006
7007 return 0;
7008}
7009
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007010int radio_1_5::sendImsSmsResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007011 int responseType, int serial, RIL_Errno e, void *response,
7012 size_t responseLen) {
7013#if VDBG
7014 RLOGD("sendImsSmsResponse: serial %d", serial);
7015#endif
7016
7017 if (radioService[slotId]->mRadioResponse != NULL) {
7018 RadioResponseInfo responseInfo = {};
7019 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
7020 responseLen);
7021
7022 Return<void> retStatus
7023 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
7024 radioService[slotId]->checkReturnStatus(retStatus);
7025 } else {
7026 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7027 }
7028
7029 return 0;
7030}
7031
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007032int radio_1_5::iccTransmitApduBasicChannelResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007033 int responseType, int serial, RIL_Errno e,
7034 void *response, size_t responseLen) {
7035#if VDBG
7036 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
7037#endif
7038
7039 if (radioService[slotId]->mRadioResponse != NULL) {
7040 RadioResponseInfo responseInfo = {};
7041 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
7042 responseLen);
7043
7044 Return<void> retStatus
7045 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
7046 responseInfo, result);
7047 radioService[slotId]->checkReturnStatus(retStatus);
7048 } else {
7049 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
7050 "== NULL", slotId);
7051 }
7052
7053 return 0;
7054}
7055
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007056int radio_1_5::iccOpenLogicalChannelResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007057 int responseType, int serial, RIL_Errno e, void *response,
7058 size_t responseLen) {
7059#if VDBG
7060 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
7061#endif
7062
7063 if (radioService[slotId]->mRadioResponse != NULL) {
7064 RadioResponseInfo responseInfo = {};
7065 populateResponseInfo(responseInfo, serial, responseType, e);
7066 int channelId = -1;
7067 hidl_vec<int8_t> selectResponse;
7068 int numInts = responseLen / sizeof(int);
7069 if (response == NULL || responseLen % sizeof(int) != 0) {
7070 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
7071 if (response != NULL) {
7072 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7073 }
7074 } else {
7075 int *pInt = (int *) response;
7076 channelId = pInt[0];
7077 selectResponse.resize(numInts - 1);
7078 for (int i = 1; i < numInts; i++) {
7079 selectResponse[i - 1] = (int8_t) pInt[i];
7080 }
7081 }
7082 Return<void> retStatus
7083 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
7084 channelId, selectResponse);
7085 radioService[slotId]->checkReturnStatus(retStatus);
7086 } else {
7087 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
7088 slotId);
7089 }
7090
7091 return 0;
7092}
7093
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007094int radio_1_5::iccCloseLogicalChannelResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007095 int responseType, int serial, RIL_Errno e,
7096 void *response, size_t responseLen) {
7097#if VDBG
7098 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
7099#endif
7100
7101 if (radioService[slotId]->mRadioResponse != NULL) {
7102 RadioResponseInfo responseInfo = {};
7103 populateResponseInfo(responseInfo, serial, responseType, e);
7104 Return<void> retStatus
7105 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
7106 responseInfo);
7107 radioService[slotId]->checkReturnStatus(retStatus);
7108 } else {
7109 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
7110 slotId);
7111 }
7112
7113 return 0;
7114}
7115
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007116int radio_1_5::iccTransmitApduLogicalChannelResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007117 int responseType, int serial, RIL_Errno e,
7118 void *response, size_t responseLen) {
7119#if VDBG
7120 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
7121#endif
7122
7123 if (radioService[slotId]->mRadioResponse != NULL) {
7124 RadioResponseInfo responseInfo = {};
7125 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
7126 responseLen);
7127
7128 Return<void> retStatus
7129 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
7130 responseInfo, result);
7131 radioService[slotId]->checkReturnStatus(retStatus);
7132 } else {
7133 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
7134 "== NULL", slotId);
7135 }
7136
7137 return 0;
7138}
7139
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007140int radio_1_5::nvReadItemResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007141 int responseType, int serial, RIL_Errno e,
7142 void *response, size_t responseLen) {
7143#if VDBG
7144 RLOGD("nvReadItemResponse: serial %d", serial);
7145#endif
7146
7147 if (radioService[slotId]->mRadioResponse != NULL) {
7148 RadioResponseInfo responseInfo = {};
7149 populateResponseInfo(responseInfo, serial, responseType, e);
7150 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
7151 responseInfo,
7152 convertCharPtrToHidlString((char *) response));
7153 radioService[slotId]->checkReturnStatus(retStatus);
7154 } else {
7155 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7156 }
7157
7158 return 0;
7159}
7160
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007161int radio_1_5::nvWriteItemResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007162 int responseType, int serial, RIL_Errno e,
7163 void *response, size_t responseLen) {
7164#if VDBG
7165 RLOGD("nvWriteItemResponse: serial %d", serial);
7166#endif
7167
7168 if (radioService[slotId]->mRadioResponse != NULL) {
7169 RadioResponseInfo responseInfo = {};
7170 populateResponseInfo(responseInfo, serial, responseType, e);
7171 Return<void> retStatus
7172 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
7173 radioService[slotId]->checkReturnStatus(retStatus);
7174 } else {
7175 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7176 }
7177
7178 return 0;
7179}
7180
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007181int radio_1_5::nvWriteCdmaPrlResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007182 int responseType, int serial, RIL_Errno e,
7183 void *response, size_t responseLen) {
7184#if VDBG
7185 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
7186#endif
7187
7188 if (radioService[slotId]->mRadioResponse != NULL) {
7189 RadioResponseInfo responseInfo = {};
7190 populateResponseInfo(responseInfo, serial, responseType, e);
7191 Return<void> retStatus
7192 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
7193 radioService[slotId]->checkReturnStatus(retStatus);
7194 } else {
7195 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7196 }
7197
7198 return 0;
7199}
7200
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007201int radio_1_5::nvResetConfigResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007202 int responseType, int serial, RIL_Errno e,
7203 void *response, size_t responseLen) {
7204#if VDBG
7205 RLOGD("nvResetConfigResponse: serial %d", serial);
7206#endif
7207
7208 if (radioService[slotId]->mRadioResponse != NULL) {
7209 RadioResponseInfo responseInfo = {};
7210 populateResponseInfo(responseInfo, serial, responseType, e);
7211 Return<void> retStatus
7212 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
7213 radioService[slotId]->checkReturnStatus(retStatus);
7214 } else {
7215 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7216 }
7217
7218 return 0;
7219}
7220
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007221int radio_1_5::setUiccSubscriptionResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007222 int responseType, int serial, RIL_Errno e,
7223 void *response, size_t responseLen) {
7224#if VDBG
7225 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
7226#endif
7227
7228 if (radioService[slotId]->mRadioResponse != NULL) {
7229 RadioResponseInfo responseInfo = {};
7230 populateResponseInfo(responseInfo, serial, responseType, e);
7231 Return<void> retStatus
7232 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
7233 radioService[slotId]->checkReturnStatus(retStatus);
7234 } else {
7235 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
7236 slotId);
7237 }
7238
7239 return 0;
7240}
7241
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007242int radio_1_5::setDataAllowedResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007243 int responseType, int serial, RIL_Errno e,
7244 void *response, size_t responseLen) {
7245#if VDBG
7246 RLOGD("setDataAllowedResponse: serial %d", serial);
7247#endif
7248
7249 if (radioService[slotId]->mRadioResponse != NULL) {
7250 RadioResponseInfo responseInfo = {};
7251 populateResponseInfo(responseInfo, serial, responseType, e);
7252 Return<void> retStatus
7253 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
7254 radioService[slotId]->checkReturnStatus(retStatus);
7255 } else {
7256 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7257 }
7258
7259 return 0;
7260}
7261
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007262int radio_1_5::getHardwareConfigResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007263 int responseType, int serial, RIL_Errno e,
7264 void *response, size_t responseLen) {
7265#if VDBG
7266 RLOGD("getHardwareConfigResponse: serial %d", serial);
7267#endif
7268
7269 if (radioService[slotId]->mRadioResponse != NULL) {
7270 RadioResponseInfo responseInfo = {};
7271 populateResponseInfo(responseInfo, serial, responseType, e);
7272
7273 hidl_vec<HardwareConfig> result;
7274 if ((response == NULL && responseLen != 0)
7275 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7276 RLOGE("hardwareConfigChangedInd: invalid response");
7277 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7278 } else {
7279 convertRilHardwareConfigListToHal(response, responseLen, result);
7280 }
7281
7282 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
7283 responseInfo, result);
7284 radioService[slotId]->checkReturnStatus(retStatus);
7285 } else {
7286 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7287 }
7288
7289 return 0;
7290}
7291
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007292int radio_1_5::requestIccSimAuthenticationResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007293 int responseType, int serial, RIL_Errno e,
7294 void *response, size_t responseLen) {
7295#if VDBG
7296 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
7297#endif
7298
7299 if (radioService[slotId]->mRadioResponse != NULL) {
7300 RadioResponseInfo responseInfo = {};
7301 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
7302 responseLen);
7303
7304 Return<void> retStatus
7305 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
7306 responseInfo, result);
7307 radioService[slotId]->checkReturnStatus(retStatus);
7308 } else {
7309 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
7310 "== NULL", slotId);
7311 }
7312
7313 return 0;
7314}
7315
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007316int radio_1_5::setDataProfileResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007317 int responseType, int serial, RIL_Errno e,
7318 void *response, size_t responseLen) {
7319#if VDBG
7320 RLOGD("setDataProfileResponse: serial %d", serial);
7321#endif
7322
Sarah Chin75b299c2019-12-11 10:57:28 -08007323 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7324 RadioResponseInfo responseInfo = {};
7325 populateResponseInfo(responseInfo, serial, responseType, e);
7326 Return<void> retStatus
7327 = radioService[slotId]->mRadioResponseV1_5->setDataProfileResponse_1_5(
7328 responseInfo);
7329 } else if (radioService[slotId]->mRadioResponse != NULL) {
paulye91d34712019-02-07 19:02:02 -08007330 RadioResponseInfo responseInfo = {};
7331 populateResponseInfo(responseInfo, serial, responseType, e);
7332 Return<void> retStatus
7333 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
7334 radioService[slotId]->checkReturnStatus(retStatus);
7335 } else {
7336 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7337 }
7338
7339 return 0;
7340}
7341
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007342int radio_1_5::requestShutdownResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007343 int responseType, int serial, RIL_Errno e,
7344 void *response, size_t responseLen) {
7345#if VDBG
7346 RLOGD("requestShutdownResponse: serial %d", serial);
7347#endif
7348
7349 if (radioService[slotId]->mRadioResponse != NULL) {
7350 RadioResponseInfo responseInfo = {};
7351 populateResponseInfo(responseInfo, serial, responseType, e);
7352 Return<void> retStatus
7353 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
7354 radioService[slotId]->checkReturnStatus(retStatus);
7355 } else {
7356 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7357 }
7358
7359 return 0;
7360}
7361
7362void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
7363 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
7364 populateResponseInfo(responseInfo, serial, responseType, e);
7365
7366 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
7367 RLOGE("responseRadioCapability: Invalid response");
7368 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7369 rc.logicalModemUuid = hidl_string();
7370 } else {
7371 convertRilRadioCapabilityToHal(response, responseLen, rc);
7372 }
7373}
7374
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007375int radio_1_5::getRadioCapabilityResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007376 int responseType, int serial, RIL_Errno e,
7377 void *response, size_t responseLen) {
7378#if VDBG
7379 RLOGD("getRadioCapabilityResponse: serial %d", serial);
7380#endif
7381
7382 if (radioService[slotId]->mRadioResponse != NULL) {
7383 RadioResponseInfo responseInfo = {};
7384 RadioCapability result = {};
7385 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
7386 result);
7387 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
7388 responseInfo, result);
7389 radioService[slotId]->checkReturnStatus(retStatus);
7390 } else {
7391 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7392 }
7393
7394 return 0;
7395}
7396
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007397int radio_1_5::setRadioCapabilityResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007398 int responseType, int serial, RIL_Errno e,
7399 void *response, size_t responseLen) {
7400#if VDBG
7401 RLOGD("setRadioCapabilityResponse: serial %d", serial);
7402#endif
7403
7404 if (radioService[slotId]->mRadioResponse != NULL) {
7405 RadioResponseInfo responseInfo = {};
7406 RadioCapability result = {};
7407 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
7408 result);
7409 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
7410 responseInfo, result);
7411 radioService[slotId]->checkReturnStatus(retStatus);
7412 } else {
7413 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7414 }
7415
7416 return 0;
7417}
7418
7419LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
7420 RIL_Errno e, void *response, size_t responseLen) {
7421 populateResponseInfo(responseInfo, serial, responseType, e);
7422 LceStatusInfo result = {};
7423
7424 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
7425 RLOGE("Invalid response: NULL");
7426 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7427 } else {
7428 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
7429 result.lceStatus = (LceStatus) resp->lce_status;
7430 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
7431 }
7432 return result;
7433}
7434
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007435int radio_1_5::startLceServiceResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007436 int responseType, int serial, RIL_Errno e,
7437 void *response, size_t responseLen) {
7438#if VDBG
7439 RLOGD("startLceServiceResponse: serial %d", serial);
7440#endif
7441
7442 if (radioService[slotId]->mRadioResponse != NULL) {
7443 RadioResponseInfo responseInfo = {};
7444 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
7445 response, responseLen);
7446
7447 Return<void> retStatus
7448 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
7449 result);
7450 radioService[slotId]->checkReturnStatus(retStatus);
7451 } else {
7452 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7453 }
7454
7455 return 0;
7456}
7457
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007458int radio_1_5::stopLceServiceResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007459 int responseType, int serial, RIL_Errno e,
7460 void *response, size_t responseLen) {
7461#if VDBG
7462 RLOGD("stopLceServiceResponse: serial %d", serial);
7463#endif
7464
7465 if (radioService[slotId]->mRadioResponse != NULL) {
7466 RadioResponseInfo responseInfo = {};
7467 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
7468 response, responseLen);
7469
7470 Return<void> retStatus
7471 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
7472 result);
7473 radioService[slotId]->checkReturnStatus(retStatus);
7474 } else {
7475 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7476 }
7477
7478 return 0;
7479}
7480
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007481int radio_1_5::pullLceDataResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007482 int responseType, int serial, RIL_Errno e,
7483 void *response, size_t responseLen) {
7484#if VDBG
7485 RLOGD("pullLceDataResponse: serial %d", serial);
7486#endif
7487
7488 if (radioService[slotId]->mRadioResponse != NULL) {
7489 RadioResponseInfo responseInfo = {};
7490 populateResponseInfo(responseInfo, serial, responseType, e);
7491
7492 LceDataInfo result = {};
7493 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
7494 RLOGE("pullLceDataResponse: Invalid response");
7495 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7496 } else {
7497 convertRilLceDataInfoToHal(response, responseLen, result);
7498 }
7499
7500 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
7501 responseInfo, result);
7502 radioService[slotId]->checkReturnStatus(retStatus);
7503 } else {
7504 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7505 }
7506
7507 return 0;
7508}
7509
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007510int radio_1_5::getModemActivityInfoResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007511 int responseType, int serial, RIL_Errno e,
7512 void *response, size_t responseLen) {
7513#if VDBG
7514 RLOGD("getModemActivityInfoResponse: serial %d", serial);
7515#endif
7516
7517 if (radioService[slotId]->mRadioResponse != NULL) {
7518 RadioResponseInfo responseInfo = {};
7519 populateResponseInfo(responseInfo, serial, responseType, e);
7520 ActivityStatsInfo info;
7521 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
7522 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
7523 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7524 } else {
7525 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
7526 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
7527 info.idleModeTimeMs = resp->idle_mode_time_ms;
7528 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
7529 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
7530 }
7531 info.rxModeTimeMs = resp->rx_mode_time_ms;
7532 }
7533
7534 Return<void> retStatus
7535 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
7536 info);
7537 radioService[slotId]->checkReturnStatus(retStatus);
7538 } else {
7539 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
7540 slotId);
7541 }
7542
7543 return 0;
7544}
7545
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007546int radio_1_5::setAllowedCarriersResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007547 int responseType, int serial, RIL_Errno e,
7548 void *response, size_t responseLen) {
7549#if VDBG
7550 RLOGD("setAllowedCarriersResponse: serial %d", serial);
7551#endif
Sarah Chinef7f9222020-01-30 10:37:08 -08007552 RadioResponseInfo responseInfo = {};
Michelee218c362019-02-27 22:48:48 -08007553
7554 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
Sarah Chinef7f9222020-01-30 10:37:08 -08007555 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
7556 ->setAllowedCarriersResponse_1_4(responseInfo);
7557 radioService[slotId]->checkReturnStatus(retStatus);
7558 } else if (radioService[slotId]->mRadioResponse != NULL) {
7559 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
7560 Return<void> retStatus = radioService[slotId]->mRadioResponse
7561 ->setAllowedCarriersResponse(responseInfo, ret);
Michelee218c362019-02-27 22:48:48 -08007562 radioService[slotId]->checkReturnStatus(retStatus);
7563 } else {
Sarah Chinef7f9222020-01-30 10:37:08 -08007564 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Michelee218c362019-02-27 22:48:48 -08007565 }
7566
7567 return 0;
7568}
7569
7570void prepareCarrierRestrictionsResponse(hidl_vec<Carrier>& allowedCarriers,
7571 hidl_vec<Carrier>& excludedCarriers,
7572 bool& allAllowed,
7573 const RIL_CarrierRestrictions* pCr) {
7574 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
7575 allAllowed = false;
7576 }
7577 allowedCarriers.resize(pCr->len_allowed_carriers);
7578 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
7579 RIL_Carrier *carrier = pCr->allowed_carriers + i;
7580 allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
7581 allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
7582 allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
7583 allowedCarriers[i].matchData =
7584 convertCharPtrToHidlString(carrier->match_data);
7585 }
7586
7587 excludedCarriers.resize(pCr->len_excluded_carriers);
7588 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
7589 RIL_Carrier *carrier = pCr->excluded_carriers + i;
7590 excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
7591 excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
7592 excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
7593 excludedCarriers[i].matchData =
7594 convertCharPtrToHidlString(carrier->match_data);
7595 }
7596}
7597
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007598int radio_1_5::getAllowedCarriersResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007599 int responseType, int serial, RIL_Errno e,
7600 void *response, size_t responseLen) {
7601#if VDBG
7602 RLOGD("getAllowedCarriersResponse: serial %d", serial);
7603#endif
Sarah Chinef7f9222020-01-30 10:37:08 -08007604 RadioResponseInfo responseInfo = {};
7605 populateResponseInfo(responseInfo, serial, responseType, e);
paulye91d34712019-02-07 19:02:02 -08007606
Sarah Chinef7f9222020-01-30 10:37:08 -08007607 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7608 V1_4::CarrierRestrictionsWithPriority carrierInfo = {};
7609 V1_4::SimLockMultiSimPolicy multiSimPolicy =
7610 V1_4::SimLockMultiSimPolicy::NO_MULTISIM_POLICY;
7611 bool allAllowed = true;
7612
7613 if (response == NULL) {
7614#if VDBG
7615 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
7616#endif
7617 carrierInfo.allowedCarriers.resize(0);
7618 carrierInfo.excludedCarriers.resize(0);
7619 carrierInfo.allowedCarriersPrioritized = false;
7620 } else if (responseLen != sizeof(RIL_CarrierRestrictionsWithPriority)) {
7621 RLOGE("getAllowedCarriersResponse Invalid response");
7622 if (e == RIL_E_SUCCESS) {
7623 responseInfo.error = RadioError::INVALID_RESPONSE;
7624 }
7625 } else {
7626 RIL_CarrierRestrictionsWithPriority *pCrExt =
7627 (RIL_CarrierRestrictionsWithPriority *)response;
7628
7629 // Convert into the structure used in IRadio 1.0 to re-use existing code
7630 RIL_CarrierRestrictions cr = {};
7631 cr.len_allowed_carriers = pCrExt->len_allowed_carriers;
7632 cr.len_excluded_carriers = pCrExt->len_excluded_carriers;
7633 cr.allowed_carriers = pCrExt->allowed_carriers;
7634 cr.excluded_carriers = pCrExt->excluded_carriers;
7635 prepareCarrierRestrictionsResponse(carrierInfo.allowedCarriers,
7636 carrierInfo.excludedCarriers, allAllowed, &cr);
7637
7638 carrierInfo.allowedCarriersPrioritized = (bool)pCrExt->allowedCarriersPrioritized;
7639 multiSimPolicy = (V1_4::SimLockMultiSimPolicy)pCrExt->multiSimPolicy;
7640 }
7641
7642 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
7643 ->getAllowedCarriersResponse_1_4(responseInfo, carrierInfo, multiSimPolicy);
7644 radioService[slotId]->checkReturnStatus(retStatus);
7645 } else if (radioService[slotId]->mRadioResponse != NULL) {
paulye91d34712019-02-07 19:02:02 -08007646 CarrierRestrictions carrierInfo = {};
7647 bool allAllowed = true;
7648 if (response == NULL) {
7649#if VDBG
7650 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
7651#endif
7652 carrierInfo.allowedCarriers.resize(0);
7653 carrierInfo.excludedCarriers.resize(0);
7654 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
7655 RLOGE("getAllowedCarriersResponse Invalid response");
Michelee218c362019-02-27 22:48:48 -08007656 if (e == RIL_E_SUCCESS) {
7657 responseInfo.error = RadioError::INVALID_RESPONSE;
7658 }
paulye91d34712019-02-07 19:02:02 -08007659 } else {
7660 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
Sarah Chinef7f9222020-01-30 10:37:08 -08007661 prepareCarrierRestrictionsResponse(carrierInfo.allowedCarriers,
7662 carrierInfo.excludedCarriers, allAllowed, pCr);
paulye91d34712019-02-07 19:02:02 -08007663 }
7664
Sarah Chinef7f9222020-01-30 10:37:08 -08007665 Return<void> retStatus = radioService[slotId]->mRadioResponse
7666 ->getAllowedCarriersResponse(responseInfo, allAllowed, carrierInfo);
paulye91d34712019-02-07 19:02:02 -08007667 radioService[slotId]->checkReturnStatus(retStatus);
7668 } else {
Sarah Chinef7f9222020-01-30 10:37:08 -08007669 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Michelee218c362019-02-27 22:48:48 -08007670 }
7671
7672 return 0;
7673}
7674
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007675int radio_1_5::sendDeviceStateResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007676 int responseType, int serial, RIL_Errno e,
7677 void *response, size_t responselen) {
7678#if VDBG
7679 RLOGD("sendDeviceStateResponse: serial %d", serial);
7680#endif
7681
7682 if (radioService[slotId]->mRadioResponse != NULL) {
7683 RadioResponseInfo responseInfo = {};
7684 populateResponseInfo(responseInfo, serial, responseType, e);
7685 Return<void> retStatus
7686 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
7687 radioService[slotId]->checkReturnStatus(retStatus);
7688 } else {
7689 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
7690 }
7691
7692 return 0;
7693}
7694
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007695int radio_1_5::setCarrierInfoForImsiEncryptionResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007696 int responseType, int serial, RIL_Errno e,
7697 void *response, size_t responseLen) {
7698 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
7699 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7700 RadioResponseInfo responseInfo = {};
7701 populateResponseInfo(responseInfo, serial, responseType, e);
7702 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4->
7703 setCarrierInfoForImsiEncryptionResponse(responseInfo);
7704 radioService[slotId]->checkReturnStatus(retStatus);
7705 } else {
7706 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponseV1_4 == "
7707 "NULL", slotId);
7708 }
7709 return 0;
7710}
7711
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007712int radio_1_5::setIndicationFilterResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007713 int responseType, int serial, RIL_Errno e,
7714 void *response, size_t responselen) {
7715#if VDBG
7716 RLOGD("setIndicationFilterResponse: serial %d", serial);
7717#endif
Sarah Chinef7f9222020-01-30 10:37:08 -08007718 RadioResponseInfo responseInfo = {};
7719 populateResponseInfo(responseInfo, serial, responseType, e);
paulye91d34712019-02-07 19:02:02 -08007720
Sarah Chinef7f9222020-01-30 10:37:08 -08007721 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7722 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
7723 ->setIndicationFilterResponse_1_5(responseInfo);
7724 radioService[slotId]->checkReturnStatus(retStatus);
7725 } else if (radioService[slotId]->mRadioResponse != NULL) {
7726 Return<void> retStatus = radioService[slotId]->mRadioResponse
7727 ->setIndicationFilterResponse(responseInfo);
paulye91d34712019-02-07 19:02:02 -08007728 radioService[slotId]->checkReturnStatus(retStatus);
7729 } else {
Sarah Chinef7f9222020-01-30 10:37:08 -08007730 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL", slotId);
paulye91d34712019-02-07 19:02:02 -08007731 }
7732
7733 return 0;
7734}
7735
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007736int radio_1_5::setSimCardPowerResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007737 int responseType, int serial, RIL_Errno e,
7738 void *response, size_t responseLen) {
7739#if VDBG
7740 RLOGD("setSimCardPowerResponse: serial %d", serial);
7741#endif
7742
7743 if (radioService[slotId]->mRadioResponse != NULL
7744 || radioService[slotId]->mRadioResponseV1_4 != NULL) {
7745 RadioResponseInfo responseInfo = {};
7746 populateResponseInfo(responseInfo, serial, responseType, e);
7747 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7748 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4->
7749 setSimCardPowerResponse_1_1(responseInfo);
7750 radioService[slotId]->checkReturnStatus(retStatus);
7751 } else {
7752 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_4 == NULL",
7753 slotId);
7754 Return<void> retStatus
7755 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
7756 radioService[slotId]->checkReturnStatus(retStatus);
7757 }
7758 } else {
7759 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL && "
7760 "radioService[%d]->mRadioResponseV1_4 == NULL", slotId, slotId);
7761 }
7762 return 0;
7763}
7764
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007765int radio_1_5::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
paulye91d34712019-02-07 19:02:02 -08007766 void *response, size_t responseLen) {
7767#if VDBG
7768 RLOGD("startNetworkScanResponse: serial %d", serial);
7769#endif
Sarah Chinef7f9222020-01-30 10:37:08 -08007770 RadioResponseInfo responseInfo = {};
7771 populateResponseInfo(responseInfo, serial, responseType, e);
paulye91d34712019-02-07 19:02:02 -08007772
Sarah Chinef7f9222020-01-30 10:37:08 -08007773 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
7774 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
7775 ->startNetworkScanResponse_1_5(responseInfo);
7776 radioService[slotId]->checkReturnStatus(retStatus);
7777 } else if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7778 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_4
7779 ->startNetworkScanResponse_1_4(responseInfo);
7780 radioService[slotId]->checkReturnStatus(retStatus);
7781 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
7782 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2
7783 ->startNetworkScanResponse(responseInfo);
paulye91d34712019-02-07 19:02:02 -08007784 radioService[slotId]->checkReturnStatus(retStatus);
7785 } else {
Sarah Chinef7f9222020-01-30 10:37:08 -08007786 RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponse == NULL", slotId);
paulyef2dd42e2019-02-19 20:28:19 -08007787 }
7788
7789 return 0;
7790}
7791
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007792int radio_1_5::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
paulye91d34712019-02-07 19:02:02 -08007793 void *response, size_t responseLen) {
7794#if VDBG
7795 RLOGD("stopNetworkScanResponse: serial %d", serial);
7796#endif
7797
7798 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7799 RadioResponseInfo responseInfo = {};
7800 populateResponseInfo(responseInfo, serial, responseType, e);
7801 Return<void> retStatus
7802 = radioService[slotId]->mRadioResponseV1_4->stopNetworkScanResponse(responseInfo);
7803 radioService[slotId]->checkReturnStatus(retStatus);
7804 } else {
7805 RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponseV1_4 == NULL", slotId);
7806 }
7807
7808 return 0;
7809}
7810
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007811int radio_1_5::emergencyDialResponse(int slotId, int responseType, int serial, RIL_Errno e,
sqian2e6e6c62019-02-26 16:55:02 -08007812 void *response, size_t responseLen) {
7813#if VDBG
7814 RLOGD("emergencyDialResponse: serial %d", serial);
7815#endif
7816
7817 if (radioService[slotId]->mRadioResponseV1_4 != NULL) {
7818 RadioResponseInfo responseInfo = {};
7819 populateResponseInfo(responseInfo, serial, responseType, e);
7820 Return<void> retStatus
7821 = radioService[slotId]->mRadioResponseV1_4->emergencyDialResponse(responseInfo);
7822 radioService[slotId]->checkReturnStatus(retStatus);
7823 } else {
7824 RLOGE("emergencyDialResponse: radioService[%d]->mRadioResponseV1_4 == NULL", slotId);
7825 }
7826 return 0;
7827}
7828
paulye91d34712019-02-07 19:02:02 -08007829void convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus *rilStatus,
7830 V1_1::KeepaliveStatus& halStatus) {
7831 halStatus.sessionHandle = rilStatus->sessionHandle;
7832 halStatus.code = static_cast<V1_1::KeepaliveStatusCode>(rilStatus->code);
7833}
7834
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007835int radio_1_5::startKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
paulye91d34712019-02-07 19:02:02 -08007836 void *response, size_t responseLen) {
7837#if VDBG
7838 RLOGD("%s(): %d", __FUNCTION__, serial);
7839#endif
7840 RadioResponseInfo responseInfo = {};
7841 populateResponseInfo(responseInfo, serial, responseType, e);
7842
7843 // If we don't have a radio service, there's nothing we can do
7844 if (radioService[slotId]->mRadioResponseV1_4 == NULL) {
7845 RLOGE("%s: radioService[%d]->mRadioResponseV1_4 == NULL", __FUNCTION__, slotId);
7846 return 0;
7847 }
7848
7849 V1_1::KeepaliveStatus ks = {};
7850 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
7851 RLOGE("%s: invalid response - %d", __FUNCTION__, static_cast<int>(e));
7852 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7853 } else {
7854 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
7855 }
7856
7857 Return<void> retStatus =
7858 radioService[slotId]->mRadioResponseV1_4->startKeepaliveResponse(responseInfo, ks);
7859 radioService[slotId]->checkReturnStatus(retStatus);
7860 return 0;
7861}
7862
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007863int radio_1_5::stopKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
paulye91d34712019-02-07 19:02:02 -08007864 void *response, size_t responseLen) {
7865#if VDBG
7866 RLOGD("%s(): %d", __FUNCTION__, serial);
7867#endif
7868 RadioResponseInfo responseInfo = {};
7869 populateResponseInfo(responseInfo, serial, responseType, e);
7870
7871 // If we don't have a radio service, there's nothing we can do
7872 if (radioService[slotId]->mRadioResponseV1_4 == NULL) {
7873 RLOGE("%s: radioService[%d]->mRadioResponseV1_4 == NULL", __FUNCTION__, slotId);
7874 return 0;
7875 }
7876
7877 Return<void> retStatus =
7878 radioService[slotId]->mRadioResponseV1_4->stopKeepaliveResponse(responseInfo);
7879 radioService[slotId]->checkReturnStatus(retStatus);
7880 return 0;
7881}
7882
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007883int radio_1_5::getModemStackStatusResponse(int slotId, int responseType, int serial, RIL_Errno e,
Nazanin Bakhshi25443002019-02-21 16:52:32 -08007884 void *response, size_t responseLen) {
7885#if VDBG
7886 RLOGD("%s(): %d", __FUNCTION__, serial);
7887#endif
7888 RadioResponseInfo responseInfo = {};
7889 populateResponseInfo(responseInfo, serial, responseType, e);
7890
7891 // If we don't have a radio service, there's nothing we can do
Malcolm Chen4bb42072019-02-22 18:21:48 -08007892 if (radioService[slotId]->mRadioResponseV1_3 == NULL) {
7893 RLOGE("%s: radioService[%d]->mRadioResponseV1_3 == NULL", __FUNCTION__, slotId);
Nazanin Bakhshi25443002019-02-21 16:52:32 -08007894 return 0;
7895 }
7896
7897 Return<void> retStatus =
Malcolm Chen4bb42072019-02-22 18:21:48 -08007898 radioService[slotId]->mRadioResponseV1_3->getModemStackStatusResponse(
Nazanin Bakhshi25443002019-02-21 16:52:32 -08007899 responseInfo, true);
7900 radioService[slotId]->checkReturnStatus(retStatus);
Malcolm Chen4bb42072019-02-22 18:21:48 -08007901 return 0;
Nazanin Bakhshi25443002019-02-21 16:52:32 -08007902}
7903
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007904int radio_1_5::enableModemResponse(int slotId, int responseType, int serial, RIL_Errno e,
Nazanin Bakhshi42acd932019-02-27 15:05:39 -08007905 void *response, size_t responseLen) {
7906#if VDBG
7907 RLOGD("%s(): %d", __FUNCTION__, serial);
7908#endif
7909 RadioResponseInfo responseInfo = {};
7910 populateResponseInfo(responseInfo, serial, responseType, e);
7911
7912 // If we don't have a radio service, there's nothing we can do
7913 if (radioService[slotId]->mRadioResponseV1_3 == NULL) {
7914 RLOGE("%s: radioService[%d]->mRadioResponseV1_3 == NULL", __FUNCTION__, slotId);
7915 return 0;
7916 }
7917
7918 Return<void> retStatus =
7919 radioService[slotId]->mRadioResponseV1_3->enableModemResponse(responseInfo);
7920 radioService[slotId]->checkReturnStatus(retStatus);
7921 return 0;
7922}
7923
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007924int radio_1_5::sendRequestRawResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007925 int responseType, int serial, RIL_Errno e,
7926 void *response, size_t responseLen) {
7927#if VDBG
7928 RLOGD("sendRequestRawResponse: serial %d", serial);
7929#endif
7930
7931 if (!kOemHookEnabled) return 0;
7932
7933 if (oemHookService[slotId]->mOemHookResponse != NULL) {
7934 RadioResponseInfo responseInfo = {};
7935 populateResponseInfo(responseInfo, serial, responseType, e);
7936 hidl_vec<uint8_t> data;
7937
7938 if (response == NULL) {
7939 RLOGE("sendRequestRawResponse: Invalid response");
7940 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7941 } else {
7942 data.setToExternal((uint8_t *) response, responseLen);
7943 }
7944 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
7945 sendRequestRawResponse(responseInfo, data);
7946 checkReturnStatus(slotId, retStatus, false);
7947 } else {
7948 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
7949 slotId);
7950 }
7951
7952 return 0;
7953}
7954
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007955int radio_1_5::sendRequestStringsResponse(int slotId,
paulye91d34712019-02-07 19:02:02 -08007956 int responseType, int serial, RIL_Errno e,
7957 void *response, size_t responseLen) {
7958#if VDBG
7959 RLOGD("sendRequestStringsResponse: serial %d", serial);
7960#endif
7961
7962 if (!kOemHookEnabled) return 0;
7963
7964 if (oemHookService[slotId]->mOemHookResponse != NULL) {
7965 RadioResponseInfo responseInfo = {};
7966 populateResponseInfo(responseInfo, serial, responseType, e);
7967 hidl_vec<hidl_string> data;
7968
7969 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
7970 RLOGE("sendRequestStringsResponse Invalid response: NULL");
7971 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
7972 } else {
7973 char **resp = (char **) response;
7974 int numStrings = responseLen / sizeof(char *);
7975 data.resize(numStrings);
7976 for (int i = 0; i < numStrings; i++) {
7977 data[i] = convertCharPtrToHidlString(resp[i]);
7978 }
7979 }
7980 Return<void> retStatus
7981 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
7982 responseInfo, data);
7983 checkReturnStatus(slotId, retStatus, false);
7984 } else {
7985 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
7986 "NULL", slotId);
7987 }
7988
7989 return 0;
7990}
7991
Malcolm Chen6b9984e2019-10-10 14:44:58 -07007992int radio_1_5::setSystemSelectionChannelsResponse(int slotId, int responseType, int serial,
Malcolm Chen4bb42072019-02-22 18:21:48 -08007993 RIL_Errno e, void* /* response */, size_t responseLen) {
7994#if VDBG
Sarah Chinef7f9222020-01-30 10:37:08 -08007995 RLOGD("setSystemSelectionChannelsResponse: serial %d", serial);
Malcolm Chen4bb42072019-02-22 18:21:48 -08007996#endif
7997 RadioResponseInfo responseInfo = {};
7998 populateResponseInfo(responseInfo, serial, responseType, e);
7999
Sarah Chinef7f9222020-01-30 10:37:08 -08008000 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
8001 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
8002 ->setSystemSelectionChannelsResponse_1_5(responseInfo);
8003 radioService[slotId]->checkReturnStatus(retStatus);
8004 } else if (radioService[slotId]->mRadioResponseV1_3 != NULL) {
8005 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_3
8006 ->setSystemSelectionChannelsResponse(responseInfo);
8007 radioService[slotId]->checkReturnStatus(retStatus);
8008 } else {
8009 RLOGE("setSystemSelectionChannelsResponse: radioService[%d]->mRadioResponse == NULL",
8010 slotId);
Malcolm Chen4bb42072019-02-22 18:21:48 -08008011 }
8012
Malcolm Chen4bb42072019-02-22 18:21:48 -08008013 return 0;
8014}
8015
Sarah Chinef7f9222020-01-30 10:37:08 -08008016int radio_1_5::setSignalStrengthReportingCriteriaResponse(int slotId, int responseType, int serial,
8017 RIL_Errno e, void* /* response */, size_t responseLen) {
Shuo Qian4fffb032019-11-08 17:59:42 -08008018#if VDBG
Sarah Chinef7f9222020-01-30 10:37:08 -08008019 RLOGD("setSignalStrengthReportingCriteriaResponse: serial %d", serial);
Shuo Qian4fffb032019-11-08 17:59:42 -08008020#endif
8021 RadioResponseInfo responseInfo = {};
8022 populateResponseInfo(responseInfo, serial, responseType, e);
8023
Sarah Chinef7f9222020-01-30 10:37:08 -08008024 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
8025 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
8026 ->setSignalStrengthReportingCriteriaResponse_1_5(responseInfo);
Shuo Qian4fffb032019-11-08 17:59:42 -08008027 radioService[slotId]->checkReturnStatus(retStatus);
Sarah Chinef7f9222020-01-30 10:37:08 -08008028 } else if (radioService[slotId]->mRadioResponseV1_2 != NULL) {
8029 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_2
8030 ->setSignalStrengthReportingCriteriaResponse(responseInfo);
8031 radioService[slotId]->checkReturnStatus(retStatus);
8032 } else {
8033 RLOGE("setSignalStrengthReportingCriteriaResponse: radioService[%d]->mRadioResponse "
8034 "== NULL", slotId);
Shuo Qian4fffb032019-11-08 17:59:42 -08008035 }
Sarah Chinef7f9222020-01-30 10:37:08 -08008036
Shuo Qian4fffb032019-11-08 17:59:42 -08008037 return 0;
8038}
8039
Malcolm Chenc2008a22019-11-12 18:43:09 -08008040int radio_1_5::enableUiccApplicationsResponse(int slotId, int responseType, int serial,
8041 RIL_Errno e, void* /* response */, size_t responseLen) {
8042#if VDBG
8043 RLOGD("%s(): %d", __FUNCTION__, serial);
8044#endif
8045 RadioResponseInfo responseInfo = {};
8046 populateResponseInfo(responseInfo, serial, responseType, e);
8047
8048 // If we don't have a radio service, there's nothing we can do
8049 if (radioService[slotId]->mRadioResponseV1_5 == NULL) {
8050 RLOGE("%s: radioService[%d]->mRadioResponseV1_5 == NULL", __FUNCTION__, slotId);
8051 return 0;
8052 }
8053
8054 Return<void> retStatus =
8055 radioService[slotId]->mRadioResponseV1_5->enableUiccApplicationsResponse(
8056 responseInfo);
8057 radioService[slotId]->checkReturnStatus(retStatus);
8058 return 0;
8059}
8060
8061int radio_1_5::areUiccApplicationsEnabledResponse(int slotId, int responseType, int serial,
8062 RIL_Errno e, void* response, size_t responseLen) {
8063#if VDBG
8064 RLOGD("%s(): %d", __FUNCTION__, serial);
8065#endif
8066 RadioResponseInfo responseInfo = {};
8067 populateResponseInfo(responseInfo, serial, responseType, e);
8068
8069 // If we don't have a radio service, there's nothing we can do
8070 if (radioService[slotId]->mRadioResponseV1_5 == NULL) {
8071 RLOGE("%s: radioService[%d]->mRadioResponseV1_5 == NULL", __FUNCTION__, slotId);
8072 return 0;
8073 }
8074
8075 bool enable = false;
8076 if (response == NULL || responseLen != sizeof(bool)) {
8077 RLOGE("isSimDetachedFromNetwork Invalid response.");
8078 } else {
8079 enable = (*((bool *) response));
8080 }
8081
8082 Return<void> retStatus =
8083 radioService[slotId]->mRadioResponseV1_5->areUiccApplicationsEnabledResponse(
8084 responseInfo, enable);
8085 radioService[slotId]->checkReturnStatus(retStatus);
8086 return 0;
8087}
8088
Nathan Harold8a9283c2020-01-02 15:31:41 -08008089int radio_1_5::getBarringInfoResponse(int slotId,
8090 int responseType, int serial, RIL_Errno e,
8091 void *response, size_t responselen) {
8092#if VDBG
8093 RLOGD("getBarringInfoResponse: serial %d", serial);
8094#endif
8095
8096 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
8097 RadioResponseInfo responseInfo = {};
8098 populateResponseInfo(responseInfo, serial, responseType, e);
8099 hidl_vec<::android::hardware::radio::V1_5::BarringInfo> barringInfo;
8100 Return<void> retStatus
8101 = radioService[slotId]->mRadioResponseV1_5->
8102 getBarringInfoResponse(responseInfo, barringInfo);
8103 radioService[slotId]->checkReturnStatus(retStatus);
8104 } else {
8105 RLOGE("getBarringInfoResponse: radioService[%d]->mRadioResponse == NULL",
8106 slotId);
8107 }
8108
8109 return 0;
8110}
Nathan Harold30a7d092020-01-02 15:08:37 -08008111
Sarah Chinef7f9222020-01-30 10:37:08 -08008112int radio_1_5::sendCdmaSmsExpectMoreResponse(int slotId, int responseType, int serial, RIL_Errno e,
8113 void *response, size_t responseLen) {
Sarah Chin65f1d7f2019-12-18 17:07:39 -08008114#if VDBG
Sarah Chinef7f9222020-01-30 10:37:08 -08008115 RLOGD("sendCdmaSmsExpectMoreResponse: serial %d", serial);
Sarah Chin65f1d7f2019-12-18 17:07:39 -08008116#endif
8117
8118 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
8119 RadioResponseInfo responseInfo = {};
Sarah Chinef7f9222020-01-30 10:37:08 -08008120 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
8121 responseLen);
8122
Sarah Chin65f1d7f2019-12-18 17:07:39 -08008123 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
Sarah Chinef7f9222020-01-30 10:37:08 -08008124 ->sendCdmaSmsExpectMoreResponse(responseInfo, result);
Sarah Chin65f1d7f2019-12-18 17:07:39 -08008125 radioService[slotId]->checkReturnStatus(retStatus);
8126 } else {
Sarah Chinef7f9222020-01-30 10:37:08 -08008127 RLOGE("sendCdmaSmsExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
8128 }
8129
8130 return 0;
8131}
8132
8133int radio_1_5::supplySimDepersonalizationResponse(int slotId, int responseType, int serial,
8134 RIL_Errno e, void *response, size_t responseLen) {
8135#if VDBG
8136 RLOGD("supplySimDepersonalizationResponse: serial %d", serial);
8137#endif
8138
8139 if (radioService[slotId]->mRadioResponseV1_5 != NULL) {
8140 RadioResponseInfo responseInfo = {};
8141 int persoType = -1, remainingRetries = -1;
8142 int numInts = responseLen / sizeof(int);
8143 if (response == NULL || numInts != 2) {
8144 RLOGE("getClirResponse Invalid response: NULL");
8145 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
8146 } else {
8147 int *pInt = (int *) response;
8148 persoType = pInt[0];
8149 remainingRetries = pInt[1];
8150 }
8151 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_5
8152 ->supplySimDepersonalizationResponse(responseInfo, (V1_5::PersoSubstate) persoType,
8153 remainingRetries);
8154 radioService[slotId]->checkReturnStatus(retStatus);
8155 } else {
8156 RLOGE("supplySimDepersonalizationResponse: radioService[%d]->mRadioResponseV1_5 == "
8157 "NULL", slotId);
Sarah Chin65f1d7f2019-12-18 17:07:39 -08008158 }
8159
8160 return 0;
8161}
8162
paulye91d34712019-02-07 19:02:02 -08008163/***************************************************************************************************
8164 * INDICATION FUNCTIONS
8165 * The below function handle unsolicited messages coming from the Radio
8166 * (messages for which there is no pending request)
8167 **************************************************************************************************/
8168
8169RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
8170 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
8171 (RadioIndicationType::UNSOLICITED_ACK_EXP);
8172}
8173
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008174int radio_1_5::radioStateChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008175 int indicationType, int token, RIL_Errno e, void *response,
8176 size_t responseLen) {
8177 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8178 RadioState radioState =
8179 (RadioState) CALL_ONSTATEREQUEST(slotId);
8180 RLOGD("radioStateChangedInd: radioState %d", radioState);
8181 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
8182 convertIntToRadioIndicationType(indicationType), radioState);
8183 radioService[slotId]->checkReturnStatus(retStatus);
8184 } else {
8185 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
8186 }
8187
8188 return 0;
8189}
8190
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008191int radio_1_5::callStateChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008192 int indicationType, int token, RIL_Errno e, void *response,
8193 size_t responseLen) {
8194 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8195#if VDBG
8196 RLOGD("callStateChangedInd");
8197#endif
8198 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
8199 convertIntToRadioIndicationType(indicationType));
8200 radioService[slotId]->checkReturnStatus(retStatus);
8201 } else {
8202 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
8203 }
8204
8205 return 0;
8206}
8207
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008208int radio_1_5::networkStateChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008209 int indicationType, int token, RIL_Errno e, void *response,
8210 size_t responseLen) {
8211 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8212#if VDBG
8213 RLOGD("networkStateChangedInd");
8214#endif
8215 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
8216 convertIntToRadioIndicationType(indicationType));
8217 radioService[slotId]->checkReturnStatus(retStatus);
8218 } else {
8219 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
8220 slotId);
8221 }
8222
8223 return 0;
8224}
8225
8226uint8_t hexCharToInt(uint8_t c) {
8227 if (c >= '0' && c <= '9') return (c - '0');
8228 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
8229 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
8230
8231 return INVALID_HEX_CHAR;
8232}
8233
8234uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
8235 if (responseLen % 2 != 0) {
8236 return NULL;
8237 }
8238
8239 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
8240 if (bytes == NULL) {
8241 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
8242 return NULL;
8243 }
8244 uint8_t *hexString = (uint8_t *)response;
8245
8246 for (size_t i = 0; i < responseLen; i += 2) {
8247 uint8_t hexChar1 = hexCharToInt(hexString[i]);
8248 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
8249
8250 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
8251 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
8252 hexString[i], hexString[i + 1]);
8253 free(bytes);
8254 return NULL;
8255 }
8256 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
8257 }
8258
8259 return bytes;
8260}
8261
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008262int radio_1_5::newSmsInd(int slotId, int indicationType,
paulye91d34712019-02-07 19:02:02 -08008263 int token, RIL_Errno e, void *response, size_t responseLen) {
8264 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8265 if (response == NULL || responseLen == 0) {
8266 RLOGE("newSmsInd: invalid response");
8267 return 0;
8268 }
8269
8270 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
8271 if (bytes == NULL) {
8272 RLOGE("newSmsInd: convertHexStringToBytes failed");
8273 return 0;
8274 }
8275
8276 hidl_vec<uint8_t> pdu;
8277 pdu.setToExternal(bytes, responseLen/2);
8278#if VDBG
8279 RLOGD("newSmsInd");
8280#endif
8281 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
8282 convertIntToRadioIndicationType(indicationType), pdu);
8283 radioService[slotId]->checkReturnStatus(retStatus);
8284 free(bytes);
8285 } else {
8286 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
8287 }
8288
8289 return 0;
8290}
8291
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008292int radio_1_5::newSmsStatusReportInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008293 int indicationType, int token, RIL_Errno e, void *response,
8294 size_t responseLen) {
8295 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8296 if (response == NULL || responseLen == 0) {
8297 RLOGE("newSmsStatusReportInd: invalid response");
8298 return 0;
8299 }
8300
8301 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
8302 if (bytes == NULL) {
8303 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
8304 return 0;
8305 }
8306
8307 hidl_vec<uint8_t> pdu;
8308 pdu.setToExternal(bytes, responseLen/2);
8309#if VDBG
8310 RLOGD("newSmsStatusReportInd");
8311#endif
8312 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
8313 convertIntToRadioIndicationType(indicationType), pdu);
8314 radioService[slotId]->checkReturnStatus(retStatus);
8315 free(bytes);
8316 } else {
8317 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
8318 }
8319
8320 return 0;
8321}
8322
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008323int radio_1_5::newSmsOnSimInd(int slotId, int indicationType,
paulye91d34712019-02-07 19:02:02 -08008324 int token, RIL_Errno e, void *response, size_t responseLen) {
8325 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8326 if (response == NULL || responseLen != sizeof(int)) {
8327 RLOGE("newSmsOnSimInd: invalid response");
8328 return 0;
8329 }
8330 int32_t recordNumber = ((int32_t *) response)[0];
8331#if VDBG
8332 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
8333#endif
8334 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
8335 convertIntToRadioIndicationType(indicationType), recordNumber);
8336 radioService[slotId]->checkReturnStatus(retStatus);
8337 } else {
8338 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
8339 }
8340
8341 return 0;
8342}
8343
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008344int radio_1_5::onUssdInd(int slotId, int indicationType,
paulye91d34712019-02-07 19:02:02 -08008345 int token, RIL_Errno e, void *response, size_t responseLen) {
8346 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8347 if (response == NULL || responseLen != 2 * sizeof(char *)) {
8348 RLOGE("onUssdInd: invalid response");
8349 return 0;
8350 }
8351 char **strings = (char **) response;
8352 char *mode = strings[0];
8353 hidl_string msg = convertCharPtrToHidlString(strings[1]);
8354 UssdModeType modeType = (UssdModeType) atoi(mode);
8355#if VDBG
8356 RLOGD("onUssdInd: mode %s", mode);
8357#endif
8358 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
8359 convertIntToRadioIndicationType(indicationType), modeType, msg);
8360 radioService[slotId]->checkReturnStatus(retStatus);
8361 } else {
8362 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
8363 }
8364
8365 return 0;
8366}
8367
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008368int radio_1_5::nitzTimeReceivedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008369 int indicationType, int token, RIL_Errno e, void *response,
8370 size_t responseLen) {
8371 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8372 if (response == NULL || responseLen == 0) {
8373 RLOGE("nitzTimeReceivedInd: invalid response");
8374 return 0;
8375 }
8376 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
8377#if VDBG
8378 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
8379 nitzTimeReceived[slotId]);
8380#endif
8381 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
8382 convertIntToRadioIndicationType(indicationType), nitzTime,
8383 nitzTimeReceived[slotId]);
8384 radioService[slotId]->checkReturnStatus(retStatus);
8385 } else {
8386 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
8387 return -1;
8388 }
8389
8390 return 0;
8391}
8392
8393void convertRilSignalStrengthToHal(void *response, size_t responseLen,
8394 SignalStrength& signalStrength) {
8395 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
8396
8397 // Fixup LTE for backwards compatibility
8398 // signalStrength: -1 -> 99
8399 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
8400 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
8401 }
8402 // rsrp: -1 -> INT_MAX all other negative value to positive.
8403 // So remap here
8404 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
8405 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
8406 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
8407 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
8408 }
8409 // rsrq: -1 -> INT_MAX
8410 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
8411 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
8412 }
8413 // Not remapping rssnr is already using INT_MAX
8414 // cqi: -1 -> INT_MAX
8415 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
8416 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
8417 }
8418
8419 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
8420 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
8421 // RIL_SignalStrength_v10 not support gw.timingAdvance. Set to INT_MAX as
8422 // invalid value.
8423 signalStrength.gw.timingAdvance = INT_MAX;
8424
8425 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
8426 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
8427 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
8428 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
8429 signalStrength.evdo.signalNoiseRatio =
8430 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
8431 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
8432 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
8433 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
8434 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
8435 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
8436 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
8437 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
8438}
8439
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008440int radio_1_5::currentSignalStrengthInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008441 int indicationType, int token, RIL_Errno e,
8442 void *response, size_t responseLen) {
8443 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8444 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
8445 RLOGE("currentSignalStrengthInd: invalid response");
8446 return 0;
8447 }
8448
8449 SignalStrength signalStrength = {};
8450 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
8451
8452#if VDBG
8453 RLOGD("currentSignalStrengthInd");
8454#endif
8455 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
8456 convertIntToRadioIndicationType(indicationType), signalStrength);
8457 radioService[slotId]->checkReturnStatus(retStatus);
8458 } else {
8459 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
8460 slotId);
8461 }
8462
8463 return 0;
8464}
8465
8466void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
8467 SetupDataCallResult& dcResult) {
8468 dcResult.status = (DataCallFailCause) dcResponse->status;
8469 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
8470 dcResult.cid = dcResponse->cid;
8471 dcResult.active = dcResponse->active;
8472 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
8473 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
8474 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
8475 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
8476 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
8477 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
8478 dcResult.mtu = dcResponse->mtu;
8479}
8480
Jack Yud5a67ed2019-03-06 14:59:36 -08008481hidl_vec<hidl_string> split(hidl_string str) {
8482 std::vector<hidl_string> ret;
8483 std::stringstream ss(static_cast<std::string>(str));
8484
8485 std::string tok;
8486
8487 while(getline(ss, tok, ' ')) {
8488 ret.push_back(hidl_string(tok));
8489 }
8490
8491 return ret;
8492}
8493
8494::android::hardware::radio::V1_4::PdpProtocolType convertToPdpProtocolType(hidl_string str) {
8495 if (strncmp("IP", str.c_str(), 2) == 0) {
8496 return ::android::hardware::radio::V1_4::PdpProtocolType::IP;
8497 } else if (strncmp("IPV6", str.c_str(), 4) == 0) {
8498 return ::android::hardware::radio::V1_4::PdpProtocolType::IPV6;
8499 } else if (strncmp("IPV4V6", str.c_str(), 6) == 0) {
8500 return ::android::hardware::radio::V1_4::PdpProtocolType::IPV4V6;
8501 } else if (strncmp("PPP", str.c_str(), 3) == 0) {
8502 return ::android::hardware::radio::V1_4::PdpProtocolType::PPP;
8503 } else if (strncmp("NON_IP", str.c_str(), 6) == 0) {
8504 return ::android::hardware::radio::V1_4::PdpProtocolType::NON_IP;
8505 } else if (strncmp("UNSTRUCTURED", str.c_str(), 12) == 0) {
8506 return ::android::hardware::radio::V1_4::PdpProtocolType::UNSTRUCTURED;
8507 } else {
8508 return ::android::hardware::radio::V1_4::PdpProtocolType::UNKNOWN;
8509 }
8510}
8511
8512void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
8513 ::android::hardware::radio::V1_4::SetupDataCallResult& dcResult) {
8514 dcResult.cause = (::android::hardware::radio::V1_4::DataCallFailCause) dcResponse->status;
8515 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
8516 dcResult.cid = dcResponse->cid;
8517 dcResult.active = (::android::hardware::radio::V1_4::DataConnActiveStatus)dcResponse->active;
8518 dcResult.type = convertToPdpProtocolType(convertCharPtrToHidlString(dcResponse->type));
8519 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
8520 dcResult.addresses = split(convertCharPtrToHidlString(dcResponse->addresses));
8521 dcResult.dnses = split(convertCharPtrToHidlString(dcResponse->dnses));
8522 dcResult.gateways = split(convertCharPtrToHidlString(dcResponse->gateways));
8523 dcResult.pcscf = split(convertCharPtrToHidlString(dcResponse->pcscf));
8524 dcResult.mtu = dcResponse->mtu;
8525}
8526
Sarah Chin9ecfc322020-01-16 10:35:02 -08008527void convertRilDataCallToHal(RIL_Data_Call_Response_v12 *dcResponse,
Jack Yufd2ea3f2019-12-14 10:43:41 -08008528 ::android::hardware::radio::V1_5::SetupDataCallResult& dcResult) {
8529 dcResult.cause = (::android::hardware::radio::V1_4::DataCallFailCause) dcResponse->status;
8530 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
8531 dcResult.cid = dcResponse->cid;
8532 dcResult.active = (::android::hardware::radio::V1_4::DataConnActiveStatus)dcResponse->active;
8533 dcResult.type = convertToPdpProtocolType(convertCharPtrToHidlString(dcResponse->type));
8534 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
8535
8536 std::vector<::android::hardware::radio::V1_5::LinkAddress> linkAddresses;
8537 std::stringstream ss(static_cast<std::string>(dcResponse->addresses));
8538 std::string tok;
8539 while(getline(ss, tok, ' ')) {
8540 ::android::hardware::radio::V1_5::LinkAddress la;
8541 la.address = hidl_string(tok);
8542 la.properties = 0;
Sarah Chin2d868152020-01-22 18:06:13 -08008543 la.deprecationTime = 0;
8544 la.expirationTime = 0;
Jack Yufd2ea3f2019-12-14 10:43:41 -08008545 linkAddresses.push_back(la);
8546 }
8547
8548 dcResult.addresses = linkAddresses;
8549 dcResult.dnses = split(convertCharPtrToHidlString(dcResponse->dnses));
8550 dcResult.gateways = split(convertCharPtrToHidlString(dcResponse->gateways));
8551 dcResult.pcscf = split(convertCharPtrToHidlString(dcResponse->pcscf));
Sarah Chin9ecfc322020-01-16 10:35:02 -08008552 dcResult.mtuV4 = dcResponse->mtuV4;
8553 dcResult.mtuV6 = dcResponse->mtuV6;
Jack Yufd2ea3f2019-12-14 10:43:41 -08008554}
8555
Jack Yud5a67ed2019-03-06 14:59:36 -08008556
paulye91d34712019-02-07 19:02:02 -08008557void convertRilDataCallListToHal(void *response, size_t responseLen,
8558 hidl_vec<SetupDataCallResult>& dcResultList) {
8559 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
8560
8561 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
8562 dcResultList.resize(num);
8563 for (int i = 0; i < num; i++) {
8564 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
8565 }
8566}
8567
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008568int radio_1_5::dataCallListChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008569 int indicationType, int token, RIL_Errno e, void *response,
8570 size_t responseLen) {
8571 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8572 if ((response == NULL && responseLen != 0)
8573 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
8574 RLOGE("dataCallListChangedInd: invalid response");
8575 return 0;
8576 }
8577 hidl_vec<SetupDataCallResult> dcList;
8578 convertRilDataCallListToHal(response, responseLen, dcList);
8579#if VDBG
8580 RLOGD("dataCallListChangedInd");
8581#endif
8582 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
8583 convertIntToRadioIndicationType(indicationType), dcList);
8584 radioService[slotId]->checkReturnStatus(retStatus);
8585 } else {
8586 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
8587 }
8588
8589 return 0;
8590}
8591
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008592int radio_1_5::suppSvcNotifyInd(int slotId, int indicationType,
paulye91d34712019-02-07 19:02:02 -08008593 int token, RIL_Errno e, void *response, size_t responseLen) {
8594 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8595 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
8596 RLOGE("suppSvcNotifyInd: invalid response");
8597 return 0;
8598 }
8599
8600 SuppSvcNotification suppSvc = {};
8601 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
8602 suppSvc.isMT = ssn->notificationType;
8603 suppSvc.code = ssn->code;
8604 suppSvc.index = ssn->index;
8605 suppSvc.type = ssn->type;
8606 suppSvc.number = convertCharPtrToHidlString(ssn->number);
8607
8608#if VDBG
8609 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
8610 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
8611#endif
8612 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
8613 convertIntToRadioIndicationType(indicationType), suppSvc);
8614 radioService[slotId]->checkReturnStatus(retStatus);
8615 } else {
8616 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
8617 }
8618
8619 return 0;
8620}
8621
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008622int radio_1_5::stkSessionEndInd(int slotId, int indicationType,
paulye91d34712019-02-07 19:02:02 -08008623 int token, RIL_Errno e, void *response, size_t responseLen) {
8624 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8625#if VDBG
8626 RLOGD("stkSessionEndInd");
8627#endif
8628 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
8629 convertIntToRadioIndicationType(indicationType));
8630 radioService[slotId]->checkReturnStatus(retStatus);
8631 } else {
8632 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
8633 }
8634
8635 return 0;
8636}
8637
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008638int radio_1_5::stkProactiveCommandInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008639 int indicationType, int token, RIL_Errno e, void *response,
8640 size_t responseLen) {
8641 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8642 if (response == NULL || responseLen == 0) {
8643 RLOGE("stkProactiveCommandInd: invalid response");
8644 return 0;
8645 }
8646#if VDBG
8647 RLOGD("stkProactiveCommandInd");
8648#endif
8649 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
8650 convertIntToRadioIndicationType(indicationType),
8651 convertCharPtrToHidlString((char *) response));
8652 radioService[slotId]->checkReturnStatus(retStatus);
8653 } else {
8654 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
8655 }
8656
8657 return 0;
8658}
8659
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008660int radio_1_5::stkEventNotifyInd(int slotId, int indicationType,
paulye91d34712019-02-07 19:02:02 -08008661 int token, RIL_Errno e, void *response, size_t responseLen) {
8662 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8663 if (response == NULL || responseLen == 0) {
8664 RLOGE("stkEventNotifyInd: invalid response");
8665 return 0;
8666 }
8667#if VDBG
8668 RLOGD("stkEventNotifyInd");
8669#endif
8670 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
8671 convertIntToRadioIndicationType(indicationType),
8672 convertCharPtrToHidlString((char *) response));
8673 radioService[slotId]->checkReturnStatus(retStatus);
8674 } else {
8675 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
8676 }
8677
8678 return 0;
8679}
8680
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008681int radio_1_5::stkCallSetupInd(int slotId, int indicationType,
paulye91d34712019-02-07 19:02:02 -08008682 int token, RIL_Errno e, void *response, size_t responseLen) {
8683 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8684 if (response == NULL || responseLen != sizeof(int)) {
8685 RLOGE("stkCallSetupInd: invalid response");
8686 return 0;
8687 }
8688 int32_t timeout = ((int32_t *) response)[0];
8689#if VDBG
8690 RLOGD("stkCallSetupInd: timeout %d", timeout);
8691#endif
8692 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
8693 convertIntToRadioIndicationType(indicationType), timeout);
8694 radioService[slotId]->checkReturnStatus(retStatus);
8695 } else {
8696 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
8697 }
8698
8699 return 0;
8700}
8701
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008702int radio_1_5::simSmsStorageFullInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008703 int indicationType, int token, RIL_Errno e, void *response,
8704 size_t responseLen) {
8705 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8706#if VDBG
8707 RLOGD("simSmsStorageFullInd");
8708#endif
8709 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
8710 convertIntToRadioIndicationType(indicationType));
8711 radioService[slotId]->checkReturnStatus(retStatus);
8712 } else {
8713 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
8714 }
8715
8716 return 0;
8717}
8718
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008719int radio_1_5::simRefreshInd(int slotId, int indicationType,
paulye91d34712019-02-07 19:02:02 -08008720 int token, RIL_Errno e, void *response, size_t responseLen) {
8721 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8722 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
8723 RLOGE("simRefreshInd: invalid response");
8724 return 0;
8725 }
8726
8727 SimRefreshResult refreshResult = {};
8728 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
8729 refreshResult.type =
8730 (V1_0::SimRefreshType) simRefreshResponse->result;
8731 refreshResult.efId = simRefreshResponse->ef_id;
8732 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
8733
8734#if VDBG
8735 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
8736#endif
8737 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
8738 convertIntToRadioIndicationType(indicationType), refreshResult);
8739 radioService[slotId]->checkReturnStatus(retStatus);
8740 } else {
8741 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
8742 }
8743
8744 return 0;
8745}
8746
8747void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
8748 CdmaSignalInfoRecord& record) {
8749 record.isPresent = signalInfoRecord->isPresent;
8750 record.signalType = signalInfoRecord->signalType;
8751 record.alertPitch = signalInfoRecord->alertPitch;
8752 record.signal = signalInfoRecord->signal;
8753}
8754
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008755int radio_1_5::callRingInd(int slotId, int indicationType,
paulye91d34712019-02-07 19:02:02 -08008756 int token, RIL_Errno e, void *response, size_t responseLen) {
8757 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8758 bool isGsm;
8759 CdmaSignalInfoRecord record = {};
8760 if (response == NULL || responseLen == 0) {
8761 isGsm = true;
8762 } else {
8763 isGsm = false;
8764 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
8765 RLOGE("callRingInd: invalid response");
8766 return 0;
8767 }
8768 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
8769 }
8770
8771#if VDBG
8772 RLOGD("callRingInd: isGsm %d", isGsm);
8773#endif
8774 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
8775 convertIntToRadioIndicationType(indicationType), isGsm, record);
8776 radioService[slotId]->checkReturnStatus(retStatus);
8777 } else {
8778 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
8779 }
8780
8781 return 0;
8782}
8783
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008784int radio_1_5::simStatusChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008785 int indicationType, int token, RIL_Errno e, void *response,
8786 size_t responseLen) {
8787 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8788#if VDBG
8789 RLOGD("simStatusChangedInd");
8790#endif
8791 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
8792 convertIntToRadioIndicationType(indicationType));
8793 radioService[slotId]->checkReturnStatus(retStatus);
8794 } else {
8795 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
8796 }
8797
8798 return 0;
8799}
8800
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008801int radio_1_5::cdmaNewSmsInd(int slotId, int indicationType,
paulye91d34712019-02-07 19:02:02 -08008802 int token, RIL_Errno e, void *response, size_t responseLen) {
8803 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8804 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
8805 RLOGE("cdmaNewSmsInd: invalid response");
8806 return 0;
8807 }
8808
8809 CdmaSmsMessage msg = {};
8810 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
8811 msg.teleserviceId = rilMsg->uTeleserviceID;
8812 msg.isServicePresent = rilMsg->bIsServicePresent;
8813 msg.serviceCategory = rilMsg->uServicecategory;
8814 msg.address.digitMode =
8815 (V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
8816 msg.address.numberMode =
8817 (V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
8818 msg.address.numberType =
8819 (V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
8820 msg.address.numberPlan =
8821 (V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
8822
8823 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
8824 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
8825
8826 msg.subAddress.subaddressType = (V1_0::CdmaSmsSubaddressType)
8827 rilMsg->sSubAddress.subaddressType;
8828 msg.subAddress.odd = rilMsg->sSubAddress.odd;
8829
8830 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
8831 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
8832
8833 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
8834 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
8835
8836#if VDBG
8837 RLOGD("cdmaNewSmsInd");
8838#endif
8839 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
8840 convertIntToRadioIndicationType(indicationType), msg);
8841 radioService[slotId]->checkReturnStatus(retStatus);
8842 } else {
8843 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
8844 }
8845
8846 return 0;
8847}
8848
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008849int radio_1_5::newBroadcastSmsInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008850 int indicationType, int token, RIL_Errno e, void *response,
8851 size_t responseLen) {
8852 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8853 if (response == NULL || responseLen == 0) {
8854 RLOGE("newBroadcastSmsInd: invalid response");
8855 return 0;
8856 }
8857
8858 hidl_vec<uint8_t> data;
8859 data.setToExternal((uint8_t *) response, responseLen);
8860#if VDBG
8861 RLOGD("newBroadcastSmsInd");
8862#endif
8863 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
8864 convertIntToRadioIndicationType(indicationType), data);
8865 radioService[slotId]->checkReturnStatus(retStatus);
8866 } else {
8867 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
8868 }
8869
8870 return 0;
8871}
8872
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008873int radio_1_5::cdmaRuimSmsStorageFullInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008874 int indicationType, int token, RIL_Errno e, void *response,
8875 size_t responseLen) {
8876 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8877#if VDBG
8878 RLOGD("cdmaRuimSmsStorageFullInd");
8879#endif
8880 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
8881 convertIntToRadioIndicationType(indicationType));
8882 radioService[slotId]->checkReturnStatus(retStatus);
8883 } else {
8884 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
8885 slotId);
8886 }
8887
8888 return 0;
8889}
8890
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008891int radio_1_5::restrictedStateChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008892 int indicationType, int token, RIL_Errno e, void *response,
8893 size_t responseLen) {
8894 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8895 if (response == NULL || responseLen != sizeof(int)) {
8896 RLOGE("restrictedStateChangedInd: invalid response");
8897 return 0;
8898 }
8899 int32_t state = ((int32_t *) response)[0];
8900#if VDBG
8901 RLOGD("restrictedStateChangedInd: state %d", state);
8902#endif
8903 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
8904 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
8905 radioService[slotId]->checkReturnStatus(retStatus);
8906 } else {
8907 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
8908 slotId);
8909 }
8910
8911 return 0;
8912}
8913
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008914int radio_1_5::enterEmergencyCallbackModeInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008915 int indicationType, int token, RIL_Errno e, void *response,
8916 size_t responseLen) {
8917 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8918#if VDBG
8919 RLOGD("enterEmergencyCallbackModeInd");
8920#endif
8921 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
8922 convertIntToRadioIndicationType(indicationType));
8923 radioService[slotId]->checkReturnStatus(retStatus);
8924 } else {
8925 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
8926 slotId);
8927 }
8928
8929 return 0;
8930}
8931
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008932int radio_1_5::cdmaCallWaitingInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008933 int indicationType, int token, RIL_Errno e, void *response,
8934 size_t responseLen) {
8935 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8936 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
8937 RLOGE("cdmaCallWaitingInd: invalid response");
8938 return 0;
8939 }
8940
8941 CdmaCallWaiting callWaitingRecord = {};
8942 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
8943 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
8944 callWaitingRecord.numberPresentation =
8945 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
8946 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
8947 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
8948 callWaitingRecord.signalInfoRecord);
8949 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
8950 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
8951
8952#if VDBG
8953 RLOGD("cdmaCallWaitingInd");
8954#endif
8955 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
8956 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
8957 radioService[slotId]->checkReturnStatus(retStatus);
8958 } else {
8959 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
8960 }
8961
8962 return 0;
8963}
8964
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008965int radio_1_5::cdmaOtaProvisionStatusInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008966 int indicationType, int token, RIL_Errno e, void *response,
8967 size_t responseLen) {
8968 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8969 if (response == NULL || responseLen != sizeof(int)) {
8970 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
8971 return 0;
8972 }
8973 int32_t status = ((int32_t *) response)[0];
8974#if VDBG
8975 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
8976#endif
8977 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
8978 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
8979 radioService[slotId]->checkReturnStatus(retStatus);
8980 } else {
8981 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
8982 slotId);
8983 }
8984
8985 return 0;
8986}
8987
Malcolm Chen6b9984e2019-10-10 14:44:58 -07008988int radio_1_5::cdmaInfoRecInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08008989 int indicationType, int token, RIL_Errno e, void *response,
8990 size_t responseLen) {
8991 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8992 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
8993 RLOGE("cdmaInfoRecInd: invalid response");
8994 return 0;
8995 }
8996
8997 CdmaInformationRecords records = {};
8998 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
8999
9000 char* string8 = NULL;
9001 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
9002 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
9003 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
9004 "additional ones", recordsRil->numberOfInfoRecs,
9005 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
9006 }
9007 records.infoRec.resize(num);
9008 for (int i = 0 ; i < num ; i++) {
9009 CdmaInformationRecord *record = &records.infoRec[i];
9010 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
9011 record->name = (CdmaInfoRecName) infoRec->name;
9012 // All vectors should be size 0 except one which will be size 1. Set everything to
9013 // size 0 initially.
9014 record->display.resize(0);
9015 record->number.resize(0);
9016 record->signal.resize(0);
9017 record->redir.resize(0);
9018 record->lineCtrl.resize(0);
9019 record->clir.resize(0);
9020 record->audioCtrl.resize(0);
9021 switch (infoRec->name) {
9022 case RIL_CDMA_DISPLAY_INFO_REC:
9023 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
9024 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
9025 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
9026 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
9027 CDMA_ALPHA_INFO_BUFFER_LENGTH);
9028 return 0;
9029 }
9030 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
9031 if (string8 == NULL) {
9032 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
9033 "responseCdmaInformationRecords");
9034 return 0;
9035 }
9036 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
9037 string8[(int)infoRec->rec.display.alpha_len] = '\0';
9038
9039 record->display.resize(1);
9040 record->display[0].alphaBuf = string8;
9041 free(string8);
9042 string8 = NULL;
9043 break;
9044 }
9045
9046 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
9047 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
9048 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
9049 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
9050 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
9051 "expected not more than %d", (int) infoRec->rec.number.len,
9052 CDMA_NUMBER_INFO_BUFFER_LENGTH);
9053 return 0;
9054 }
9055 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
9056 if (string8 == NULL) {
9057 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
9058 "responseCdmaInformationRecords");
9059 return 0;
9060 }
9061 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
9062 string8[(int)infoRec->rec.number.len] = '\0';
9063
9064 record->number.resize(1);
9065 record->number[0].number = string8;
9066 free(string8);
9067 string8 = NULL;
9068 record->number[0].numberType = infoRec->rec.number.number_type;
9069 record->number[0].numberPlan = infoRec->rec.number.number_plan;
9070 record->number[0].pi = infoRec->rec.number.pi;
9071 record->number[0].si = infoRec->rec.number.si;
9072 break;
9073 }
9074
9075 case RIL_CDMA_SIGNAL_INFO_REC: {
9076 record->signal.resize(1);
9077 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
9078 record->signal[0].signalType = infoRec->rec.signal.signalType;
9079 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
9080 record->signal[0].signal = infoRec->rec.signal.signal;
9081 break;
9082 }
9083
9084 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
9085 if (infoRec->rec.redir.redirectingNumber.len >
9086 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
9087 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
9088 "expected not more than %d\n",
9089 (int)infoRec->rec.redir.redirectingNumber.len,
9090 CDMA_NUMBER_INFO_BUFFER_LENGTH);
9091 return 0;
9092 }
9093 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
9094 sizeof(char));
9095 if (string8 == NULL) {
9096 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
9097 "responseCdmaInformationRecords");
9098 return 0;
9099 }
9100 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
9101 infoRec->rec.redir.redirectingNumber.len);
9102 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
9103
9104 record->redir.resize(1);
9105 record->redir[0].redirectingNumber.number = string8;
9106 free(string8);
9107 string8 = NULL;
9108 record->redir[0].redirectingNumber.numberType =
9109 infoRec->rec.redir.redirectingNumber.number_type;
9110 record->redir[0].redirectingNumber.numberPlan =
9111 infoRec->rec.redir.redirectingNumber.number_plan;
9112 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
9113 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
9114 record->redir[0].redirectingReason =
9115 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
9116 break;
9117 }
9118
9119 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
9120 record->lineCtrl.resize(1);
9121 record->lineCtrl[0].lineCtrlPolarityIncluded =
9122 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
9123 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
9124 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
9125 record->lineCtrl[0].lineCtrlPowerDenial =
9126 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
9127 break;
9128 }
9129
9130 case RIL_CDMA_T53_CLIR_INFO_REC: {
9131 record->clir.resize(1);
9132 record->clir[0].cause = infoRec->rec.clir.cause;
9133 break;
9134 }
9135
9136 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
9137 record->audioCtrl.resize(1);
9138 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
9139 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
9140 break;
9141 }
9142
9143 case RIL_CDMA_T53_RELEASE_INFO_REC:
9144 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
9145 return 0;
9146
9147 default:
9148 RLOGE("cdmaInfoRecInd: Incorrect name value");
9149 return 0;
9150 }
9151 }
9152
9153#if VDBG
9154 RLOGD("cdmaInfoRecInd");
9155#endif
9156 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
9157 convertIntToRadioIndicationType(indicationType), records);
9158 radioService[slotId]->checkReturnStatus(retStatus);
9159 } else {
9160 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
9161 }
9162
9163 return 0;
9164}
9165
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009166int radio_1_5::indicateRingbackToneInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009167 int indicationType, int token, RIL_Errno e, void *response,
9168 size_t responseLen) {
9169 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9170 if (response == NULL || responseLen != sizeof(int)) {
9171 RLOGE("indicateRingbackToneInd: invalid response");
9172 return 0;
9173 }
9174 bool start = ((int32_t *) response)[0];
9175#if VDBG
9176 RLOGD("indicateRingbackToneInd: start %d", start);
9177#endif
9178 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
9179 convertIntToRadioIndicationType(indicationType), start);
9180 radioService[slotId]->checkReturnStatus(retStatus);
9181 } else {
9182 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
9183 }
9184
9185 return 0;
9186}
9187
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009188int radio_1_5::resendIncallMuteInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009189 int indicationType, int token, RIL_Errno e, void *response,
9190 size_t responseLen) {
9191 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9192#if VDBG
9193 RLOGD("resendIncallMuteInd");
9194#endif
9195 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
9196 convertIntToRadioIndicationType(indicationType));
9197 radioService[slotId]->checkReturnStatus(retStatus);
9198 } else {
9199 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
9200 }
9201
9202 return 0;
9203}
9204
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009205int radio_1_5::cdmaSubscriptionSourceChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009206 int indicationType, int token, RIL_Errno e,
9207 void *response, size_t responseLen) {
9208 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9209 if (response == NULL || responseLen != sizeof(int)) {
9210 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
9211 return 0;
9212 }
9213 int32_t cdmaSource = ((int32_t *) response)[0];
9214#if VDBG
9215 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
9216#endif
9217 Return<void> retStatus = radioService[slotId]->mRadioIndication->
9218 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
9219 (CdmaSubscriptionSource) cdmaSource);
9220 radioService[slotId]->checkReturnStatus(retStatus);
9221 } else {
9222 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
9223 slotId);
9224 }
9225
9226 return 0;
9227}
9228
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009229int radio_1_5::cdmaPrlChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009230 int indicationType, int token, RIL_Errno e, void *response,
9231 size_t responseLen) {
9232 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9233 if (response == NULL || responseLen != sizeof(int)) {
9234 RLOGE("cdmaPrlChangedInd: invalid response");
9235 return 0;
9236 }
9237 int32_t version = ((int32_t *) response)[0];
9238#if VDBG
9239 RLOGD("cdmaPrlChangedInd: version %d", version);
9240#endif
9241 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
9242 convertIntToRadioIndicationType(indicationType), version);
9243 radioService[slotId]->checkReturnStatus(retStatus);
9244 } else {
9245 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
9246 }
9247
9248 return 0;
9249}
9250
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009251int radio_1_5::exitEmergencyCallbackModeInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009252 int indicationType, int token, RIL_Errno e, void *response,
9253 size_t responseLen) {
9254 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9255#if VDBG
9256 RLOGD("exitEmergencyCallbackModeInd");
9257#endif
9258 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
9259 convertIntToRadioIndicationType(indicationType));
9260 radioService[slotId]->checkReturnStatus(retStatus);
9261 } else {
9262 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
9263 slotId);
9264 }
9265
9266 return 0;
9267}
9268
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009269int radio_1_5::rilConnectedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009270 int indicationType, int token, RIL_Errno e, void *response,
9271 size_t responseLen) {
9272 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9273 RLOGD("rilConnectedInd");
9274 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
9275 convertIntToRadioIndicationType(indicationType));
9276 radioService[slotId]->checkReturnStatus(retStatus);
9277 } else {
9278 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
9279 }
9280
9281 return 0;
9282}
9283
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009284int radio_1_5::voiceRadioTechChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009285 int indicationType, int token, RIL_Errno e, void *response,
9286 size_t responseLen) {
9287 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9288 if (response == NULL || responseLen != sizeof(int)) {
9289 RLOGE("voiceRadioTechChangedInd: invalid response");
9290 return 0;
9291 }
9292 int32_t rat = ((int32_t *) response)[0];
9293#if VDBG
9294 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
9295#endif
9296 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
9297 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
9298 radioService[slotId]->checkReturnStatus(retStatus);
9299 } else {
9300 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
9301 slotId);
9302 }
9303
9304 return 0;
9305}
9306
9307void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
9308 int num = responseLen / sizeof(RIL_CellInfo_v12);
9309 records.resize(num);
9310
9311 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
9312 for (int i = 0; i < num; i++) {
9313 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
9314 records[i].registered = rillCellInfo->registered;
9315 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
9316 records[i].timeStamp = rillCellInfo->timeStamp;
9317 // All vectors should be size 0 except one which will be size 1. Set everything to
9318 // size 0 initially.
9319 records[i].gsm.resize(0);
9320 records[i].wcdma.resize(0);
9321 records[i].cdma.resize(0);
9322 records[i].lte.resize(0);
9323 records[i].tdscdma.resize(0);
9324 switch(rillCellInfo->cellInfoType) {
9325 case RIL_CELL_INFO_TYPE_GSM: {
9326 records[i].gsm.resize(1);
9327 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
9328 cellInfoGsm->cellIdentityGsm.mcc =
9329 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
9330 cellInfoGsm->cellIdentityGsm.mnc =
9331 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
9332 cellInfoGsm->cellIdentityGsm.lac =
9333 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
9334 cellInfoGsm->cellIdentityGsm.cid =
9335 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
9336 cellInfoGsm->cellIdentityGsm.arfcn =
9337 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
9338 cellInfoGsm->cellIdentityGsm.bsic =
9339 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
9340 cellInfoGsm->signalStrengthGsm.signalStrength =
9341 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
9342 cellInfoGsm->signalStrengthGsm.bitErrorRate =
9343 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
9344 cellInfoGsm->signalStrengthGsm.timingAdvance =
9345 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
9346 break;
9347 }
9348
9349 case RIL_CELL_INFO_TYPE_WCDMA: {
9350 records[i].wcdma.resize(1);
9351 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
9352 cellInfoWcdma->cellIdentityWcdma.mcc =
9353 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
9354 cellInfoWcdma->cellIdentityWcdma.mnc =
9355 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
9356 cellInfoWcdma->cellIdentityWcdma.lac =
9357 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
9358 cellInfoWcdma->cellIdentityWcdma.cid =
9359 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
9360 cellInfoWcdma->cellIdentityWcdma.psc =
9361 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
9362 cellInfoWcdma->cellIdentityWcdma.uarfcn =
9363 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
9364 cellInfoWcdma->signalStrengthWcdma.signalStrength =
9365 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
9366 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
9367 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
9368 break;
9369 }
9370
9371 case RIL_CELL_INFO_TYPE_CDMA: {
9372 records[i].cdma.resize(1);
9373 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
9374 cellInfoCdma->cellIdentityCdma.networkId =
9375 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
9376 cellInfoCdma->cellIdentityCdma.systemId =
9377 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
9378 cellInfoCdma->cellIdentityCdma.baseStationId =
9379 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
9380 cellInfoCdma->cellIdentityCdma.longitude =
9381 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
9382 cellInfoCdma->cellIdentityCdma.latitude =
9383 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
9384 cellInfoCdma->signalStrengthCdma.dbm =
9385 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
9386 cellInfoCdma->signalStrengthCdma.ecio =
9387 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
9388 cellInfoCdma->signalStrengthEvdo.dbm =
9389 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
9390 cellInfoCdma->signalStrengthEvdo.ecio =
9391 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
9392 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
9393 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
9394 break;
9395 }
9396
9397 case RIL_CELL_INFO_TYPE_LTE: {
9398 records[i].lte.resize(1);
9399 CellInfoLte *cellInfoLte = &records[i].lte[0];
9400 cellInfoLte->cellIdentityLte.mcc =
9401 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
9402 cellInfoLte->cellIdentityLte.mnc =
9403 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
9404 cellInfoLte->cellIdentityLte.ci =
9405 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
9406 cellInfoLte->cellIdentityLte.pci =
9407 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
9408 cellInfoLte->cellIdentityLte.tac =
9409 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
9410 cellInfoLte->cellIdentityLte.earfcn =
9411 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
9412 cellInfoLte->signalStrengthLte.signalStrength =
9413 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
9414 cellInfoLte->signalStrengthLte.rsrp =
9415 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
9416 cellInfoLte->signalStrengthLte.rsrq =
9417 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
9418 cellInfoLte->signalStrengthLte.rssnr =
9419 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
9420 cellInfoLte->signalStrengthLte.cqi =
9421 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
9422 cellInfoLte->signalStrengthLte.timingAdvance =
9423 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
9424 break;
9425 }
9426
9427 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
9428 records[i].tdscdma.resize(1);
9429 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
9430 cellInfoTdscdma->cellIdentityTdscdma.mcc =
9431 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
9432 cellInfoTdscdma->cellIdentityTdscdma.mnc =
9433 ril::util::mnc::decode(
9434 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
9435 cellInfoTdscdma->cellIdentityTdscdma.lac =
9436 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
9437 cellInfoTdscdma->cellIdentityTdscdma.cid =
9438 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
9439 cellInfoTdscdma->cellIdentityTdscdma.cpid =
9440 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
9441 cellInfoTdscdma->signalStrengthTdscdma.rscp =
9442 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
9443 break;
9444 }
9445 default: {
9446 break;
9447 }
9448 }
9449 rillCellInfo += 1;
9450 }
9451}
9452
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009453int radio_1_5::cellInfoListInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009454 int indicationType, int token, RIL_Errno e, void *response,
9455 size_t responseLen) {
9456 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9457 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
9458 RLOGE("cellInfoListInd: invalid response");
9459 return 0;
9460 }
9461
9462 hidl_vec<CellInfo> records;
9463 convertRilCellInfoListToHal(response, responseLen, records);
9464
9465#if VDBG
9466 RLOGD("cellInfoListInd");
9467#endif
9468 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
9469 convertIntToRadioIndicationType(indicationType), records);
9470 radioService[slotId]->checkReturnStatus(retStatus);
9471 } else {
9472 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
9473 }
9474
9475 return 0;
9476}
9477
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009478int radio_1_5::imsNetworkStateChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009479 int indicationType, int token, RIL_Errno e, void *response,
9480 size_t responseLen) {
9481 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9482#if VDBG
9483 RLOGD("imsNetworkStateChangedInd");
9484#endif
9485 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
9486 convertIntToRadioIndicationType(indicationType));
9487 radioService[slotId]->checkReturnStatus(retStatus);
9488 } else {
9489 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
9490 slotId);
9491 }
9492
9493 return 0;
9494}
9495
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009496int radio_1_5::subscriptionStatusChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009497 int indicationType, int token, RIL_Errno e, void *response,
9498 size_t responseLen) {
9499 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9500 if (response == NULL || responseLen != sizeof(int)) {
9501 RLOGE("subscriptionStatusChangedInd: invalid response");
9502 return 0;
9503 }
9504 bool activate = ((int32_t *) response)[0];
9505#if VDBG
9506 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
9507#endif
9508 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
9509 convertIntToRadioIndicationType(indicationType), activate);
9510 radioService[slotId]->checkReturnStatus(retStatus);
9511 } else {
9512 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
9513 slotId);
9514 }
9515
9516 return 0;
9517}
9518
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009519int radio_1_5::srvccStateNotifyInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009520 int indicationType, int token, RIL_Errno e, void *response,
9521 size_t responseLen) {
9522 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9523 if (response == NULL || responseLen != sizeof(int)) {
9524 RLOGE("srvccStateNotifyInd: invalid response");
9525 return 0;
9526 }
9527 int32_t state = ((int32_t *) response)[0];
9528#if VDBG
9529 RLOGD("srvccStateNotifyInd: rat %d", state);
9530#endif
9531 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
9532 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
9533 radioService[slotId]->checkReturnStatus(retStatus);
9534 } else {
9535 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
9536 }
9537
9538 return 0;
9539}
9540
9541void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
9542 hidl_vec<HardwareConfig>& records) {
9543 int num = responseLen / sizeof(RIL_HardwareConfig);
9544 records.resize(num);
9545
9546 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
9547 for (int i = 0; i < num; i++) {
9548 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
9549 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
9550 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
9551 switch (rilHardwareConfig[i].type) {
9552 case RIL_HARDWARE_CONFIG_MODEM: {
9553 records[i].modem.resize(1);
9554 records[i].sim.resize(0);
9555 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
9556 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
9557 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
9558 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
9559 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
9560 break;
9561 }
9562
9563 case RIL_HARDWARE_CONFIG_SIM: {
9564 records[i].sim.resize(1);
9565 records[i].modem.resize(0);
9566 records[i].sim[0].modemUuid =
9567 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
9568 break;
9569 }
9570 }
9571 }
9572}
9573
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009574int radio_1_5::hardwareConfigChangedInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009575 int indicationType, int token, RIL_Errno e, void *response,
9576 size_t responseLen) {
9577 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9578 if ((response == NULL && responseLen != 0)
9579 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
9580 RLOGE("hardwareConfigChangedInd: invalid response");
9581 return 0;
9582 }
9583
9584 hidl_vec<HardwareConfig> configs;
9585 convertRilHardwareConfigListToHal(response, responseLen, configs);
9586
9587#if VDBG
9588 RLOGD("hardwareConfigChangedInd");
9589#endif
9590 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
9591 convertIntToRadioIndicationType(indicationType), configs);
9592 radioService[slotId]->checkReturnStatus(retStatus);
9593 } else {
9594 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
9595 slotId);
9596 }
9597
9598 return 0;
9599}
9600
9601void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
9602 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
9603 rc.session = rilRadioCapability->session;
9604 rc.phase = (V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
9605 rc.raf = rilRadioCapability->rat;
9606 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
9607 rc.status = (V1_0::RadioCapabilityStatus) rilRadioCapability->status;
9608}
9609
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009610int radio_1_5::radioCapabilityIndicationInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009611 int indicationType, int token, RIL_Errno e, void *response,
9612 size_t responseLen) {
9613 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9614 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
9615 RLOGE("radioCapabilityIndicationInd: invalid response");
9616 return 0;
9617 }
9618
9619 RadioCapability rc = {};
9620 convertRilRadioCapabilityToHal(response, responseLen, rc);
9621
9622#if VDBG
9623 RLOGD("radioCapabilityIndicationInd");
9624#endif
9625 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
9626 convertIntToRadioIndicationType(indicationType), rc);
9627 radioService[slotId]->checkReturnStatus(retStatus);
9628 } else {
9629 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
9630 slotId);
9631 }
9632
9633 return 0;
9634}
9635
9636bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
9637 if ((reqType == SS_INTERROGATION) &&
9638 (serType == SS_CFU ||
9639 serType == SS_CF_BUSY ||
9640 serType == SS_CF_NO_REPLY ||
9641 serType == SS_CF_NOT_REACHABLE ||
9642 serType == SS_CF_ALL ||
9643 serType == SS_CF_ALL_CONDITIONAL)) {
9644 return true;
9645 }
9646 return false;
9647}
9648
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009649int radio_1_5::onSupplementaryServiceIndicationInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009650 int indicationType, int token, RIL_Errno e,
9651 void *response, size_t responseLen) {
9652 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9653 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
9654 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
9655 return 0;
9656 }
9657
9658 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
9659 StkCcUnsolSsResult ss = {};
9660 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
9661 ss.requestType = (SsRequestType) rilSsResponse->requestType;
9662 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
9663 ss.serviceClass = rilSsResponse->serviceClass;
9664 ss.result = (RadioError) rilSsResponse->result;
9665
9666 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
9667#if VDBG
9668 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
9669 rilSsResponse->cfData.numValidIndexes);
9670#endif
9671 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
9672 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
9673 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
9674 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
9675 }
9676
9677 ss.cfData.resize(1);
9678 ss.ssInfo.resize(0);
9679
9680 /* number of call info's */
9681 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
9682
9683 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
9684 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
9685 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
9686
9687 cfInfo->status = (CallForwardInfoStatus) cf.status;
9688 cfInfo->reason = cf.reason;
9689 cfInfo->serviceClass = cf.serviceClass;
9690 cfInfo->toa = cf.toa;
9691 cfInfo->number = convertCharPtrToHidlString(cf.number);
9692 cfInfo->timeSeconds = cf.timeSeconds;
9693#if VDBG
9694 RLOGD("onSupplementaryServiceIndicationInd: "
9695 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
9696 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
9697#endif
9698 }
9699 } else {
9700 ss.ssInfo.resize(1);
9701 ss.cfData.resize(0);
9702
9703 /* each int */
9704 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
9705 for (int i = 0; i < SS_INFO_MAX; i++) {
9706#if VDBG
9707 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
9708 rilSsResponse->ssInfo[i]);
9709#endif
9710 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
9711 }
9712 }
9713
9714#if VDBG
9715 RLOGD("onSupplementaryServiceIndicationInd");
9716#endif
9717 Return<void> retStatus = radioService[slotId]->mRadioIndication->
9718 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
9719 ss);
9720 radioService[slotId]->checkReturnStatus(retStatus);
9721 } else {
9722 RLOGE("onSupplementaryServiceIndicationInd: "
9723 "radioService[%d]->mRadioIndication == NULL", slotId);
9724 }
9725
9726 return 0;
9727}
9728
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009729int radio_1_5::stkCallControlAlphaNotifyInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009730 int indicationType, int token, RIL_Errno e, void *response,
9731 size_t responseLen) {
9732 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9733 if (response == NULL || responseLen == 0) {
9734 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
9735 return 0;
9736 }
9737#if VDBG
9738 RLOGD("stkCallControlAlphaNotifyInd");
9739#endif
9740 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
9741 convertIntToRadioIndicationType(indicationType),
9742 convertCharPtrToHidlString((char *) response));
9743 radioService[slotId]->checkReturnStatus(retStatus);
9744 } else {
9745 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
9746 slotId);
9747 }
9748
9749 return 0;
9750}
9751
9752void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
9753 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
9754 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
9755 lce.confidenceLevel = rilLceDataInfo->confidence_level;
9756 lce.lceSuspended = rilLceDataInfo->lce_suspended;
9757}
9758
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009759int radio_1_5::lceDataInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009760 int indicationType, int token, RIL_Errno e, void *response,
9761 size_t responseLen) {
9762 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9763 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
9764 RLOGE("lceDataInd: invalid response");
9765 return 0;
9766 }
9767
9768 LceDataInfo lce = {};
9769 convertRilLceDataInfoToHal(response, responseLen, lce);
9770#if VDBG
9771 RLOGD("lceDataInd");
9772#endif
9773 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
9774 convertIntToRadioIndicationType(indicationType), lce);
9775 radioService[slotId]->checkReturnStatus(retStatus);
9776 } else {
9777 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
9778 }
9779
9780 return 0;
9781}
9782
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009783int radio_1_5::pcoDataInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009784 int indicationType, int token, RIL_Errno e, void *response,
9785 size_t responseLen) {
9786 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9787 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
9788 RLOGE("pcoDataInd: invalid response");
9789 return 0;
9790 }
9791
9792 PcoDataInfo pco = {};
9793 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
9794 pco.cid = rilPcoData->cid;
9795 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
9796 pco.pcoId = rilPcoData->pco_id;
9797 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
9798
9799#if VDBG
9800 RLOGD("pcoDataInd");
9801#endif
9802 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
9803 convertIntToRadioIndicationType(indicationType), pco);
9804 radioService[slotId]->checkReturnStatus(retStatus);
9805 } else {
9806 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
9807 }
9808
9809 return 0;
9810}
9811
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009812int radio_1_5::modemResetInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009813 int indicationType, int token, RIL_Errno e, void *response,
9814 size_t responseLen) {
9815 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
9816 if (response == NULL || responseLen == 0) {
9817 RLOGE("modemResetInd: invalid response");
9818 return 0;
9819 }
9820#if VDBG
9821 RLOGD("modemResetInd");
9822#endif
9823 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
9824 convertIntToRadioIndicationType(indicationType),
9825 convertCharPtrToHidlString((char *) response));
9826 radioService[slotId]->checkReturnStatus(retStatus);
9827 } else {
9828 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
9829 }
9830
9831 return 0;
9832}
9833
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009834int radio_1_5::networkScanResultInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009835 int indicationType, int token, RIL_Errno e, void *response,
9836 size_t responseLen) {
9837#if VDBG
9838 RLOGD("networkScanResultInd");
9839#endif
9840 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_4 != NULL) {
9841 if (response == NULL || responseLen == 0) {
9842 RLOGE("networkScanResultInd: invalid response");
9843 return 0;
9844 }
9845 RLOGD("networkScanResultInd");
9846
9847#if VDBG
9848 RLOGD("networkScanResultInd");
9849#endif
9850
9851 RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
9852
9853 V1_1::NetworkScanResult result;
9854 result.status = (V1_1::ScanStatus) networkScanResult->status;
9855 result.error = (RadioError) networkScanResult->error;
9856 convertRilCellInfoListToHal(
9857 networkScanResult->network_infos,
9858 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
9859 result.networkInfos);
9860
9861 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_4->networkScanResult(
9862 convertIntToRadioIndicationType(indicationType), result);
9863 radioService[slotId]->checkReturnStatus(retStatus);
9864 } else {
9865 RLOGE("networkScanResultInd: radioService[%d]->mRadioIndicationV1_4 == NULL", slotId);
9866 }
9867 return 0;
9868}
9869
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009870int radio_1_5::carrierInfoForImsiEncryption(int slotId,
paulye91d34712019-02-07 19:02:02 -08009871 int indicationType, int token, RIL_Errno e, void *response,
9872 size_t responseLen) {
9873 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_4 != NULL) {
9874 if (response == NULL || responseLen == 0) {
9875 RLOGE("carrierInfoForImsiEncryption: invalid response");
9876 return 0;
9877 }
9878 RLOGD("carrierInfoForImsiEncryption");
9879 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_4->
9880 carrierInfoForImsiEncryption(convertIntToRadioIndicationType(indicationType));
9881 radioService[slotId]->checkReturnStatus(retStatus);
9882 } else {
9883 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndicationV1_4 == NULL",
9884 slotId);
9885 }
9886
9887 return 0;
9888}
9889
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009890int radio_1_5::keepaliveStatusInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009891 int indicationType, int token, RIL_Errno e, void *response,
9892 size_t responseLen) {
9893#if VDBG
9894 RLOGD("%s(): token=%d", __FUNCTION__, token);
9895#endif
9896 if (radioService[slotId] == NULL || radioService[slotId]->mRadioIndication == NULL) {
9897 RLOGE("%s: radioService[%d]->mRadioIndication == NULL", __FUNCTION__, slotId);
9898 return 0;
9899 }
9900
9901 auto ret = V1_1::IRadioIndication::castFrom(
9902 radioService[slotId]->mRadioIndication);
9903 if (!ret.isOk()) {
9904 RLOGE("%s: ret.isOk() == false for radioService[%d]", __FUNCTION__, slotId);
9905 return 0;
9906 }
9907 sp<V1_1::IRadioIndication> radioIndicationV1_1 = ret;
9908
9909 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
9910 RLOGE("%s: invalid response", __FUNCTION__);
9911 return 0;
9912 }
9913
9914 V1_1::KeepaliveStatus ks;
9915 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
9916
9917 Return<void> retStatus = radioIndicationV1_1->keepaliveStatus(
9918 convertIntToRadioIndicationType(indicationType), ks);
9919 radioService[slotId]->checkReturnStatus(retStatus);
9920 return 0;
9921}
9922
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009923int radio_1_5::oemHookRawInd(int slotId,
paulye91d34712019-02-07 19:02:02 -08009924 int indicationType, int token, RIL_Errno e, void *response,
9925 size_t responseLen) {
9926 if (!kOemHookEnabled) return 0;
9927
9928 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
9929 if (response == NULL || responseLen == 0) {
9930 RLOGE("oemHookRawInd: invalid response");
9931 return 0;
9932 }
9933
9934 hidl_vec<uint8_t> data;
9935 data.setToExternal((uint8_t *) response, responseLen);
9936#if VDBG
9937 RLOGD("oemHookRawInd");
9938#endif
9939 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
9940 convertIntToRadioIndicationType(indicationType), data);
9941 checkReturnStatus(slotId, retStatus, false);
9942 } else {
9943 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
9944 }
9945
9946 return 0;
9947}
9948
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009949void radio_1_5::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
paulye91d34712019-02-07 19:02:02 -08009950 using namespace android::hardware;
9951 int simCount = 1;
9952 const char *serviceNames[] = {
9953 android::RIL_getServiceName()
9954 #if (SIM_COUNT >= 2)
9955 , RIL2_SERVICE_NAME
9956 #if (SIM_COUNT >= 3)
9957 , RIL3_SERVICE_NAME
9958 #if (SIM_COUNT >= 4)
9959 , RIL4_SERVICE_NAME
9960 #endif
9961 #endif
9962 #endif
9963 };
9964
9965 #if (SIM_COUNT >= 2)
9966 simCount = SIM_COUNT;
9967 #endif
9968
9969 s_vendorFunctions = callbacks;
9970 s_commands = commands;
9971
9972 configureRpcThreadpool(1, true /* callerWillJoin */);
9973 for (int i = 0; i < simCount; i++) {
9974 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
9975 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
9976 assert(ret == 0);
9977
9978 RLOGD("sim i = %d registering ...", i);
9979
Malcolm Chen6b9984e2019-10-10 14:44:58 -07009980 radioService[i] = new RadioImpl_1_5;
paulye91d34712019-02-07 19:02:02 -08009981 radioService[i]->mSlotId = i;
Sarah Chinbb757c62019-11-06 12:46:42 -08009982 RLOGD("registerService: starting android::hardware::radio::V1_5::IRadio %s for slot %d",
paulye91d34712019-02-07 19:02:02 -08009983 serviceNames[i], i);
9984 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
Steven Morelande4caa4e2020-01-10 15:06:00 -08009985 LOG_ALWAYS_FATAL_IF(status != android::OK, "status %d", status);
paulye91d34712019-02-07 19:02:02 -08009986
9987 RLOGD("registerService: OemHook is enabled = %s", kOemHookEnabled ? "true" : "false");
9988 if (kOemHookEnabled) {
9989 oemHookService[i] = new OemHookImpl;
9990 oemHookService[i]->mSlotId = i;
Steven Moreland20ff5812019-08-14 14:49:30 -07009991 // status = oemHookService[i]->registerAsService(serviceNames[i]);
paulye91d34712019-02-07 19:02:02 -08009992 }
9993
9994 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
9995 assert(ret == 0);
9996 }
9997}
9998
9999void rilc_thread_pool() {
10000 joinRpcThreadpool();
10001}
10002
Malcolm Chen6b9984e2019-10-10 14:44:58 -070010003pthread_rwlock_t * radio_1_5::getRadioServiceRwlock(int slotId) {
paulye91d34712019-02-07 19:02:02 -080010004 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
10005
10006 #if (SIM_COUNT >= 2)
10007 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
10008 #if (SIM_COUNT >= 3)
10009 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
10010 #if (SIM_COUNT >= 4)
10011 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
10012 #endif
10013 #endif
10014 #endif
10015
10016 return radioServiceRwlockPtr;
10017}
10018
10019// should acquire write lock for the corresponding service before calling this
Malcolm Chen6b9984e2019-10-10 14:44:58 -070010020void radio_1_5::setNitzTimeReceived(int slotId, long timeReceived) {
paulye91d34712019-02-07 19:02:02 -080010021 nitzTimeReceived[slotId] = timeReceived;
10022}