blob: 0618aa965c72454c143bdb57ec7dd4fa364ce08d [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
Amit Mahajan34b33aa2017-03-01 11:13:15 -080017#define LOG_TAG "RILC"
18
Amit Mahajancd77a5b2016-08-25 11:19:21 -070019#include <android/hardware/radio/1.0/IRadio.h>
Amit Mahajan439da362017-02-13 17:43:04 -080020#include <android/hardware/radio/deprecated/1.0/IOemHook.h>
Amit Mahajancd77a5b2016-08-25 11:19:21 -070021
22#include <hwbinder/IPCThreadState.h>
23#include <hwbinder/ProcessState.h>
24#include <ril_service.h>
25#include <hidl/HidlTransportSupport.h>
Amit Mahajan5829a472016-12-28 17:28:07 -080026#include <utils/SystemClock.h>
Wei Wang100ac9b2017-02-03 14:18:07 -080027#include <inttypes.h>
Amit Mahajan5829a472016-12-28 17:28:07 -080028
29#define INVALID_HEX_CHAR 16
Amit Mahajancd77a5b2016-08-25 11:19:21 -070030
31using namespace android::hardware::radio::V1_0;
Amit Mahajan439da362017-02-13 17:43:04 -080032using namespace android::hardware::radio::deprecated::V1_0;
Amit Mahajancd77a5b2016-08-25 11:19:21 -070033using ::android::hardware::configureRpcThreadpool;
34using ::android::hardware::joinRpcThreadpool;
35using ::android::hardware::Return;
Amit Mahajancd77a5b2016-08-25 11:19:21 -070036using ::android::hardware::hidl_string;
37using ::android::hardware::hidl_vec;
38using ::android::hardware::hidl_array;
39using ::android::hardware::Void;
40using android::CommandInfo;
41using android::RequestInfo;
42using android::requestToString;
43using android::sp;
44
Sanket Padawe378ccdd2017-01-24 14:11:12 -080045#define BOOL_TO_INT(x) (x ? 1 : 0)
46#define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
47#define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
48
49RIL_RadioFunctions *s_vendorFunctions = NULL;
Amit Mahajancd77a5b2016-08-25 11:19:21 -070050static CommandInfo *s_commands;
51
52struct RadioImpl;
Amit Mahajan439da362017-02-13 17:43:04 -080053struct OemHookImpl;
Amit Mahajancd77a5b2016-08-25 11:19:21 -070054
55#if (SIM_COUNT >= 2)
56sp<RadioImpl> radioService[SIM_COUNT];
Amit Mahajan439da362017-02-13 17:43:04 -080057sp<OemHookImpl> oemHookService[SIM_COUNT];
58// counter used for synchronization. It is incremented every time response callbacks are updated.
Amit Mahajand423d192017-03-16 17:04:01 -070059volatile int32_t mCounterRadio[SIM_COUNT];
60volatile int32_t mCounterOemHook[SIM_COUNT];
Amit Mahajancd77a5b2016-08-25 11:19:21 -070061#else
62sp<RadioImpl> radioService[1];
Amit Mahajan439da362017-02-13 17:43:04 -080063sp<OemHookImpl> oemHookService[1];
64// counter used for synchronization. It is incremented every time response callbacks are updated.
Amit Mahajand423d192017-03-16 17:04:01 -070065volatile int32_t mCounterRadio[1];
66volatile int32_t mCounterOemHook[1];
Amit Mahajancd77a5b2016-08-25 11:19:21 -070067#endif
68
Amit Mahajan932e08e2017-01-24 05:45:02 -080069static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
70
71#if (SIM_COUNT >= 2)
72static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
73#if (SIM_COUNT >= 3)
74static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
75#if (SIM_COUNT >= 4)
76static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
77#endif
78#endif
79#endif
80
Amit Mahajan3df62912017-02-10 01:35:55 +000081void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
82 hidl_vec<HardwareConfig>& records);
83
84void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
85
86void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
87
88void convertRilSignalStrengthToHal(void *response, size_t responseLen,
89 SignalStrength& signalStrength);
90
91void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
92 SetupDataCallResult& dcResult);
93
94void convertRilDataCallListToHal(void *response, size_t responseLen,
95 hidl_vec<SetupDataCallResult>& dcResultList);
96
97void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
98
Amit Mahajancd77a5b2016-08-25 11:19:21 -070099struct RadioImpl : public IRadio {
Sanket Padawef220dc52017-01-02 23:46:00 -0800100 int32_t mSlotId;
101 sp<IRadioResponse> mRadioResponse;
102 sp<IRadioIndication> mRadioIndication;
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700103
104 Return<void> setResponseFunctions(
105 const ::android::sp<IRadioResponse>& radioResponse,
106 const ::android::sp<IRadioIndication>& radioIndication);
107
108 Return<void> getIccCardStatus(int32_t serial);
109
Sanket Padawef220dc52017-01-02 23:46:00 -0800110 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
111 const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700112
Sanket Padawef220dc52017-01-02 23:46:00 -0800113 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
114 const hidl_string& pin, const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700115
116 Return<void> supplyIccPin2ForApp(int32_t serial,
Sanket Padawef220dc52017-01-02 23:46:00 -0800117 const hidl_string& pin2,
118 const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700119
Sanket Padawef220dc52017-01-02 23:46:00 -0800120 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
121 const hidl_string& pin2, const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700122
Sanket Padawef220dc52017-01-02 23:46:00 -0800123 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
124 const hidl_string& newPin, const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700125
Sanket Padawef220dc52017-01-02 23:46:00 -0800126 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
127 const hidl_string& newPin2, const hidl_string& aid);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700128
Sanket Padawef220dc52017-01-02 23:46:00 -0800129 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700130
131 Return<void> getCurrentCalls(int32_t serial);
132
Sanket Padawef220dc52017-01-02 23:46:00 -0800133 Return<void> dial(int32_t serial, const Dial& dialInfo);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700134
135 Return<void> getImsiForApp(int32_t serial,
136 const ::android::hardware::hidl_string& aid);
137
138 Return<void> hangup(int32_t serial, int32_t gsmIndex);
139
140 Return<void> hangupWaitingOrBackground(int32_t serial);
141
142 Return<void> hangupForegroundResumeBackground(int32_t serial);
143
144 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
145
146 Return<void> conference(int32_t serial);
147
148 Return<void> rejectCall(int32_t serial);
149
150 Return<void> getLastCallFailCause(int32_t serial);
151
152 Return<void> getSignalStrength(int32_t serial);
153
154 Return<void> getVoiceRegistrationState(int32_t serial);
155
156 Return<void> getDataRegistrationState(int32_t serial);
157
158 Return<void> getOperator(int32_t serial);
159
160 Return<void> setRadioPower(int32_t serial, bool on);
161
162 Return<void> sendDtmf(int32_t serial,
163 const ::android::hardware::hidl_string& s);
164
165 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
166
167 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
168
169 Return<void> setupDataCall(int32_t serial,
Jack Yu06181bb2017-01-10 12:10:41 -0800170 RadioTechnology radioTechnology,
171 const DataProfileInfo& profileInfo,
172 bool modemCognitive,
Jack Yuffc06452017-02-13 11:21:00 -0800173 bool roamingAllowed,
174 bool isRoaming);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700175
176 Return<void> iccIOForApp(int32_t serial,
177 const IccIo& iccIo);
178
179 Return<void> sendUssd(int32_t serial,
180 const ::android::hardware::hidl_string& ussd);
181
182 Return<void> cancelPendingUssd(int32_t serial);
183
184 Return<void> getClir(int32_t serial);
185
186 Return<void> setClir(int32_t serial, int32_t status);
187
188 Return<void> getCallForwardStatus(int32_t serial,
189 const CallForwardInfo& callInfo);
190
191 Return<void> setCallForward(int32_t serial,
192 const CallForwardInfo& callInfo);
193
194 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
195
196 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
197
198 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
199 bool success, SmsAcknowledgeFailCause cause);
200
201 Return<void> acceptCall(int32_t serial);
202
203 Return<void> deactivateDataCall(int32_t serial,
204 int32_t cid, bool reasonRadioShutDown);
205
206 Return<void> getFacilityLockForApp(int32_t serial,
207 const ::android::hardware::hidl_string& facility,
208 const ::android::hardware::hidl_string& password,
209 int32_t serviceClass,
210 const ::android::hardware::hidl_string& appId);
211
212 Return<void> setFacilityLockForApp(int32_t serial,
213 const ::android::hardware::hidl_string& facility,
214 bool lockState,
215 const ::android::hardware::hidl_string& password,
216 int32_t serviceClass,
217 const ::android::hardware::hidl_string& appId);
218
219 Return<void> setBarringPassword(int32_t serial,
220 const ::android::hardware::hidl_string& facility,
221 const ::android::hardware::hidl_string& oldPassword,
222 const ::android::hardware::hidl_string& newPassword);
223
224 Return<void> getNetworkSelectionMode(int32_t serial);
225
226 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
227
228 Return<void> setNetworkSelectionModeManual(int32_t serial,
229 const ::android::hardware::hidl_string& operatorNumeric);
230
231 Return<void> getAvailableNetworks(int32_t serial);
232
233 Return<void> startDtmf(int32_t serial,
234 const ::android::hardware::hidl_string& s);
235
236 Return<void> stopDtmf(int32_t serial);
237
238 Return<void> getBasebandVersion(int32_t serial);
239
240 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
241
242 Return<void> setMute(int32_t serial, bool enable);
243
244 Return<void> getMute(int32_t serial);
245
246 Return<void> getClip(int32_t serial);
247
248 Return<void> getDataCallList(int32_t serial);
249
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700250 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
251
252 Return<void> writeSmsToSim(int32_t serial,
253 const SmsWriteArgs& smsWriteArgs);
254
255 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
256
257 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
258
259 Return<void> getAvailableBandModes(int32_t serial);
260
261 Return<void> sendEnvelope(int32_t serial,
262 const ::android::hardware::hidl_string& command);
263
264 Return<void> sendTerminalResponseToSim(int32_t serial,
265 const ::android::hardware::hidl_string& commandResponse);
266
267 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
268
269 Return<void> explicitCallTransfer(int32_t serial);
270
271 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
272
273 Return<void> getPreferredNetworkType(int32_t serial);
274
275 Return<void> getNeighboringCids(int32_t serial);
276
277 Return<void> setLocationUpdates(int32_t serial, bool enable);
278
279 Return<void> setCdmaSubscriptionSource(int32_t serial,
280 CdmaSubscriptionSource cdmaSub);
281
282 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
283
284 Return<void> getCdmaRoamingPreference(int32_t serial);
285
286 Return<void> setTTYMode(int32_t serial, TtyMode mode);
287
288 Return<void> getTTYMode(int32_t serial);
289
290 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
291
292 Return<void> getPreferredVoicePrivacy(int32_t serial);
293
294 Return<void> sendCDMAFeatureCode(int32_t serial,
295 const ::android::hardware::hidl_string& featureCode);
296
297 Return<void> sendBurstDtmf(int32_t serial,
298 const ::android::hardware::hidl_string& dtmf,
299 int32_t on,
300 int32_t off);
301
302 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
303
304 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
305 const CdmaSmsAck& smsAck);
306
307 Return<void> getGsmBroadcastConfig(int32_t serial);
308
309 Return<void> setGsmBroadcastConfig(int32_t serial,
310 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
311
312 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
313
314 Return<void> getCdmaBroadcastConfig(int32_t serial);
315
316 Return<void> setCdmaBroadcastConfig(int32_t serial,
317 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
318
319 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
320
321 Return<void> getCDMASubscription(int32_t serial);
322
323 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
324
325 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
326
327 Return<void> getDeviceIdentity(int32_t serial);
328
329 Return<void> exitEmergencyCallbackMode(int32_t serial);
330
331 Return<void> getSmscAddress(int32_t serial);
332
333 Return<void> setSmscAddress(int32_t serial,
334 const ::android::hardware::hidl_string& smsc);
335
336 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
337
338 Return<void> reportStkServiceIsRunning(int32_t serial);
339
340 Return<void> getCdmaSubscriptionSource(int32_t serial);
341
342 Return<void> requestIsimAuthentication(int32_t serial,
343 const ::android::hardware::hidl_string& challenge);
344
345 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
346 bool success,
347 const ::android::hardware::hidl_string& ackPdu);
348
349 Return<void> sendEnvelopeWithStatus(int32_t serial,
350 const ::android::hardware::hidl_string& contents);
351
352 Return<void> getVoiceRadioTechnology(int32_t serial);
353
354 Return<void> getCellInfoList(int32_t serial);
355
356 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
357
Jack Yu06181bb2017-01-10 12:10:41 -0800358 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
Jack Yuffc06452017-02-13 11:21:00 -0800359 bool modemCognitive, bool isRoaming);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700360
361 Return<void> getImsRegistrationState(int32_t serial);
362
363 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
364
365 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
366
367 Return<void> iccOpenLogicalChannel(int32_t serial,
368 const ::android::hardware::hidl_string& aid);
369
370 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
371
372 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
373
374 Return<void> nvReadItem(int32_t serial, NvItem itemId);
375
376 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
377
378 Return<void> nvWriteCdmaPrl(int32_t serial,
379 const ::android::hardware::hidl_vec<uint8_t>& prl);
380
381 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
382
383 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
384
385 Return<void> setDataAllowed(int32_t serial, bool allow);
386
387 Return<void> getHardwareConfig(int32_t serial);
388
389 Return<void> requestIccSimAuthentication(int32_t serial,
390 int32_t authContext,
391 const ::android::hardware::hidl_string& authData,
392 const ::android::hardware::hidl_string& aid);
393
394 Return<void> setDataProfile(int32_t serial,
Jack Yuffc06452017-02-13 11:21:00 -0800395 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700396
397 Return<void> requestShutdown(int32_t serial);
398
399 Return<void> getRadioCapability(int32_t serial);
400
401 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
402
403 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
404
405 Return<void> stopLceService(int32_t serial);
406
407 Return<void> pullLceData(int32_t serial);
408
409 Return<void> getModemActivityInfo(int32_t serial);
410
411 Return<void> setAllowedCarriers(int32_t serial,
412 bool allAllowed,
413 const CarrierRestrictions& carriers);
414
415 Return<void> getAllowedCarriers(int32_t serial);
416
Jack Yu06181bb2017-01-10 12:10:41 -0800417 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
418
419 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
420
Wileen Chiu718c0bf2017-01-04 11:37:19 -0800421 Return<void> setSimCardPower(int32_t serial, bool powerUp);
422
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700423 Return<void> responseAcknowledgement();
Amit Mahajan17249842017-01-19 15:05:45 -0800424
425 void checkReturnStatus(Return<void>& ret);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700426};
427
Amit Mahajan439da362017-02-13 17:43:04 -0800428struct OemHookImpl : public IOemHook {
429 int32_t mSlotId;
430 sp<IOemHookResponse> mOemHookResponse;
431 sp<IOemHookIndication> mOemHookIndication;
432
433 Return<void> setResponseFunctions(
434 const ::android::sp<IOemHookResponse>& oemHookResponse,
435 const ::android::sp<IOemHookIndication>& oemHookIndication);
436
437 Return<void> sendRequestRaw(int32_t serial,
438 const ::android::hardware::hidl_vec<uint8_t>& data);
439
440 Return<void> sendRequestStrings(int32_t serial,
441 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
442};
443
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800444void memsetAndFreeStrings(int numPointers, ...) {
445 va_list ap;
446 va_start(ap, numPointers);
447 for (int i = 0; i < numPointers; i++) {
448 char *ptr = va_arg(ap, char *);
449 if (ptr) {
450#ifdef MEMSET_FREED
Jack Yuffc06452017-02-13 11:21:00 -0800451 // TODO: Should pass in the maximum length of the string
452 memsetString(ptr);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800453#endif
454 free(ptr);
455 }
456 }
457 va_end(ap);
458}
459
Jack Yuffc06452017-02-13 11:21:00 -0800460void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
Amit Mahajan759786a2017-03-03 17:35:47 -0800461 pRI->pCI->responseFunction((int) pRI->socket_id,
Jack Yuffc06452017-02-13 11:21:00 -0800462 (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 Mahajand423d192017-03-16 17:04:01 -0700700void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
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 Mahajand423d192017-03-16 17:04:01 -0700710 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
Amit Mahajan439da362017-02-13 17:43:04 -0800711 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 Mahajand423d192017-03-16 17:04:01 -0700720 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
721 if (isRadioService) {
722 radioService[slotId]->mRadioResponse = NULL;
723 radioService[slotId]->mRadioIndication = NULL;
724 } else {
725 oemHookService[slotId]->mOemHookResponse = NULL;
726 oemHookService[slotId]->mOemHookIndication = NULL;
727 }
728 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
Amit Mahajan932e08e2017-01-24 05:45:02 -0800729 } else {
Amit Mahajan439da362017-02-13 17:43:04 -0800730 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800731 "got updated on another thread");
Amit Mahajan932e08e2017-01-24 05:45:02 -0800732 }
733
734 // release wrlock
735 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
736 assert(ret == 0);
737
738 // Reacquire rdlock
739 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
740 assert(ret == 0);
Amit Mahajan17249842017-01-19 15:05:45 -0800741 }
742}
743
Amit Mahajan439da362017-02-13 17:43:04 -0800744void RadioImpl::checkReturnStatus(Return<void>& ret) {
Amit Mahajand423d192017-03-16 17:04:01 -0700745 ::checkReturnStatus(mSlotId, ret, true);
Amit Mahajan439da362017-02-13 17:43:04 -0800746}
747
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700748Return<void> RadioImpl::setResponseFunctions(
749 const ::android::sp<IRadioResponse>& radioResponseParam,
750 const ::android::sp<IRadioIndication>& radioIndicationParam) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800751 RLOGD("setResponseFunctions");
Amit Mahajan932e08e2017-01-24 05:45:02 -0800752
753 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
754 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
755 assert(ret == 0);
756
Sanket Padawef220dc52017-01-02 23:46:00 -0800757 mRadioResponse = radioResponseParam;
758 mRadioIndication = radioIndicationParam;
Amit Mahajand423d192017-03-16 17:04:01 -0700759 mCounterRadio[mSlotId]++;
Amit Mahajan932e08e2017-01-24 05:45:02 -0800760
761 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
762 assert(ret == 0);
763
Amit Mahajan60482fd2017-03-14 16:39:27 -0700764 // client is connected. Send initial indications.
765 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
766
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800767 return Void();
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700768}
769
770Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800771 RLOGD("getIccCardStatus: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800772 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
773 return Void();
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700774}
775
Sanket Padawef220dc52017-01-02 23:46:00 -0800776Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
777 const hidl_string& aid) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800778 RLOGD("supplyIccPinForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800779 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
780 2, (const char *)pin, (const char *)aid);
781 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800782}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700783
Sanket Padawef220dc52017-01-02 23:46:00 -0800784Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800785 const hidl_string& pin, const hidl_string& aid) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800786 RLOGD("supplyIccPukForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800787 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
788 3, (const char *)puk, (const char *)pin, (const char *)aid);
789 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800790}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700791
Sanket Padawef220dc52017-01-02 23:46:00 -0800792Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800793 const hidl_string& aid) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800794 RLOGD("supplyIccPin2ForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800795 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
796 2, (const char *)pin2, (const char *)aid);
797 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800798}
799
800Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800801 const hidl_string& pin2, const hidl_string& aid) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800802 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800803 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
804 3, (const char *)puk2, (const char *)pin2, (const char *)aid);
805 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800806}
807
808Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800809 const hidl_string& newPin, const hidl_string& aid) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800810 RLOGD("changeIccPinForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800811 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
812 3, (const char *)oldPin, (const char *)newPin, (const char *)aid);
813 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800814}
815
816Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800817 const hidl_string& newPin2, const hidl_string& aid) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800818 RLOGD("changeIccPin2ForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800819 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
820 3, (const char *)oldPin2, (const char *)newPin2, (const char *)aid);
821 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800822}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700823
824Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800825 const hidl_string& netPin) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800826 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800827 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
828 1, (const char *)netPin);
829 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800830}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700831
Sanket Padawef220dc52017-01-02 23:46:00 -0800832Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800833 RLOGD("getCurrentCalls: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800834 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
835 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800836}
837
838Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800839 RLOGD("dial: serial %d", serial);
Sanket Padawef220dc52017-01-02 23:46:00 -0800840 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
841 if (pRI == NULL) {
842 return Void();
843 }
Jack Yuf68e0da2017-02-07 14:53:09 -0800844 RIL_Dial dial = {};
845 RIL_UUS_Info uusInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -0800846 int32_t sizeOfDial = sizeof(dial);
847
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800848 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
Sanket Padawef220dc52017-01-02 23:46:00 -0800849 return Void();
850 }
Jack Yuf68e0da2017-02-07 14:53:09 -0800851 dial.clir = (int) dialInfo.clir;
Sanket Padawef220dc52017-01-02 23:46:00 -0800852
Sanket Padawef220dc52017-01-02 23:46:00 -0800853 if (dialInfo.uusInfo.size() != 0) {
Sanket Padawef220dc52017-01-02 23:46:00 -0800854 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
855 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
856
857 if (dialInfo.uusInfo[0].uusData.size() == 0) {
858 uusInfo.uusData = NULL;
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800859 uusInfo.uusLength = 0;
Sanket Padawef220dc52017-01-02 23:46:00 -0800860 } else {
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800861 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
862 memsetAndFreeStrings(1, dial.address);
Sanket Padawef220dc52017-01-02 23:46:00 -0800863 return Void();
864 }
Jack Yuf68e0da2017-02-07 14:53:09 -0800865 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
Sanket Padawef220dc52017-01-02 23:46:00 -0800866 }
867
Sanket Padawef220dc52017-01-02 23:46:00 -0800868 dial.uusInfo = &uusInfo;
869 }
870
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800871 s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI);
Sanket Padawef220dc52017-01-02 23:46:00 -0800872
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800873 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
Sanket Padawef220dc52017-01-02 23:46:00 -0800874
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800875 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -0800876}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700877
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800878Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800879 RLOGD("getImsiForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800880 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
881 1, (const char *) aid);
882 return Void();
883}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700884
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800885Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800886 RLOGD("hangup: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800887 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
888 return Void();
889}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700890
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800891Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800892 RLOGD("hangupWaitingOrBackground: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800893 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
894 return Void();
895}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700896
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800897Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800898 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800899 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
900 return Void();
901}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700902
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800903Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800904 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800905 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
906 return Void();
907}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700908
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800909Return<void> RadioImpl::conference(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800910 RLOGD("conference: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800911 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
912 return Void();
913}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700914
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800915Return<void> RadioImpl::rejectCall(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800916 RLOGD("rejectCall: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800917 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
918 return Void();
919}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700920
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800921Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800922 RLOGD("getLastCallFailCause: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800923 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
924 return Void();
925}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700926
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800927Return<void> RadioImpl::getSignalStrength(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800928 RLOGD("getSignalStrength: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800929 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
930 return Void();
931}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700932
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800933Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800934 RLOGD("getVoiceRegistrationState: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800935 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
936 return Void();
937}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700938
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800939Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800940 RLOGD("getDataRegistrationState: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800941 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
942 return Void();
943}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700944
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800945Return<void> RadioImpl::getOperator(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800946 RLOGD("getOperator: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800947 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
948 return Void();
949}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700950
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800951Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800952 RLOGD("setRadioPower: serial %d on %d", serial, on);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800953 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
954 return Void();
955}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700956
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800957Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800958 RLOGD("sendDtmf: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800959 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, (const char *) s);
960 return Void();
961}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700962
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800963Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800964 RLOGD("sendSms: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800965 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
966 2, (const char *) message.smscPdu, (const char *) message.pdu);
967 return Void();
968}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700969
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800970Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
Amit Mahajan111ddca2017-03-03 12:05:13 -0800971 RLOGD("sendSMSExpectMore: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -0800972 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
973 2, (const char *) message.smscPdu, (const char *) message.pdu);
974 return Void();
975}
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700976
Jack Yuffc06452017-02-13 11:21:00 -0800977const char *convertMvnoTypeToString(MvnoType type) {
978 switch (type) {
979 case MvnoType::IMSI: return "imsi";
980 case MvnoType::GID: return "gid";
981 case MvnoType::SPN: return "spn";
982 default: return NULL;
983 }
984}
985
986Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
987 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
988 bool roamingAllowed, bool isRoaming) {
989
Amit Mahajan111ddca2017-03-03 12:05:13 -0800990 RLOGD("setupDataCall: serial %d", serial);
Amit Mahajancd77a5b2016-08-25 11:19:21 -0700991
Jack Yuffc06452017-02-13 11:21:00 -0800992 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
993 const hidl_string &protocol =
994 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
995 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
996 std::to_string((int) radioTechnology + 2).c_str(),
997 std::to_string((int) dataProfileInfo.profileId).c_str(),
998 dataProfileInfo.apn.c_str(),
999 dataProfileInfo.user.c_str(),
1000 dataProfileInfo.password.c_str(),
1001 std::to_string((int) dataProfileInfo.authType).c_str(),
1002 protocol.c_str());
1003 } else if (s_vendorFunctions->version >= 15) {
1004 const char *mvnoTypeStr = convertMvnoTypeToString(dataProfileInfo.mvnoType);
1005 if (mvnoTypeStr == NULL) {
1006 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1007 RIL_REQUEST_SETUP_DATA_CALL);
1008 if (pRI != NULL) {
1009 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1010 }
1011 return Void();
1012 }
1013 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1014 std::to_string((int) radioTechnology + 2).c_str(),
1015 std::to_string((int) dataProfileInfo.profileId).c_str(),
1016 dataProfileInfo.apn.c_str(),
1017 dataProfileInfo.user.c_str(),
1018 dataProfileInfo.password.c_str(),
1019 std::to_string((int) dataProfileInfo.authType).c_str(),
1020 dataProfileInfo.protocol.c_str(),
1021 dataProfileInfo.roamingProtocol.c_str(),
1022 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1023 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1024 BOOL_TO_INT(modemCognitive),
1025 std::to_string(dataProfileInfo.mtu).c_str(),
1026 mvnoTypeStr,
1027 dataProfileInfo.mvnoMatchData.c_str(),
1028 BOOL_TO_INT(roamingAllowed));
1029 } else {
1030 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1031 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1032 RIL_REQUEST_SETUP_DATA_CALL);
1033 if (pRI != NULL) {
1034 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1035 }
1036 }
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001037 return Void();
1038}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001039
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001040Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001041 RLOGD("iccIOForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001042 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1043 if (pRI == NULL) {
1044 return Void();
1045 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001046
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001047 RIL_SIM_IO_v6 rilIccIo;
1048 rilIccIo.command = iccIo.command;
1049 rilIccIo.fileid = iccIo.fileId;
1050 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1051 return Void();
1052 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001053
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001054 rilIccIo.p1 = iccIo.p1;
1055 rilIccIo.p2 = iccIo.p2;
1056 rilIccIo.p3 = iccIo.p3;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001057
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001058 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1059 memsetAndFreeStrings(1, rilIccIo.path);
1060 return Void();
1061 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001062
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001063 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1064 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1065 return Void();
1066 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001067
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001068 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1069 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1070 return Void();
1071 }
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001072
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001073 s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI);
1074
1075 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1076
1077 return Void();
1078}
1079
1080Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001081 RLOGD("sendUssd: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001082 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, (const char *) ussd);
1083 return Void();
1084}
1085
1086Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001087 RLOGD("cancelPendingUssd: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001088 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1089 return Void();
1090}
1091
1092Return<void> RadioImpl::getClir(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001093 RLOGD("getClir: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001094 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1095 return Void();
1096}
1097
1098Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001099 RLOGD("setClir: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001100 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1101 return Void();
1102}
1103
1104Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001105 RLOGD("getCallForwardStatus: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001106 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1107 callInfo);
1108 return Void();
1109}
1110
1111Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001112 RLOGD("setCallForward: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001113 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1114 callInfo);
1115 return Void();
1116}
1117
1118Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001119 RLOGD("getCallWaiting: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001120 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1121 return Void();
1122}
1123
1124Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001125 RLOGD("setCallWaiting: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001126 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1127 serviceClass);
1128 return Void();
1129}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001130
1131Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001132 bool success, SmsAcknowledgeFailCause cause) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001133 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001134 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1135 cause);
1136 return Void();
1137}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001138
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001139Return<void> RadioImpl::acceptCall(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001140 RLOGD("acceptCall: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001141 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1142 return Void();
1143}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001144
1145Return<void> RadioImpl::deactivateDataCall(int32_t serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001146 int32_t cid, bool reasonRadioShutDown) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001147 RLOGD("deactivateDataCall: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001148 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1149 2, (const char *) (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1150 return Void();
1151}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001152
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001153Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1154 const hidl_string& password, int32_t serviceClass,
1155 const hidl_string& appId) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001156 RLOGD("getFacilityLockForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001157 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1158 4, (const char *) facility, (const char *) password,
1159 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId);
1160 return Void();
1161}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001162
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001163Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1164 bool lockState, const hidl_string& password,
1165 int32_t serviceClass, const hidl_string& appId) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001166 RLOGD("setFacilityLockForApp: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001167 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1168 5, (const char *) facility, lockState ? "1" : "0", (const char *) password,
1169 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId);
1170 return Void();
1171}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001172
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001173Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1174 const hidl_string& oldPassword,
1175 const hidl_string& newPassword) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001176 RLOGD("setBarringPassword: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001177 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1178 2, (const char *) oldPassword, (const char *) newPassword);
1179 return Void();
1180}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001181
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001182Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001183 RLOGD("getNetworkSelectionMode: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001184 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1185 return Void();
1186}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001187
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001188Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001189 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001190 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1191 return Void();
1192}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001193
1194Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001195 const hidl_string& operatorNumeric) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001196 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001197 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1198 (const char *) operatorNumeric);
1199 return Void();
1200}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001201
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001202Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001203 RLOGD("getAvailableNetworks: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001204 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1205 return Void();
1206}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001207
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001208Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001209 RLOGD("startDtmf: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001210 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1211 (const char *) s);
1212 return Void();
1213}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001214
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001215Return<void> RadioImpl::stopDtmf(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001216 RLOGD("stopDtmf: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001217 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1218 return Void();
1219}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001220
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001221Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001222 RLOGD("getBasebandVersion: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001223 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1224 return Void();
1225}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001226
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001227Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001228 RLOGD("separateConnection: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001229 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1230 return Void();
1231}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001232
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001233Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001234 RLOGD("setMute: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001235 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1236 return Void();
1237}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001238
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001239Return<void> RadioImpl::getMute(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001240 RLOGD("getMute: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001241 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1242 return Void();
1243}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001244
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001245Return<void> RadioImpl::getClip(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001246 RLOGD("getClip: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001247 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1248 return Void();
1249}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07001250
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001251Return<void> RadioImpl::getDataCallList(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001252 RLOGD("getDataCallList: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001253 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001258 RLOGD("setSuppServiceNotifications: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001259 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001265 RLOGD("writeSmsToSim: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001266 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001292 RLOGD("deleteSmsOnSim: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001293 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001298 RLOGD("setBandMode: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001299 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1300 return Void();
1301}
1302
1303Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001304 RLOGD("getAvailableBandModes: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001305 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001310 RLOGD("sendEnvelope: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001311 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001318 RLOGD("sendTerminalResponseToSim: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001319 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001325 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001326 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001332 RLOGD("explicitCallTransfer: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001333 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001338 RLOGD("setPreferredNetworkType: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001339 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001344 RLOGD("getPreferredNetworkType: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001345 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001350 RLOGD("getNeighboringCids: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001351 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001356 RLOGD("setLocationUpdates: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001357 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001362 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001363 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001368 RLOGD("setCdmaRoamingPreference: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001369 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001374 RLOGD("getCdmaRoamingPreference: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001375 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001380 RLOGD("setTTYMode: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001381 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001386 RLOGD("getTTYMode: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001387 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001392 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001393 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001399 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001400 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001405 RLOGD("sendCDMAFeatureCode: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001406 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001413 RLOGD("sendBurstDtmf: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001414 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001454 RLOGD("sendCdmaSms: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001455 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001468 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001469 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001484 RLOGD("getGsmBroadcastConfig: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001485 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001492 RLOGD("setGsmBroadcastConfig: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001493 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001518 RLOGD("setGsmBroadcastActivation: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001519 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001525 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001526 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001533 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001534 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001557 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001558 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001564 RLOGD("getCDMASubscription: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001565 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001570 RLOGD("writeSmsToRuim: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001571 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001586 RLOGD("deleteSmsOnRuim: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001587 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001592 RLOGD("getDeviceIdentity: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001593 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001598 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001599 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001604 RLOGD("getSmscAddress: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001605 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001610 RLOGD("setSmscAddress: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001611 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001617 RLOGD("reportSmsMemoryStatus: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001618 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001624 RLOGD("reportStkServiceIsRunning: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001625 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001630 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001631 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001636 RLOGD("requestIsimAuthentication: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001637 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001644 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001645 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001651 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001652 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001658 RLOGD("getVoiceRadioTechnology: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001659 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001664 RLOGD("getCellInfoList: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001665 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001670 RLOGD("setCellInfoListRate: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001671 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001677 RLOGD("setInitialAttachApn: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001678 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001753 RLOGD("getImsRegistrationState: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001754 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001839 RLOGD("sendImsSms: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001840 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 {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001852 RLOGE("sendImsSms: Invalid radio tech %s",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001853 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001860 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001861 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001866 RLOGD("iccOpenLogicalChannel: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001867 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001873 RLOGD("iccCloseLogicalChannel: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001874 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001879 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001880 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
1881 return Void();
1882}
1883
1884Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001885 RLOGD("nvReadItem: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001886 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001900 RLOGD("nvWriteItem: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001901 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001922 RLOGD("nvWriteCdmaPrl: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001923 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
1924 return Void();
1925}
1926
1927Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001928 RLOGD("nvResetConfig: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001929 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001934 RLOGD("setUiccSubscription: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001935 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001953 RLOGD("setDataAllowed: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001954 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
1955 return Void();
1956}
1957
1958Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001959 RLOGD("getHardwareConfig: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001960 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08001966 RLOGD("requestIccSimAuthentication: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08001967 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002029 RLOGD("setDataProfile: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002030 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002189 RLOGD("requestShutdown: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002190 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2191 return Void();
2192}
2193
2194Return<void> RadioImpl::getRadioCapability(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002195 RLOGD("getRadioCapability: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002196 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2197 return Void();
2198}
2199
2200Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002201 RLOGD("setRadioCapability: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002202 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002223 RLOGD("startLceService: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002224 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002230 RLOGD("stopLceService: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002231 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2232 return Void();
2233}
2234
2235Return<void> RadioImpl::pullLceData(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002236 RLOGD("pullLceData: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002237 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2238 return Void();
2239}
2240
2241Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002242 RLOGD("getModemActivityInfo: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002243 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002249 RLOGD("setAllowedCarriers: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002250 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 = {};
Jack Yu11ab4042017-02-21 17:08:01 -08002257 RIL_Carrier *allowedCarriers = NULL;
2258 RIL_Carrier *excludedCarriers = NULL;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002259
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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002263 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002264 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002273 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002274 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
Amit Mahajan3f510f62017-03-01 10:26:58 -08002291 for (int i = 0; i < cr.len_excluded_carriers; i++) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002292 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) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002311 RLOGD("getAllowedCarriers: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002312 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2313 return Void();
2314}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002315
Jack Yu11ab4042017-02-21 17:08:01 -08002316Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2317 bool state) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002318 RLOGD("sendDeviceState: serial %d", serial);
Jack Yu11ab4042017-02-21 17:08:01 -08002319 if (s_vendorFunctions->version < 15) {
2320 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002321 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
Jack Yu11ab4042017-02-21 17:08:01 -08002322 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2323 } else {
2324 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2325 RIL_REQUEST_SEND_DEVICE_STATE);
2326 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2327 }
2328 return Void();
2329 }
2330 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2331 BOOL_TO_INT(state));
2332 return Void();
2333}
2334
2335Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002336 RLOGD("setIndicationFilter: serial %d", serial);
Jack Yu11ab4042017-02-21 17:08:01 -08002337 if (s_vendorFunctions->version < 15) {
2338 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2339 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2340 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2341 return Void();
2342 }
2343 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2344 return Void();
2345}
2346
Wileen Chiu718c0bf2017-01-04 11:37:19 -08002347Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002348 RLOGD("setSimCardPower: serial %d", serial);
Wileen Chiu718c0bf2017-01-04 11:37:19 -08002349 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2350 return Void();
2351}
2352
Sanket Padawef220dc52017-01-02 23:46:00 -08002353Return<void> RadioImpl::responseAcknowledgement() {
2354 android::releaseWakeLock();
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002355 return Void();
Sanket Padawef220dc52017-01-02 23:46:00 -08002356}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002357
Amit Mahajan439da362017-02-13 17:43:04 -08002358Return<void> OemHookImpl::setResponseFunctions(
2359 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2360 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2361 RLOGD("OemHookImpl::setResponseFunctions");
2362
2363 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2364 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2365 assert(ret == 0);
2366
2367 mOemHookResponse = oemHookResponseParam;
2368 mOemHookIndication = oemHookIndicationParam;
Amit Mahajand423d192017-03-16 17:04:01 -07002369 mCounterOemHook[mSlotId]++;
Amit Mahajan439da362017-02-13 17:43:04 -08002370
2371 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2372 assert(ret == 0);
2373
2374 return Void();
2375}
2376
2377Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2378 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2379 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2380 return Void();
2381}
2382
2383Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2384 const hidl_vec<hidl_string>& data) {
2385 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2386 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2387 return Void();
2388}
2389
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002390/***************************************************************************************************
2391 * RESPONSE FUNCTIONS
2392 * Functions above are used for requests going from framework to vendor code. The ones below are
2393 * responses for those requests coming back from the vendor code.
2394 **************************************************************************************************/
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002395
Sanket Padawef220dc52017-01-02 23:46:00 -08002396void radio::acknowledgeRequest(int slotId, int serial) {
2397 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan17249842017-01-19 15:05:45 -08002398 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2399 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002400 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002401 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawef220dc52017-01-02 23:46:00 -08002402 }
2403}
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002404
Sanket Padawef220dc52017-01-02 23:46:00 -08002405void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002406 RIL_Errno e) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002407 responseInfo.serial = serial;
2408 switch (responseType) {
2409 case RESPONSE_SOLICITED:
2410 responseInfo.type = RadioResponseType::SOLICITED;
2411 break;
2412 case RESPONSE_SOLICITED_ACK_EXP:
2413 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2414 break;
2415 }
2416 responseInfo.error = (RadioError) e;
2417}
2418
Naveen Kalla346bbc02017-03-16 12:55:55 -07002419int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2420 void *response, size_t responseLen) {
2421 populateResponseInfo(responseInfo, serial, responseType, e);
2422 int ret = -1;
2423
2424 if (response == NULL && responseLen == 0) {
2425 // Earlier RILs did not send a response for some cases although the interface
2426 // expected an integer as response. Do not return error if response is empty. Instead
2427 // Return -1 in those cases to maintain backward compatibility.
2428 } else if (response == NULL || responseLen != sizeof(int)) {
2429 RLOGE("responseIntOrEmpty: Invalid response");
2430 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2431 } else {
2432 int *p_int = (int *) response;
2433 ret = p_int[0];
2434 }
2435 return ret;
2436}
2437
Sanket Padawef220dc52017-01-02 23:46:00 -08002438int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002439 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002440 populateResponseInfo(responseInfo, serial, responseType, e);
2441 int ret = -1;
2442
2443 if (response == NULL || responseLen != sizeof(int)) {
2444 RLOGE("responseInt: Invalid response");
2445 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2446 } else {
2447 int *p_int = (int *) response;
2448 ret = p_int[0];
2449 }
2450 return ret;
2451}
2452
Amit Mahajan759786a2017-03-03 17:35:47 -08002453int radio::getIccCardStatusResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002454 int responseType, int serial, RIL_Errno e,
2455 void *response, size_t responseLen) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002456 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002457 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002458 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08002459 CardStatus cardStatus = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002460 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002461 RLOGE("getIccCardStatusResponse: Invalid response");
Sanket Padawef220dc52017-01-02 23:46:00 -08002462 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002463 } else {
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002464 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2465 cardStatus.cardState = (CardState) p_cur->card_state;
2466 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2467 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2468 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2469 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2470
2471 RIL_AppStatus *rilAppStatus = p_cur->applications;
2472 cardStatus.applications.resize(p_cur->num_applications);
2473 AppStatus *appStatus = cardStatus.applications.data();
Amit Mahajan111ddca2017-03-03 12:05:13 -08002474 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002475 for (int i = 0; i < p_cur->num_applications; i++) {
2476 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2477 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2478 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2479 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2480 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2481 rilAppStatus[i].app_label_ptr);
2482 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2483 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2484 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2485 }
2486 }
2487
Amit Mahajan17249842017-01-19 15:05:45 -08002488 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2489 getIccCardStatusResponse(responseInfo, cardStatus);
2490 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002491 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002492 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawef220dc52017-01-02 23:46:00 -08002493 }
2494
2495 return 0;
2496}
2497
Amit Mahajan759786a2017-03-03 17:35:47 -08002498int radio::supplyIccPinForAppResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002499 int responseType, int serial, RIL_Errno e,
2500 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002501 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
Sanket Padawef220dc52017-01-02 23:46:00 -08002502
2503 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002504 RadioResponseInfo responseInfo = {};
Naveen Kalla346bbc02017-03-16 12:55:55 -07002505 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002506 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2507 supplyIccPinForAppResponse(responseInfo, ret);
2508 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002509 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002510 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawef220dc52017-01-02 23:46:00 -08002511 slotId);
2512 }
2513
2514 return 0;
2515}
2516
Amit Mahajan759786a2017-03-03 17:35:47 -08002517int radio::supplyIccPukForAppResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002518 int responseType, int serial, RIL_Errno e,
2519 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002520 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
Sanket Padawef220dc52017-01-02 23:46:00 -08002521
2522 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002523 RadioResponseInfo responseInfo = {};
Naveen Kalla346bbc02017-03-16 12:55:55 -07002524 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002525 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2526 responseInfo, ret);
Amit Mahajan17249842017-01-19 15:05:45 -08002527 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002528 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002529 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawef220dc52017-01-02 23:46:00 -08002530 slotId);
2531 }
2532
2533 return 0;
2534}
2535
Amit Mahajan759786a2017-03-03 17:35:47 -08002536int radio::supplyIccPin2ForAppResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002537 int responseType, int serial, RIL_Errno e,
2538 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002539 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
Sanket Padawef220dc52017-01-02 23:46:00 -08002540
2541 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002542 RadioResponseInfo responseInfo = {};
Naveen Kalla346bbc02017-03-16 12:55:55 -07002543 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002544 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2545 supplyIccPin2ForAppResponse(responseInfo, ret);
2546 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002547 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002548 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawef220dc52017-01-02 23:46:00 -08002549 slotId);
2550 }
2551
2552 return 0;
2553}
2554
Amit Mahajan759786a2017-03-03 17:35:47 -08002555int radio::supplyIccPuk2ForAppResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002556 int responseType, int serial, RIL_Errno e,
2557 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002558 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
Sanket Padawef220dc52017-01-02 23:46:00 -08002559
2560 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002561 RadioResponseInfo responseInfo = {};
Naveen Kalla346bbc02017-03-16 12:55:55 -07002562 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002563 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2564 supplyIccPuk2ForAppResponse(responseInfo, ret);
2565 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002566 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002567 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawef220dc52017-01-02 23:46:00 -08002568 slotId);
2569 }
2570
2571 return 0;
2572}
2573
Amit Mahajan759786a2017-03-03 17:35:47 -08002574int radio::changeIccPinForAppResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002575 int responseType, int serial, RIL_Errno e,
2576 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002577 RLOGD("changeIccPinForAppResponse: serial %d", serial);
Sanket Padawef220dc52017-01-02 23:46:00 -08002578
2579 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002580 RadioResponseInfo responseInfo = {};
Naveen Kalla346bbc02017-03-16 12:55:55 -07002581 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002582 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2583 changeIccPinForAppResponse(responseInfo, ret);
2584 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002585 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002586 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawef220dc52017-01-02 23:46:00 -08002587 slotId);
2588 }
2589
2590 return 0;
2591}
2592
Amit Mahajan759786a2017-03-03 17:35:47 -08002593int radio::changeIccPin2ForAppResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002594 int responseType, int serial, RIL_Errno e,
2595 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002596 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
Sanket Padawef220dc52017-01-02 23:46:00 -08002597
2598 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002599 RadioResponseInfo responseInfo = {};
Naveen Kalla346bbc02017-03-16 12:55:55 -07002600 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002601 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2602 changeIccPin2ForAppResponse(responseInfo, ret);
2603 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002604 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002605 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawef220dc52017-01-02 23:46:00 -08002606 slotId);
2607 }
2608
2609 return 0;
2610}
2611
Amit Mahajan759786a2017-03-03 17:35:47 -08002612int radio::supplyNetworkDepersonalizationResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002613 int responseType, int serial, RIL_Errno e,
2614 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002615 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
Sanket Padawef220dc52017-01-02 23:46:00 -08002616
2617 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002618 RadioResponseInfo responseInfo = {};
Naveen Kalla346bbc02017-03-16 12:55:55 -07002619 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
Amit Mahajan17249842017-01-19 15:05:45 -08002620 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2621 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2622 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002623 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002624 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002625 "NULL", slotId);
Sanket Padawef220dc52017-01-02 23:46:00 -08002626 }
2627
2628 return 0;
2629}
2630
Amit Mahajan759786a2017-03-03 17:35:47 -08002631int radio::getCurrentCallsResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002632 int responseType, int serial, RIL_Errno e,
2633 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002634 RLOGD("getCurrentCallsResponse: serial %d", serial);
Sanket Padawef220dc52017-01-02 23:46:00 -08002635
2636 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002637 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002638 populateResponseInfo(responseInfo, serial, responseType, e);
2639
2640 hidl_vec<Call> calls;
2641 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002642 RLOGE("getCurrentCallsResponse: Invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08002643 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Sanket Padawef220dc52017-01-02 23:46:00 -08002644 } else {
2645 int num = responseLen / sizeof(RIL_Call *);
2646 calls.resize(num);
2647
2648 for (int i = 0 ; i < num ; i++) {
2649 RIL_Call *p_cur = ((RIL_Call **) response)[i];
2650 /* each call info */
2651 calls[i].state = (CallState) p_cur->state;
2652 calls[i].index = p_cur->index;
2653 calls[i].toa = p_cur->toa;
2654 calls[i].isMpty = p_cur->isMpty;
2655 calls[i].isMT = p_cur->isMT;
2656 calls[i].als = p_cur->als;
2657 calls[i].isVoice = p_cur->isVoice;
2658 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
2659 calls[i].number = convertCharPtrToHidlString(p_cur->number);
2660 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
2661 calls[i].name = convertCharPtrToHidlString(p_cur->name);
2662 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002663 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
Sanket Padawef220dc52017-01-02 23:46:00 -08002664 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
2665 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
2666 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
2667 // convert uusInfo->uusData to a null-terminated string
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002668 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
2669 calls[i].uusInfo[0].uusData = nullTermStr;
2670 free(nullTermStr);
Sanket Padawef220dc52017-01-02 23:46:00 -08002671 }
2672 }
2673 }
2674
Amit Mahajan17249842017-01-19 15:05:45 -08002675 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2676 getCurrentCallsResponse(responseInfo, calls);
2677 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002678 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002679 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawef220dc52017-01-02 23:46:00 -08002680 }
2681
2682 return 0;
2683}
2684
Amit Mahajan759786a2017-03-03 17:35:47 -08002685int radio::dialResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002686 int responseType, int serial, RIL_Errno e, void *response,
2687 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002688 RLOGD("dialResponse: serial %d", serial);
Sanket Padawef220dc52017-01-02 23:46:00 -08002689
2690 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002691 RadioResponseInfo responseInfo = {};
Sanket Padawef220dc52017-01-02 23:46:00 -08002692 populateResponseInfo(responseInfo, serial, responseType, e);
Amit Mahajan17249842017-01-19 15:05:45 -08002693 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
2694 radioService[slotId]->checkReturnStatus(retStatus);
Sanket Padawef220dc52017-01-02 23:46:00 -08002695 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002696 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07002697 }
2698
2699 return 0;
2700}
2701
Amit Mahajan759786a2017-03-03 17:35:47 -08002702int radio::getIMSIForAppResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002703 int responseType, int serial, RIL_Errno e, void *response,
2704 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002705 RLOGD("getIMSIForAppResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002706
2707 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002708 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002709 populateResponseInfo(responseInfo, serial, responseType, e);
2710 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
2711 responseInfo, convertCharPtrToHidlString((char *) response));
2712 radioService[slotId]->checkReturnStatus(retStatus);
2713 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002714 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002715 slotId);
2716 }
2717
2718 return 0;
2719}
2720
Amit Mahajan759786a2017-03-03 17:35:47 -08002721int radio::hangupConnectionResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002722 int responseType, int serial, RIL_Errno e,
2723 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002724 RLOGD("hangupConnectionResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002725
2726 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002727 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002728 populateResponseInfo(responseInfo, serial, responseType, e);
2729 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
2730 responseInfo);
2731 radioService[slotId]->checkReturnStatus(retStatus);
2732 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002733 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002734 slotId);
2735 }
2736
2737 return 0;
2738}
2739
Amit Mahajan759786a2017-03-03 17:35:47 -08002740int radio::hangupWaitingOrBackgroundResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002741 int responseType, int serial, RIL_Errno e,
2742 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002743 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002744
2745 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002746 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002747 populateResponseInfo(responseInfo, serial, responseType, e);
2748 Return<void> retStatus =
2749 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
2750 responseInfo);
2751 radioService[slotId]->checkReturnStatus(retStatus);
2752 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002753 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002754 slotId);
2755 }
2756
2757 return 0;
2758}
2759
Amit Mahajan759786a2017-03-03 17:35:47 -08002760int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
2761 RIL_Errno e, void *response,
2762 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002763 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002764
2765 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002766 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002767 populateResponseInfo(responseInfo, serial, responseType, e);
2768 Return<void> retStatus =
2769 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
2770 responseInfo);
2771 radioService[slotId]->checkReturnStatus(retStatus);
2772 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002773 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002774 slotId);
2775 }
2776
2777 return 0;
2778}
2779
Amit Mahajan759786a2017-03-03 17:35:47 -08002780int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
2781 RIL_Errno e, void *response,
2782 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002783 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002784
2785 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002786 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002787 populateResponseInfo(responseInfo, serial, responseType, e);
2788 Return<void> retStatus =
2789 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
2790 responseInfo);
2791 radioService[slotId]->checkReturnStatus(retStatus);
2792 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002793 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002794 "== NULL", slotId);
2795 }
2796
2797 return 0;
2798}
2799
Amit Mahajan759786a2017-03-03 17:35:47 -08002800int radio::conferenceResponse(int slotId, int responseType,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002801 int serial, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002802 RLOGD("conferenceResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002803
2804 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002805 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002806 populateResponseInfo(responseInfo, serial, responseType, e);
2807 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
2808 responseInfo);
2809 radioService[slotId]->checkReturnStatus(retStatus);
2810 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002811 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002812 slotId);
2813 }
2814
2815 return 0;
2816}
2817
Amit Mahajan759786a2017-03-03 17:35:47 -08002818int radio::rejectCallResponse(int slotId, int responseType,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002819 int serial, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002820 RLOGD("rejectCallResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002821
2822 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002823 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002824 populateResponseInfo(responseInfo, serial, responseType, e);
2825 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
2826 responseInfo);
2827 radioService[slotId]->checkReturnStatus(retStatus);
2828 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002829 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002830 slotId);
2831 }
2832
2833 return 0;
2834}
2835
Amit Mahajan759786a2017-03-03 17:35:47 -08002836int radio::getLastCallFailCauseResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002837 int responseType, int serial, RIL_Errno e, void *response,
2838 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002839 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002840
2841 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08002842 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002843 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08002844
2845 LastCallFailCauseInfo info = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002846 info.vendorCause = hidl_string();
2847 if (response == NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002848 RLOGE("getCurrentCallsResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002849 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2850 } else if (responseLen == sizeof(int)) {
2851 int *pInt = (int *) response;
2852 info.causeCode = (LastCallFailCause) pInt[0];
2853 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
2854 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
2855 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
2856 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
2857 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002858 RLOGE("getCurrentCallsResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002859 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2860 }
2861
2862 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
2863 responseInfo, info);
2864 radioService[slotId]->checkReturnStatus(retStatus);
2865 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002866 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08002867 slotId);
2868 }
2869
2870 return 0;
2871}
2872
Amit Mahajan759786a2017-03-03 17:35:47 -08002873int radio::getSignalStrengthResponse(int slotId,
Amit Mahajan3df62912017-02-10 01:35:55 +00002874 int responseType, int serial, RIL_Errno e,
2875 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002876 RLOGD("getSignalStrengthResponse: serial %d", serial);
Amit Mahajan3df62912017-02-10 01:35:55 +00002877
2878 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08002879 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00002880 populateResponseInfo(responseInfo, serial, responseType, e);
Amit Mahajan3da9ac02017-02-13 13:41:28 -08002881 SignalStrength signalStrength = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00002882 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002883 RLOGE("getSignalStrengthResponse: Invalid response");
Amit Mahajan3df62912017-02-10 01:35:55 +00002884 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2885 } else {
2886 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
2887 }
2888
2889 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
2890 responseInfo, signalStrength);
2891 radioService[slotId]->checkReturnStatus(retStatus);
2892 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08002893 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
Amit Mahajan3df62912017-02-10 01:35:55 +00002894 slotId);
2895 }
2896
2897 return 0;
2898}
2899
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08002900RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
2901 if (rat == NULL) {
2902 return RIL_CELL_INFO_TYPE_NONE;
2903 }
2904
2905 int radioTech = atoi(rat);
2906
2907 switch(radioTech) {
2908
2909 case RADIO_TECH_GPRS:
2910 case RADIO_TECH_EDGE:
2911 case RADIO_TECH_GSM: {
2912 return RIL_CELL_INFO_TYPE_GSM;
2913 }
2914
2915 case RADIO_TECH_UMTS:
2916 case RADIO_TECH_HSDPA:
2917 case RADIO_TECH_HSUPA:
2918 case RADIO_TECH_HSPA:
2919 case RADIO_TECH_HSPAP: {
2920 return RIL_CELL_INFO_TYPE_WCDMA;
2921 }
2922
2923 case RADIO_TECH_IS95A:
2924 case RADIO_TECH_IS95B:
2925 case RADIO_TECH_1xRTT:
2926 case RADIO_TECH_EVDO_0:
2927 case RADIO_TECH_EVDO_A:
2928 case RADIO_TECH_EVDO_B:
2929 case RADIO_TECH_EHRPD: {
2930 return RIL_CELL_INFO_TYPE_CDMA;
2931 }
2932
2933 case RADIO_TECH_LTE:
2934 case RADIO_TECH_LTE_CA: {
2935 return RIL_CELL_INFO_TYPE_LTE;
2936 }
2937
2938 case RADIO_TECH_TD_SCDMA: {
2939 return RIL_CELL_INFO_TYPE_TD_SCDMA;
2940 }
2941
2942 default: {
2943 break;
2944 }
2945 }
2946
2947 return RIL_CELL_INFO_TYPE_NONE;
2948
2949}
2950
2951void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
2952
2953 cellIdentity.cellIdentityGsm.resize(0);
2954 cellIdentity.cellIdentityWcdma.resize(0);
2955 cellIdentity.cellIdentityCdma.resize(0);
2956 cellIdentity.cellIdentityTdscdma.resize(0);
2957 cellIdentity.cellIdentityLte.resize(0);
2958 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
2959 switch(rilCellIdentity.cellInfoType) {
2960
2961 case RIL_CELL_INFO_TYPE_GSM: {
2962 cellIdentity.cellIdentityGsm.resize(1);
2963 cellIdentity.cellIdentityGsm[0].mcc =
2964 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
2965 cellIdentity.cellIdentityGsm[0].mnc =
2966 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
2967 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
2968 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
2969 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
2970 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
2971 break;
2972 }
2973
2974 case RIL_CELL_INFO_TYPE_WCDMA: {
2975 cellIdentity.cellIdentityWcdma.resize(1);
2976 cellIdentity.cellIdentityWcdma[0].mcc =
2977 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
2978 cellIdentity.cellIdentityWcdma[0].mnc =
2979 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
2980 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
2981 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
2982 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
2983 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
2984 break;
2985 }
2986
2987 case RIL_CELL_INFO_TYPE_CDMA: {
2988 cellIdentity.cellIdentityCdma.resize(1);
2989 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
2990 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
2991 cellIdentity.cellIdentityCdma[0].baseStationId =
2992 rilCellIdentity.cellIdentityCdma.basestationId;
2993 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
2994 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
2995 break;
2996 }
2997
2998 case RIL_CELL_INFO_TYPE_LTE: {
2999 cellIdentity.cellIdentityLte.resize(1);
3000 cellIdentity.cellIdentityLte[0].mcc =
3001 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3002 cellIdentity.cellIdentityLte[0].mnc =
3003 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3004 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3005 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3006 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3007 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3008 break;
3009 }
3010
3011 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3012 cellIdentity.cellIdentityTdscdma.resize(1);
3013 cellIdentity.cellIdentityTdscdma[0].mcc =
3014 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3015 cellIdentity.cellIdentityTdscdma[0].mnc =
3016 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3017 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3018 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3019 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3020 break;
3021 }
3022
3023 default: {
3024 break;
3025 }
3026 }
3027}
3028
3029int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3030 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3031 return atoi(response[index]);
3032 }
3033
3034 return -1;
3035}
3036
3037void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3038 int numStrings, char** response) {
3039
3040 RIL_CellIdentity_v16 rilCellIdentity;
3041 int32_t *tmp = (int32_t*)&rilCellIdentity;
3042
Nathan Harold2593b012017-03-01 18:57:56 -08003043 for (size_t i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) {
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003044 tmp[i] = -1;
3045 }
3046
3047 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3048 switch(rilCellIdentity.cellInfoType) {
3049
3050 case RIL_CELL_INFO_TYPE_GSM: {
3051 rilCellIdentity.cellIdentityGsm.lac =
3052 convertResponseStringEntryToInt(response, 1, numStrings);
3053 rilCellIdentity.cellIdentityGsm.cid =
3054 convertResponseStringEntryToInt(response, 2, numStrings);
3055 break;
3056 }
3057
3058 case RIL_CELL_INFO_TYPE_WCDMA: {
3059 rilCellIdentity.cellIdentityWcdma.lac =
3060 convertResponseStringEntryToInt(response, 1, numStrings);
3061 rilCellIdentity.cellIdentityWcdma.cid =
3062 convertResponseStringEntryToInt(response, 2, numStrings);
3063 rilCellIdentity.cellIdentityWcdma.psc =
3064 convertResponseStringEntryToInt(response, 14, numStrings);
3065 break;
3066 }
3067
3068 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3069 rilCellIdentity.cellIdentityTdscdma.lac =
3070 convertResponseStringEntryToInt(response, 1, numStrings);
3071 rilCellIdentity.cellIdentityTdscdma.cid =
3072 convertResponseStringEntryToInt(response, 2, numStrings);
3073 break;
3074 }
3075
3076 case RIL_CELL_INFO_TYPE_CDMA:{
3077 rilCellIdentity.cellIdentityCdma.basestationId =
3078 convertResponseStringEntryToInt(response, 4, numStrings);
3079 rilCellIdentity.cellIdentityCdma.longitude =
3080 convertResponseStringEntryToInt(response, 5, numStrings);
3081 rilCellIdentity.cellIdentityCdma.latitude =
3082 convertResponseStringEntryToInt(response, 6, numStrings);
3083 rilCellIdentity.cellIdentityCdma.systemId =
3084 convertResponseStringEntryToInt(response, 8, numStrings);
3085 rilCellIdentity.cellIdentityCdma.networkId =
3086 convertResponseStringEntryToInt(response, 9, numStrings);
3087 break;
3088 }
3089
Sooraj Sasindranf28e42a2017-03-06 23:07:22 -08003090 case RIL_CELL_INFO_TYPE_LTE:{
3091 rilCellIdentity.cellIdentityLte.tac =
3092 convertResponseStringEntryToInt(response, 1, numStrings);
3093 rilCellIdentity.cellIdentityLte.ci =
3094 convertResponseStringEntryToInt(response, 2, numStrings);
3095 break;
3096 }
3097
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003098 default: {
3099 break;
3100 }
3101 }
3102
3103 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3104}
3105
3106void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3107 int numStrings, char** response) {
3108
3109 RIL_CellIdentity_v16 rilCellIdentity;
3110 int32_t *tmp = (int32_t*)&rilCellIdentity;
3111
Nathan Harold2593b012017-03-01 18:57:56 -08003112 for (size_t i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) {
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003113 tmp[i] = -1;
3114 }
3115
3116 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3117 switch(rilCellIdentity.cellInfoType) {
3118 case RIL_CELL_INFO_TYPE_GSM: {
3119 rilCellIdentity.cellIdentityGsm.lac =
3120 convertResponseStringEntryToInt(response, 1, numStrings);
3121 rilCellIdentity.cellIdentityGsm.cid =
3122 convertResponseStringEntryToInt(response, 2, numStrings);
3123 break;
3124 }
3125 case RIL_CELL_INFO_TYPE_WCDMA: {
3126 rilCellIdentity.cellIdentityWcdma.lac =
3127 convertResponseStringEntryToInt(response, 1, numStrings);
3128 rilCellIdentity.cellIdentityWcdma.cid =
3129 convertResponseStringEntryToInt(response, 2, numStrings);
3130 break;
3131 }
3132 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3133 rilCellIdentity.cellIdentityTdscdma.lac =
3134 convertResponseStringEntryToInt(response, 1, numStrings);
3135 rilCellIdentity.cellIdentityTdscdma.cid =
3136 convertResponseStringEntryToInt(response, 2, numStrings);
3137 break;
3138 }
3139 case RIL_CELL_INFO_TYPE_LTE: {
3140 rilCellIdentity.cellIdentityLte.tac =
3141 convertResponseStringEntryToInt(response, 6, numStrings);
3142 rilCellIdentity.cellIdentityLte.pci =
3143 convertResponseStringEntryToInt(response, 7, numStrings);
3144 rilCellIdentity.cellIdentityLte.ci =
3145 convertResponseStringEntryToInt(response, 8, numStrings);
3146 break;
3147 }
3148 default: {
3149 break;
3150 }
3151 }
3152
3153 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3154}
3155
Amit Mahajan759786a2017-03-03 17:35:47 -08003156int radio::getVoiceRegistrationStateResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003157 int responseType, int serial, RIL_Errno e,
3158 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003159 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003160
3161 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003162 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003163 populateResponseInfo(responseInfo, serial, responseType, e);
3164
Jack Yuf68e0da2017-02-07 14:53:09 -08003165 VoiceRegStateResult voiceRegResponse = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003166 int numStrings = responseLen / sizeof(char *);
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003167 if (response == NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003168 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003169 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3170 } else if (s_vendorFunctions->version <= 14) {
3171 if (numStrings != 15) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003172 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003173 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3174 } else {
3175 char **resp = (char **) response;
3176 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3177 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3178 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3179 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3180 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3181 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3182 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3183 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3184 numStrings, resp);
3185 }
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003186 } else {
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003187 RIL_VoiceRegistrationStateResponse *voiceRegState =
3188 (RIL_VoiceRegistrationStateResponse *)response;
3189
3190 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003191 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003192 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3193 } else {
3194 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3195 voiceRegResponse.rat = voiceRegState->rat;;
3196 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3197 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3198 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3199 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3200 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3201 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3202 voiceRegState->cellIdentity);
3203 }
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003204 }
3205
3206 Return<void> retStatus =
3207 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3208 responseInfo, voiceRegResponse);
3209 radioService[slotId]->checkReturnStatus(retStatus);
3210 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003211 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003212 slotId);
3213 }
3214
3215 return 0;
3216}
3217
Amit Mahajan759786a2017-03-03 17:35:47 -08003218int radio::getDataRegistrationStateResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003219 int responseType, int serial, RIL_Errno e,
3220 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003221 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003222
3223 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003224 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003225 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08003226 DataRegStateResult dataRegResponse = {};
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003227 if (response == NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003228 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003229 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003230 } else if (s_vendorFunctions->version <= 14) {
3231 int numStrings = responseLen / sizeof(char *);
3232 if ((numStrings != 6) && (numStrings != 11)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003233 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003234 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3235 } else {
3236 char **resp = (char **) response;
3237 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3238 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3239 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3240 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3241 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3242 numStrings, resp);
3243 }
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003244 } else {
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003245 RIL_DataRegistrationStateResponse *dataRegState =
3246 (RIL_DataRegistrationStateResponse *)response;
3247
3248 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003249 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08003250 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3251 } else {
3252 dataRegResponse.regState = (RegState) dataRegState->regState;
3253 dataRegResponse.rat = dataRegState->rat;;
3254 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3255 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3256 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003257 }
3258 }
3259
3260 Return<void> retStatus =
3261 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3262 dataRegResponse);
3263 radioService[slotId]->checkReturnStatus(retStatus);
3264 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003265 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003266 slotId);
3267 }
3268
3269 return 0;
3270}
3271
Amit Mahajan759786a2017-03-03 17:35:47 -08003272int radio::getOperatorResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003273 int responseType, int serial, RIL_Errno e, void *response,
3274 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003275 RLOGD("getOperatorResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003276
3277 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003278 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003279 populateResponseInfo(responseInfo, serial, responseType, e);
3280 hidl_string longName;
3281 hidl_string shortName;
3282 hidl_string numeric;
3283 int numStrings = responseLen / sizeof(char *);
3284 if (response == NULL || numStrings != 3) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003285 RLOGE("getOperatorResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003286 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3287
3288 } else {
3289 char **resp = (char **) response;
3290 longName = convertCharPtrToHidlString(resp[0]);
3291 shortName = convertCharPtrToHidlString(resp[1]);
3292 numeric = convertCharPtrToHidlString(resp[2]);
3293 }
3294 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3295 responseInfo, longName, shortName, numeric);
3296 radioService[slotId]->checkReturnStatus(retStatus);
3297 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003298 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003299 slotId);
3300 }
3301
3302 return 0;
3303}
3304
Amit Mahajan759786a2017-03-03 17:35:47 -08003305int radio::setRadioPowerResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003306 int responseType, int serial, RIL_Errno e, void *response,
3307 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003308 RLOGD("setRadioPowerResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003309
3310 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003311 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003312 populateResponseInfo(responseInfo, serial, responseType, e);
3313 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3314 responseInfo);
3315 radioService[slotId]->checkReturnStatus(retStatus);
3316 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003317 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003318 slotId);
3319 }
3320
3321 return 0;
3322}
3323
Amit Mahajan759786a2017-03-03 17:35:47 -08003324int radio::sendDtmfResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003325 int responseType, int serial, RIL_Errno e, void *response,
3326 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003327 RLOGD("sendDtmfResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003328
3329 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003330 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003331 populateResponseInfo(responseInfo, serial, responseType, e);
3332 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3333 responseInfo);
3334 radioService[slotId]->checkReturnStatus(retStatus);
3335 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003336 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003337 slotId);
3338 }
3339
3340 return 0;
3341}
3342
3343SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3344 RIL_Errno e, void *response, size_t responseLen) {
3345 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08003346 SendSmsResult result = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003347
3348 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3349 RLOGE("Invalid response: NULL");
3350 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003351 result.ackPDU = hidl_string();
3352 } else {
3353 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3354 result.messageRef = resp->messageRef;
3355 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3356 result.errorCode = resp->errorCode;
3357 }
3358 return result;
3359}
3360
Amit Mahajan759786a2017-03-03 17:35:47 -08003361int radio::sendSmsResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003362 int responseType, int serial, RIL_Errno e, void *response,
3363 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003364 RLOGD("sendSmsResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003365
3366 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003367 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003368 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3369 responseLen);
3370
3371 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3372 result);
3373 radioService[slotId]->checkReturnStatus(retStatus);
3374 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003375 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003376 }
3377
3378 return 0;
3379}
3380
Amit Mahajan759786a2017-03-03 17:35:47 -08003381int radio::sendSMSExpectMoreResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003382 int responseType, int serial, RIL_Errno e, void *response,
3383 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003384 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003385
3386 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003387 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003388 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3389 responseLen);
3390
3391 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3392 responseInfo, result);
3393 radioService[slotId]->checkReturnStatus(retStatus);
3394 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003395 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003396 }
3397
3398 return 0;
3399}
3400
Amit Mahajan759786a2017-03-03 17:35:47 -08003401int radio::setupDataCallResponse(int slotId,
Amit Mahajan3df62912017-02-10 01:35:55 +00003402 int responseType, int serial, RIL_Errno e, void *response,
3403 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003404 RLOGD("setupDataCallResponse: serial %d", serial);
Amit Mahajan3df62912017-02-10 01:35:55 +00003405
3406 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08003407 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00003408 populateResponseInfo(responseInfo, serial, responseType, e);
3409
Amit Mahajan3da9ac02017-02-13 13:41:28 -08003410 SetupDataCallResult result = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00003411 if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003412 RLOGE("setupDataCallResponse: Invalid response");
Amit Mahajan3df62912017-02-10 01:35:55 +00003413 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Jack Yu5079e182017-02-28 15:21:18 -08003414 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
Amit Mahajan3da9ac02017-02-13 13:41:28 -08003415 result.type = hidl_string();
3416 result.ifname = hidl_string();
3417 result.addresses = hidl_string();
3418 result.dnses = hidl_string();
3419 result.gateways = hidl_string();
3420 result.pcscf = hidl_string();
Amit Mahajan3df62912017-02-10 01:35:55 +00003421 } else {
3422 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3423 }
3424
3425 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3426 responseInfo, result);
3427 radioService[slotId]->checkReturnStatus(retStatus);
3428 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003429 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Amit Mahajan3df62912017-02-10 01:35:55 +00003430 }
3431
3432 return 0;
3433}
3434
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003435IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3436 RIL_Errno e, void *response, size_t responseLen) {
3437 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08003438 IccIoResult result = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003439
3440 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3441 RLOGE("Invalid response: NULL");
3442 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003443 result.simResponse = hidl_string();
3444 } else {
3445 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3446 result.sw1 = resp->sw1;
3447 result.sw2 = resp->sw2;
3448 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3449 }
3450 return result;
3451}
3452
Amit Mahajan759786a2017-03-03 17:35:47 -08003453int radio::iccIOForAppResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003454 int responseType, int serial, RIL_Errno e, void *response,
3455 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003456 RLOGD("iccIOForAppResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003457
3458 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003459 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003460 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3461 responseLen);
3462
3463 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3464 responseInfo, result);
3465 radioService[slotId]->checkReturnStatus(retStatus);
3466 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003467 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003468 }
3469
3470 return 0;
3471}
3472
Amit Mahajan759786a2017-03-03 17:35:47 -08003473int radio::sendUssdResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003474 int responseType, int serial, RIL_Errno e, void *response,
3475 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003476 RLOGD("sendUssdResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003477
3478 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003479 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003480 populateResponseInfo(responseInfo, serial, responseType, e);
3481 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3482 responseInfo);
3483 radioService[slotId]->checkReturnStatus(retStatus);
3484 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003485 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003486 slotId);
3487 }
3488
3489 return 0;
3490}
3491
Amit Mahajan759786a2017-03-03 17:35:47 -08003492int radio::cancelPendingUssdResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003493 int responseType, int serial, RIL_Errno e, void *response,
3494 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003495 RLOGD("cancelPendingUssdResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003496
3497 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003498 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003499 populateResponseInfo(responseInfo, serial, responseType, e);
3500 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3501 responseInfo);
3502 radioService[slotId]->checkReturnStatus(retStatus);
3503 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003504 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003505 slotId);
3506 }
3507
3508 return 0;
3509}
3510
Amit Mahajan759786a2017-03-03 17:35:47 -08003511int radio::getClirResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003512 int responseType, int serial, RIL_Errno e, void *response,
3513 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003514 RLOGD("getClirResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003515
3516 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003517 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003518 populateResponseInfo(responseInfo, serial, responseType, e);
3519 int n = -1, m = -1;
3520 int numInts = responseLen / sizeof(int);
3521 if (response == NULL || numInts != 2) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003522 RLOGE("getClirResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003523 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3524 } else {
3525 int *pInt = (int *) response;
3526 n = pInt[0];
3527 m = pInt[1];
3528 }
3529 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3530 n, m);
3531 radioService[slotId]->checkReturnStatus(retStatus);
3532 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003533 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003534 }
3535
3536 return 0;
3537}
3538
Amit Mahajan759786a2017-03-03 17:35:47 -08003539int radio::setClirResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003540 int responseType, int serial, RIL_Errno e, void *response,
3541 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003542 RLOGD("setClirResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003543
3544 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003545 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003546 populateResponseInfo(responseInfo, serial, responseType, e);
3547 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
3548 responseInfo);
3549 radioService[slotId]->checkReturnStatus(retStatus);
3550 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003551 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003552 }
3553
3554 return 0;
3555}
3556
Amit Mahajan759786a2017-03-03 17:35:47 -08003557int radio::getCallForwardStatusResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003558 int responseType, int serial, RIL_Errno e,
3559 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003560 RLOGD("getCallForwardStatusResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003561
3562 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003563 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003564 populateResponseInfo(responseInfo, serial, responseType, e);
3565 hidl_vec<CallForwardInfo> callForwardInfos;
3566
3567 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003568 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003569 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3570 } else {
3571 int num = responseLen / sizeof(RIL_CallForwardInfo *);
3572 callForwardInfos.resize(num);
3573 for (int i = 0 ; i < num; i++) {
3574 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
3575 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
3576 callForwardInfos[i].reason = resp->reason;
3577 callForwardInfos[i].serviceClass = resp->serviceClass;
3578 callForwardInfos[i].toa = resp->toa;
3579 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
3580 callForwardInfos[i].timeSeconds = resp->timeSeconds;
3581 }
3582 }
3583
3584 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
3585 responseInfo, callForwardInfos);
3586 radioService[slotId]->checkReturnStatus(retStatus);
3587 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003588 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003589 slotId);
3590 }
3591
3592 return 0;
3593}
3594
Amit Mahajan759786a2017-03-03 17:35:47 -08003595int radio::setCallForwardResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003596 int responseType, int serial, RIL_Errno e, void *response,
3597 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003598 RLOGD("setCallForwardResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003599
3600 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003601 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003602 populateResponseInfo(responseInfo, serial, responseType, e);
3603 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
3604 responseInfo);
3605 radioService[slotId]->checkReturnStatus(retStatus);
3606 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003607 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003608 }
3609
3610 return 0;
3611}
3612
Amit Mahajan759786a2017-03-03 17:35:47 -08003613int radio::getCallWaitingResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003614 int responseType, int serial, RIL_Errno e, void *response,
3615 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003616 RLOGD("getCallWaitingResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003617
3618 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003619 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003620 populateResponseInfo(responseInfo, serial, responseType, e);
3621 bool enable = false;
3622 int serviceClass = -1;
3623 int numInts = responseLen / sizeof(int);
3624 if (response == NULL || numInts != 2) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003625 RLOGE("getCallWaitingResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003626 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3627 } else {
3628 int *pInt = (int *) response;
3629 enable = pInt[0] == 1 ? true : false;
3630 serviceClass = pInt[1];
3631 }
Sanket Padawe5375bfa2017-03-07 17:21:05 -08003632 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
3633 responseInfo, enable, serviceClass);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003634 radioService[slotId]->checkReturnStatus(retStatus);
3635 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003636 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003637 }
3638
3639 return 0;
3640}
3641
Amit Mahajan759786a2017-03-03 17:35:47 -08003642int radio::setCallWaitingResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003643 int responseType, int serial, RIL_Errno e, void *response,
3644 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003645 RLOGD("setCallWaitingResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003646
3647 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003648 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003649 populateResponseInfo(responseInfo, serial, responseType, e);
3650 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
3651 responseInfo);
3652 radioService[slotId]->checkReturnStatus(retStatus);
3653 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003654 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003655 }
3656
3657 return 0;
3658}
3659
Amit Mahajan759786a2017-03-03 17:35:47 -08003660int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003661 int responseType, int serial, RIL_Errno e,
3662 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003663 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003664
3665 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003666 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003667 populateResponseInfo(responseInfo, serial, responseType, e);
3668 Return<void> retStatus =
3669 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
3670 responseInfo);
3671 radioService[slotId]->checkReturnStatus(retStatus);
3672 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003673 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003674 "== NULL", slotId);
3675 }
3676
3677 return 0;
3678}
3679
Amit Mahajan759786a2017-03-03 17:35:47 -08003680int radio::acceptCallResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003681 int responseType, int serial, RIL_Errno e,
3682 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003683 RLOGD("acceptCallResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003684
3685 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003686 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003687 populateResponseInfo(responseInfo, serial, responseType, e);
3688 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
3689 responseInfo);
3690 radioService[slotId]->checkReturnStatus(retStatus);
3691 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003692 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003693 slotId);
3694 }
3695
3696 return 0;
3697}
3698
Amit Mahajan759786a2017-03-03 17:35:47 -08003699int radio::deactivateDataCallResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003700 int responseType, int serial, RIL_Errno e,
3701 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003702 RLOGD("deactivateDataCallResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003703
3704 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003705 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003706 populateResponseInfo(responseInfo, serial, responseType, e);
3707 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
3708 responseInfo);
3709 radioService[slotId]->checkReturnStatus(retStatus);
3710 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003711 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003712 slotId);
3713 }
3714
3715 return 0;
3716}
3717
Amit Mahajan759786a2017-03-03 17:35:47 -08003718int radio::getFacilityLockForAppResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003719 int responseType, int serial, RIL_Errno e,
3720 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003721 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003722
3723 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003724 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003725 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
3726 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3727 getFacilityLockForAppResponse(responseInfo, ret);
3728 radioService[slotId]->checkReturnStatus(retStatus);
3729 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003730 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003731 slotId);
3732 }
3733
3734 return 0;
3735}
3736
Amit Mahajan759786a2017-03-03 17:35:47 -08003737int radio::setFacilityLockForAppResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003738 int responseType, int serial, RIL_Errno e,
3739 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003740 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003741
3742 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003743 RadioResponseInfo responseInfo = {};
Naveen Kalla346bbc02017-03-16 12:55:55 -07003744 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003745 Return<void> retStatus
3746 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
3747 ret);
3748 radioService[slotId]->checkReturnStatus(retStatus);
3749 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003750 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003751 slotId);
3752 }
3753
3754 return 0;
3755}
3756
Amit Mahajan759786a2017-03-03 17:35:47 -08003757int radio::setBarringPasswordResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003758 int responseType, int serial, RIL_Errno e,
3759 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003760 RLOGD("acceptCallResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003761
3762 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003763 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003764 populateResponseInfo(responseInfo, serial, responseType, e);
3765 Return<void> retStatus
3766 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
3767 radioService[slotId]->checkReturnStatus(retStatus);
3768 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003769 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003770 slotId);
3771 }
3772
3773 return 0;
3774}
3775
Amit Mahajan759786a2017-03-03 17:35:47 -08003776int radio::getNetworkSelectionModeResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003777 int responseType, int serial, RIL_Errno e, void *response,
3778 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003779 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003780
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 bool manual = false;
3785 int serviceClass;
3786 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003787 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003788 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3789 } else {
3790 int *pInt = (int *) response;
3791 manual = pInt[0] == 1 ? true : false;
3792 }
3793 Return<void> retStatus
3794 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
3795 responseInfo,
3796 manual);
3797 radioService[slotId]->checkReturnStatus(retStatus);
3798 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003799 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003800 slotId);
3801 }
3802
3803 return 0;
3804}
3805
Amit Mahajan759786a2017-03-03 17:35:47 -08003806int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
3807 RIL_Errno e, void *response,
3808 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003809 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003810
3811 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003812 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003813 populateResponseInfo(responseInfo, serial, responseType, e);
3814 Return<void> retStatus
3815 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
3816 responseInfo);
3817 radioService[slotId]->checkReturnStatus(retStatus);
3818 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003819 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003820 "== NULL", slotId);
3821 }
3822
3823 return 0;
3824}
3825
Amit Mahajan759786a2017-03-03 17:35:47 -08003826int radio::setNetworkSelectionModeManualResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003827 int responseType, int serial, RIL_Errno e,
3828 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003829 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003830
3831 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003832 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003833 populateResponseInfo(responseInfo, serial, responseType, e);
3834 Return<void> retStatus
3835 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
3836 responseInfo);
3837 radioService[slotId]->checkReturnStatus(retStatus);
3838 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003839 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003840 "== NULL", slotId);
3841 }
3842
3843 return 0;
3844}
3845
Jack Yuf68e0da2017-02-07 14:53:09 -08003846int convertOperatorStatusToInt(const char *str) {
3847 if (strncmp("unknown", str, 9) == 0) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003848 return (int) OperatorStatus::UNKNOWN;
Jack Yuf68e0da2017-02-07 14:53:09 -08003849 } else if (strncmp("available", str, 9) == 0) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003850 return (int) OperatorStatus::AVAILABLE;
Jack Yuf68e0da2017-02-07 14:53:09 -08003851 } else if (strncmp("current", str, 9) == 0) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003852 return (int) OperatorStatus::CURRENT;
Jack Yuf68e0da2017-02-07 14:53:09 -08003853 } else if (strncmp("forbidden", str, 9) == 0) {
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003854 return (int) OperatorStatus::FORBIDDEN;
3855 } else {
3856 return -1;
3857 }
3858}
3859
Amit Mahajan759786a2017-03-03 17:35:47 -08003860int radio::getAvailableNetworksResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003861 int responseType, int serial, RIL_Errno e, void *response,
3862 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003863 RLOGD("getAvailableNetworksResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003864
3865 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003866 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003867 populateResponseInfo(responseInfo, serial, responseType, e);
3868 hidl_vec<OperatorInfo> networks;
3869 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003870 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003871 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3872 } else {
3873 char **resp = (char **) response;
3874 int numStrings = responseLen / sizeof(char *);
3875 networks.resize(numStrings/4);
Jayachandran Ce0d755c2017-03-01 18:26:50 -08003876 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
3877 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
3878 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
3879 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003880 int status = convertOperatorStatusToInt(resp[i + 3]);
3881 if (status == -1) {
3882 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3883 } else {
Jayachandran Ce0d755c2017-03-01 18:26:50 -08003884 networks[j].status = (OperatorStatus) status;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003885 }
3886 }
3887 }
3888 Return<void> retStatus
3889 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
3890 networks);
3891 radioService[slotId]->checkReturnStatus(retStatus);
3892 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003893 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003894 slotId);
3895 }
3896
3897 return 0;
3898}
3899
Amit Mahajan759786a2017-03-03 17:35:47 -08003900int radio::startDtmfResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003901 int responseType, int serial, RIL_Errno e,
3902 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003903 RLOGD("startDtmfResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003904
3905 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003906 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003907 populateResponseInfo(responseInfo, serial, responseType, e);
3908 Return<void> retStatus
3909 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
3910 radioService[slotId]->checkReturnStatus(retStatus);
3911 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003912 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003913 }
3914
3915 return 0;
3916}
3917
Amit Mahajan759786a2017-03-03 17:35:47 -08003918int radio::stopDtmfResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003919 int responseType, int serial, RIL_Errno e,
3920 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003921 RLOGD("stopDtmfResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003922
3923 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003924 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003925 populateResponseInfo(responseInfo, serial, responseType, e);
3926 Return<void> retStatus
3927 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
3928 radioService[slotId]->checkReturnStatus(retStatus);
3929 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003930 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003931 }
3932
3933 return 0;
3934}
3935
Amit Mahajan759786a2017-03-03 17:35:47 -08003936int radio::getBasebandVersionResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003937 int responseType, int serial, RIL_Errno e,
3938 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003939 RLOGD("getBasebandVersionResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003940
3941 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003942 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003943 populateResponseInfo(responseInfo, serial, responseType, e);
3944 Return<void> retStatus
3945 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
3946 convertCharPtrToHidlString((char *) response));
3947 radioService[slotId]->checkReturnStatus(retStatus);
3948 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003949 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003950 }
3951
3952 return 0;
3953}
3954
Amit Mahajan759786a2017-03-03 17:35:47 -08003955int radio::separateConnectionResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003956 int responseType, int serial, RIL_Errno e,
3957 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003958 RLOGD("separateConnectionResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003959
3960 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003961 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003962 populateResponseInfo(responseInfo, serial, responseType, e);
3963 Return<void> retStatus
3964 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
3965 radioService[slotId]->checkReturnStatus(retStatus);
3966 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003967 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003968 slotId);
3969 }
3970
3971 return 0;
3972}
3973
Amit Mahajan759786a2017-03-03 17:35:47 -08003974int radio::setMuteResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003975 int responseType, int serial, RIL_Errno e,
3976 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003977 RLOGD("setMuteResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003978
3979 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003980 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003981 populateResponseInfo(responseInfo, serial, responseType, e);
3982 Return<void> retStatus
3983 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
3984 radioService[slotId]->checkReturnStatus(retStatus);
3985 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003986 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003987 }
3988
3989 return 0;
3990}
3991
Amit Mahajan759786a2017-03-03 17:35:47 -08003992int radio::getMuteResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003993 int responseType, int serial, RIL_Errno e, void *response,
3994 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08003995 RLOGD("getMuteResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003996
3997 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08003998 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08003999 populateResponseInfo(responseInfo, serial, responseType, e);
4000 bool enable = false;
4001 int serviceClass;
4002 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004003 RLOGE("getMuteResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004004 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4005 } else {
4006 int *pInt = (int *) response;
4007 enable = pInt[0] == 1 ? true : false;
4008 }
4009 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4010 enable);
4011 radioService[slotId]->checkReturnStatus(retStatus);
4012 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004013 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004014 }
4015
4016 return 0;
4017}
4018
Amit Mahajan759786a2017-03-03 17:35:47 -08004019int radio::getClipResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004020 int responseType, int serial, RIL_Errno e,
4021 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004022 RLOGD("getClipResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004023
4024 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004025 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004026 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4027 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4028 (ClipStatus) ret);
4029 radioService[slotId]->checkReturnStatus(retStatus);
4030 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004031 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004032 }
4033
4034 return 0;
4035}
4036
Amit Mahajan759786a2017-03-03 17:35:47 -08004037int radio::getDataCallListResponse(int slotId,
Amit Mahajan3df62912017-02-10 01:35:55 +00004038 int responseType, int serial, RIL_Errno e,
4039 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004040 RLOGD("getDataCallListResponse: serial %d", serial);
Amit Mahajan3df62912017-02-10 01:35:55 +00004041
4042 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08004043 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00004044 populateResponseInfo(responseInfo, serial, responseType, e);
4045
4046 hidl_vec<SetupDataCallResult> ret;
4047 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004048 RLOGE("getDataCallListResponse: invalid response");
Amit Mahajan3df62912017-02-10 01:35:55 +00004049 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4050 } else {
4051 convertRilDataCallListToHal(response, responseLen, ret);
4052 }
4053
4054 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4055 responseInfo, ret);
4056 radioService[slotId]->checkReturnStatus(retStatus);
4057 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004058 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Amit Mahajan3df62912017-02-10 01:35:55 +00004059 }
4060
4061 return 0;
4062}
4063
Amit Mahajan759786a2017-03-03 17:35:47 -08004064int radio::setSuppServiceNotificationsResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004065 int responseType, int serial, RIL_Errno e,
4066 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004067 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004068
4069 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004070 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004071 populateResponseInfo(responseInfo, serial, responseType, e);
4072 Return<void> retStatus
4073 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4074 responseInfo);
4075 radioService[slotId]->checkReturnStatus(retStatus);
4076 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004077 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004078 "== NULL", slotId);
4079 }
4080
4081 return 0;
4082}
4083
Amit Mahajan759786a2017-03-03 17:35:47 -08004084int radio::deleteSmsOnSimResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004085 int responseType, int serial, RIL_Errno e,
4086 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004087 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004088
4089 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004090 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004091 populateResponseInfo(responseInfo, serial, responseType, e);
4092 Return<void> retStatus
4093 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4094 radioService[slotId]->checkReturnStatus(retStatus);
4095 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004096 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004097 }
4098
4099 return 0;
4100}
4101
Amit Mahajan759786a2017-03-03 17:35:47 -08004102int radio::setBandModeResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004103 int responseType, int serial, RIL_Errno e,
4104 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004105 RLOGD("setBandModeResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004106
4107 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004108 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004109 populateResponseInfo(responseInfo, serial, responseType, e);
4110 Return<void> retStatus
4111 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4112 radioService[slotId]->checkReturnStatus(retStatus);
4113 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004114 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004115 }
4116
4117 return 0;
4118}
4119
Amit Mahajan759786a2017-03-03 17:35:47 -08004120int radio::writeSmsToSimResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004121 int responseType, int serial, RIL_Errno e,
4122 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004123 RLOGD("writeSmsToSimResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004124
4125 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004126 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004127 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4128 Return<void> retStatus
4129 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4130 radioService[slotId]->checkReturnStatus(retStatus);
4131 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004132 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004133 }
4134
4135 return 0;
4136}
4137
Amit Mahajan759786a2017-03-03 17:35:47 -08004138int radio::getAvailableBandModesResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004139 int responseType, int serial, RIL_Errno e, void *response,
4140 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004141 RLOGD("getAvailableBandModesResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004142
4143 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004144 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004145 populateResponseInfo(responseInfo, serial, responseType, e);
4146 hidl_vec<RadioBandMode> modes;
4147 if (response == NULL || responseLen % sizeof(int) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004148 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004149 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4150 } else {
4151 int *pInt = (int *) response;
4152 int numInts = responseLen / sizeof(int);
4153 modes.resize(numInts);
4154 for (int i = 0; i < numInts; i++) {
4155 modes[i] = (RadioBandMode) pInt[i];
4156 }
4157 }
4158 Return<void> retStatus
4159 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4160 modes);
4161 radioService[slotId]->checkReturnStatus(retStatus);
4162 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004163 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004164 slotId);
4165 }
4166
4167 return 0;
4168}
4169
Amit Mahajan759786a2017-03-03 17:35:47 -08004170int radio::sendEnvelopeResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004171 int responseType, int serial, RIL_Errno e,
4172 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004173 RLOGD("sendEnvelopeResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004174
4175 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004176 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004177 populateResponseInfo(responseInfo, serial, responseType, e);
4178 Return<void> retStatus
4179 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4180 convertCharPtrToHidlString((char *) response));
4181 radioService[slotId]->checkReturnStatus(retStatus);
4182 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004183 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004184 }
4185
4186 return 0;
4187}
4188
Amit Mahajan759786a2017-03-03 17:35:47 -08004189int radio::sendTerminalResponseToSimResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004190 int responseType, int serial, RIL_Errno e,
4191 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004192 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004193
4194 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004195 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004196 populateResponseInfo(responseInfo, serial, responseType, e);
4197 Return<void> retStatus
4198 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4199 responseInfo);
4200 radioService[slotId]->checkReturnStatus(retStatus);
4201 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004202 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004203 slotId);
4204 }
4205
4206 return 0;
4207}
4208
Amit Mahajan759786a2017-03-03 17:35:47 -08004209int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4210 int responseType, int serial,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004211 RIL_Errno e, void *response,
4212 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004213 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004214
4215 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004216 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004217 populateResponseInfo(responseInfo, serial, responseType, e);
4218 Return<void> retStatus
4219 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4220 responseInfo);
4221 radioService[slotId]->checkReturnStatus(retStatus);
4222 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004223 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004224 "== NULL", slotId);
4225 }
4226
4227 return 0;
4228}
4229
Amit Mahajan759786a2017-03-03 17:35:47 -08004230int radio::explicitCallTransferResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004231 int responseType, int serial, RIL_Errno e,
4232 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004233 RLOGD("explicitCallTransferResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004234
4235 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004236 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004237 populateResponseInfo(responseInfo, serial, responseType, e);
4238 Return<void> retStatus
4239 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4240 radioService[slotId]->checkReturnStatus(retStatus);
4241 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004242 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004243 slotId);
4244 }
4245
4246 return 0;
4247}
4248
Amit Mahajan759786a2017-03-03 17:35:47 -08004249int radio::setPreferredNetworkTypeResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004250 int responseType, int serial, RIL_Errno e,
4251 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004252 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004253
4254 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004255 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004256 populateResponseInfo(responseInfo, serial, responseType, e);
4257 Return<void> retStatus
4258 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4259 responseInfo);
4260 radioService[slotId]->checkReturnStatus(retStatus);
4261 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004262 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004263 slotId);
4264 }
4265
4266 return 0;
4267}
4268
4269
Amit Mahajan759786a2017-03-03 17:35:47 -08004270int radio::getPreferredNetworkTypeResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004271 int responseType, int serial, RIL_Errno e,
4272 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004273 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004274
4275 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004276 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004277 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4278 Return<void> retStatus
4279 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4280 responseInfo, (PreferredNetworkType) ret);
4281 radioService[slotId]->checkReturnStatus(retStatus);
4282 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004283 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004284 slotId);
4285 }
4286
4287 return 0;
4288}
4289
Amit Mahajan759786a2017-03-03 17:35:47 -08004290int radio::getNeighboringCidsResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004291 int responseType, int serial, RIL_Errno e,
4292 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004293 RLOGD("getNeighboringCidsResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004294
4295 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004296 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004297 populateResponseInfo(responseInfo, serial, responseType, e);
4298 hidl_vec<NeighboringCell> cells;
4299
4300 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004301 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004302 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4303 } else {
4304 int num = responseLen / sizeof(RIL_NeighboringCell *);
4305 cells.resize(num);
4306 for (int i = 0 ; i < num; i++) {
4307 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4308 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4309 cells[i].rssi = resp->rssi;
4310 }
4311 }
4312
4313 Return<void> retStatus
4314 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4315 cells);
4316 radioService[slotId]->checkReturnStatus(retStatus);
4317 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004318 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004319 slotId);
4320 }
4321
4322 return 0;
4323}
4324
Amit Mahajan759786a2017-03-03 17:35:47 -08004325int radio::setLocationUpdatesResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004326 int responseType, int serial, RIL_Errno e,
4327 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004328 RLOGD("setLocationUpdatesResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004329
4330 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004331 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004332 populateResponseInfo(responseInfo, serial, responseType, e);
4333 Return<void> retStatus
4334 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4335 radioService[slotId]->checkReturnStatus(retStatus);
4336 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004337 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004338 slotId);
4339 }
4340
4341 return 0;
4342}
4343
Amit Mahajan759786a2017-03-03 17:35:47 -08004344int radio::setCdmaSubscriptionSourceResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004345 int responseType, int serial, RIL_Errno e,
4346 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004347 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004348
4349 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004350 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004351 populateResponseInfo(responseInfo, serial, responseType, e);
4352 Return<void> retStatus
4353 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4354 responseInfo);
4355 radioService[slotId]->checkReturnStatus(retStatus);
4356 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004357 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004358 slotId);
4359 }
4360
4361 return 0;
4362}
4363
Amit Mahajan759786a2017-03-03 17:35:47 -08004364int radio::setCdmaRoamingPreferenceResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004365 int responseType, int serial, RIL_Errno e,
4366 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004367 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004368
4369 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004370 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004371 populateResponseInfo(responseInfo, serial, responseType, e);
4372 Return<void> retStatus
4373 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4374 responseInfo);
4375 radioService[slotId]->checkReturnStatus(retStatus);
4376 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004377 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004378 slotId);
4379 }
4380
4381 return 0;
4382}
4383
Amit Mahajan759786a2017-03-03 17:35:47 -08004384int radio::getCdmaRoamingPreferenceResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004385 int responseType, int serial, RIL_Errno e,
4386 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004387 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004388
4389 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004390 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004391 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4392 Return<void> retStatus
4393 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4394 responseInfo, (CdmaRoamingType) ret);
4395 radioService[slotId]->checkReturnStatus(retStatus);
4396 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004397 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004398 slotId);
4399 }
4400
4401 return 0;
4402}
4403
Amit Mahajan759786a2017-03-03 17:35:47 -08004404int radio::setTTYModeResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004405 int responseType, int serial, RIL_Errno e,
4406 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004407 RLOGD("setTTYModeResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004408
4409 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004410 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004411 populateResponseInfo(responseInfo, serial, responseType, e);
4412 Return<void> retStatus
4413 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4414 radioService[slotId]->checkReturnStatus(retStatus);
4415 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004416 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004417 }
4418
4419 return 0;
4420}
4421
Amit Mahajan759786a2017-03-03 17:35:47 -08004422int radio::getTTYModeResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004423 int responseType, int serial, RIL_Errno e,
4424 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004425 RLOGD("getTTYModeResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004426
4427 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004428 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004429 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4430 Return<void> retStatus
4431 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4432 (TtyMode) ret);
4433 radioService[slotId]->checkReturnStatus(retStatus);
4434 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004435 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004436 }
4437
4438 return 0;
4439}
4440
Amit Mahajan759786a2017-03-03 17:35:47 -08004441int radio::setPreferredVoicePrivacyResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004442 int responseType, int serial, RIL_Errno e,
4443 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004444 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004445
4446 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004447 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004448 populateResponseInfo(responseInfo, serial, responseType, e);
4449 Return<void> retStatus
4450 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4451 responseInfo);
4452 radioService[slotId]->checkReturnStatus(retStatus);
4453 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004454 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004455 slotId);
4456 }
4457
4458 return 0;
4459}
4460
Amit Mahajan759786a2017-03-03 17:35:47 -08004461int radio::getPreferredVoicePrivacyResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004462 int responseType, int serial, RIL_Errno e,
4463 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004464 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004465
4466 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004467 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004468 populateResponseInfo(responseInfo, serial, responseType, e);
4469 bool enable = false;
4470 int numInts = responseLen / sizeof(int);
4471 if (response == NULL || numInts != 1) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004472 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004473 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4474 } else {
4475 int *pInt = (int *) response;
4476 enable = pInt[0] == 1 ? true : false;
4477 }
4478 Return<void> retStatus
4479 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
4480 responseInfo, enable);
4481 radioService[slotId]->checkReturnStatus(retStatus);
4482 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004483 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004484 slotId);
4485 }
4486
4487 return 0;
4488}
4489
Amit Mahajan759786a2017-03-03 17:35:47 -08004490int radio::sendCDMAFeatureCodeResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004491 int responseType, int serial, RIL_Errno e,
4492 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004493 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004494
4495 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004496 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004497 populateResponseInfo(responseInfo, serial, responseType, e);
4498 Return<void> retStatus
4499 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
4500 radioService[slotId]->checkReturnStatus(retStatus);
4501 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004502 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004503 slotId);
4504 }
4505
4506 return 0;
4507}
4508
Amit Mahajan759786a2017-03-03 17:35:47 -08004509int radio::sendBurstDtmfResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004510 int responseType, int serial, RIL_Errno e,
4511 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004512 RLOGD("sendBurstDtmfResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004513
4514 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004515 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004516 populateResponseInfo(responseInfo, serial, responseType, e);
4517 Return<void> retStatus
4518 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
4519 radioService[slotId]->checkReturnStatus(retStatus);
4520 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004521 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004522 }
4523
4524 return 0;
4525}
4526
Amit Mahajan759786a2017-03-03 17:35:47 -08004527int radio::sendCdmaSmsResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004528 int responseType, int serial, RIL_Errno e, void *response,
4529 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004530 RLOGD("sendCdmaSmsResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004531
4532 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004533 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004534 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4535 responseLen);
4536
4537 Return<void> retStatus
4538 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
4539 radioService[slotId]->checkReturnStatus(retStatus);
4540 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004541 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004542 }
4543
4544 return 0;
4545}
4546
Amit Mahajan759786a2017-03-03 17:35:47 -08004547int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004548 int responseType, int serial, RIL_Errno e,
4549 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004550 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004551
4552 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004553 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004554 populateResponseInfo(responseInfo, serial, responseType, e);
4555 Return<void> retStatus
4556 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
4557 responseInfo);
4558 radioService[slotId]->checkReturnStatus(retStatus);
4559 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004560 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004561 "== NULL", slotId);
4562 }
4563
4564 return 0;
4565}
4566
Amit Mahajan759786a2017-03-03 17:35:47 -08004567int radio::getGsmBroadcastConfigResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004568 int responseType, int serial, RIL_Errno e,
4569 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004570 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004571
4572 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004573 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004574 populateResponseInfo(responseInfo, serial, responseType, e);
4575 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
4576
4577 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004578 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004579 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4580 } else {
4581 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
4582 configs.resize(num);
4583 for (int i = 0 ; i < num; i++) {
4584 RIL_GSM_BroadcastSmsConfigInfo *resp =
4585 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
4586 configs[i].fromServiceId = resp->fromServiceId;
4587 configs[i].toServiceId = resp->toServiceId;
4588 configs[i].fromCodeScheme = resp->fromCodeScheme;
4589 configs[i].toCodeScheme = resp->toCodeScheme;
4590 configs[i].selected = resp->selected == 1 ? true : false;
4591 }
4592 }
4593
4594 Return<void> retStatus
4595 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
4596 configs);
4597 radioService[slotId]->checkReturnStatus(retStatus);
4598 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004599 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004600 slotId);
4601 }
4602
4603 return 0;
4604}
4605
Amit Mahajan759786a2017-03-03 17:35:47 -08004606int radio::setGsmBroadcastConfigResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004607 int responseType, int serial, RIL_Errno e,
4608 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004609 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004610
4611 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004612 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004613 populateResponseInfo(responseInfo, serial, responseType, e);
4614 Return<void> retStatus
4615 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
4616 radioService[slotId]->checkReturnStatus(retStatus);
4617 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004618 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004619 slotId);
4620 }
4621
4622 return 0;
4623}
4624
Amit Mahajan759786a2017-03-03 17:35:47 -08004625int radio::setGsmBroadcastActivationResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004626 int responseType, int serial, RIL_Errno e,
4627 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004628 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004629
4630 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004631 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004632 populateResponseInfo(responseInfo, serial, responseType, e);
4633 Return<void> retStatus
4634 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
4635 responseInfo);
4636 radioService[slotId]->checkReturnStatus(retStatus);
4637 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004638 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004639 slotId);
4640 }
4641
4642 return 0;
4643}
4644
Amit Mahajan759786a2017-03-03 17:35:47 -08004645int radio::getCdmaBroadcastConfigResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004646 int responseType, int serial, RIL_Errno e,
4647 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004648 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004649
4650 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004651 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004652 populateResponseInfo(responseInfo, serial, responseType, e);
4653 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
4654
4655 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004656 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004657 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4658 } else {
4659 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
4660 configs.resize(num);
4661 for (int i = 0 ; i < num; i++) {
4662 RIL_CDMA_BroadcastSmsConfigInfo *resp =
4663 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
4664 configs[i].serviceCategory = resp->service_category;
4665 configs[i].language = resp->language;
4666 configs[i].selected = resp->selected == 1 ? true : false;
4667 }
4668 }
4669
4670 Return<void> retStatus
4671 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
4672 configs);
4673 radioService[slotId]->checkReturnStatus(retStatus);
4674 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004675 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004676 slotId);
4677 }
4678
4679 return 0;
4680}
4681
Amit Mahajan759786a2017-03-03 17:35:47 -08004682int radio::setCdmaBroadcastConfigResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004683 int responseType, int serial, RIL_Errno e,
4684 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004685 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004686
4687 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004688 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004689 populateResponseInfo(responseInfo, serial, responseType, e);
4690 Return<void> retStatus
4691 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
4692 responseInfo);
4693 radioService[slotId]->checkReturnStatus(retStatus);
4694 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004695 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004696 slotId);
4697 }
4698
4699 return 0;
4700}
4701
Amit Mahajan759786a2017-03-03 17:35:47 -08004702int radio::setCdmaBroadcastActivationResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004703 int responseType, int serial, RIL_Errno e,
4704 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004705 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004706
4707 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004708 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004709 populateResponseInfo(responseInfo, serial, responseType, e);
4710 Return<void> retStatus
4711 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
4712 responseInfo);
4713 radioService[slotId]->checkReturnStatus(retStatus);
4714 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004715 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004716 slotId);
4717 }
4718
4719 return 0;
4720}
4721
Amit Mahajan759786a2017-03-03 17:35:47 -08004722int radio::getCDMASubscriptionResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004723 int responseType, int serial, RIL_Errno e, void *response,
4724 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004725 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004726
4727 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004728 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004729 populateResponseInfo(responseInfo, serial, responseType, e);
4730
4731 int numStrings = responseLen / sizeof(char *);
4732 hidl_string emptyString;
4733 if (response == NULL || numStrings != 5) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004734 RLOGE("getOperatorResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004735 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4736 Return<void> retStatus
4737 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
4738 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
4739 radioService[slotId]->checkReturnStatus(retStatus);
4740 } else {
4741 char **resp = (char **) response;
4742 Return<void> retStatus
4743 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
4744 responseInfo,
4745 convertCharPtrToHidlString(resp[0]),
4746 convertCharPtrToHidlString(resp[1]),
4747 convertCharPtrToHidlString(resp[2]),
4748 convertCharPtrToHidlString(resp[3]),
4749 convertCharPtrToHidlString(resp[4]));
4750 radioService[slotId]->checkReturnStatus(retStatus);
4751 }
4752 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004753 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004754 slotId);
4755 }
4756
4757 return 0;
4758}
4759
Amit Mahajan759786a2017-03-03 17:35:47 -08004760int radio::writeSmsToRuimResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004761 int responseType, int serial, RIL_Errno e,
4762 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004763 RLOGD("writeSmsToRuimResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004764
4765 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004766 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004767 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4768 Return<void> retStatus
4769 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
4770 radioService[slotId]->checkReturnStatus(retStatus);
4771 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004772 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004773 }
4774
4775 return 0;
4776}
4777
Amit Mahajan759786a2017-03-03 17:35:47 -08004778int radio::deleteSmsOnRuimResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004779 int responseType, int serial, RIL_Errno e,
4780 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004781 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004782
4783 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004784 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004785 populateResponseInfo(responseInfo, serial, responseType, e);
4786 Return<void> retStatus
4787 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
4788 radioService[slotId]->checkReturnStatus(retStatus);
4789 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004790 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004791 }
4792
4793 return 0;
4794}
4795
Amit Mahajan759786a2017-03-03 17:35:47 -08004796int radio::getDeviceIdentityResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004797 int responseType, int serial, RIL_Errno e, void *response,
4798 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004799 RLOGD("getDeviceIdentityResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004800
4801 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004802 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004803 populateResponseInfo(responseInfo, serial, responseType, e);
4804
4805 int numStrings = responseLen / sizeof(char *);
4806 hidl_string emptyString;
4807 if (response == NULL || numStrings != 4) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004808 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004809 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4810 Return<void> retStatus
4811 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
4812 emptyString, emptyString, emptyString, emptyString);
4813 radioService[slotId]->checkReturnStatus(retStatus);
4814 } else {
4815 char **resp = (char **) response;
4816 Return<void> retStatus
4817 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
4818 convertCharPtrToHidlString(resp[0]),
4819 convertCharPtrToHidlString(resp[1]),
4820 convertCharPtrToHidlString(resp[2]),
4821 convertCharPtrToHidlString(resp[3]));
4822 radioService[slotId]->checkReturnStatus(retStatus);
4823 }
4824 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004825 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004826 slotId);
4827 }
4828
4829 return 0;
4830}
4831
Amit Mahajan759786a2017-03-03 17:35:47 -08004832int radio::exitEmergencyCallbackModeResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004833 int responseType, int serial, RIL_Errno e,
4834 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004835 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004836
4837 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004838 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004839 populateResponseInfo(responseInfo, serial, responseType, e);
4840 Return<void> retStatus
4841 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
4842 responseInfo);
4843 radioService[slotId]->checkReturnStatus(retStatus);
4844 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004845 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004846 slotId);
4847 }
4848
4849 return 0;
4850}
4851
Amit Mahajan759786a2017-03-03 17:35:47 -08004852int radio::getSmscAddressResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004853 int responseType, int serial, RIL_Errno e,
4854 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004855 RLOGD("getSmscAddressResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004856
4857 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004858 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004859 populateResponseInfo(responseInfo, serial, responseType, e);
4860 Return<void> retStatus
4861 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
4862 convertCharPtrToHidlString((char *) response));
4863 radioService[slotId]->checkReturnStatus(retStatus);
4864 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004865 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004866 }
4867
4868 return 0;
4869}
4870
Amit Mahajan759786a2017-03-03 17:35:47 -08004871int radio::setSmscAddressResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004872 int responseType, int serial, RIL_Errno e,
4873 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004874 RLOGD("setSmscAddressResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004875
4876 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004877 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004878 populateResponseInfo(responseInfo, serial, responseType, e);
4879 Return<void> retStatus
4880 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
4881 radioService[slotId]->checkReturnStatus(retStatus);
4882 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004883 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004884 }
4885
4886 return 0;
4887}
4888
Amit Mahajan759786a2017-03-03 17:35:47 -08004889int radio::reportSmsMemoryStatusResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004890 int responseType, int serial, RIL_Errno e,
4891 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004892 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004893
4894 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004895 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004896 populateResponseInfo(responseInfo, serial, responseType, e);
4897 Return<void> retStatus
4898 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
4899 radioService[slotId]->checkReturnStatus(retStatus);
4900 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004901 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004902 slotId);
4903 }
4904
4905 return 0;
4906}
4907
Amit Mahajan759786a2017-03-03 17:35:47 -08004908int radio::reportStkServiceIsRunningResponse(int slotId,
Amit Mahajan5007ffa2017-01-31 17:14:42 -08004909 int responseType, int serial, RIL_Errno e,
4910 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004911 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
Amit Mahajan5007ffa2017-01-31 17:14:42 -08004912
4913 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08004914 RadioResponseInfo responseInfo = {};
Amit Mahajan5007ffa2017-01-31 17:14:42 -08004915 populateResponseInfo(responseInfo, serial, responseType, e);
4916 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4917 reportStkServiceIsRunningResponse(responseInfo);
4918 radioService[slotId]->checkReturnStatus(retStatus);
4919 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004920 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
Amit Mahajan5007ffa2017-01-31 17:14:42 -08004921 slotId);
4922 }
4923
4924 return 0;
4925}
4926
Amit Mahajan759786a2017-03-03 17:35:47 -08004927int radio::getCdmaSubscriptionSourceResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004928 int responseType, int serial, RIL_Errno e,
4929 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004930 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004931
4932 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004933 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004934 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4935 Return<void> retStatus
4936 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
4937 responseInfo, (CdmaSubscriptionSource) ret);
4938 radioService[slotId]->checkReturnStatus(retStatus);
4939 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004940 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004941 slotId);
4942 }
4943
4944 return 0;
4945}
4946
Amit Mahajan759786a2017-03-03 17:35:47 -08004947int radio::requestIsimAuthenticationResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004948 int responseType, int serial, RIL_Errno e,
4949 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004950 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004951
4952 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004953 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004954 populateResponseInfo(responseInfo, serial, responseType, e);
4955 Return<void> retStatus
4956 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
4957 responseInfo,
4958 convertCharPtrToHidlString((char *) response));
4959 radioService[slotId]->checkReturnStatus(retStatus);
4960 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004961 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004962 slotId);
4963 }
4964
4965 return 0;
4966}
4967
Amit Mahajan759786a2017-03-03 17:35:47 -08004968int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
4969 int responseType,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004970 int serial, RIL_Errno e, void *response,
4971 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004972 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004973
4974 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004975 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004976 populateResponseInfo(responseInfo, serial, responseType, e);
4977 Return<void> retStatus
4978 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
4979 responseInfo);
4980 radioService[slotId]->checkReturnStatus(retStatus);
4981 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004982 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004983 "== NULL", slotId);
4984 }
4985
4986 return 0;
4987}
4988
Amit Mahajan759786a2017-03-03 17:35:47 -08004989int radio::sendEnvelopeWithStatusResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004990 int responseType, int serial, RIL_Errno e, void *response,
4991 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08004992 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004993
4994 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08004995 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08004996 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
4997 response, responseLen);
4998
4999 Return<void> retStatus
5000 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5001 result);
5002 radioService[slotId]->checkReturnStatus(retStatus);
5003 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005004 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005005 slotId);
5006 }
5007
5008 return 0;
5009}
5010
Amit Mahajan759786a2017-03-03 17:35:47 -08005011int radio::getVoiceRadioTechnologyResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005012 int responseType, int serial, RIL_Errno e,
5013 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005014 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005015
5016 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005017 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005018 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5019 Return<void> retStatus
5020 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5021 responseInfo, (RadioTechnology) ret);
5022 radioService[slotId]->checkReturnStatus(retStatus);
5023 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005024 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005025 slotId);
5026 }
5027
5028 return 0;
5029}
5030
Amit Mahajan759786a2017-03-03 17:35:47 -08005031int radio::getCellInfoListResponse(int slotId,
5032 int responseType,
Amit Mahajan3df62912017-02-10 01:35:55 +00005033 int serial, RIL_Errno e, void *response,
5034 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005035 RLOGD("getCellInfoListResponse: serial %d", serial);
Amit Mahajan3df62912017-02-10 01:35:55 +00005036
5037 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005038 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00005039 populateResponseInfo(responseInfo, serial, responseType, e);
5040
5041 hidl_vec<CellInfo> ret;
5042 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005043 RLOGE("getCellInfoListResponse: Invalid response");
Amit Mahajan3df62912017-02-10 01:35:55 +00005044 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5045 } else {
5046 convertRilCellInfoListToHal(response, responseLen, ret);
5047 }
5048
5049 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5050 responseInfo, ret);
5051 radioService[slotId]->checkReturnStatus(retStatus);
5052 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005053 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Amit Mahajan3df62912017-02-10 01:35:55 +00005054 }
5055
5056 return 0;
5057}
5058
Amit Mahajan759786a2017-03-03 17:35:47 -08005059int radio::setCellInfoListRateResponse(int slotId,
5060 int responseType,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005061 int serial, RIL_Errno e, void *response,
5062 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005063 RLOGD("setCellInfoListRateResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005064
5065 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005066 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005067 populateResponseInfo(responseInfo, serial, responseType, e);
5068 Return<void> retStatus
5069 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5070 radioService[slotId]->checkReturnStatus(retStatus);
5071 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005072 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005073 slotId);
5074 }
5075
5076 return 0;
5077}
5078
Amit Mahajan759786a2017-03-03 17:35:47 -08005079int radio::setInitialAttachApnResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005080 int responseType, int serial, RIL_Errno e,
5081 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005082 RLOGD("setInitialAttachApnResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005083
5084 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005085 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005086 populateResponseInfo(responseInfo, serial, responseType, e);
5087 Return<void> retStatus
5088 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5089 radioService[slotId]->checkReturnStatus(retStatus);
5090 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005091 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005092 slotId);
5093 }
5094
5095 return 0;
5096}
5097
Amit Mahajan759786a2017-03-03 17:35:47 -08005098int radio::getImsRegistrationStateResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005099 int responseType, int serial, RIL_Errno e,
5100 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005101 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005102
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 bool isRegistered = false;
5107 int ratFamily = 0;
5108 int numInts = responseLen / sizeof(int);
5109 if (response == NULL || numInts != 2) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005110 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005111 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5112 } else {
5113 int *pInt = (int *) response;
5114 isRegistered = pInt[0] == 1 ? true : false;
5115 ratFamily = pInt[1];
5116 }
5117 Return<void> retStatus
5118 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5119 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5120 radioService[slotId]->checkReturnStatus(retStatus);
5121 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005122 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005123 slotId);
5124 }
5125
5126 return 0;
5127}
5128
Amit Mahajan759786a2017-03-03 17:35:47 -08005129int radio::sendImsSmsResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005130 int responseType, int serial, RIL_Errno e, void *response,
5131 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005132 RLOGD("sendImsSmsResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005133
5134 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005135 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005136 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5137 responseLen);
5138
5139 Return<void> retStatus
5140 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5141 radioService[slotId]->checkReturnStatus(retStatus);
5142 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005143 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005144 }
5145
5146 return 0;
5147}
5148
Amit Mahajan759786a2017-03-03 17:35:47 -08005149int radio::iccTransmitApduBasicChannelResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005150 int responseType, int serial, RIL_Errno e,
5151 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005152 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005153
5154 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005155 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005156 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5157 responseLen);
5158
5159 Return<void> retStatus
5160 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5161 responseInfo, result);
5162 radioService[slotId]->checkReturnStatus(retStatus);
5163 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005164 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005165 "== NULL", slotId);
5166 }
5167
5168 return 0;
5169}
5170
Amit Mahajan759786a2017-03-03 17:35:47 -08005171int radio::iccOpenLogicalChannelResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005172 int responseType, int serial, RIL_Errno e, void *response,
5173 size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005174 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005175
5176 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005177 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005178 populateResponseInfo(responseInfo, serial, responseType, e);
5179 int channelId = -1;
5180 hidl_vec<int8_t> selectResponse;
5181 int numInts = responseLen / sizeof(int);
5182 if (response == NULL || responseLen % sizeof(int) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005183 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005184 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5185 } else {
5186 int *pInt = (int *) response;
5187 channelId = pInt[0];
5188 selectResponse.resize(numInts - 1);
5189 for (int i = 1; i < numInts; i++) {
5190 selectResponse[i - 1] = (int8_t) pInt[i];
5191 }
5192 }
5193 Return<void> retStatus
5194 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5195 channelId, selectResponse);
5196 radioService[slotId]->checkReturnStatus(retStatus);
5197 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005198 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005199 slotId);
5200 }
5201
5202 return 0;
5203}
5204
Amit Mahajan759786a2017-03-03 17:35:47 -08005205int radio::iccCloseLogicalChannelResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005206 int responseType, int serial, RIL_Errno e,
5207 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005208 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005209
5210 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005211 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005212 populateResponseInfo(responseInfo, serial, responseType, e);
5213 Return<void> retStatus
5214 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5215 responseInfo);
5216 radioService[slotId]->checkReturnStatus(retStatus);
5217 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005218 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005219 slotId);
5220 }
5221
5222 return 0;
5223}
5224
Amit Mahajan759786a2017-03-03 17:35:47 -08005225int radio::iccTransmitApduLogicalChannelResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005226 int responseType, int serial, RIL_Errno e,
5227 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005228 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005229
5230 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005231 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005232 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5233 responseLen);
5234
5235 Return<void> retStatus
5236 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5237 responseInfo, result);
5238 radioService[slotId]->checkReturnStatus(retStatus);
5239 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005240 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005241 "== NULL", slotId);
5242 }
5243
5244 return 0;
5245}
5246
Amit Mahajan759786a2017-03-03 17:35:47 -08005247int radio::nvReadItemResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005248 int responseType, int serial, RIL_Errno e,
5249 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005250 RLOGD("nvReadItemResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005251
5252 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005253 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005254 populateResponseInfo(responseInfo, serial, responseType, e);
5255 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5256 responseInfo,
5257 convertCharPtrToHidlString((char *) response));
5258 radioService[slotId]->checkReturnStatus(retStatus);
5259 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005260 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005261 }
5262
5263 return 0;
5264}
5265
Amit Mahajan759786a2017-03-03 17:35:47 -08005266int radio::nvWriteItemResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005267 int responseType, int serial, RIL_Errno e,
5268 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005269 RLOGD("nvWriteItemResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005270
5271 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005272 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005273 populateResponseInfo(responseInfo, serial, responseType, e);
5274 Return<void> retStatus
5275 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5276 radioService[slotId]->checkReturnStatus(retStatus);
5277 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005278 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005279 }
5280
5281 return 0;
5282}
5283
Amit Mahajan759786a2017-03-03 17:35:47 -08005284int radio::nvWriteCdmaPrlResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005285 int responseType, int serial, RIL_Errno e,
5286 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005287 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005288
5289 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005290 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005291 populateResponseInfo(responseInfo, serial, responseType, e);
5292 Return<void> retStatus
5293 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5294 radioService[slotId]->checkReturnStatus(retStatus);
5295 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005296 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005297 }
5298
5299 return 0;
5300}
5301
Amit Mahajan759786a2017-03-03 17:35:47 -08005302int radio::nvResetConfigResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005303 int responseType, int serial, RIL_Errno e,
5304 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005305 RLOGD("nvResetConfigResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005306
5307 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005308 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005309 populateResponseInfo(responseInfo, serial, responseType, e);
5310 Return<void> retStatus
5311 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5312 radioService[slotId]->checkReturnStatus(retStatus);
5313 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005314 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005315 }
5316
5317 return 0;
5318}
5319
Amit Mahajan759786a2017-03-03 17:35:47 -08005320int radio::setUiccSubscriptionResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005321 int responseType, int serial, RIL_Errno e,
5322 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005323 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005324
5325 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005326 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005327 populateResponseInfo(responseInfo, serial, responseType, e);
5328 Return<void> retStatus
5329 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5330 radioService[slotId]->checkReturnStatus(retStatus);
5331 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005332 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005333 slotId);
5334 }
5335
5336 return 0;
5337}
5338
Amit Mahajan759786a2017-03-03 17:35:47 -08005339int radio::setDataAllowedResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005340 int responseType, int serial, RIL_Errno e,
5341 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005342 RLOGD("setDataAllowedResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005343
5344 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005345 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005346 populateResponseInfo(responseInfo, serial, responseType, e);
5347 Return<void> retStatus
5348 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5349 radioService[slotId]->checkReturnStatus(retStatus);
5350 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005351 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005352 }
5353
5354 return 0;
5355}
5356
Amit Mahajan759786a2017-03-03 17:35:47 -08005357int radio::getHardwareConfigResponse(int slotId,
Amit Mahajan3df62912017-02-10 01:35:55 +00005358 int responseType, int serial, RIL_Errno e,
5359 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005360 RLOGD("getHardwareConfigResponse: serial %d", serial);
Amit Mahajan3df62912017-02-10 01:35:55 +00005361
5362 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005363 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00005364 populateResponseInfo(responseInfo, serial, responseType, e);
5365
5366 hidl_vec<HardwareConfig> result;
5367 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005368 RLOGE("hardwareConfigChangedInd: invalid response");
Amit Mahajan3df62912017-02-10 01:35:55 +00005369 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5370 } else {
5371 convertRilHardwareConfigListToHal(response, responseLen, result);
5372 }
5373
5374 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
5375 responseInfo, result);
5376 radioService[slotId]->checkReturnStatus(retStatus);
5377 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005378 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Amit Mahajan3df62912017-02-10 01:35:55 +00005379 }
5380
5381 return 0;
5382}
5383
Amit Mahajan759786a2017-03-03 17:35:47 -08005384int radio::requestIccSimAuthenticationResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005385 int responseType, int serial, RIL_Errno e,
5386 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005387 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005388
5389 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005390 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005391 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5392 responseLen);
5393
5394 Return<void> retStatus
5395 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
5396 responseInfo, result);
5397 radioService[slotId]->checkReturnStatus(retStatus);
5398 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005399 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005400 "== NULL", slotId);
5401 }
5402
5403 return 0;
5404}
5405
Amit Mahajan759786a2017-03-03 17:35:47 -08005406int radio::setDataProfileResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005407 int responseType, int serial, RIL_Errno e,
5408 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005409 RLOGD("setDataProfileResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005410
5411 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005412 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005413 populateResponseInfo(responseInfo, serial, responseType, e);
5414 Return<void> retStatus
5415 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
5416 radioService[slotId]->checkReturnStatus(retStatus);
5417 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005418 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005419 }
5420
5421 return 0;
5422}
5423
Amit Mahajan759786a2017-03-03 17:35:47 -08005424int radio::requestShutdownResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005425 int responseType, int serial, RIL_Errno e,
5426 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005427 RLOGD("requestShutdownResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005428
5429 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005430 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005431 populateResponseInfo(responseInfo, serial, responseType, e);
5432 Return<void> retStatus
5433 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
5434 radioService[slotId]->checkReturnStatus(retStatus);
5435 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005436 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005437 }
5438
5439 return 0;
5440}
5441
Amit Mahajan3df62912017-02-10 01:35:55 +00005442void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
5443 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
5444 populateResponseInfo(responseInfo, serial, responseType, e);
5445
Amit Mahajan1fbff082017-02-24 11:24:39 -08005446 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
Amit Mahajan3df62912017-02-10 01:35:55 +00005447 RLOGE("responseRadioCapability: Invalid response");
5448 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005449 rc.logicalModemUuid = hidl_string();
Amit Mahajan3df62912017-02-10 01:35:55 +00005450 } else {
5451 convertRilRadioCapabilityToHal(response, responseLen, rc);
5452 }
5453}
5454
Amit Mahajan759786a2017-03-03 17:35:47 -08005455int radio::getRadioCapabilityResponse(int slotId,
Amit Mahajan3df62912017-02-10 01:35:55 +00005456 int responseType, int serial, RIL_Errno e,
5457 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005458 RLOGD("getRadioCapabilityResponse: serial %d", serial);
Amit Mahajan3df62912017-02-10 01:35:55 +00005459
5460 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005461 RadioResponseInfo responseInfo = {};
5462 RadioCapability result = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00005463 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
5464 result);
5465 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
5466 responseInfo, result);
5467 radioService[slotId]->checkReturnStatus(retStatus);
5468 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005469 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Amit Mahajan3df62912017-02-10 01:35:55 +00005470 }
5471
5472 return 0;
5473}
5474
Amit Mahajan759786a2017-03-03 17:35:47 -08005475int radio::setRadioCapabilityResponse(int slotId,
Amit Mahajan3df62912017-02-10 01:35:55 +00005476 int responseType, int serial, RIL_Errno e,
5477 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005478 RLOGD("setRadioCapabilityResponse: serial %d", serial);
Amit Mahajan3df62912017-02-10 01:35:55 +00005479
5480 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005481 RadioResponseInfo responseInfo = {};
5482 RadioCapability result = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00005483 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
5484 result);
5485 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
5486 responseInfo, result);
5487 radioService[slotId]->checkReturnStatus(retStatus);
5488 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005489 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Amit Mahajan3df62912017-02-10 01:35:55 +00005490 }
5491
5492 return 0;
5493}
5494
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005495LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
5496 RIL_Errno e, void *response, size_t responseLen) {
5497 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08005498 LceStatusInfo result = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005499
5500 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
5501 RLOGE("Invalid response: NULL");
5502 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005503 } else {
5504 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
5505 result.lceStatus = (LceStatus) resp->lce_status;
5506 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
5507 }
5508 return result;
5509}
5510
Amit Mahajan759786a2017-03-03 17:35:47 -08005511int radio::startLceServiceResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005512 int responseType, int serial, RIL_Errno e,
5513 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005514 RLOGD("startLceServiceResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005515
5516 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005517 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005518 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
5519 response, responseLen);
5520
5521 Return<void> retStatus
5522 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
5523 result);
5524 radioService[slotId]->checkReturnStatus(retStatus);
5525 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005526 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005527 }
5528
5529 return 0;
5530}
5531
Amit Mahajan759786a2017-03-03 17:35:47 -08005532int radio::stopLceServiceResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005533 int responseType, int serial, RIL_Errno e,
5534 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005535 RLOGD("stopLceServiceResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005536
5537 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005538 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005539 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
5540 response, responseLen);
5541
5542 Return<void> retStatus
5543 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
5544 result);
5545 radioService[slotId]->checkReturnStatus(retStatus);
5546 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005547 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005548 }
5549
5550 return 0;
5551}
5552
Amit Mahajan759786a2017-03-03 17:35:47 -08005553int radio::pullLceDataResponse(int slotId,
Amit Mahajan3df62912017-02-10 01:35:55 +00005554 int responseType, int serial, RIL_Errno e,
5555 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005556 RLOGD("pullLceDataResponse: serial %d", serial);
Amit Mahajan3df62912017-02-10 01:35:55 +00005557
5558 if (radioService[slotId]->mRadioResponse != NULL) {
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005559 RadioResponseInfo responseInfo = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00005560 populateResponseInfo(responseInfo, serial, responseType, e);
5561
Amit Mahajan3da9ac02017-02-13 13:41:28 -08005562 LceDataInfo result = {};
Amit Mahajan3df62912017-02-10 01:35:55 +00005563 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005564 RLOGE("pullLceDataResponse: Invalid response");
Amit Mahajan3df62912017-02-10 01:35:55 +00005565 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Amit Mahajan3df62912017-02-10 01:35:55 +00005566 } else {
5567 convertRilLceDataInfoToHal(response, responseLen, result);
5568 }
5569
5570 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
5571 responseInfo, result);
5572 radioService[slotId]->checkReturnStatus(retStatus);
5573 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005574 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Amit Mahajan3df62912017-02-10 01:35:55 +00005575 }
5576
5577 return 0;
5578}
5579
Amit Mahajan759786a2017-03-03 17:35:47 -08005580int radio::getModemActivityInfoResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005581 int responseType, int serial, RIL_Errno e,
5582 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005583 RLOGD("getModemActivityInfoResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005584
5585 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005586 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005587 populateResponseInfo(responseInfo, serial, responseType, e);
5588 ActivityStatsInfo info;
5589 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005590 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005591 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005592 } else {
5593 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
5594 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
5595 info.idleModeTimeMs = resp->idle_mode_time_ms;
5596 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
5597 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
5598 }
5599 info.rxModeTimeMs = resp->rx_mode_time_ms;
5600 }
5601
5602 Return<void> retStatus
5603 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
5604 info);
5605 radioService[slotId]->checkReturnStatus(retStatus);
5606 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005607 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005608 slotId);
5609 }
5610
5611 return 0;
5612}
5613
Amit Mahajan759786a2017-03-03 17:35:47 -08005614int radio::setAllowedCarriersResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005615 int responseType, int serial, RIL_Errno e,
5616 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005617 RLOGD("setAllowedCarriersResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005618
5619 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005620 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005621 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5622 Return<void> retStatus
5623 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
5624 ret);
5625 radioService[slotId]->checkReturnStatus(retStatus);
5626 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005627 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005628 slotId);
5629 }
5630
5631 return 0;
5632}
5633
Amit Mahajan759786a2017-03-03 17:35:47 -08005634int radio::getAllowedCarriersResponse(int slotId,
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005635 int responseType, int serial, RIL_Errno e,
5636 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005637 RLOGD("getAllowedCarriersResponse: serial %d", serial);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005638
5639 if (radioService[slotId]->mRadioResponse != NULL) {
Jack Yuf68e0da2017-02-07 14:53:09 -08005640 RadioResponseInfo responseInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005641 populateResponseInfo(responseInfo, serial, responseType, e);
Jack Yuf68e0da2017-02-07 14:53:09 -08005642 CarrierRestrictions carrierInfo = {};
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005643 bool allAllowed = true;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005644 if (response == NULL || responseLen != sizeof(RIL_CarrierRestrictions)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005645 RLOGE("getAllowedCarriersResponse Invalid response: NULL");
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005646 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5647 } else {
5648 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
5649 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
5650 allAllowed = false;
5651 }
5652
5653 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
5654 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
5655 RIL_Carrier *carrier = pCr->allowed_carriers + i;
5656 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
5657 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
5658 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
5659 carrierInfo.allowedCarriers[i].matchData =
5660 convertCharPtrToHidlString(carrier->match_data);
5661 }
5662
5663 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
5664 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
5665 RIL_Carrier *carrier = pCr->excluded_carriers + i;
5666 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
5667 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
5668 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
5669 carrierInfo.excludedCarriers[i].matchData =
5670 convertCharPtrToHidlString(carrier->match_data);
5671 }
5672 }
5673
5674 Return<void> retStatus
5675 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
5676 allAllowed, carrierInfo);
5677 radioService[slotId]->checkReturnStatus(retStatus);
5678 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005679 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005680 slotId);
5681 }
5682
5683 return 0;
5684}
5685
Amit Mahajan759786a2017-03-03 17:35:47 -08005686int radio::sendDeviceStateResponse(int slotId,
Jack Yu11ab4042017-02-21 17:08:01 -08005687 int responseType, int serial, RIL_Errno e,
5688 void *response, size_t responselen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005689 RLOGD("sendDeviceStateResponse: serial %d", serial);
Jack Yu11ab4042017-02-21 17:08:01 -08005690
5691 if (radioService[slotId]->mRadioResponse != NULL) {
5692 RadioResponseInfo responseInfo = {};
5693 populateResponseInfo(responseInfo, serial, responseType, e);
5694 Return<void> retStatus
5695 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
5696 radioService[slotId]->checkReturnStatus(retStatus);
5697 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005698 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Jack Yu11ab4042017-02-21 17:08:01 -08005699 }
5700
5701 return 0;
5702}
5703
Amit Mahajan759786a2017-03-03 17:35:47 -08005704int radio::setIndicationFilterResponse(int slotId,
Jack Yu11ab4042017-02-21 17:08:01 -08005705 int responseType, int serial, RIL_Errno e,
5706 void *response, size_t responselen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005707 RLOGD("setIndicationFilterResponse: serial %d", serial);
Jack Yu11ab4042017-02-21 17:08:01 -08005708
5709 if (radioService[slotId]->mRadioResponse != NULL) {
5710 RadioResponseInfo responseInfo = {};
5711 populateResponseInfo(responseInfo, serial, responseType, e);
5712 Return<void> retStatus
5713 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
5714 radioService[slotId]->checkReturnStatus(retStatus);
5715 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005716 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
Jack Yu11ab4042017-02-21 17:08:01 -08005717 slotId);
5718 }
5719
5720 return 0;
5721}
5722
5723
Amit Mahajan759786a2017-03-03 17:35:47 -08005724int radio::setSimCardPowerResponse(int slotId,
Wileen Chiu718c0bf2017-01-04 11:37:19 -08005725 int responseType, int serial, RIL_Errno e,
5726 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005727 RLOGD("setSimCardPowerResponse: serial %d", serial);
Wileen Chiu718c0bf2017-01-04 11:37:19 -08005728
5729 if (radioService[slotId]->mRadioResponse != NULL) {
5730 RadioResponseInfo responseInfo = {};
5731 populateResponseInfo(responseInfo, serial, responseType, e);
5732 Return<void> retStatus
5733 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
5734 radioService[slotId]->checkReturnStatus(retStatus);
5735 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005736 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
Wileen Chiu718c0bf2017-01-04 11:37:19 -08005737 }
5738
5739 return 0;
5740}
5741
Amit Mahajan759786a2017-03-03 17:35:47 -08005742int radio::sendRequestRawResponse(int slotId,
Amit Mahajan439da362017-02-13 17:43:04 -08005743 int responseType, int serial, RIL_Errno e,
5744 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005745 RLOGD("sendRequestRawResponse: serial %d", serial);
Amit Mahajan439da362017-02-13 17:43:04 -08005746
5747 if (oemHookService[slotId]->mOemHookResponse != NULL) {
5748 RadioResponseInfo responseInfo = {};
5749 populateResponseInfo(responseInfo, serial, responseType, e);
5750 hidl_vec<uint8_t> data;
5751
5752 if (response == NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005753 RLOGE("sendRequestRawResponse: Invalid response");
Amit Mahajan439da362017-02-13 17:43:04 -08005754 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5755 } else {
5756 data.setToExternal((uint8_t *) response, responseLen);
5757 }
5758 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
5759 sendRequestRawResponse(responseInfo, data);
Amit Mahajand423d192017-03-16 17:04:01 -07005760 checkReturnStatus(slotId, retStatus, false);
Amit Mahajan439da362017-02-13 17:43:04 -08005761 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005762 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
Amit Mahajan439da362017-02-13 17:43:04 -08005763 slotId);
5764 }
5765
5766 return 0;
5767}
5768
Amit Mahajan759786a2017-03-03 17:35:47 -08005769int radio::sendRequestStringsResponse(int slotId,
Amit Mahajan439da362017-02-13 17:43:04 -08005770 int responseType, int serial, RIL_Errno e,
5771 void *response, size_t responseLen) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005772 RLOGD("sendRequestStringsResponse: serial %d", serial);
Amit Mahajan439da362017-02-13 17:43:04 -08005773
5774 if (oemHookService[slotId]->mOemHookResponse != NULL) {
5775 RadioResponseInfo responseInfo = {};
5776 populateResponseInfo(responseInfo, serial, responseType, e);
5777 hidl_vec<hidl_string> data;
5778
5779 if (response == NULL || responseLen % sizeof(char *) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005780 RLOGE("sendRequestStringsResponse Invalid response: NULL");
Amit Mahajan439da362017-02-13 17:43:04 -08005781 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5782 } else {
5783 char **resp = (char **) response;
5784 int numStrings = responseLen / sizeof(char *);
5785 data.resize(numStrings);
5786 for (int i = 0; i < numStrings; i++) {
5787 data[i] = convertCharPtrToHidlString(resp[i]);
5788 }
5789 }
5790 Return<void> retStatus
5791 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
5792 responseInfo, data);
Amit Mahajand423d192017-03-16 17:04:01 -07005793 checkReturnStatus(slotId, retStatus, false);
Amit Mahajan439da362017-02-13 17:43:04 -08005794 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005795 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
Amit Mahajan439da362017-02-13 17:43:04 -08005796 "NULL", slotId);
5797 }
5798
5799 return 0;
5800}
5801
Sanket Padawe378ccdd2017-01-24 14:11:12 -08005802// Radio Indication functions
5803
Amit Mahajan5829a472016-12-28 17:28:07 -08005804RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
5805 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
5806 (RadioIndicationType::UNSOLICITED_ACK_EXP);
5807}
5808
Amit Mahajan759786a2017-03-03 17:35:47 -08005809int radio::radioStateChangedInd(int slotId,
Amit Mahajan1f652692017-03-01 12:08:46 -08005810 int indicationType, int token, RIL_Errno e, void *response,
5811 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005812 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1f652692017-03-01 12:08:46 -08005813 RadioState radioState = (RadioState) s_vendorFunctions->onStateRequest();
Amit Mahajan111ddca2017-03-03 12:05:13 -08005814 RLOGD("radioStateChangedInd: radioState %d", radioState);
Amit Mahajan17249842017-01-19 15:05:45 -08005815 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
Amit Mahajan1f652692017-03-01 12:08:46 -08005816 convertIntToRadioIndicationType(indicationType), radioState);
Amit Mahajan17249842017-01-19 15:05:45 -08005817 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07005818 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005819 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07005820 }
Amit Mahajan1f652692017-03-01 12:08:46 -08005821
5822 return 0;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07005823}
5824
Amit Mahajan759786a2017-03-03 17:35:47 -08005825int radio::callStateChangedInd(int slotId,
Amit Mahajan5829a472016-12-28 17:28:07 -08005826 int indicationType, int token, RIL_Errno e, void *response,
5827 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005828 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005829 RLOGD("callStateChangedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005830 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
Amit Mahajan5829a472016-12-28 17:28:07 -08005831 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08005832 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005833 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005834 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08005835 }
5836
5837 return 0;
5838}
5839
Amit Mahajan759786a2017-03-03 17:35:47 -08005840int radio::networkStateChangedInd(int slotId,
Amit Mahajan1f652692017-03-01 12:08:46 -08005841 int indicationType, int token, RIL_Errno e, void *response,
5842 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005843 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005844 RLOGD("networkStateChangedInd");
Jack Yu06181bb2017-01-10 12:10:41 -08005845 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
Amit Mahajan5829a472016-12-28 17:28:07 -08005846 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08005847 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005848 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005849 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08005850 slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08005851 }
5852
5853 return 0;
5854}
5855
5856uint8_t hexCharToInt(uint8_t c) {
5857 if (c >= '0' && c <= '9') return (c - '0');
5858 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
5859 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
5860
5861 return INVALID_HEX_CHAR;
5862}
5863
5864uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
5865 if (responseLen % 2 != 0) {
5866 return NULL;
5867 }
5868
5869 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
5870 if (bytes == NULL) {
5871 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
5872 return NULL;
5873 }
5874 uint8_t *hexString = (uint8_t *)response;
5875
Wei Wang100ac9b2017-02-03 14:18:07 -08005876 for (size_t i = 0; i < responseLen; i += 2) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005877 uint8_t hexChar1 = hexCharToInt(hexString[i]);
5878 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
5879
5880 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
5881 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
5882 hexString[i], hexString[i + 1]);
5883 free(bytes);
5884 return NULL;
5885 }
5886 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
5887 }
5888
5889 return bytes;
5890}
5891
Amit Mahajan759786a2017-03-03 17:35:47 -08005892int radio::newSmsInd(int slotId, int indicationType,
Amit Mahajan5829a472016-12-28 17:28:07 -08005893 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005894 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005895 if (response == NULL || responseLen == 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005896 RLOGE("newSmsInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08005897 return 0;
5898 }
5899
5900 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
5901 if (bytes == NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005902 RLOGE("newSmsInd: convertHexStringToBytes failed");
Amit Mahajan5829a472016-12-28 17:28:07 -08005903 return 0;
5904 }
5905
5906 hidl_vec<uint8_t> pdu;
5907 pdu.setToExternal(bytes, responseLen/2);
Amit Mahajan111ddca2017-03-03 12:05:13 -08005908 RLOGD("newSmsInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005909 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
Amit Mahajan5829a472016-12-28 17:28:07 -08005910 convertIntToRadioIndicationType(indicationType), pdu);
Amit Mahajan17249842017-01-19 15:05:45 -08005911 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005912 free(bytes);
5913 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005914 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08005915 }
5916
5917 return 0;
5918}
5919
Amit Mahajan759786a2017-03-03 17:35:47 -08005920int radio::newSmsStatusReportInd(int slotId,
Amit Mahajan5829a472016-12-28 17:28:07 -08005921 int indicationType, int token, RIL_Errno e, void *response,
5922 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005923 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005924 if (response == NULL || responseLen == 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005925 RLOGE("newSmsStatusReportInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08005926 return 0;
5927 }
5928
5929 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
5930 if (bytes == NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005931 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
Amit Mahajan5829a472016-12-28 17:28:07 -08005932 return 0;
5933 }
5934
5935 hidl_vec<uint8_t> pdu;
5936 pdu.setToExternal(bytes, responseLen/2);
Amit Mahajan111ddca2017-03-03 12:05:13 -08005937 RLOGD("newSmsStatusReportInd");
Amit Mahajan17249842017-01-19 15:05:45 -08005938 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
Amit Mahajan5829a472016-12-28 17:28:07 -08005939 convertIntToRadioIndicationType(indicationType), pdu);
Amit Mahajan17249842017-01-19 15:05:45 -08005940 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005941 free(bytes);
5942 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005943 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08005944 }
5945
5946 return 0;
5947}
5948
Amit Mahajan759786a2017-03-03 17:35:47 -08005949int radio::newSmsOnSimInd(int slotId, int indicationType,
Amit Mahajan5829a472016-12-28 17:28:07 -08005950 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005951 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005952 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005953 RLOGE("newSmsOnSimInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08005954 return 0;
5955 }
5956 int32_t recordNumber = ((int32_t *) response)[0];
Amit Mahajan111ddca2017-03-03 12:05:13 -08005957 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
Amit Mahajan17249842017-01-19 15:05:45 -08005958 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
Amit Mahajan5829a472016-12-28 17:28:07 -08005959 convertIntToRadioIndicationType(indicationType), recordNumber);
Amit Mahajan17249842017-01-19 15:05:45 -08005960 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005961 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005962 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08005963 }
5964
5965 return 0;
5966}
5967
Amit Mahajan759786a2017-03-03 17:35:47 -08005968int radio::onUssdInd(int slotId, int indicationType,
Amit Mahajan5829a472016-12-28 17:28:07 -08005969 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005970 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005971 if (response == NULL || responseLen != 2 * sizeof(char *)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005972 RLOGE("onUssdInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08005973 return 0;
5974 }
5975 char **strings = (char **) response;
5976 char *mode = strings[0];
5977 hidl_string msg = convertCharPtrToHidlString(strings[1]);
5978 UssdModeType modeType = (UssdModeType) atoi(mode);
Amit Mahajan111ddca2017-03-03 12:05:13 -08005979 RLOGD("onUssdInd: mode %s", mode);
Amit Mahajan17249842017-01-19 15:05:45 -08005980 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
Amit Mahajan5829a472016-12-28 17:28:07 -08005981 convertIntToRadioIndicationType(indicationType), modeType, msg);
Amit Mahajan17249842017-01-19 15:05:45 -08005982 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08005983 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005984 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08005985 }
5986
5987 return 0;
5988}
5989
Amit Mahajan759786a2017-03-03 17:35:47 -08005990int radio::nitzTimeReceivedInd(int slotId,
Amit Mahajan5829a472016-12-28 17:28:07 -08005991 int indicationType, int token, RIL_Errno e, void *response,
5992 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08005993 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08005994 if (response == NULL || responseLen == 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08005995 RLOGE("nitzTimeReceivedInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08005996 return 0;
5997 }
5998 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
5999 int64_t timeReceived = android::elapsedRealtime();
Amit Mahajan111ddca2017-03-03 12:05:13 -08006000 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006001 timeReceived);
Amit Mahajan17249842017-01-19 15:05:45 -08006002 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
Amit Mahajan5829a472016-12-28 17:28:07 -08006003 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
Amit Mahajan17249842017-01-19 15:05:45 -08006004 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006005 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006006 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
Weilun Dud2c30932017-02-09 12:32:42 -08006007 return -1;
Amit Mahajan5829a472016-12-28 17:28:07 -08006008 }
6009
6010 return 0;
6011}
6012
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006013void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6014 SignalStrength& signalStrength) {
6015 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6016
6017 // Fixup LTE for backwards compatibility
6018 // signalStrength: -1 -> 99
6019 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6020 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6021 }
6022 // rsrp: -1 -> INT_MAX all other negative value to positive.
6023 // So remap here
6024 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6025 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6026 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6027 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6028 }
6029 // rsrq: -1 -> INT_MAX
6030 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6031 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6032 }
6033 // Not remapping rssnr is already using INT_MAX
6034 // cqi: -1 -> INT_MAX
6035 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6036 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6037 }
6038
6039 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6040 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6041 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6042 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6043 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6044 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6045 signalStrength.evdo.signalNoiseRatio =
6046 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6047 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6048 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6049 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6050 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6051 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6052 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6053 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6054}
6055
Amit Mahajan759786a2017-03-03 17:35:47 -08006056int radio::currentSignalStrengthInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006057 int indicationType, int token, RIL_Errno e,
6058 void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006059 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006060 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006061 RLOGE("currentSignalStrengthInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006062 return 0;
6063 }
6064
Jack Yuf68e0da2017-02-07 14:53:09 -08006065 SignalStrength signalStrength = {};
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006066 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6067
Amit Mahajan111ddca2017-03-03 12:05:13 -08006068 RLOGD("currentSignalStrengthInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006069 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006070 convertIntToRadioIndicationType(indicationType), signalStrength);
Amit Mahajan17249842017-01-19 15:05:45 -08006071 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006072 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006073 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006074 slotId);
6075 }
6076
6077 return 0;
6078}
6079
Amit Mahajan5829a472016-12-28 17:28:07 -08006080void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6081 SetupDataCallResult& dcResult) {
Jack Yu5079e182017-02-28 15:21:18 -08006082 dcResult.status = (DataCallFailCause) dcResponse->status;
Amit Mahajan5829a472016-12-28 17:28:07 -08006083 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6084 dcResult.cid = dcResponse->cid;
6085 dcResult.active = dcResponse->active;
6086 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6087 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6088 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6089 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6090 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6091 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6092 dcResult.mtu = dcResponse->mtu;
6093}
6094
6095void convertRilDataCallListToHal(void *response, size_t responseLen,
6096 hidl_vec<SetupDataCallResult>& dcResultList) {
6097 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6098
6099 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6100 dcResultList.resize(num);
6101 for (int i = 0; i < num; i++) {
6102 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6103 }
6104}
6105
Amit Mahajan759786a2017-03-03 17:35:47 -08006106int radio::dataCallListChangedInd(int slotId,
Amit Mahajan5829a472016-12-28 17:28:07 -08006107 int indicationType, int token, RIL_Errno e, void *response,
6108 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006109 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08006110 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006111 RLOGE("dataCallListChangedInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08006112 return 0;
6113 }
6114 hidl_vec<SetupDataCallResult> dcList;
6115 convertRilDataCallListToHal(response, responseLen, dcList);
Amit Mahajan111ddca2017-03-03 12:05:13 -08006116 RLOGD("dataCallListChangedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006117 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
Amit Mahajan5829a472016-12-28 17:28:07 -08006118 convertIntToRadioIndicationType(indicationType), dcList);
Amit Mahajan17249842017-01-19 15:05:45 -08006119 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006120 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006121 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08006122 }
6123
6124 return 0;
6125}
6126
Amit Mahajan759786a2017-03-03 17:35:47 -08006127int radio::suppSvcNotifyInd(int slotId, int indicationType,
Amit Mahajan5829a472016-12-28 17:28:07 -08006128 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006129 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08006130 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006131 RLOGE("suppSvcNotifyInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08006132 return 0;
6133 }
6134
Jack Yuf68e0da2017-02-07 14:53:09 -08006135 SuppSvcNotification suppSvc = {};
Amit Mahajan5829a472016-12-28 17:28:07 -08006136 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6137 suppSvc.isMT = ssn->notificationType;
6138 suppSvc.code = ssn->code;
6139 suppSvc.index = ssn->index;
6140 suppSvc.type = ssn->type;
6141 suppSvc.number = convertCharPtrToHidlString(ssn->number);
6142
Amit Mahajan111ddca2017-03-03 12:05:13 -08006143 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
Amit Mahajan5829a472016-12-28 17:28:07 -08006144 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
Amit Mahajan17249842017-01-19 15:05:45 -08006145 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
Amit Mahajan5829a472016-12-28 17:28:07 -08006146 convertIntToRadioIndicationType(indicationType), suppSvc);
Amit Mahajan17249842017-01-19 15:05:45 -08006147 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006148 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006149 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08006150 }
6151
6152 return 0;
6153}
6154
Amit Mahajan759786a2017-03-03 17:35:47 -08006155int radio::stkSessionEndInd(int slotId, int indicationType,
Amit Mahajan5829a472016-12-28 17:28:07 -08006156 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006157 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006158 RLOGD("stkSessionEndInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006159 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
Amit Mahajan5829a472016-12-28 17:28:07 -08006160 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006161 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006162 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006163 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08006164 }
6165
6166 return 0;
6167}
6168
Amit Mahajan759786a2017-03-03 17:35:47 -08006169int radio::stkProactiveCommandInd(int slotId,
Amit Mahajan5829a472016-12-28 17:28:07 -08006170 int indicationType, int token, RIL_Errno e, void *response,
6171 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006172 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08006173 if (response == NULL || responseLen == 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006174 RLOGE("stkProactiveCommandInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08006175 return 0;
6176 }
Amit Mahajan111ddca2017-03-03 12:05:13 -08006177 RLOGD("stkProactiveCommandInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006178 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
Amit Mahajan5829a472016-12-28 17:28:07 -08006179 convertIntToRadioIndicationType(indicationType),
6180 convertCharPtrToHidlString((char *) response));
Amit Mahajan17249842017-01-19 15:05:45 -08006181 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006182 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006183 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08006184 }
6185
6186 return 0;
6187}
6188
Amit Mahajan759786a2017-03-03 17:35:47 -08006189int radio::stkEventNotifyInd(int slotId, int indicationType,
Amit Mahajan5829a472016-12-28 17:28:07 -08006190 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006191 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08006192 if (response == NULL || responseLen == 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006193 RLOGE("stkEventNotifyInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08006194 return 0;
6195 }
Amit Mahajan111ddca2017-03-03 12:05:13 -08006196 RLOGD("stkEventNotifyInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006197 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
Amit Mahajan5829a472016-12-28 17:28:07 -08006198 convertIntToRadioIndicationType(indicationType),
6199 convertCharPtrToHidlString((char *) response));
Amit Mahajan17249842017-01-19 15:05:45 -08006200 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006201 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006202 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08006203 }
6204
6205 return 0;
6206}
6207
Amit Mahajan759786a2017-03-03 17:35:47 -08006208int radio::stkCallSetupInd(int slotId, int indicationType,
Amit Mahajan5829a472016-12-28 17:28:07 -08006209 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006210 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08006211 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006212 RLOGE("stkCallSetupInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08006213 return 0;
6214 }
6215 int32_t timeout = ((int32_t *) response)[0];
Amit Mahajan111ddca2017-03-03 12:05:13 -08006216 RLOGD("stkCallSetupInd: timeout %d", timeout);
Amit Mahajan17249842017-01-19 15:05:45 -08006217 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
Amit Mahajan5829a472016-12-28 17:28:07 -08006218 convertIntToRadioIndicationType(indicationType), timeout);
Amit Mahajan17249842017-01-19 15:05:45 -08006219 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006220 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006221 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08006222 }
6223
6224 return 0;
6225}
6226
Amit Mahajan759786a2017-03-03 17:35:47 -08006227int radio::simSmsStorageFullInd(int slotId,
Amit Mahajan5829a472016-12-28 17:28:07 -08006228 int indicationType, int token, RIL_Errno e, void *response,
6229 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006230 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006231 RLOGD("simSmsStorageFullInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006232 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
Amit Mahajan5829a472016-12-28 17:28:07 -08006233 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006234 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006235 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006236 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08006237 }
6238
6239 return 0;
6240}
6241
Amit Mahajan759786a2017-03-03 17:35:47 -08006242int radio::simRefreshInd(int slotId, int indicationType,
Amit Mahajan5829a472016-12-28 17:28:07 -08006243 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006244 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08006245 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006246 RLOGE("simRefreshInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08006247 return 0;
6248 }
6249
Jack Yuf68e0da2017-02-07 14:53:09 -08006250 SimRefreshResult refreshResult = {};
Amit Mahajan5829a472016-12-28 17:28:07 -08006251 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
6252 refreshResult.type =
6253 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
6254 refreshResult.efId = simRefreshResponse->ef_id;
6255 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
6256
Amit Mahajan111ddca2017-03-03 12:05:13 -08006257 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
Amit Mahajan17249842017-01-19 15:05:45 -08006258 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
Amit Mahajan5829a472016-12-28 17:28:07 -08006259 convertIntToRadioIndicationType(indicationType), refreshResult);
Amit Mahajan17249842017-01-19 15:05:45 -08006260 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006261 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006262 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08006263 }
6264
6265 return 0;
6266}
6267
6268void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
6269 CdmaSignalInfoRecord& record) {
6270 record.isPresent = signalInfoRecord->isPresent;
6271 record.signalType = signalInfoRecord->signalType;
6272 record.alertPitch = signalInfoRecord->alertPitch;
6273 record.signal = signalInfoRecord->signal;
6274}
6275
Amit Mahajan759786a2017-03-03 17:35:47 -08006276int radio::callRingInd(int slotId, int indicationType,
Amit Mahajan5829a472016-12-28 17:28:07 -08006277 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006278 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08006279 bool isGsm;
Jack Yuf68e0da2017-02-07 14:53:09 -08006280 CdmaSignalInfoRecord record = {};
Amit Mahajan5829a472016-12-28 17:28:07 -08006281 if (response == NULL || responseLen == 0) {
6282 isGsm = true;
6283 } else {
6284 isGsm = false;
6285 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006286 RLOGE("callRingInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08006287 return 0;
6288 }
6289 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
6290 }
6291
Amit Mahajan111ddca2017-03-03 12:05:13 -08006292 RLOGD("callRingInd: isGsm %d", isGsm);
Amit Mahajan17249842017-01-19 15:05:45 -08006293 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
Amit Mahajan5829a472016-12-28 17:28:07 -08006294 convertIntToRadioIndicationType(indicationType), isGsm, record);
Amit Mahajan17249842017-01-19 15:05:45 -08006295 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006296 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006297 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08006298 }
6299
6300 return 0;
6301}
6302
Amit Mahajan759786a2017-03-03 17:35:47 -08006303int radio::simStatusChangedInd(int slotId,
Amit Mahajan5829a472016-12-28 17:28:07 -08006304 int indicationType, int token, RIL_Errno e, void *response,
6305 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006306 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006307 RLOGD("simStatusChangedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006308 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
Amit Mahajan5829a472016-12-28 17:28:07 -08006309 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006310 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006311 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006312 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08006313 }
6314
6315 return 0;
6316}
6317
Amit Mahajan759786a2017-03-03 17:35:47 -08006318int radio::cdmaNewSmsInd(int slotId, int indicationType,
Amit Mahajan5829a472016-12-28 17:28:07 -08006319 int token, RIL_Errno e, void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006320 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan5829a472016-12-28 17:28:07 -08006321 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006322 RLOGE("cdmaNewSmsInd: invalid response");
Amit Mahajan5829a472016-12-28 17:28:07 -08006323 return 0;
6324 }
6325
Jack Yuf68e0da2017-02-07 14:53:09 -08006326 CdmaSmsMessage msg = {};
Amit Mahajan5829a472016-12-28 17:28:07 -08006327 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
6328 msg.teleserviceId = rilMsg->uTeleserviceID;
6329 msg.isServicePresent = rilMsg->bIsServicePresent;
6330 msg.serviceCategory = rilMsg->uServicecategory;
6331 msg.address.digitMode =
6332 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
6333 msg.address.numberMode =
6334 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
6335 msg.address.numberType =
6336 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
6337 msg.address.numberPlan =
6338 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
6339
6340 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
6341 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
6342
6343 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
6344 rilMsg->sSubAddress.subaddressType;
6345 msg.subAddress.odd = rilMsg->sSubAddress.odd;
6346
6347 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
6348 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
6349
6350 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
6351 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
6352
Amit Mahajan111ddca2017-03-03 12:05:13 -08006353 RLOGD("cdmaNewSmsInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006354 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
Amit Mahajan5829a472016-12-28 17:28:07 -08006355 convertIntToRadioIndicationType(indicationType), msg);
Amit Mahajan17249842017-01-19 15:05:45 -08006356 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan5829a472016-12-28 17:28:07 -08006357 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006358 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan5829a472016-12-28 17:28:07 -08006359 }
6360
6361 return 0;
6362}
6363
Amit Mahajan759786a2017-03-03 17:35:47 -08006364int radio::newBroadcastSmsInd(int slotId,
Amit Mahajan1955c742016-12-29 07:07:54 -08006365 int indicationType, int token, RIL_Errno e, void *response,
6366 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006367 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006368 if (response == NULL || responseLen == 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006369 RLOGE("newBroadcastSmsInd: invalid response");
Amit Mahajan1955c742016-12-29 07:07:54 -08006370 return 0;
6371 }
6372
6373 hidl_vec<uint8_t> data;
6374 data.setToExternal((uint8_t *) response, responseLen);
Amit Mahajan111ddca2017-03-03 12:05:13 -08006375 RLOGD("newBroadcastSmsInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006376 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
Amit Mahajan1955c742016-12-29 07:07:54 -08006377 convertIntToRadioIndicationType(indicationType), data);
Amit Mahajan17249842017-01-19 15:05:45 -08006378 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006379 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006380 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan1955c742016-12-29 07:07:54 -08006381 }
6382
6383 return 0;
6384}
6385
Amit Mahajan759786a2017-03-03 17:35:47 -08006386int radio::cdmaRuimSmsStorageFullInd(int slotId,
Amit Mahajan1955c742016-12-29 07:07:54 -08006387 int indicationType, int token, RIL_Errno e, void *response,
6388 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006389 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006390 RLOGD("cdmaRuimSmsStorageFullInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006391 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
Amit Mahajan1955c742016-12-29 07:07:54 -08006392 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006393 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006394 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006395 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan1955c742016-12-29 07:07:54 -08006396 slotId);
6397 }
6398
6399 return 0;
6400}
6401
Amit Mahajan759786a2017-03-03 17:35:47 -08006402int radio::restrictedStateChangedInd(int slotId,
Amit Mahajan1955c742016-12-29 07:07:54 -08006403 int indicationType, int token, RIL_Errno e, void *response,
6404 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006405 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006406 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006407 RLOGE("restrictedStateChangedInd: invalid response");
Amit Mahajan1955c742016-12-29 07:07:54 -08006408 return 0;
6409 }
6410 int32_t state = ((int32_t *) response)[0];
Amit Mahajan111ddca2017-03-03 12:05:13 -08006411 RLOGD("restrictedStateChangedInd: state %d", state);
Amit Mahajan17249842017-01-19 15:05:45 -08006412 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
Amit Mahajan1955c742016-12-29 07:07:54 -08006413 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
Amit Mahajan17249842017-01-19 15:05:45 -08006414 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006415 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006416 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan1955c742016-12-29 07:07:54 -08006417 slotId);
6418 }
6419
6420 return 0;
6421}
6422
Amit Mahajan759786a2017-03-03 17:35:47 -08006423int radio::enterEmergencyCallbackModeInd(int slotId,
Amit Mahajan1955c742016-12-29 07:07:54 -08006424 int indicationType, int token, RIL_Errno e, void *response,
6425 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006426 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006427 RLOGD("enterEmergencyCallbackModeInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006428 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
Amit Mahajan1955c742016-12-29 07:07:54 -08006429 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006430 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006431 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006432 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan1955c742016-12-29 07:07:54 -08006433 slotId);
6434 }
6435
6436 return 0;
6437}
6438
Amit Mahajan759786a2017-03-03 17:35:47 -08006439int radio::cdmaCallWaitingInd(int slotId,
Amit Mahajan1955c742016-12-29 07:07:54 -08006440 int indicationType, int token, RIL_Errno e, void *response,
6441 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006442 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006443 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006444 RLOGE("cdmaCallWaitingInd: invalid response");
Amit Mahajan1955c742016-12-29 07:07:54 -08006445 return 0;
6446 }
6447
Jack Yuf68e0da2017-02-07 14:53:09 -08006448 CdmaCallWaiting callWaitingRecord = {};
Amit Mahajan1955c742016-12-29 07:07:54 -08006449 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
6450 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
6451 callWaitingRecord.numberPresentation =
6452 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
6453 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
6454 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
6455 callWaitingRecord.signalInfoRecord);
6456 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
6457 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
6458
Amit Mahajan111ddca2017-03-03 12:05:13 -08006459 RLOGD("cdmaCallWaitingInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006460 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
Amit Mahajan1955c742016-12-29 07:07:54 -08006461 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
Amit Mahajan17249842017-01-19 15:05:45 -08006462 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006463 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006464 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan1955c742016-12-29 07:07:54 -08006465 }
6466
6467 return 0;
6468}
6469
Amit Mahajan759786a2017-03-03 17:35:47 -08006470int radio::cdmaOtaProvisionStatusInd(int slotId,
Amit Mahajan1955c742016-12-29 07:07:54 -08006471 int indicationType, int token, RIL_Errno e, void *response,
6472 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006473 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006474 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006475 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
Amit Mahajan1955c742016-12-29 07:07:54 -08006476 return 0;
6477 }
6478 int32_t status = ((int32_t *) response)[0];
Amit Mahajan111ddca2017-03-03 12:05:13 -08006479 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
Amit Mahajan17249842017-01-19 15:05:45 -08006480 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
Amit Mahajan1955c742016-12-29 07:07:54 -08006481 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
Amit Mahajan17249842017-01-19 15:05:45 -08006482 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006483 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006484 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan1955c742016-12-29 07:07:54 -08006485 slotId);
6486 }
6487
6488 return 0;
6489}
6490
Amit Mahajan759786a2017-03-03 17:35:47 -08006491int radio::cdmaInfoRecInd(int slotId,
Amit Mahajan1955c742016-12-29 07:07:54 -08006492 int indicationType, int token, RIL_Errno e, void *response,
6493 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006494 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan1955c742016-12-29 07:07:54 -08006495 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006496 RLOGE("cdmaInfoRecInd: invalid response");
Amit Mahajan1955c742016-12-29 07:07:54 -08006497 return 0;
6498 }
6499
Jack Yuf68e0da2017-02-07 14:53:09 -08006500 CdmaInformationRecords records = {};
Amit Mahajan1955c742016-12-29 07:07:54 -08006501 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
6502
6503 char* string8 = NULL;
6504 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
6505 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006506 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006507 "additional ones", recordsRil->numberOfInfoRecs,
Amit Mahajan1955c742016-12-29 07:07:54 -08006508 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
6509 }
6510 records.infoRec.resize(num);
6511 for (int i = 0 ; i < num ; i++) {
6512 CdmaInformationRecord *record = &records.infoRec[i];
6513 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
6514 record->name = (CdmaInfoRecName) infoRec->name;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006515 // All vectors should be size 0 except one which will be size 1. Set everything to
6516 // size 0 initially.
6517 record->display.resize(0);
6518 record->number.resize(0);
6519 record->signal.resize(0);
6520 record->redir.resize(0);
6521 record->lineCtrl.resize(0);
6522 record->clir.resize(0);
6523 record->audioCtrl.resize(0);
Amit Mahajan1955c742016-12-29 07:07:54 -08006524 switch (infoRec->name) {
6525 case RIL_CDMA_DISPLAY_INFO_REC:
6526 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
6527 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006528 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006529 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
Amit Mahajan1955c742016-12-29 07:07:54 -08006530 CDMA_ALPHA_INFO_BUFFER_LENGTH);
6531 return 0;
6532 }
6533 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
6534 if (string8 == NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006535 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006536 "responseCdmaInformationRecords");
Amit Mahajan1955c742016-12-29 07:07:54 -08006537 return 0;
6538 }
6539 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
6540 string8[(int)infoRec->rec.display.alpha_len] = '\0';
6541
6542 record->display.resize(1);
6543 record->display[0].alphaBuf = string8;
6544 free(string8);
6545 string8 = NULL;
6546 break;
6547 }
6548
6549 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
6550 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
6551 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
6552 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006553 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006554 "expected not more than %d", (int) infoRec->rec.number.len,
Amit Mahajan1955c742016-12-29 07:07:54 -08006555 CDMA_NUMBER_INFO_BUFFER_LENGTH);
6556 return 0;
6557 }
6558 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
6559 if (string8 == NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006560 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006561 "responseCdmaInformationRecords");
Amit Mahajan1955c742016-12-29 07:07:54 -08006562 return 0;
6563 }
6564 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
6565 string8[(int)infoRec->rec.number.len] = '\0';
6566
6567 record->number.resize(1);
6568 record->number[0].number = string8;
6569 free(string8);
6570 string8 = NULL;
6571 record->number[0].numberType = infoRec->rec.number.number_type;
6572 record->number[0].numberPlan = infoRec->rec.number.number_plan;
6573 record->number[0].pi = infoRec->rec.number.pi;
6574 record->number[0].si = infoRec->rec.number.si;
6575 break;
6576 }
6577
6578 case RIL_CDMA_SIGNAL_INFO_REC: {
6579 record->signal.resize(1);
6580 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
6581 record->signal[0].signalType = infoRec->rec.signal.signalType;
6582 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
6583 record->signal[0].signal = infoRec->rec.signal.signal;
6584 break;
6585 }
6586
6587 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
6588 if (infoRec->rec.redir.redirectingNumber.len >
6589 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006590 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006591 "expected not more than %d\n",
Amit Mahajan1955c742016-12-29 07:07:54 -08006592 (int)infoRec->rec.redir.redirectingNumber.len,
6593 CDMA_NUMBER_INFO_BUFFER_LENGTH);
6594 return 0;
6595 }
6596 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
6597 sizeof(char));
6598 if (string8 == NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006599 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006600 "responseCdmaInformationRecords");
Amit Mahajan1955c742016-12-29 07:07:54 -08006601 return 0;
6602 }
6603 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
6604 infoRec->rec.redir.redirectingNumber.len);
6605 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
6606
6607 record->redir.resize(1);
6608 record->redir[0].redirectingNumber.number = string8;
6609 free(string8);
6610 string8 = NULL;
6611 record->redir[0].redirectingNumber.numberType =
6612 infoRec->rec.redir.redirectingNumber.number_type;
6613 record->redir[0].redirectingNumber.numberPlan =
6614 infoRec->rec.redir.redirectingNumber.number_plan;
6615 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
6616 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
6617 record->redir[0].redirectingReason =
6618 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
6619 break;
6620 }
6621
6622 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
6623 record->lineCtrl.resize(1);
6624 record->lineCtrl[0].lineCtrlPolarityIncluded =
6625 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
6626 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
6627 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
6628 record->lineCtrl[0].lineCtrlPowerDenial =
6629 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
6630 break;
6631 }
6632
6633 case RIL_CDMA_T53_CLIR_INFO_REC: {
6634 record->clir.resize(1);
6635 record->clir[0].cause = infoRec->rec.clir.cause;
6636 break;
6637 }
6638
6639 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
6640 record->audioCtrl.resize(1);
6641 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
6642 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
6643 break;
6644 }
6645
6646 case RIL_CDMA_T53_RELEASE_INFO_REC:
Amit Mahajan111ddca2017-03-03 12:05:13 -08006647 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
Amit Mahajan1955c742016-12-29 07:07:54 -08006648 return 0;
6649
6650 default:
Amit Mahajan111ddca2017-03-03 12:05:13 -08006651 RLOGE("cdmaInfoRecInd: Incorrect name value");
Amit Mahajan1955c742016-12-29 07:07:54 -08006652 return 0;
6653 }
6654 }
6655
Amit Mahajan111ddca2017-03-03 12:05:13 -08006656 RLOGD("cdmaInfoRecInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006657 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
Amit Mahajan1955c742016-12-29 07:07:54 -08006658 convertIntToRadioIndicationType(indicationType), records);
Amit Mahajan17249842017-01-19 15:05:45 -08006659 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan1955c742016-12-29 07:07:54 -08006660 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006661 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan1955c742016-12-29 07:07:54 -08006662 }
6663
6664 return 0;
6665}
6666
Amit Mahajan759786a2017-03-03 17:35:47 -08006667int radio::indicateRingbackToneInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006668 int indicationType, int token, RIL_Errno e, void *response,
6669 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006670 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006671 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006672 RLOGE("indicateRingbackToneInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006673 return 0;
6674 }
6675 bool start = ((int32_t *) response)[0];
Amit Mahajan111ddca2017-03-03 12:05:13 -08006676 RLOGD("indicateRingbackToneInd: start %d", start);
Amit Mahajan17249842017-01-19 15:05:45 -08006677 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006678 convertIntToRadioIndicationType(indicationType), start);
Amit Mahajan17249842017-01-19 15:05:45 -08006679 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006680 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006681 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006682 }
6683
6684 return 0;
6685}
6686
Amit Mahajan759786a2017-03-03 17:35:47 -08006687int radio::resendIncallMuteInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006688 int indicationType, int token, RIL_Errno e, void *response,
6689 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006690 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006691 RLOGD("resendIncallMuteInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006692 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006693 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006694 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006695 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006696 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006697 }
6698
6699 return 0;
6700}
6701
Amit Mahajan759786a2017-03-03 17:35:47 -08006702int radio::cdmaSubscriptionSourceChangedInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006703 int indicationType, int token, RIL_Errno e,
6704 void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006705 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006706 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006707 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006708 return 0;
6709 }
6710 int32_t cdmaSource = ((int32_t *) response)[0];
Amit Mahajan111ddca2017-03-03 12:05:13 -08006711 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
Amit Mahajan17249842017-01-19 15:05:45 -08006712 Return<void> retStatus = radioService[slotId]->mRadioIndication->
6713 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006714 (CdmaSubscriptionSource) cdmaSource);
Amit Mahajan17249842017-01-19 15:05:45 -08006715 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006716 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006717 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006718 slotId);
6719 }
6720
6721 return 0;
6722}
6723
Amit Mahajan759786a2017-03-03 17:35:47 -08006724int radio::cdmaPrlChangedInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006725 int indicationType, int token, RIL_Errno e, void *response,
6726 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006727 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006728 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006729 RLOGE("cdmaPrlChangedInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006730 return 0;
6731 }
6732 int32_t version = ((int32_t *) response)[0];
Amit Mahajan111ddca2017-03-03 12:05:13 -08006733 RLOGD("cdmaPrlChangedInd: version %d", version);
Amit Mahajan17249842017-01-19 15:05:45 -08006734 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006735 convertIntToRadioIndicationType(indicationType), version);
Amit Mahajan17249842017-01-19 15:05:45 -08006736 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006737 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006738 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006739 }
6740
6741 return 0;
6742}
6743
Amit Mahajan759786a2017-03-03 17:35:47 -08006744int radio::exitEmergencyCallbackModeInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006745 int indicationType, int token, RIL_Errno e, void *response,
6746 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006747 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006748 RLOGD("exitEmergencyCallbackModeInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006749 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006750 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006751 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006752 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006753 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006754 slotId);
6755 }
6756
6757 return 0;
6758}
6759
Amit Mahajan759786a2017-03-03 17:35:47 -08006760int radio::rilConnectedInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006761 int indicationType, int token, RIL_Errno e, void *response,
6762 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006763 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006764 RLOGD("rilConnectedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006765 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006766 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006767 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006768 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006769 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006770 }
6771
6772 return 0;
6773}
6774
Amit Mahajan759786a2017-03-03 17:35:47 -08006775int radio::voiceRadioTechChangedInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006776 int indicationType, int token, RIL_Errno e, void *response,
6777 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006778 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006779 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006780 RLOGE("voiceRadioTechChangedInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006781 return 0;
6782 }
6783 int32_t rat = ((int32_t *) response)[0];
Amit Mahajan111ddca2017-03-03 12:05:13 -08006784 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
Amit Mahajan17249842017-01-19 15:05:45 -08006785 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006786 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
Amit Mahajan17249842017-01-19 15:05:45 -08006787 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006788 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006789 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006790 slotId);
6791 }
6792
6793 return 0;
6794}
6795
6796void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
6797 int num = responseLen / sizeof(RIL_CellInfo_v12);
6798 records.resize(num);
6799
6800 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
6801 for (int i = 0; i < num; i++) {
6802 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
6803 records[i].registered = rillCellInfo->registered;
6804 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
6805 records[i].timeStamp = rillCellInfo->timeStamp;
Sanket Padawe378ccdd2017-01-24 14:11:12 -08006806 // All vectors should be size 0 except one which will be size 1. Set everything to
6807 // size 0 initially.
6808 records[i].gsm.resize(0);
6809 records[i].wcdma.resize(0);
6810 records[i].cdma.resize(0);
6811 records[i].lte.resize(0);
6812 records[i].tdscdma.resize(0);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006813 switch(rillCellInfo->cellInfoType) {
6814 case RIL_CELL_INFO_TYPE_GSM: {
6815 records[i].gsm.resize(1);
6816 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
6817 cellInfoGsm->cellIdentityGsm.mcc =
6818 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
6819 cellInfoGsm->cellIdentityGsm.mnc =
6820 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
6821 cellInfoGsm->cellIdentityGsm.lac =
6822 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
6823 cellInfoGsm->cellIdentityGsm.cid =
6824 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
6825 cellInfoGsm->cellIdentityGsm.arfcn =
6826 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
6827 cellInfoGsm->cellIdentityGsm.bsic =
6828 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
6829 cellInfoGsm->signalStrengthGsm.signalStrength =
6830 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
6831 cellInfoGsm->signalStrengthGsm.bitErrorRate =
6832 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
6833 cellInfoGsm->signalStrengthGsm.timingAdvance =
6834 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
6835 break;
6836 }
6837
6838 case RIL_CELL_INFO_TYPE_WCDMA: {
6839 records[i].wcdma.resize(1);
6840 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
6841 cellInfoWcdma->cellIdentityWcdma.mcc =
6842 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
6843 cellInfoWcdma->cellIdentityWcdma.mnc =
6844 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
6845 cellInfoWcdma->cellIdentityWcdma.lac =
6846 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
6847 cellInfoWcdma->cellIdentityWcdma.cid =
6848 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
6849 cellInfoWcdma->cellIdentityWcdma.psc =
6850 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
6851 cellInfoWcdma->cellIdentityWcdma.uarfcn =
6852 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
6853 cellInfoWcdma->signalStrengthWcdma.signalStrength =
6854 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
6855 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
6856 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
6857 break;
6858 }
6859
6860 case RIL_CELL_INFO_TYPE_CDMA: {
6861 records[i].cdma.resize(1);
6862 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
6863 cellInfoCdma->cellIdentityCdma.networkId =
6864 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
6865 cellInfoCdma->cellIdentityCdma.systemId =
6866 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
6867 cellInfoCdma->cellIdentityCdma.baseStationId =
6868 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
6869 cellInfoCdma->cellIdentityCdma.longitude =
6870 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
6871 cellInfoCdma->cellIdentityCdma.latitude =
6872 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
6873 cellInfoCdma->signalStrengthCdma.dbm =
6874 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
6875 cellInfoCdma->signalStrengthCdma.ecio =
6876 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
6877 cellInfoCdma->signalStrengthEvdo.dbm =
6878 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
6879 cellInfoCdma->signalStrengthEvdo.ecio =
6880 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
6881 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
6882 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
6883 break;
6884 }
6885
6886 case RIL_CELL_INFO_TYPE_LTE: {
6887 records[i].lte.resize(1);
6888 CellInfoLte *cellInfoLte = &records[i].lte[0];
6889 cellInfoLte->cellIdentityLte.mcc =
6890 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
6891 cellInfoLte->cellIdentityLte.mnc =
6892 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
6893 cellInfoLte->cellIdentityLte.ci =
6894 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
6895 cellInfoLte->cellIdentityLte.pci =
6896 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
6897 cellInfoLte->cellIdentityLte.tac =
6898 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
6899 cellInfoLte->cellIdentityLte.earfcn =
6900 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
6901 cellInfoLte->signalStrengthLte.signalStrength =
6902 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
6903 cellInfoLte->signalStrengthLte.rsrp =
6904 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
6905 cellInfoLte->signalStrengthLte.rsrq =
6906 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
6907 cellInfoLte->signalStrengthLte.rssnr =
6908 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
6909 cellInfoLte->signalStrengthLte.cqi =
6910 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
6911 cellInfoLte->signalStrengthLte.timingAdvance =
6912 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
6913 break;
6914 }
6915
6916 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
6917 records[i].tdscdma.resize(1);
6918 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
6919 cellInfoTdscdma->cellIdentityTdscdma.mcc =
6920 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
6921 cellInfoTdscdma->cellIdentityTdscdma.mnc =
6922 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
6923 cellInfoTdscdma->cellIdentityTdscdma.lac =
6924 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
6925 cellInfoTdscdma->cellIdentityTdscdma.cid =
6926 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
6927 cellInfoTdscdma->cellIdentityTdscdma.cpid =
6928 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
6929 cellInfoTdscdma->signalStrengthTdscdma.rscp =
6930 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
6931 break;
6932 }
Sooraj Sasindrand8db60c2016-11-30 18:36:03 -08006933 default: {
6934 break;
6935 }
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006936 }
6937 rillCellInfo += 1;
6938 }
6939}
6940
Amit Mahajan759786a2017-03-03 17:35:47 -08006941int radio::cellInfoListInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006942 int indicationType, int token, RIL_Errno e, void *response,
6943 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006944 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006945 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006946 RLOGE("cellInfoListInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006947 return 0;
6948 }
6949
6950 hidl_vec<CellInfo> records;
6951 convertRilCellInfoListToHal(response, responseLen, records);
6952
Amit Mahajan111ddca2017-03-03 12:05:13 -08006953 RLOGD("cellInfoListInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006954 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006955 convertIntToRadioIndicationType(indicationType), records);
Amit Mahajan17249842017-01-19 15:05:45 -08006956 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006957 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006958 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006959 }
6960
6961 return 0;
6962}
6963
Amit Mahajan759786a2017-03-03 17:35:47 -08006964int radio::imsNetworkStateChangedInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006965 int indicationType, int token, RIL_Errno e, void *response,
6966 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006967 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006968 RLOGD("imsNetworkStateChangedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08006969 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006970 convertIntToRadioIndicationType(indicationType));
Amit Mahajan17249842017-01-19 15:05:45 -08006971 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006972 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006973 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006974 slotId);
6975 }
6976
6977 return 0;
6978}
6979
Amit Mahajan759786a2017-03-03 17:35:47 -08006980int radio::subscriptionStatusChangedInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006981 int indicationType, int token, RIL_Errno e, void *response,
6982 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08006983 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006984 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006985 RLOGE("subscriptionStatusChangedInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006986 return 0;
6987 }
6988 bool activate = ((int32_t *) response)[0];
Amit Mahajan111ddca2017-03-03 12:05:13 -08006989 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
Amit Mahajan17249842017-01-19 15:05:45 -08006990 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006991 convertIntToRadioIndicationType(indicationType), activate);
Amit Mahajan17249842017-01-19 15:05:45 -08006992 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006993 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08006994 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08006995 slotId);
6996 }
6997
6998 return 0;
6999}
7000
Amit Mahajan759786a2017-03-03 17:35:47 -08007001int radio::srvccStateNotifyInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007002 int indicationType, int token, RIL_Errno e, void *response,
7003 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08007004 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007005 if (response == NULL || responseLen != sizeof(int)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007006 RLOGE("srvccStateNotifyInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007007 return 0;
7008 }
7009 int32_t state = ((int32_t *) response)[0];
Amit Mahajan111ddca2017-03-03 12:05:13 -08007010 RLOGD("srvccStateNotifyInd: rat %d", state);
Amit Mahajan17249842017-01-19 15:05:45 -08007011 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007012 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
Amit Mahajan17249842017-01-19 15:05:45 -08007013 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007014 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007015 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007016 }
7017
7018 return 0;
7019}
7020
7021void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7022 hidl_vec<HardwareConfig>& records) {
7023 int num = responseLen / sizeof(RIL_HardwareConfig);
7024 records.resize(num);
7025
7026 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7027 for (int i = 0; i < num; i++) {
7028 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7029 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7030 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7031 switch (rilHardwareConfig[i].type) {
7032 case RIL_HARDWARE_CONFIG_MODEM: {
7033 records[i].modem.resize(1);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08007034 records[i].sim.resize(0);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007035 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7036 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7037 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7038 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7039 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7040 break;
7041 }
7042
7043 case RIL_HARDWARE_CONFIG_SIM: {
7044 records[i].sim.resize(1);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08007045 records[i].modem.resize(0);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007046 records[i].sim[0].modemUuid =
7047 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7048 break;
7049 }
7050 }
7051 }
7052}
7053
Amit Mahajan759786a2017-03-03 17:35:47 -08007054int radio::hardwareConfigChangedInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007055 int indicationType, int token, RIL_Errno e, void *response,
7056 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08007057 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007058 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007059 RLOGE("hardwareConfigChangedInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007060 return 0;
7061 }
7062
7063 hidl_vec<HardwareConfig> configs;
7064 convertRilHardwareConfigListToHal(response, responseLen, configs);
7065
Amit Mahajan111ddca2017-03-03 12:05:13 -08007066 RLOGD("hardwareConfigChangedInd");
Amit Mahajan17249842017-01-19 15:05:45 -08007067 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007068 convertIntToRadioIndicationType(indicationType), configs);
Amit Mahajan17249842017-01-19 15:05:45 -08007069 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007070 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007071 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007072 slotId);
7073 }
7074
7075 return 0;
7076}
7077
7078void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7079 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7080 rc.session = rilRadioCapability->session;
7081 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7082 rc.raf = rilRadioCapability->rat;
7083 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7084 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
7085}
7086
Amit Mahajan759786a2017-03-03 17:35:47 -08007087int radio::radioCapabilityIndicationInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007088 int indicationType, int token, RIL_Errno e, void *response,
7089 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08007090 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007091 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007092 RLOGE("radioCapabilityIndicationInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007093 return 0;
7094 }
7095
Jack Yuf68e0da2017-02-07 14:53:09 -08007096 RadioCapability rc = {};
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007097 convertRilRadioCapabilityToHal(response, responseLen, rc);
7098
Amit Mahajan111ddca2017-03-03 12:05:13 -08007099 RLOGD("radioCapabilityIndicationInd");
Amit Mahajan17249842017-01-19 15:05:45 -08007100 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007101 convertIntToRadioIndicationType(indicationType), rc);
Amit Mahajan17249842017-01-19 15:05:45 -08007102 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007103 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007104 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007105 slotId);
7106 }
7107
7108 return 0;
7109}
7110
7111bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
7112 if ((reqType == SS_INTERROGATION) &&
7113 (serType == SS_CFU ||
7114 serType == SS_CF_BUSY ||
7115 serType == SS_CF_NO_REPLY ||
7116 serType == SS_CF_NOT_REACHABLE ||
7117 serType == SS_CF_ALL ||
7118 serType == SS_CF_ALL_CONDITIONAL)) {
7119 return true;
7120 }
7121 return false;
7122}
7123
Amit Mahajan759786a2017-03-03 17:35:47 -08007124int radio::onSupplementaryServiceIndicationInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007125 int indicationType, int token, RIL_Errno e,
7126 void *response, size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08007127 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007128 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007129 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007130 return 0;
7131 }
7132
7133 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
Jack Yuf68e0da2017-02-07 14:53:09 -08007134 StkCcUnsolSsResult ss = {};
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007135 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
7136 ss.requestType = (SsRequestType) rilSsResponse->requestType;
7137 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
7138 ss.serviceClass = rilSsResponse->serviceClass;
7139 ss.result = (RadioError) rilSsResponse->result;
7140
7141 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007142 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007143 rilSsResponse->cfData.numValidIndexes);
7144 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007145 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007146 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
7147 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
7148 }
7149
7150 ss.cfData.resize(1);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08007151 ss.ssInfo.resize(0);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007152
7153 /* number of call info's */
7154 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
7155
7156 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
7157 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
7158 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
7159
7160 cfInfo->status = (CallForwardInfoStatus) cf.status;
7161 cfInfo->reason = cf.reason;
7162 cfInfo->serviceClass = cf.serviceClass;
7163 cfInfo->toa = cf.toa;
7164 cfInfo->number = convertCharPtrToHidlString(cf.number);
7165 cfInfo->timeSeconds = cf.timeSeconds;
Amit Mahajan111ddca2017-03-03 12:05:13 -08007166 RLOGD("onSupplementaryServiceIndicationInd: "
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007167 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
7168 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
7169 }
7170 } else {
7171 ss.ssInfo.resize(1);
Sanket Padawe378ccdd2017-01-24 14:11:12 -08007172 ss.cfData.resize(0);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007173
7174 /* each int */
7175 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
7176 for (int i = 0; i < SS_INFO_MAX; i++) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007177 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007178 rilSsResponse->ssInfo[i]);
7179 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
7180 }
7181 }
7182
Amit Mahajan111ddca2017-03-03 12:05:13 -08007183 RLOGD("onSupplementaryServiceIndicationInd");
Amit Mahajan17249842017-01-19 15:05:45 -08007184 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7185 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
7186 ss);
7187 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007188 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007189 RLOGE("onSupplementaryServiceIndicationInd: "
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007190 "radioService[%d]->mRadioIndication == NULL", slotId);
7191 }
7192
7193 return 0;
7194}
7195
Amit Mahajan759786a2017-03-03 17:35:47 -08007196int radio::stkCallControlAlphaNotifyInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007197 int indicationType, int token, RIL_Errno e, void *response,
7198 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08007199 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007200 if (response == NULL || responseLen == 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007201 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007202 return 0;
7203 }
Amit Mahajan111ddca2017-03-03 12:05:13 -08007204 RLOGD("stkCallControlAlphaNotifyInd");
Amit Mahajan17249842017-01-19 15:05:45 -08007205 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007206 convertIntToRadioIndicationType(indicationType),
7207 convertCharPtrToHidlString((char *) response));
Amit Mahajan17249842017-01-19 15:05:45 -08007208 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007209 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007210 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007211 slotId);
7212 }
7213
7214 return 0;
7215}
7216
7217void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
7218 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
7219 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
7220 lce.confidenceLevel = rilLceDataInfo->confidence_level;
7221 lce.lceSuspended = rilLceDataInfo->lce_suspended;
7222}
7223
Amit Mahajan759786a2017-03-03 17:35:47 -08007224int radio::lceDataInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007225 int indicationType, int token, RIL_Errno e, void *response,
7226 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08007227 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007228 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007229 RLOGE("lceDataInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007230 return 0;
7231 }
7232
Jack Yuf68e0da2017-02-07 14:53:09 -08007233 LceDataInfo lce = {};
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007234 convertRilLceDataInfoToHal(response, responseLen, lce);
Amit Mahajan111ddca2017-03-03 12:05:13 -08007235 RLOGD("lceDataInd");
Amit Mahajan17249842017-01-19 15:05:45 -08007236 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007237 convertIntToRadioIndicationType(indicationType), lce);
Amit Mahajan17249842017-01-19 15:05:45 -08007238 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007239 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007240 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007241 }
7242
7243 return 0;
7244}
7245
Amit Mahajan759786a2017-03-03 17:35:47 -08007246int radio::pcoDataInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007247 int indicationType, int token, RIL_Errno e, void *response,
7248 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08007249 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007250 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007251 RLOGE("pcoDataInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007252 return 0;
7253 }
7254
Jack Yuf68e0da2017-02-07 14:53:09 -08007255 PcoDataInfo pco = {};
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007256 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
7257 pco.cid = rilPcoData->cid;
7258 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
7259 pco.pcoId = rilPcoData->pco_id;
7260 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
7261
Amit Mahajan111ddca2017-03-03 12:05:13 -08007262 RLOGD("pcoDataInd");
Amit Mahajan17249842017-01-19 15:05:45 -08007263 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007264 convertIntToRadioIndicationType(indicationType), pco);
Amit Mahajan17249842017-01-19 15:05:45 -08007265 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007266 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007267 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007268 }
7269
7270 return 0;
7271}
7272
Amit Mahajan759786a2017-03-03 17:35:47 -08007273int radio::modemResetInd(int slotId,
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007274 int indicationType, int token, RIL_Errno e, void *response,
7275 size_t responseLen) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08007276 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007277 if (response == NULL || responseLen == 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007278 RLOGE("modemResetInd: invalid response");
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007279 return 0;
7280 }
Amit Mahajan111ddca2017-03-03 12:05:13 -08007281 RLOGD("modemResetInd");
Amit Mahajan17249842017-01-19 15:05:45 -08007282 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007283 convertIntToRadioIndicationType(indicationType),
7284 convertCharPtrToHidlString((char *) response));
Amit Mahajan17249842017-01-19 15:05:45 -08007285 radioService[slotId]->checkReturnStatus(retStatus);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007286 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007287 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
Amit Mahajan2fa9e632017-01-06 16:55:33 -08007288 }
7289
7290 return 0;
7291}
7292
Amit Mahajan759786a2017-03-03 17:35:47 -08007293int radio::oemHookRawInd(int slotId,
Amit Mahajan439da362017-02-13 17:43:04 -08007294 int indicationType, int token, RIL_Errno e, void *response,
7295 size_t responseLen) {
7296 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
7297 if (response == NULL || responseLen == 0) {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007298 RLOGE("oemHookRawInd: invalid response");
Amit Mahajan439da362017-02-13 17:43:04 -08007299 return 0;
7300 }
7301
7302 hidl_vec<uint8_t> data;
7303 data.setToExternal((uint8_t *) response, responseLen);
Amit Mahajan111ddca2017-03-03 12:05:13 -08007304 RLOGD("oemHookRawInd");
Amit Mahajan439da362017-02-13 17:43:04 -08007305 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
7306 convertIntToRadioIndicationType(indicationType), data);
Amit Mahajand423d192017-03-16 17:04:01 -07007307 checkReturnStatus(slotId, retStatus, false);
Amit Mahajan439da362017-02-13 17:43:04 -08007308 } else {
Amit Mahajan111ddca2017-03-03 12:05:13 -08007309 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
Amit Mahajan439da362017-02-13 17:43:04 -08007310 }
7311
7312 return 0;
7313}
7314
Amit Mahajancd77a5b2016-08-25 11:19:21 -07007315void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
7316 using namespace android::hardware;
7317 int simCount = 1;
Amit Mahajan439da362017-02-13 17:43:04 -08007318 const char *serviceNames[] = {
Amit Mahajancd77a5b2016-08-25 11:19:21 -07007319 android::RIL_getRilSocketName()
7320 #if (SIM_COUNT >= 2)
7321 , SOCKET2_NAME_RIL
7322 #if (SIM_COUNT >= 3)
7323 , SOCKET3_NAME_RIL
7324 #if (SIM_COUNT >= 4)
7325 , SOCKET4_NAME_RIL
7326 #endif
7327 #endif
7328 #endif
7329 };
7330
Amit Mahajan439da362017-02-13 17:43:04 -08007331 const char *oemHookServiceNames[] = {
7332 OEM_HOOK_SERVICE_NAME
7333 #if (SIM_COUNT >= 2)
7334 , OEM_HOOK2_SERVICE_NAME
7335 #if (SIM_COUNT >= 3)
7336 , OEM_HOOK3_SERVICE_NAME
7337 #if (SIM_COUNT >= 4)
7338 , OEM_HOOK4_SERVICE_NAME
7339 #endif
7340 #endif
7341 #endif
7342 };
7343
Amit Mahajancd77a5b2016-08-25 11:19:21 -07007344 #if (SIM_COUNT >= 2)
7345 simCount = SIM_COUNT;
7346 #endif
7347
7348 configureRpcThreadpool(1, true /* callerWillJoin */);
7349 for (int i = 0; i < simCount; i++) {
Amit Mahajan932e08e2017-01-24 05:45:02 -08007350 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
7351 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
7352 assert(ret == 0);
7353
Amit Mahajancd77a5b2016-08-25 11:19:21 -07007354 radioService[i] = new RadioImpl;
Sanket Padawef220dc52017-01-02 23:46:00 -08007355 radioService[i]->mSlotId = i;
Amit Mahajan439da362017-02-13 17:43:04 -08007356 oemHookService[i] = new OemHookImpl;
7357 oemHookService[i]->mSlotId = i;
Amit Mahajan111ddca2017-03-03 12:05:13 -08007358 RLOGD("registerService: starting IRadio %s", serviceNames[i]);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07007359 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
Amit Mahajan439da362017-02-13 17:43:04 -08007360 status = oemHookService[i]->registerAsService(oemHookServiceNames[i]);
Amit Mahajan932e08e2017-01-24 05:45:02 -08007361
7362 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
7363 assert(ret == 0);
Amit Mahajancd77a5b2016-08-25 11:19:21 -07007364 }
7365
Sanket Padawe378ccdd2017-01-24 14:11:12 -08007366 s_vendorFunctions = callbacks;
Amit Mahajancd77a5b2016-08-25 11:19:21 -07007367 s_commands = commands;
7368}
7369
7370void rilc_thread_pool() {
7371 joinRpcThreadpool();
Amit Mahajan932e08e2017-01-24 05:45:02 -08007372}
7373
7374pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
7375 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
7376
7377 #if (SIM_COUNT >= 2)
7378 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
7379 #if (SIM_COUNT >= 3)
7380 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
7381 #if (SIM_COUNT >= 4)
7382 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
7383 #endif
7384 #endif
7385 #endif
7386
7387 return radioServiceRwlockPtr;
Sanket Padawe0de29d12017-02-10 13:19:47 -08007388}