blob: 1ffee5e65e90931e9d8871e6d8808add13a80566 [file] [log] [blame]
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001/*
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#include <android/hardware/radio/1.0/IRadio.h>
Amit Mahajan439da362017-02-13 17:43:04 -080018#include <android/hardware/radio/deprecated/1.0/IOemHook.h>
Amit Mahajancd77a5b2016-08-25 11:19:21 -070019
20#include <hwbinder/IPCThreadState.h>
21#include <hwbinder/ProcessState.h>
22#include <ril_service.h>
23#include <hidl/HidlTransportSupport.h>
Amit Mahajan5829a472016-12-28 17:28:07 -080024#include <utils/SystemClock.h>
Wei Wang100ac9b2017-02-03 14:18:07 -080025#include <inttypes.h>
Amit Mahajan5829a472016-12-28 17:28:07 -080026
27#define INVALID_HEX_CHAR 16
Amit Mahajancd77a5b2016-08-25 11:19:21 -070028
29using namespace android::hardware::radio::V1_0;
Amit Mahajan439da362017-02-13 17:43:04 -080030using namespace android::hardware::radio::deprecated::V1_0;
Amit Mahajancd77a5b2016-08-25 11:19:21 -070031using ::android::hardware::configureRpcThreadpool;
32using ::android::hardware::joinRpcThreadpool;
33using ::android::hardware::Return;
34using ::android::hardware::Status;
35using ::android::hardware::hidl_string;
36using ::android::hardware::hidl_vec;
37using ::android::hardware::hidl_array;
38using ::android::hardware::Void;
39using android::CommandInfo;
40using android::RequestInfo;
41using android::requestToString;
42using android::sp;
43
Sanket Padawe378ccdd2017-01-24 14:11:12 -080044#define BOOL_TO_INT(x) (x ? 1 : 0)
45#define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
46#define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
47
48RIL_RadioFunctions *s_vendorFunctions = NULL;
Amit Mahajancd77a5b2016-08-25 11:19:21 -070049static CommandInfo *s_commands;
50
51struct RadioImpl;
Amit Mahajan439da362017-02-13 17:43:04 -080052struct OemHookImpl;
Amit Mahajancd77a5b2016-08-25 11:19:21 -070053
54#if (SIM_COUNT >= 2)
55sp<RadioImpl> radioService[SIM_COUNT];
Amit Mahajan439da362017-02-13 17:43:04 -080056sp<OemHookImpl> oemHookService[SIM_COUNT];
57// counter used for synchronization. It is incremented every time response callbacks are updated.
58volatile int32_t mCounter[SIM_COUNT];
Amit Mahajancd77a5b2016-08-25 11:19:21 -070059#else
60sp<RadioImpl> radioService[1];
Amit Mahajan439da362017-02-13 17:43:04 -080061sp<OemHookImpl> oemHookService[1];
62// counter used for synchronization. It is incremented every time response callbacks are updated.
63volatile int32_t mCounter[1];
Amit Mahajancd77a5b2016-08-25 11:19:21 -070064#endif
65
Amit Mahajan932e08e2017-01-24 05:45:02 -080066static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
67
68#if (SIM_COUNT >= 2)
69static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
70#if (SIM_COUNT >= 3)
71static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
72#if (SIM_COUNT >= 4)
73static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
74#endif
75#endif
76#endif
77
Amit Mahajan3df62912017-02-10 01:35:55 +000078void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
79 hidl_vec<HardwareConfig>& records);
80
81void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
82
83void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
84
85void convertRilSignalStrengthToHal(void *response, size_t responseLen,
86 SignalStrength& signalStrength);
87
88void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
89 SetupDataCallResult& dcResult);
90
91void convertRilDataCallListToHal(void *response, size_t responseLen,
92 hidl_vec<SetupDataCallResult>& dcResultList);
93
94void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
95
Amit Mahajancd77a5b2016-08-25 11:19:21 -070096struct RadioImpl : public IRadio {
Sanket Padawef220dc52017-01-02 23:46:00 -080097 int32_t mSlotId;
98 sp<IRadioResponse> mRadioResponse;
99 sp<IRadioIndication> mRadioIndication;
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700100
101 Return<void> setResponseFunctions(
102 const ::android::sp<IRadioResponse>& radioResponse,
103 const ::android::sp<IRadioIndication>& radioIndication);
104
105 Return<void> getIccCardStatus(int32_t serial);
106
Sanket Padawef220dc52017-01-02 23:46:00 -0800107 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
108 const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700109
Sanket Padawef220dc52017-01-02 23:46:00 -0800110 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
111 const hidl_string& pin, const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700112
113 Return<void> supplyIccPin2ForApp(int32_t serial,
Sanket Padawef220dc52017-01-02 23:46:00 -0800114 const hidl_string& pin2,
115 const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700116
Sanket Padawef220dc52017-01-02 23:46:00 -0800117 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
118 const hidl_string& pin2, const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700119
Sanket Padawef220dc52017-01-02 23:46:00 -0800120 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
121 const hidl_string& newPin, const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700122
Sanket Padawef220dc52017-01-02 23:46:00 -0800123 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
124 const hidl_string& newPin2, const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700125
Sanket Padawef220dc52017-01-02 23:46:00 -0800126 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700127
128 Return<void> getCurrentCalls(int32_t serial);
129
Sanket Padawef220dc52017-01-02 23:46:00 -0800130 Return<void> dial(int32_t serial, const Dial& dialInfo);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700131
132 Return<void> getImsiForApp(int32_t serial,
133 const ::android::hardware::hidl_string& aid);
134
135 Return<void> hangup(int32_t serial, int32_t gsmIndex);
136
137 Return<void> hangupWaitingOrBackground(int32_t serial);
138
139 Return<void> hangupForegroundResumeBackground(int32_t serial);
140
141 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
142
143 Return<void> conference(int32_t serial);
144
145 Return<void> rejectCall(int32_t serial);
146
147 Return<void> getLastCallFailCause(int32_t serial);
148
149 Return<void> getSignalStrength(int32_t serial);
150
151 Return<void> getVoiceRegistrationState(int32_t serial);
152
153 Return<void> getDataRegistrationState(int32_t serial);
154
155 Return<void> getOperator(int32_t serial);
156
157 Return<void> setRadioPower(int32_t serial, bool on);
158
159 Return<void> sendDtmf(int32_t serial,
160 const ::android::hardware::hidl_string& s);
161
162 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
163
164 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
165
166 Return<void> setupDataCall(int32_t serial,
Jack Yu06181bb2017-01-10 12:10:41 -0800167 RadioTechnology radioTechnology,
168 const DataProfileInfo& profileInfo,
169 bool modemCognitive,
Jack Yuffc06452017-02-13 11:21:00 -0800170 bool roamingAllowed,
171 bool isRoaming);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700172
173 Return<void> iccIOForApp(int32_t serial,
174 const IccIo& iccIo);
175
176 Return<void> sendUssd(int32_t serial,
177 const ::android::hardware::hidl_string& ussd);
178
179 Return<void> cancelPendingUssd(int32_t serial);
180
181 Return<void> getClir(int32_t serial);
182
183 Return<void> setClir(int32_t serial, int32_t status);
184
185 Return<void> getCallForwardStatus(int32_t serial,
186 const CallForwardInfo& callInfo);
187
188 Return<void> setCallForward(int32_t serial,
189 const CallForwardInfo& callInfo);
190
191 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
192
193 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
194
195 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
196 bool success, SmsAcknowledgeFailCause cause);
197
198 Return<void> acceptCall(int32_t serial);
199
200 Return<void> deactivateDataCall(int32_t serial,
201 int32_t cid, bool reasonRadioShutDown);
202
203 Return<void> getFacilityLockForApp(int32_t serial,
204 const ::android::hardware::hidl_string& facility,
205 const ::android::hardware::hidl_string& password,
206 int32_t serviceClass,
207 const ::android::hardware::hidl_string& appId);
208
209 Return<void> setFacilityLockForApp(int32_t serial,
210 const ::android::hardware::hidl_string& facility,
211 bool lockState,
212 const ::android::hardware::hidl_string& password,
213 int32_t serviceClass,
214 const ::android::hardware::hidl_string& appId);
215
216 Return<void> setBarringPassword(int32_t serial,
217 const ::android::hardware::hidl_string& facility,
218 const ::android::hardware::hidl_string& oldPassword,
219 const ::android::hardware::hidl_string& newPassword);
220
221 Return<void> getNetworkSelectionMode(int32_t serial);
222
223 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
224
225 Return<void> setNetworkSelectionModeManual(int32_t serial,
226 const ::android::hardware::hidl_string& operatorNumeric);
227
228 Return<void> getAvailableNetworks(int32_t serial);
229
230 Return<void> startDtmf(int32_t serial,
231 const ::android::hardware::hidl_string& s);
232
233 Return<void> stopDtmf(int32_t serial);
234
235 Return<void> getBasebandVersion(int32_t serial);
236
237 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
238
239 Return<void> setMute(int32_t serial, bool enable);
240
241 Return<void> getMute(int32_t serial);
242
243 Return<void> getClip(int32_t serial);
244
245 Return<void> getDataCallList(int32_t serial);
246
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700247 Return<void> sendScreenState(int32_t serial, bool enable);
248
249 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
250
251 Return<void> writeSmsToSim(int32_t serial,
252 const SmsWriteArgs& smsWriteArgs);
253
254 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
255
256 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
257
258 Return<void> getAvailableBandModes(int32_t serial);
259
260 Return<void> sendEnvelope(int32_t serial,
261 const ::android::hardware::hidl_string& command);
262
263 Return<void> sendTerminalResponseToSim(int32_t serial,
264 const ::android::hardware::hidl_string& commandResponse);
265
266 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
267
268 Return<void> explicitCallTransfer(int32_t serial);
269
270 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
271
272 Return<void> getPreferredNetworkType(int32_t serial);
273
274 Return<void> getNeighboringCids(int32_t serial);
275
276 Return<void> setLocationUpdates(int32_t serial, bool enable);
277
278 Return<void> setCdmaSubscriptionSource(int32_t serial,
279 CdmaSubscriptionSource cdmaSub);
280
281 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
282
283 Return<void> getCdmaRoamingPreference(int32_t serial);
284
285 Return<void> setTTYMode(int32_t serial, TtyMode mode);
286
287 Return<void> getTTYMode(int32_t serial);
288
289 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
290
291 Return<void> getPreferredVoicePrivacy(int32_t serial);
292
293 Return<void> sendCDMAFeatureCode(int32_t serial,
294 const ::android::hardware::hidl_string& featureCode);
295
296 Return<void> sendBurstDtmf(int32_t serial,
297 const ::android::hardware::hidl_string& dtmf,
298 int32_t on,
299 int32_t off);
300
301 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
302
303 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
304 const CdmaSmsAck& smsAck);
305
306 Return<void> getGsmBroadcastConfig(int32_t serial);
307
308 Return<void> setGsmBroadcastConfig(int32_t serial,
309 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
310
311 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
312
313 Return<void> getCdmaBroadcastConfig(int32_t serial);
314
315 Return<void> setCdmaBroadcastConfig(int32_t serial,
316 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
317
318 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
319
320 Return<void> getCDMASubscription(int32_t serial);
321
322 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
323
324 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
325
326 Return<void> getDeviceIdentity(int32_t serial);
327
328 Return<void> exitEmergencyCallbackMode(int32_t serial);
329
330 Return<void> getSmscAddress(int32_t serial);
331
332 Return<void> setSmscAddress(int32_t serial,
333 const ::android::hardware::hidl_string& smsc);
334
335 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
336
337 Return<void> reportStkServiceIsRunning(int32_t serial);
338
339 Return<void> getCdmaSubscriptionSource(int32_t serial);
340
341 Return<void> requestIsimAuthentication(int32_t serial,
342 const ::android::hardware::hidl_string& challenge);
343
344 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
345 bool success,
346 const ::android::hardware::hidl_string& ackPdu);
347
348 Return<void> sendEnvelopeWithStatus(int32_t serial,
349 const ::android::hardware::hidl_string& contents);
350
351 Return<void> getVoiceRadioTechnology(int32_t serial);
352
353 Return<void> getCellInfoList(int32_t serial);
354
355 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
356
Jack Yu06181bb2017-01-10 12:10:41 -0800357 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
Jack Yuffc06452017-02-13 11:21:00 -0800358 bool modemCognitive, bool isRoaming);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700359
360 Return<void> getImsRegistrationState(int32_t serial);
361
362 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
363
364 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
365
366 Return<void> iccOpenLogicalChannel(int32_t serial,
367 const ::android::hardware::hidl_string& aid);
368
369 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
370
371 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
372
373 Return<void> nvReadItem(int32_t serial, NvItem itemId);
374
375 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
376
377 Return<void> nvWriteCdmaPrl(int32_t serial,
378 const ::android::hardware::hidl_vec<uint8_t>& prl);
379
380 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
381
382 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
383
384 Return<void> setDataAllowed(int32_t serial, bool allow);
385
386 Return<void> getHardwareConfig(int32_t serial);
387
388 Return<void> requestIccSimAuthentication(int32_t serial,
389 int32_t authContext,
390 const ::android::hardware::hidl_string& authData,
391 const ::android::hardware::hidl_string& aid);
392
393 Return<void> setDataProfile(int32_t serial,
Jack Yuffc06452017-02-13 11:21:00 -0800394 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700395
396 Return<void> requestShutdown(int32_t serial);
397
398 Return<void> getRadioCapability(int32_t serial);
399
400 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
401
402 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
403
404 Return<void> stopLceService(int32_t serial);
405
406 Return<void> pullLceData(int32_t serial);
407
408 Return<void> getModemActivityInfo(int32_t serial);
409
410 Return<void> setAllowedCarriers(int32_t serial,
411 bool allAllowed,
412 const CarrierRestrictions& carriers);
413
414 Return<void> getAllowedCarriers(int32_t serial);
415
Jack Yu06181bb2017-01-10 12:10:41 -0800416 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
417
418 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
419
Wileen Chiu718c0bf2017-01-04 11:37:19 -0800420 Return<void> setSimCardPower(int32_t serial, bool powerUp);
421
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700422 Return<void> responseAcknowledgement();
Amit Mahajan17249842017-01-19 15:05:45 -0800423
424 void checkReturnStatus(Return<void>& ret);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700425};
426
Amit Mahajan439da362017-02-13 17:43:04 -0800427struct OemHookImpl : public IOemHook {
428 int32_t mSlotId;
429 sp<IOemHookResponse> mOemHookResponse;
430 sp<IOemHookIndication> mOemHookIndication;
431
432 Return<void> setResponseFunctions(
433 const ::android::sp<IOemHookResponse>& oemHookResponse,
434 const ::android::sp<IOemHookIndication>& oemHookIndication);
435
436 Return<void> sendRequestRaw(int32_t serial,
437 const ::android::hardware::hidl_vec<uint8_t>& data);
438
439 Return<void> sendRequestStrings(int32_t serial,
440 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
441};
442
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800443void memsetAndFreeStrings(int numPointers, ...) {
444 va_list ap;
445 va_start(ap, numPointers);
446 for (int i = 0; i < numPointers; i++) {
447 char *ptr = va_arg(ap, char *);
448 if (ptr) {
449#ifdef MEMSET_FREED
Jack Yuffc06452017-02-13 11:21:00 -0800450 // TODO: Should pass in the maximum length of the string
451 memsetString(ptr);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800452#endif
453 free(ptr);
454 }
455 }
456 va_end(ap);
457}
458
Jack Yuffc06452017-02-13 11:21:00 -0800459void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
460 android::Parcel p; // TODO: should delete this after translation of all commands is complete
461 pRI->pCI->responseFunction(p, (int) pRI->socket_id, pRI->pCI->requestNumber,
462 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
463}
464
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800465/**
Jack Yuf68e0da2017-02-07 14:53:09 -0800466 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800467 * request with error RIL_E_NO_MEMORY.
468 * Returns true on success, and false on failure.
469 */
Jack Yuf68e0da2017-02-07 14:53:09 -0800470bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
471 size_t len = src.size();
472 if (len == 0) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800473 *dest = NULL;
474 return true;
475 }
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800476 *dest = (char *) calloc(len + 1, sizeof(char));
477 if (*dest == NULL) {
478 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
Jack Yuffc06452017-02-13 11:21:00 -0800479 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800480 return false;
481 }
482 strncpy(*dest, src, len + 1);
483 return true;
484}
485
486hidl_string convertCharPtrToHidlString(const char *ptr) {
487 hidl_string ret;
488 if (ptr != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -0800489 // TODO: replace this with strnlen
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800490 ret.setToExternal(ptr, strlen(ptr));
491 }
492 return ret;
493}
494
495bool dispatchVoid(int serial, int slotId, int request) {
496 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
497 if (pRI == NULL) {
498 return false;
499 }
500 s_vendorFunctions->onRequest(request, NULL, 0, pRI);
501 return true;
502}
503
504bool dispatchString(int serial, int slotId, int request, const char * str) {
505 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
506 if (pRI == NULL) {
507 return false;
508 }
509
510 char *pString;
511 if (!copyHidlStringToRil(&pString, str, pRI)) {
512 return false;
513 }
514
515 s_vendorFunctions->onRequest(request, pString, sizeof(char *), pRI);
516
517 memsetAndFreeStrings(1, pString);
518 return true;
519}
520
521bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) {
522 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
523 if (pRI == NULL) {
524 return false;
525 }
526
Sanket Padawef220dc52017-01-02 23:46:00 -0800527 char **pStrings;
Sanket Padawef220dc52017-01-02 23:46:00 -0800528 pStrings = (char **)calloc(countStrings, sizeof(char *));
529 if (pStrings == NULL) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800530 RLOGE("Memory allocation failed for request %s", requestToString(request));
Jack Yuffc06452017-02-13 11:21:00 -0800531 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800532 return false;
Sanket Padawef220dc52017-01-02 23:46:00 -0800533 }
534 va_list ap;
535 va_start(ap, countStrings);
536 for (int i = 0; i < countStrings; i++) {
537 const char* str = va_arg(ap, const char *);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800538 if (!copyHidlStringToRil(&pStrings[i], str, pRI)) {
Sanket Padawef220dc52017-01-02 23:46:00 -0800539 va_end(ap);
Sanket Padawef220dc52017-01-02 23:46:00 -0800540 for (int j = 0; j < i; j++) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800541 memsetAndFreeStrings(1, pStrings[j]);
Sanket Padawef220dc52017-01-02 23:46:00 -0800542 }
543 free(pStrings);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800544 return false;
Sanket Padawef220dc52017-01-02 23:46:00 -0800545 }
Sanket Padawef220dc52017-01-02 23:46:00 -0800546 }
547 va_end(ap);
548
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800549 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
Sanket Padawef220dc52017-01-02 23:46:00 -0800550
551 if (pStrings != NULL) {
552 for (int i = 0 ; i < countStrings ; i++) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800553 memsetAndFreeStrings(1, pStrings[i]);
Sanket Padawef220dc52017-01-02 23:46:00 -0800554 }
555
556#ifdef MEMSET_FREED
557 memset(pStrings, 0, countStrings * sizeof(char *));
558#endif
559 free(pStrings);
560 }
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800561 return true;
562}
563
564bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
565 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
566 if (pRI == NULL) {
567 return false;
568 }
569
570 int countStrings = data.size();
571 char **pStrings;
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800572 pStrings = (char **)calloc(countStrings, sizeof(char *));
573 if (pStrings == NULL) {
574 RLOGE("Memory allocation failed for request %s", requestToString(request));
Jack Yuffc06452017-02-13 11:21:00 -0800575 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800576 return false;
577 }
578
579 for (int i = 0; i < countStrings; i++) {
Jack Yuf68e0da2017-02-07 14:53:09 -0800580 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800581 for (int j = 0; j < i; j++) {
582 memsetAndFreeStrings(1, pStrings[j]);
583 }
584 free(pStrings);
585 return false;
586 }
587 }
588
589 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
590
591 if (pStrings != NULL) {
592 for (int i = 0 ; i < countStrings ; i++) {
593 memsetAndFreeStrings(1, pStrings[i]);
594 }
595
596#ifdef MEMSET_FREED
597 memset(pStrings, 0, countStrings * sizeof(char *));
598#endif
599 free(pStrings);
600 }
601 return true;
602}
603
604bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
605 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
606 if (pRI == NULL) {
607 return false;
608 }
609
Jack Yuffc06452017-02-13 11:21:00 -0800610 int *pInts = (int *)calloc(countInts, sizeof(int));
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800611
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800612 if (pInts == NULL) {
613 RLOGE("Memory allocation failed for request %s", requestToString(request));
Jack Yuffc06452017-02-13 11:21:00 -0800614 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800615 return false;
616 }
617 va_list ap;
618 va_start(ap, countInts);
619 for (int i = 0; i < countInts; i++) {
620 pInts[i] = va_arg(ap, int);
621 }
622 va_end(ap);
623
624 s_vendorFunctions->onRequest(request, pInts, countInts * sizeof(int), pRI);
625
626 if (pInts != NULL) {
627#ifdef MEMSET_FREED
628 memset(pInts, 0, countInts * sizeof(int));
629#endif
630 free(pInts);
631 }
632 return true;
633}
634
635bool dispatchCallForwardStatus(int serial, int slotId, int request,
636 const CallForwardInfo& callInfo) {
637 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
638 if (pRI == NULL) {
639 return false;
640 }
641
642 RIL_CallForwardInfo cf;
643 cf.status = (int) callInfo.status;
644 cf.reason = callInfo.reason;
645 cf.serviceClass = callInfo.serviceClass;
646 cf.toa = callInfo.toa;
647 cf.timeSeconds = callInfo.timeSeconds;
648
649 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
650 return false;
651 }
652
653 s_vendorFunctions->onRequest(request, &cf, sizeof(cf), pRI);
654
655 memsetAndFreeStrings(1, cf.number);
656
657 return true;
658}
659
660bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
661 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
662 if (pRI == NULL) {
663 return false;
664 }
665
666 const uint8_t *uData = rawBytes.data();
667
668 s_vendorFunctions->onRequest(request, (void *) uData, rawBytes.size(), pRI);
669
670 return true;
671}
672
673bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
674 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
675 if (pRI == NULL) {
676 return false;
677 }
678
679 RIL_SIM_APDU apdu;
680 memset (&apdu, 0, sizeof(RIL_SIM_APDU));
681
682 apdu.sessionid = message.sessionId;
683 apdu.cla = message.cla;
684 apdu.instruction = message.instruction;
685 apdu.p1 = message.p1;
686 apdu.p2 = message.p2;
687 apdu.p3 = message.p3;
688
689 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
690 return false;
691 }
692
693 s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI);
694
695 memsetAndFreeStrings(1, apdu.data);
696
697 return true;
Sanket Padawef220dc52017-01-02 23:46:00 -0800698}
699
Amit Mahajan439da362017-02-13 17:43:04 -0800700void checkReturnStatus(int32_t slotId, Return<void>& ret) {
Amit Mahajan17249842017-01-19 15:05:45 -0800701 if (ret.isOk() == false) {
Amit Mahajan439da362017-02-13 17:43:04 -0800702 RLOGE("checkReturnStatus: unable to call response/indication callback");
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800703 // Remote process hosting the callbacks must be dead. Reset the callback objects;
Amit Mahajan17249842017-01-19 15:05:45 -0800704 // there's no other recovery to be done here. When the client process is back up, it will
705 // call setResponseFunctions()
Amit Mahajan932e08e2017-01-24 05:45:02 -0800706
707 // Caller should already hold rdlock, release that first
708 // note the current counter to avoid overwriting updates made by another thread before
709 // write lock is acquired.
Amit Mahajan439da362017-02-13 17:43:04 -0800710 int counter = mCounter[slotId];
711 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
Amit Mahajan932e08e2017-01-24 05:45:02 -0800712 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
713 assert(ret == 0);
714
715 // acquire wrlock
716 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
717 assert(ret == 0);
718
719 // make sure the counter value has not changed
Amit Mahajan439da362017-02-13 17:43:04 -0800720 if (counter == mCounter[slotId]) {
721 radioService[slotId]->mRadioResponse = NULL;
722 radioService[slotId]->mRadioIndication = NULL;
723 oemHookService[slotId]->mOemHookResponse = NULL;
724 oemHookService[slotId]->mOemHookIndication = NULL;
725 mCounter[slotId]++;
Amit Mahajan932e08e2017-01-24 05:45:02 -0800726 } else {
Amit Mahajan439da362017-02-13 17:43:04 -0800727 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800728 "got updated on another thread");
Amit Mahajan932e08e2017-01-24 05:45:02 -0800729 }
730
731 // release wrlock
732 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
733 assert(ret == 0);
734
735 // Reacquire rdlock
736 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
737 assert(ret == 0);
Amit Mahajan17249842017-01-19 15:05:45 -0800738 }
739}
740
Amit Mahajan439da362017-02-13 17:43:04 -0800741void RadioImpl::checkReturnStatus(Return<void>& ret) {
742 ::checkReturnStatus(mSlotId, ret);
743}
744
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700745Return<void> RadioImpl::setResponseFunctions(
746 const ::android::sp<IRadioResponse>& radioResponseParam,
747 const ::android::sp<IRadioIndication>& radioIndicationParam) {
748 RLOGD("RadioImpl::setResponseFunctions");
Amit Mahajan932e08e2017-01-24 05:45:02 -0800749
750 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
751 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
752 assert(ret == 0);
753
Sanket Padawef220dc52017-01-02 23:46:00 -0800754 mRadioResponse = radioResponseParam;
755 mRadioIndication = radioIndicationParam;
Amit Mahajan439da362017-02-13 17:43:04 -0800756 mCounter[mSlotId]++;
Amit Mahajan932e08e2017-01-24 05:45:02 -0800757
758 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
759 assert(ret == 0);
760
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800761 return Void();
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700762}
763
764Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
765 RLOGD("RadioImpl::getIccCardStatus: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800766 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
767 return Void();
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700768}
769
Sanket Padawef220dc52017-01-02 23:46:00 -0800770Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
771 const hidl_string& aid) {
772 RLOGD("RadioImpl::supplyIccPinForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800773 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
774 2, (const char *)pin, (const char *)aid);
775 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800776}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700777
Sanket Padawef220dc52017-01-02 23:46:00 -0800778Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800779 const hidl_string& pin, const hidl_string& aid) {
Sanket Padawef220dc52017-01-02 23:46:00 -0800780 RLOGD("RadioImpl::supplyIccPukForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800781 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
782 3, (const char *)puk, (const char *)pin, (const char *)aid);
783 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800784}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700785
Sanket Padawef220dc52017-01-02 23:46:00 -0800786Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800787 const hidl_string& aid) {
Sanket Padawef220dc52017-01-02 23:46:00 -0800788 RLOGD("RadioImpl::supplyIccPin2ForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800789 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
790 2, (const char *)pin2, (const char *)aid);
791 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800792}
793
794Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800795 const hidl_string& pin2, const hidl_string& aid) {
Sanket Padawef220dc52017-01-02 23:46:00 -0800796 RLOGD("RadioImpl::supplyIccPuk2ForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800797 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
798 3, (const char *)puk2, (const char *)pin2, (const char *)aid);
799 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800800}
801
802Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800803 const hidl_string& newPin, const hidl_string& aid) {
Sanket Padawef220dc52017-01-02 23:46:00 -0800804 RLOGD("RadioImpl::changeIccPinForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800805 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
806 3, (const char *)oldPin, (const char *)newPin, (const char *)aid);
807 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800808}
809
810Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800811 const hidl_string& newPin2, const hidl_string& aid) {
Sanket Padawef220dc52017-01-02 23:46:00 -0800812 RLOGD("RadioImpl::changeIccPin2ForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800813 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
814 3, (const char *)oldPin2, (const char *)newPin2, (const char *)aid);
815 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800816}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700817
818Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800819 const hidl_string& netPin) {
Sanket Padawef220dc52017-01-02 23:46:00 -0800820 RLOGD("RadioImpl::supplyNetworkDepersonalization: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800821 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
822 1, (const char *)netPin);
823 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800824}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700825
Sanket Padawef220dc52017-01-02 23:46:00 -0800826Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
827 RLOGD("RadioImpl::getCurrentCalls: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800828 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
829 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800830}
831
832Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
833 RLOGD("RadioImpl::dial: serial %d", serial);
834 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
835 if (pRI == NULL) {
836 return Void();
837 }
Jack Yuf68e0da2017-02-07 14:53:09 -0800838 RIL_Dial dial = {};
839 RIL_UUS_Info uusInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -0800840 int32_t sizeOfDial = sizeof(dial);
841
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800842 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
Sanket Padawef220dc52017-01-02 23:46:00 -0800843 return Void();
844 }
Jack Yuf68e0da2017-02-07 14:53:09 -0800845 dial.clir = (int) dialInfo.clir;
Sanket Padawef220dc52017-01-02 23:46:00 -0800846
Sanket Padawef220dc52017-01-02 23:46:00 -0800847 if (dialInfo.uusInfo.size() != 0) {
Sanket Padawef220dc52017-01-02 23:46:00 -0800848 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
849 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
850
851 if (dialInfo.uusInfo[0].uusData.size() == 0) {
852 uusInfo.uusData = NULL;
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800853 uusInfo.uusLength = 0;
Sanket Padawef220dc52017-01-02 23:46:00 -0800854 } else {
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800855 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
856 memsetAndFreeStrings(1, dial.address);
Sanket Padawef220dc52017-01-02 23:46:00 -0800857 return Void();
858 }
Jack Yuf68e0da2017-02-07 14:53:09 -0800859 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
Sanket Padawef220dc52017-01-02 23:46:00 -0800860 }
861
Sanket Padawef220dc52017-01-02 23:46:00 -0800862 dial.uusInfo = &uusInfo;
863 }
864
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800865 s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI);
Sanket Padawef220dc52017-01-02 23:46:00 -0800866
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800867 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
Sanket Padawef220dc52017-01-02 23:46:00 -0800868
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800869 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800870}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700871
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800872Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
873 RLOGD("RadioImpl::getImsiForApp: serial %d", serial);
874 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
875 1, (const char *) aid);
876 return Void();
877}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700878
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800879Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
880 RLOGD("RadioImpl::hangup: serial %d", serial);
881 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
882 return Void();
883}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700884
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800885Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
886 RLOGD("RadioImpl::hangupWaitingOrBackground: serial %d", serial);
887 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
888 return Void();
889}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700890
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800891Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
892 RLOGD("RadioImpl::hangupForegroundResumeBackground: serial %d", serial);
893 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
894 return Void();
895}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700896
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800897Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
898 RLOGD("RadioImpl::switchWaitingOrHoldingAndActive: serial %d", serial);
899 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
900 return Void();
901}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700902
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800903Return<void> RadioImpl::conference(int32_t serial) {
904 RLOGD("RadioImpl::conference: serial %d", serial);
905 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
906 return Void();
907}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700908
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800909Return<void> RadioImpl::rejectCall(int32_t serial) {
910 RLOGD("RadioImpl::rejectCall: serial %d", serial);
911 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
912 return Void();
913}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700914
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800915Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
916 RLOGD("RadioImpl::getLastCallFailCause: serial %d", serial);
917 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
918 return Void();
919}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700920
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800921Return<void> RadioImpl::getSignalStrength(int32_t serial) {
922 RLOGD("RadioImpl::getSignalStrength: serial %d", serial);
923 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
924 return Void();
925}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700926
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800927Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
928 RLOGD("RadioImpl::getVoiceRegistrationState: serial %d", serial);
929 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
930 return Void();
931}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700932
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800933Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
934 RLOGD("RadioImpl::getDataRegistrationState: serial %d", serial);
935 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
936 return Void();
937}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700938
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800939Return<void> RadioImpl::getOperator(int32_t serial) {
940 RLOGD("RadioImpl::getOperator: serial %d", serial);
941 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
942 return Void();
943}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700944
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800945Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
946 RLOGD("RadioImpl::setRadioPower: serial %d on %d", serial, on);
947 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
948 return Void();
949}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700950
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800951Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
952 RLOGD("RadioImpl::sendDtmf: serial %d", serial);
953 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, (const char *) s);
954 return Void();
955}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700956
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800957Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
958 RLOGD("RadioImpl::sendSms: serial %d", serial);
959 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
960 2, (const char *) message.smscPdu, (const char *) message.pdu);
961 return Void();
962}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700963
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800964Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
965 RLOGD("RadioImpl::sendSMSExpectMore: serial %d", serial);
966 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
967 2, (const char *) message.smscPdu, (const char *) message.pdu);
968 return Void();
969}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700970
Jack Yuffc06452017-02-13 11:21:00 -0800971const char *convertMvnoTypeToString(MvnoType type) {
972 switch (type) {
973 case MvnoType::IMSI: return "imsi";
974 case MvnoType::GID: return "gid";
975 case MvnoType::SPN: return "spn";
976 default: return NULL;
977 }
978}
979
980Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
981 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
982 bool roamingAllowed, bool isRoaming) {
983
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800984 RLOGD("RadioImpl::setupDataCall: serial %d", serial);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700985
Jack Yuffc06452017-02-13 11:21:00 -0800986 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
987 const hidl_string &protocol =
988 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
989 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
990 std::to_string((int) radioTechnology + 2).c_str(),
991 std::to_string((int) dataProfileInfo.profileId).c_str(),
992 dataProfileInfo.apn.c_str(),
993 dataProfileInfo.user.c_str(),
994 dataProfileInfo.password.c_str(),
995 std::to_string((int) dataProfileInfo.authType).c_str(),
996 protocol.c_str());
997 } else if (s_vendorFunctions->version >= 15) {
998 const char *mvnoTypeStr = convertMvnoTypeToString(dataProfileInfo.mvnoType);
999 if (mvnoTypeStr == NULL) {
1000 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1001 RIL_REQUEST_SETUP_DATA_CALL);
1002 if (pRI != NULL) {
1003 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1004 }
1005 return Void();
1006 }
1007 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1008 std::to_string((int) radioTechnology + 2).c_str(),
1009 std::to_string((int) dataProfileInfo.profileId).c_str(),
1010 dataProfileInfo.apn.c_str(),
1011 dataProfileInfo.user.c_str(),
1012 dataProfileInfo.password.c_str(),
1013 std::to_string((int) dataProfileInfo.authType).c_str(),
1014 dataProfileInfo.protocol.c_str(),
1015 dataProfileInfo.roamingProtocol.c_str(),
1016 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1017 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1018 BOOL_TO_INT(modemCognitive),
1019 std::to_string(dataProfileInfo.mtu).c_str(),
1020 mvnoTypeStr,
1021 dataProfileInfo.mvnoMatchData.c_str(),
1022 BOOL_TO_INT(roamingAllowed));
1023 } else {
1024 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1025 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1026 RIL_REQUEST_SETUP_DATA_CALL);
1027 if (pRI != NULL) {
1028 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1029 }
1030 }
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001031 return Void();
1032}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001033
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001034Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1035 RLOGD("RadioImpl::iccIOForApp: serial %d", serial);
1036 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1037 if (pRI == NULL) {
1038 return Void();
1039 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001040
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001041 RIL_SIM_IO_v6 rilIccIo;
1042 rilIccIo.command = iccIo.command;
1043 rilIccIo.fileid = iccIo.fileId;
1044 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1045 return Void();
1046 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001047
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001048 rilIccIo.p1 = iccIo.p1;
1049 rilIccIo.p2 = iccIo.p2;
1050 rilIccIo.p3 = iccIo.p3;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001051
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001052 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1053 memsetAndFreeStrings(1, rilIccIo.path);
1054 return Void();
1055 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001056
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001057 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1058 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1059 return Void();
1060 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001061
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001062 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1063 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1064 return Void();
1065 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001066
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001067 s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI);
1068
1069 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1070
1071 return Void();
1072}
1073
1074Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1075 RLOGD("RadioImpl::sendUssd: serial %d", serial);
1076 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, (const char *) ussd);
1077 return Void();
1078}
1079
1080Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1081 RLOGD("RadioImpl::cancelPendingUssd: serial %d", serial);
1082 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1083 return Void();
1084}
1085
1086Return<void> RadioImpl::getClir(int32_t serial) {
1087 RLOGD("RadioImpl::getClir: serial %d", serial);
1088 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1089 return Void();
1090}
1091
1092Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1093 RLOGD("RadioImpl::setClir: serial %d", serial);
1094 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1095 return Void();
1096}
1097
1098Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1099 RLOGD("RadioImpl::getCallForwardStatus: serial %d", serial);
1100 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1101 callInfo);
1102 return Void();
1103}
1104
1105Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1106 RLOGD("RadioImpl::setCallForward: serial %d", serial);
1107 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1108 callInfo);
1109 return Void();
1110}
1111
1112Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1113 RLOGD("RadioImpl::getCallWaiting: serial %d", serial);
1114 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1115 return Void();
1116}
1117
1118Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1119 RLOGD("RadioImpl::setCallWaiting: serial %d", serial);
1120 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1121 serviceClass);
1122 return Void();
1123}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001124
1125Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001126 bool success, SmsAcknowledgeFailCause cause) {
1127 RLOGD("RadioImpl::acknowledgeLastIncomingGsmSms: serial %d", serial);
1128 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1129 cause);
1130 return Void();
1131}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001132
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001133Return<void> RadioImpl::acceptCall(int32_t serial) {
1134 RLOGD("RadioImpl::acceptCall: serial %d", serial);
1135 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1136 return Void();
1137}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001138
1139Return<void> RadioImpl::deactivateDataCall(int32_t serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001140 int32_t cid, bool reasonRadioShutDown) {
1141 RLOGD("RadioImpl::deactivateDataCall: serial %d", serial);
1142 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1143 2, (const char *) (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1144 return Void();
1145}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001146
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001147Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1148 const hidl_string& password, int32_t serviceClass,
1149 const hidl_string& appId) {
1150 RLOGD("RadioImpl::getFacilityLockForApp: serial %d", serial);
1151 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1152 4, (const char *) facility, (const char *) password,
1153 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId);
1154 return Void();
1155}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001156
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001157Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1158 bool lockState, const hidl_string& password,
1159 int32_t serviceClass, const hidl_string& appId) {
1160 RLOGD("RadioImpl::setFacilityLockForApp: serial %d", serial);
1161 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1162 5, (const char *) facility, lockState ? "1" : "0", (const char *) password,
1163 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId);
1164 return Void();
1165}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001166
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001167Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1168 const hidl_string& oldPassword,
1169 const hidl_string& newPassword) {
1170 RLOGD("RadioImpl::setBarringPassword: serial %d", serial);
1171 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1172 2, (const char *) oldPassword, (const char *) newPassword);
1173 return Void();
1174}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001175
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001176Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1177 RLOGD("RadioImpl::getNetworkSelectionMode: serial %d", serial);
1178 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1179 return Void();
1180}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001181
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001182Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1183 RLOGD("RadioImpl::setNetworkSelectionModeAutomatic: serial %d", serial);
1184 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1185 return Void();
1186}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001187
1188Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001189 const hidl_string& operatorNumeric) {
1190 RLOGD("RadioImpl::setNetworkSelectionModeManual: serial %d", serial);
1191 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1192 (const char *) operatorNumeric);
1193 return Void();
1194}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001195
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001196Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1197 RLOGD("RadioImpl::getAvailableNetworks: serial %d", serial);
1198 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1199 return Void();
1200}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001201
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001202Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1203 RLOGD("RadioImpl::startDtmf: serial %d", serial);
1204 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1205 (const char *) s);
1206 return Void();
1207}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001208
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001209Return<void> RadioImpl::stopDtmf(int32_t serial) {
1210 RLOGD("RadioImpl::stopDtmf: serial %d", serial);
1211 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1212 return Void();
1213}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001214
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001215Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1216 RLOGD("RadioImpl::getBasebandVersion: serial %d", serial);
1217 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1218 return Void();
1219}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001220
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001221Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1222 RLOGD("RadioImpl::separateConnection: serial %d", serial);
1223 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1224 return Void();
1225}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001226
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001227Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1228 RLOGD("RadioImpl::setMute: serial %d", serial);
1229 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1230 return Void();
1231}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001232
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001233Return<void> RadioImpl::getMute(int32_t serial) {
1234 RLOGD("RadioImpl::getMute: serial %d", serial);
1235 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1236 return Void();
1237}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001238
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001239Return<void> RadioImpl::getClip(int32_t serial) {
1240 RLOGD("RadioImpl::getClip: serial %d", serial);
1241 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1242 return Void();
1243}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001244
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001245Return<void> RadioImpl::getDataCallList(int32_t serial) {
1246 RLOGD("RadioImpl::getDataCallList: serial %d", serial);
1247 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1248 return Void();
1249}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001250
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001251Return<void> RadioImpl::sendScreenState(int32_t serial, bool enable) {
1252 RLOGD("RadioImpl::sendScreenState: serial %d", serial);
1253 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(enable));
1254 return Void();
1255}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001256
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001257Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1258 RLOGD("RadioImpl::setSuppServiceNotifications: serial %d", serial);
1259 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1260 BOOL_TO_INT(enable));
1261 return Void();
1262}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001263
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001264Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1265 RLOGD("RadioImpl::writeSmsToSim: serial %d", serial);
1266 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1267 if (pRI == NULL) {
1268 return Void();
1269 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001270
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001271 RIL_SMS_WriteArgs args;
1272 args.status = (int) smsWriteArgs.status;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001273
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001274 int len;
1275 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1276 return Void();
1277 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001278
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001279 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1280 memsetAndFreeStrings(1, args.pdu);
1281 return Void();
1282 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001283
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001284 s_vendorFunctions->onRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI);
1285
1286 memsetAndFreeStrings(2, args.smsc, args.pdu);
1287
1288 return Void();
1289}
1290
1291Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1292 RLOGD("RadioImpl::deleteSmsOnSim: serial %d", serial);
1293 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1294 return Void();
1295}
1296
1297Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1298 RLOGD("RadioImpl::setBandMode: serial %d", serial);
1299 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1300 return Void();
1301}
1302
1303Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1304 RLOGD("RadioImpl::getAvailableBandModes: serial %d", serial);
1305 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1306 return Void();
1307}
1308
1309Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1310 RLOGD("RadioImpl::sendEnvelope: serial %d", serial);
1311 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1312 (const char *) command);
1313 return Void();
1314}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001315
1316Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001317 const hidl_string& commandResponse) {
1318 RLOGD("RadioImpl::sendTerminalResponseToSim: serial %d", serial);
1319 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1320 (const char *) commandResponse);
1321 return Void();
1322}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001323
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001324Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1325 RLOGD("RadioImpl::handleStkCallSetupRequestFromSim: serial %d", serial);
1326 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1327 1, BOOL_TO_INT(accept));
1328 return Void();
1329}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001330
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001331Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1332 RLOGD("RadioImpl::explicitCallTransfer: serial %d", serial);
1333 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1334 return Void();
1335}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001336
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001337Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1338 RLOGD("RadioImpl::setPreferredNetworkType: serial %d", serial);
1339 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1340 return Void();
1341}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001342
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001343Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1344 RLOGD("RadioImpl::getPreferredNetworkType: serial %d", serial);
1345 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1346 return Void();
1347}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001348
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001349Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1350 RLOGD("RadioImpl::getNeighboringCids: serial %d", serial);
1351 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1352 return Void();
1353}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001354
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001355Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1356 RLOGD("RadioImpl::setLocationUpdates: serial %d", serial);
1357 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1358 return Void();
1359}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001360
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001361Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1362 RLOGD("RadioImpl::setCdmaSubscriptionSource: serial %d", serial);
1363 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1364 return Void();
1365}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001366
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001367Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1368 RLOGD("RadioImpl::setCdmaRoamingPreference: serial %d", serial);
1369 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1370 return Void();
1371}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001372
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001373Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1374 RLOGD("RadioImpl::getCdmaRoamingPreference: serial %d", serial);
1375 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1376 return Void();
1377}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001378
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001379Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1380 RLOGD("RadioImpl::setTTYMode: serial %d", serial);
1381 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1382 return Void();
1383}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001384
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001385Return<void> RadioImpl::getTTYMode(int32_t serial) {
1386 RLOGD("RadioImpl::getTTYMode: serial %d", serial);
1387 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1388 return Void();
1389}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001390
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001391Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1392 RLOGD("RadioImpl::setPreferredVoicePrivacy: serial %d", serial);
1393 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1394 1, BOOL_TO_INT(enable));
1395 return Void();
1396}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001397
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001398Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1399 RLOGD("RadioImpl::getPreferredVoicePrivacy: serial %d", serial);
1400 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1401 return Void();
1402}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001403
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001404Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1405 RLOGD("RadioImpl::sendCDMAFeatureCode: serial %d", serial);
1406 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1407 (const char *) featureCode);
1408 return Void();
1409}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001410
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001411Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1412 int32_t off) {
1413 RLOGD("RadioImpl::sendBurstDtmf: serial %d", serial);
1414 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1415 3, (const char *) dtmf, (const char *) (std::to_string(on)).c_str(),
1416 (const char *) (std::to_string(off)).c_str());
1417 return Void();
1418}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001419
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001420void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1421 memset(&rcsm, 0, sizeof(rcsm));
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001422
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001423 rcsm.uTeleserviceID = sms.teleserviceId;
1424 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1425 rcsm.uServicecategory = sms.serviceCategory;
1426 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1427 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1428 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1429 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001430
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001431 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1432 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1433 for (int i = 0; i < digitLimit; i++) {
1434 rcsm.sAddress.digits[i] = sms.address.digits[i];
1435 }
1436
1437 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1438 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1439
1440 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1441 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1442 for (int i = 0; i < digitLimit; i++) {
1443 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1444 }
1445
1446 rcsm.uBearerDataLen = sms.bearerData.size();
1447 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1448 for (int i = 0; i < digitLimit; i++) {
1449 rcsm.aBearerData[i] = sms.bearerData[i];
1450 }
1451}
1452
1453Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1454 RLOGD("RadioImpl::sendCdmaSms: serial %d", serial);
1455 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1456 if (pRI == NULL) {
1457 return Void();
1458 }
1459
1460 RIL_CDMA_SMS_Message rcsm;
1461 constructCdmaSms(rcsm, sms);
1462
1463 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI);
1464 return Void();
1465}
1466
1467Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1468 RLOGD("RadioImpl::acknowledgeLastIncomingCdmaSms: serial %d", serial);
1469 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1470 if (pRI == NULL) {
1471 return Void();
1472 }
1473
Jack Yuf68e0da2017-02-07 14:53:09 -08001474 RIL_CDMA_SMS_Ack rcsa = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001475
1476 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1477 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1478
1479 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI);
1480 return Void();
1481}
1482
1483Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1484 RLOGD("RadioImpl::getGsmBroadcastConfig: serial %d", serial);
1485 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1486 return Void();
1487}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001488
1489Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001490 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1491 configInfo) {
1492 RLOGD("RadioImpl::setGsmBroadcastConfig: serial %d", serial);
1493 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1494 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1495 if (pRI == NULL) {
1496 return Void();
1497 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001498
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001499 int num = configInfo.size();
1500 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1501 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001502
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001503 for (int i = 0 ; i < num ; i++ ) {
1504 gsmBciPtrs[i] = &gsmBci[i];
1505 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1506 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1507 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1508 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1509 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1510 }
1511
1512 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, gsmBciPtrs,
1513 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI);
1514 return Void();
1515}
1516
1517Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1518 RLOGD("RadioImpl::setGsmBroadcastActivation: serial %d", serial);
1519 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
Sanket Padawe0de29d12017-02-10 13:19:47 -08001520 1, BOOL_TO_INT(!activate));
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001521 return Void();
1522}
1523
1524Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1525 RLOGD("RadioImpl::getCdmaBroadcastConfig: serial %d", serial);
1526 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1527 return Void();
1528}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001529
1530Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001531 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1532 configInfo) {
1533 RLOGD("RadioImpl::setCdmaBroadcastConfig: serial %d", serial);
1534 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1535 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1536 if (pRI == NULL) {
1537 return Void();
1538 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001539
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001540 int num = configInfo.size();
1541 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1542 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001543
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001544 for (int i = 0 ; i < num ; i++ ) {
1545 cdmaBciPtrs[i] = &cdmaBci[i];
1546 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1547 cdmaBci[i].language = configInfo[i].language;
1548 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1549 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001550
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001551 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, cdmaBciPtrs,
1552 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI);
1553 return Void();
1554}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001555
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001556Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1557 RLOGD("RadioImpl::setCdmaBroadcastActivation: serial %d", serial);
1558 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
Sanket Padawe0de29d12017-02-10 13:19:47 -08001559 1, BOOL_TO_INT(!activate));
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001560 return Void();
1561}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001562
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001563Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1564 RLOGD("RadioImpl::getCDMASubscription: serial %d", serial);
1565 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1566 return Void();
1567}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001568
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001569Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1570 RLOGD("RadioImpl::writeSmsToRuim: serial %d", serial);
1571 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1572 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1573 if (pRI == NULL) {
1574 return Void();
1575 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001576
Jack Yuf68e0da2017-02-07 14:53:09 -08001577 RIL_CDMA_SMS_WriteArgs rcsw = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001578 rcsw.status = (int) cdmaSms.status;
1579 constructCdmaSms(rcsw.message, cdmaSms.message);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001580
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001581 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI);
1582 return Void();
1583}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001584
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001585Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1586 RLOGD("RadioImpl::deleteSmsOnRuim: serial %d", serial);
1587 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1588 return Void();
1589}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001590
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001591Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1592 RLOGD("RadioImpl::getDeviceIdentity: serial %d", serial);
1593 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1594 return Void();
1595}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001596
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001597Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1598 RLOGD("RadioImpl::exitEmergencyCallbackMode: serial %d", serial);
1599 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1600 return Void();
1601}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001602
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001603Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1604 RLOGD("RadioImpl::getSmscAddress: serial %d", serial);
1605 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1606 return Void();
1607}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001608
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001609Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1610 RLOGD("RadioImpl::setSmscAddress: serial %d", serial);
1611 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1612 (const char *) smsc);
1613 return Void();
1614}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001615
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001616Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1617 RLOGD("RadioImpl::reportSmsMemoryStatus: serial %d", serial);
1618 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1619 BOOL_TO_INT(available));
1620 return Void();
1621}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001622
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001623Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1624 RLOGD("RadioImpl::reportStkServiceIsRunning: serial %d", serial);
1625 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1626 return Void();
1627}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001628
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001629Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1630 RLOGD("RadioImpl::getCdmaSubscriptionSource: serial %d", serial);
1631 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1632 return Void();
1633}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001634
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001635Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1636 RLOGD("RadioImpl::requestIsimAuthentication: serial %d", serial);
1637 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1638 (const char *) challenge);
1639 return Void();
1640}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001641
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001642Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1643 const hidl_string& ackPdu) {
1644 RLOGD("RadioImpl::acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1645 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1646 2, success ? "1" : "0", (const char *) ackPdu);
1647 return Void();
1648}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001649
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001650Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1651 RLOGD("RadioImpl::sendEnvelopeWithStatus: serial %d", serial);
1652 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1653 (const char *) contents);
1654 return Void();
1655}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001656
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001657Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1658 RLOGD("RadioImpl::getVoiceRadioTechnology: serial %d", serial);
1659 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1660 return Void();
1661}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001662
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001663Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1664 RLOGD("RadioImpl::getCellInfoList: serial %d", serial);
1665 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1666 return Void();
1667}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001668
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001669Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1670 RLOGD("RadioImpl::setCellInfoListRate: serial %d", serial);
1671 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1672 return Void();
1673}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001674
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001675Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
Jack Yuffc06452017-02-13 11:21:00 -08001676 bool modemCognitive, bool isRoaming) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001677 RLOGD("RadioImpl::setInitialAttachApn: serial %d", serial);
1678 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1679 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
1680 if (pRI == NULL) {
1681 return Void();
1682 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001683
Jack Yuffc06452017-02-13 11:21:00 -08001684 if (s_vendorFunctions->version <= 14) {
1685 RIL_InitialAttachApn iaa = {};
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001686
Jack Yuffc06452017-02-13 11:21:00 -08001687 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1688 return Void();
1689 }
1690
1691 const hidl_string &protocol =
1692 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1693
1694 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
1695 return Void();
1696 }
1697 iaa.authtype = (int) dataProfileInfo.authType;
1698 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1699 return Void();
1700 }
1701 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1702 return Void();
1703 }
1704
1705 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1706
1707 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
1708 } else {
1709 RIL_InitialAttachApn_v15 iaa = {};
1710
1711 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1712 return Void();
1713 }
1714 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
1715 return Void();
1716 }
1717 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
1718 return Void();
1719 }
1720 iaa.authtype = (int) dataProfileInfo.authType;
1721 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1722 return Void();
1723 }
1724 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1725 return Void();
1726 }
1727 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
1728 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
1729 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
1730 iaa.mtu = dataProfileInfo.mtu;
1731
1732 // Note that there is no need for memory allocation/free.
1733 iaa.mvnoType = (char *) convertMvnoTypeToString(dataProfileInfo.mvnoType);
1734 if (iaa.mvnoType == NULL) {
1735 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1736 return Void();
1737 }
1738
1739 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
1740 return Void();
1741 }
1742
1743 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1744
1745 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1746 iaa.password, iaa.mvnoMatchData);
1747 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001748
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001749 return Void();
1750}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001751
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001752Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
1753 RLOGD("RadioImpl::getImsRegistrationState: serial %d", serial);
1754 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
1755 return Void();
1756}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001757
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001758bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
Jack Yuf68e0da2017-02-07 14:53:09 -08001759 RIL_IMS_SMS_Message rism = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001760 char **pStrings;
1761 int countStrings = 2;
1762 int dataLen = sizeof(char *) * countStrings;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001763
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001764 rism.tech = RADIO_TECH_3GPP;
1765 rism.retry = BOOL_TO_INT(message.retry);
1766 rism.messageRef = message.messageRef;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001767
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001768 if (message.gsmMessage.size() != 1) {
1769 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
Jack Yuffc06452017-02-13 11:21:00 -08001770 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001771 return false;
1772 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001773
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001774 pStrings = (char **)calloc(countStrings, sizeof(char *));
1775 if (pStrings == NULL) {
1776 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
1777 requestToString(pRI->pCI->requestNumber));
Jack Yuffc06452017-02-13 11:21:00 -08001778 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001779 return false;
1780 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001781
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001782 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
1783#ifdef MEMSET_FREED
1784 memset(pStrings, 0, datalen);
1785#endif
1786 free(pStrings);
1787 return false;
1788 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001789
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001790 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
1791 memsetAndFreeStrings(1, pStrings[0]);
1792#ifdef MEMSET_FREED
1793 memset(pStrings, 0, datalen);
1794#endif
1795 free(pStrings);
1796 return false;
1797 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001798
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001799 rism.message.gsmMessage = pStrings;
1800 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
1801 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001802
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001803 for (int i = 0 ; i < countStrings ; i++) {
1804 memsetAndFreeStrings(1, pStrings[i]);
1805 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001806
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001807#ifdef MEMSET_FREED
1808 memset(pStrings, 0, datalen);
1809#endif
1810 free(pStrings);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001811
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001812 return true;
1813}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001814
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001815bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
1816 RIL_IMS_SMS_Message rism;
1817 RIL_CDMA_SMS_Message rcsm;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001818
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001819 if (message.cdmaMessage.size() != 1) {
1820 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
Jack Yuffc06452017-02-13 11:21:00 -08001821 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001822 return false;
1823 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001824
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001825 rism.tech = RADIO_TECH_3GPP2;
1826 rism.retry = BOOL_TO_INT(message.retry);
1827 rism.messageRef = message.messageRef;
1828 rism.message.cdmaMessage = &rcsm;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001829
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001830 constructCdmaSms(rcsm, message.cdmaMessage[0]);
1831
1832 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
1833 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI);
1834
1835 return true;
1836}
1837
1838Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
1839 RLOGD("RadioImpl::sendImsSms: serial %d", serial);
1840 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
1841 if (pRI == NULL) {
1842 return Void();
1843 }
1844
1845 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
1846
1847 if (RADIO_TECH_3GPP == format) {
1848 dispatchImsGsmSms(message, pRI);
1849 } else if (RADIO_TECH_3GPP2 == format) {
1850 dispatchImsCdmaSms(message, pRI);
1851 } else {
1852 RLOGE("RadioImpl::sendImsSms: Invalid radio tech %s",
1853 requestToString(pRI->pCI->requestNumber));
Jack Yuffc06452017-02-13 11:21:00 -08001854 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001855 }
1856 return Void();
1857}
1858
1859Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
1860 RLOGD("RadioImpl::iccTransmitApduBasicChannel: serial %d", serial);
1861 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
1862 return Void();
1863}
1864
1865Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid) {
1866 RLOGD("RadioImpl::iccOpenLogicalChannel: serial %d", serial);
1867 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL,
1868 (const char *) aid);
1869 return Void();
1870}
1871
1872Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
1873 RLOGD("RadioImpl::iccCloseLogicalChannel: serial %d", serial);
1874 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
1875 return Void();
1876}
1877
1878Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
1879 RLOGD("RadioImpl::iccTransmitApduLogicalChannel: serial %d", serial);
1880 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
1881 return Void();
1882}
1883
1884Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
1885 RLOGD("RadioImpl::nvReadItem: serial %d", serial);
1886 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
1887 if (pRI == NULL) {
1888 return Void();
1889 }
1890
1891 RIL_NV_ReadItem nvri;
1892 memset (&nvri, 0, sizeof(nvri));
1893 nvri.itemID = (RIL_NV_Item) itemId;
1894
1895 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI);
1896 return Void();
1897}
1898
1899Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
1900 RLOGD("RadioImpl::nvWriteItem: serial %d", serial);
1901 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
1902 if (pRI == NULL) {
1903 return Void();
1904 }
1905
1906 RIL_NV_WriteItem nvwi;
1907 memset (&nvwi, 0, sizeof(nvwi));
1908
1909 nvwi.itemID = (RIL_NV_Item) item.itemId;
1910
1911 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
1912 return Void();
1913 }
1914
1915 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI);
1916
1917 memsetAndFreeStrings(1, nvwi.value);
1918 return Void();
1919}
1920
1921Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
1922 RLOGD("RadioImpl::nvWriteCdmaPrl: serial %d", serial);
1923 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
1924 return Void();
1925}
1926
1927Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
1928 RLOGD("RadioImpl::nvResetConfig: serial %d", serial);
1929 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, (int) resetType);
1930 return Void();
1931}
1932
1933Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
1934 RLOGD("RadioImpl::setUiccSubscription: serial %d", serial);
1935 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1936 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
1937 if (pRI == NULL) {
1938 return Void();
1939 }
1940
Jack Yuf68e0da2017-02-07 14:53:09 -08001941 RIL_SelectUiccSub rilUiccSub = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001942
1943 rilUiccSub.slot = uiccSub.slot;
1944 rilUiccSub.app_index = uiccSub.appIndex;
1945 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
1946 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
1947
1948 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI);
1949 return Void();
1950}
1951
1952Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
1953 RLOGD("RadioImpl::setDataAllowed: serial %d", serial);
1954 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
1955 return Void();
1956}
1957
1958Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
1959 RLOGD("RadioImpl::getHardwareConfig: serial %d", serial);
1960 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
1961 return Void();
1962}
1963
1964Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
1965 const hidl_string& authData, const hidl_string& aid) {
1966 RLOGD("RadioImpl::requestIccSimAuthentication: serial %d", serial);
1967 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
1968 if (pRI == NULL) {
1969 return Void();
1970 }
1971
1972 RIL_SimAuthentication pf;
1973 memset (&pf, 0, sizeof(pf));
1974
1975 pf.authContext = authContext;
1976
1977 int len;
1978 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
1979 return Void();
1980 }
1981
1982 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
1983 memsetAndFreeStrings(1, pf.authData);
1984 return Void();
1985 }
1986
1987 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI);
1988
1989 memsetAndFreeStrings(2, pf.authData, pf.aid);
1990 return Void();
1991}
1992
1993/**
Jack Yuffc06452017-02-13 11:21:00 -08001994 * @param numProfiles number of data profile
1995 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
1996 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
1997 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
1998 * @param numfields number of string-type member in the data profile structure
1999 * @param ... the variadic parameters are pointers to each string-type member
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002000 **/
Jack Yuffc06452017-02-13 11:21:00 -08002001template <typename T>
2002void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2003 int numfields, ...) {
2004 va_list args;
2005 va_start(args, numfields);
2006
2007 // Iterate through each string-type field that need to be free.
2008 for (int i = 0; i < numfields; i++) {
2009 // Iterate through each data profile and free that specific string-type field.
2010 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2011 char *T::*ptr = va_arg(args, char *T::*);
2012 for (int j = 0; j < numProfiles; j++) {
2013 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2014 }
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002015 }
2016
Jack Yuffc06452017-02-13 11:21:00 -08002017 va_end(args);
2018
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002019#ifdef MEMSET_FREED
Jack Yuffc06452017-02-13 11:21:00 -08002020 memset(dataProfiles, 0, numProfiles * sizeof(T));
2021 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002022#endif
2023 free(dataProfiles);
2024 free(dataProfilePtrs);
2025}
2026
Jack Yuffc06452017-02-13 11:21:00 -08002027Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2028 bool isRoaming) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002029 RLOGD("RadioImpl::setDataProfile: serial %d", serial);
2030 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2031 if (pRI == NULL) {
2032 return Void();
2033 }
2034
Jack Yuffc06452017-02-13 11:21:00 -08002035 size_t num = profiles.size();
2036 bool success = false;
2037
2038 if (s_vendorFunctions->version <= 14) {
2039
2040 RIL_DataProfileInfo *dataProfiles =
2041 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2042
2043 if (dataProfiles == NULL) {
2044 RLOGE("Memory allocation failed for request %s",
2045 requestToString(pRI->pCI->requestNumber));
2046 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2047 return Void();
2048 }
2049
2050 RIL_DataProfileInfo **dataProfilePtrs =
2051 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2052 if (dataProfilePtrs == NULL) {
2053 RLOGE("Memory allocation failed for request %s",
2054 requestToString(pRI->pCI->requestNumber));
2055 free(dataProfiles);
2056 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2057 return Void();
2058 }
2059
2060 for (size_t i = 0; i < num; i++) {
2061 dataProfilePtrs[i] = &dataProfiles[i];
2062
2063 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2064
2065 const hidl_string &protocol =
2066 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2067
2068 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2069 success = false;
2070 }
2071
2072 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2073 success = false;
2074 }
2075 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2076 pRI)) {
2077 success = false;
2078 }
2079
2080 if (!success) {
2081 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2082 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2083 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2084 return Void();
2085 }
2086
2087 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2088 dataProfiles[i].authType = (int) profiles[i].authType;
2089 dataProfiles[i].type = (int) profiles[i].type;
2090 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2091 dataProfiles[i].maxConns = profiles[i].maxConns;
2092 dataProfiles[i].waitTime = profiles[i].waitTime;
2093 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2094 }
2095
2096 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2097 num * sizeof(RIL_DataProfileInfo *), pRI);
2098
2099 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2100 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2101 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2102 } else {
2103 RIL_DataProfileInfo_v15 *dataProfiles =
2104 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2105
2106 if (dataProfiles == NULL) {
2107 RLOGE("Memory allocation failed for request %s",
2108 requestToString(pRI->pCI->requestNumber));
2109 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2110 return Void();
2111 }
2112
2113 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2114 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2115 if (dataProfilePtrs == NULL) {
2116 RLOGE("Memory allocation failed for request %s",
2117 requestToString(pRI->pCI->requestNumber));
2118 free(dataProfiles);
2119 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2120 return Void();
2121 }
2122
2123 for (size_t i = 0; i < num; i++) {
2124 dataProfilePtrs[i] = &dataProfiles[i];
2125
2126 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2127 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2128 pRI)) {
2129 success = false;
2130 }
2131 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2132 profiles[i].roamingProtocol, pRI)) {
2133 success = false;
2134 }
2135 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2136 success = false;
2137 }
2138 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2139 pRI)) {
2140 success = false;
2141 }
2142
2143 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2144 profiles[i].mvnoMatchData, pRI)) {
2145 success = false;
2146 }
2147
2148 if (success) {
2149 dataProfiles[i].mvnoType = (char *) convertMvnoTypeToString(profiles[i].mvnoType);
2150 if (dataProfiles[i].mvnoType == NULL) {
2151 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2152 success = false;
2153 }
2154 }
2155
2156 if (!success) {
2157 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2158 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2159 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2160 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2161 return Void();
2162 }
2163
2164 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2165 dataProfiles[i].authType = (int) profiles[i].authType;
2166 dataProfiles[i].type = (int) profiles[i].type;
2167 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2168 dataProfiles[i].maxConns = profiles[i].maxConns;
2169 dataProfiles[i].waitTime = profiles[i].waitTime;
2170 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2171 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2172 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2173 dataProfiles[i].mtu = profiles[i].mtu;
2174 }
2175
2176 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2177 num * sizeof(RIL_DataProfileInfo_v15 *), pRI);
2178
2179 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2180 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2181 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2182 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2183 }
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002184
2185 return Void();
2186}
2187
2188Return<void> RadioImpl::requestShutdown(int32_t serial) {
2189 RLOGD("RadioImpl::requestShutdown: serial %d", serial);
2190 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2191 return Void();
2192}
2193
2194Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2195 RLOGD("RadioImpl::getRadioCapability: serial %d", serial);
2196 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2197 return Void();
2198}
2199
2200Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2201 RLOGD("RadioImpl::setRadioCapability: serial %d", serial);
2202 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2203 if (pRI == NULL) {
2204 return Void();
2205 }
2206
2207 RIL_RadioCapability rilRc;
2208 memset (&rilRc, 0, sizeof(rilRc));
2209
2210 // TODO : set rilRc.version using HIDL version ?
2211 rilRc.session = rc.session;
2212 rilRc.phase = (int) rc.phase;
2213 rilRc.rat = (int) rc.raf;
2214 rilRc.status = (int) rc.status;
2215 strncpy(rilRc.logicalModemUuid, (const char *) rc.logicalModemUuid, MAX_UUID_LENGTH);
2216
2217 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI);
2218
2219 return Void();
2220}
2221
2222Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2223 RLOGD("RadioImpl::startLceService: serial %d", serial);
2224 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2225 BOOL_TO_INT(pullMode));
2226 return Void();
2227}
2228
2229Return<void> RadioImpl::stopLceService(int32_t serial) {
2230 RLOGD("RadioImpl::stopLceService: serial %d", serial);
2231 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2232 return Void();
2233}
2234
2235Return<void> RadioImpl::pullLceData(int32_t serial) {
2236 RLOGD("RadioImpl::pullLceData: serial %d", serial);
2237 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2238 return Void();
2239}
2240
2241Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2242 RLOGD("RadioImpl::getModemActivityInfo: serial %d", serial);
2243 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2244 return Void();
2245}
2246
2247Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2248 const CarrierRestrictions& carriers) {
2249 RLOGD("RadioImpl::setAllowedCarriers: serial %d", serial);
2250 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2251 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2252 if (pRI == NULL) {
2253 return Void();
2254 }
2255
Jack Yuf68e0da2017-02-07 14:53:09 -08002256 RIL_CarrierRestrictions cr = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002257 RIL_Carrier * allowedCarriers = NULL;
2258 RIL_Carrier * excludedCarriers = NULL;
2259
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002260 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2261 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2262 if (allowedCarriers == NULL) {
2263 RLOGE("RadioImpl::setAllowedCarriers: Memory allocation failed for request %s",
2264 requestToString(pRI->pCI->requestNumber));
Jack Yuffc06452017-02-13 11:21:00 -08002265 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002266 return Void();
2267 }
2268 cr.allowed_carriers = allowedCarriers;
2269
2270 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2271 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2272 if (excludedCarriers == NULL) {
2273 RLOGE("RadioImpl::setAllowedCarriers: Memory allocation failed for request %s",
2274 requestToString(pRI->pCI->requestNumber));
Jack Yuffc06452017-02-13 11:21:00 -08002275 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002276#ifdef MEMSET_FREED
2277 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2278#endif
2279 free(allowedCarriers);
2280 return Void();
2281 }
2282 cr.excluded_carriers = excludedCarriers;
2283
2284 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2285 allowedCarriers[i].mcc = (const char *) carriers.allowedCarriers[i].mcc;
2286 allowedCarriers[i].mnc = (const char *) carriers.allowedCarriers[i].mnc;
2287 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2288 allowedCarriers[i].match_data = (const char *) carriers.allowedCarriers[i].matchData;
2289 }
2290
2291 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2292 excludedCarriers[i].mcc = (const char *) carriers.excludedCarriers[i].mcc;
2293 excludedCarriers[i].mnc = (const char *) carriers.excludedCarriers[i].mnc;
2294 excludedCarriers[i].match_type =
2295 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2296 excludedCarriers[i].match_data = (const char *) carriers.excludedCarriers[i].matchData;
2297 }
2298
2299 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI);
2300
2301#ifdef MEMSET_FREED
2302 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2303 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2304#endif
2305 free(allowedCarriers);
2306 free(excludedCarriers);
2307 return Void();
2308}
2309
2310Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2311 RLOGD("RadioImpl::getAllowedCarriers: serial %d", serial);
2312 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2313 return Void();
2314}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002315
Wileen Chiu718c0bf2017-01-04 11:37:19 -08002316Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2317 RLOGD("RadioImpl::setSimCardPower: serial %d", serial);
2318 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2319 return Void();
2320}
2321
Jack Yu06181bb2017-01-10 12:10:41 -08002322Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state) {return Status::ok();}
2323
2324Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {return Status::ok();}
2325
Sanket Padawef220dc52017-01-02 23:46:00 -08002326Return<void> RadioImpl::responseAcknowledgement() {
2327 android::releaseWakeLock();
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002328 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -08002329}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002330
Amit Mahajan439da362017-02-13 17:43:04 -08002331Return<void> OemHookImpl::setResponseFunctions(
2332 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2333 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2334 RLOGD("OemHookImpl::setResponseFunctions");
2335
2336 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2337 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2338 assert(ret == 0);
2339
2340 mOemHookResponse = oemHookResponseParam;
2341 mOemHookIndication = oemHookIndicationParam;
2342 mCounter[mSlotId]++;
2343
2344 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2345 assert(ret == 0);
2346
2347 return Void();
2348}
2349
2350Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2351 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2352 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2353 return Void();
2354}
2355
2356Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2357 const hidl_vec<hidl_string>& data) {
2358 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2359 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2360 return Void();
2361}
2362
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002363/***************************************************************************************************
2364 * RESPONSE FUNCTIONS
2365 * Functions above are used for requests going from framework to vendor code. The ones below are
2366 * responses for those requests coming back from the vendor code.
2367 **************************************************************************************************/
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002368
Sanket Padawef220dc52017-01-02 23:46:00 -08002369void radio::acknowledgeRequest(int slotId, int serial) {
2370 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan17249842017-01-19 15:05:45 -08002371 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2372 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002373 } else {
Amit Mahajan5829a472016-12-28 17:28:07 -08002374 RLOGE("radio::acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawef220dc52017-01-02 23:46:00 -08002375 }
2376}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002377
Sanket Padawef220dc52017-01-02 23:46:00 -08002378void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002379 RIL_Errno e) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002380 responseInfo.serial = serial;
2381 switch (responseType) {
2382 case RESPONSE_SOLICITED:
2383 responseInfo.type = RadioResponseType::SOLICITED;
2384 break;
2385 case RESPONSE_SOLICITED_ACK_EXP:
2386 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2387 break;
2388 }
2389 responseInfo.error = (RadioError) e;
2390}
2391
2392int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002393 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002394 populateResponseInfo(responseInfo, serial, responseType, e);
2395 int ret = -1;
2396
2397 if (response == NULL || responseLen != sizeof(int)) {
2398 RLOGE("responseInt: Invalid response");
2399 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2400 } else {
2401 int *p_int = (int *) response;
2402 ret = p_int[0];
2403 }
2404 return ret;
2405}
2406
2407int radio::getIccCardStatusResponse(android::Parcel &p, int slotId, int requestNumber,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002408 int responseType, int serial, RIL_Errno e,
2409 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002410 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002411 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002412 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08002413 CardStatus cardStatus = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002414 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2415 RLOGE("radio::getIccCardStatusResponse: Invalid response");
2416 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002417 } else {
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002418 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2419 cardStatus.cardState = (CardState) p_cur->card_state;
2420 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2421 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2422 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2423 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2424
2425 RIL_AppStatus *rilAppStatus = p_cur->applications;
2426 cardStatus.applications.resize(p_cur->num_applications);
2427 AppStatus *appStatus = cardStatus.applications.data();
Sanket Padawef220dc52017-01-02 23:46:00 -08002428 RLOGD("radio::getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002429 for (int i = 0; i < p_cur->num_applications; i++) {
2430 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2431 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2432 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2433 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2434 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2435 rilAppStatus[i].app_label_ptr);
2436 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2437 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2438 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2439 }
2440 }
2441
Amit Mahajan17249842017-01-19 15:05:45 -08002442 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2443 getIccCardStatusResponse(responseInfo, cardStatus);
2444 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002445 } else {
Sanket Padawef220dc52017-01-02 23:46:00 -08002446 RLOGE("radio::getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2447 }
2448
2449 return 0;
2450}
2451
2452int radio::supplyIccPinForAppResponse(android::Parcel &p, int slotId, int requestNumber,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002453 int responseType, int serial, RIL_Errno e,
2454 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002455 RLOGD("radio::supplyIccPinForAppResponse: serial %d", serial);
2456
2457 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002458 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002459 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002460 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2461 supplyIccPinForAppResponse(responseInfo, ret);
2462 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002463 } else {
2464 RLOGE("radio::supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2465 slotId);
2466 }
2467
2468 return 0;
2469}
2470
2471int radio::supplyIccPukForAppResponse(android::Parcel &p, int slotId, int requestNumber,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002472 int responseType, int serial, RIL_Errno e,
2473 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002474 RLOGD("radio::supplyIccPukForAppResponse: serial %d", serial);
2475
2476 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002477 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002478 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002479 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2480 responseInfo, ret);
Amit Mahajan17249842017-01-19 15:05:45 -08002481 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002482 } else {
2483 RLOGE("radio::supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2484 slotId);
2485 }
2486
2487 return 0;
2488}
2489
2490int radio::supplyIccPin2ForAppResponse(android::Parcel &p, int slotId, int requestNumber,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002491 int responseType, int serial, RIL_Errno e,
2492 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002493 RLOGD("radio::supplyIccPin2ForAppResponse: serial %d", serial);
2494
2495 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002496 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002497 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002498 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2499 supplyIccPin2ForAppResponse(responseInfo, ret);
2500 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002501 } else {
2502 RLOGE("radio::supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2503 slotId);
2504 }
2505
2506 return 0;
2507}
2508
2509int radio::supplyIccPuk2ForAppResponse(android::Parcel &p, int slotId, int requestNumber,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002510 int responseType, int serial, RIL_Errno e,
2511 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002512 RLOGD("radio::supplyIccPuk2ForAppResponse: serial %d", serial);
2513
2514 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002515 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002516 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002517 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2518 supplyIccPuk2ForAppResponse(responseInfo, ret);
2519 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002520 } else {
2521 RLOGE("radio::supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2522 slotId);
2523 }
2524
2525 return 0;
2526}
2527
2528int radio::changeIccPinForAppResponse(android::Parcel &p, int slotId, int requestNumber,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002529 int responseType, int serial, RIL_Errno e,
2530 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002531 RLOGD("radio::changeIccPinForAppResponse: serial %d", serial);
2532
2533 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002534 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002535 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002536 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2537 changeIccPinForAppResponse(responseInfo, ret);
2538 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002539 } else {
2540 RLOGE("radio::changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2541 slotId);
2542 }
2543
2544 return 0;
2545}
2546
2547int radio::changeIccPin2ForAppResponse(android::Parcel &p, int slotId, int requestNumber,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002548 int responseType, int serial, RIL_Errno e,
2549 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002550 RLOGD("radio::changeIccPin2ForAppResponse: serial %d", serial);
2551
2552 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002553 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002554 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002555 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2556 changeIccPin2ForAppResponse(responseInfo, ret);
2557 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002558 } else {
2559 RLOGE("radio::changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2560 slotId);
2561 }
2562
2563 return 0;
2564}
2565
2566int radio::supplyNetworkDepersonalizationResponse(android::Parcel &p, int slotId, int requestNumber,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002567 int responseType, int serial, RIL_Errno e,
2568 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002569 RLOGD("radio::supplyNetworkDepersonalizationResponse: serial %d", serial);
2570
2571 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002572 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002573 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002574 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2575 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2576 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002577 } else {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002578 RLOGE("radio::supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
2579 "NULL", slotId);
Sanket Padawef220dc52017-01-02 23:46:00 -08002580 }
2581
2582 return 0;
2583}
2584
2585int radio::getCurrentCallsResponse(android::Parcel &p, int slotId, int requestNumber,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002586 int responseType, int serial, RIL_Errno e,
2587 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002588 RLOGD("radio::getCurrentCallsResponse: serial %d", serial);
2589
2590 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002591 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002592 populateResponseInfo(responseInfo, serial, responseType, e);
2593
2594 hidl_vec<Call> calls;
2595 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) {
2596 RLOGE("radio::getCurrentCallsResponse: Invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08002597 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Sanket Padawef220dc52017-01-02 23:46:00 -08002598 } else {
2599 int num = responseLen / sizeof(RIL_Call *);
2600 calls.resize(num);
2601
2602 for (int i = 0 ; i < num ; i++) {
2603 RIL_Call *p_cur = ((RIL_Call **) response)[i];
2604 /* each call info */
2605 calls[i].state = (CallState) p_cur->state;
2606 calls[i].index = p_cur->index;
2607 calls[i].toa = p_cur->toa;
2608 calls[i].isMpty = p_cur->isMpty;
2609 calls[i].isMT = p_cur->isMT;
2610 calls[i].als = p_cur->als;
2611 calls[i].isVoice = p_cur->isVoice;
2612 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
2613 calls[i].number = convertCharPtrToHidlString(p_cur->number);
2614 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
2615 calls[i].name = convertCharPtrToHidlString(p_cur->name);
2616 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002617 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002618 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
2619 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
2620 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
2621 // convert uusInfo->uusData to a null-terminated string
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002622 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
2623 calls[i].uusInfo[0].uusData = nullTermStr;
2624 free(nullTermStr);
Sanket Padawef220dc52017-01-02 23:46:00 -08002625 }
2626 }
2627 }
2628
Amit Mahajan17249842017-01-19 15:05:45 -08002629 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2630 getCurrentCallsResponse(responseInfo, calls);
2631 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002632 } else {
Amit Mahajan5829a472016-12-28 17:28:07 -08002633 RLOGE("radio::getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawef220dc52017-01-02 23:46:00 -08002634 }
2635
2636 return 0;
2637}
2638
2639int radio::dialResponse(android::Parcel &p, int slotId, int requestNumber,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002640 int responseType, int serial, RIL_Errno e, void *response,
2641 size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002642 RLOGD("radio::dialResponse: serial %d", serial);
2643
2644 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002645 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002646 populateResponseInfo(responseInfo, serial, responseType, e);
Amit Mahajan17249842017-01-19 15:05:45 -08002647 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
2648 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002649 } else {
2650 RLOGE("radio::dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002651 }
2652
2653 return 0;
2654}
2655
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002656int radio::getIMSIForAppResponse(android::Parcel &p, int slotId, int requestNumber,
2657 int responseType, int serial, RIL_Errno e, void *response,
2658 size_t responseLen) {
2659 RLOGD("radio::getIMSIForAppResponse: serial %d", serial);
2660
2661 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002662 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002663 populateResponseInfo(responseInfo, serial, responseType, e);
2664 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
2665 responseInfo, convertCharPtrToHidlString((char *) response));
2666 radioService[slotId]->checkReturnStatus(retStatus);
2667 } else {
2668 RLOGE("radio::getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
2669 slotId);
2670 }
2671
2672 return 0;
2673}
2674
2675int radio::hangupConnectionResponse(android::Parcel &p, int slotId, int requestNumber,
2676 int responseType, int serial, RIL_Errno e,
2677 void *response, size_t responseLen) {
2678 RLOGD("radio::hangupConnectionResponse: serial %d", serial);
2679
2680 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002681 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002682 populateResponseInfo(responseInfo, serial, responseType, e);
2683 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
2684 responseInfo);
2685 radioService[slotId]->checkReturnStatus(retStatus);
2686 } else {
2687 RLOGE("radio::hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
2688 slotId);
2689 }
2690
2691 return 0;
2692}
2693
2694int radio::hangupWaitingOrBackgroundResponse(android::Parcel &p, int slotId, int requestNumber,
2695 int responseType, int serial, RIL_Errno e,
2696 void *response, size_t responseLen) {
2697 RLOGD("radio::hangupWaitingOrBackgroundResponse: serial %d", serial);
2698
2699 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002700 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002701 populateResponseInfo(responseInfo, serial, responseType, e);
2702 Return<void> retStatus =
2703 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
2704 responseInfo);
2705 radioService[slotId]->checkReturnStatus(retStatus);
2706 } else {
2707 RLOGE("radio::hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
2708 slotId);
2709 }
2710
2711 return 0;
2712}
2713
2714int radio::hangupForegroundResumeBackgroundResponse(android::Parcel &p, int slotId,
2715 int requestNumber,
2716 int responseType, int serial, RIL_Errno e,
2717 void *response, size_t responseLen) {
2718 RLOGD("radio::hangupWaitingOrBackgroundResponse: serial %d", serial);
2719
2720 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002721 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002722 populateResponseInfo(responseInfo, serial, responseType, e);
2723 Return<void> retStatus =
2724 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
2725 responseInfo);
2726 radioService[slotId]->checkReturnStatus(retStatus);
2727 } else {
2728 RLOGE("radio::hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
2729 slotId);
2730 }
2731
2732 return 0;
2733}
2734
2735int radio::switchWaitingOrHoldingAndActiveResponse(android::Parcel &p, int slotId,
2736 int requestNumber,
2737 int responseType, int serial, RIL_Errno e,
2738 void *response, size_t responseLen) {
2739 RLOGD("radio::switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
2740
2741 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002742 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002743 populateResponseInfo(responseInfo, serial, responseType, e);
2744 Return<void> retStatus =
2745 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
2746 responseInfo);
2747 radioService[slotId]->checkReturnStatus(retStatus);
2748 } else {
2749 RLOGE("radio::switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
2750 "== NULL", slotId);
2751 }
2752
2753 return 0;
2754}
2755
2756int radio::conferenceResponse(android::Parcel &p, int slotId, int requestNumber, int responseType,
2757 int serial, RIL_Errno e, void *response, size_t responseLen) {
2758 RLOGD("radio::conferenceResponse: serial %d", serial);
2759
2760 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002761 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002762 populateResponseInfo(responseInfo, serial, responseType, e);
2763 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
2764 responseInfo);
2765 radioService[slotId]->checkReturnStatus(retStatus);
2766 } else {
2767 RLOGE("radio::conferenceResponse: radioService[%d]->mRadioResponse == NULL",
2768 slotId);
2769 }
2770
2771 return 0;
2772}
2773
2774int radio::rejectCallResponse(android::Parcel &p, int slotId, int requestNumber, int responseType,
2775 int serial, RIL_Errno e, void *response, size_t responseLen) {
2776 RLOGD("radio::rejectCallResponse: serial %d", serial);
2777
2778 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002779 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002780 populateResponseInfo(responseInfo, serial, responseType, e);
2781 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
2782 responseInfo);
2783 radioService[slotId]->checkReturnStatus(retStatus);
2784 } else {
2785 RLOGE("radio::rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
2786 slotId);
2787 }
2788
2789 return 0;
2790}
2791
2792int radio::getLastCallFailCauseResponse(android::Parcel &p, int slotId, int requestNumber,
2793 int responseType, int serial, RIL_Errno e, void *response,
2794 size_t responseLen) {
2795 RLOGD("radio::getLastCallFailCauseResponse: serial %d", serial);
2796
2797 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002798 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002799 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08002800
2801 LastCallFailCauseInfo info = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002802 info.vendorCause = hidl_string();
2803 if (response == NULL) {
2804 RLOGE("radio::getCurrentCallsResponse Invalid response: NULL");
2805 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2806 } else if (responseLen == sizeof(int)) {
2807 int *pInt = (int *) response;
2808 info.causeCode = (LastCallFailCause) pInt[0];
2809 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
2810 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
2811 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
2812 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
2813 } else {
2814 RLOGE("radio::getCurrentCallsResponse Invalid response: NULL");
2815 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2816 }
2817
2818 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
2819 responseInfo, info);
2820 radioService[slotId]->checkReturnStatus(retStatus);
2821 } else {
2822 RLOGE("radio::getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
2823 slotId);
2824 }
2825
2826 return 0;
2827}
2828
Amit Mahajan3df62912017-02-10 01:35:55 +00002829int radio::getSignalStrengthResponse(android::Parcel &p, int slotId, int requestNumber,
2830 int responseType, int serial, RIL_Errno e,
2831 void *response, size_t responseLen) {
2832 RLOGD("radio::getSignalStrengthResponse: serial %d", serial);
2833
2834 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08002835 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00002836 populateResponseInfo(responseInfo, serial, responseType, e);
Amit Mahajan3da9ac02017-02-13 13:41:28 -08002837 SignalStrength signalStrength = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00002838 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
2839 RLOGE("radio::getSignalStrengthResponse: Invalid response");
2840 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2841 } else {
2842 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
2843 }
2844
2845 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
2846 responseInfo, signalStrength);
2847 radioService[slotId]->checkReturnStatus(retStatus);
2848 } else {
2849 RLOGE("radio::getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
2850 slotId);
2851 }
2852
2853 return 0;
2854}
2855
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002856int radio::getVoiceRegistrationStateResponse(android::Parcel &p, int slotId, int requestNumber,
2857 int responseType, int serial, RIL_Errno e,
2858 void *response, size_t responseLen) {
2859 RLOGD("radio::getVoiceRegistrationStateResponse: serial %d", serial);
2860
2861 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002862 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002863 populateResponseInfo(responseInfo, serial, responseType, e);
2864
Jack Yuf68e0da2017-02-07 14:53:09 -08002865 VoiceRegStateResult voiceRegResponse = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002866
2867 int numStrings = responseLen / sizeof(char *);
2868
2869 if (response == NULL || numStrings != 15) {
2870 RLOGE("radio::getVoiceRegistrationStateResponse Invalid response: NULL");
2871 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2872 } else {
2873 char **resp = (char **) response;
2874 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
2875 voiceRegResponse.lac = ATOI_NULL_HANDLED(resp[1]);
2876 voiceRegResponse.cid = ATOI_NULL_HANDLED(resp[2]);
2877 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
2878 voiceRegResponse.baseStationId = ATOI_NULL_HANDLED(resp[4]);
2879 voiceRegResponse.baseStationLatitude = ATOI_NULL_HANDLED_DEF(resp[5], INT_MAX);
2880 voiceRegResponse.baseStationLongitude = ATOI_NULL_HANDLED_DEF(resp[6], INT_MAX);
2881 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
2882 voiceRegResponse.systemId = ATOI_NULL_HANDLED_DEF(resp[8], 0);
2883 voiceRegResponse.networkId = ATOI_NULL_HANDLED_DEF(resp[9], 0);
2884 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
2885 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
2886 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
2887 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
2888 voiceRegResponse.psc = ATOI_NULL_HANDLED(resp[14]);
2889 }
2890
2891 Return<void> retStatus =
2892 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
2893 responseInfo, voiceRegResponse);
2894 radioService[slotId]->checkReturnStatus(retStatus);
2895 } else {
2896 RLOGE("radio::getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
2897 slotId);
2898 }
2899
2900 return 0;
2901}
2902
2903int radio::getDataRegistrationStateResponse(android::Parcel &p, int slotId, int requestNumber,
2904 int responseType, int serial, RIL_Errno e,
2905 void *response, size_t responseLen) {
2906 RLOGD("radio::getDataRegistrationStateResponse: serial %d", serial);
2907
2908 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002909 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002910 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08002911 DataRegStateResult dataRegResponse = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002912 int numStrings = responseLen / sizeof(char *);
2913 if (response == NULL || (numStrings != 6 && numStrings != 11)) {
2914 RLOGE("radio::getDataRegistrationStateResponse Invalid response: NULL");
2915 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2916 } else {
2917 char **resp = (char **) response;
2918 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
2919 dataRegResponse.lac = ATOI_NULL_HANDLED(resp[1]);
2920 dataRegResponse.cid = ATOI_NULL_HANDLED(resp[2]);
2921 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
2922 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
2923 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
2924 if (numStrings == 11) {
2925 dataRegResponse.tac = ATOI_NULL_HANDLED(resp[6]);
2926 dataRegResponse.phyCid = ATOI_NULL_HANDLED(resp[7]);
2927 dataRegResponse.eci = ATOI_NULL_HANDLED(resp[8]);
2928 dataRegResponse.csgid = ATOI_NULL_HANDLED(resp[9]);
2929 dataRegResponse.tadv = ATOI_NULL_HANDLED(resp[10]);
2930 }
2931 }
2932
2933 Return<void> retStatus =
2934 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
2935 dataRegResponse);
2936 radioService[slotId]->checkReturnStatus(retStatus);
2937 } else {
2938 RLOGE("radio::getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
2939 slotId);
2940 }
2941
2942 return 0;
2943}
2944
2945int radio::getOperatorResponse(android::Parcel &p, int slotId, int requestNumber,
2946 int responseType, int serial, RIL_Errno e, void *response,
2947 size_t responseLen) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002948 RLOGD("radio::getOperatorResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002949
2950 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002951 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002952 populateResponseInfo(responseInfo, serial, responseType, e);
2953 hidl_string longName;
2954 hidl_string shortName;
2955 hidl_string numeric;
2956 int numStrings = responseLen / sizeof(char *);
2957 if (response == NULL || numStrings != 3) {
2958 RLOGE("radio::getOperatorResponse Invalid response: NULL");
2959 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2960
2961 } else {
2962 char **resp = (char **) response;
2963 longName = convertCharPtrToHidlString(resp[0]);
2964 shortName = convertCharPtrToHidlString(resp[1]);
2965 numeric = convertCharPtrToHidlString(resp[2]);
2966 }
2967 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
2968 responseInfo, longName, shortName, numeric);
2969 radioService[slotId]->checkReturnStatus(retStatus);
2970 } else {
2971 RLOGE("radio::getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
2972 slotId);
2973 }
2974
2975 return 0;
2976}
2977
2978int radio::setRadioPowerResponse(android::Parcel &p, int slotId, int requestNumber,
2979 int responseType, int serial, RIL_Errno e, void *response,
2980 size_t responseLen) {
2981 RLOGD("radio::setRadioPowerResponse: serial %d", serial);
2982
2983 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002984 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002985 populateResponseInfo(responseInfo, serial, responseType, e);
2986 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
2987 responseInfo);
2988 radioService[slotId]->checkReturnStatus(retStatus);
2989 } else {
2990 RLOGE("radio::setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
2991 slotId);
2992 }
2993
2994 return 0;
2995}
2996
2997int radio::sendDtmfResponse(android::Parcel &p, int slotId, int requestNumber,
2998 int responseType, int serial, RIL_Errno e, void *response,
2999 size_t responseLen) {
3000 RLOGD("radio::sendDtmfResponse: serial %d", serial);
3001
3002 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003003 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003004 populateResponseInfo(responseInfo, serial, responseType, e);
3005 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3006 responseInfo);
3007 radioService[slotId]->checkReturnStatus(retStatus);
3008 } else {
3009 RLOGE("radio::sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3010 slotId);
3011 }
3012
3013 return 0;
3014}
3015
3016SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3017 RIL_Errno e, void *response, size_t responseLen) {
3018 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08003019 SendSmsResult result = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003020
3021 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3022 RLOGE("Invalid response: NULL");
3023 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003024 result.ackPDU = hidl_string();
3025 } else {
3026 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3027 result.messageRef = resp->messageRef;
3028 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3029 result.errorCode = resp->errorCode;
3030 }
3031 return result;
3032}
3033
3034int radio::sendSmsResponse(android::Parcel &p, int slotId, int requestNumber,
3035 int responseType, int serial, RIL_Errno e, void *response,
3036 size_t responseLen) {
3037 RLOGD("radio::sendSmsResponse: serial %d", serial);
3038
3039 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003040 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003041 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3042 responseLen);
3043
3044 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3045 result);
3046 radioService[slotId]->checkReturnStatus(retStatus);
3047 } else {
3048 RLOGE("radio::sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3049 }
3050
3051 return 0;
3052}
3053
3054int radio::sendSMSExpectMoreResponse(android::Parcel &p, int slotId, int requestNumber,
3055 int responseType, int serial, RIL_Errno e, void *response,
3056 size_t responseLen) {
3057 RLOGD("radio::sendSMSExpectMoreResponse: serial %d", serial);
3058
3059 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003060 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003061 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3062 responseLen);
3063
3064 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3065 responseInfo, result);
3066 radioService[slotId]->checkReturnStatus(retStatus);
3067 } else {
3068 RLOGE("radio::sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3069 }
3070
3071 return 0;
3072}
3073
Amit Mahajan3df62912017-02-10 01:35:55 +00003074int radio::setupDataCallResponse(android::Parcel &p, int slotId, int requestNumber,
3075 int responseType, int serial, RIL_Errno e, void *response,
3076 size_t responseLen) {
3077 RLOGD("radio::setupDataCallResponse: serial %d", serial);
3078
3079 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08003080 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00003081 populateResponseInfo(responseInfo, serial, responseType, e);
3082
Amit Mahajan3da9ac02017-02-13 13:41:28 -08003083 SetupDataCallResult result = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00003084 if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) {
3085 RLOGE("radio::setupDataCallResponse: Invalid response");
3086 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Jack Yu5079e182017-02-28 15:21:18 -08003087 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
Amit Mahajan3da9ac02017-02-13 13:41:28 -08003088 result.type = hidl_string();
3089 result.ifname = hidl_string();
3090 result.addresses = hidl_string();
3091 result.dnses = hidl_string();
3092 result.gateways = hidl_string();
3093 result.pcscf = hidl_string();
Amit Mahajan3df62912017-02-10 01:35:55 +00003094 } else {
3095 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3096 }
3097
3098 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3099 responseInfo, result);
3100 radioService[slotId]->checkReturnStatus(retStatus);
3101 } else {
3102 RLOGE("radio::setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3103 }
3104
3105 return 0;
3106}
3107
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003108IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3109 RIL_Errno e, void *response, size_t responseLen) {
3110 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08003111 IccIoResult result = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003112
3113 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3114 RLOGE("Invalid response: NULL");
3115 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003116 result.simResponse = hidl_string();
3117 } else {
3118 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3119 result.sw1 = resp->sw1;
3120 result.sw2 = resp->sw2;
3121 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3122 }
3123 return result;
3124}
3125
3126int radio::iccIOForAppResponse(android::Parcel &p, int slotId, int requestNumber,
3127 int responseType, int serial, RIL_Errno e, void *response,
3128 size_t responseLen) {
3129 RLOGD("radio::radio::iccIOForAppResponse: serial %d", serial);
3130
3131 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003132 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003133 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3134 responseLen);
3135
3136 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3137 responseInfo, result);
3138 radioService[slotId]->checkReturnStatus(retStatus);
3139 } else {
3140 RLOGE("radio::iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3141 }
3142
3143 return 0;
3144}
3145
3146int radio::sendUssdResponse(android::Parcel &p, int slotId, int requestNumber,
3147 int responseType, int serial, RIL_Errno e, void *response,
3148 size_t responseLen) {
3149 RLOGD("radio::sendUssdResponse: serial %d", serial);
3150
3151 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003152 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003153 populateResponseInfo(responseInfo, serial, responseType, e);
3154 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3155 responseInfo);
3156 radioService[slotId]->checkReturnStatus(retStatus);
3157 } else {
3158 RLOGE("radio::sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3159 slotId);
3160 }
3161
3162 return 0;
3163}
3164
3165int radio::cancelPendingUssdResponse(android::Parcel &p, int slotId, int requestNumber,
3166 int responseType, int serial, RIL_Errno e, void *response,
3167 size_t responseLen) {
3168 RLOGD("radio::cancelPendingUssdResponse: serial %d", serial);
3169
3170 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003171 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003172 populateResponseInfo(responseInfo, serial, responseType, e);
3173 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3174 responseInfo);
3175 radioService[slotId]->checkReturnStatus(retStatus);
3176 } else {
3177 RLOGE("radio::cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3178 slotId);
3179 }
3180
3181 return 0;
3182}
3183
3184int radio::getClirResponse(android::Parcel &p, int slotId, int requestNumber,
3185 int responseType, int serial, RIL_Errno e, void *response,
3186 size_t responseLen) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003187 RLOGD("radio::getClirResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003188
3189 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003190 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003191 populateResponseInfo(responseInfo, serial, responseType, e);
3192 int n = -1, m = -1;
3193 int numInts = responseLen / sizeof(int);
3194 if (response == NULL || numInts != 2) {
3195 RLOGE("radio::getClirResponse Invalid response: NULL");
3196 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3197 } else {
3198 int *pInt = (int *) response;
3199 n = pInt[0];
3200 m = pInt[1];
3201 }
3202 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3203 n, m);
3204 radioService[slotId]->checkReturnStatus(retStatus);
3205 } else {
3206 RLOGE("radio::getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3207 }
3208
3209 return 0;
3210}
3211
3212int radio::setClirResponse(android::Parcel &p, int slotId, int requestNumber,
3213 int responseType, int serial, RIL_Errno e, void *response,
3214 size_t responseLen) {
3215 RLOGD("radio::setClirResponse: serial %d", serial);
3216
3217 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003218 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003219 populateResponseInfo(responseInfo, serial, responseType, e);
3220 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
3221 responseInfo);
3222 radioService[slotId]->checkReturnStatus(retStatus);
3223 } else {
3224 RLOGE("radio::setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3225 }
3226
3227 return 0;
3228}
3229
3230int radio::getCallForwardStatusResponse(android::Parcel &p, int slotId, int requestNumber,
3231 int responseType, int serial, RIL_Errno e,
3232 void *response, size_t responseLen) {
3233 RLOGD("radio::getCallForwardStatusResponse: serial %d", serial);
3234
3235 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003236 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003237 populateResponseInfo(responseInfo, serial, responseType, e);
3238 hidl_vec<CallForwardInfo> callForwardInfos;
3239
3240 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
3241 RLOGE("radio::getCallForwardStatusResponse Invalid response: NULL");
3242 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3243 } else {
3244 int num = responseLen / sizeof(RIL_CallForwardInfo *);
3245 callForwardInfos.resize(num);
3246 for (int i = 0 ; i < num; i++) {
3247 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
3248 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
3249 callForwardInfos[i].reason = resp->reason;
3250 callForwardInfos[i].serviceClass = resp->serviceClass;
3251 callForwardInfos[i].toa = resp->toa;
3252 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
3253 callForwardInfos[i].timeSeconds = resp->timeSeconds;
3254 }
3255 }
3256
3257 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
3258 responseInfo, callForwardInfos);
3259 radioService[slotId]->checkReturnStatus(retStatus);
3260 } else {
3261 RLOGE("radio::getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
3262 slotId);
3263 }
3264
3265 return 0;
3266}
3267
3268int radio::setCallForwardResponse(android::Parcel &p, int slotId, int requestNumber,
3269 int responseType, int serial, RIL_Errno e, void *response,
3270 size_t responseLen) {
3271 RLOGD("radio::setCallForwardResponse: serial %d", serial);
3272
3273 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003274 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003275 populateResponseInfo(responseInfo, serial, responseType, e);
3276 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
3277 responseInfo);
3278 radioService[slotId]->checkReturnStatus(retStatus);
3279 } else {
3280 RLOGE("radio::setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3281 }
3282
3283 return 0;
3284}
3285
3286int radio::getCallWaitingResponse(android::Parcel &p, int slotId, int requestNumber,
3287 int responseType, int serial, RIL_Errno e, void *response,
3288 size_t responseLen) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003289 RLOGD("radio::getCallWaitingResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003290
3291 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003292 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003293 populateResponseInfo(responseInfo, serial, responseType, e);
3294 bool enable = false;
3295 int serviceClass = -1;
3296 int numInts = responseLen / sizeof(int);
3297 if (response == NULL || numInts != 2) {
3298 RLOGE("radio::getCallWaitingResponse Invalid response: NULL");
3299 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3300 } else {
3301 int *pInt = (int *) response;
3302 enable = pInt[0] == 1 ? true : false;
3303 serviceClass = pInt[1];
3304 }
3305 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3306 enable, serviceClass);
3307 radioService[slotId]->checkReturnStatus(retStatus);
3308 } else {
3309 RLOGE("radio::getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3310 }
3311
3312 return 0;
3313}
3314
3315int radio::setCallWaitingResponse(android::Parcel &p, int slotId, int requestNumber,
3316 int responseType, int serial, RIL_Errno e, void *response,
3317 size_t responseLen) {
3318 RLOGD("radio::setCallWaitingResponse: serial %d", serial);
3319
3320 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003321 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003322 populateResponseInfo(responseInfo, serial, responseType, e);
3323 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
3324 responseInfo);
3325 radioService[slotId]->checkReturnStatus(retStatus);
3326 } else {
3327 RLOGE("radio::setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3328 }
3329
3330 return 0;
3331}
3332
3333int radio::acknowledgeLastIncomingGsmSmsResponse(android::Parcel &p, int slotId, int requestNumber,
3334 int responseType, int serial, RIL_Errno e,
3335 void *response, size_t responseLen) {
3336 RLOGD("radio::acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
3337
3338 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003339 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003340 populateResponseInfo(responseInfo, serial, responseType, e);
3341 Return<void> retStatus =
3342 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
3343 responseInfo);
3344 radioService[slotId]->checkReturnStatus(retStatus);
3345 } else {
3346 RLOGE("radio::acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
3347 "== NULL", slotId);
3348 }
3349
3350 return 0;
3351}
3352
3353int radio::acceptCallResponse(android::Parcel &p, int slotId, int requestNumber,
3354 int responseType, int serial, RIL_Errno e,
3355 void *response, size_t responseLen) {
3356 RLOGD("radio::acceptCallResponse: serial %d", serial);
3357
3358 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003359 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003360 populateResponseInfo(responseInfo, serial, responseType, e);
3361 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
3362 responseInfo);
3363 radioService[slotId]->checkReturnStatus(retStatus);
3364 } else {
3365 RLOGE("radio::acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
3366 slotId);
3367 }
3368
3369 return 0;
3370}
3371
3372int radio::deactivateDataCallResponse(android::Parcel &p, int slotId, int requestNumber,
3373 int responseType, int serial, RIL_Errno e,
3374 void *response, size_t responseLen) {
3375 RLOGD("radio::deactivateDataCallResponse: serial %d", serial);
3376
3377 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003378 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003379 populateResponseInfo(responseInfo, serial, responseType, e);
3380 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
3381 responseInfo);
3382 radioService[slotId]->checkReturnStatus(retStatus);
3383 } else {
3384 RLOGE("radio::deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
3385 slotId);
3386 }
3387
3388 return 0;
3389}
3390
3391int radio::getFacilityLockForAppResponse(android::Parcel &p, int slotId, int requestNumber,
3392 int responseType, int serial, RIL_Errno e,
3393 void *response, size_t responseLen) {
3394 RLOGD("radio::getFacilityLockForAppResponse: serial %d", serial);
3395
3396 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003397 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003398 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
3399 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3400 getFacilityLockForAppResponse(responseInfo, ret);
3401 radioService[slotId]->checkReturnStatus(retStatus);
3402 } else {
3403 RLOGE("radio::getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
3404 slotId);
3405 }
3406
3407 return 0;
3408}
3409
3410int radio::setFacilityLockForAppResponse(android::Parcel &p, int slotId, int requestNumber,
3411 int responseType, int serial, RIL_Errno e,
3412 void *response, size_t responseLen) {
3413 RLOGD("radio::setFacilityLockForAppResponse: serial %d", serial);
3414
3415 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003416 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003417 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
3418 Return<void> retStatus
3419 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
3420 ret);
3421 radioService[slotId]->checkReturnStatus(retStatus);
3422 } else {
3423 RLOGE("radio::setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
3424 slotId);
3425 }
3426
3427 return 0;
3428}
3429
3430int radio::setBarringPasswordResponse(android::Parcel &p, int slotId, int requestNumber,
3431 int responseType, int serial, RIL_Errno e,
3432 void *response, size_t responseLen) {
3433 RLOGD("radio::acceptCallResponse: serial %d", serial);
3434
3435 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003436 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003437 populateResponseInfo(responseInfo, serial, responseType, e);
3438 Return<void> retStatus
3439 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
3440 radioService[slotId]->checkReturnStatus(retStatus);
3441 } else {
3442 RLOGE("radio::setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
3443 slotId);
3444 }
3445
3446 return 0;
3447}
3448
3449int radio::getNetworkSelectionModeResponse(android::Parcel &p, int slotId, int requestNumber,
3450 int responseType, int serial, RIL_Errno e, void *response,
3451 size_t responseLen) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003452 RLOGD("radio::getNetworkSelectionModeResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003453
3454 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003455 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003456 populateResponseInfo(responseInfo, serial, responseType, e);
3457 bool manual = false;
3458 int serviceClass;
3459 if (response == NULL || responseLen != sizeof(int)) {
3460 RLOGE("radio::getNetworkSelectionModeResponse Invalid response: NULL");
3461 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3462 } else {
3463 int *pInt = (int *) response;
3464 manual = pInt[0] == 1 ? true : false;
3465 }
3466 Return<void> retStatus
3467 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
3468 responseInfo,
3469 manual);
3470 radioService[slotId]->checkReturnStatus(retStatus);
3471 } else {
3472 RLOGE("radio::getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
3473 slotId);
3474 }
3475
3476 return 0;
3477}
3478
3479int radio::setNetworkSelectionModeAutomaticResponse(android::Parcel &p, int slotId,
3480 int requestNumber,
3481 int responseType, int serial, RIL_Errno e,
3482 void *response, size_t responseLen) {
3483 RLOGD("radio::setNetworkSelectionModeAutomaticResponse: serial %d", serial);
3484
3485 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003486 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003487 populateResponseInfo(responseInfo, serial, responseType, e);
3488 Return<void> retStatus
3489 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
3490 responseInfo);
3491 radioService[slotId]->checkReturnStatus(retStatus);
3492 } else {
3493 RLOGE("radio::setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
3494 "== NULL", slotId);
3495 }
3496
3497 return 0;
3498}
3499
3500int radio::setNetworkSelectionModeManualResponse(android::Parcel &p, int slotId, int requestNumber,
3501 int responseType, int serial, RIL_Errno e,
3502 void *response, size_t responseLen) {
3503 RLOGD("radio::setNetworkSelectionModeManualResponse: serial %d", serial);
3504
3505 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003506 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003507 populateResponseInfo(responseInfo, serial, responseType, e);
3508 Return<void> retStatus
3509 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
3510 responseInfo);
3511 radioService[slotId]->checkReturnStatus(retStatus);
3512 } else {
3513 RLOGE("radio::acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
3514 "== NULL", slotId);
3515 }
3516
3517 return 0;
3518}
3519
Jack Yuf68e0da2017-02-07 14:53:09 -08003520int convertOperatorStatusToInt(const char *str) {
3521 if (strncmp("unknown", str, 9) == 0) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003522 return (int) OperatorStatus::UNKNOWN;
Jack Yuf68e0da2017-02-07 14:53:09 -08003523 } else if (strncmp("available", str, 9) == 0) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003524 return (int) OperatorStatus::AVAILABLE;
Jack Yuf68e0da2017-02-07 14:53:09 -08003525 } else if (strncmp("current", str, 9) == 0) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003526 return (int) OperatorStatus::CURRENT;
Jack Yuf68e0da2017-02-07 14:53:09 -08003527 } else if (strncmp("forbidden", str, 9) == 0) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003528 return (int) OperatorStatus::FORBIDDEN;
3529 } else {
3530 return -1;
3531 }
3532}
3533
3534int radio::getAvailableNetworksResponse(android::Parcel &p, int slotId, int requestNumber,
3535 int responseType, int serial, RIL_Errno e, void *response,
3536 size_t responseLen) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003537 RLOGD("radio::getAvailableNetworksResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003538
3539 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003540 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003541 populateResponseInfo(responseInfo, serial, responseType, e);
3542 hidl_vec<OperatorInfo> networks;
3543 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) {
3544 RLOGE("radio::getAvailableNetworksResponse Invalid response: NULL");
3545 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3546 } else {
3547 char **resp = (char **) response;
3548 int numStrings = responseLen / sizeof(char *);
3549 networks.resize(numStrings/4);
3550 for (int i = 0; i < numStrings; i = i + 4) {
3551 networks[i].alphaLong = convertCharPtrToHidlString(resp[i]);
3552 networks[i].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
3553 networks[i].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
3554 int status = convertOperatorStatusToInt(resp[i + 3]);
3555 if (status == -1) {
3556 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3557 } else {
3558 networks[i].status = (OperatorStatus) status;
3559 }
3560 }
3561 }
3562 Return<void> retStatus
3563 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
3564 networks);
3565 radioService[slotId]->checkReturnStatus(retStatus);
3566 } else {
3567 RLOGE("radio::getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
3568 slotId);
3569 }
3570
3571 return 0;
3572}
3573
3574int radio::startDtmfResponse(android::Parcel &p, int slotId, int requestNumber,
3575 int responseType, int serial, RIL_Errno e,
3576 void *response, size_t responseLen) {
3577 RLOGD("radio::startDtmfResponse: serial %d", serial);
3578
3579 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003580 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003581 populateResponseInfo(responseInfo, serial, responseType, e);
3582 Return<void> retStatus
3583 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
3584 radioService[slotId]->checkReturnStatus(retStatus);
3585 } else {
3586 RLOGE("radio::startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3587 }
3588
3589 return 0;
3590}
3591
3592int radio::stopDtmfResponse(android::Parcel &p, int slotId, int requestNumber,
3593 int responseType, int serial, RIL_Errno e,
3594 void *response, size_t responseLen) {
3595 RLOGD("radio::stopDtmfResponse: serial %d", serial);
3596
3597 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003598 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003599 populateResponseInfo(responseInfo, serial, responseType, e);
3600 Return<void> retStatus
3601 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
3602 radioService[slotId]->checkReturnStatus(retStatus);
3603 } else {
3604 RLOGE("radio::stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3605 }
3606
3607 return 0;
3608}
3609
3610int radio::getBasebandVersionResponse(android::Parcel &p, int slotId, int requestNumber,
3611 int responseType, int serial, RIL_Errno e,
3612 void *response, size_t responseLen) {
3613 RLOGD("radio::getBasebandVersionResponse: serial %d", serial);
3614
3615 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003616 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003617 populateResponseInfo(responseInfo, serial, responseType, e);
3618 Return<void> retStatus
3619 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
3620 convertCharPtrToHidlString((char *) response));
3621 radioService[slotId]->checkReturnStatus(retStatus);
3622 } else {
3623 RLOGE("radio::getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3624 }
3625
3626 return 0;
3627}
3628
3629int radio::separateConnectionResponse(android::Parcel &p, int slotId, int requestNumber,
3630 int responseType, int serial, RIL_Errno e,
3631 void *response, size_t responseLen) {
3632 RLOGD("radio::separateConnectionResponse: serial %d", serial);
3633
3634 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003635 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003636 populateResponseInfo(responseInfo, serial, responseType, e);
3637 Return<void> retStatus
3638 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
3639 radioService[slotId]->checkReturnStatus(retStatus);
3640 } else {
3641 RLOGE("radio::separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3642 slotId);
3643 }
3644
3645 return 0;
3646}
3647
3648int radio::setMuteResponse(android::Parcel &p, int slotId, int requestNumber,
3649 int responseType, int serial, RIL_Errno e,
3650 void *response, size_t responseLen) {
3651 RLOGD("radio::setMuteResponse: serial %d", serial);
3652
3653 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003654 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003655 populateResponseInfo(responseInfo, serial, responseType, e);
3656 Return<void> retStatus
3657 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
3658 radioService[slotId]->checkReturnStatus(retStatus);
3659 } else {
3660 RLOGE("radio::setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3661 }
3662
3663 return 0;
3664}
3665
3666int radio::getMuteResponse(android::Parcel &p, int slotId, int requestNumber,
3667 int responseType, int serial, RIL_Errno e, void *response,
3668 size_t responseLen) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003669 RLOGD("radio::getMuteResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003670
3671 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003672 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003673 populateResponseInfo(responseInfo, serial, responseType, e);
3674 bool enable = false;
3675 int serviceClass;
3676 if (response == NULL || responseLen != sizeof(int)) {
3677 RLOGE("radio::getMuteResponse Invalid response: NULL");
3678 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3679 } else {
3680 int *pInt = (int *) response;
3681 enable = pInt[0] == 1 ? true : false;
3682 }
3683 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
3684 enable);
3685 radioService[slotId]->checkReturnStatus(retStatus);
3686 } else {
3687 RLOGE("radio::getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3688 }
3689
3690 return 0;
3691}
3692
3693int radio::getClipResponse(android::Parcel &p, int slotId, int requestNumber,
3694 int responseType, int serial, RIL_Errno e,
3695 void *response, size_t responseLen) {
3696 RLOGD("radio::getClipResponse: serial %d", serial);
3697
3698 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003699 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003700 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
3701 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
3702 (ClipStatus) ret);
3703 radioService[slotId]->checkReturnStatus(retStatus);
3704 } else {
3705 RLOGE("radio::getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3706 }
3707
3708 return 0;
3709}
3710
Amit Mahajan3df62912017-02-10 01:35:55 +00003711int radio::getDataCallListResponse(android::Parcel &p, int slotId, int requestNumber,
3712 int responseType, int serial, RIL_Errno e,
3713 void *response, size_t responseLen) {
3714 RLOGD("radio::getDataCallListResponse: serial %d", serial);
3715
3716 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08003717 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00003718 populateResponseInfo(responseInfo, serial, responseType, e);
3719
3720 hidl_vec<SetupDataCallResult> ret;
3721 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
3722 RLOGE("radio::getDataCallListResponse: invalid response");
3723 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3724 } else {
3725 convertRilDataCallListToHal(response, responseLen, ret);
3726 }
3727
3728 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
3729 responseInfo, ret);
3730 radioService[slotId]->checkReturnStatus(retStatus);
3731 } else {
3732 RLOGE("radio::getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3733 }
3734
3735 return 0;
3736}
3737
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003738int radio::sendScreenStateResponse(android::Parcel &p, int slotId, int requestNumber,
3739 int responseType, int serial, RIL_Errno e,
3740 void *response, size_t responseLen) {
3741 RLOGD("radio::sendScreenStateResponse: serial %d", serial);
3742
3743 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003744 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003745 populateResponseInfo(responseInfo, serial, responseType, e);
3746 Return<void> retStatus
3747 = radioService[slotId]->mRadioResponse->sendScreenStateResponse(responseInfo);
3748 radioService[slotId]->checkReturnStatus(retStatus);
3749 } else {
3750 RLOGE("radio::sendScreenStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3751 }
3752
3753 return 0;
3754}
3755
3756int radio::setSuppServiceNotificationsResponse(android::Parcel &p, int slotId, int requestNumber,
3757 int responseType, int serial, RIL_Errno e,
3758 void *response, size_t responseLen) {
3759 RLOGD("radio::setSuppServiceNotificationsResponse: serial %d", serial);
3760
3761 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003762 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003763 populateResponseInfo(responseInfo, serial, responseType, e);
3764 Return<void> retStatus
3765 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
3766 responseInfo);
3767 radioService[slotId]->checkReturnStatus(retStatus);
3768 } else {
3769 RLOGE("radio::setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
3770 "== NULL", slotId);
3771 }
3772
3773 return 0;
3774}
3775
3776int radio::deleteSmsOnSimResponse(android::Parcel &p, int slotId, int requestNumber,
3777 int responseType, int serial, RIL_Errno e,
3778 void *response, size_t responseLen) {
3779 RLOGD("radio::deleteSmsOnSimResponse: serial %d", serial);
3780
3781 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003782 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003783 populateResponseInfo(responseInfo, serial, responseType, e);
3784 Return<void> retStatus
3785 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
3786 radioService[slotId]->checkReturnStatus(retStatus);
3787 } else {
3788 RLOGE("radio::deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3789 }
3790
3791 return 0;
3792}
3793
3794int radio::setBandModeResponse(android::Parcel &p, int slotId, int requestNumber,
3795 int responseType, int serial, RIL_Errno e,
3796 void *response, size_t responseLen) {
3797 RLOGD("radio::setBandModeResponse: serial %d", serial);
3798
3799 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003800 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003801 populateResponseInfo(responseInfo, serial, responseType, e);
3802 Return<void> retStatus
3803 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
3804 radioService[slotId]->checkReturnStatus(retStatus);
3805 } else {
3806 RLOGE("radio::setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3807 }
3808
3809 return 0;
3810}
3811
3812int radio::writeSmsToSimResponse(android::Parcel &p, int slotId, int requestNumber,
3813 int responseType, int serial, RIL_Errno e,
3814 void *response, size_t responseLen) {
3815 RLOGD("radio::writeSmsToSimResponse: serial %d", serial);
3816
3817 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003818 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003819 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
3820 Return<void> retStatus
3821 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
3822 radioService[slotId]->checkReturnStatus(retStatus);
3823 } else {
3824 RLOGE("radio::writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3825 }
3826
3827 return 0;
3828}
3829
3830int radio::getAvailableBandModesResponse(android::Parcel &p, int slotId, int requestNumber,
3831 int responseType, int serial, RIL_Errno e, void *response,
3832 size_t responseLen) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003833 RLOGD("radio::getAvailableBandModesResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003834
3835 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003836 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003837 populateResponseInfo(responseInfo, serial, responseType, e);
3838 hidl_vec<RadioBandMode> modes;
3839 if (response == NULL || responseLen % sizeof(int) != 0) {
3840 RLOGE("radio::getAvailableBandModesResponse Invalid response: NULL");
3841 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3842 } else {
3843 int *pInt = (int *) response;
3844 int numInts = responseLen / sizeof(int);
3845 modes.resize(numInts);
3846 for (int i = 0; i < numInts; i++) {
3847 modes[i] = (RadioBandMode) pInt[i];
3848 }
3849 }
3850 Return<void> retStatus
3851 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
3852 modes);
3853 radioService[slotId]->checkReturnStatus(retStatus);
3854 } else {
3855 RLOGE("radio::getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
3856 slotId);
3857 }
3858
3859 return 0;
3860}
3861
3862int radio::sendEnvelopeResponse(android::Parcel &p, int slotId, int requestNumber,
3863 int responseType, int serial, RIL_Errno e,
3864 void *response, size_t responseLen) {
3865 RLOGD("radio::sendEnvelopeResponse: serial %d", serial);
3866
3867 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003868 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003869 populateResponseInfo(responseInfo, serial, responseType, e);
3870 Return<void> retStatus
3871 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
3872 convertCharPtrToHidlString((char *) response));
3873 radioService[slotId]->checkReturnStatus(retStatus);
3874 } else {
3875 RLOGE("radio::sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3876 }
3877
3878 return 0;
3879}
3880
3881int radio::sendTerminalResponseToSimResponse(android::Parcel &p, int slotId, int requestNumber,
3882 int responseType, int serial, RIL_Errno e,
3883 void *response, size_t responseLen) {
3884 RLOGD("radio::sendTerminalResponseToSimResponse: serial %d", serial);
3885
3886 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003887 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003888 populateResponseInfo(responseInfo, serial, responseType, e);
3889 Return<void> retStatus
3890 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
3891 responseInfo);
3892 radioService[slotId]->checkReturnStatus(retStatus);
3893 } else {
3894 RLOGE("radio::sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
3895 slotId);
3896 }
3897
3898 return 0;
3899}
3900
3901int radio::handleStkCallSetupRequestFromSimResponse(android::Parcel &p, int slotId,
3902 int requestNumber, int responseType, int serial,
3903 RIL_Errno e, void *response,
3904 size_t responseLen) {
3905 RLOGD("radio::handleStkCallSetupRequestFromSimResponse: serial %d", serial);
3906
3907 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003908 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003909 populateResponseInfo(responseInfo, serial, responseType, e);
3910 Return<void> retStatus
3911 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
3912 responseInfo);
3913 radioService[slotId]->checkReturnStatus(retStatus);
3914 } else {
3915 RLOGE("radio::handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
3916 "== NULL", slotId);
3917 }
3918
3919 return 0;
3920}
3921
3922int radio::explicitCallTransferResponse(android::Parcel &p, int slotId, int requestNumber,
3923 int responseType, int serial, RIL_Errno e,
3924 void *response, size_t responseLen) {
3925 RLOGD("radio::explicitCallTransferResponse: serial %d", serial);
3926
3927 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003928 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003929 populateResponseInfo(responseInfo, serial, responseType, e);
3930 Return<void> retStatus
3931 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
3932 radioService[slotId]->checkReturnStatus(retStatus);
3933 } else {
3934 RLOGE("radio::explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
3935 slotId);
3936 }
3937
3938 return 0;
3939}
3940
3941int radio::setPreferredNetworkTypeResponse(android::Parcel &p, int slotId, int requestNumber,
3942 int responseType, int serial, RIL_Errno e,
3943 void *response, size_t responseLen) {
3944 RLOGD("radio::setPreferredNetworkTypeResponse: serial %d", serial);
3945
3946 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003947 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003948 populateResponseInfo(responseInfo, serial, responseType, e);
3949 Return<void> retStatus
3950 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
3951 responseInfo);
3952 radioService[slotId]->checkReturnStatus(retStatus);
3953 } else {
3954 RLOGE("radio::setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
3955 slotId);
3956 }
3957
3958 return 0;
3959}
3960
3961
3962int radio::getPreferredNetworkTypeResponse(android::Parcel &p, int slotId, int requestNumber,
3963 int responseType, int serial, RIL_Errno e,
3964 void *response, size_t responseLen) {
3965 RLOGD("radio::getPreferredNetworkTypeResponse: serial %d", serial);
3966
3967 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003968 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003969 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
3970 Return<void> retStatus
3971 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
3972 responseInfo, (PreferredNetworkType) ret);
3973 radioService[slotId]->checkReturnStatus(retStatus);
3974 } else {
3975 RLOGE("radio::getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
3976 slotId);
3977 }
3978
3979 return 0;
3980}
3981
3982int radio::getNeighboringCidsResponse(android::Parcel &p, int slotId, int requestNumber,
3983 int responseType, int serial, RIL_Errno e,
3984 void *response, size_t responseLen) {
3985 RLOGD("radio::getNeighboringCidsResponse: serial %d", serial);
3986
3987 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003988 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003989 populateResponseInfo(responseInfo, serial, responseType, e);
3990 hidl_vec<NeighboringCell> cells;
3991
3992 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
3993 RLOGE("radio::getNeighboringCidsResponse Invalid response: NULL");
3994 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3995 } else {
3996 int num = responseLen / sizeof(RIL_NeighboringCell *);
3997 cells.resize(num);
3998 for (int i = 0 ; i < num; i++) {
3999 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4000 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4001 cells[i].rssi = resp->rssi;
4002 }
4003 }
4004
4005 Return<void> retStatus
4006 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4007 cells);
4008 radioService[slotId]->checkReturnStatus(retStatus);
4009 } else {
4010 RLOGE("radio::getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4011 slotId);
4012 }
4013
4014 return 0;
4015}
4016
4017int radio::setLocationUpdatesResponse(android::Parcel &p, int slotId, int requestNumber,
4018 int responseType, int serial, RIL_Errno e,
4019 void *response, size_t responseLen) {
4020 RLOGD("radio::setLocationUpdatesResponse: serial %d", serial);
4021
4022 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004023 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004024 populateResponseInfo(responseInfo, serial, responseType, e);
4025 Return<void> retStatus
4026 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4027 radioService[slotId]->checkReturnStatus(retStatus);
4028 } else {
4029 RLOGE("radio::setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4030 slotId);
4031 }
4032
4033 return 0;
4034}
4035
4036int radio::setCdmaSubscriptionSourceResponse(android::Parcel &p, int slotId, int requestNumber,
4037 int responseType, int serial, RIL_Errno e,
4038 void *response, size_t responseLen) {
4039 RLOGD("radio::setCdmaSubscriptionSourceResponse: serial %d", serial);
4040
4041 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004042 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004043 populateResponseInfo(responseInfo, serial, responseType, e);
4044 Return<void> retStatus
4045 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4046 responseInfo);
4047 radioService[slotId]->checkReturnStatus(retStatus);
4048 } else {
4049 RLOGE("radio::setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4050 slotId);
4051 }
4052
4053 return 0;
4054}
4055
4056int radio::setCdmaRoamingPreferenceResponse(android::Parcel &p, int slotId, int requestNumber,
4057 int responseType, int serial, RIL_Errno e,
4058 void *response, size_t responseLen) {
4059 RLOGD("radio::setCdmaRoamingPreferenceResponse: serial %d", serial);
4060
4061 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004062 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004063 populateResponseInfo(responseInfo, serial, responseType, e);
4064 Return<void> retStatus
4065 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4066 responseInfo);
4067 radioService[slotId]->checkReturnStatus(retStatus);
4068 } else {
4069 RLOGE("radio::setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4070 slotId);
4071 }
4072
4073 return 0;
4074}
4075
4076int radio::getCdmaRoamingPreferenceResponse(android::Parcel &p, int slotId, int requestNumber,
4077 int responseType, int serial, RIL_Errno e,
4078 void *response, size_t responseLen) {
4079 RLOGD("radio::getCdmaRoamingPreferenceResponse: serial %d", serial);
4080
4081 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004082 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004083 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4084 Return<void> retStatus
4085 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4086 responseInfo, (CdmaRoamingType) ret);
4087 radioService[slotId]->checkReturnStatus(retStatus);
4088 } else {
4089 RLOGE("radio::getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4090 slotId);
4091 }
4092
4093 return 0;
4094}
4095
4096int radio::setTTYModeResponse(android::Parcel &p, int slotId, int requestNumber,
4097 int responseType, int serial, RIL_Errno e,
4098 void *response, size_t responseLen) {
4099 RLOGD("radio::setTTYModeResponse: serial %d", serial);
4100
4101 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004102 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004103 populateResponseInfo(responseInfo, serial, responseType, e);
4104 Return<void> retStatus
4105 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4106 radioService[slotId]->checkReturnStatus(retStatus);
4107 } else {
4108 RLOGE("radio::setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4109 }
4110
4111 return 0;
4112}
4113
4114int radio::getTTYModeResponse(android::Parcel &p, int slotId, int requestNumber,
4115 int responseType, int serial, RIL_Errno e,
4116 void *response, size_t responseLen) {
4117 RLOGD("radio::getTTYModeResponse: serial %d", serial);
4118
4119 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004120 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004121 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4122 Return<void> retStatus
4123 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4124 (TtyMode) ret);
4125 radioService[slotId]->checkReturnStatus(retStatus);
4126 } else {
4127 RLOGE("radio::getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4128 }
4129
4130 return 0;
4131}
4132
4133int radio::setPreferredVoicePrivacyResponse(android::Parcel &p, int slotId, int requestNumber,
4134 int responseType, int serial, RIL_Errno e,
4135 void *response, size_t responseLen) {
4136 RLOGD("radio::setPreferredVoicePrivacyResponse: serial %d", serial);
4137
4138 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004139 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004140 populateResponseInfo(responseInfo, serial, responseType, e);
4141 Return<void> retStatus
4142 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4143 responseInfo);
4144 radioService[slotId]->checkReturnStatus(retStatus);
4145 } else {
4146 RLOGE("radio::setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4147 slotId);
4148 }
4149
4150 return 0;
4151}
4152
4153int radio::getPreferredVoicePrivacyResponse(android::Parcel &p, int slotId, int requestNumber,
4154 int responseType, int serial, RIL_Errno e,
4155 void *response, size_t responseLen) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004156 RLOGD("radio::getPreferredVoicePrivacyResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004157
4158 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004159 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004160 populateResponseInfo(responseInfo, serial, responseType, e);
4161 bool enable = false;
4162 int numInts = responseLen / sizeof(int);
4163 if (response == NULL || numInts != 1) {
4164 RLOGE("radio::getPreferredVoicePrivacyResponse Invalid response: NULL");
4165 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4166 } else {
4167 int *pInt = (int *) response;
4168 enable = pInt[0] == 1 ? true : false;
4169 }
4170 Return<void> retStatus
4171 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
4172 responseInfo, enable);
4173 radioService[slotId]->checkReturnStatus(retStatus);
4174 } else {
4175 RLOGE("radio::getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4176 slotId);
4177 }
4178
4179 return 0;
4180}
4181
4182int radio::sendCDMAFeatureCodeResponse(android::Parcel &p, int slotId, int requestNumber,
4183 int responseType, int serial, RIL_Errno e,
4184 void *response, size_t responseLen) {
4185 RLOGD("radio::sendCDMAFeatureCodeResponse: serial %d", serial);
4186
4187 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004188 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004189 populateResponseInfo(responseInfo, serial, responseType, e);
4190 Return<void> retStatus
4191 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
4192 radioService[slotId]->checkReturnStatus(retStatus);
4193 } else {
4194 RLOGE("radio::sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
4195 slotId);
4196 }
4197
4198 return 0;
4199}
4200
4201int radio::sendBurstDtmfResponse(android::Parcel &p, int slotId, int requestNumber,
4202 int responseType, int serial, RIL_Errno e,
4203 void *response, size_t responseLen) {
4204 RLOGD("radio::sendBurstDtmfResponse: serial %d", serial);
4205
4206 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004207 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004208 populateResponseInfo(responseInfo, serial, responseType, e);
4209 Return<void> retStatus
4210 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
4211 radioService[slotId]->checkReturnStatus(retStatus);
4212 } else {
4213 RLOGE("radio::sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4214 }
4215
4216 return 0;
4217}
4218
4219int radio::sendCdmaSmsResponse(android::Parcel &p, int slotId, int requestNumber,
4220 int responseType, int serial, RIL_Errno e, void *response,
4221 size_t responseLen) {
4222 RLOGD("radio::sendCdmaSmsResponse: serial %d", serial);
4223
4224 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004225 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004226 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4227 responseLen);
4228
4229 Return<void> retStatus
4230 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
4231 radioService[slotId]->checkReturnStatus(retStatus);
4232 } else {
4233 RLOGE("radio::sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4234 }
4235
4236 return 0;
4237}
4238
4239int radio::acknowledgeLastIncomingCdmaSmsResponse(android::Parcel &p, int slotId, int requestNumber,
4240 int responseType, int serial, RIL_Errno e,
4241 void *response, size_t responseLen) {
4242 RLOGD("radio::acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
4243
4244 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004245 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004246 populateResponseInfo(responseInfo, serial, responseType, e);
4247 Return<void> retStatus
4248 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
4249 responseInfo);
4250 radioService[slotId]->checkReturnStatus(retStatus);
4251 } else {
4252 RLOGE("radio::acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
4253 "== NULL", slotId);
4254 }
4255
4256 return 0;
4257}
4258
4259int radio::getGsmBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber,
4260 int responseType, int serial, RIL_Errno e,
4261 void *response, size_t responseLen) {
4262 RLOGD("radio::getGsmBroadcastConfigResponse: serial %d", serial);
4263
4264 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004265 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004266 populateResponseInfo(responseInfo, serial, responseType, e);
4267 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
4268
4269 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
4270 RLOGE("radio::getGsmBroadcastConfigResponse Invalid response: NULL");
4271 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4272 } else {
4273 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
4274 configs.resize(num);
4275 for (int i = 0 ; i < num; i++) {
4276 RIL_GSM_BroadcastSmsConfigInfo *resp =
4277 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
4278 configs[i].fromServiceId = resp->fromServiceId;
4279 configs[i].toServiceId = resp->toServiceId;
4280 configs[i].fromCodeScheme = resp->fromCodeScheme;
4281 configs[i].toCodeScheme = resp->toCodeScheme;
4282 configs[i].selected = resp->selected == 1 ? true : false;
4283 }
4284 }
4285
4286 Return<void> retStatus
4287 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
4288 configs);
4289 radioService[slotId]->checkReturnStatus(retStatus);
4290 } else {
4291 RLOGE("radio::getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4292 slotId);
4293 }
4294
4295 return 0;
4296}
4297
4298int radio::setGsmBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber,
4299 int responseType, int serial, RIL_Errno e,
4300 void *response, size_t responseLen) {
4301 RLOGD("radio::setGsmBroadcastConfigResponse: serial %d", serial);
4302
4303 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004304 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004305 populateResponseInfo(responseInfo, serial, responseType, e);
4306 Return<void> retStatus
4307 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
4308 radioService[slotId]->checkReturnStatus(retStatus);
4309 } else {
4310 RLOGE("radio::setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4311 slotId);
4312 }
4313
4314 return 0;
4315}
4316
4317int radio::setGsmBroadcastActivationResponse(android::Parcel &p, int slotId, int requestNumber,
4318 int responseType, int serial, RIL_Errno e,
4319 void *response, size_t responseLen) {
4320 RLOGD("radio::setGsmBroadcastActivationResponse: serial %d", serial);
4321
4322 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004323 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004324 populateResponseInfo(responseInfo, serial, responseType, e);
4325 Return<void> retStatus
4326 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
4327 responseInfo);
4328 radioService[slotId]->checkReturnStatus(retStatus);
4329 } else {
4330 RLOGE("radio::setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
4331 slotId);
4332 }
4333
4334 return 0;
4335}
4336
4337int radio::getCdmaBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber,
4338 int responseType, int serial, RIL_Errno e,
4339 void *response, size_t responseLen) {
4340 RLOGD("radio::getCdmaBroadcastConfigResponse: serial %d", serial);
4341
4342 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004343 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004344 populateResponseInfo(responseInfo, serial, responseType, e);
4345 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
4346
4347 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
4348 RLOGE("radio::getCdmaBroadcastConfigResponse Invalid response: NULL");
4349 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4350 } else {
4351 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
4352 configs.resize(num);
4353 for (int i = 0 ; i < num; i++) {
4354 RIL_CDMA_BroadcastSmsConfigInfo *resp =
4355 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
4356 configs[i].serviceCategory = resp->service_category;
4357 configs[i].language = resp->language;
4358 configs[i].selected = resp->selected == 1 ? true : false;
4359 }
4360 }
4361
4362 Return<void> retStatus
4363 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
4364 configs);
4365 radioService[slotId]->checkReturnStatus(retStatus);
4366 } else {
4367 RLOGE("radio::getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4368 slotId);
4369 }
4370
4371 return 0;
4372}
4373
4374int radio::setCdmaBroadcastConfigResponse(android::Parcel &p, int slotId, int requestNumber,
4375 int responseType, int serial, RIL_Errno e,
4376 void *response, size_t responseLen) {
4377 RLOGD("radio::setCdmaBroadcastConfigResponse: serial %d", serial);
4378
4379 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004380 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004381 populateResponseInfo(responseInfo, serial, responseType, e);
4382 Return<void> retStatus
4383 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
4384 responseInfo);
4385 radioService[slotId]->checkReturnStatus(retStatus);
4386 } else {
4387 RLOGE("radio::setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4388 slotId);
4389 }
4390
4391 return 0;
4392}
4393
4394int radio::setCdmaBroadcastActivationResponse(android::Parcel &p, int slotId, int requestNumber,
4395 int responseType, int serial, RIL_Errno e,
4396 void *response, size_t responseLen) {
4397 RLOGD("radio::setCdmaBroadcastActivationResponse: serial %d", serial);
4398
4399 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004400 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004401 populateResponseInfo(responseInfo, serial, responseType, e);
4402 Return<void> retStatus
4403 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
4404 responseInfo);
4405 radioService[slotId]->checkReturnStatus(retStatus);
4406 } else {
4407 RLOGE("radio::setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
4408 slotId);
4409 }
4410
4411 return 0;
4412}
4413
4414int radio::getCDMASubscriptionResponse(android::Parcel &p, int slotId, int requestNumber,
4415 int responseType, int serial, RIL_Errno e, void *response,
4416 size_t responseLen) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004417 RLOGD("radio::getCDMASubscriptionResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004418
4419 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004420 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004421 populateResponseInfo(responseInfo, serial, responseType, e);
4422
4423 int numStrings = responseLen / sizeof(char *);
4424 hidl_string emptyString;
4425 if (response == NULL || numStrings != 5) {
4426 RLOGE("radio::getOperatorResponse Invalid response: NULL");
4427 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4428 Return<void> retStatus
4429 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
4430 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
4431 radioService[slotId]->checkReturnStatus(retStatus);
4432 } else {
4433 char **resp = (char **) response;
4434 Return<void> retStatus
4435 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
4436 responseInfo,
4437 convertCharPtrToHidlString(resp[0]),
4438 convertCharPtrToHidlString(resp[1]),
4439 convertCharPtrToHidlString(resp[2]),
4440 convertCharPtrToHidlString(resp[3]),
4441 convertCharPtrToHidlString(resp[4]));
4442 radioService[slotId]->checkReturnStatus(retStatus);
4443 }
4444 } else {
4445 RLOGE("radio::getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
4446 slotId);
4447 }
4448
4449 return 0;
4450}
4451
4452int radio::writeSmsToRuimResponse(android::Parcel &p, int slotId, int requestNumber,
4453 int responseType, int serial, RIL_Errno e,
4454 void *response, size_t responseLen) {
4455 RLOGD("radio::writeSmsToRuimResponse: serial %d", serial);
4456
4457 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004458 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004459 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4460 Return<void> retStatus
4461 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
4462 radioService[slotId]->checkReturnStatus(retStatus);
4463 } else {
4464 RLOGE("radio::writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4465 }
4466
4467 return 0;
4468}
4469
4470int radio::deleteSmsOnRuimResponse(android::Parcel &p, int slotId, int requestNumber,
4471 int responseType, int serial, RIL_Errno e,
4472 void *response, size_t responseLen) {
4473 RLOGD("radio::deleteSmsOnRuimResponse: serial %d", serial);
4474
4475 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004476 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004477 populateResponseInfo(responseInfo, serial, responseType, e);
4478 Return<void> retStatus
4479 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
4480 radioService[slotId]->checkReturnStatus(retStatus);
4481 } else {
4482 RLOGE("radio::deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4483 }
4484
4485 return 0;
4486}
4487
4488int radio::getDeviceIdentityResponse(android::Parcel &p, int slotId, int requestNumber,
4489 int responseType, int serial, RIL_Errno e, void *response,
4490 size_t responseLen) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004491 RLOGD("radio::getDeviceIdentityResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004492
4493 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004494 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004495 populateResponseInfo(responseInfo, serial, responseType, e);
4496
4497 int numStrings = responseLen / sizeof(char *);
4498 hidl_string emptyString;
4499 if (response == NULL || numStrings != 4) {
4500 RLOGE("radio::getDeviceIdentityResponse Invalid response: NULL");
4501 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4502 Return<void> retStatus
4503 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
4504 emptyString, emptyString, emptyString, emptyString);
4505 radioService[slotId]->checkReturnStatus(retStatus);
4506 } else {
4507 char **resp = (char **) response;
4508 Return<void> retStatus
4509 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
4510 convertCharPtrToHidlString(resp[0]),
4511 convertCharPtrToHidlString(resp[1]),
4512 convertCharPtrToHidlString(resp[2]),
4513 convertCharPtrToHidlString(resp[3]));
4514 radioService[slotId]->checkReturnStatus(retStatus);
4515 }
4516 } else {
4517 RLOGE("radio::getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
4518 slotId);
4519 }
4520
4521 return 0;
4522}
4523
4524int radio::exitEmergencyCallbackModeResponse(android::Parcel &p, int slotId, int requestNumber,
4525 int responseType, int serial, RIL_Errno e,
4526 void *response, size_t responseLen) {
4527 RLOGD("radio::exitEmergencyCallbackModeResponse: serial %d", serial);
4528
4529 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004530 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004531 populateResponseInfo(responseInfo, serial, responseType, e);
4532 Return<void> retStatus
4533 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
4534 responseInfo);
4535 radioService[slotId]->checkReturnStatus(retStatus);
4536 } else {
4537 RLOGE("radio::exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
4538 slotId);
4539 }
4540
4541 return 0;
4542}
4543
4544int radio::getSmscAddressResponse(android::Parcel &p, int slotId, int requestNumber,
4545 int responseType, int serial, RIL_Errno e,
4546 void *response, size_t responseLen) {
4547 RLOGD("radio::getSmscAddressResponse: serial %d", serial);
4548
4549 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004550 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004551 populateResponseInfo(responseInfo, serial, responseType, e);
4552 Return<void> retStatus
4553 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
4554 convertCharPtrToHidlString((char *) response));
4555 radioService[slotId]->checkReturnStatus(retStatus);
4556 } else {
4557 RLOGE("radio::getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4558 }
4559
4560 return 0;
4561}
4562
4563int radio::setSmscAddressResponse(android::Parcel &p, int slotId, int requestNumber,
4564 int responseType, int serial, RIL_Errno e,
4565 void *response, size_t responseLen) {
4566 RLOGD("radio::setSmscAddressResponse: serial %d", serial);
4567
4568 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004569 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004570 populateResponseInfo(responseInfo, serial, responseType, e);
4571 Return<void> retStatus
4572 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
4573 radioService[slotId]->checkReturnStatus(retStatus);
4574 } else {
4575 RLOGE("radio::setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4576 }
4577
4578 return 0;
4579}
4580
4581int radio::reportSmsMemoryStatusResponse(android::Parcel &p, int slotId, int requestNumber,
4582 int responseType, int serial, RIL_Errno e,
4583 void *response, size_t responseLen) {
4584 RLOGD("radio::reportSmsMemoryStatusResponse: serial %d", serial);
4585
4586 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004587 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004588 populateResponseInfo(responseInfo, serial, responseType, e);
4589 Return<void> retStatus
4590 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
4591 radioService[slotId]->checkReturnStatus(retStatus);
4592 } else {
4593 RLOGE("radio::reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
4594 slotId);
4595 }
4596
4597 return 0;
4598}
4599
Amit Mahajan5007ffa2017-01-31 17:14:42 -08004600int radio::reportStkServiceIsRunningResponse(android::Parcel &p, int slotId, int requestNumber,
4601 int responseType, int serial, RIL_Errno e,
4602 void *response, size_t responseLen) {
4603 RLOGD("radio::reportStkServiceIsRunningResponse: serial %d", serial);
4604
4605 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08004606 RadioResponseInfo responseInfo = {};
Amit Mahajan5007ffa2017-01-31 17:14:42 -08004607 populateResponseInfo(responseInfo, serial, responseType, e);
4608 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4609 reportStkServiceIsRunningResponse(responseInfo);
4610 radioService[slotId]->checkReturnStatus(retStatus);
4611 } else {
4612 RLOGE("radio::reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
4613 slotId);
4614 }
4615
4616 return 0;
4617}
4618
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004619int radio::getCdmaSubscriptionSourceResponse(android::Parcel &p, int slotId, int requestNumber,
4620 int responseType, int serial, RIL_Errno e,
4621 void *response, size_t responseLen) {
4622 RLOGD("radio::getCdmaSubscriptionSourceResponse: serial %d", serial);
4623
4624 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004625 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004626 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4627 Return<void> retStatus
4628 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
4629 responseInfo, (CdmaSubscriptionSource) ret);
4630 radioService[slotId]->checkReturnStatus(retStatus);
4631 } else {
4632 RLOGE("radio::getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4633 slotId);
4634 }
4635
4636 return 0;
4637}
4638
4639int radio::requestIsimAuthenticationResponse(android::Parcel &p, int slotId, int requestNumber,
4640 int responseType, int serial, RIL_Errno e,
4641 void *response, size_t responseLen) {
4642 RLOGD("radio::requestIsimAuthenticationResponse: serial %d", serial);
4643
4644 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004645 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004646 populateResponseInfo(responseInfo, serial, responseType, e);
4647 Return<void> retStatus
4648 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
4649 responseInfo,
4650 convertCharPtrToHidlString((char *) response));
4651 radioService[slotId]->checkReturnStatus(retStatus);
4652 } else {
4653 RLOGE("radio::requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
4654 slotId);
4655 }
4656
4657 return 0;
4658}
4659
4660int radio::acknowledgeIncomingGsmSmsWithPduResponse(android::Parcel &p, int slotId,
4661 int requestNumber, int responseType,
4662 int serial, RIL_Errno e, void *response,
4663 size_t responseLen) {
4664 RLOGD("radio::acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
4665
4666 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004667 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004668 populateResponseInfo(responseInfo, serial, responseType, e);
4669 Return<void> retStatus
4670 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
4671 responseInfo);
4672 radioService[slotId]->checkReturnStatus(retStatus);
4673 } else {
4674 RLOGE("radio::acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
4675 "== NULL", slotId);
4676 }
4677
4678 return 0;
4679}
4680
4681int radio::sendEnvelopeWithStatusResponse(android::Parcel &p, int slotId, int requestNumber,
4682 int responseType, int serial, RIL_Errno e, void *response,
4683 size_t responseLen) {
4684 RLOGD("radio::sendEnvelopeWithStatusResponse: serial %d", serial);
4685
4686 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004687 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004688 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
4689 response, responseLen);
4690
4691 Return<void> retStatus
4692 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
4693 result);
4694 radioService[slotId]->checkReturnStatus(retStatus);
4695 } else {
4696 RLOGE("radio::sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
4697 slotId);
4698 }
4699
4700 return 0;
4701}
4702
4703int radio::getVoiceRadioTechnologyResponse(android::Parcel &p, int slotId, int requestNumber,
4704 int responseType, int serial, RIL_Errno e,
4705 void *response, size_t responseLen) {
4706 RLOGD("radio::getVoiceRadioTechnologyResponse: serial %d", serial);
4707
4708 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004709 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004710 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4711 Return<void> retStatus
4712 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
4713 responseInfo, (RadioTechnology) ret);
4714 radioService[slotId]->checkReturnStatus(retStatus);
4715 } else {
4716 RLOGE("radio::getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
4717 slotId);
4718 }
4719
4720 return 0;
4721}
4722
Amit Mahajan3df62912017-02-10 01:35:55 +00004723int radio::getCellInfoListResponse(android::Parcel &p, int slotId,
4724 int requestNumber, int responseType,
4725 int serial, RIL_Errno e, void *response,
4726 size_t responseLen) {
4727 RLOGD("radio::getCellInfoListResponse: serial %d", serial);
4728
4729 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08004730 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00004731 populateResponseInfo(responseInfo, serial, responseType, e);
4732
4733 hidl_vec<CellInfo> ret;
4734 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
4735 RLOGE("radio::getCellInfoListResponse: Invalid response");
4736 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4737 } else {
4738 convertRilCellInfoListToHal(response, responseLen, ret);
4739 }
4740
4741 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
4742 responseInfo, ret);
4743 radioService[slotId]->checkReturnStatus(retStatus);
4744 } else {
4745 RLOGE("radio::getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4746 }
4747
4748 return 0;
4749}
4750
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004751int radio::setCellInfoListRateResponse(android::Parcel &p, int slotId,
4752 int requestNumber, int responseType,
4753 int serial, RIL_Errno e, void *response,
4754 size_t responseLen) {
4755 RLOGD("radio::setCellInfoListRateResponse: serial %d", serial);
4756
4757 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004758 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004759 populateResponseInfo(responseInfo, serial, responseType, e);
4760 Return<void> retStatus
4761 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
4762 radioService[slotId]->checkReturnStatus(retStatus);
4763 } else {
4764 RLOGE("radio::setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
4765 slotId);
4766 }
4767
4768 return 0;
4769}
4770
4771int radio::setInitialAttachApnResponse(android::Parcel &p, int slotId, int requestNumber,
4772 int responseType, int serial, RIL_Errno e,
4773 void *response, size_t responseLen) {
4774 RLOGD("radio::setInitialAttachApnResponse: serial %d", serial);
4775
4776 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004777 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004778 populateResponseInfo(responseInfo, serial, responseType, e);
4779 Return<void> retStatus
4780 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
4781 radioService[slotId]->checkReturnStatus(retStatus);
4782 } else {
4783 RLOGE("radio::setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
4784 slotId);
4785 }
4786
4787 return 0;
4788}
4789
4790int radio::getImsRegistrationStateResponse(android::Parcel &p, int slotId, int requestNumber,
4791 int responseType, int serial, RIL_Errno e,
4792 void *response, size_t responseLen) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004793 RLOGD("radio::getImsRegistrationStateResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004794
4795 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004796 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004797 populateResponseInfo(responseInfo, serial, responseType, e);
4798 bool isRegistered = false;
4799 int ratFamily = 0;
4800 int numInts = responseLen / sizeof(int);
4801 if (response == NULL || numInts != 2) {
4802 RLOGE("radio::getImsRegistrationStateResponse Invalid response: NULL");
4803 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4804 } else {
4805 int *pInt = (int *) response;
4806 isRegistered = pInt[0] == 1 ? true : false;
4807 ratFamily = pInt[1];
4808 }
4809 Return<void> retStatus
4810 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
4811 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
4812 radioService[slotId]->checkReturnStatus(retStatus);
4813 } else {
4814 RLOGE("radio::getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
4815 slotId);
4816 }
4817
4818 return 0;
4819}
4820
4821int radio::sendImsSmsResponse(android::Parcel &p, int slotId, int requestNumber,
4822 int responseType, int serial, RIL_Errno e, void *response,
4823 size_t responseLen) {
4824 RLOGD("radio::sendImsSmsResponse: serial %d", serial);
4825
4826 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004827 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004828 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4829 responseLen);
4830
4831 Return<void> retStatus
4832 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
4833 radioService[slotId]->checkReturnStatus(retStatus);
4834 } else {
4835 RLOGE("radio::sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4836 }
4837
4838 return 0;
4839}
4840
4841int radio::iccTransmitApduBasicChannelResponse(android::Parcel &p, int slotId, int requestNumber,
4842 int responseType, int serial, RIL_Errno e,
4843 void *response, size_t responseLen) {
4844 RLOGD("radio::iccTransmitApduBasicChannelResponse: serial %d", serial);
4845
4846 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004847 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004848 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
4849 responseLen);
4850
4851 Return<void> retStatus
4852 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
4853 responseInfo, result);
4854 radioService[slotId]->checkReturnStatus(retStatus);
4855 } else {
4856 RLOGE("radio::iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
4857 "== NULL", slotId);
4858 }
4859
4860 return 0;
4861}
4862
4863int radio::iccOpenLogicalChannelResponse(android::Parcel &p, int slotId, int requestNumber,
4864 int responseType, int serial, RIL_Errno e, void *response,
4865 size_t responseLen) {
4866 RLOGD("radio::iccOpenLogicalChannelResponse: serial %d", serial);
4867
4868 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004869 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004870 populateResponseInfo(responseInfo, serial, responseType, e);
4871 int channelId = -1;
4872 hidl_vec<int8_t> selectResponse;
4873 int numInts = responseLen / sizeof(int);
4874 if (response == NULL || responseLen % sizeof(int) != 0) {
4875 RLOGE("radio::iccOpenLogicalChannelResponse Invalid response: NULL");
4876 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4877 } else {
4878 int *pInt = (int *) response;
4879 channelId = pInt[0];
4880 selectResponse.resize(numInts - 1);
4881 for (int i = 1; i < numInts; i++) {
4882 selectResponse[i - 1] = (int8_t) pInt[i];
4883 }
4884 }
4885 Return<void> retStatus
4886 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
4887 channelId, selectResponse);
4888 radioService[slotId]->checkReturnStatus(retStatus);
4889 } else {
4890 RLOGE("radio::iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
4891 slotId);
4892 }
4893
4894 return 0;
4895}
4896
4897int radio::iccCloseLogicalChannelResponse(android::Parcel &p, int slotId, int requestNumber,
4898 int responseType, int serial, RIL_Errno e,
4899 void *response, size_t responseLen) {
4900 RLOGD("radio::iccCloseLogicalChannelResponse: serial %d", serial);
4901
4902 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004903 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004904 populateResponseInfo(responseInfo, serial, responseType, e);
4905 Return<void> retStatus
4906 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
4907 responseInfo);
4908 radioService[slotId]->checkReturnStatus(retStatus);
4909 } else {
4910 RLOGE("radio::iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
4911 slotId);
4912 }
4913
4914 return 0;
4915}
4916
4917int radio::iccTransmitApduLogicalChannelResponse(android::Parcel &p, int slotId, int requestNumber,
4918 int responseType, int serial, RIL_Errno e,
4919 void *response, size_t responseLen) {
4920 RLOGD("radio::iccTransmitApduLogicalChannelResponse: serial %d", serial);
4921
4922 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004923 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004924 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
4925 responseLen);
4926
4927 Return<void> retStatus
4928 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
4929 responseInfo, result);
4930 radioService[slotId]->checkReturnStatus(retStatus);
4931 } else {
4932 RLOGE("radio::iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
4933 "== NULL", slotId);
4934 }
4935
4936 return 0;
4937}
4938
4939int radio::nvReadItemResponse(android::Parcel &p, int slotId, int requestNumber,
4940 int responseType, int serial, RIL_Errno e,
4941 void *response, size_t responseLen) {
4942 RLOGD("radio::nvReadItemResponse: serial %d", serial);
4943
4944 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004945 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004946 populateResponseInfo(responseInfo, serial, responseType, e);
4947 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
4948 responseInfo,
4949 convertCharPtrToHidlString((char *) response));
4950 radioService[slotId]->checkReturnStatus(retStatus);
4951 } else {
4952 RLOGE("radio::nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4953 }
4954
4955 return 0;
4956}
4957
4958int radio::nvWriteItemResponse(android::Parcel &p, int slotId, int requestNumber,
4959 int responseType, int serial, RIL_Errno e,
4960 void *response, size_t responseLen) {
4961 RLOGD("radio::nvWriteItemResponse: serial %d", serial);
4962
4963 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004964 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004965 populateResponseInfo(responseInfo, serial, responseType, e);
4966 Return<void> retStatus
4967 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
4968 radioService[slotId]->checkReturnStatus(retStatus);
4969 } else {
4970 RLOGE("radio::nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4971 }
4972
4973 return 0;
4974}
4975
4976int radio::nvWriteCdmaPrlResponse(android::Parcel &p, int slotId, int requestNumber,
4977 int responseType, int serial, RIL_Errno e,
4978 void *response, size_t responseLen) {
4979 RLOGD("radio::nvWriteCdmaPrlResponse: serial %d", serial);
4980
4981 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004982 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004983 populateResponseInfo(responseInfo, serial, responseType, e);
4984 Return<void> retStatus
4985 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
4986 radioService[slotId]->checkReturnStatus(retStatus);
4987 } else {
4988 RLOGE("radio::nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4989 }
4990
4991 return 0;
4992}
4993
4994int radio::nvResetConfigResponse(android::Parcel &p, int slotId, int requestNumber,
4995 int responseType, int serial, RIL_Errno e,
4996 void *response, size_t responseLen) {
4997 RLOGD("radio::nvResetConfigResponse: serial %d", serial);
4998
4999 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005000 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005001 populateResponseInfo(responseInfo, serial, responseType, e);
5002 Return<void> retStatus
5003 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5004 radioService[slotId]->checkReturnStatus(retStatus);
5005 } else {
5006 RLOGE("radio::nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5007 }
5008
5009 return 0;
5010}
5011
5012int radio::setUiccSubscriptionResponse(android::Parcel &p, int slotId, int requestNumber,
5013 int responseType, int serial, RIL_Errno e,
5014 void *response, size_t responseLen) {
5015 RLOGD("radio::setUiccSubscriptionResponse: serial %d", serial);
5016
5017 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005018 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005019 populateResponseInfo(responseInfo, serial, responseType, e);
5020 Return<void> retStatus
5021 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5022 radioService[slotId]->checkReturnStatus(retStatus);
5023 } else {
5024 RLOGE("radio::setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5025 slotId);
5026 }
5027
5028 return 0;
5029}
5030
5031int radio::setDataAllowedResponse(android::Parcel &p, int slotId, int requestNumber,
5032 int responseType, int serial, RIL_Errno e,
5033 void *response, size_t responseLen) {
5034 RLOGD("radio::setDataAllowedResponse: serial %d", serial);
5035
5036 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005037 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005038 populateResponseInfo(responseInfo, serial, responseType, e);
5039 Return<void> retStatus
5040 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5041 radioService[slotId]->checkReturnStatus(retStatus);
5042 } else {
5043 RLOGE("radio::setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5044 }
5045
5046 return 0;
5047}
5048
Amit Mahajan3df62912017-02-10 01:35:55 +00005049int radio::getHardwareConfigResponse(android::Parcel &p, int slotId, int requestNumber,
5050 int responseType, int serial, RIL_Errno e,
5051 void *response, size_t responseLen) {
5052 RLOGD("radio::getHardwareConfigResponse: serial %d", serial);
5053
5054 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005055 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00005056 populateResponseInfo(responseInfo, serial, responseType, e);
5057
5058 hidl_vec<HardwareConfig> result;
5059 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
5060 RLOGE("radio::hardwareConfigChangedInd: invalid response");
5061 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5062 } else {
5063 convertRilHardwareConfigListToHal(response, responseLen, result);
5064 }
5065
5066 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
5067 responseInfo, result);
5068 radioService[slotId]->checkReturnStatus(retStatus);
5069 } else {
5070 RLOGE("radio::getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5071 }
5072
5073 return 0;
5074}
5075
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005076int radio::requestIccSimAuthenticationResponse(android::Parcel &p, int slotId, int requestNumber,
5077 int responseType, int serial, RIL_Errno e,
5078 void *response, size_t responseLen) {
5079 RLOGD("radio::requestIccSimAuthenticationResponse: serial %d", serial);
5080
5081 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005082 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005083 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5084 responseLen);
5085
5086 Return<void> retStatus
5087 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
5088 responseInfo, result);
5089 radioService[slotId]->checkReturnStatus(retStatus);
5090 } else {
5091 RLOGE("radio::requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
5092 "== NULL", slotId);
5093 }
5094
5095 return 0;
5096}
5097
5098int radio::setDataProfileResponse(android::Parcel &p, int slotId, int requestNumber,
5099 int responseType, int serial, RIL_Errno e,
5100 void *response, size_t responseLen) {
5101 RLOGD("radio::setDataProfileResponse: serial %d", serial);
5102
5103 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005104 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005105 populateResponseInfo(responseInfo, serial, responseType, e);
5106 Return<void> retStatus
5107 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
5108 radioService[slotId]->checkReturnStatus(retStatus);
5109 } else {
5110 RLOGE("radio::setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5111 }
5112
5113 return 0;
5114}
5115
5116int radio::requestShutdownResponse(android::Parcel &p, int slotId, int requestNumber,
5117 int responseType, int serial, RIL_Errno e,
5118 void *response, size_t responseLen) {
5119 RLOGD("radio::requestShutdownResponse: serial %d", serial);
5120
5121 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005122 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005123 populateResponseInfo(responseInfo, serial, responseType, e);
5124 Return<void> retStatus
5125 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
5126 radioService[slotId]->checkReturnStatus(retStatus);
5127 } else {
5128 RLOGE("radio::requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5129 }
5130
5131 return 0;
5132}
5133
Amit Mahajan3df62912017-02-10 01:35:55 +00005134void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
5135 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
5136 populateResponseInfo(responseInfo, serial, responseType, e);
5137
Amit Mahajan1fbff082017-02-24 11:24:39 -08005138 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
Amit Mahajan3df62912017-02-10 01:35:55 +00005139 RLOGE("responseRadioCapability: Invalid response");
5140 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005141 rc.logicalModemUuid = hidl_string();
Amit Mahajan3df62912017-02-10 01:35:55 +00005142 } else {
5143 convertRilRadioCapabilityToHal(response, responseLen, rc);
5144 }
5145}
5146
5147int radio::getRadioCapabilityResponse(android::Parcel &p, int slotId, int requestNumber,
5148 int responseType, int serial, RIL_Errno e,
5149 void *response, size_t responseLen) {
5150 RLOGD("radio::getRadioCapabilityResponse: serial %d", serial);
5151
5152 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005153 RadioResponseInfo responseInfo = {};
5154 RadioCapability result = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00005155 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
5156 result);
5157 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
5158 responseInfo, result);
5159 radioService[slotId]->checkReturnStatus(retStatus);
5160 } else {
5161 RLOGE("radio::getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5162 }
5163
5164 return 0;
5165}
5166
5167int radio::setRadioCapabilityResponse(android::Parcel &p, int slotId, int requestNumber,
5168 int responseType, int serial, RIL_Errno e,
5169 void *response, size_t responseLen) {
5170 RLOGD("radio::setRadioCapabilityResponse: serial %d", serial);
5171
5172 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005173 RadioResponseInfo responseInfo = {};
5174 RadioCapability result = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00005175 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
5176 result);
5177 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
5178 responseInfo, result);
5179 radioService[slotId]->checkReturnStatus(retStatus);
5180 } else {
5181 RLOGE("radio::setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5182 }
5183
5184 return 0;
5185}
5186
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005187LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
5188 RIL_Errno e, void *response, size_t responseLen) {
5189 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08005190 LceStatusInfo result = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005191
5192 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
5193 RLOGE("Invalid response: NULL");
5194 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005195 } else {
5196 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
5197 result.lceStatus = (LceStatus) resp->lce_status;
5198 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
5199 }
5200 return result;
5201}
5202
5203int radio::startLceServiceResponse(android::Parcel &p, int slotId, int requestNumber,
5204 int responseType, int serial, RIL_Errno e,
5205 void *response, size_t responseLen) {
5206 RLOGD("radio::startLceServiceResponse: serial %d", serial);
5207
5208 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005209 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005210 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
5211 response, responseLen);
5212
5213 Return<void> retStatus
5214 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
5215 result);
5216 radioService[slotId]->checkReturnStatus(retStatus);
5217 } else {
5218 RLOGE("radio::startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5219 }
5220
5221 return 0;
5222}
5223
5224int radio::stopLceServiceResponse(android::Parcel &p, int slotId, int requestNumber,
5225 int responseType, int serial, RIL_Errno e,
5226 void *response, size_t responseLen) {
5227 RLOGD("radio::stopLceServiceResponse: serial %d", serial);
5228
5229 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005230 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005231 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
5232 response, responseLen);
5233
5234 Return<void> retStatus
5235 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
5236 result);
5237 radioService[slotId]->checkReturnStatus(retStatus);
5238 } else {
5239 RLOGE("radio::stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5240 }
5241
5242 return 0;
5243}
5244
Amit Mahajan3df62912017-02-10 01:35:55 +00005245int radio::pullLceDataResponse(android::Parcel &p, int slotId, int requestNumber,
5246 int responseType, int serial, RIL_Errno e,
5247 void *response, size_t responseLen) {
5248 RLOGD("radio::pullLceDataResponse: serial %d", serial);
5249
5250 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005251 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00005252 populateResponseInfo(responseInfo, serial, responseType, e);
5253
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005254 LceDataInfo result = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00005255 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
5256 RLOGE("radio::pullLceDataResponse: Invalid response");
5257 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Amit Mahajan3df62912017-02-10 01:35:55 +00005258 } else {
5259 convertRilLceDataInfoToHal(response, responseLen, result);
5260 }
5261
5262 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
5263 responseInfo, result);
5264 radioService[slotId]->checkReturnStatus(retStatus);
5265 } else {
5266 RLOGE("radio::pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5267 }
5268
5269 return 0;
5270}
5271
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005272int radio::getModemActivityInfoResponse(android::Parcel &p, int slotId, int requestNumber,
5273 int responseType, int serial, RIL_Errno e,
5274 void *response, size_t responseLen) {
5275 RLOGD("radio::getModemActivityInfoResponse: serial %d", serial);
5276
5277 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005278 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005279 populateResponseInfo(responseInfo, serial, responseType, e);
5280 ActivityStatsInfo info;
5281 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
5282 RLOGE("radio::getModemActivityInfoResponse Invalid response: NULL");
5283 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005284 } else {
5285 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
5286 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
5287 info.idleModeTimeMs = resp->idle_mode_time_ms;
5288 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
5289 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
5290 }
5291 info.rxModeTimeMs = resp->rx_mode_time_ms;
5292 }
5293
5294 Return<void> retStatus
5295 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
5296 info);
5297 radioService[slotId]->checkReturnStatus(retStatus);
5298 } else {
5299 RLOGE("radio::getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
5300 slotId);
5301 }
5302
5303 return 0;
5304}
5305
5306int radio::setAllowedCarriersResponse(android::Parcel &p, int slotId, int requestNumber,
5307 int responseType, int serial, RIL_Errno e,
5308 void *response, size_t responseLen) {
5309 RLOGD("radio::setAllowedCarriersResponse: serial %d", serial);
5310
5311 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005312 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005313 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5314 Return<void> retStatus
5315 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
5316 ret);
5317 radioService[slotId]->checkReturnStatus(retStatus);
5318 } else {
5319 RLOGE("radio::setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
5320 slotId);
5321 }
5322
5323 return 0;
5324}
5325
5326int radio::getAllowedCarriersResponse(android::Parcel &p, int slotId, int requestNumber,
5327 int responseType, int serial, RIL_Errno e,
5328 void *response, size_t responseLen) {
5329 RLOGD("radio::getAllowedCarriersResponse: serial %d", serial);
5330
5331 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005332 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005333 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08005334 CarrierRestrictions carrierInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005335 bool allAllowed = true;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005336 if (response == NULL || responseLen != sizeof(RIL_CarrierRestrictions)) {
5337 RLOGE("radio::getAllowedCarriersResponse Invalid response: NULL");
5338 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5339 } else {
5340 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
5341 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
5342 allAllowed = false;
5343 }
5344
5345 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
5346 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
5347 RIL_Carrier *carrier = pCr->allowed_carriers + i;
5348 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
5349 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
5350 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
5351 carrierInfo.allowedCarriers[i].matchData =
5352 convertCharPtrToHidlString(carrier->match_data);
5353 }
5354
5355 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
5356 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
5357 RIL_Carrier *carrier = pCr->excluded_carriers + i;
5358 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
5359 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
5360 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
5361 carrierInfo.excludedCarriers[i].matchData =
5362 convertCharPtrToHidlString(carrier->match_data);
5363 }
5364 }
5365
5366 Return<void> retStatus
5367 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
5368 allAllowed, carrierInfo);
5369 radioService[slotId]->checkReturnStatus(retStatus);
5370 } else {
5371 RLOGE("radio::getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
5372 slotId);
5373 }
5374
5375 return 0;
5376}
5377
Wileen Chiu718c0bf2017-01-04 11:37:19 -08005378int radio::setSimCardPowerResponse(android::Parcel &p, int slotId, int requestNumber,
5379 int responseType, int serial, RIL_Errno e,
5380 void *response, size_t responseLen) {
5381 RLOGD("radio::setSimCardPowerResponse: serial %d", serial);
5382
5383 if (radioService[slotId]->mRadioResponse != NULL) {
5384 RadioResponseInfo responseInfo = {};
5385 populateResponseInfo(responseInfo, serial, responseType, e);
5386 Return<void> retStatus
5387 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
5388 radioService[slotId]->checkReturnStatus(retStatus);
5389 } else {
5390 RLOGE("radio::setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5391 }
5392
5393 return 0;
5394}
5395
Amit Mahajan439da362017-02-13 17:43:04 -08005396int radio::sendRequestRawResponse(android::Parcel &p, int slotId, int requestNumber,
5397 int responseType, int serial, RIL_Errno e,
5398 void *response, size_t responseLen) {
5399 RLOGD("radio::sendRequestRawResponse: serial %d", serial);
5400
5401 if (oemHookService[slotId]->mOemHookResponse != NULL) {
5402 RadioResponseInfo responseInfo = {};
5403 populateResponseInfo(responseInfo, serial, responseType, e);
5404 hidl_vec<uint8_t> data;
5405
5406 if (response == NULL) {
5407 RLOGE("radio::sendRequestRawResponse: Invalid response");
5408 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5409 } else {
5410 data.setToExternal((uint8_t *) response, responseLen);
5411 }
5412 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
5413 sendRequestRawResponse(responseInfo, data);
5414 checkReturnStatus(slotId, retStatus);
5415 } else {
5416 RLOGE("radio::sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
5417 slotId);
5418 }
5419
5420 return 0;
5421}
5422
5423int radio::sendRequestStringsResponse(android::Parcel &p, int slotId, int requestNumber,
5424 int responseType, int serial, RIL_Errno e,
5425 void *response, size_t responseLen) {
5426 RLOGD("radio::sendRequestStringsResponse: serial %d", serial);
5427
5428 if (oemHookService[slotId]->mOemHookResponse != NULL) {
5429 RadioResponseInfo responseInfo = {};
5430 populateResponseInfo(responseInfo, serial, responseType, e);
5431 hidl_vec<hidl_string> data;
5432
5433 if (response == NULL || responseLen % sizeof(char *) != 0) {
5434 RLOGE("radio::sendRequestStringsResponse Invalid response: NULL");
5435 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5436 } else {
5437 char **resp = (char **) response;
5438 int numStrings = responseLen / sizeof(char *);
5439 data.resize(numStrings);
5440 for (int i = 0; i < numStrings; i++) {
5441 data[i] = convertCharPtrToHidlString(resp[i]);
5442 }
5443 }
5444 Return<void> retStatus
5445 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
5446 responseInfo, data);
5447 checkReturnStatus(slotId, retStatus);
5448 } else {
5449 RLOGE("radio::sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
5450 "NULL", slotId);
5451 }
5452
5453 return 0;
5454}
5455
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005456// Radio Indication functions
5457
Amit Mahajan5829a472016-12-28 17:28:07 -08005458RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
5459 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
5460 (RadioIndicationType::UNSOLICITED_ACK_EXP);
5461}
5462
5463void radio::radioStateChangedInd(int slotId, int indicationType, RIL_RadioState radioState) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005464 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005465 RLOGD("radio::radioStateChangedInd: radioState %d", radioState);
Amit Mahajan17249842017-01-19 15:05:45 -08005466 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
Amit Mahajan5829a472016-12-28 17:28:07 -08005467 convertIntToRadioIndicationType(indicationType), (RadioState) radioState);
Amit Mahajan17249842017-01-19 15:05:45 -08005468 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07005469 } else {
Amit Mahajan5829a472016-12-28 17:28:07 -08005470 RLOGE("radio::radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07005471 }
5472}
5473
Amit Mahajan5829a472016-12-28 17:28:07 -08005474int radio::callStateChangedInd(android::Parcel &p, int slotId, int requestNumber,
5475 int indicationType, int token, RIL_Errno e, void *response,
5476 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005477 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005478 RLOGD("radio::callStateChangedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005479 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
Amit Mahajan5829a472016-12-28 17:28:07 -08005480 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08005481 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005482 } else {
5483 RLOGE("radio::callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
5484 }
5485
5486 return 0;
5487}
5488
Jack Yu06181bb2017-01-10 12:10:41 -08005489int radio::networkStateChangedInd(android::Parcel &p, int slotId, int requestNumber,
Amit Mahajan5829a472016-12-28 17:28:07 -08005490 int indicationType, int token, RIL_Errno e, void *response,
5491 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005492 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Jack Yu06181bb2017-01-10 12:10:41 -08005493 RLOGD("radio::networkStateChangedInd");
5494 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
Amit Mahajan5829a472016-12-28 17:28:07 -08005495 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08005496 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005497 } else {
Jack Yu06181bb2017-01-10 12:10:41 -08005498 RLOGE("radio::networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08005499 slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08005500 }
5501
5502 return 0;
5503}
5504
5505uint8_t hexCharToInt(uint8_t c) {
5506 if (c >= '0' && c <= '9') return (c - '0');
5507 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
5508 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
5509
5510 return INVALID_HEX_CHAR;
5511}
5512
5513uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
5514 if (responseLen % 2 != 0) {
5515 return NULL;
5516 }
5517
5518 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
5519 if (bytes == NULL) {
5520 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
5521 return NULL;
5522 }
5523 uint8_t *hexString = (uint8_t *)response;
5524
Wei Wang100ac9b2017-02-03 14:18:07 -08005525 for (size_t i = 0; i < responseLen; i += 2) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005526 uint8_t hexChar1 = hexCharToInt(hexString[i]);
5527 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
5528
5529 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
5530 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
5531 hexString[i], hexString[i + 1]);
5532 free(bytes);
5533 return NULL;
5534 }
5535 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
5536 }
5537
5538 return bytes;
5539}
5540
5541int radio::newSmsInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
5542 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005543 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005544 if (response == NULL || responseLen == 0) {
5545 RLOGE("radio::newSmsInd: invalid response");
5546 return 0;
5547 }
5548
5549 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
5550 if (bytes == NULL) {
5551 RLOGE("radio::newSmsInd: convertHexStringToBytes failed");
5552 return 0;
5553 }
5554
5555 hidl_vec<uint8_t> pdu;
5556 pdu.setToExternal(bytes, responseLen/2);
5557 RLOGD("radio::newSmsInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005558 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
Amit Mahajan5829a472016-12-28 17:28:07 -08005559 convertIntToRadioIndicationType(indicationType), pdu);
Amit Mahajan17249842017-01-19 15:05:45 -08005560 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005561 free(bytes);
5562 } else {
5563 RLOGE("radio::newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
5564 }
5565
5566 return 0;
5567}
5568
5569int radio::newSmsStatusReportInd(android::Parcel &p, int slotId, int requestNumber,
5570 int indicationType, int token, RIL_Errno e, void *response,
5571 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005572 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005573 if (response == NULL || responseLen == 0) {
5574 RLOGE("radio::newSmsStatusReportInd: invalid response");
5575 return 0;
5576 }
5577
5578 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
5579 if (bytes == NULL) {
5580 RLOGE("radio::newSmsStatusReportInd: convertHexStringToBytes failed");
5581 return 0;
5582 }
5583
5584 hidl_vec<uint8_t> pdu;
5585 pdu.setToExternal(bytes, responseLen/2);
5586 RLOGD("radio::newSmsStatusReportInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005587 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
Amit Mahajan5829a472016-12-28 17:28:07 -08005588 convertIntToRadioIndicationType(indicationType), pdu);
Amit Mahajan17249842017-01-19 15:05:45 -08005589 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005590 free(bytes);
5591 } else {
5592 RLOGE("radio::newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
5593 }
5594
5595 return 0;
5596}
5597
5598int radio::newSmsOnSimInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
5599 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005600 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005601 if (response == NULL || responseLen != sizeof(int)) {
5602 RLOGE("radio::newSmsOnSimInd: invalid response");
5603 return 0;
5604 }
5605 int32_t recordNumber = ((int32_t *) response)[0];
5606 RLOGD("radio::newSmsOnSimInd: slotIndex %d", recordNumber);
Amit Mahajan17249842017-01-19 15:05:45 -08005607 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
Amit Mahajan5829a472016-12-28 17:28:07 -08005608 convertIntToRadioIndicationType(indicationType), recordNumber);
Amit Mahajan17249842017-01-19 15:05:45 -08005609 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005610 } else {
5611 RLOGE("radio::newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
5612 }
5613
5614 return 0;
5615}
5616
5617int radio::onUssdInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
5618 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005619 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005620 if (response == NULL || responseLen != 2 * sizeof(char *)) {
5621 RLOGE("radio::onUssdInd: invalid response");
5622 return 0;
5623 }
5624 char **strings = (char **) response;
5625 char *mode = strings[0];
5626 hidl_string msg = convertCharPtrToHidlString(strings[1]);
5627 UssdModeType modeType = (UssdModeType) atoi(mode);
5628 RLOGD("radio::onUssdInd: mode %s", mode);
Amit Mahajan17249842017-01-19 15:05:45 -08005629 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
Amit Mahajan5829a472016-12-28 17:28:07 -08005630 convertIntToRadioIndicationType(indicationType), modeType, msg);
Amit Mahajan17249842017-01-19 15:05:45 -08005631 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005632 } else {
5633 RLOGE("radio::onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
5634 }
5635
5636 return 0;
5637}
5638
5639int radio::nitzTimeReceivedInd(android::Parcel &p, int slotId, int requestNumber,
5640 int indicationType, int token, RIL_Errno e, void *response,
5641 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005642 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005643 if (response == NULL || responseLen == 0) {
5644 RLOGE("radio::nitzTimeReceivedInd: invalid response");
5645 return 0;
5646 }
5647 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
5648 int64_t timeReceived = android::elapsedRealtime();
Wei Wang100ac9b2017-02-03 14:18:07 -08005649 RLOGD("radio::nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
Amit Mahajan2fa9e632017-01-06 16:55:33 -08005650 timeReceived);
Amit Mahajan17249842017-01-19 15:05:45 -08005651 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
Amit Mahajan5829a472016-12-28 17:28:07 -08005652 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
Amit Mahajan17249842017-01-19 15:05:45 -08005653 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005654 } else {
5655 RLOGE("radio::nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
Weilun Dud2c30932017-02-09 12:32:42 -08005656 return -1;
Amit Mahajan5829a472016-12-28 17:28:07 -08005657 }
5658
5659 return 0;
5660}
5661
Amit Mahajan2fa9e632017-01-06 16:55:33 -08005662void convertRilSignalStrengthToHal(void *response, size_t responseLen,
5663 SignalStrength& signalStrength) {
5664 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
5665
5666 // Fixup LTE for backwards compatibility
5667 // signalStrength: -1 -> 99
5668 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
5669 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
5670 }
5671 // rsrp: -1 -> INT_MAX all other negative value to positive.
5672 // So remap here
5673 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
5674 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
5675 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
5676 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
5677 }
5678 // rsrq: -1 -> INT_MAX
5679 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
5680 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
5681 }
5682 // Not remapping rssnr is already using INT_MAX
5683 // cqi: -1 -> INT_MAX
5684 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
5685 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
5686 }
5687
5688 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
5689 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
5690 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
5691 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
5692 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
5693 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
5694 signalStrength.evdo.signalNoiseRatio =
5695 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
5696 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
5697 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
5698 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
5699 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
5700 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
5701 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
5702 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
5703}
5704
5705int radio::currentSignalStrengthInd(android::Parcel &p, int slotId, int requestNumber,
5706 int indicationType, int token, RIL_Errno e,
5707 void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005708 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08005709 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
5710 RLOGE("radio::currentSignalStrengthInd: invalid response");
5711 return 0;
5712 }
5713
Jack Yuf68e0da2017-02-07 14:53:09 -08005714 SignalStrength signalStrength = {};
Amit Mahajan2fa9e632017-01-06 16:55:33 -08005715 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
5716
5717 RLOGD("radio::currentSignalStrengthInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005718 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08005719 convertIntToRadioIndicationType(indicationType), signalStrength);
Amit Mahajan17249842017-01-19 15:05:45 -08005720 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08005721 } else {
5722 RLOGE("radio::currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
5723 slotId);
5724 }
5725
5726 return 0;
5727}
5728
Amit Mahajan5829a472016-12-28 17:28:07 -08005729void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
5730 SetupDataCallResult& dcResult) {
Jack Yu5079e182017-02-28 15:21:18 -08005731 dcResult.status = (DataCallFailCause) dcResponse->status;
Amit Mahajan5829a472016-12-28 17:28:07 -08005732 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
5733 dcResult.cid = dcResponse->cid;
5734 dcResult.active = dcResponse->active;
5735 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
5736 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
5737 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
5738 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
5739 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
5740 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
5741 dcResult.mtu = dcResponse->mtu;
5742}
5743
5744void convertRilDataCallListToHal(void *response, size_t responseLen,
5745 hidl_vec<SetupDataCallResult>& dcResultList) {
5746 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
5747
5748 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
5749 dcResultList.resize(num);
5750 for (int i = 0; i < num; i++) {
5751 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
5752 }
5753}
5754
5755int radio::dataCallListChangedInd(android::Parcel &p, int slotId, int requestNumber,
5756 int indicationType, int token, RIL_Errno e, void *response,
5757 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005758 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005759 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
5760 RLOGE("radio::dataCallListChangedInd: invalid response");
5761 return 0;
5762 }
5763 hidl_vec<SetupDataCallResult> dcList;
5764 convertRilDataCallListToHal(response, responseLen, dcList);
5765 RLOGD("radio::dataCallListChangedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005766 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
Amit Mahajan5829a472016-12-28 17:28:07 -08005767 convertIntToRadioIndicationType(indicationType), dcList);
Amit Mahajan17249842017-01-19 15:05:45 -08005768 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005769 } else {
5770 RLOGE("radio::dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
5771 }
5772
5773 return 0;
5774}
5775
5776int radio::suppSvcNotifyInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
5777 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005778 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005779 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
5780 RLOGE("radio::suppSvcNotifyInd: invalid response");
5781 return 0;
5782 }
5783
Jack Yuf68e0da2017-02-07 14:53:09 -08005784 SuppSvcNotification suppSvc = {};
Amit Mahajan5829a472016-12-28 17:28:07 -08005785 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
5786 suppSvc.isMT = ssn->notificationType;
5787 suppSvc.code = ssn->code;
5788 suppSvc.index = ssn->index;
5789 suppSvc.type = ssn->type;
5790 suppSvc.number = convertCharPtrToHidlString(ssn->number);
5791
5792 RLOGD("radio::suppSvcNotifyInd: isMT %d code %d index %d type %d",
5793 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
Amit Mahajan17249842017-01-19 15:05:45 -08005794 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
Amit Mahajan5829a472016-12-28 17:28:07 -08005795 convertIntToRadioIndicationType(indicationType), suppSvc);
Amit Mahajan17249842017-01-19 15:05:45 -08005796 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005797 } else {
5798 RLOGE("radio::suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
5799 }
5800
5801 return 0;
5802}
5803
5804int radio::stkSessionEndInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
5805 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005806 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005807 RLOGD("radio::stkSessionEndInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005808 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
Amit Mahajan5829a472016-12-28 17:28:07 -08005809 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08005810 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005811 } else {
5812 RLOGE("radio::stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
5813 }
5814
5815 return 0;
5816}
5817
5818int radio::stkProactiveCommandInd(android::Parcel &p, int slotId, int requestNumber,
5819 int indicationType, int token, RIL_Errno e, void *response,
5820 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005821 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005822 if (response == NULL || responseLen == 0) {
5823 RLOGE("radio::stkProactiveCommandInd: invalid response");
5824 return 0;
5825 }
5826 RLOGD("radio::stkProactiveCommandInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005827 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
Amit Mahajan5829a472016-12-28 17:28:07 -08005828 convertIntToRadioIndicationType(indicationType),
5829 convertCharPtrToHidlString((char *) response));
Amit Mahajan17249842017-01-19 15:05:45 -08005830 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005831 } else {
5832 RLOGE("radio::stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
5833 }
5834
5835 return 0;
5836}
5837
5838int radio::stkEventNotifyInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
5839 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005840 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005841 if (response == NULL || responseLen == 0) {
5842 RLOGE("radio::stkEventNotifyInd: invalid response");
5843 return 0;
5844 }
5845 RLOGD("radio::stkEventNotifyInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005846 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
Amit Mahajan5829a472016-12-28 17:28:07 -08005847 convertIntToRadioIndicationType(indicationType),
5848 convertCharPtrToHidlString((char *) response));
Amit Mahajan17249842017-01-19 15:05:45 -08005849 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005850 } else {
5851 RLOGE("radio::stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
5852 }
5853
5854 return 0;
5855}
5856
5857int radio::stkCallSetupInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
5858 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005859 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005860 if (response == NULL || responseLen != sizeof(int)) {
5861 RLOGE("radio::stkCallSetupInd: invalid response");
5862 return 0;
5863 }
5864 int32_t timeout = ((int32_t *) response)[0];
5865 RLOGD("radio::stkCallSetupInd: timeout %d", timeout);
Amit Mahajan17249842017-01-19 15:05:45 -08005866 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
Amit Mahajan5829a472016-12-28 17:28:07 -08005867 convertIntToRadioIndicationType(indicationType), timeout);
Amit Mahajan17249842017-01-19 15:05:45 -08005868 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005869 } else {
5870 RLOGE("radio::stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
5871 }
5872
5873 return 0;
5874}
5875
5876int radio::simSmsStorageFullInd(android::Parcel &p, int slotId, int requestNumber,
5877 int indicationType, int token, RIL_Errno e, void *response,
5878 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005879 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005880 RLOGD("radio::simSmsStorageFullInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005881 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
Amit Mahajan5829a472016-12-28 17:28:07 -08005882 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08005883 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005884 } else {
5885 RLOGE("radio::simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
5886 }
5887
5888 return 0;
5889}
5890
5891int radio::simRefreshInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
5892 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005893 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005894 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
5895 RLOGE("radio::simRefreshInd: invalid response");
5896 return 0;
5897 }
5898
Jack Yuf68e0da2017-02-07 14:53:09 -08005899 SimRefreshResult refreshResult = {};
Amit Mahajan5829a472016-12-28 17:28:07 -08005900 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
5901 refreshResult.type =
5902 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
5903 refreshResult.efId = simRefreshResponse->ef_id;
5904 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
5905
5906 RLOGD("radio::simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
Amit Mahajan17249842017-01-19 15:05:45 -08005907 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
Amit Mahajan5829a472016-12-28 17:28:07 -08005908 convertIntToRadioIndicationType(indicationType), refreshResult);
Amit Mahajan17249842017-01-19 15:05:45 -08005909 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005910 } else {
5911 RLOGE("radio::simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
5912 }
5913
5914 return 0;
5915}
5916
5917void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
5918 CdmaSignalInfoRecord& record) {
5919 record.isPresent = signalInfoRecord->isPresent;
5920 record.signalType = signalInfoRecord->signalType;
5921 record.alertPitch = signalInfoRecord->alertPitch;
5922 record.signal = signalInfoRecord->signal;
5923}
5924
5925int radio::callRingInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
5926 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005927 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005928 bool isGsm;
Jack Yuf68e0da2017-02-07 14:53:09 -08005929 CdmaSignalInfoRecord record = {};
Amit Mahajan5829a472016-12-28 17:28:07 -08005930 if (response == NULL || responseLen == 0) {
5931 isGsm = true;
5932 } else {
5933 isGsm = false;
5934 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
5935 RLOGE("radio::callRingInd: invalid response");
5936 return 0;
5937 }
5938 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
5939 }
5940
5941 RLOGD("radio::callRingInd: isGsm %d", isGsm);
Amit Mahajan17249842017-01-19 15:05:45 -08005942 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
Amit Mahajan5829a472016-12-28 17:28:07 -08005943 convertIntToRadioIndicationType(indicationType), isGsm, record);
Amit Mahajan17249842017-01-19 15:05:45 -08005944 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005945 } else {
5946 RLOGE("radio::callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
5947 }
5948
5949 return 0;
5950}
5951
5952int radio::simStatusChangedInd(android::Parcel &p, int slotId, int requestNumber,
5953 int indicationType, int token, RIL_Errno e, void *response,
5954 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005955 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005956 RLOGD("radio::simStatusChangedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005957 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
Amit Mahajan5829a472016-12-28 17:28:07 -08005958 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08005959 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005960 } else {
5961 RLOGE("radio::simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
5962 }
5963
5964 return 0;
5965}
5966
5967int radio::cdmaNewSmsInd(android::Parcel &p, int slotId, int requestNumber, int indicationType,
5968 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005969 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005970 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
5971 RLOGE("radio::cdmaNewSmsInd: invalid response");
5972 return 0;
5973 }
5974
Jack Yuf68e0da2017-02-07 14:53:09 -08005975 CdmaSmsMessage msg = {};
Amit Mahajan5829a472016-12-28 17:28:07 -08005976 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
5977 msg.teleserviceId = rilMsg->uTeleserviceID;
5978 msg.isServicePresent = rilMsg->bIsServicePresent;
5979 msg.serviceCategory = rilMsg->uServicecategory;
5980 msg.address.digitMode =
5981 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
5982 msg.address.numberMode =
5983 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
5984 msg.address.numberType =
5985 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
5986 msg.address.numberPlan =
5987 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
5988
5989 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
5990 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
5991
5992 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
5993 rilMsg->sSubAddress.subaddressType;
5994 msg.subAddress.odd = rilMsg->sSubAddress.odd;
5995
5996 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
5997 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
5998
5999 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
6000 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
6001
6002 RLOGD("radio::cdmaNewSmsInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006003 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
Amit Mahajan5829a472016-12-28 17:28:07 -08006004 convertIntToRadioIndicationType(indicationType), msg);
Amit Mahajan17249842017-01-19 15:05:45 -08006005 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006006 } else {
6007 RLOGE("radio::cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6008 }
6009
6010 return 0;
6011}
6012
Amit Mahajan1955c742016-12-29 07:07:54 -08006013int radio::newBroadcastSmsInd(android::Parcel &p, int slotId, int requestNumber,
6014 int indicationType, int token, RIL_Errno e, void *response,
6015 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006016 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006017 if (response == NULL || responseLen == 0) {
6018 RLOGE("radio::newBroadcastSmsInd: invalid response");
6019 return 0;
6020 }
6021
6022 hidl_vec<uint8_t> data;
6023 data.setToExternal((uint8_t *) response, responseLen);
6024 RLOGD("radio::newBroadcastSmsInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006025 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
Amit Mahajan1955c742016-12-29 07:07:54 -08006026 convertIntToRadioIndicationType(indicationType), data);
Amit Mahajan17249842017-01-19 15:05:45 -08006027 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006028 } else {
6029 RLOGE("radio::newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6030 }
6031
6032 return 0;
6033}
6034
6035int radio::cdmaRuimSmsStorageFullInd(android::Parcel &p, int slotId, int requestNumber,
6036 int indicationType, int token, RIL_Errno e, void *response,
6037 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006038 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006039 RLOGD("radio::cdmaRuimSmsStorageFullInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006040 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
Amit Mahajan1955c742016-12-29 07:07:54 -08006041 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006042 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006043 } else {
6044 RLOGE("radio::cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
6045 slotId);
6046 }
6047
6048 return 0;
6049}
6050
6051int radio::restrictedStateChangedInd(android::Parcel &p, int slotId, int requestNumber,
6052 int indicationType, int token, RIL_Errno e, void *response,
6053 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006054 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006055 if (response == NULL || responseLen != sizeof(int)) {
6056 RLOGE("radio::restrictedStateChangedInd: invalid response");
6057 return 0;
6058 }
6059 int32_t state = ((int32_t *) response)[0];
6060 RLOGD("radio::restrictedStateChangedInd: state %d", state);
Amit Mahajan17249842017-01-19 15:05:45 -08006061 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
Amit Mahajan1955c742016-12-29 07:07:54 -08006062 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
Amit Mahajan17249842017-01-19 15:05:45 -08006063 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006064 } else {
6065 RLOGE("radio::restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6066 slotId);
6067 }
6068
6069 return 0;
6070}
6071
6072int radio::enterEmergencyCallbackModeInd(android::Parcel &p, int slotId, int requestNumber,
6073 int indicationType, int token, RIL_Errno e, void *response,
6074 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006075 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006076 RLOGD("radio::enterEmergencyCallbackModeInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006077 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
Amit Mahajan1955c742016-12-29 07:07:54 -08006078 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006079 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006080 } else {
6081 RLOGE("radio::enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
6082 slotId);
6083 }
6084
6085 return 0;
6086}
6087
6088int radio::cdmaCallWaitingInd(android::Parcel &p, int slotId, int requestNumber,
6089 int indicationType, int token, RIL_Errno e, void *response,
6090 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006091 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006092 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
6093 RLOGE("radio::cdmaCallWaitingInd: invalid response");
6094 return 0;
6095 }
6096
Jack Yuf68e0da2017-02-07 14:53:09 -08006097 CdmaCallWaiting callWaitingRecord = {};
Amit Mahajan1955c742016-12-29 07:07:54 -08006098 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
6099 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
6100 callWaitingRecord.numberPresentation =
6101 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
6102 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
6103 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
6104 callWaitingRecord.signalInfoRecord);
6105 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
6106 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
6107
6108 RLOGD("radio::cdmaCallWaitingInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006109 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
Amit Mahajan1955c742016-12-29 07:07:54 -08006110 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
Amit Mahajan17249842017-01-19 15:05:45 -08006111 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006112 } else {
6113 RLOGE("radio::cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
6114 }
6115
6116 return 0;
6117}
6118
6119int radio::cdmaOtaProvisionStatusInd(android::Parcel &p, int slotId, int requestNumber,
6120 int indicationType, int token, RIL_Errno e, void *response,
6121 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006122 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006123 if (response == NULL || responseLen != sizeof(int)) {
6124 RLOGE("radio::cdmaOtaProvisionStatusInd: invalid response");
6125 return 0;
6126 }
6127 int32_t status = ((int32_t *) response)[0];
6128 RLOGD("radio::cdmaOtaProvisionStatusInd: status %d", status);
Amit Mahajan17249842017-01-19 15:05:45 -08006129 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
Amit Mahajan1955c742016-12-29 07:07:54 -08006130 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
Amit Mahajan17249842017-01-19 15:05:45 -08006131 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006132 } else {
6133 RLOGE("radio::cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
6134 slotId);
6135 }
6136
6137 return 0;
6138}
6139
6140int radio::cdmaInfoRecInd(android::Parcel &p, int slotId, int requestNumber,
6141 int indicationType, int token, RIL_Errno e, void *response,
6142 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006143 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006144 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
6145 RLOGE("radio::cdmaInfoRecInd: invalid response");
6146 return 0;
6147 }
6148
Jack Yuf68e0da2017-02-07 14:53:09 -08006149 CdmaInformationRecords records = {};
Amit Mahajan1955c742016-12-29 07:07:54 -08006150 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
6151
6152 char* string8 = NULL;
6153 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
6154 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006155 RLOGE("radio::cdmaInfoRecInd: received %d recs which is more than %d, dropping "
6156 "additional ones", recordsRil->numberOfInfoRecs,
Amit Mahajan1955c742016-12-29 07:07:54 -08006157 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
6158 }
6159 records.infoRec.resize(num);
6160 for (int i = 0 ; i < num ; i++) {
6161 CdmaInformationRecord *record = &records.infoRec[i];
6162 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
6163 record->name = (CdmaInfoRecName) infoRec->name;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006164 // All vectors should be size 0 except one which will be size 1. Set everything to
6165 // size 0 initially.
6166 record->display.resize(0);
6167 record->number.resize(0);
6168 record->signal.resize(0);
6169 record->redir.resize(0);
6170 record->lineCtrl.resize(0);
6171 record->clir.resize(0);
6172 record->audioCtrl.resize(0);
Amit Mahajan1955c742016-12-29 07:07:54 -08006173 switch (infoRec->name) {
6174 case RIL_CDMA_DISPLAY_INFO_REC:
6175 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
6176 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006177 RLOGE("radio::cdmaInfoRecInd: invalid display info response length %d "
6178 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
Amit Mahajan1955c742016-12-29 07:07:54 -08006179 CDMA_ALPHA_INFO_BUFFER_LENGTH);
6180 return 0;
6181 }
6182 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
6183 if (string8 == NULL) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006184 RLOGE("radio::cdmaInfoRecInd: Memory allocation failed for "
6185 "responseCdmaInformationRecords");
Amit Mahajan1955c742016-12-29 07:07:54 -08006186 return 0;
6187 }
6188 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
6189 string8[(int)infoRec->rec.display.alpha_len] = '\0';
6190
6191 record->display.resize(1);
6192 record->display[0].alphaBuf = string8;
6193 free(string8);
6194 string8 = NULL;
6195 break;
6196 }
6197
6198 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
6199 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
6200 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
6201 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006202 RLOGE("radio::cdmaInfoRecInd: invalid display info response length %d "
6203 "expected not more than %d", (int) infoRec->rec.number.len,
Amit Mahajan1955c742016-12-29 07:07:54 -08006204 CDMA_NUMBER_INFO_BUFFER_LENGTH);
6205 return 0;
6206 }
6207 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
6208 if (string8 == NULL) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006209 RLOGE("radio::cdmaInfoRecInd: Memory allocation failed for "
6210 "responseCdmaInformationRecords");
Amit Mahajan1955c742016-12-29 07:07:54 -08006211 return 0;
6212 }
6213 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
6214 string8[(int)infoRec->rec.number.len] = '\0';
6215
6216 record->number.resize(1);
6217 record->number[0].number = string8;
6218 free(string8);
6219 string8 = NULL;
6220 record->number[0].numberType = infoRec->rec.number.number_type;
6221 record->number[0].numberPlan = infoRec->rec.number.number_plan;
6222 record->number[0].pi = infoRec->rec.number.pi;
6223 record->number[0].si = infoRec->rec.number.si;
6224 break;
6225 }
6226
6227 case RIL_CDMA_SIGNAL_INFO_REC: {
6228 record->signal.resize(1);
6229 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
6230 record->signal[0].signalType = infoRec->rec.signal.signalType;
6231 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
6232 record->signal[0].signal = infoRec->rec.signal.signal;
6233 break;
6234 }
6235
6236 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
6237 if (infoRec->rec.redir.redirectingNumber.len >
6238 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006239 RLOGE("radio::cdmaInfoRecInd: invalid display info response length %d "
6240 "expected not more than %d\n",
Amit Mahajan1955c742016-12-29 07:07:54 -08006241 (int)infoRec->rec.redir.redirectingNumber.len,
6242 CDMA_NUMBER_INFO_BUFFER_LENGTH);
6243 return 0;
6244 }
6245 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
6246 sizeof(char));
6247 if (string8 == NULL) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006248 RLOGE("radio::cdmaInfoRecInd: Memory allocation failed for "
6249 "responseCdmaInformationRecords");
Amit Mahajan1955c742016-12-29 07:07:54 -08006250 return 0;
6251 }
6252 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
6253 infoRec->rec.redir.redirectingNumber.len);
6254 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
6255
6256 record->redir.resize(1);
6257 record->redir[0].redirectingNumber.number = string8;
6258 free(string8);
6259 string8 = NULL;
6260 record->redir[0].redirectingNumber.numberType =
6261 infoRec->rec.redir.redirectingNumber.number_type;
6262 record->redir[0].redirectingNumber.numberPlan =
6263 infoRec->rec.redir.redirectingNumber.number_plan;
6264 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
6265 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
6266 record->redir[0].redirectingReason =
6267 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
6268 break;
6269 }
6270
6271 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
6272 record->lineCtrl.resize(1);
6273 record->lineCtrl[0].lineCtrlPolarityIncluded =
6274 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
6275 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
6276 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
6277 record->lineCtrl[0].lineCtrlPowerDenial =
6278 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
6279 break;
6280 }
6281
6282 case RIL_CDMA_T53_CLIR_INFO_REC: {
6283 record->clir.resize(1);
6284 record->clir[0].cause = infoRec->rec.clir.cause;
6285 break;
6286 }
6287
6288 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
6289 record->audioCtrl.resize(1);
6290 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
6291 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
6292 break;
6293 }
6294
6295 case RIL_CDMA_T53_RELEASE_INFO_REC:
6296 RLOGE("radio::cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
6297 return 0;
6298
6299 default:
6300 RLOGE("radio::cdmaInfoRecInd: Incorrect name value");
6301 return 0;
6302 }
6303 }
6304
6305 RLOGD("radio::cdmaInfoRecInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006306 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
Amit Mahajan1955c742016-12-29 07:07:54 -08006307 convertIntToRadioIndicationType(indicationType), records);
Amit Mahajan17249842017-01-19 15:05:45 -08006308 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006309 } else {
6310 RLOGE("radio::cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
6311 }
6312
6313 return 0;
6314}
6315
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006316int radio::indicateRingbackToneInd(android::Parcel &p, int slotId, int requestNumber,
6317 int indicationType, int token, RIL_Errno e, void *response,
6318 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006319 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006320 if (response == NULL || responseLen != sizeof(int)) {
6321 RLOGE("radio::indicateRingbackToneInd: invalid response");
6322 return 0;
6323 }
6324 bool start = ((int32_t *) response)[0];
6325 RLOGD("radio::indicateRingbackToneInd: start %d", start);
Amit Mahajan17249842017-01-19 15:05:45 -08006326 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006327 convertIntToRadioIndicationType(indicationType), start);
Amit Mahajan17249842017-01-19 15:05:45 -08006328 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006329 } else {
6330 RLOGE("radio::indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
6331 }
6332
6333 return 0;
6334}
6335
6336int radio::resendIncallMuteInd(android::Parcel &p, int slotId, int requestNumber,
6337 int indicationType, int token, RIL_Errno e, void *response,
6338 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006339 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006340 RLOGD("radio::resendIncallMuteInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006341 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006342 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006343 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006344 } else {
6345 RLOGE("radio::resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
6346 }
6347
6348 return 0;
6349}
6350
6351int radio::cdmaSubscriptionSourceChangedInd(android::Parcel &p, int slotId, int requestNumber,
6352 int indicationType, int token, RIL_Errno e,
6353 void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006354 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006355 if (response == NULL || responseLen != sizeof(int)) {
6356 RLOGE("radio::cdmaSubscriptionSourceChangedInd: invalid response");
6357 return 0;
6358 }
6359 int32_t cdmaSource = ((int32_t *) response)[0];
6360 RLOGD("radio::cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
Amit Mahajan17249842017-01-19 15:05:45 -08006361 Return<void> retStatus = radioService[slotId]->mRadioIndication->
6362 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006363 (CdmaSubscriptionSource) cdmaSource);
Amit Mahajan17249842017-01-19 15:05:45 -08006364 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006365 } else {
6366 RLOGE("radio::cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
6367 slotId);
6368 }
6369
6370 return 0;
6371}
6372
6373int radio::cdmaPrlChangedInd(android::Parcel &p, int slotId, int requestNumber,
6374 int indicationType, int token, RIL_Errno e, void *response,
6375 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006376 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006377 if (response == NULL || responseLen != sizeof(int)) {
6378 RLOGE("radio::cdmaPrlChangedInd: invalid response");
6379 return 0;
6380 }
6381 int32_t version = ((int32_t *) response)[0];
6382 RLOGD("radio::cdmaPrlChangedInd: version %d", version);
Amit Mahajan17249842017-01-19 15:05:45 -08006383 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006384 convertIntToRadioIndicationType(indicationType), version);
Amit Mahajan17249842017-01-19 15:05:45 -08006385 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006386 } else {
6387 RLOGE("radio::cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6388 }
6389
6390 return 0;
6391}
6392
6393int radio::exitEmergencyCallbackModeInd(android::Parcel &p, int slotId, int requestNumber,
6394 int indicationType, int token, RIL_Errno e, void *response,
6395 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006396 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006397 RLOGD("radio::exitEmergencyCallbackModeInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006398 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006399 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006400 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006401 } else {
6402 RLOGE("radio::exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
6403 slotId);
6404 }
6405
6406 return 0;
6407}
6408
6409int radio::rilConnectedInd(android::Parcel &p, int slotId, int requestNumber,
6410 int indicationType, int token, RIL_Errno e, void *response,
6411 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006412 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006413 RLOGD("radio::rilConnectedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006414 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006415 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006416 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006417 } else {
6418 RLOGE("radio::rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6419 }
6420
6421 return 0;
6422}
6423
6424int radio::voiceRadioTechChangedInd(android::Parcel &p, int slotId, int requestNumber,
6425 int indicationType, int token, RIL_Errno e, void *response,
6426 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006427 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006428 if (response == NULL || responseLen != sizeof(int)) {
6429 RLOGE("radio::voiceRadioTechChangedInd: invalid response");
6430 return 0;
6431 }
6432 int32_t rat = ((int32_t *) response)[0];
6433 RLOGD("radio::voiceRadioTechChangedInd: rat %d", rat);
Amit Mahajan17249842017-01-19 15:05:45 -08006434 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006435 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
Amit Mahajan17249842017-01-19 15:05:45 -08006436 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006437 } else {
6438 RLOGE("radio::voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
6439 slotId);
6440 }
6441
6442 return 0;
6443}
6444
6445void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
6446 int num = responseLen / sizeof(RIL_CellInfo_v12);
6447 records.resize(num);
6448
6449 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
6450 for (int i = 0; i < num; i++) {
6451 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
6452 records[i].registered = rillCellInfo->registered;
6453 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
6454 records[i].timeStamp = rillCellInfo->timeStamp;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006455 // All vectors should be size 0 except one which will be size 1. Set everything to
6456 // size 0 initially.
6457 records[i].gsm.resize(0);
6458 records[i].wcdma.resize(0);
6459 records[i].cdma.resize(0);
6460 records[i].lte.resize(0);
6461 records[i].tdscdma.resize(0);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006462 switch(rillCellInfo->cellInfoType) {
6463 case RIL_CELL_INFO_TYPE_GSM: {
6464 records[i].gsm.resize(1);
6465 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
6466 cellInfoGsm->cellIdentityGsm.mcc =
6467 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
6468 cellInfoGsm->cellIdentityGsm.mnc =
6469 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
6470 cellInfoGsm->cellIdentityGsm.lac =
6471 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
6472 cellInfoGsm->cellIdentityGsm.cid =
6473 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
6474 cellInfoGsm->cellIdentityGsm.arfcn =
6475 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
6476 cellInfoGsm->cellIdentityGsm.bsic =
6477 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
6478 cellInfoGsm->signalStrengthGsm.signalStrength =
6479 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
6480 cellInfoGsm->signalStrengthGsm.bitErrorRate =
6481 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
6482 cellInfoGsm->signalStrengthGsm.timingAdvance =
6483 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
6484 break;
6485 }
6486
6487 case RIL_CELL_INFO_TYPE_WCDMA: {
6488 records[i].wcdma.resize(1);
6489 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
6490 cellInfoWcdma->cellIdentityWcdma.mcc =
6491 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
6492 cellInfoWcdma->cellIdentityWcdma.mnc =
6493 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
6494 cellInfoWcdma->cellIdentityWcdma.lac =
6495 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
6496 cellInfoWcdma->cellIdentityWcdma.cid =
6497 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
6498 cellInfoWcdma->cellIdentityWcdma.psc =
6499 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
6500 cellInfoWcdma->cellIdentityWcdma.uarfcn =
6501 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
6502 cellInfoWcdma->signalStrengthWcdma.signalStrength =
6503 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
6504 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
6505 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
6506 break;
6507 }
6508
6509 case RIL_CELL_INFO_TYPE_CDMA: {
6510 records[i].cdma.resize(1);
6511 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
6512 cellInfoCdma->cellIdentityCdma.networkId =
6513 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
6514 cellInfoCdma->cellIdentityCdma.systemId =
6515 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
6516 cellInfoCdma->cellIdentityCdma.baseStationId =
6517 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
6518 cellInfoCdma->cellIdentityCdma.longitude =
6519 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
6520 cellInfoCdma->cellIdentityCdma.latitude =
6521 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
6522 cellInfoCdma->signalStrengthCdma.dbm =
6523 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
6524 cellInfoCdma->signalStrengthCdma.ecio =
6525 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
6526 cellInfoCdma->signalStrengthEvdo.dbm =
6527 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
6528 cellInfoCdma->signalStrengthEvdo.ecio =
6529 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
6530 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
6531 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
6532 break;
6533 }
6534
6535 case RIL_CELL_INFO_TYPE_LTE: {
6536 records[i].lte.resize(1);
6537 CellInfoLte *cellInfoLte = &records[i].lte[0];
6538 cellInfoLte->cellIdentityLte.mcc =
6539 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
6540 cellInfoLte->cellIdentityLte.mnc =
6541 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
6542 cellInfoLte->cellIdentityLte.ci =
6543 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
6544 cellInfoLte->cellIdentityLte.pci =
6545 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
6546 cellInfoLte->cellIdentityLte.tac =
6547 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
6548 cellInfoLte->cellIdentityLte.earfcn =
6549 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
6550 cellInfoLte->signalStrengthLte.signalStrength =
6551 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
6552 cellInfoLte->signalStrengthLte.rsrp =
6553 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
6554 cellInfoLte->signalStrengthLte.rsrq =
6555 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
6556 cellInfoLte->signalStrengthLte.rssnr =
6557 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
6558 cellInfoLte->signalStrengthLte.cqi =
6559 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
6560 cellInfoLte->signalStrengthLte.timingAdvance =
6561 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
6562 break;
6563 }
6564
6565 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
6566 records[i].tdscdma.resize(1);
6567 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
6568 cellInfoTdscdma->cellIdentityTdscdma.mcc =
6569 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
6570 cellInfoTdscdma->cellIdentityTdscdma.mnc =
6571 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
6572 cellInfoTdscdma->cellIdentityTdscdma.lac =
6573 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
6574 cellInfoTdscdma->cellIdentityTdscdma.cid =
6575 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
6576 cellInfoTdscdma->cellIdentityTdscdma.cpid =
6577 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
6578 cellInfoTdscdma->signalStrengthTdscdma.rscp =
6579 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
6580 break;
6581 }
6582 }
6583 rillCellInfo += 1;
6584 }
6585}
6586
6587int radio::cellInfoListInd(android::Parcel &p, int slotId, int requestNumber,
6588 int indicationType, int token, RIL_Errno e, void *response,
6589 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006590 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006591 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
6592 RLOGE("radio::cellInfoListInd: invalid response");
6593 return 0;
6594 }
6595
6596 hidl_vec<CellInfo> records;
6597 convertRilCellInfoListToHal(response, responseLen, records);
6598
6599 RLOGD("radio::cellInfoListInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006600 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006601 convertIntToRadioIndicationType(indicationType), records);
Amit Mahajan17249842017-01-19 15:05:45 -08006602 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006603 } else {
6604 RLOGE("radio::cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
6605 }
6606
6607 return 0;
6608}
6609
6610int radio::imsNetworkStateChangedInd(android::Parcel &p, int slotId, int requestNumber,
6611 int indicationType, int token, RIL_Errno e, void *response,
6612 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006613 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006614 RLOGD("radio::imsNetworkStateChangedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006615 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006616 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006617 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006618 } else {
6619 RLOGE("radio::imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6620 slotId);
6621 }
6622
6623 return 0;
6624}
6625
6626int radio::subscriptionStatusChangedInd(android::Parcel &p, int slotId, int requestNumber,
6627 int indicationType, int token, RIL_Errno e, void *response,
6628 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006629 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006630 if (response == NULL || responseLen != sizeof(int)) {
6631 RLOGE("radio::subscriptionStatusChangedInd: invalid response");
6632 return 0;
6633 }
6634 bool activate = ((int32_t *) response)[0];
6635 RLOGD("radio::subscriptionStatusChangedInd: activate %d", activate);
Amit Mahajan17249842017-01-19 15:05:45 -08006636 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006637 convertIntToRadioIndicationType(indicationType), activate);
Amit Mahajan17249842017-01-19 15:05:45 -08006638 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006639 } else {
6640 RLOGE("radio::subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
6641 slotId);
6642 }
6643
6644 return 0;
6645}
6646
6647int radio::srvccStateNotifyInd(android::Parcel &p, int slotId, int requestNumber,
6648 int indicationType, int token, RIL_Errno e, void *response,
6649 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006650 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006651 if (response == NULL || responseLen != sizeof(int)) {
6652 RLOGE("radio::srvccStateNotifyInd: invalid response");
6653 return 0;
6654 }
6655 int32_t state = ((int32_t *) response)[0];
6656 RLOGD("radio::srvccStateNotifyInd: rat %d", state);
Amit Mahajan17249842017-01-19 15:05:45 -08006657 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006658 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
Amit Mahajan17249842017-01-19 15:05:45 -08006659 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006660 } else {
6661 RLOGE("radio::srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6662 }
6663
6664 return 0;
6665}
6666
6667void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
6668 hidl_vec<HardwareConfig>& records) {
6669 int num = responseLen / sizeof(RIL_HardwareConfig);
6670 records.resize(num);
6671
6672 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
6673 for (int i = 0; i < num; i++) {
6674 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
6675 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
6676 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
6677 switch (rilHardwareConfig[i].type) {
6678 case RIL_HARDWARE_CONFIG_MODEM: {
6679 records[i].modem.resize(1);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006680 records[i].sim.resize(0);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006681 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
6682 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
6683 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
6684 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
6685 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
6686 break;
6687 }
6688
6689 case RIL_HARDWARE_CONFIG_SIM: {
6690 records[i].sim.resize(1);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006691 records[i].modem.resize(0);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006692 records[i].sim[0].modemUuid =
6693 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
6694 break;
6695 }
6696 }
6697 }
6698}
6699
6700int radio::hardwareConfigChangedInd(android::Parcel &p, int slotId, int requestNumber,
6701 int indicationType, int token, RIL_Errno e, void *response,
6702 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006703 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006704 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
6705 RLOGE("radio::hardwareConfigChangedInd: invalid response");
6706 return 0;
6707 }
6708
6709 hidl_vec<HardwareConfig> configs;
6710 convertRilHardwareConfigListToHal(response, responseLen, configs);
6711
6712 RLOGD("radio::hardwareConfigChangedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006713 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006714 convertIntToRadioIndicationType(indicationType), configs);
Amit Mahajan17249842017-01-19 15:05:45 -08006715 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006716 } else {
6717 RLOGE("radio::hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
6718 slotId);
6719 }
6720
6721 return 0;
6722}
6723
6724void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
6725 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
6726 rc.session = rilRadioCapability->session;
6727 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
6728 rc.raf = rilRadioCapability->rat;
6729 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
6730 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
6731}
6732
6733int radio::radioCapabilityIndicationInd(android::Parcel &p, int slotId, int requestNumber,
6734 int indicationType, int token, RIL_Errno e, void *response,
6735 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006736 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006737 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6738 RLOGE("radio::radioCapabilityIndicationInd: invalid response");
6739 return 0;
6740 }
6741
Jack Yuf68e0da2017-02-07 14:53:09 -08006742 RadioCapability rc = {};
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006743 convertRilRadioCapabilityToHal(response, responseLen, rc);
6744
6745 RLOGD("radio::radioCapabilityIndicationInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006746 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006747 convertIntToRadioIndicationType(indicationType), rc);
Amit Mahajan17249842017-01-19 15:05:45 -08006748 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006749 } else {
6750 RLOGE("radio::radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
6751 slotId);
6752 }
6753
6754 return 0;
6755}
6756
6757bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
6758 if ((reqType == SS_INTERROGATION) &&
6759 (serType == SS_CFU ||
6760 serType == SS_CF_BUSY ||
6761 serType == SS_CF_NO_REPLY ||
6762 serType == SS_CF_NOT_REACHABLE ||
6763 serType == SS_CF_ALL ||
6764 serType == SS_CF_ALL_CONDITIONAL)) {
6765 return true;
6766 }
6767 return false;
6768}
6769
6770int radio::onSupplementaryServiceIndicationInd(android::Parcel &p, int slotId, int requestNumber,
6771 int indicationType, int token, RIL_Errno e,
6772 void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006773 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006774 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
6775 RLOGE("radio::onSupplementaryServiceIndicationInd: invalid response");
6776 return 0;
6777 }
6778
6779 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
Jack Yuf68e0da2017-02-07 14:53:09 -08006780 StkCcUnsolSsResult ss = {};
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006781 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
6782 ss.requestType = (SsRequestType) rilSsResponse->requestType;
6783 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
6784 ss.serviceClass = rilSsResponse->serviceClass;
6785 ss.result = (RadioError) rilSsResponse->result;
6786
6787 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
6788 RLOGD("radio::onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
6789 rilSsResponse->cfData.numValidIndexes);
6790 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
6791 RLOGE("radio::onSupplementaryServiceIndicationInd numValidIndexes is greater than "
6792 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
6793 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
6794 }
6795
6796 ss.cfData.resize(1);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006797 ss.ssInfo.resize(0);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006798
6799 /* number of call info's */
6800 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
6801
6802 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
6803 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
6804 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
6805
6806 cfInfo->status = (CallForwardInfoStatus) cf.status;
6807 cfInfo->reason = cf.reason;
6808 cfInfo->serviceClass = cf.serviceClass;
6809 cfInfo->toa = cf.toa;
6810 cfInfo->number = convertCharPtrToHidlString(cf.number);
6811 cfInfo->timeSeconds = cf.timeSeconds;
6812 RLOGD("radio::onSupplementaryServiceIndicationInd: "
6813 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
6814 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
6815 }
6816 } else {
6817 ss.ssInfo.resize(1);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006818 ss.cfData.resize(0);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006819
6820 /* each int */
6821 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
6822 for (int i = 0; i < SS_INFO_MAX; i++) {
6823 RLOGD("radio::onSupplementaryServiceIndicationInd: Data: %d",
6824 rilSsResponse->ssInfo[i]);
6825 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
6826 }
6827 }
6828
6829 RLOGD("radio::onSupplementaryServiceIndicationInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006830 Return<void> retStatus = radioService[slotId]->mRadioIndication->
6831 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
6832 ss);
6833 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006834 } else {
6835 RLOGE("radio::onSupplementaryServiceIndicationInd: "
6836 "radioService[%d]->mRadioIndication == NULL", slotId);
6837 }
6838
6839 return 0;
6840}
6841
6842int radio::stkCallControlAlphaNotifyInd(android::Parcel &p, int slotId, int requestNumber,
6843 int indicationType, int token, RIL_Errno e, void *response,
6844 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006845 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006846 if (response == NULL || responseLen == 0) {
6847 RLOGE("radio::stkCallControlAlphaNotifyInd: invalid response");
6848 return 0;
6849 }
6850 RLOGD("radio::stkCallControlAlphaNotifyInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006851 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006852 convertIntToRadioIndicationType(indicationType),
6853 convertCharPtrToHidlString((char *) response));
Amit Mahajan17249842017-01-19 15:05:45 -08006854 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006855 } else {
6856 RLOGE("radio::stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
6857 slotId);
6858 }
6859
6860 return 0;
6861}
6862
6863void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
6864 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
6865 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
6866 lce.confidenceLevel = rilLceDataInfo->confidence_level;
6867 lce.lceSuspended = rilLceDataInfo->lce_suspended;
6868}
6869
6870int radio::lceDataInd(android::Parcel &p, int slotId, int requestNumber,
6871 int indicationType, int token, RIL_Errno e, void *response,
6872 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006873 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006874 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6875 RLOGE("radio::lceDataInd: invalid response");
6876 return 0;
6877 }
6878
Jack Yuf68e0da2017-02-07 14:53:09 -08006879 LceDataInfo lce = {};
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006880 convertRilLceDataInfoToHal(response, responseLen, lce);
6881 RLOGD("radio::lceDataInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006882 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006883 convertIntToRadioIndicationType(indicationType), lce);
Amit Mahajan17249842017-01-19 15:05:45 -08006884 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006885 } else {
6886 RLOGE("radio::lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
6887 }
6888
6889 return 0;
6890}
6891
6892int radio::pcoDataInd(android::Parcel &p, int slotId, int requestNumber,
6893 int indicationType, int token, RIL_Errno e, void *response,
6894 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006895 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006896 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
6897 RLOGE("radio::pcoDataInd: invalid response");
6898 return 0;
6899 }
6900
Jack Yuf68e0da2017-02-07 14:53:09 -08006901 PcoDataInfo pco = {};
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006902 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
6903 pco.cid = rilPcoData->cid;
6904 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
6905 pco.pcoId = rilPcoData->pco_id;
6906 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
6907
6908 RLOGD("radio::pcoDataInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006909 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006910 convertIntToRadioIndicationType(indicationType), pco);
Amit Mahajan17249842017-01-19 15:05:45 -08006911 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006912 } else {
6913 RLOGE("radio::pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
6914 }
6915
6916 return 0;
6917}
6918
6919int radio::modemResetInd(android::Parcel &p, int slotId, int requestNumber,
6920 int indicationType, int token, RIL_Errno e, void *response,
6921 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006922 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006923 if (response == NULL || responseLen == 0) {
6924 RLOGE("radio::modemResetInd: invalid response");
6925 return 0;
6926 }
6927 RLOGD("radio::modemResetInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006928 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006929 convertIntToRadioIndicationType(indicationType),
6930 convertCharPtrToHidlString((char *) response));
Amit Mahajan17249842017-01-19 15:05:45 -08006931 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006932 } else {
6933 RLOGE("radio::modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
6934 }
6935
6936 return 0;
6937}
6938
Amit Mahajan439da362017-02-13 17:43:04 -08006939int radio::oemHookRawInd(android::Parcel &p, int slotId, int requestNumber,
6940 int indicationType, int token, RIL_Errno e, void *response,
6941 size_t responseLen) {
6942 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
6943 if (response == NULL || responseLen == 0) {
6944 RLOGE("radio::oemHookRawInd: invalid response");
6945 return 0;
6946 }
6947
6948 hidl_vec<uint8_t> data;
6949 data.setToExternal((uint8_t *) response, responseLen);
6950 RLOGD("radio::oemHookRawInd");
6951 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
6952 convertIntToRadioIndicationType(indicationType), data);
6953 checkReturnStatus(slotId, retStatus);
6954 } else {
6955 RLOGE("radio::oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
6956 }
6957
6958 return 0;
6959}
6960
Amit Mahajancd77a5b2016-08-25 11:19:21 -07006961void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
6962 using namespace android::hardware;
6963 int simCount = 1;
Amit Mahajan439da362017-02-13 17:43:04 -08006964 const char *serviceNames[] = {
Amit Mahajancd77a5b2016-08-25 11:19:21 -07006965 android::RIL_getRilSocketName()
6966 #if (SIM_COUNT >= 2)
6967 , SOCKET2_NAME_RIL
6968 #if (SIM_COUNT >= 3)
6969 , SOCKET3_NAME_RIL
6970 #if (SIM_COUNT >= 4)
6971 , SOCKET4_NAME_RIL
6972 #endif
6973 #endif
6974 #endif
6975 };
6976
Amit Mahajan439da362017-02-13 17:43:04 -08006977 const char *oemHookServiceNames[] = {
6978 OEM_HOOK_SERVICE_NAME
6979 #if (SIM_COUNT >= 2)
6980 , OEM_HOOK2_SERVICE_NAME
6981 #if (SIM_COUNT >= 3)
6982 , OEM_HOOK3_SERVICE_NAME
6983 #if (SIM_COUNT >= 4)
6984 , OEM_HOOK4_SERVICE_NAME
6985 #endif
6986 #endif
6987 #endif
6988 };
6989
Amit Mahajancd77a5b2016-08-25 11:19:21 -07006990 #if (SIM_COUNT >= 2)
6991 simCount = SIM_COUNT;
6992 #endif
6993
6994 configureRpcThreadpool(1, true /* callerWillJoin */);
6995 for (int i = 0; i < simCount; i++) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006996 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
6997 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
6998 assert(ret == 0);
6999
Amit Mahajancd77a5b2016-08-25 11:19:21 -07007000 radioService[i] = new RadioImpl;
Sanket Padawef220dc52017-01-02 23:46:00 -08007001 radioService[i]->mSlotId = i;
Amit Mahajan439da362017-02-13 17:43:04 -08007002 oemHookService[i] = new OemHookImpl;
7003 oemHookService[i]->mSlotId = i;
Amit Mahajan5829a472016-12-28 17:28:07 -08007004 RLOGD("radio::registerService: starting IRadio %s", serviceNames[i]);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07007005 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
Amit Mahajan439da362017-02-13 17:43:04 -08007006 status = oemHookService[i]->registerAsService(oemHookServiceNames[i]);
Amit Mahajan932e08e2017-01-24 05:45:02 -08007007
7008 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
7009 assert(ret == 0);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07007010 }
7011
Sanket Padawe378ccdd2017-01-24 14:11:12 -08007012 s_vendorFunctions = callbacks;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07007013 s_commands = commands;
7014}
7015
7016void rilc_thread_pool() {
7017 joinRpcThreadpool();
Amit Mahajan932e08e2017-01-24 05:45:02 -08007018}
7019
7020pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
7021 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
7022
7023 #if (SIM_COUNT >= 2)
7024 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
7025 #if (SIM_COUNT >= 3)
7026 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
7027 #if (SIM_COUNT >= 4)
7028 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
7029 #endif
7030 #endif
7031 #endif
7032
7033 return radioServiceRwlockPtr;
Sanket Padawe0de29d12017-02-10 13:19:47 -08007034}