blob: f6d4a10d4fe47573dc4a71282cbbbf8aa6a5b168 [file] [log] [blame]
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03001/*
2 * Copyright (c) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "RILC"
18
19#include <android/hardware/radio/1.0/IRadio.h>
20#include <android/hardware/radio/deprecated/1.0/IOemHook.h>
21
22#include <hwbinder/IPCThreadState.h>
23#include <hwbinder/ProcessState.h>
24#include <ril_service.h>
25#include <hidl/HidlTransportSupport.h>
26#include <utils/SystemClock.h>
27#include <inttypes.h>
28
29#define INVALID_HEX_CHAR 16
30
31// Enable verbose logging
32#define VDBG 0
33
34using namespace android::hardware::radio::V1_0;
35using namespace android::hardware::radio::deprecated::V1_0;
36using ::android::hardware::configureRpcThreadpool;
37using ::android::hardware::joinRpcThreadpool;
38using ::android::hardware::Return;
39using ::android::hardware::hidl_string;
40using ::android::hardware::hidl_vec;
41using ::android::hardware::hidl_array;
42using ::android::hardware::Void;
43using android::CommandInfo;
44using android::RequestInfo;
45using android::requestToString;
46using android::sp;
47
48#define BOOL_TO_INT(x) (x ? 1 : 0)
49#define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
50#define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
51
52#if defined(ANDROID_MULTI_SIM)
53#define CALL_ONREQUEST(a, b, c, d, e) \
54 s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e)))
55#define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a))
56#else
57#define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d))
58#define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
59#endif
60
61RIL_RadioFunctions *s_vendorFunctions = NULL;
62static CommandInfo *s_commands;
63
64struct RadioImpl;
65struct OemHookImpl;
66
67#if (SIM_COUNT >= 2)
68sp<RadioImpl> radioService[SIM_COUNT];
69sp<OemHookImpl> oemHookService[SIM_COUNT];
70// counter used for synchronization. It is incremented every time response callbacks are updated.
71volatile int32_t mCounterRadio[SIM_COUNT];
72volatile int32_t mCounterOemHook[SIM_COUNT];
73#else
74sp<RadioImpl> radioService[1];
75sp<OemHookImpl> oemHookService[1];
76// counter used for synchronization. It is incremented every time response callbacks are updated.
77volatile int32_t mCounterRadio[1];
78volatile int32_t mCounterOemHook[1];
79#endif
80
81static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
82
83#if (SIM_COUNT >= 2)
84static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
85#if (SIM_COUNT >= 3)
86static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
87#if (SIM_COUNT >= 4)
88static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
89#endif
90#endif
91#endif
92
93void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
94 hidl_vec<HardwareConfig>& records);
95
96void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
97
98void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
99
100void convertRilSignalStrengthToHal(void *response, size_t responseLen,
101 SignalStrength& signalStrength);
102
103void convertRilDataCallToHal(RIL_Data_Call_Response_v6 *dcResponse,
104 SetupDataCallResult& dcResult);
105
106void convertRilDataCallToHal(RIL_Data_Call_Response_v9 *dcResponse,
107 SetupDataCallResult& dcResult);
108
109void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
110 SetupDataCallResult& dcResult);
111
112void convertRilDataCallListToHal(void *response, size_t responseLen,
113 hidl_vec<SetupDataCallResult>& dcResultList);
114
115void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
116
117struct RadioImpl : public IRadio {
118 int32_t mSlotId;
119 sp<IRadioResponse> mRadioResponse;
120 sp<IRadioIndication> mRadioIndication;
121
122 Return<void> setResponseFunctions(
123 const ::android::sp<IRadioResponse>& radioResponse,
124 const ::android::sp<IRadioIndication>& radioIndication);
125
126 Return<void> getIccCardStatus(int32_t serial);
127
128 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
129 const hidl_string& aid);
130
131 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
132 const hidl_string& pin, const hidl_string& aid);
133
134 Return<void> supplyIccPin2ForApp(int32_t serial,
135 const hidl_string& pin2,
136 const hidl_string& aid);
137
138 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
139 const hidl_string& pin2, const hidl_string& aid);
140
141 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
142 const hidl_string& newPin, const hidl_string& aid);
143
144 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
145 const hidl_string& newPin2, const hidl_string& aid);
146
147 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
148
149 Return<void> getCurrentCalls(int32_t serial);
150
151 Return<void> dial(int32_t serial, const Dial& dialInfo);
152
153 Return<void> getImsiForApp(int32_t serial,
154 const ::android::hardware::hidl_string& aid);
155
156 Return<void> hangup(int32_t serial, int32_t gsmIndex);
157
158 Return<void> hangupWaitingOrBackground(int32_t serial);
159
160 Return<void> hangupForegroundResumeBackground(int32_t serial);
161
162 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
163
164 Return<void> conference(int32_t serial);
165
166 Return<void> rejectCall(int32_t serial);
167
168 Return<void> getLastCallFailCause(int32_t serial);
169
170 Return<void> getSignalStrength(int32_t serial);
171
172 Return<void> getVoiceRegistrationState(int32_t serial);
173
174 Return<void> getDataRegistrationState(int32_t serial);
175
176 Return<void> getOperator(int32_t serial);
177
178 Return<void> setRadioPower(int32_t serial, bool on);
179
180 Return<void> sendDtmf(int32_t serial,
181 const ::android::hardware::hidl_string& s);
182
183 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
184
185 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
186
187 Return<void> setupDataCall(int32_t serial,
188 RadioTechnology radioTechnology,
189 const DataProfileInfo& profileInfo,
190 bool modemCognitive,
191 bool roamingAllowed,
192 bool isRoaming);
193
194 Return<void> iccIOForApp(int32_t serial,
195 const IccIo& iccIo);
196
197 Return<void> sendUssd(int32_t serial,
198 const ::android::hardware::hidl_string& ussd);
199
200 Return<void> cancelPendingUssd(int32_t serial);
201
202 Return<void> getClir(int32_t serial);
203
204 Return<void> setClir(int32_t serial, int32_t status);
205
206 Return<void> getCallForwardStatus(int32_t serial,
207 const CallForwardInfo& callInfo);
208
209 Return<void> setCallForward(int32_t serial,
210 const CallForwardInfo& callInfo);
211
212 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
213
214 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
215
216 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
217 bool success, SmsAcknowledgeFailCause cause);
218
219 Return<void> acceptCall(int32_t serial);
220
221 Return<void> deactivateDataCall(int32_t serial,
222 int32_t cid, bool reasonRadioShutDown);
223
224 Return<void> getFacilityLockForApp(int32_t serial,
225 const ::android::hardware::hidl_string& facility,
226 const ::android::hardware::hidl_string& password,
227 int32_t serviceClass,
228 const ::android::hardware::hidl_string& appId);
229
230 Return<void> setFacilityLockForApp(int32_t serial,
231 const ::android::hardware::hidl_string& facility,
232 bool lockState,
233 const ::android::hardware::hidl_string& password,
234 int32_t serviceClass,
235 const ::android::hardware::hidl_string& appId);
236
237 Return<void> setBarringPassword(int32_t serial,
238 const ::android::hardware::hidl_string& facility,
239 const ::android::hardware::hidl_string& oldPassword,
240 const ::android::hardware::hidl_string& newPassword);
241
242 Return<void> getNetworkSelectionMode(int32_t serial);
243
244 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
245
246 Return<void> setNetworkSelectionModeManual(int32_t serial,
247 const ::android::hardware::hidl_string& operatorNumeric);
248
249 Return<void> getAvailableNetworks(int32_t serial);
250
251 Return<void> startDtmf(int32_t serial,
252 const ::android::hardware::hidl_string& s);
253
254 Return<void> stopDtmf(int32_t serial);
255
256 Return<void> getBasebandVersion(int32_t serial);
257
258 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
259
260 Return<void> setMute(int32_t serial, bool enable);
261
262 Return<void> getMute(int32_t serial);
263
264 Return<void> getClip(int32_t serial);
265
266 Return<void> getDataCallList(int32_t serial);
267
268 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
269
270 Return<void> writeSmsToSim(int32_t serial,
271 const SmsWriteArgs& smsWriteArgs);
272
273 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
274
275 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
276
277 Return<void> getAvailableBandModes(int32_t serial);
278
279 Return<void> sendEnvelope(int32_t serial,
280 const ::android::hardware::hidl_string& command);
281
282 Return<void> sendTerminalResponseToSim(int32_t serial,
283 const ::android::hardware::hidl_string& commandResponse);
284
285 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
286
287 Return<void> explicitCallTransfer(int32_t serial);
288
289 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
290
291 Return<void> getPreferredNetworkType(int32_t serial);
292
293 Return<void> getNeighboringCids(int32_t serial);
294
295 Return<void> setLocationUpdates(int32_t serial, bool enable);
296
297 Return<void> setCdmaSubscriptionSource(int32_t serial,
298 CdmaSubscriptionSource cdmaSub);
299
300 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
301
302 Return<void> getCdmaRoamingPreference(int32_t serial);
303
304 Return<void> setTTYMode(int32_t serial, TtyMode mode);
305
306 Return<void> getTTYMode(int32_t serial);
307
308 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
309
310 Return<void> getPreferredVoicePrivacy(int32_t serial);
311
312 Return<void> sendCDMAFeatureCode(int32_t serial,
313 const ::android::hardware::hidl_string& featureCode);
314
315 Return<void> sendBurstDtmf(int32_t serial,
316 const ::android::hardware::hidl_string& dtmf,
317 int32_t on,
318 int32_t off);
319
320 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
321
322 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
323 const CdmaSmsAck& smsAck);
324
325 Return<void> getGsmBroadcastConfig(int32_t serial);
326
327 Return<void> setGsmBroadcastConfig(int32_t serial,
328 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
329
330 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
331
332 Return<void> getCdmaBroadcastConfig(int32_t serial);
333
334 Return<void> setCdmaBroadcastConfig(int32_t serial,
335 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
336
337 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
338
339 Return<void> getCDMASubscription(int32_t serial);
340
341 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
342
343 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
344
345 Return<void> getDeviceIdentity(int32_t serial);
346
347 Return<void> exitEmergencyCallbackMode(int32_t serial);
348
349 Return<void> getSmscAddress(int32_t serial);
350
351 Return<void> setSmscAddress(int32_t serial,
352 const ::android::hardware::hidl_string& smsc);
353
354 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
355
356 Return<void> reportStkServiceIsRunning(int32_t serial);
357
358 Return<void> getCdmaSubscriptionSource(int32_t serial);
359
360 Return<void> requestIsimAuthentication(int32_t serial,
361 const ::android::hardware::hidl_string& challenge);
362
363 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
364 bool success,
365 const ::android::hardware::hidl_string& ackPdu);
366
367 Return<void> sendEnvelopeWithStatus(int32_t serial,
368 const ::android::hardware::hidl_string& contents);
369
370 Return<void> getVoiceRadioTechnology(int32_t serial);
371
372 Return<void> getCellInfoList(int32_t serial);
373
374 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
375
376 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
377 bool modemCognitive, bool isRoaming);
378
379 Return<void> getImsRegistrationState(int32_t serial);
380
381 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
382
383 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
384
385 Return<void> iccOpenLogicalChannel(int32_t serial,
386 const ::android::hardware::hidl_string& aid, int32_t p2);
387
388 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
389
390 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
391
392 Return<void> nvReadItem(int32_t serial, NvItem itemId);
393
394 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
395
396 Return<void> nvWriteCdmaPrl(int32_t serial,
397 const ::android::hardware::hidl_vec<uint8_t>& prl);
398
399 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
400
401 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
402
403 Return<void> setDataAllowed(int32_t serial, bool allow);
404
405 Return<void> getHardwareConfig(int32_t serial);
406
407 Return<void> requestIccSimAuthentication(int32_t serial,
408 int32_t authContext,
409 const ::android::hardware::hidl_string& authData,
410 const ::android::hardware::hidl_string& aid);
411
412 Return<void> setDataProfile(int32_t serial,
413 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
414
415 Return<void> requestShutdown(int32_t serial);
416
417 Return<void> getRadioCapability(int32_t serial);
418
419 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
420
421 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
422
423 Return<void> stopLceService(int32_t serial);
424
425 Return<void> pullLceData(int32_t serial);
426
427 Return<void> getModemActivityInfo(int32_t serial);
428
429 Return<void> setAllowedCarriers(int32_t serial,
430 bool allAllowed,
431 const CarrierRestrictions& carriers);
432
433 Return<void> getAllowedCarriers(int32_t serial);
434
435 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
436
437 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
438
439 Return<void> setSimCardPower(int32_t serial, bool powerUp);
440
441 Return<void> responseAcknowledgement();
442
443 void checkReturnStatus(Return<void>& ret);
444};
445
446struct OemHookImpl : public IOemHook {
447 int32_t mSlotId;
448 sp<IOemHookResponse> mOemHookResponse;
449 sp<IOemHookIndication> mOemHookIndication;
450
451 Return<void> setResponseFunctions(
452 const ::android::sp<IOemHookResponse>& oemHookResponse,
453 const ::android::sp<IOemHookIndication>& oemHookIndication);
454
455 Return<void> sendRequestRaw(int32_t serial,
456 const ::android::hardware::hidl_vec<uint8_t>& data);
457
458 Return<void> sendRequestStrings(int32_t serial,
459 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
460};
461
462void memsetAndFreeStrings(int numPointers, ...) {
463 va_list ap;
464 va_start(ap, numPointers);
465 for (int i = 0; i < numPointers; i++) {
466 char *ptr = va_arg(ap, char *);
467 if (ptr) {
468#ifdef MEMSET_FREED
469 // TODO: Should pass in the maximum length of the string
470 memsetString(ptr);
471#endif
472 free(ptr);
473 }
474 }
475 va_end(ap);
476}
477
478void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
479 pRI->pCI->responseFunction((int) pRI->socket_id,
480 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
481}
482
483/**
484 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
485 * request with error RIL_E_NO_MEMORY.
486 * Returns true on success, and false on failure.
487 */
488bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
489 size_t len = src.size();
490 if (len == 0) {
491 *dest = NULL;
492 return true;
493 }
494 *dest = (char *) calloc(len + 1, sizeof(char));
495 if (*dest == NULL) {
496 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
497 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
498 return false;
499 }
500 strncpy(*dest, src.c_str(), len + 1);
501 return true;
502}
503
504hidl_string convertCharPtrToHidlString(const char *ptr) {
505 hidl_string ret;
506 if (ptr != NULL) {
507 // TODO: replace this with strnlen
508 ret.setToExternal(ptr, strlen(ptr));
509 }
510 return ret;
511}
512
513bool dispatchVoid(int serial, int slotId, int request) {
514 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
515 if (pRI == NULL) {
516 return false;
517 }
518 CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
519 return true;
520}
521
522bool dispatchString(int serial, int slotId, int request, const char * str) {
523 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
524 if (pRI == NULL) {
525 return false;
526 }
527
528 char *pString;
529 if (!copyHidlStringToRil(&pString, str, pRI)) {
530 return false;
531 }
532
533 CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
534
535 memsetAndFreeStrings(1, pString);
536 return true;
537}
538
539bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) {
540 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
541 if (pRI == NULL) {
542 return false;
543 }
544
545 char **pStrings;
546 pStrings = (char **)calloc(countStrings, sizeof(char *));
547 if (pStrings == NULL) {
548 RLOGE("Memory allocation failed for request %s", requestToString(request));
549 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
550 return false;
551 }
552 va_list ap;
553 va_start(ap, countStrings);
554 for (int i = 0; i < countStrings; i++) {
555 const char* str = va_arg(ap, const char *);
556 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI)) {
557 va_end(ap);
558 for (int j = 0; j < i; j++) {
559 memsetAndFreeStrings(1, pStrings[j]);
560 }
561 free(pStrings);
562 return false;
563 }
564 }
565 va_end(ap);
566
567 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
568
569 if (pStrings != NULL) {
570 for (int i = 0 ; i < countStrings ; i++) {
571 memsetAndFreeStrings(1, pStrings[i]);
572 }
573
574#ifdef MEMSET_FREED
575 memset(pStrings, 0, countStrings * sizeof(char *));
576#endif
577 free(pStrings);
578 }
579 return true;
580}
581
582bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
583 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
584 if (pRI == NULL) {
585 return false;
586 }
587
588 int countStrings = data.size();
589 char **pStrings;
590 pStrings = (char **)calloc(countStrings, sizeof(char *));
591 if (pStrings == NULL) {
592 RLOGE("Memory allocation failed for request %s", requestToString(request));
593 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
594 return false;
595 }
596
597 for (int i = 0; i < countStrings; i++) {
598 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
599 for (int j = 0; j < i; j++) {
600 memsetAndFreeStrings(1, pStrings[j]);
601 }
602 free(pStrings);
603 return false;
604 }
605 }
606
607 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
608
609 if (pStrings != NULL) {
610 for (int i = 0 ; i < countStrings ; i++) {
611 memsetAndFreeStrings(1, pStrings[i]);
612 }
613
614#ifdef MEMSET_FREED
615 memset(pStrings, 0, countStrings * sizeof(char *));
616#endif
617 free(pStrings);
618 }
619 return true;
620}
621
622bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
623 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
624 if (pRI == NULL) {
625 return false;
626 }
627
628 int *pInts = (int *)calloc(countInts, sizeof(int));
629
630 if (pInts == NULL) {
631 RLOGE("Memory allocation failed for request %s", requestToString(request));
632 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
633 return false;
634 }
635 va_list ap;
636 va_start(ap, countInts);
637 for (int i = 0; i < countInts; i++) {
638 pInts[i] = va_arg(ap, int);
639 }
640 va_end(ap);
641
642 CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
643
644 if (pInts != NULL) {
645#ifdef MEMSET_FREED
646 memset(pInts, 0, countInts * sizeof(int));
647#endif
648 free(pInts);
649 }
650 return true;
651}
652
653bool dispatchCallForwardStatus(int serial, int slotId, int request,
654 const CallForwardInfo& callInfo) {
655 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
656 if (pRI == NULL) {
657 return false;
658 }
659
660 RIL_CallForwardInfo cf;
661 cf.status = (int) callInfo.status;
662 cf.reason = callInfo.reason;
663 cf.serviceClass = callInfo.serviceClass;
664 cf.toa = callInfo.toa;
665 cf.timeSeconds = callInfo.timeSeconds;
666
667 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
668 return false;
669 }
670
671 CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
672
673 memsetAndFreeStrings(1, cf.number);
674
675 return true;
676}
677
678bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
679 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
680 if (pRI == NULL) {
681 return false;
682 }
683
684 const uint8_t *uData = rawBytes.data();
685
686 CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
687
688 return true;
689}
690
691bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
692 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
693 if (pRI == NULL) {
694 return false;
695 }
696
697 RIL_SIM_APDU apdu = {};
698
699 apdu.sessionid = message.sessionId;
700 apdu.cla = message.cla;
701 apdu.instruction = message.instruction;
702 apdu.p1 = message.p1;
703 apdu.p2 = message.p2;
704 apdu.p3 = message.p3;
705
706 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
707 return false;
708 }
709
710 CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
711
712 memsetAndFreeStrings(1, apdu.data);
713
714 return true;
715}
716
717void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
718 if (ret.isOk() == false) {
719 RLOGE("checkReturnStatus: unable to call response/indication callback");
720 // Remote process hosting the callbacks must be dead. Reset the callback objects;
721 // there's no other recovery to be done here. When the client process is back up, it will
722 // call setResponseFunctions()
723
724 // Caller should already hold rdlock, release that first
725 // note the current counter to avoid overwriting updates made by another thread before
726 // write lock is acquired.
727 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
728 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
729 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
730 assert(ret == 0);
731
732 // acquire wrlock
733 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
734 assert(ret == 0);
735
736 // make sure the counter value has not changed
737 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
738 if (isRadioService) {
739 radioService[slotId]->mRadioResponse = NULL;
740 radioService[slotId]->mRadioIndication = NULL;
741 } else {
742 oemHookService[slotId]->mOemHookResponse = NULL;
743 oemHookService[slotId]->mOemHookIndication = NULL;
744 }
745 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
746 } else {
747 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
748 "got updated on another thread");
749 }
750
751 // release wrlock
752 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
753 assert(ret == 0);
754
755 // Reacquire rdlock
756 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
757 assert(ret == 0);
758 }
759}
760
761void RadioImpl::checkReturnStatus(Return<void>& ret) {
762 ::checkReturnStatus(mSlotId, ret, true);
763}
764
765Return<void> RadioImpl::setResponseFunctions(
766 const ::android::sp<IRadioResponse>& radioResponseParam,
767 const ::android::sp<IRadioIndication>& radioIndicationParam) {
768 RLOGD("setResponseFunctions");
769
770 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
771 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
772 assert(ret == 0);
773
774 mRadioResponse = radioResponseParam;
775 mRadioIndication = radioIndicationParam;
776 mCounterRadio[mSlotId]++;
777
778 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
779 assert(ret == 0);
780
781 // client is connected. Send initial indications.
782 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
783
784 return Void();
785}
786
787Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
788#if VDBG
789 RLOGD("getIccCardStatus: serial %d", serial);
790#endif
791 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
792 return Void();
793}
794
795Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
796 const hidl_string& aid) {
797#if VDBG
798 RLOGD("supplyIccPinForApp: serial %d", serial);
799#endif
800 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
801 2, pin.c_str(), aid.c_str());
802 return Void();
803}
804
805Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
806 const hidl_string& pin, const hidl_string& aid) {
807#if VDBG
808 RLOGD("supplyIccPukForApp: serial %d", serial);
809#endif
810 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
811 3, puk.c_str(), pin.c_str(), aid.c_str());
812 return Void();
813}
814
815Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
816 const hidl_string& aid) {
817#if VDBG
818 RLOGD("supplyIccPin2ForApp: serial %d", serial);
819#endif
820 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
821 2, pin2.c_str(), aid.c_str());
822 return Void();
823}
824
825Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
826 const hidl_string& pin2, const hidl_string& aid) {
827#if VDBG
828 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
829#endif
830 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
831 3, puk2.c_str(), pin2.c_str(), aid.c_str());
832 return Void();
833}
834
835Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
836 const hidl_string& newPin, const hidl_string& aid) {
837#if VDBG
838 RLOGD("changeIccPinForApp: serial %d", serial);
839#endif
840 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
841 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
842 return Void();
843}
844
845Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
846 const hidl_string& newPin2, const hidl_string& aid) {
847#if VDBG
848 RLOGD("changeIccPin2ForApp: serial %d", serial);
849#endif
850 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
851 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
852 return Void();
853}
854
855Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
856 const hidl_string& netPin) {
857#if VDBG
858 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
859#endif
860 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
861 1, netPin.c_str());
862 return Void();
863}
864
865Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
866#if VDBG
867 RLOGD("getCurrentCalls: serial %d", serial);
868#endif
869 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
870 return Void();
871}
872
873Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
874#if VDBG
875 RLOGD("dial: serial %d", serial);
876#endif
877 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
878 if (pRI == NULL) {
879 return Void();
880 }
881 RIL_Dial dial = {};
882 RIL_UUS_Info uusInfo = {};
883 int32_t sizeOfDial = sizeof(dial);
884
885 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
886 return Void();
887 }
888 dial.clir = (int) dialInfo.clir;
889
890 if (dialInfo.uusInfo.size() != 0) {
891 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
892 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
893
894 if (dialInfo.uusInfo[0].uusData.size() == 0) {
895 uusInfo.uusData = NULL;
896 uusInfo.uusLength = 0;
897 } else {
898 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
899 memsetAndFreeStrings(1, dial.address);
900 return Void();
901 }
902 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
903 }
904
905 dial.uusInfo = &uusInfo;
906 }
907
908 CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
909
910 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
911
912 return Void();
913}
914
915Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
916#if VDBG
917 RLOGD("getImsiForApp: serial %d", serial);
918#endif
919 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
920 1, aid.c_str());
921 return Void();
922}
923
924Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
925#if VDBG
926 RLOGD("hangup: serial %d", serial);
927#endif
928 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
929 return Void();
930}
931
932Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
933#if VDBG
934 RLOGD("hangupWaitingOrBackground: serial %d", serial);
935#endif
936 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
937 return Void();
938}
939
940Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
941#if VDBG
942 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
943#endif
944 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
945 return Void();
946}
947
948Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
949#if VDBG
950 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
951#endif
952 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
953 return Void();
954}
955
956Return<void> RadioImpl::conference(int32_t serial) {
957#if VDBG
958 RLOGD("conference: serial %d", serial);
959#endif
960 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
961 return Void();
962}
963
964Return<void> RadioImpl::rejectCall(int32_t serial) {
965#if VDBG
966 RLOGD("rejectCall: serial %d", serial);
967#endif
968 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
969 return Void();
970}
971
972Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
973#if VDBG
974 RLOGD("getLastCallFailCause: serial %d", serial);
975#endif
976 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
977 return Void();
978}
979
980Return<void> RadioImpl::getSignalStrength(int32_t serial) {
981#if VDBG
982 RLOGD("getSignalStrength: serial %d", serial);
983#endif
984 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
985 return Void();
986}
987
988Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
989#if VDBG
990 RLOGD("getVoiceRegistrationState: serial %d", serial);
991#endif
992 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
993 return Void();
994}
995
996Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
997#if VDBG
998 RLOGD("getDataRegistrationState: serial %d", serial);
999#endif
1000 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1001 return Void();
1002}
1003
1004Return<void> RadioImpl::getOperator(int32_t serial) {
1005#if VDBG
1006 RLOGD("getOperator: serial %d", serial);
1007#endif
1008 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1009 return Void();
1010}
1011
1012Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
1013 RLOGD("setRadioPower: serial %d on %d", serial, on);
1014 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1015 return Void();
1016}
1017
1018Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1019#if VDBG
1020 RLOGD("sendDtmf: serial %d", serial);
1021#endif
1022 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1023 return Void();
1024}
1025
1026Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1027#if VDBG
1028 RLOGD("sendSms: serial %d", serial);
1029#endif
1030 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
1031 2, message.smscPdu.c_str(), message.pdu.c_str());
1032 return Void();
1033}
1034
1035Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1036#if VDBG
1037 RLOGD("sendSMSExpectMore: serial %d", serial);
1038#endif
1039 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
1040 2, message.smscPdu.c_str(), message.pdu.c_str());
1041 return Void();
1042}
1043
1044static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1045 switch (type) {
1046 case MvnoType::IMSI:
1047 str = (char *)"imsi";
1048 return true;
1049 case MvnoType::GID:
1050 str = (char *)"gid";
1051 return true;
1052 case MvnoType::SPN:
1053 str = (char *)"spn";
1054 return true;
1055 case MvnoType::NONE:
1056 str = (char *)"";
1057 return true;
1058 }
1059 return false;
1060}
1061
1062Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1063 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1064 bool roamingAllowed, bool isRoaming) {
1065
1066#if VDBG
1067 RLOGD("setupDataCall: serial %d", serial);
1068#endif
1069
1070 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1071 const hidl_string &protocol =
1072 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1073 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
1074 std::to_string((int) radioTechnology + 2).c_str(),
1075 std::to_string((int) dataProfileInfo.profileId).c_str(),
1076 dataProfileInfo.apn.c_str(),
1077 dataProfileInfo.user.c_str(),
1078 dataProfileInfo.password.c_str(),
1079 std::to_string((int) dataProfileInfo.authType).c_str(),
1080 protocol.c_str());
1081 } else if (s_vendorFunctions->version >= 15) {
1082 char *mvnoTypeStr = NULL;
1083 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1084 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1085 RIL_REQUEST_SETUP_DATA_CALL);
1086 if (pRI != NULL) {
1087 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1088 }
1089 return Void();
1090 }
1091 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1092 std::to_string((int) radioTechnology + 2).c_str(),
1093 std::to_string((int) dataProfileInfo.profileId).c_str(),
1094 dataProfileInfo.apn.c_str(),
1095 dataProfileInfo.user.c_str(),
1096 dataProfileInfo.password.c_str(),
1097 std::to_string((int) dataProfileInfo.authType).c_str(),
1098 dataProfileInfo.protocol.c_str(),
1099 dataProfileInfo.roamingProtocol.c_str(),
1100 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1101 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1102 modemCognitive ? "1" : "0",
1103 std::to_string(dataProfileInfo.mtu).c_str(),
1104 mvnoTypeStr,
1105 dataProfileInfo.mvnoMatchData.c_str(),
1106 roamingAllowed ? "1" : "0");
1107 } else {
1108 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1109 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1110 RIL_REQUEST_SETUP_DATA_CALL);
1111 if (pRI != NULL) {
1112 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1113 }
1114 }
1115 return Void();
1116}
1117
1118Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1119#if VDBG
1120 RLOGD("iccIOForApp: serial %d", serial);
1121#endif
1122 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1123 if (pRI == NULL) {
1124 return Void();
1125 }
1126
1127 RIL_SIM_IO_v6 rilIccIo = {};
1128 rilIccIo.command = iccIo.command;
1129 rilIccIo.fileid = iccIo.fileId;
1130 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1131 return Void();
1132 }
1133
1134 rilIccIo.p1 = iccIo.p1;
1135 rilIccIo.p2 = iccIo.p2;
1136 rilIccIo.p3 = iccIo.p3;
1137
1138 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1139 memsetAndFreeStrings(1, rilIccIo.path);
1140 return Void();
1141 }
1142
1143 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1144 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1145 return Void();
1146 }
1147
1148 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1149 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1150 return Void();
1151 }
1152
1153 CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1154
1155 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1156
1157 return Void();
1158}
1159
1160Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1161#if VDBG
1162 RLOGD("sendUssd: serial %d", serial);
1163#endif
1164 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1165 return Void();
1166}
1167
1168Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1169#if VDBG
1170 RLOGD("cancelPendingUssd: serial %d", serial);
1171#endif
1172 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1173 return Void();
1174}
1175
1176Return<void> RadioImpl::getClir(int32_t serial) {
1177#if VDBG
1178 RLOGD("getClir: serial %d", serial);
1179#endif
1180 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1181 return Void();
1182}
1183
1184Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1185#if VDBG
1186 RLOGD("setClir: serial %d", serial);
1187#endif
1188 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1189 return Void();
1190}
1191
1192Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1193#if VDBG
1194 RLOGD("getCallForwardStatus: serial %d", serial);
1195#endif
1196 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1197 callInfo);
1198 return Void();
1199}
1200
1201Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1202#if VDBG
1203 RLOGD("setCallForward: serial %d", serial);
1204#endif
1205 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1206 callInfo);
1207 return Void();
1208}
1209
1210Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1211#if VDBG
1212 RLOGD("getCallWaiting: serial %d", serial);
1213#endif
1214 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1215 return Void();
1216}
1217
1218Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1219#if VDBG
1220 RLOGD("setCallWaiting: serial %d", serial);
1221#endif
1222 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1223 serviceClass);
1224 return Void();
1225}
1226
1227Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1228 bool success, SmsAcknowledgeFailCause cause) {
1229#if VDBG
1230 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1231#endif
1232 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1233 cause);
1234 return Void();
1235}
1236
1237Return<void> RadioImpl::acceptCall(int32_t serial) {
1238#if VDBG
1239 RLOGD("acceptCall: serial %d", serial);
1240#endif
1241 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1242 return Void();
1243}
1244
1245Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1246 int32_t cid, bool reasonRadioShutDown) {
1247#if VDBG
1248 RLOGD("deactivateDataCall: serial %d", serial);
1249#endif
1250 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1251 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1252 return Void();
1253}
1254
1255Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1256 const hidl_string& password, int32_t serviceClass,
1257 const hidl_string& appId) {
1258#if VDBG
1259 RLOGD("getFacilityLockForApp: serial %d", serial);
1260#endif
1261 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1262 4, facility.c_str(), password.c_str(),
1263 (std::to_string(serviceClass)).c_str(), appId.c_str());
1264 return Void();
1265}
1266
1267Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1268 bool lockState, const hidl_string& password,
1269 int32_t serviceClass, const hidl_string& appId) {
1270#if VDBG
1271 RLOGD("setFacilityLockForApp: serial %d", serial);
1272#endif
1273 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1274 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1275 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1276 return Void();
1277}
1278
1279Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1280 const hidl_string& oldPassword,
1281 const hidl_string& newPassword) {
1282#if VDBG
1283 RLOGD("setBarringPassword: serial %d", serial);
1284#endif
1285 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1286 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1287 return Void();
1288}
1289
1290Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1291#if VDBG
1292 RLOGD("getNetworkSelectionMode: serial %d", serial);
1293#endif
1294 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1295 return Void();
1296}
1297
1298Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1299#if VDBG
1300 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1301#endif
1302 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1303 return Void();
1304}
1305
1306Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1307 const hidl_string& operatorNumeric) {
1308#if VDBG
1309 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1310#endif
1311 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1312 operatorNumeric.c_str());
1313 return Void();
1314}
1315
1316Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1317#if VDBG
1318 RLOGD("getAvailableNetworks: serial %d", serial);
1319#endif
1320 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1321 return Void();
1322}
1323
1324Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1325#if VDBG
1326 RLOGD("startDtmf: serial %d", serial);
1327#endif
1328 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1329 s.c_str());
1330 return Void();
1331}
1332
1333Return<void> RadioImpl::stopDtmf(int32_t serial) {
1334#if VDBG
1335 RLOGD("stopDtmf: serial %d", serial);
1336#endif
1337 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1338 return Void();
1339}
1340
1341Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1342#if VDBG
1343 RLOGD("getBasebandVersion: serial %d", serial);
1344#endif
1345 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1346 return Void();
1347}
1348
1349Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1350#if VDBG
1351 RLOGD("separateConnection: serial %d", serial);
1352#endif
1353 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1354 return Void();
1355}
1356
1357Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1358#if VDBG
1359 RLOGD("setMute: serial %d", serial);
1360#endif
1361 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1362 return Void();
1363}
1364
1365Return<void> RadioImpl::getMute(int32_t serial) {
1366#if VDBG
1367 RLOGD("getMute: serial %d", serial);
1368#endif
1369 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1370 return Void();
1371}
1372
1373Return<void> RadioImpl::getClip(int32_t serial) {
1374#if VDBG
1375 RLOGD("getClip: serial %d", serial);
1376#endif
1377 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1378 return Void();
1379}
1380
1381Return<void> RadioImpl::getDataCallList(int32_t serial) {
1382#if VDBG
1383 RLOGD("getDataCallList: serial %d", serial);
1384#endif
1385 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1386 return Void();
1387}
1388
1389Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1390#if VDBG
1391 RLOGD("setSuppServiceNotifications: serial %d", serial);
1392#endif
1393 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1394 BOOL_TO_INT(enable));
1395 return Void();
1396}
1397
1398Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1399#if VDBG
1400 RLOGD("writeSmsToSim: serial %d", serial);
1401#endif
1402 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1403 if (pRI == NULL) {
1404 return Void();
1405 }
1406
1407 RIL_SMS_WriteArgs args;
1408 args.status = (int) smsWriteArgs.status;
1409
1410 int len;
1411 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1412 return Void();
1413 }
1414
1415 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1416 memsetAndFreeStrings(1, args.pdu);
1417 return Void();
1418 }
1419
1420 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
1421
1422 memsetAndFreeStrings(2, args.smsc, args.pdu);
1423
1424 return Void();
1425}
1426
1427Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1428#if VDBG
1429 RLOGD("deleteSmsOnSim: serial %d", serial);
1430#endif
1431 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1432 return Void();
1433}
1434
1435Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1436#if VDBG
1437 RLOGD("setBandMode: serial %d", serial);
1438#endif
1439 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1440 return Void();
1441}
1442
1443Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1444#if VDBG
1445 RLOGD("getAvailableBandModes: serial %d", serial);
1446#endif
1447 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1448 return Void();
1449}
1450
1451Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1452#if VDBG
1453 RLOGD("sendEnvelope: serial %d", serial);
1454#endif
1455 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1456 command.c_str());
1457 return Void();
1458}
1459
1460Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1461 const hidl_string& commandResponse) {
1462#if VDBG
1463 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1464#endif
1465 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1466 commandResponse.c_str());
1467 return Void();
1468}
1469
1470Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1471#if VDBG
1472 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1473#endif
1474 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1475 1, BOOL_TO_INT(accept));
1476 return Void();
1477}
1478
1479Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1480#if VDBG
1481 RLOGD("explicitCallTransfer: serial %d", serial);
1482#endif
1483 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1484 return Void();
1485}
1486
1487Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1488#if VDBG
1489 RLOGD("setPreferredNetworkType: serial %d", serial);
1490#endif
1491 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1492 return Void();
1493}
1494
1495Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1496#if VDBG
1497 RLOGD("getPreferredNetworkType: serial %d", serial);
1498#endif
1499 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1500 return Void();
1501}
1502
1503Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1504#if VDBG
1505 RLOGD("getNeighboringCids: serial %d", serial);
1506#endif
1507 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1508 return Void();
1509}
1510
1511Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1512#if VDBG
1513 RLOGD("setLocationUpdates: serial %d", serial);
1514#endif
1515 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1516 return Void();
1517}
1518
1519Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1520#if VDBG
1521 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1522#endif
1523 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1524 return Void();
1525}
1526
1527Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1528#if VDBG
1529 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1530#endif
1531 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1532 return Void();
1533}
1534
1535Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1536#if VDBG
1537 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1538#endif
1539 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1540 return Void();
1541}
1542
1543Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1544#if VDBG
1545 RLOGD("setTTYMode: serial %d", serial);
1546#endif
1547 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1548 return Void();
1549}
1550
1551Return<void> RadioImpl::getTTYMode(int32_t serial) {
1552#if VDBG
1553 RLOGD("getTTYMode: serial %d", serial);
1554#endif
1555 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1556 return Void();
1557}
1558
1559Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1560#if VDBG
1561 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1562#endif
1563 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1564 1, BOOL_TO_INT(enable));
1565 return Void();
1566}
1567
1568Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1569#if VDBG
1570 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1571#endif
1572 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1573 return Void();
1574}
1575
1576Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1577#if VDBG
1578 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1579#endif
1580 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1581 featureCode.c_str());
1582 return Void();
1583}
1584
1585Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1586 int32_t off) {
1587#if VDBG
1588 RLOGD("sendBurstDtmf: serial %d", serial);
1589#endif
1590 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1591 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1592 (std::to_string(off)).c_str());
1593 return Void();
1594}
1595
1596void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1597 rcsm.uTeleserviceID = sms.teleserviceId;
1598 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1599 rcsm.uServicecategory = sms.serviceCategory;
1600 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1601 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1602 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1603 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1604
1605 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1606 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1607 for (int i = 0; i < digitLimit; i++) {
1608 rcsm.sAddress.digits[i] = sms.address.digits[i];
1609 }
1610
1611 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1612 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1613
1614 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1615 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1616 for (int i = 0; i < digitLimit; i++) {
1617 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1618 }
1619
1620 rcsm.uBearerDataLen = sms.bearerData.size();
1621 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1622 for (int i = 0; i < digitLimit; i++) {
1623 rcsm.aBearerData[i] = sms.bearerData[i];
1624 }
1625}
1626
1627Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1628#if VDBG
1629 RLOGD("sendCdmaSms: serial %d", serial);
1630#endif
1631 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1632 if (pRI == NULL) {
1633 return Void();
1634 }
1635
1636 RIL_CDMA_SMS_Message rcsm = {};
1637 constructCdmaSms(rcsm, sms);
1638
1639 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
1640 return Void();
1641}
1642
1643Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1644#if VDBG
1645 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1646#endif
1647 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1648 if (pRI == NULL) {
1649 return Void();
1650 }
1651
1652 RIL_CDMA_SMS_Ack rcsa = {};
1653
1654 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1655 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1656
1657 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
1658 return Void();
1659}
1660
1661Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1662#if VDBG
1663 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1664#endif
1665 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1666 return Void();
1667}
1668
1669Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1670 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1671 configInfo) {
1672#if VDBG
1673 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1674#endif
1675 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1676 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1677 if (pRI == NULL) {
1678 return Void();
1679 }
1680
1681 int num = configInfo.size();
1682 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1683 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1684
1685 for (int i = 0 ; i < num ; i++ ) {
1686 gsmBciPtrs[i] = &gsmBci[i];
1687 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1688 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1689 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1690 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1691 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1692 }
1693
1694 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs,
1695 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
1696 return Void();
1697}
1698
1699Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1700#if VDBG
1701 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1702#endif
1703 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1704 1, BOOL_TO_INT(!activate));
1705 return Void();
1706}
1707
1708Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1709#if VDBG
1710 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1711#endif
1712 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1713 return Void();
1714}
1715
1716Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1717 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1718 configInfo) {
1719#if VDBG
1720 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1721#endif
1722 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1723 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1724 if (pRI == NULL) {
1725 return Void();
1726 }
1727
1728 int num = configInfo.size();
1729 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1730 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1731
1732 for (int i = 0 ; i < num ; i++ ) {
1733 cdmaBciPtrs[i] = &cdmaBci[i];
1734 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1735 cdmaBci[i].language = configInfo[i].language;
1736 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1737 }
1738
1739 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs,
1740 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
1741 return Void();
1742}
1743
1744Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1745#if VDBG
1746 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1747#endif
1748 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1749 1, BOOL_TO_INT(!activate));
1750 return Void();
1751}
1752
1753Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1754#if VDBG
1755 RLOGD("getCDMASubscription: serial %d", serial);
1756#endif
1757 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1758 return Void();
1759}
1760
1761Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1762#if VDBG
1763 RLOGD("writeSmsToRuim: serial %d", serial);
1764#endif
1765 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1766 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1767 if (pRI == NULL) {
1768 return Void();
1769 }
1770
1771 RIL_CDMA_SMS_WriteArgs rcsw = {};
1772 rcsw.status = (int) cdmaSms.status;
1773 constructCdmaSms(rcsw.message, cdmaSms.message);
1774
1775 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
1776 return Void();
1777}
1778
1779Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1780#if VDBG
1781 RLOGD("deleteSmsOnRuim: serial %d", serial);
1782#endif
1783 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1784 return Void();
1785}
1786
1787Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1788#if VDBG
1789 RLOGD("getDeviceIdentity: serial %d", serial);
1790#endif
1791 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1792 return Void();
1793}
1794
1795Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1796#if VDBG
1797 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1798#endif
1799 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1800 return Void();
1801}
1802
1803Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1804#if VDBG
1805 RLOGD("getSmscAddress: serial %d", serial);
1806#endif
1807 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1808 return Void();
1809}
1810
1811Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1812#if VDBG
1813 RLOGD("setSmscAddress: serial %d", serial);
1814#endif
1815 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1816 smsc.c_str());
1817 return Void();
1818}
1819
1820Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1821#if VDBG
1822 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1823#endif
1824 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1825 BOOL_TO_INT(available));
1826 return Void();
1827}
1828
1829Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1830#if VDBG
1831 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1832#endif
1833 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1834 return Void();
1835}
1836
1837Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1838#if VDBG
1839 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1840#endif
1841 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1842 return Void();
1843}
1844
1845Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1846#if VDBG
1847 RLOGD("requestIsimAuthentication: serial %d", serial);
1848#endif
1849 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1850 challenge.c_str());
1851 return Void();
1852}
1853
1854Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1855 const hidl_string& ackPdu) {
1856#if VDBG
1857 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1858#endif
1859 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1860 2, success ? "1" : "0", ackPdu.c_str());
1861 return Void();
1862}
1863
1864Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1865#if VDBG
1866 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1867#endif
1868 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1869 contents.c_str());
1870 return Void();
1871}
1872
1873Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1874#if VDBG
1875 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1876#endif
1877 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1878 return Void();
1879}
1880
1881Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1882#if VDBG
1883 RLOGD("getCellInfoList: serial %d", serial);
1884#endif
1885 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1886 return Void();
1887}
1888
1889Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1890#if VDBG
1891 RLOGD("setCellInfoListRate: serial %d", serial);
1892#endif
1893 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1894 return Void();
1895}
1896
1897Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1898 bool modemCognitive, bool isRoaming) {
1899#if VDBG
1900 RLOGD("setInitialAttachApn: serial %d", serial);
1901#endif
1902 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1903 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
1904 if (pRI == NULL) {
1905 return Void();
1906 }
1907
1908 if (s_vendorFunctions->version <= 14) {
1909 RIL_InitialAttachApn iaa = {};
1910
1911 if (dataProfileInfo.apn.size() == 0) {
1912 iaa.apn = (char *) calloc(1, sizeof(char));
1913 if (iaa.apn == NULL) {
1914 RLOGE("Memory allocation failed for request %s",
1915 requestToString(pRI->pCI->requestNumber));
1916 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1917 return Void();
1918 }
1919 iaa.apn[0] = '\0';
1920 } else {
1921 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1922 return Void();
1923 }
1924 }
1925
1926 const hidl_string &protocol =
1927 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1928
1929 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
1930 memsetAndFreeStrings(1, iaa.apn);
1931 return Void();
1932 }
1933 iaa.authtype = (int) dataProfileInfo.authType;
1934 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1935 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
1936 return Void();
1937 }
1938 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1939 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
1940 return Void();
1941 }
1942
1943 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
1944
1945 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
1946 } else {
1947 RIL_InitialAttachApn_v15 iaa = {};
1948
1949 if (dataProfileInfo.apn.size() == 0) {
1950 iaa.apn = (char *) calloc(1, sizeof(char));
1951 if (iaa.apn == NULL) {
1952 RLOGE("Memory allocation failed for request %s",
1953 requestToString(pRI->pCI->requestNumber));
1954 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1955 return Void();
1956 }
1957 iaa.apn[0] = '\0';
1958 } else {
1959 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1960 return Void();
1961 }
1962 }
1963
1964 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
1965 memsetAndFreeStrings(1, iaa.apn);
1966 return Void();
1967 }
1968 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
1969 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
1970 return Void();
1971 }
1972 iaa.authtype = (int) dataProfileInfo.authType;
1973 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1974 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
1975 return Void();
1976 }
1977 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1978 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
1979 return Void();
1980 }
1981 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
1982 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
1983 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
1984 iaa.mtu = dataProfileInfo.mtu;
1985
1986 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
1987 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1988 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1989 iaa.password);
1990 return Void();
1991 }
1992
1993 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
1994 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1995 iaa.password);
1996 return Void();
1997 }
1998
1999 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2000
2001 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2002 iaa.password, iaa.mvnoMatchData);
2003 }
2004
2005 return Void();
2006}
2007
2008Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
2009#if VDBG
2010 RLOGD("getImsRegistrationState: serial %d", serial);
2011#endif
2012 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2013 return Void();
2014}
2015
2016bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2017 RIL_IMS_SMS_Message rism = {};
2018 char **pStrings;
2019 int countStrings = 2;
2020 int dataLen = sizeof(char *) * countStrings;
2021
2022 rism.tech = RADIO_TECH_3GPP;
2023 rism.retry = BOOL_TO_INT(message.retry);
2024 rism.messageRef = message.messageRef;
2025
2026 if (message.gsmMessage.size() != 1) {
2027 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2028 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2029 return false;
2030 }
2031
2032 pStrings = (char **)calloc(countStrings, sizeof(char *));
2033 if (pStrings == NULL) {
2034 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2035 requestToString(pRI->pCI->requestNumber));
2036 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2037 return false;
2038 }
2039
2040 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2041#ifdef MEMSET_FREED
2042 memset(pStrings, 0, datalen);
2043#endif
2044 free(pStrings);
2045 return false;
2046 }
2047
2048 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2049 memsetAndFreeStrings(1, pStrings[0]);
2050#ifdef MEMSET_FREED
2051 memset(pStrings, 0, datalen);
2052#endif
2053 free(pStrings);
2054 return false;
2055 }
2056
2057 rism.message.gsmMessage = pStrings;
2058 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2059 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2060
2061 for (int i = 0 ; i < countStrings ; i++) {
2062 memsetAndFreeStrings(1, pStrings[i]);
2063 }
2064
2065#ifdef MEMSET_FREED
2066 memset(pStrings, 0, datalen);
2067#endif
2068 free(pStrings);
2069
2070 return true;
2071}
2072
2073bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2074 RIL_IMS_SMS_Message rism = {};
2075 RIL_CDMA_SMS_Message rcsm = {};
2076
2077 if (message.cdmaMessage.size() != 1) {
2078 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2079 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2080 return false;
2081 }
2082
2083 rism.tech = RADIO_TECH_3GPP2;
2084 rism.retry = BOOL_TO_INT(message.retry);
2085 rism.messageRef = message.messageRef;
2086 rism.message.cdmaMessage = &rcsm;
2087
2088 constructCdmaSms(rcsm, message.cdmaMessage[0]);
2089
2090 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2091 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI, pRI->socket_id);
2092
2093 return true;
2094}
2095
2096Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2097#if VDBG
2098 RLOGD("sendImsSms: serial %d", serial);
2099#endif
2100 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2101 if (pRI == NULL) {
2102 return Void();
2103 }
2104
2105 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2106
2107 if (RADIO_TECH_3GPP == format) {
2108 dispatchImsGsmSms(message, pRI);
2109 } else if (RADIO_TECH_3GPP2 == format) {
2110 dispatchImsCdmaSms(message, pRI);
2111 } else {
2112 RLOGE("sendImsSms: Invalid radio tech %s",
2113 requestToString(pRI->pCI->requestNumber));
2114 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2115 }
2116 return Void();
2117}
2118
2119Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2120#if VDBG
2121 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2122#endif
2123 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2124 return Void();
2125}
2126
2127Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2128#if VDBG
2129 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2130#endif
2131 if (s_vendorFunctions->version < 15) {
2132 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2133 } else {
2134 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2135 if (pRI == NULL) {
2136 return Void();
2137 }
2138
2139 RIL_OpenChannelParams params = {};
2140
2141 params.p2 = p2;
2142
2143 if (!copyHidlStringToRil(&params.aidPtr, aid, pRI)) {
2144 return Void();
2145 }
2146
2147 CALL_ONREQUEST(pRI->pCI->requestNumber, &params, sizeof(params), pRI, mSlotId);
2148
2149 memsetAndFreeStrings(1, params.aidPtr);
2150 }
2151 return Void();
2152}
2153
2154Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2155#if VDBG
2156 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2157#endif
2158 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2159 return Void();
2160}
2161
2162Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2163#if VDBG
2164 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2165#endif
2166 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2167 return Void();
2168}
2169
2170Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2171#if VDBG
2172 RLOGD("nvReadItem: serial %d", serial);
2173#endif
2174 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2175 if (pRI == NULL) {
2176 return Void();
2177 }
2178
2179 RIL_NV_ReadItem nvri = {};
2180 nvri.itemID = (RIL_NV_Item) itemId;
2181
2182 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2183 return Void();
2184}
2185
2186Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2187#if VDBG
2188 RLOGD("nvWriteItem: serial %d", serial);
2189#endif
2190 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2191 if (pRI == NULL) {
2192 return Void();
2193 }
2194
2195 RIL_NV_WriteItem nvwi = {};
2196
2197 nvwi.itemID = (RIL_NV_Item) item.itemId;
2198
2199 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2200 return Void();
2201 }
2202
2203 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2204
2205 memsetAndFreeStrings(1, nvwi.value);
2206 return Void();
2207}
2208
2209Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2210#if VDBG
2211 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2212#endif
2213 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2214 return Void();
2215}
2216
2217Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2218 int rilResetType = -1;
2219#if VDBG
2220 RLOGD("nvResetConfig: serial %d", serial);
2221#endif
2222 /* Convert ResetNvType to RIL.h values
2223 * RIL_REQUEST_NV_RESET_CONFIG
2224 * 1 - reload all NV items
2225 * 2 - erase NV reset (SCRTN)
2226 * 3 - factory reset (RTN)
2227 */
2228 switch(resetType) {
2229 case ResetNvType::RELOAD:
2230 rilResetType = 1;
2231 break;
2232 case ResetNvType::ERASE:
2233 rilResetType = 2;
2234 break;
2235 case ResetNvType::FACTORY_RESET:
2236 rilResetType = 3;
2237 break;
2238 }
2239 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2240 return Void();
2241}
2242
2243Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2244#if VDBG
2245 RLOGD("setUiccSubscription: serial %d", serial);
2246#endif
2247 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2248 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2249 if (pRI == NULL) {
2250 return Void();
2251 }
2252
2253 RIL_SelectUiccSub rilUiccSub = {};
2254
2255 rilUiccSub.slot = uiccSub.slot;
2256 rilUiccSub.app_index = uiccSub.appIndex;
2257 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2258 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2259
2260 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2261 return Void();
2262}
2263
2264Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2265#if VDBG
2266 RLOGD("setDataAllowed: serial %d", serial);
2267#endif
2268 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2269 return Void();
2270}
2271
2272Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2273#if VDBG
2274 RLOGD("getHardwareConfig: serial %d", serial);
2275#endif
2276 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2277 return Void();
2278}
2279
2280Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2281 const hidl_string& authData, const hidl_string& aid) {
2282#if VDBG
2283 RLOGD("requestIccSimAuthentication: serial %d", serial);
2284#endif
2285 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2286 if (pRI == NULL) {
2287 return Void();
2288 }
2289
2290 RIL_SimAuthentication pf = {};
2291
2292 pf.authContext = authContext;
2293
2294 int len;
2295 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2296 return Void();
2297 }
2298
2299 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2300 memsetAndFreeStrings(1, pf.authData);
2301 return Void();
2302 }
2303
2304 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2305
2306 memsetAndFreeStrings(2, pf.authData, pf.aid);
2307 return Void();
2308}
2309
2310/**
2311 * @param numProfiles number of data profile
2312 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2313 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2314 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2315 * @param numfields number of string-type member in the data profile structure
2316 * @param ... the variadic parameters are pointers to each string-type member
2317 **/
2318template <typename T>
2319void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2320 int numfields, ...) {
2321 va_list args;
2322 va_start(args, numfields);
2323
2324 // Iterate through each string-type field that need to be free.
2325 for (int i = 0; i < numfields; i++) {
2326 // Iterate through each data profile and free that specific string-type field.
2327 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2328 char *T::*ptr = va_arg(args, char *T::*);
2329 for (int j = 0; j < numProfiles; j++) {
2330 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2331 }
2332 }
2333
2334 va_end(args);
2335
2336#ifdef MEMSET_FREED
2337 memset(dataProfiles, 0, numProfiles * sizeof(T));
2338 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2339#endif
2340 free(dataProfiles);
2341 free(dataProfilePtrs);
2342}
2343
2344Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2345 bool isRoaming) {
2346#if VDBG
2347 RLOGD("setDataProfile: serial %d", serial);
2348#endif
2349 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2350 if (pRI == NULL) {
2351 return Void();
2352 }
2353
2354 size_t num = profiles.size();
2355 bool success = false;
2356
2357 if (s_vendorFunctions->version <= 14) {
2358
2359 RIL_DataProfileInfo *dataProfiles =
2360 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2361
2362 if (dataProfiles == NULL) {
2363 RLOGE("Memory allocation failed for request %s",
2364 requestToString(pRI->pCI->requestNumber));
2365 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2366 return Void();
2367 }
2368
2369 RIL_DataProfileInfo **dataProfilePtrs =
2370 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2371 if (dataProfilePtrs == NULL) {
2372 RLOGE("Memory allocation failed for request %s",
2373 requestToString(pRI->pCI->requestNumber));
2374 free(dataProfiles);
2375 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2376 return Void();
2377 }
2378
2379 for (size_t i = 0; i < num; i++) {
2380 dataProfilePtrs[i] = &dataProfiles[i];
2381
2382 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2383
2384 const hidl_string &protocol =
2385 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2386
2387 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2388 success = false;
2389 }
2390
2391 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2392 success = false;
2393 }
2394 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2395 pRI)) {
2396 success = false;
2397 }
2398
2399 if (!success) {
2400 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2401 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2402 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2403 return Void();
2404 }
2405
2406 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2407 dataProfiles[i].authType = (int) profiles[i].authType;
2408 dataProfiles[i].type = (int) profiles[i].type;
2409 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2410 dataProfiles[i].maxConns = profiles[i].maxConns;
2411 dataProfiles[i].waitTime = profiles[i].waitTime;
2412 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2413 }
2414
2415 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2416 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2417
2418 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2419 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2420 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2421 } else {
2422 RIL_DataProfileInfo_v15 *dataProfiles =
2423 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2424
2425 if (dataProfiles == NULL) {
2426 RLOGE("Memory allocation failed for request %s",
2427 requestToString(pRI->pCI->requestNumber));
2428 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2429 return Void();
2430 }
2431
2432 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2433 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2434 if (dataProfilePtrs == NULL) {
2435 RLOGE("Memory allocation failed for request %s",
2436 requestToString(pRI->pCI->requestNumber));
2437 free(dataProfiles);
2438 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2439 return Void();
2440 }
2441
2442 for (size_t i = 0; i < num; i++) {
2443 dataProfilePtrs[i] = &dataProfiles[i];
2444
2445 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2446 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2447 pRI)) {
2448 success = false;
2449 }
2450 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2451 profiles[i].roamingProtocol, pRI)) {
2452 success = false;
2453 }
2454 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2455 success = false;
2456 }
2457 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2458 pRI)) {
2459 success = false;
2460 }
2461
2462 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2463 profiles[i].mvnoMatchData, pRI)) {
2464 success = false;
2465 }
2466
2467 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2468 dataProfiles[i].mvnoType)) {
2469 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2470 success = false;
2471 }
2472
2473 if (!success) {
2474 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2475 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2476 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2477 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2478 return Void();
2479 }
2480
2481 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2482 dataProfiles[i].authType = (int) profiles[i].authType;
2483 dataProfiles[i].type = (int) profiles[i].type;
2484 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2485 dataProfiles[i].maxConns = profiles[i].maxConns;
2486 dataProfiles[i].waitTime = profiles[i].waitTime;
2487 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2488 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2489 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2490 dataProfiles[i].mtu = profiles[i].mtu;
2491 }
2492
2493 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2494 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
2495
2496 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2497 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2498 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2499 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2500 }
2501
2502 return Void();
2503}
2504
2505Return<void> RadioImpl::requestShutdown(int32_t serial) {
2506#if VDBG
2507 RLOGD("requestShutdown: serial %d", serial);
2508#endif
2509 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2510 return Void();
2511}
2512
2513Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2514#if VDBG
2515 RLOGD("getRadioCapability: serial %d", serial);
2516#endif
2517 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2518 return Void();
2519}
2520
2521Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2522#if VDBG
2523 RLOGD("setRadioCapability: serial %d", serial);
2524#endif
2525 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2526 if (pRI == NULL) {
2527 return Void();
2528 }
2529
2530 RIL_RadioCapability rilRc = {};
2531
2532 // TODO : set rilRc.version using HIDL version ?
2533 rilRc.session = rc.session;
2534 rilRc.phase = (int) rc.phase;
2535 rilRc.rat = (int) rc.raf;
2536 rilRc.status = (int) rc.status;
2537 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2538
2539 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
2540
2541 return Void();
2542}
2543
2544Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2545#if VDBG
2546 RLOGD("startLceService: serial %d", serial);
2547#endif
2548 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2549 BOOL_TO_INT(pullMode));
2550 return Void();
2551}
2552
2553Return<void> RadioImpl::stopLceService(int32_t serial) {
2554#if VDBG
2555 RLOGD("stopLceService: serial %d", serial);
2556#endif
2557 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2558 return Void();
2559}
2560
2561Return<void> RadioImpl::pullLceData(int32_t serial) {
2562#if VDBG
2563 RLOGD("pullLceData: serial %d", serial);
2564#endif
2565 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2566 return Void();
2567}
2568
2569Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2570#if VDBG
2571 RLOGD("getModemActivityInfo: serial %d", serial);
2572#endif
2573 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2574 return Void();
2575}
2576
2577Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2578 const CarrierRestrictions& carriers) {
2579#if VDBG
2580 RLOGD("setAllowedCarriers: serial %d", serial);
2581#endif
2582 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2583 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2584 if (pRI == NULL) {
2585 return Void();
2586 }
2587
2588 RIL_CarrierRestrictions cr = {};
2589 RIL_Carrier *allowedCarriers = NULL;
2590 RIL_Carrier *excludedCarriers = NULL;
2591
2592 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2593 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2594 if (allowedCarriers == NULL) {
2595 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2596 requestToString(pRI->pCI->requestNumber));
2597 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2598 return Void();
2599 }
2600 cr.allowed_carriers = allowedCarriers;
2601
2602 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2603 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2604 if (excludedCarriers == NULL) {
2605 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2606 requestToString(pRI->pCI->requestNumber));
2607 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2608#ifdef MEMSET_FREED
2609 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2610#endif
2611 free(allowedCarriers);
2612 return Void();
2613 }
2614 cr.excluded_carriers = excludedCarriers;
2615
2616 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2617 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2618 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2619 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2620 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2621 }
2622
2623 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2624 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2625 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2626 excludedCarriers[i].match_type =
2627 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2628 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2629 }
2630
2631 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
2632
2633#ifdef MEMSET_FREED
2634 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2635 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2636#endif
2637 free(allowedCarriers);
2638 free(excludedCarriers);
2639 return Void();
2640}
2641
2642Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2643#if VDBG
2644 RLOGD("getAllowedCarriers: serial %d", serial);
2645#endif
2646 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2647 return Void();
2648}
2649
2650Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2651 bool state) {
2652#if VDBG
2653 RLOGD("sendDeviceState: serial %d", serial);
2654#endif
2655 if (s_vendorFunctions->version < 15) {
2656 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2657 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2658 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2659 } else {
2660 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2661 RIL_REQUEST_SEND_DEVICE_STATE);
2662 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2663 }
2664 return Void();
2665 }
2666 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2667 BOOL_TO_INT(state));
2668 return Void();
2669}
2670
2671Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2672#if VDBG
2673 RLOGD("setIndicationFilter: serial %d", serial);
2674#endif
2675 if (s_vendorFunctions->version < 15) {
2676 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2677 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2678 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2679 return Void();
2680 }
2681 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2682 return Void();
2683}
2684
2685Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2686#if VDBG
2687 RLOGD("setSimCardPower: serial %d", serial);
2688#endif
2689 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2690 return Void();
2691}
2692
2693Return<void> RadioImpl::responseAcknowledgement() {
2694 android::releaseWakeLock();
2695 return Void();
2696}
2697
2698Return<void> OemHookImpl::setResponseFunctions(
2699 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2700 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2701#if VDBG
2702 RLOGD("OemHookImpl::setResponseFunctions");
2703#endif
2704
2705 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2706 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2707 assert(ret == 0);
2708
2709 mOemHookResponse = oemHookResponseParam;
2710 mOemHookIndication = oemHookIndicationParam;
2711 mCounterOemHook[mSlotId]++;
2712
2713 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2714 assert(ret == 0);
2715
2716 return Void();
2717}
2718
2719Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2720#if VDBG
2721 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2722#endif
2723 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2724 return Void();
2725}
2726
2727Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2728 const hidl_vec<hidl_string>& data) {
2729#if VDBG
2730 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2731#endif
2732 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2733 return Void();
2734}
2735
2736/***************************************************************************************************
2737 * RESPONSE FUNCTIONS
2738 * Functions above are used for requests going from framework to vendor code. The ones below are
2739 * responses for those requests coming back from the vendor code.
2740 **************************************************************************************************/
2741
2742void radio::acknowledgeRequest(int slotId, int serial) {
2743 if (radioService[slotId]->mRadioResponse != NULL) {
2744 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2745 radioService[slotId]->checkReturnStatus(retStatus);
2746 } else {
2747 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2748 }
2749}
2750
2751void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2752 RIL_Errno e) {
2753 responseInfo.serial = serial;
2754 switch (responseType) {
2755 case RESPONSE_SOLICITED:
2756 responseInfo.type = RadioResponseType::SOLICITED;
2757 break;
2758 case RESPONSE_SOLICITED_ACK_EXP:
2759 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2760 break;
2761 }
2762 responseInfo.error = (RadioError) e;
2763}
2764
2765int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2766 void *response, size_t responseLen) {
2767 populateResponseInfo(responseInfo, serial, responseType, e);
2768 int ret = -1;
2769
2770 if (response == NULL && responseLen == 0) {
2771 // Earlier RILs did not send a response for some cases although the interface
2772 // expected an integer as response. Do not return error if response is empty. Instead
2773 // Return -1 in those cases to maintain backward compatibility.
2774 } else if (response == NULL || responseLen != sizeof(int)) {
2775 RLOGE("responseIntOrEmpty: Invalid response");
2776 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2777 } else {
2778 int *p_int = (int *) response;
2779 ret = p_int[0];
2780 }
2781 return ret;
2782}
2783
2784int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2785 void *response, size_t responseLen) {
2786 populateResponseInfo(responseInfo, serial, responseType, e);
2787 int ret = -1;
2788
2789 if (response == NULL || responseLen != sizeof(int)) {
2790 RLOGE("responseInt: Invalid response");
2791 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2792 } else {
2793 int *p_int = (int *) response;
2794 ret = p_int[0];
2795 }
2796 return ret;
2797}
2798
2799int radio::getIccCardStatusResponse(int slotId,
2800 int responseType, int serial, RIL_Errno e,
2801 void *response, size_t responseLen) {
2802 if (radioService[slotId]->mRadioResponse != NULL) {
2803 RadioResponseInfo responseInfo = {};
2804 populateResponseInfo(responseInfo, serial, responseType, e);
2805 CardStatus cardStatus = {};
2806 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2807 RLOGE("getIccCardStatusResponse: Invalid response");
2808 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2809 } else {
2810 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2811 cardStatus.cardState = (CardState) p_cur->card_state;
2812 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2813 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2814 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2815 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2816
2817 RIL_AppStatus *rilAppStatus = p_cur->applications;
2818 cardStatus.applications.resize(p_cur->num_applications);
2819 AppStatus *appStatus = cardStatus.applications.data();
2820#if VDBG
2821 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2822#endif
2823 for (int i = 0; i < p_cur->num_applications; i++) {
2824 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2825 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2826 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2827 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2828 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2829 rilAppStatus[i].app_label_ptr);
2830 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2831 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2832 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2833 }
2834 }
2835
2836 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2837 getIccCardStatusResponse(responseInfo, cardStatus);
2838 radioService[slotId]->checkReturnStatus(retStatus);
2839 } else {
2840 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2841 }
2842
2843 return 0;
2844}
2845
2846int radio::supplyIccPinForAppResponse(int slotId,
2847 int responseType, int serial, RIL_Errno e,
2848 void *response, size_t responseLen) {
2849#if VDBG
2850 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
2851#endif
2852
2853 if (radioService[slotId]->mRadioResponse != NULL) {
2854 RadioResponseInfo responseInfo = {};
2855 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2856 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2857 supplyIccPinForAppResponse(responseInfo, ret);
2858 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
2859 radioService[slotId]->checkReturnStatus(retStatus);
2860 } else {
2861 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2862 slotId);
2863 }
2864
2865 return 0;
2866}
2867
2868int radio::supplyIccPukForAppResponse(int slotId,
2869 int responseType, int serial, RIL_Errno e,
2870 void *response, size_t responseLen) {
2871#if VDBG
2872 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
2873#endif
2874
2875 if (radioService[slotId]->mRadioResponse != NULL) {
2876 RadioResponseInfo responseInfo = {};
2877 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2878 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2879 responseInfo, ret);
2880 radioService[slotId]->checkReturnStatus(retStatus);
2881 } else {
2882 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2883 slotId);
2884 }
2885
2886 return 0;
2887}
2888
2889int radio::supplyIccPin2ForAppResponse(int slotId,
2890 int responseType, int serial, RIL_Errno e,
2891 void *response, size_t responseLen) {
2892#if VDBG
2893 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
2894#endif
2895
2896 if (radioService[slotId]->mRadioResponse != NULL) {
2897 RadioResponseInfo responseInfo = {};
2898 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2899 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2900 supplyIccPin2ForAppResponse(responseInfo, ret);
2901 radioService[slotId]->checkReturnStatus(retStatus);
2902 } else {
2903 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2904 slotId);
2905 }
2906
2907 return 0;
2908}
2909
2910int radio::supplyIccPuk2ForAppResponse(int slotId,
2911 int responseType, int serial, RIL_Errno e,
2912 void *response, size_t responseLen) {
2913#if VDBG
2914 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
2915#endif
2916
2917 if (radioService[slotId]->mRadioResponse != NULL) {
2918 RadioResponseInfo responseInfo = {};
2919 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2920 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2921 supplyIccPuk2ForAppResponse(responseInfo, ret);
2922 radioService[slotId]->checkReturnStatus(retStatus);
2923 } else {
2924 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2925 slotId);
2926 }
2927
2928 return 0;
2929}
2930
2931int radio::changeIccPinForAppResponse(int slotId,
2932 int responseType, int serial, RIL_Errno e,
2933 void *response, size_t responseLen) {
2934#if VDBG
2935 RLOGD("changeIccPinForAppResponse: serial %d", serial);
2936#endif
2937
2938 if (radioService[slotId]->mRadioResponse != NULL) {
2939 RadioResponseInfo responseInfo = {};
2940 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2941 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2942 changeIccPinForAppResponse(responseInfo, ret);
2943 radioService[slotId]->checkReturnStatus(retStatus);
2944 } else {
2945 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2946 slotId);
2947 }
2948
2949 return 0;
2950}
2951
2952int radio::changeIccPin2ForAppResponse(int slotId,
2953 int responseType, int serial, RIL_Errno e,
2954 void *response, size_t responseLen) {
2955#if VDBG
2956 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
2957#endif
2958
2959 if (radioService[slotId]->mRadioResponse != NULL) {
2960 RadioResponseInfo responseInfo = {};
2961 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2962 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2963 changeIccPin2ForAppResponse(responseInfo, ret);
2964 radioService[slotId]->checkReturnStatus(retStatus);
2965 } else {
2966 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2967 slotId);
2968 }
2969
2970 return 0;
2971}
2972
2973int radio::supplyNetworkDepersonalizationResponse(int slotId,
2974 int responseType, int serial, RIL_Errno e,
2975 void *response, size_t responseLen) {
2976#if VDBG
2977 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
2978#endif
2979
2980 if (radioService[slotId]->mRadioResponse != NULL) {
2981 RadioResponseInfo responseInfo = {};
2982 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2983 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2984 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2985 radioService[slotId]->checkReturnStatus(retStatus);
2986 } else {
2987 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
2988 "NULL", slotId);
2989 }
2990
2991 return 0;
2992}
2993
2994int radio::getCurrentCallsResponse(int slotId,
2995 int responseType, int serial, RIL_Errno e,
2996 void *response, size_t responseLen) {
2997#if VDBG
2998 RLOGD("getCurrentCallsResponse: serial %d", serial);
2999#endif
3000
3001 if (radioService[slotId]->mRadioResponse != NULL) {
3002 RadioResponseInfo responseInfo = {};
3003 populateResponseInfo(responseInfo, serial, responseType, e);
3004
3005 hidl_vec<Call> calls;
3006 if ((response == NULL && responseLen != 0)
3007 || (responseLen % sizeof(RIL_Call *)) != 0) {
3008 RLOGE("getCurrentCallsResponse: Invalid response");
3009 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3010 } else {
3011 int num = responseLen / sizeof(RIL_Call *);
3012 calls.resize(num);
3013
3014 for (int i = 0 ; i < num ; i++) {
3015 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3016 /* each call info */
3017 calls[i].state = (CallState) p_cur->state;
3018 calls[i].index = p_cur->index;
3019 calls[i].toa = p_cur->toa;
3020 calls[i].isMpty = p_cur->isMpty;
3021 calls[i].isMT = p_cur->isMT;
3022 calls[i].als = p_cur->als;
3023 calls[i].isVoice = p_cur->isVoice;
3024 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3025 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3026 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3027 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3028 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3029 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3030 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3031 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3032 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3033 // convert uusInfo->uusData to a null-terminated string
3034 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3035 calls[i].uusInfo[0].uusData = nullTermStr;
3036 free(nullTermStr);
3037 }
3038 }
3039 }
3040
3041 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3042 getCurrentCallsResponse(responseInfo, calls);
3043 radioService[slotId]->checkReturnStatus(retStatus);
3044 } else {
3045 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3046 }
3047
3048 return 0;
3049}
3050
3051int radio::dialResponse(int slotId,
3052 int responseType, int serial, RIL_Errno e, void *response,
3053 size_t responseLen) {
3054#if VDBG
3055 RLOGD("dialResponse: serial %d", serial);
3056#endif
3057
3058 if (radioService[slotId]->mRadioResponse != NULL) {
3059 RadioResponseInfo responseInfo = {};
3060 populateResponseInfo(responseInfo, serial, responseType, e);
3061 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3062 radioService[slotId]->checkReturnStatus(retStatus);
3063 } else {
3064 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3065 }
3066
3067 return 0;
3068}
3069
3070int radio::getIMSIForAppResponse(int slotId,
3071 int responseType, int serial, RIL_Errno e, void *response,
3072 size_t responseLen) {
3073#if VDBG
3074 RLOGD("getIMSIForAppResponse: serial %d", serial);
3075#endif
3076
3077 if (radioService[slotId]->mRadioResponse != NULL) {
3078 RadioResponseInfo responseInfo = {};
3079 populateResponseInfo(responseInfo, serial, responseType, e);
3080 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3081 responseInfo, convertCharPtrToHidlString((char *) response));
3082 radioService[slotId]->checkReturnStatus(retStatus);
3083 } else {
3084 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3085 slotId);
3086 }
3087
3088 return 0;
3089}
3090
3091int radio::hangupConnectionResponse(int slotId,
3092 int responseType, int serial, RIL_Errno e,
3093 void *response, size_t responseLen) {
3094#if VDBG
3095 RLOGD("hangupConnectionResponse: serial %d", serial);
3096#endif
3097
3098 if (radioService[slotId]->mRadioResponse != NULL) {
3099 RadioResponseInfo responseInfo = {};
3100 populateResponseInfo(responseInfo, serial, responseType, e);
3101 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3102 responseInfo);
3103 radioService[slotId]->checkReturnStatus(retStatus);
3104 } else {
3105 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3106 slotId);
3107 }
3108
3109 return 0;
3110}
3111
3112int radio::hangupWaitingOrBackgroundResponse(int slotId,
3113 int responseType, int serial, RIL_Errno e,
3114 void *response, size_t responseLen) {
3115#if VDBG
3116 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3117#endif
3118
3119 if (radioService[slotId]->mRadioResponse != NULL) {
3120 RadioResponseInfo responseInfo = {};
3121 populateResponseInfo(responseInfo, serial, responseType, e);
3122 Return<void> retStatus =
3123 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3124 responseInfo);
3125 radioService[slotId]->checkReturnStatus(retStatus);
3126 } else {
3127 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3128 slotId);
3129 }
3130
3131 return 0;
3132}
3133
3134int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3135 RIL_Errno e, void *response,
3136 size_t responseLen) {
3137#if VDBG
3138 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3139#endif
3140
3141 if (radioService[slotId]->mRadioResponse != NULL) {
3142 RadioResponseInfo responseInfo = {};
3143 populateResponseInfo(responseInfo, serial, responseType, e);
3144 Return<void> retStatus =
3145 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3146 responseInfo);
3147 radioService[slotId]->checkReturnStatus(retStatus);
3148 } else {
3149 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3150 slotId);
3151 }
3152
3153 return 0;
3154}
3155
3156int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3157 RIL_Errno e, void *response,
3158 size_t responseLen) {
3159#if VDBG
3160 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3161#endif
3162
3163 if (radioService[slotId]->mRadioResponse != NULL) {
3164 RadioResponseInfo responseInfo = {};
3165 populateResponseInfo(responseInfo, serial, responseType, e);
3166 Return<void> retStatus =
3167 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3168 responseInfo);
3169 radioService[slotId]->checkReturnStatus(retStatus);
3170 } else {
3171 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3172 "== NULL", slotId);
3173 }
3174
3175 return 0;
3176}
3177
3178int radio::conferenceResponse(int slotId, int responseType,
3179 int serial, RIL_Errno e, void *response, size_t responseLen) {
3180#if VDBG
3181 RLOGD("conferenceResponse: serial %d", serial);
3182#endif
3183
3184 if (radioService[slotId]->mRadioResponse != NULL) {
3185 RadioResponseInfo responseInfo = {};
3186 populateResponseInfo(responseInfo, serial, responseType, e);
3187 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3188 responseInfo);
3189 radioService[slotId]->checkReturnStatus(retStatus);
3190 } else {
3191 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3192 slotId);
3193 }
3194
3195 return 0;
3196}
3197
3198int radio::rejectCallResponse(int slotId, int responseType,
3199 int serial, RIL_Errno e, void *response, size_t responseLen) {
3200#if VDBG
3201 RLOGD("rejectCallResponse: serial %d", serial);
3202#endif
3203
3204 if (radioService[slotId]->mRadioResponse != NULL) {
3205 RadioResponseInfo responseInfo = {};
3206 populateResponseInfo(responseInfo, serial, responseType, e);
3207 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3208 responseInfo);
3209 radioService[slotId]->checkReturnStatus(retStatus);
3210 } else {
3211 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3212 slotId);
3213 }
3214
3215 return 0;
3216}
3217
3218int radio::getLastCallFailCauseResponse(int slotId,
3219 int responseType, int serial, RIL_Errno e, void *response,
3220 size_t responseLen) {
3221#if VDBG
3222 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3223#endif
3224
3225 if (radioService[slotId]->mRadioResponse != NULL) {
3226 RadioResponseInfo responseInfo = {};
3227 populateResponseInfo(responseInfo, serial, responseType, e);
3228
3229 LastCallFailCauseInfo info = {};
3230 info.vendorCause = hidl_string();
3231 if (response == NULL) {
3232 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3233 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3234 } else if (responseLen == sizeof(int)) {
3235 int *pInt = (int *) response;
3236 info.causeCode = (LastCallFailCause) pInt[0];
3237 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3238 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3239 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3240 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3241 } else {
3242 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3243 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3244 }
3245
3246 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3247 responseInfo, info);
3248 radioService[slotId]->checkReturnStatus(retStatus);
3249 } else {
3250 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3251 slotId);
3252 }
3253
3254 return 0;
3255}
3256
3257int radio::getSignalStrengthResponse(int slotId,
3258 int responseType, int serial, RIL_Errno e,
3259 void *response, size_t responseLen) {
3260#if VDBG
3261 RLOGD("getSignalStrengthResponse: serial %d", serial);
3262#endif
3263
3264 if (radioService[slotId]->mRadioResponse != NULL) {
3265 RadioResponseInfo responseInfo = {};
3266 populateResponseInfo(responseInfo, serial, responseType, e);
3267 SignalStrength signalStrength = {};
3268 if (response == NULL || (responseLen != sizeof(RIL_SignalStrength_v10)
Martin Bouchet6e9a4972017-09-23 04:55:52 -03003269 && responseLen != sizeof(RIL_SignalStrength_v8)
3270 && responseLen != sizeof(RIL_SignalStrength_v6)
3271 && responseLen != sizeof(RIL_SignalStrength_v5))) {
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03003272 RLOGE("getSignalStrengthResponse: Invalid response");
3273 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3274 } else {
3275 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3276 }
3277
3278 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3279 responseInfo, signalStrength);
3280 radioService[slotId]->checkReturnStatus(retStatus);
3281 } else {
3282 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3283 slotId);
3284 }
3285
3286 return 0;
3287}
3288
3289RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3290 if (rat == NULL) {
3291 return RIL_CELL_INFO_TYPE_NONE;
3292 }
3293
3294 int radioTech = atoi(rat);
3295
3296 switch(radioTech) {
3297
3298 case RADIO_TECH_GPRS:
3299 case RADIO_TECH_EDGE:
3300 case RADIO_TECH_GSM: {
3301 return RIL_CELL_INFO_TYPE_GSM;
3302 }
3303
3304 case RADIO_TECH_UMTS:
3305 case RADIO_TECH_HSDPA:
3306 case RADIO_TECH_HSUPA:
3307 case RADIO_TECH_HSPA:
3308 case RADIO_TECH_HSPAP: {
3309 return RIL_CELL_INFO_TYPE_WCDMA;
3310 }
3311
3312 case RADIO_TECH_IS95A:
3313 case RADIO_TECH_IS95B:
3314 case RADIO_TECH_1xRTT:
3315 case RADIO_TECH_EVDO_0:
3316 case RADIO_TECH_EVDO_A:
3317 case RADIO_TECH_EVDO_B:
3318 case RADIO_TECH_EHRPD: {
3319 return RIL_CELL_INFO_TYPE_CDMA;
3320 }
3321
3322 case RADIO_TECH_LTE:
3323 case RADIO_TECH_LTE_CA: {
3324 return RIL_CELL_INFO_TYPE_LTE;
3325 }
3326
3327 case RADIO_TECH_TD_SCDMA: {
3328 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3329 }
3330
3331 default: {
3332 break;
3333 }
3334 }
3335
3336 return RIL_CELL_INFO_TYPE_NONE;
3337
3338}
3339
3340void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3341
3342 cellIdentity.cellIdentityGsm.resize(0);
3343 cellIdentity.cellIdentityWcdma.resize(0);
3344 cellIdentity.cellIdentityCdma.resize(0);
3345 cellIdentity.cellIdentityTdscdma.resize(0);
3346 cellIdentity.cellIdentityLte.resize(0);
3347 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3348 switch(rilCellIdentity.cellInfoType) {
3349
3350 case RIL_CELL_INFO_TYPE_GSM: {
3351 cellIdentity.cellIdentityGsm.resize(1);
3352 cellIdentity.cellIdentityGsm[0].mcc =
3353 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3354 cellIdentity.cellIdentityGsm[0].mnc =
3355 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3356 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3357 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3358 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3359 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3360 break;
3361 }
3362
3363 case RIL_CELL_INFO_TYPE_WCDMA: {
3364 cellIdentity.cellIdentityWcdma.resize(1);
3365 cellIdentity.cellIdentityWcdma[0].mcc =
3366 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3367 cellIdentity.cellIdentityWcdma[0].mnc =
3368 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3369 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3370 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3371 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3372 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3373 break;
3374 }
3375
3376 case RIL_CELL_INFO_TYPE_CDMA: {
3377 cellIdentity.cellIdentityCdma.resize(1);
3378 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3379 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3380 cellIdentity.cellIdentityCdma[0].baseStationId =
3381 rilCellIdentity.cellIdentityCdma.basestationId;
3382 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3383 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3384 break;
3385 }
3386
3387 case RIL_CELL_INFO_TYPE_LTE: {
3388 cellIdentity.cellIdentityLte.resize(1);
3389 cellIdentity.cellIdentityLte[0].mcc =
3390 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3391 cellIdentity.cellIdentityLte[0].mnc =
3392 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3393 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3394 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3395 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3396 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3397 break;
3398 }
3399
3400 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3401 cellIdentity.cellIdentityTdscdma.resize(1);
3402 cellIdentity.cellIdentityTdscdma[0].mcc =
3403 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3404 cellIdentity.cellIdentityTdscdma[0].mnc =
3405 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3406 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3407 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3408 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3409 break;
3410 }
3411
3412 default: {
3413 break;
3414 }
3415 }
3416}
3417
3418int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3419 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3420 return atoi(response[index]);
3421 }
3422
3423 return -1;
3424}
3425
3426int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
3427 const int hexBase = 16;
3428 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3429 return strtol(response[index], NULL, hexBase);
3430 }
3431
3432 return -1;
3433}
3434
3435/* Fill Cell Identity info from Voice Registration State Response.
3436 * This fucntion is applicable only for RIL Version < 15.
3437 * Response is a "char **".
3438 * First and Second entries are in hex string format
3439 * and rest are integers represented in ascii format. */
3440void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3441 int numStrings, char** response) {
3442
3443 RIL_CellIdentity_v16 rilCellIdentity;
3444 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3445
3446 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3447 switch(rilCellIdentity.cellInfoType) {
3448
3449 case RIL_CELL_INFO_TYPE_GSM: {
3450 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3451 rilCellIdentity.cellIdentityGsm.lac =
3452 convertResponseHexStringEntryToInt(response, 1, numStrings);
3453
3454 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3455 rilCellIdentity.cellIdentityGsm.cid =
3456 convertResponseHexStringEntryToInt(response, 2, numStrings);
3457 break;
3458 }
3459
3460 case RIL_CELL_INFO_TYPE_WCDMA: {
3461 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3462 rilCellIdentity.cellIdentityWcdma.lac =
3463 convertResponseHexStringEntryToInt(response, 1, numStrings);
3464
3465 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3466 rilCellIdentity.cellIdentityWcdma.cid =
3467 convertResponseHexStringEntryToInt(response, 2, numStrings);
3468 rilCellIdentity.cellIdentityWcdma.psc =
3469 convertResponseStringEntryToInt(response, 14, numStrings);
3470 break;
3471 }
3472
3473 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3474 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3475 rilCellIdentity.cellIdentityTdscdma.lac =
3476 convertResponseHexStringEntryToInt(response, 1, numStrings);
3477
3478 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3479 rilCellIdentity.cellIdentityTdscdma.cid =
3480 convertResponseHexStringEntryToInt(response, 2, numStrings);
3481 break;
3482 }
3483
3484 case RIL_CELL_INFO_TYPE_CDMA:{
3485 rilCellIdentity.cellIdentityCdma.basestationId =
3486 convertResponseStringEntryToInt(response, 4, numStrings);
3487 rilCellIdentity.cellIdentityCdma.longitude =
3488 convertResponseStringEntryToInt(response, 5, numStrings);
3489 rilCellIdentity.cellIdentityCdma.latitude =
3490 convertResponseStringEntryToInt(response, 6, numStrings);
3491 rilCellIdentity.cellIdentityCdma.systemId =
3492 convertResponseStringEntryToInt(response, 8, numStrings);
3493 rilCellIdentity.cellIdentityCdma.networkId =
3494 convertResponseStringEntryToInt(response, 9, numStrings);
3495 break;
3496 }
3497
3498 case RIL_CELL_INFO_TYPE_LTE:{
3499 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
3500 rilCellIdentity.cellIdentityLte.tac =
3501 convertResponseHexStringEntryToInt(response, 1, numStrings);
3502
3503 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3504 rilCellIdentity.cellIdentityLte.ci =
3505 convertResponseHexStringEntryToInt(response, 2, numStrings);
3506 break;
3507 }
3508
3509 default: {
3510 break;
3511 }
3512 }
3513
3514 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3515}
3516
3517/* Fill Cell Identity info from Data Registration State Response.
3518 * This fucntion is applicable only for RIL Version < 15.
3519 * Response is a "char **".
3520 * First and Second entries are in hex string format
3521 * and rest are integers represented in ascii format. */
3522void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3523 int numStrings, char** response) {
3524
3525 RIL_CellIdentity_v16 rilCellIdentity;
3526 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3527
3528 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3529 switch(rilCellIdentity.cellInfoType) {
3530 case RIL_CELL_INFO_TYPE_GSM: {
3531 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3532 rilCellIdentity.cellIdentityGsm.lac =
3533 convertResponseHexStringEntryToInt(response, 1, numStrings);
3534
3535 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3536 rilCellIdentity.cellIdentityGsm.cid =
3537 convertResponseHexStringEntryToInt(response, 2, numStrings);
3538 break;
3539 }
3540 case RIL_CELL_INFO_TYPE_WCDMA: {
3541 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3542 rilCellIdentity.cellIdentityWcdma.lac =
3543 convertResponseHexStringEntryToInt(response, 1, numStrings);
3544
3545 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3546 rilCellIdentity.cellIdentityWcdma.cid =
3547 convertResponseHexStringEntryToInt(response, 2, numStrings);
3548 break;
3549 }
3550 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3551 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3552 rilCellIdentity.cellIdentityTdscdma.lac =
3553 convertResponseHexStringEntryToInt(response, 1, numStrings);
3554
3555 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3556 rilCellIdentity.cellIdentityTdscdma.cid =
3557 convertResponseHexStringEntryToInt(response, 2, numStrings);
3558 break;
3559 }
3560 case RIL_CELL_INFO_TYPE_LTE: {
3561 rilCellIdentity.cellIdentityLte.tac =
3562 convertResponseStringEntryToInt(response, 6, numStrings);
3563 rilCellIdentity.cellIdentityLte.pci =
3564 convertResponseStringEntryToInt(response, 7, numStrings);
3565 rilCellIdentity.cellIdentityLte.ci =
3566 convertResponseStringEntryToInt(response, 8, numStrings);
3567 break;
3568 }
3569 default: {
3570 break;
3571 }
3572 }
3573
3574 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3575}
3576
3577int radio::getVoiceRegistrationStateResponse(int slotId,
3578 int responseType, int serial, RIL_Errno e,
3579 void *response, size_t responseLen) {
3580#if VDBG
3581 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3582#endif
3583
3584 if (radioService[slotId]->mRadioResponse != NULL) {
3585 RadioResponseInfo responseInfo = {};
3586 populateResponseInfo(responseInfo, serial, responseType, e);
3587
3588 VoiceRegStateResult voiceRegResponse = {};
3589 int numStrings = responseLen / sizeof(char *);
3590 if (response == NULL) {
3591 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3592 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3593 } else if (s_vendorFunctions->version <= 14) {
3594 if (numStrings != 15) {
3595 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3596 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3597 } else {
3598 char **resp = (char **) response;
3599 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3600 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3601 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3602 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3603 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3604 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3605 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3606 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3607 numStrings, resp);
3608 }
3609 } else {
3610 RIL_VoiceRegistrationStateResponse *voiceRegState =
3611 (RIL_VoiceRegistrationStateResponse *)response;
3612
3613 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3614 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3615 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3616 } else {
3617 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3618 voiceRegResponse.rat = voiceRegState->rat;;
3619 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3620 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3621 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3622 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3623 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3624 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3625 voiceRegState->cellIdentity);
3626 }
3627 }
3628
3629 Return<void> retStatus =
3630 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3631 responseInfo, voiceRegResponse);
3632 radioService[slotId]->checkReturnStatus(retStatus);
3633 } else {
3634 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3635 slotId);
3636 }
3637
3638 return 0;
3639}
3640
3641int radio::getDataRegistrationStateResponse(int slotId,
3642 int responseType, int serial, RIL_Errno e,
3643 void *response, size_t responseLen) {
3644#if VDBG
3645 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3646#endif
3647
3648 if (radioService[slotId]->mRadioResponse != NULL) {
3649 RadioResponseInfo responseInfo = {};
3650 populateResponseInfo(responseInfo, serial, responseType, e);
3651 DataRegStateResult dataRegResponse = {};
3652 if (response == NULL) {
3653 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3654 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3655 } else if (s_vendorFunctions->version <= 14) {
3656 int numStrings = responseLen / sizeof(char *);
3657 if ((numStrings != 6) && (numStrings != 11)) {
3658 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3659 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3660 } else {
3661 char **resp = (char **) response;
3662 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3663 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3664 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3665 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3666 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3667 numStrings, resp);
3668 }
3669 } else {
3670 RIL_DataRegistrationStateResponse *dataRegState =
3671 (RIL_DataRegistrationStateResponse *)response;
3672
3673 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3674 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3675 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3676 } else {
3677 dataRegResponse.regState = (RegState) dataRegState->regState;
3678 dataRegResponse.rat = dataRegState->rat;;
3679 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3680 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3681 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3682 }
3683 }
3684
3685 Return<void> retStatus =
3686 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3687 dataRegResponse);
3688 radioService[slotId]->checkReturnStatus(retStatus);
3689 } else {
3690 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3691 slotId);
3692 }
3693
3694 return 0;
3695}
3696
3697int radio::getOperatorResponse(int slotId,
3698 int responseType, int serial, RIL_Errno e, void *response,
3699 size_t responseLen) {
3700#if VDBG
3701 RLOGD("getOperatorResponse: serial %d", serial);
3702#endif
3703
3704 if (radioService[slotId]->mRadioResponse != NULL) {
3705 RadioResponseInfo responseInfo = {};
3706 populateResponseInfo(responseInfo, serial, responseType, e);
3707 hidl_string longName;
3708 hidl_string shortName;
3709 hidl_string numeric;
3710 int numStrings = responseLen / sizeof(char *);
3711 if (response == NULL || numStrings != 3) {
3712 RLOGE("getOperatorResponse Invalid response: NULL");
3713 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3714
3715 } else {
3716 char **resp = (char **) response;
3717 longName = convertCharPtrToHidlString(resp[0]);
3718 shortName = convertCharPtrToHidlString(resp[1]);
3719 numeric = convertCharPtrToHidlString(resp[2]);
3720 }
3721 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3722 responseInfo, longName, shortName, numeric);
3723 radioService[slotId]->checkReturnStatus(retStatus);
3724 } else {
3725 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3726 slotId);
3727 }
3728
3729 return 0;
3730}
3731
3732int radio::setRadioPowerResponse(int slotId,
3733 int responseType, int serial, RIL_Errno e, void *response,
3734 size_t responseLen) {
3735 RLOGD("setRadioPowerResponse: serial %d", serial);
3736
3737 if (radioService[slotId]->mRadioResponse != NULL) {
3738 RadioResponseInfo responseInfo = {};
3739 populateResponseInfo(responseInfo, serial, responseType, e);
3740 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3741 responseInfo);
3742 radioService[slotId]->checkReturnStatus(retStatus);
3743 } else {
3744 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3745 slotId);
3746 }
3747
3748 return 0;
3749}
3750
3751int radio::sendDtmfResponse(int slotId,
3752 int responseType, int serial, RIL_Errno e, void *response,
3753 size_t responseLen) {
3754#if VDBG
3755 RLOGD("sendDtmfResponse: serial %d", serial);
3756#endif
3757
3758 if (radioService[slotId]->mRadioResponse != NULL) {
3759 RadioResponseInfo responseInfo = {};
3760 populateResponseInfo(responseInfo, serial, responseType, e);
3761 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3762 responseInfo);
3763 radioService[slotId]->checkReturnStatus(retStatus);
3764 } else {
3765 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3766 slotId);
3767 }
3768
3769 return 0;
3770}
3771
3772SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3773 RIL_Errno e, void *response, size_t responseLen) {
3774 populateResponseInfo(responseInfo, serial, responseType, e);
3775 SendSmsResult result = {};
3776
3777 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3778 RLOGE("Invalid response: NULL");
3779 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3780 result.ackPDU = hidl_string();
3781 } else {
3782 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3783 result.messageRef = resp->messageRef;
3784 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3785 result.errorCode = resp->errorCode;
3786 }
3787 return result;
3788}
3789
3790int radio::sendSmsResponse(int slotId,
3791 int responseType, int serial, RIL_Errno e, void *response,
3792 size_t responseLen) {
3793#if VDBG
3794 RLOGD("sendSmsResponse: serial %d", serial);
3795#endif
3796
3797 if (radioService[slotId]->mRadioResponse != NULL) {
3798 RadioResponseInfo responseInfo = {};
3799 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3800 responseLen);
3801
3802 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3803 result);
3804 radioService[slotId]->checkReturnStatus(retStatus);
3805 } else {
3806 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3807 }
3808
3809 return 0;
3810}
3811
3812int radio::sendSMSExpectMoreResponse(int slotId,
3813 int responseType, int serial, RIL_Errno e, void *response,
3814 size_t responseLen) {
3815#if VDBG
3816 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3817#endif
3818
3819 if (radioService[slotId]->mRadioResponse != NULL) {
3820 RadioResponseInfo responseInfo = {};
3821 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3822 responseLen);
3823
3824 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3825 responseInfo, result);
3826 radioService[slotId]->checkReturnStatus(retStatus);
3827 } else {
3828 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3829 }
3830
3831 return 0;
3832}
3833
3834int radio::setupDataCallResponse(int slotId,
3835 int responseType, int serial, RIL_Errno e, void *response,
3836 size_t responseLen) {
3837#if VDBG
3838 RLOGD("setupDataCallResponse: serial %d", serial);
3839#endif
3840
3841 if (radioService[slotId]->mRadioResponse != NULL) {
3842 RadioResponseInfo responseInfo = {};
3843 populateResponseInfo(responseInfo, serial, responseType, e);
3844
3845 SetupDataCallResult result = {};
3846
3847 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11) != 0
3848 && responseLen % sizeof(RIL_Data_Call_Response_v9) != 0
3849 && responseLen % sizeof(RIL_Data_Call_Response_v6) != 0)) {
3850 if (response != NULL) {
3851 RLOGE("setupDataCallResponse: Invalid response");
3852 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3853 }
3854 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3855 result.type = hidl_string();
3856 result.ifname = hidl_string();
3857 result.addresses = hidl_string();
3858 result.dnses = hidl_string();
3859 result.gateways = hidl_string();
3860 result.pcscf = hidl_string();
3861 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v11)) == 0) {
3862 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3863 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v9)) == 0) {
3864 convertRilDataCallToHal((RIL_Data_Call_Response_v9 *) response, result);
3865 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v6)) == 0) {
3866 convertRilDataCallToHal((RIL_Data_Call_Response_v6 *) response, result);
3867 }
3868
3869 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3870 responseInfo, result);
3871 radioService[slotId]->checkReturnStatus(retStatus);
3872 } else {
3873 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3874 }
3875
3876 return 0;
3877}
3878
3879IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3880 RIL_Errno e, void *response, size_t responseLen) {
3881 populateResponseInfo(responseInfo, serial, responseType, e);
3882 IccIoResult result = {};
3883
3884 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3885 RLOGE("Invalid response: NULL");
3886 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3887 result.simResponse = hidl_string();
3888 } else {
3889 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3890 result.sw1 = resp->sw1;
3891 result.sw2 = resp->sw2;
3892 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3893 }
3894 return result;
3895}
3896
3897int radio::iccIOForAppResponse(int slotId,
3898 int responseType, int serial, RIL_Errno e, void *response,
3899 size_t responseLen) {
3900#if VDBG
3901 RLOGD("iccIOForAppResponse: serial %d", serial);
3902#endif
3903
3904 if (radioService[slotId]->mRadioResponse != NULL) {
3905 RadioResponseInfo responseInfo = {};
3906 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3907 responseLen);
3908
3909 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3910 responseInfo, result);
3911 radioService[slotId]->checkReturnStatus(retStatus);
3912 } else {
3913 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3914 }
3915
3916 return 0;
3917}
3918
3919int radio::sendUssdResponse(int slotId,
3920 int responseType, int serial, RIL_Errno e, void *response,
3921 size_t responseLen) {
3922#if VDBG
3923 RLOGD("sendUssdResponse: serial %d", serial);
3924#endif
3925
3926 if (radioService[slotId]->mRadioResponse != NULL) {
3927 RadioResponseInfo responseInfo = {};
3928 populateResponseInfo(responseInfo, serial, responseType, e);
3929 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3930 responseInfo);
3931 radioService[slotId]->checkReturnStatus(retStatus);
3932 } else {
3933 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3934 slotId);
3935 }
3936
3937 return 0;
3938}
3939
3940int radio::cancelPendingUssdResponse(int slotId,
3941 int responseType, int serial, RIL_Errno e, void *response,
3942 size_t responseLen) {
3943#if VDBG
3944 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3945#endif
3946
3947 if (radioService[slotId]->mRadioResponse != NULL) {
3948 RadioResponseInfo responseInfo = {};
3949 populateResponseInfo(responseInfo, serial, responseType, e);
3950 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3951 responseInfo);
3952 radioService[slotId]->checkReturnStatus(retStatus);
3953 } else {
3954 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3955 slotId);
3956 }
3957
3958 return 0;
3959}
3960
3961int radio::getClirResponse(int slotId,
3962 int responseType, int serial, RIL_Errno e, void *response,
3963 size_t responseLen) {
3964#if VDBG
3965 RLOGD("getClirResponse: serial %d", serial);
3966#endif
3967
3968 if (radioService[slotId]->mRadioResponse != NULL) {
3969 RadioResponseInfo responseInfo = {};
3970 populateResponseInfo(responseInfo, serial, responseType, e);
3971 int n = -1, m = -1;
3972 int numInts = responseLen / sizeof(int);
3973 if (response == NULL || numInts != 2) {
3974 RLOGE("getClirResponse Invalid response: NULL");
3975 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3976 } else {
3977 int *pInt = (int *) response;
3978 n = pInt[0];
3979 m = pInt[1];
3980 }
3981 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3982 n, m);
3983 radioService[slotId]->checkReturnStatus(retStatus);
3984 } else {
3985 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3986 }
3987
3988 return 0;
3989}
3990
3991int radio::setClirResponse(int slotId,
3992 int responseType, int serial, RIL_Errno e, void *response,
3993 size_t responseLen) {
3994#if VDBG
3995 RLOGD("setClirResponse: serial %d", serial);
3996#endif
3997
3998 if (radioService[slotId]->mRadioResponse != NULL) {
3999 RadioResponseInfo responseInfo = {};
4000 populateResponseInfo(responseInfo, serial, responseType, e);
4001 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
4002 responseInfo);
4003 radioService[slotId]->checkReturnStatus(retStatus);
4004 } else {
4005 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4006 }
4007
4008 return 0;
4009}
4010
4011int radio::getCallForwardStatusResponse(int slotId,
4012 int responseType, int serial, RIL_Errno e,
4013 void *response, size_t responseLen) {
4014#if VDBG
4015 RLOGD("getCallForwardStatusResponse: serial %d", serial);
4016#endif
4017
4018 if (radioService[slotId]->mRadioResponse != NULL) {
4019 RadioResponseInfo responseInfo = {};
4020 populateResponseInfo(responseInfo, serial, responseType, e);
4021 hidl_vec<CallForwardInfo> callForwardInfos;
4022
4023 if ((response == NULL && responseLen != 0)
4024 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4025 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4026 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4027 } else {
4028 int num = responseLen / sizeof(RIL_CallForwardInfo *);
4029 callForwardInfos.resize(num);
4030 for (int i = 0 ; i < num; i++) {
4031 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4032 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4033 callForwardInfos[i].reason = resp->reason;
4034 callForwardInfos[i].serviceClass = resp->serviceClass;
4035 callForwardInfos[i].toa = resp->toa;
4036 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4037 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4038 }
4039 }
4040
4041 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4042 responseInfo, callForwardInfos);
4043 radioService[slotId]->checkReturnStatus(retStatus);
4044 } else {
4045 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4046 slotId);
4047 }
4048
4049 return 0;
4050}
4051
4052int radio::setCallForwardResponse(int slotId,
4053 int responseType, int serial, RIL_Errno e, void *response,
4054 size_t responseLen) {
4055#if VDBG
4056 RLOGD("setCallForwardResponse: serial %d", serial);
4057#endif
4058
4059 if (radioService[slotId]->mRadioResponse != NULL) {
4060 RadioResponseInfo responseInfo = {};
4061 populateResponseInfo(responseInfo, serial, responseType, e);
4062 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4063 responseInfo);
4064 radioService[slotId]->checkReturnStatus(retStatus);
4065 } else {
4066 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4067 }
4068
4069 return 0;
4070}
4071
4072int radio::getCallWaitingResponse(int slotId,
4073 int responseType, int serial, RIL_Errno e, void *response,
4074 size_t responseLen) {
4075#if VDBG
4076 RLOGD("getCallWaitingResponse: serial %d", serial);
4077#endif
4078
4079 if (radioService[slotId]->mRadioResponse != NULL) {
4080 RadioResponseInfo responseInfo = {};
4081 populateResponseInfo(responseInfo, serial, responseType, e);
4082 bool enable = false;
4083 int serviceClass = -1;
4084 int numInts = responseLen / sizeof(int);
4085 if (response == NULL || numInts != 2) {
4086 RLOGE("getCallWaitingResponse Invalid response: NULL");
4087 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4088 } else {
4089 int *pInt = (int *) response;
4090 enable = pInt[0] == 1 ? true : false;
4091 serviceClass = pInt[1];
4092 }
4093 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4094 responseInfo, enable, serviceClass);
4095 radioService[slotId]->checkReturnStatus(retStatus);
4096 } else {
4097 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4098 }
4099
4100 return 0;
4101}
4102
4103int radio::setCallWaitingResponse(int slotId,
4104 int responseType, int serial, RIL_Errno e, void *response,
4105 size_t responseLen) {
4106#if VDBG
4107 RLOGD("setCallWaitingResponse: serial %d", serial);
4108#endif
4109
4110 if (radioService[slotId]->mRadioResponse != NULL) {
4111 RadioResponseInfo responseInfo = {};
4112 populateResponseInfo(responseInfo, serial, responseType, e);
4113 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4114 responseInfo);
4115 radioService[slotId]->checkReturnStatus(retStatus);
4116 } else {
4117 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4118 }
4119
4120 return 0;
4121}
4122
4123int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4124 int responseType, int serial, RIL_Errno e,
4125 void *response, size_t responseLen) {
4126#if VDBG
4127 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4128#endif
4129
4130 if (radioService[slotId]->mRadioResponse != NULL) {
4131 RadioResponseInfo responseInfo = {};
4132 populateResponseInfo(responseInfo, serial, responseType, e);
4133 Return<void> retStatus =
4134 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4135 responseInfo);
4136 radioService[slotId]->checkReturnStatus(retStatus);
4137 } else {
4138 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4139 "== NULL", slotId);
4140 }
4141
4142 return 0;
4143}
4144
4145int radio::acceptCallResponse(int slotId,
4146 int responseType, int serial, RIL_Errno e,
4147 void *response, size_t responseLen) {
4148#if VDBG
4149 RLOGD("acceptCallResponse: serial %d", serial);
4150#endif
4151
4152 if (radioService[slotId]->mRadioResponse != NULL) {
4153 RadioResponseInfo responseInfo = {};
4154 populateResponseInfo(responseInfo, serial, responseType, e);
4155 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4156 responseInfo);
4157 radioService[slotId]->checkReturnStatus(retStatus);
4158 } else {
4159 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4160 slotId);
4161 }
4162
4163 return 0;
4164}
4165
4166int radio::deactivateDataCallResponse(int slotId,
4167 int responseType, int serial, RIL_Errno e,
4168 void *response, size_t responseLen) {
4169#if VDBG
4170 RLOGD("deactivateDataCallResponse: serial %d", serial);
4171#endif
4172
4173 if (radioService[slotId]->mRadioResponse != NULL) {
4174 RadioResponseInfo responseInfo = {};
4175 populateResponseInfo(responseInfo, serial, responseType, e);
4176 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4177 responseInfo);
4178 radioService[slotId]->checkReturnStatus(retStatus);
4179 } else {
4180 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4181 slotId);
4182 }
4183
4184 return 0;
4185}
4186
4187int radio::getFacilityLockForAppResponse(int slotId,
4188 int responseType, int serial, RIL_Errno e,
4189 void *response, size_t responseLen) {
4190#if VDBG
4191 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4192#endif
4193
4194 if (radioService[slotId]->mRadioResponse != NULL) {
4195 RadioResponseInfo responseInfo = {};
4196 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4197 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4198 getFacilityLockForAppResponse(responseInfo, ret);
4199 radioService[slotId]->checkReturnStatus(retStatus);
4200 } else {
4201 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4202 slotId);
4203 }
4204
4205 return 0;
4206}
4207
4208int radio::setFacilityLockForAppResponse(int slotId,
4209 int responseType, int serial, RIL_Errno e,
4210 void *response, size_t responseLen) {
4211#if VDBG
4212 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4213#endif
4214
4215 if (radioService[slotId]->mRadioResponse != NULL) {
4216 RadioResponseInfo responseInfo = {};
4217 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4218 Return<void> retStatus
4219 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4220 ret);
4221 radioService[slotId]->checkReturnStatus(retStatus);
4222 } else {
4223 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4224 slotId);
4225 }
4226
4227 return 0;
4228}
4229
4230int radio::setBarringPasswordResponse(int slotId,
4231 int responseType, int serial, RIL_Errno e,
4232 void *response, size_t responseLen) {
4233#if VDBG
4234 RLOGD("acceptCallResponse: serial %d", serial);
4235#endif
4236
4237 if (radioService[slotId]->mRadioResponse != NULL) {
4238 RadioResponseInfo responseInfo = {};
4239 populateResponseInfo(responseInfo, serial, responseType, e);
4240 Return<void> retStatus
4241 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4242 radioService[slotId]->checkReturnStatus(retStatus);
4243 } else {
4244 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4245 slotId);
4246 }
4247
4248 return 0;
4249}
4250
4251int radio::getNetworkSelectionModeResponse(int slotId,
4252 int responseType, int serial, RIL_Errno e, void *response,
4253 size_t responseLen) {
4254#if VDBG
4255 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4256#endif
4257
4258 if (radioService[slotId]->mRadioResponse != NULL) {
4259 RadioResponseInfo responseInfo = {};
4260 populateResponseInfo(responseInfo, serial, responseType, e);
4261 bool manual = false;
4262 int serviceClass;
4263 if (response == NULL || responseLen != sizeof(int)) {
4264 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4265 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4266 } else {
4267 int *pInt = (int *) response;
4268 manual = pInt[0] == 1 ? true : false;
4269 }
4270 Return<void> retStatus
4271 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4272 responseInfo,
4273 manual);
4274 radioService[slotId]->checkReturnStatus(retStatus);
4275 } else {
4276 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4277 slotId);
4278 }
4279
4280 return 0;
4281}
4282
4283int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4284 RIL_Errno e, void *response,
4285 size_t responseLen) {
4286#if VDBG
4287 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4288#endif
4289
4290 if (radioService[slotId]->mRadioResponse != NULL) {
4291 RadioResponseInfo responseInfo = {};
4292 populateResponseInfo(responseInfo, serial, responseType, e);
4293 Return<void> retStatus
4294 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4295 responseInfo);
4296 radioService[slotId]->checkReturnStatus(retStatus);
4297 } else {
4298 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4299 "== NULL", slotId);
4300 }
4301
4302 return 0;
4303}
4304
4305int radio::setNetworkSelectionModeManualResponse(int slotId,
4306 int responseType, int serial, RIL_Errno e,
4307 void *response, size_t responseLen) {
4308#if VDBG
4309 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4310#endif
4311
4312 if (radioService[slotId]->mRadioResponse != NULL) {
4313 RadioResponseInfo responseInfo = {};
4314 populateResponseInfo(responseInfo, serial, responseType, e);
4315 Return<void> retStatus
4316 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4317 responseInfo);
4318 radioService[slotId]->checkReturnStatus(retStatus);
4319 } else {
4320 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4321 "== NULL", slotId);
4322 }
4323
4324 return 0;
4325}
4326
4327int convertOperatorStatusToInt(const char *str) {
4328 if (strncmp("unknown", str, 9) == 0) {
4329 return (int) OperatorStatus::UNKNOWN;
4330 } else if (strncmp("available", str, 9) == 0) {
4331 return (int) OperatorStatus::AVAILABLE;
4332 } else if (strncmp("current", str, 9) == 0) {
4333 return (int) OperatorStatus::CURRENT;
4334 } else if (strncmp("forbidden", str, 9) == 0) {
4335 return (int) OperatorStatus::FORBIDDEN;
4336 } else {
4337 return -1;
4338 }
4339}
4340
4341int radio::getAvailableNetworksResponse(int slotId,
4342 int responseType, int serial, RIL_Errno e, void *response,
4343 size_t responseLen) {
4344#if VDBG
4345 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4346#endif
4347
4348 if (radioService[slotId]->mRadioResponse != NULL) {
4349 RadioResponseInfo responseInfo = {};
4350 populateResponseInfo(responseInfo, serial, responseType, e);
4351 hidl_vec<OperatorInfo> networks;
4352 if ((response == NULL && responseLen != 0)
4353 || responseLen % (4 * sizeof(char *))!= 0) {
4354 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4355 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4356 } else {
4357 char **resp = (char **) response;
4358 int numStrings = responseLen / sizeof(char *);
4359 networks.resize(numStrings/4);
4360 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4361 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4362 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4363 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4364 int status = convertOperatorStatusToInt(resp[i + 3]);
4365 if (status == -1) {
4366 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4367 } else {
4368 networks[j].status = (OperatorStatus) status;
4369 }
4370 }
4371 }
4372 Return<void> retStatus
4373 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4374 networks);
4375 radioService[slotId]->checkReturnStatus(retStatus);
4376 } else {
4377 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4378 slotId);
4379 }
4380
4381 return 0;
4382}
4383
4384int radio::startDtmfResponse(int slotId,
4385 int responseType, int serial, RIL_Errno e,
4386 void *response, size_t responseLen) {
4387#if VDBG
4388 RLOGD("startDtmfResponse: serial %d", serial);
4389#endif
4390
4391 if (radioService[slotId]->mRadioResponse != NULL) {
4392 RadioResponseInfo responseInfo = {};
4393 populateResponseInfo(responseInfo, serial, responseType, e);
4394 Return<void> retStatus
4395 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4396 radioService[slotId]->checkReturnStatus(retStatus);
4397 } else {
4398 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4399 }
4400
4401 return 0;
4402}
4403
4404int radio::stopDtmfResponse(int slotId,
4405 int responseType, int serial, RIL_Errno e,
4406 void *response, size_t responseLen) {
4407#if VDBG
4408 RLOGD("stopDtmfResponse: serial %d", serial);
4409#endif
4410
4411 if (radioService[slotId]->mRadioResponse != NULL) {
4412 RadioResponseInfo responseInfo = {};
4413 populateResponseInfo(responseInfo, serial, responseType, e);
4414 Return<void> retStatus
4415 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4416 radioService[slotId]->checkReturnStatus(retStatus);
4417 } else {
4418 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4419 }
4420
4421 return 0;
4422}
4423
4424int radio::getBasebandVersionResponse(int slotId,
4425 int responseType, int serial, RIL_Errno e,
4426 void *response, size_t responseLen) {
4427#if VDBG
4428 RLOGD("getBasebandVersionResponse: serial %d", serial);
4429#endif
4430
4431 if (radioService[slotId]->mRadioResponse != NULL) {
4432 RadioResponseInfo responseInfo = {};
4433 populateResponseInfo(responseInfo, serial, responseType, e);
4434 Return<void> retStatus
4435 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4436 convertCharPtrToHidlString((char *) response));
4437 radioService[slotId]->checkReturnStatus(retStatus);
4438 } else {
4439 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4440 }
4441
4442 return 0;
4443}
4444
4445int radio::separateConnectionResponse(int slotId,
4446 int responseType, int serial, RIL_Errno e,
4447 void *response, size_t responseLen) {
4448#if VDBG
4449 RLOGD("separateConnectionResponse: serial %d", serial);
4450#endif
4451
4452 if (radioService[slotId]->mRadioResponse != NULL) {
4453 RadioResponseInfo responseInfo = {};
4454 populateResponseInfo(responseInfo, serial, responseType, e);
4455 Return<void> retStatus
4456 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4457 radioService[slotId]->checkReturnStatus(retStatus);
4458 } else {
4459 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4460 slotId);
4461 }
4462
4463 return 0;
4464}
4465
4466int radio::setMuteResponse(int slotId,
4467 int responseType, int serial, RIL_Errno e,
4468 void *response, size_t responseLen) {
4469#if VDBG
4470 RLOGD("setMuteResponse: serial %d", serial);
4471#endif
4472
4473 if (radioService[slotId]->mRadioResponse != NULL) {
4474 RadioResponseInfo responseInfo = {};
4475 populateResponseInfo(responseInfo, serial, responseType, e);
4476 Return<void> retStatus
4477 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4478 radioService[slotId]->checkReturnStatus(retStatus);
4479 } else {
4480 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4481 }
4482
4483 return 0;
4484}
4485
4486int radio::getMuteResponse(int slotId,
4487 int responseType, int serial, RIL_Errno e, void *response,
4488 size_t responseLen) {
4489#if VDBG
4490 RLOGD("getMuteResponse: serial %d", serial);
4491#endif
4492
4493 if (radioService[slotId]->mRadioResponse != NULL) {
4494 RadioResponseInfo responseInfo = {};
4495 populateResponseInfo(responseInfo, serial, responseType, e);
4496 bool enable = false;
4497 int serviceClass;
4498 if (response == NULL || responseLen != sizeof(int)) {
4499 RLOGE("getMuteResponse Invalid response: NULL");
4500 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4501 } else {
4502 int *pInt = (int *) response;
4503 enable = pInt[0] == 1 ? true : false;
4504 }
4505 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4506 enable);
4507 radioService[slotId]->checkReturnStatus(retStatus);
4508 } else {
4509 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4510 }
4511
4512 return 0;
4513}
4514
4515int radio::getClipResponse(int slotId,
4516 int responseType, int serial, RIL_Errno e,
4517 void *response, size_t responseLen) {
4518#if VDBG
4519 RLOGD("getClipResponse: serial %d", serial);
4520#endif
4521
4522 if (radioService[slotId]->mRadioResponse != NULL) {
4523 RadioResponseInfo responseInfo = {};
4524 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4525 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4526 (ClipStatus) ret);
4527 radioService[slotId]->checkReturnStatus(retStatus);
4528 } else {
4529 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4530 }
4531
4532 return 0;
4533}
4534
4535int radio::getDataCallListResponse(int slotId,
4536 int responseType, int serial, RIL_Errno e,
4537 void *response, size_t responseLen) {
4538#if VDBG
4539 RLOGD("getDataCallListResponse: serial %d", serial);
4540#endif
4541
4542 if (radioService[slotId]->mRadioResponse != NULL) {
4543 RadioResponseInfo responseInfo = {};
4544 populateResponseInfo(responseInfo, serial, responseType, e);
4545
4546 hidl_vec<SetupDataCallResult> ret;
4547 if ((response == NULL && responseLen != 0)
4548 || (responseLen % sizeof(RIL_Data_Call_Response_v11) != 0
4549 && responseLen % sizeof(RIL_Data_Call_Response_v9) != 0
4550 && responseLen % sizeof(RIL_Data_Call_Response_v6) != 0)) {
4551 RLOGE("getDataCallListResponse: invalid response");
4552 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4553 } else {
4554 convertRilDataCallListToHal(response, responseLen, ret);
4555 }
4556
4557 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4558 responseInfo, ret);
4559 radioService[slotId]->checkReturnStatus(retStatus);
4560 } else {
4561 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4562 }
4563
4564 return 0;
4565}
4566
4567int radio::setSuppServiceNotificationsResponse(int slotId,
4568 int responseType, int serial, RIL_Errno e,
4569 void *response, size_t responseLen) {
4570#if VDBG
4571 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4572#endif
4573
4574 if (radioService[slotId]->mRadioResponse != NULL) {
4575 RadioResponseInfo responseInfo = {};
4576 populateResponseInfo(responseInfo, serial, responseType, e);
4577 Return<void> retStatus
4578 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4579 responseInfo);
4580 radioService[slotId]->checkReturnStatus(retStatus);
4581 } else {
4582 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4583 "== NULL", slotId);
4584 }
4585
4586 return 0;
4587}
4588
4589int radio::deleteSmsOnSimResponse(int slotId,
4590 int responseType, int serial, RIL_Errno e,
4591 void *response, size_t responseLen) {
4592#if VDBG
4593 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4594#endif
4595
4596 if (radioService[slotId]->mRadioResponse != NULL) {
4597 RadioResponseInfo responseInfo = {};
4598 populateResponseInfo(responseInfo, serial, responseType, e);
4599 Return<void> retStatus
4600 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4601 radioService[slotId]->checkReturnStatus(retStatus);
4602 } else {
4603 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4604 }
4605
4606 return 0;
4607}
4608
4609int radio::setBandModeResponse(int slotId,
4610 int responseType, int serial, RIL_Errno e,
4611 void *response, size_t responseLen) {
4612#if VDBG
4613 RLOGD("setBandModeResponse: serial %d", serial);
4614#endif
4615
4616 if (radioService[slotId]->mRadioResponse != NULL) {
4617 RadioResponseInfo responseInfo = {};
4618 populateResponseInfo(responseInfo, serial, responseType, e);
4619 Return<void> retStatus
4620 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4621 radioService[slotId]->checkReturnStatus(retStatus);
4622 } else {
4623 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4624 }
4625
4626 return 0;
4627}
4628
4629int radio::writeSmsToSimResponse(int slotId,
4630 int responseType, int serial, RIL_Errno e,
4631 void *response, size_t responseLen) {
4632#if VDBG
4633 RLOGD("writeSmsToSimResponse: serial %d", serial);
4634#endif
4635
4636 if (radioService[slotId]->mRadioResponse != NULL) {
4637 RadioResponseInfo responseInfo = {};
4638 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4639 Return<void> retStatus
4640 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4641 radioService[slotId]->checkReturnStatus(retStatus);
4642 } else {
4643 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4644 }
4645
4646 return 0;
4647}
4648
4649int radio::getAvailableBandModesResponse(int slotId,
4650 int responseType, int serial, RIL_Errno e, void *response,
4651 size_t responseLen) {
4652#if VDBG
4653 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4654#endif
4655
4656 if (radioService[slotId]->mRadioResponse != NULL) {
4657 RadioResponseInfo responseInfo = {};
4658 populateResponseInfo(responseInfo, serial, responseType, e);
4659 hidl_vec<RadioBandMode> modes;
4660 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
4661 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4662 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4663 } else {
4664 int *pInt = (int *) response;
4665 int numInts = responseLen / sizeof(int);
4666 modes.resize(numInts);
4667 for (int i = 0; i < numInts; i++) {
4668 modes[i] = (RadioBandMode) pInt[i];
4669 }
4670 }
4671 Return<void> retStatus
4672 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4673 modes);
4674 radioService[slotId]->checkReturnStatus(retStatus);
4675 } else {
4676 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4677 slotId);
4678 }
4679
4680 return 0;
4681}
4682
4683int radio::sendEnvelopeResponse(int slotId,
4684 int responseType, int serial, RIL_Errno e,
4685 void *response, size_t responseLen) {
4686#if VDBG
4687 RLOGD("sendEnvelopeResponse: serial %d", serial);
4688#endif
4689
4690 if (radioService[slotId]->mRadioResponse != NULL) {
4691 RadioResponseInfo responseInfo = {};
4692 populateResponseInfo(responseInfo, serial, responseType, e);
4693 Return<void> retStatus
4694 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4695 convertCharPtrToHidlString((char *) response));
4696 radioService[slotId]->checkReturnStatus(retStatus);
4697 } else {
4698 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4699 }
4700
4701 return 0;
4702}
4703
4704int radio::sendTerminalResponseToSimResponse(int slotId,
4705 int responseType, int serial, RIL_Errno e,
4706 void *response, size_t responseLen) {
4707#if VDBG
4708 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4709#endif
4710
4711 if (radioService[slotId]->mRadioResponse != NULL) {
4712 RadioResponseInfo responseInfo = {};
4713 populateResponseInfo(responseInfo, serial, responseType, e);
4714 Return<void> retStatus
4715 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4716 responseInfo);
4717 radioService[slotId]->checkReturnStatus(retStatus);
4718 } else {
4719 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4720 slotId);
4721 }
4722
4723 return 0;
4724}
4725
4726int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4727 int responseType, int serial,
4728 RIL_Errno e, void *response,
4729 size_t responseLen) {
4730#if VDBG
4731 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4732#endif
4733
4734 if (radioService[slotId]->mRadioResponse != NULL) {
4735 RadioResponseInfo responseInfo = {};
4736 populateResponseInfo(responseInfo, serial, responseType, e);
4737 Return<void> retStatus
4738 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4739 responseInfo);
4740 radioService[slotId]->checkReturnStatus(retStatus);
4741 } else {
4742 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4743 "== NULL", slotId);
4744 }
4745
4746 return 0;
4747}
4748
4749int radio::explicitCallTransferResponse(int slotId,
4750 int responseType, int serial, RIL_Errno e,
4751 void *response, size_t responseLen) {
4752#if VDBG
4753 RLOGD("explicitCallTransferResponse: serial %d", serial);
4754#endif
4755
4756 if (radioService[slotId]->mRadioResponse != NULL) {
4757 RadioResponseInfo responseInfo = {};
4758 populateResponseInfo(responseInfo, serial, responseType, e);
4759 Return<void> retStatus
4760 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4761 radioService[slotId]->checkReturnStatus(retStatus);
4762 } else {
4763 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4764 slotId);
4765 }
4766
4767 return 0;
4768}
4769
4770int radio::setPreferredNetworkTypeResponse(int slotId,
4771 int responseType, int serial, RIL_Errno e,
4772 void *response, size_t responseLen) {
4773#if VDBG
4774 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4775#endif
4776
4777 if (radioService[slotId]->mRadioResponse != NULL) {
4778 RadioResponseInfo responseInfo = {};
4779 populateResponseInfo(responseInfo, serial, responseType, e);
4780 Return<void> retStatus
4781 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4782 responseInfo);
4783 radioService[slotId]->checkReturnStatus(retStatus);
4784 } else {
4785 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4786 slotId);
4787 }
4788
4789 return 0;
4790}
4791
4792
4793int radio::getPreferredNetworkTypeResponse(int slotId,
4794 int responseType, int serial, RIL_Errno e,
4795 void *response, size_t responseLen) {
4796#if VDBG
4797 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4798#endif
4799
4800 if (radioService[slotId]->mRadioResponse != NULL) {
4801 RadioResponseInfo responseInfo = {};
4802 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4803 Return<void> retStatus
4804 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4805 responseInfo, (PreferredNetworkType) ret);
4806 radioService[slotId]->checkReturnStatus(retStatus);
4807 } else {
4808 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4809 slotId);
4810 }
4811
4812 return 0;
4813}
4814
4815int radio::getNeighboringCidsResponse(int slotId,
4816 int responseType, int serial, RIL_Errno e,
4817 void *response, size_t responseLen) {
4818#if VDBG
4819 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4820#endif
4821
4822 if (radioService[slotId]->mRadioResponse != NULL) {
4823 RadioResponseInfo responseInfo = {};
4824 populateResponseInfo(responseInfo, serial, responseType, e);
4825 hidl_vec<NeighboringCell> cells;
4826
4827 if ((response == NULL && responseLen != 0)
4828 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4829 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4830 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4831 } else {
4832 int num = responseLen / sizeof(RIL_NeighboringCell *);
4833 cells.resize(num);
4834 for (int i = 0 ; i < num; i++) {
4835 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4836 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4837 cells[i].rssi = resp->rssi;
4838 }
4839 }
4840
4841 Return<void> retStatus
4842 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4843 cells);
4844 radioService[slotId]->checkReturnStatus(retStatus);
4845 } else {
4846 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4847 slotId);
4848 }
4849
4850 return 0;
4851}
4852
4853int radio::setLocationUpdatesResponse(int slotId,
4854 int responseType, int serial, RIL_Errno e,
4855 void *response, size_t responseLen) {
4856#if VDBG
4857 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4858#endif
4859
4860 if (radioService[slotId]->mRadioResponse != NULL) {
4861 RadioResponseInfo responseInfo = {};
4862 populateResponseInfo(responseInfo, serial, responseType, e);
4863 Return<void> retStatus
4864 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4865 radioService[slotId]->checkReturnStatus(retStatus);
4866 } else {
4867 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4868 slotId);
4869 }
4870
4871 return 0;
4872}
4873
4874int radio::setCdmaSubscriptionSourceResponse(int slotId,
4875 int responseType, int serial, RIL_Errno e,
4876 void *response, size_t responseLen) {
4877#if VDBG
4878 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4879#endif
4880
4881 if (radioService[slotId]->mRadioResponse != NULL) {
4882 RadioResponseInfo responseInfo = {};
4883 populateResponseInfo(responseInfo, serial, responseType, e);
4884 Return<void> retStatus
4885 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4886 responseInfo);
4887 radioService[slotId]->checkReturnStatus(retStatus);
4888 } else {
4889 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4890 slotId);
4891 }
4892
4893 return 0;
4894}
4895
4896int radio::setCdmaRoamingPreferenceResponse(int slotId,
4897 int responseType, int serial, RIL_Errno e,
4898 void *response, size_t responseLen) {
4899#if VDBG
4900 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4901#endif
4902
4903 if (radioService[slotId]->mRadioResponse != NULL) {
4904 RadioResponseInfo responseInfo = {};
4905 populateResponseInfo(responseInfo, serial, responseType, e);
4906 Return<void> retStatus
4907 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4908 responseInfo);
4909 radioService[slotId]->checkReturnStatus(retStatus);
4910 } else {
4911 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4912 slotId);
4913 }
4914
4915 return 0;
4916}
4917
4918int radio::getCdmaRoamingPreferenceResponse(int slotId,
4919 int responseType, int serial, RIL_Errno e,
4920 void *response, size_t responseLen) {
4921#if VDBG
4922 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4923#endif
4924
4925 if (radioService[slotId]->mRadioResponse != NULL) {
4926 RadioResponseInfo responseInfo = {};
4927 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4928 Return<void> retStatus
4929 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4930 responseInfo, (CdmaRoamingType) ret);
4931 radioService[slotId]->checkReturnStatus(retStatus);
4932 } else {
4933 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4934 slotId);
4935 }
4936
4937 return 0;
4938}
4939
4940int radio::setTTYModeResponse(int slotId,
4941 int responseType, int serial, RIL_Errno e,
4942 void *response, size_t responseLen) {
4943#if VDBG
4944 RLOGD("setTTYModeResponse: serial %d", serial);
4945#endif
4946
4947 if (radioService[slotId]->mRadioResponse != NULL) {
4948 RadioResponseInfo responseInfo = {};
4949 populateResponseInfo(responseInfo, serial, responseType, e);
4950 Return<void> retStatus
4951 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4952 radioService[slotId]->checkReturnStatus(retStatus);
4953 } else {
4954 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4955 }
4956
4957 return 0;
4958}
4959
4960int radio::getTTYModeResponse(int slotId,
4961 int responseType, int serial, RIL_Errno e,
4962 void *response, size_t responseLen) {
4963#if VDBG
4964 RLOGD("getTTYModeResponse: serial %d", serial);
4965#endif
4966
4967 if (radioService[slotId]->mRadioResponse != NULL) {
4968 RadioResponseInfo responseInfo = {};
4969 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4970 Return<void> retStatus
4971 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4972 (TtyMode) ret);
4973 radioService[slotId]->checkReturnStatus(retStatus);
4974 } else {
4975 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4976 }
4977
4978 return 0;
4979}
4980
4981int radio::setPreferredVoicePrivacyResponse(int slotId,
4982 int responseType, int serial, RIL_Errno e,
4983 void *response, size_t responseLen) {
4984#if VDBG
4985 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
4986#endif
4987
4988 if (radioService[slotId]->mRadioResponse != NULL) {
4989 RadioResponseInfo responseInfo = {};
4990 populateResponseInfo(responseInfo, serial, responseType, e);
4991 Return<void> retStatus
4992 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4993 responseInfo);
4994 radioService[slotId]->checkReturnStatus(retStatus);
4995 } else {
4996 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4997 slotId);
4998 }
4999
5000 return 0;
5001}
5002
5003int radio::getPreferredVoicePrivacyResponse(int slotId,
5004 int responseType, int serial, RIL_Errno e,
5005 void *response, size_t responseLen) {
5006#if VDBG
5007 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
5008#endif
5009
5010 if (radioService[slotId]->mRadioResponse != NULL) {
5011 RadioResponseInfo responseInfo = {};
5012 populateResponseInfo(responseInfo, serial, responseType, e);
5013 bool enable = false;
5014 int numInts = responseLen / sizeof(int);
5015 if (response == NULL || numInts != 1) {
5016 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
5017 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5018 } else {
5019 int *pInt = (int *) response;
5020 enable = pInt[0] == 1 ? true : false;
5021 }
5022 Return<void> retStatus
5023 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5024 responseInfo, enable);
5025 radioService[slotId]->checkReturnStatus(retStatus);
5026 } else {
5027 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5028 slotId);
5029 }
5030
5031 return 0;
5032}
5033
5034int radio::sendCDMAFeatureCodeResponse(int slotId,
5035 int responseType, int serial, RIL_Errno e,
5036 void *response, size_t responseLen) {
5037#if VDBG
5038 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5039#endif
5040
5041 if (radioService[slotId]->mRadioResponse != NULL) {
5042 RadioResponseInfo responseInfo = {};
5043 populateResponseInfo(responseInfo, serial, responseType, e);
5044 Return<void> retStatus
5045 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5046 radioService[slotId]->checkReturnStatus(retStatus);
5047 } else {
5048 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5049 slotId);
5050 }
5051
5052 return 0;
5053}
5054
5055int radio::sendBurstDtmfResponse(int slotId,
5056 int responseType, int serial, RIL_Errno e,
5057 void *response, size_t responseLen) {
5058#if VDBG
5059 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5060#endif
5061
5062 if (radioService[slotId]->mRadioResponse != NULL) {
5063 RadioResponseInfo responseInfo = {};
5064 populateResponseInfo(responseInfo, serial, responseType, e);
5065 Return<void> retStatus
5066 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5067 radioService[slotId]->checkReturnStatus(retStatus);
5068 } else {
5069 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5070 }
5071
5072 return 0;
5073}
5074
5075int radio::sendCdmaSmsResponse(int slotId,
5076 int responseType, int serial, RIL_Errno e, void *response,
5077 size_t responseLen) {
5078#if VDBG
5079 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5080#endif
5081
5082 if (radioService[slotId]->mRadioResponse != NULL) {
5083 RadioResponseInfo responseInfo = {};
5084 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5085 responseLen);
5086
5087 Return<void> retStatus
5088 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5089 radioService[slotId]->checkReturnStatus(retStatus);
5090 } else {
5091 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5092 }
5093
5094 return 0;
5095}
5096
5097int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5098 int responseType, int serial, RIL_Errno e,
5099 void *response, size_t responseLen) {
5100#if VDBG
5101 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5102#endif
5103
5104 if (radioService[slotId]->mRadioResponse != NULL) {
5105 RadioResponseInfo responseInfo = {};
5106 populateResponseInfo(responseInfo, serial, responseType, e);
5107 Return<void> retStatus
5108 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5109 responseInfo);
5110 radioService[slotId]->checkReturnStatus(retStatus);
5111 } else {
5112 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5113 "== NULL", slotId);
5114 }
5115
5116 return 0;
5117}
5118
5119int radio::getGsmBroadcastConfigResponse(int slotId,
5120 int responseType, int serial, RIL_Errno e,
5121 void *response, size_t responseLen) {
5122#if VDBG
5123 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5124#endif
5125
5126 if (radioService[slotId]->mRadioResponse != NULL) {
5127 RadioResponseInfo responseInfo = {};
5128 populateResponseInfo(responseInfo, serial, responseType, e);
5129 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5130
5131 if ((response == NULL && responseLen != 0)
5132 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5133 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5134 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5135 } else {
5136 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5137 configs.resize(num);
5138 for (int i = 0 ; i < num; i++) {
5139 RIL_GSM_BroadcastSmsConfigInfo *resp =
5140 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5141 configs[i].fromServiceId = resp->fromServiceId;
5142 configs[i].toServiceId = resp->toServiceId;
5143 configs[i].fromCodeScheme = resp->fromCodeScheme;
5144 configs[i].toCodeScheme = resp->toCodeScheme;
5145 configs[i].selected = resp->selected == 1 ? true : false;
5146 }
5147 }
5148
5149 Return<void> retStatus
5150 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5151 configs);
5152 radioService[slotId]->checkReturnStatus(retStatus);
5153 } else {
5154 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5155 slotId);
5156 }
5157
5158 return 0;
5159}
5160
5161int radio::setGsmBroadcastConfigResponse(int slotId,
5162 int responseType, int serial, RIL_Errno e,
5163 void *response, size_t responseLen) {
5164#if VDBG
5165 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5166#endif
5167
5168 if (radioService[slotId]->mRadioResponse != NULL) {
5169 RadioResponseInfo responseInfo = {};
5170 populateResponseInfo(responseInfo, serial, responseType, e);
5171 Return<void> retStatus
5172 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5173 radioService[slotId]->checkReturnStatus(retStatus);
5174 } else {
5175 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5176 slotId);
5177 }
5178
5179 return 0;
5180}
5181
5182int radio::setGsmBroadcastActivationResponse(int slotId,
5183 int responseType, int serial, RIL_Errno e,
5184 void *response, size_t responseLen) {
5185#if VDBG
5186 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5187#endif
5188
5189 if (radioService[slotId]->mRadioResponse != NULL) {
5190 RadioResponseInfo responseInfo = {};
5191 populateResponseInfo(responseInfo, serial, responseType, e);
5192 Return<void> retStatus
5193 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5194 responseInfo);
5195 radioService[slotId]->checkReturnStatus(retStatus);
5196 } else {
5197 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5198 slotId);
5199 }
5200
5201 return 0;
5202}
5203
5204int radio::getCdmaBroadcastConfigResponse(int slotId,
5205 int responseType, int serial, RIL_Errno e,
5206 void *response, size_t responseLen) {
5207#if VDBG
5208 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5209#endif
5210
5211 if (radioService[slotId]->mRadioResponse != NULL) {
5212 RadioResponseInfo responseInfo = {};
5213 populateResponseInfo(responseInfo, serial, responseType, e);
5214 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5215
5216 if ((response == NULL && responseLen != 0)
5217 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5218 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5219 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5220 } else {
5221 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5222 configs.resize(num);
5223 for (int i = 0 ; i < num; i++) {
5224 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5225 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5226 configs[i].serviceCategory = resp->service_category;
5227 configs[i].language = resp->language;
5228 configs[i].selected = resp->selected == 1 ? true : false;
5229 }
5230 }
5231
5232 Return<void> retStatus
5233 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5234 configs);
5235 radioService[slotId]->checkReturnStatus(retStatus);
5236 } else {
5237 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5238 slotId);
5239 }
5240
5241 return 0;
5242}
5243
5244int radio::setCdmaBroadcastConfigResponse(int slotId,
5245 int responseType, int serial, RIL_Errno e,
5246 void *response, size_t responseLen) {
5247#if VDBG
5248 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5249#endif
5250
5251 if (radioService[slotId]->mRadioResponse != NULL) {
5252 RadioResponseInfo responseInfo = {};
5253 populateResponseInfo(responseInfo, serial, responseType, e);
5254 Return<void> retStatus
5255 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5256 responseInfo);
5257 radioService[slotId]->checkReturnStatus(retStatus);
5258 } else {
5259 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5260 slotId);
5261 }
5262
5263 return 0;
5264}
5265
5266int radio::setCdmaBroadcastActivationResponse(int slotId,
5267 int responseType, int serial, RIL_Errno e,
5268 void *response, size_t responseLen) {
5269#if VDBG
5270 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5271#endif
5272
5273 if (radioService[slotId]->mRadioResponse != NULL) {
5274 RadioResponseInfo responseInfo = {};
5275 populateResponseInfo(responseInfo, serial, responseType, e);
5276 Return<void> retStatus
5277 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5278 responseInfo);
5279 radioService[slotId]->checkReturnStatus(retStatus);
5280 } else {
5281 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5282 slotId);
5283 }
5284
5285 return 0;
5286}
5287
5288int radio::getCDMASubscriptionResponse(int slotId,
5289 int responseType, int serial, RIL_Errno e, void *response,
5290 size_t responseLen) {
5291#if VDBG
5292 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5293#endif
5294
5295 if (radioService[slotId]->mRadioResponse != NULL) {
5296 RadioResponseInfo responseInfo = {};
5297 populateResponseInfo(responseInfo, serial, responseType, e);
5298
5299 int numStrings = responseLen / sizeof(char *);
5300 hidl_string emptyString;
5301 if (response == NULL || numStrings != 5) {
5302 RLOGE("getOperatorResponse Invalid response: NULL");
5303 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5304 Return<void> retStatus
5305 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5306 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5307 radioService[slotId]->checkReturnStatus(retStatus);
5308 } else {
5309 char **resp = (char **) response;
5310 Return<void> retStatus
5311 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5312 responseInfo,
5313 convertCharPtrToHidlString(resp[0]),
5314 convertCharPtrToHidlString(resp[1]),
5315 convertCharPtrToHidlString(resp[2]),
5316 convertCharPtrToHidlString(resp[3]),
5317 convertCharPtrToHidlString(resp[4]));
5318 radioService[slotId]->checkReturnStatus(retStatus);
5319 }
5320 } else {
5321 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5322 slotId);
5323 }
5324
5325 return 0;
5326}
5327
5328int radio::writeSmsToRuimResponse(int slotId,
5329 int responseType, int serial, RIL_Errno e,
5330 void *response, size_t responseLen) {
5331#if VDBG
5332 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5333#endif
5334
5335 if (radioService[slotId]->mRadioResponse != NULL) {
5336 RadioResponseInfo responseInfo = {};
5337 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5338 Return<void> retStatus
5339 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5340 radioService[slotId]->checkReturnStatus(retStatus);
5341 } else {
5342 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5343 }
5344
5345 return 0;
5346}
5347
5348int radio::deleteSmsOnRuimResponse(int slotId,
5349 int responseType, int serial, RIL_Errno e,
5350 void *response, size_t responseLen) {
5351#if VDBG
5352 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5353#endif
5354
5355 if (radioService[slotId]->mRadioResponse != NULL) {
5356 RadioResponseInfo responseInfo = {};
5357 populateResponseInfo(responseInfo, serial, responseType, e);
5358 Return<void> retStatus
5359 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5360 radioService[slotId]->checkReturnStatus(retStatus);
5361 } else {
5362 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5363 }
5364
5365 return 0;
5366}
5367
5368int radio::getDeviceIdentityResponse(int slotId,
5369 int responseType, int serial, RIL_Errno e, void *response,
5370 size_t responseLen) {
5371#if VDBG
5372 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5373#endif
5374
5375 if (radioService[slotId]->mRadioResponse != NULL) {
5376 RadioResponseInfo responseInfo = {};
5377 populateResponseInfo(responseInfo, serial, responseType, e);
5378
5379 int numStrings = responseLen / sizeof(char *);
5380 hidl_string emptyString;
5381 if (response == NULL || numStrings != 4) {
5382 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5383 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5384 Return<void> retStatus
5385 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5386 emptyString, emptyString, emptyString, emptyString);
5387 radioService[slotId]->checkReturnStatus(retStatus);
5388 } else {
5389 char **resp = (char **) response;
5390 Return<void> retStatus
5391 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5392 convertCharPtrToHidlString(resp[0]),
5393 convertCharPtrToHidlString(resp[1]),
5394 convertCharPtrToHidlString(resp[2]),
5395 convertCharPtrToHidlString(resp[3]));
5396 radioService[slotId]->checkReturnStatus(retStatus);
5397 }
5398 } else {
5399 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5400 slotId);
5401 }
5402
5403 return 0;
5404}
5405
5406int radio::exitEmergencyCallbackModeResponse(int slotId,
5407 int responseType, int serial, RIL_Errno e,
5408 void *response, size_t responseLen) {
5409#if VDBG
5410 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5411#endif
5412
5413 if (radioService[slotId]->mRadioResponse != NULL) {
5414 RadioResponseInfo responseInfo = {};
5415 populateResponseInfo(responseInfo, serial, responseType, e);
5416 Return<void> retStatus
5417 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5418 responseInfo);
5419 radioService[slotId]->checkReturnStatus(retStatus);
5420 } else {
5421 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5422 slotId);
5423 }
5424
5425 return 0;
5426}
5427
5428int radio::getSmscAddressResponse(int slotId,
5429 int responseType, int serial, RIL_Errno e,
5430 void *response, size_t responseLen) {
5431#if VDBG
5432 RLOGD("getSmscAddressResponse: serial %d", serial);
5433#endif
5434
5435 if (radioService[slotId]->mRadioResponse != NULL) {
5436 RadioResponseInfo responseInfo = {};
5437 populateResponseInfo(responseInfo, serial, responseType, e);
5438 Return<void> retStatus
5439 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5440 convertCharPtrToHidlString((char *) response));
5441 radioService[slotId]->checkReturnStatus(retStatus);
5442 } else {
5443 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5444 }
5445
5446 return 0;
5447}
5448
5449int radio::setSmscAddressResponse(int slotId,
5450 int responseType, int serial, RIL_Errno e,
5451 void *response, size_t responseLen) {
5452#if VDBG
5453 RLOGD("setSmscAddressResponse: serial %d", serial);
5454#endif
5455
5456 if (radioService[slotId]->mRadioResponse != NULL) {
5457 RadioResponseInfo responseInfo = {};
5458 populateResponseInfo(responseInfo, serial, responseType, e);
5459 Return<void> retStatus
5460 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5461 radioService[slotId]->checkReturnStatus(retStatus);
5462 } else {
5463 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5464 }
5465
5466 return 0;
5467}
5468
5469int radio::reportSmsMemoryStatusResponse(int slotId,
5470 int responseType, int serial, RIL_Errno e,
5471 void *response, size_t responseLen) {
5472#if VDBG
5473 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5474#endif
5475
5476 if (radioService[slotId]->mRadioResponse != NULL) {
5477 RadioResponseInfo responseInfo = {};
5478 populateResponseInfo(responseInfo, serial, responseType, e);
5479 Return<void> retStatus
5480 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5481 radioService[slotId]->checkReturnStatus(retStatus);
5482 } else {
5483 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5484 slotId);
5485 }
5486
5487 return 0;
5488}
5489
5490int radio::reportStkServiceIsRunningResponse(int slotId,
5491 int responseType, int serial, RIL_Errno e,
5492 void *response, size_t responseLen) {
5493#if VDBG
5494 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5495#endif
5496
5497 if (radioService[slotId]->mRadioResponse != NULL) {
5498 RadioResponseInfo responseInfo = {};
5499 populateResponseInfo(responseInfo, serial, responseType, e);
5500 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5501 reportStkServiceIsRunningResponse(responseInfo);
5502 radioService[slotId]->checkReturnStatus(retStatus);
5503 } else {
5504 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5505 slotId);
5506 }
5507
5508 return 0;
5509}
5510
5511int radio::getCdmaSubscriptionSourceResponse(int slotId,
5512 int responseType, int serial, RIL_Errno e,
5513 void *response, size_t responseLen) {
5514#if VDBG
5515 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5516#endif
5517
5518 if (radioService[slotId]->mRadioResponse != NULL) {
5519 RadioResponseInfo responseInfo = {};
5520 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5521 Return<void> retStatus
5522 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5523 responseInfo, (CdmaSubscriptionSource) ret);
5524 radioService[slotId]->checkReturnStatus(retStatus);
5525 } else {
5526 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5527 slotId);
5528 }
5529
5530 return 0;
5531}
5532
5533int radio::requestIsimAuthenticationResponse(int slotId,
5534 int responseType, int serial, RIL_Errno e,
5535 void *response, size_t responseLen) {
5536#if VDBG
5537 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5538#endif
5539
5540 if (radioService[slotId]->mRadioResponse != NULL) {
5541 RadioResponseInfo responseInfo = {};
5542 populateResponseInfo(responseInfo, serial, responseType, e);
5543 Return<void> retStatus
5544 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5545 responseInfo,
5546 convertCharPtrToHidlString((char *) response));
5547 radioService[slotId]->checkReturnStatus(retStatus);
5548 } else {
5549 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5550 slotId);
5551 }
5552
5553 return 0;
5554}
5555
5556int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5557 int responseType,
5558 int serial, RIL_Errno e, void *response,
5559 size_t responseLen) {
5560#if VDBG
5561 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5562#endif
5563
5564 if (radioService[slotId]->mRadioResponse != NULL) {
5565 RadioResponseInfo responseInfo = {};
5566 populateResponseInfo(responseInfo, serial, responseType, e);
5567 Return<void> retStatus
5568 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5569 responseInfo);
5570 radioService[slotId]->checkReturnStatus(retStatus);
5571 } else {
5572 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5573 "== NULL", slotId);
5574 }
5575
5576 return 0;
5577}
5578
5579int radio::sendEnvelopeWithStatusResponse(int slotId,
5580 int responseType, int serial, RIL_Errno e, void *response,
5581 size_t responseLen) {
5582#if VDBG
5583 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5584#endif
5585
5586 if (radioService[slotId]->mRadioResponse != NULL) {
5587 RadioResponseInfo responseInfo = {};
5588 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5589 response, responseLen);
5590
5591 Return<void> retStatus
5592 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5593 result);
5594 radioService[slotId]->checkReturnStatus(retStatus);
5595 } else {
5596 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5597 slotId);
5598 }
5599
5600 return 0;
5601}
5602
5603int radio::getVoiceRadioTechnologyResponse(int slotId,
5604 int responseType, int serial, RIL_Errno e,
5605 void *response, size_t responseLen) {
5606#if VDBG
5607 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5608#endif
5609
5610 if (radioService[slotId]->mRadioResponse != NULL) {
5611 RadioResponseInfo responseInfo = {};
5612 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5613 Return<void> retStatus
5614 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5615 responseInfo, (RadioTechnology) ret);
5616 radioService[slotId]->checkReturnStatus(retStatus);
5617 } else {
5618 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5619 slotId);
5620 }
5621
5622 return 0;
5623}
5624
5625int radio::getCellInfoListResponse(int slotId,
5626 int responseType,
5627 int serial, RIL_Errno e, void *response,
5628 size_t responseLen) {
5629#if VDBG
5630 RLOGD("getCellInfoListResponse: serial %d", serial);
5631#endif
5632
5633 if (radioService[slotId]->mRadioResponse != NULL) {
5634 RadioResponseInfo responseInfo = {};
5635 populateResponseInfo(responseInfo, serial, responseType, e);
5636
5637 hidl_vec<CellInfo> ret;
5638 if ((response == NULL && responseLen != 0)
5639 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5640 RLOGE("getCellInfoListResponse: Invalid response");
5641 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5642 } else {
5643 convertRilCellInfoListToHal(response, responseLen, ret);
5644 }
5645
5646 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5647 responseInfo, ret);
5648 radioService[slotId]->checkReturnStatus(retStatus);
5649 } else {
5650 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5651 }
5652
5653 return 0;
5654}
5655
5656int radio::setCellInfoListRateResponse(int slotId,
5657 int responseType,
5658 int serial, RIL_Errno e, void *response,
5659 size_t responseLen) {
5660#if VDBG
5661 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5662#endif
5663
5664 if (radioService[slotId]->mRadioResponse != NULL) {
5665 RadioResponseInfo responseInfo = {};
5666 populateResponseInfo(responseInfo, serial, responseType, e);
5667 Return<void> retStatus
5668 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5669 radioService[slotId]->checkReturnStatus(retStatus);
5670 } else {
5671 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5672 slotId);
5673 }
5674
5675 return 0;
5676}
5677
5678int radio::setInitialAttachApnResponse(int slotId,
5679 int responseType, int serial, RIL_Errno e,
5680 void *response, size_t responseLen) {
5681#if VDBG
5682 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5683#endif
5684
5685 if (radioService[slotId]->mRadioResponse != NULL) {
5686 RadioResponseInfo responseInfo = {};
5687 populateResponseInfo(responseInfo, serial, responseType, e);
5688 Return<void> retStatus
5689 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5690 radioService[slotId]->checkReturnStatus(retStatus);
5691 } else {
5692 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5693 slotId);
5694 }
5695
5696 return 0;
5697}
5698
5699int radio::getImsRegistrationStateResponse(int slotId,
5700 int responseType, int serial, RIL_Errno e,
5701 void *response, size_t responseLen) {
5702#if VDBG
5703 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5704#endif
5705
5706 if (radioService[slotId]->mRadioResponse != NULL) {
5707 RadioResponseInfo responseInfo = {};
5708 populateResponseInfo(responseInfo, serial, responseType, e);
5709 bool isRegistered = false;
5710 int ratFamily = 0;
5711 int numInts = responseLen / sizeof(int);
5712 if (response == NULL || numInts != 2) {
5713 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5714 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5715 } else {
5716 int *pInt = (int *) response;
5717 isRegistered = pInt[0] == 1 ? true : false;
5718 ratFamily = pInt[1];
5719 }
5720 Return<void> retStatus
5721 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5722 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5723 radioService[slotId]->checkReturnStatus(retStatus);
5724 } else {
5725 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5726 slotId);
5727 }
5728
5729 return 0;
5730}
5731
5732int radio::sendImsSmsResponse(int slotId,
5733 int responseType, int serial, RIL_Errno e, void *response,
5734 size_t responseLen) {
5735#if VDBG
5736 RLOGD("sendImsSmsResponse: serial %d", serial);
5737#endif
5738
5739 if (radioService[slotId]->mRadioResponse != NULL) {
5740 RadioResponseInfo responseInfo = {};
5741 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5742 responseLen);
5743
5744 Return<void> retStatus
5745 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5746 radioService[slotId]->checkReturnStatus(retStatus);
5747 } else {
5748 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5749 }
5750
5751 return 0;
5752}
5753
5754int radio::iccTransmitApduBasicChannelResponse(int slotId,
5755 int responseType, int serial, RIL_Errno e,
5756 void *response, size_t responseLen) {
5757#if VDBG
5758 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5759#endif
5760
5761 if (radioService[slotId]->mRadioResponse != NULL) {
5762 RadioResponseInfo responseInfo = {};
5763 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5764 responseLen);
5765
5766 Return<void> retStatus
5767 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5768 responseInfo, result);
5769 radioService[slotId]->checkReturnStatus(retStatus);
5770 } else {
5771 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5772 "== NULL", slotId);
5773 }
5774
5775 return 0;
5776}
5777
5778int radio::iccOpenLogicalChannelResponse(int slotId,
5779 int responseType, int serial, RIL_Errno e, void *response,
5780 size_t responseLen) {
5781#if VDBG
5782 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5783#endif
5784
5785 if (radioService[slotId]->mRadioResponse != NULL) {
5786 RadioResponseInfo responseInfo = {};
5787 populateResponseInfo(responseInfo, serial, responseType, e);
5788 int channelId = -1;
5789 hidl_vec<int8_t> selectResponse;
5790 int numInts = responseLen / sizeof(int);
5791 if (response == NULL || responseLen % sizeof(int) != 0) {
5792 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5793 if (response != NULL) {
5794 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5795 }
5796 } else {
5797 int *pInt = (int *) response;
5798 channelId = pInt[0];
5799 selectResponse.resize(numInts - 1);
5800 for (int i = 1; i < numInts; i++) {
5801 selectResponse[i - 1] = (int8_t) pInt[i];
5802 }
5803 }
5804 Return<void> retStatus
5805 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5806 channelId, selectResponse);
5807 radioService[slotId]->checkReturnStatus(retStatus);
5808 } else {
5809 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5810 slotId);
5811 }
5812
5813 return 0;
5814}
5815
5816int radio::iccCloseLogicalChannelResponse(int slotId,
5817 int responseType, int serial, RIL_Errno e,
5818 void *response, size_t responseLen) {
5819#if VDBG
5820 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5821#endif
5822
5823 if (radioService[slotId]->mRadioResponse != NULL) {
5824 RadioResponseInfo responseInfo = {};
5825 populateResponseInfo(responseInfo, serial, responseType, e);
5826 Return<void> retStatus
5827 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5828 responseInfo);
5829 radioService[slotId]->checkReturnStatus(retStatus);
5830 } else {
5831 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5832 slotId);
5833 }
5834
5835 return 0;
5836}
5837
5838int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5839 int responseType, int serial, RIL_Errno e,
5840 void *response, size_t responseLen) {
5841#if VDBG
5842 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5843#endif
5844
5845 if (radioService[slotId]->mRadioResponse != NULL) {
5846 RadioResponseInfo responseInfo = {};
5847 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5848 responseLen);
5849
5850 Return<void> retStatus
5851 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5852 responseInfo, result);
5853 radioService[slotId]->checkReturnStatus(retStatus);
5854 } else {
5855 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5856 "== NULL", slotId);
5857 }
5858
5859 return 0;
5860}
5861
5862int radio::nvReadItemResponse(int slotId,
5863 int responseType, int serial, RIL_Errno e,
5864 void *response, size_t responseLen) {
5865#if VDBG
5866 RLOGD("nvReadItemResponse: serial %d", serial);
5867#endif
5868
5869 if (radioService[slotId]->mRadioResponse != NULL) {
5870 RadioResponseInfo responseInfo = {};
5871 populateResponseInfo(responseInfo, serial, responseType, e);
5872 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5873 responseInfo,
5874 convertCharPtrToHidlString((char *) response));
5875 radioService[slotId]->checkReturnStatus(retStatus);
5876 } else {
5877 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5878 }
5879
5880 return 0;
5881}
5882
5883int radio::nvWriteItemResponse(int slotId,
5884 int responseType, int serial, RIL_Errno e,
5885 void *response, size_t responseLen) {
5886#if VDBG
5887 RLOGD("nvWriteItemResponse: serial %d", serial);
5888#endif
5889
5890 if (radioService[slotId]->mRadioResponse != NULL) {
5891 RadioResponseInfo responseInfo = {};
5892 populateResponseInfo(responseInfo, serial, responseType, e);
5893 Return<void> retStatus
5894 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5895 radioService[slotId]->checkReturnStatus(retStatus);
5896 } else {
5897 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5898 }
5899
5900 return 0;
5901}
5902
5903int radio::nvWriteCdmaPrlResponse(int slotId,
5904 int responseType, int serial, RIL_Errno e,
5905 void *response, size_t responseLen) {
5906#if VDBG
5907 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5908#endif
5909
5910 if (radioService[slotId]->mRadioResponse != NULL) {
5911 RadioResponseInfo responseInfo = {};
5912 populateResponseInfo(responseInfo, serial, responseType, e);
5913 Return<void> retStatus
5914 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5915 radioService[slotId]->checkReturnStatus(retStatus);
5916 } else {
5917 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5918 }
5919
5920 return 0;
5921}
5922
5923int radio::nvResetConfigResponse(int slotId,
5924 int responseType, int serial, RIL_Errno e,
5925 void *response, size_t responseLen) {
5926#if VDBG
5927 RLOGD("nvResetConfigResponse: serial %d", serial);
5928#endif
5929
5930 if (radioService[slotId]->mRadioResponse != NULL) {
5931 RadioResponseInfo responseInfo = {};
5932 populateResponseInfo(responseInfo, serial, responseType, e);
5933 Return<void> retStatus
5934 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5935 radioService[slotId]->checkReturnStatus(retStatus);
5936 } else {
5937 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5938 }
5939
5940 return 0;
5941}
5942
5943int radio::setUiccSubscriptionResponse(int slotId,
5944 int responseType, int serial, RIL_Errno e,
5945 void *response, size_t responseLen) {
5946#if VDBG
5947 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5948#endif
5949
5950 if (radioService[slotId]->mRadioResponse != NULL) {
5951 RadioResponseInfo responseInfo = {};
5952 populateResponseInfo(responseInfo, serial, responseType, e);
5953 Return<void> retStatus
5954 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5955 radioService[slotId]->checkReturnStatus(retStatus);
5956 } else {
5957 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5958 slotId);
5959 }
5960
5961 return 0;
5962}
5963
5964int radio::setDataAllowedResponse(int slotId,
5965 int responseType, int serial, RIL_Errno e,
5966 void *response, size_t responseLen) {
5967#if VDBG
5968 RLOGD("setDataAllowedResponse: serial %d", serial);
5969#endif
5970
5971 if (radioService[slotId]->mRadioResponse != NULL) {
5972 RadioResponseInfo responseInfo = {};
5973 populateResponseInfo(responseInfo, serial, responseType, e);
5974 Return<void> retStatus
5975 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5976 radioService[slotId]->checkReturnStatus(retStatus);
5977 } else {
5978 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5979 }
5980
5981 return 0;
5982}
5983
5984int radio::getHardwareConfigResponse(int slotId,
5985 int responseType, int serial, RIL_Errno e,
5986 void *response, size_t responseLen) {
5987#if VDBG
5988 RLOGD("getHardwareConfigResponse: serial %d", serial);
5989#endif
5990
5991 if (radioService[slotId]->mRadioResponse != NULL) {
5992 RadioResponseInfo responseInfo = {};
5993 populateResponseInfo(responseInfo, serial, responseType, e);
5994
5995 hidl_vec<HardwareConfig> result;
5996 if ((response == NULL && responseLen != 0)
5997 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
5998 RLOGE("hardwareConfigChangedInd: invalid response");
5999 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6000 } else {
6001 convertRilHardwareConfigListToHal(response, responseLen, result);
6002 }
6003
6004 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
6005 responseInfo, result);
6006 radioService[slotId]->checkReturnStatus(retStatus);
6007 } else {
6008 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6009 }
6010
6011 return 0;
6012}
6013
6014int radio::requestIccSimAuthenticationResponse(int slotId,
6015 int responseType, int serial, RIL_Errno e,
6016 void *response, size_t responseLen) {
6017#if VDBG
6018 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6019#endif
6020
6021 if (radioService[slotId]->mRadioResponse != NULL) {
6022 RadioResponseInfo responseInfo = {};
6023 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6024 responseLen);
6025
6026 Return<void> retStatus
6027 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6028 responseInfo, result);
6029 radioService[slotId]->checkReturnStatus(retStatus);
6030 } else {
6031 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6032 "== NULL", slotId);
6033 }
6034
6035 return 0;
6036}
6037
6038int radio::setDataProfileResponse(int slotId,
6039 int responseType, int serial, RIL_Errno e,
6040 void *response, size_t responseLen) {
6041#if VDBG
6042 RLOGD("setDataProfileResponse: serial %d", serial);
6043#endif
6044
6045 if (radioService[slotId]->mRadioResponse != NULL) {
6046 RadioResponseInfo responseInfo = {};
6047 populateResponseInfo(responseInfo, serial, responseType, e);
6048 Return<void> retStatus
6049 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6050 radioService[slotId]->checkReturnStatus(retStatus);
6051 } else {
6052 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6053 }
6054
6055 return 0;
6056}
6057
6058int radio::requestShutdownResponse(int slotId,
6059 int responseType, int serial, RIL_Errno e,
6060 void *response, size_t responseLen) {
6061#if VDBG
6062 RLOGD("requestShutdownResponse: serial %d", serial);
6063#endif
6064
6065 if (radioService[slotId]->mRadioResponse != NULL) {
6066 RadioResponseInfo responseInfo = {};
6067 populateResponseInfo(responseInfo, serial, responseType, e);
6068 Return<void> retStatus
6069 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6070 radioService[slotId]->checkReturnStatus(retStatus);
6071 } else {
6072 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6073 }
6074
6075 return 0;
6076}
6077
6078void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6079 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6080 populateResponseInfo(responseInfo, serial, responseType, e);
6081
6082 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6083 RLOGE("responseRadioCapability: Invalid response");
6084 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6085 rc.logicalModemUuid = hidl_string();
6086 } else {
6087 convertRilRadioCapabilityToHal(response, responseLen, rc);
6088 }
6089}
6090
6091int radio::getRadioCapabilityResponse(int slotId,
6092 int responseType, int serial, RIL_Errno e,
6093 void *response, size_t responseLen) {
6094#if VDBG
6095 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6096#endif
6097
6098 if (radioService[slotId]->mRadioResponse != NULL) {
6099 RadioResponseInfo responseInfo = {};
6100 RadioCapability result = {};
6101 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6102 result);
6103 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6104 responseInfo, result);
6105 radioService[slotId]->checkReturnStatus(retStatus);
6106 } else {
6107 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6108 }
6109
6110 return 0;
6111}
6112
6113int radio::setRadioCapabilityResponse(int slotId,
6114 int responseType, int serial, RIL_Errno e,
6115 void *response, size_t responseLen) {
6116#if VDBG
6117 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6118#endif
6119
6120 if (radioService[slotId]->mRadioResponse != NULL) {
6121 RadioResponseInfo responseInfo = {};
6122 RadioCapability result = {};
6123 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6124 result);
6125 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6126 responseInfo, result);
6127 radioService[slotId]->checkReturnStatus(retStatus);
6128 } else {
6129 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6130 }
6131
6132 return 0;
6133}
6134
6135LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6136 RIL_Errno e, void *response, size_t responseLen) {
6137 populateResponseInfo(responseInfo, serial, responseType, e);
6138 LceStatusInfo result = {};
6139
6140 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6141 RLOGE("Invalid response: NULL");
6142 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6143 } else {
6144 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6145 result.lceStatus = (LceStatus) resp->lce_status;
6146 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6147 }
6148 return result;
6149}
6150
6151int radio::startLceServiceResponse(int slotId,
6152 int responseType, int serial, RIL_Errno e,
6153 void *response, size_t responseLen) {
6154#if VDBG
6155 RLOGD("startLceServiceResponse: serial %d", serial);
6156#endif
6157
6158 if (radioService[slotId]->mRadioResponse != NULL) {
6159 RadioResponseInfo responseInfo = {};
6160 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6161 response, responseLen);
6162
6163 Return<void> retStatus
6164 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6165 result);
6166 radioService[slotId]->checkReturnStatus(retStatus);
6167 } else {
6168 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6169 }
6170
6171 return 0;
6172}
6173
6174int radio::stopLceServiceResponse(int slotId,
6175 int responseType, int serial, RIL_Errno e,
6176 void *response, size_t responseLen) {
6177#if VDBG
6178 RLOGD("stopLceServiceResponse: serial %d", serial);
6179#endif
6180
6181 if (radioService[slotId]->mRadioResponse != NULL) {
6182 RadioResponseInfo responseInfo = {};
6183 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6184 response, responseLen);
6185
6186 Return<void> retStatus
6187 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6188 result);
6189 radioService[slotId]->checkReturnStatus(retStatus);
6190 } else {
6191 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6192 }
6193
6194 return 0;
6195}
6196
6197int radio::pullLceDataResponse(int slotId,
6198 int responseType, int serial, RIL_Errno e,
6199 void *response, size_t responseLen) {
6200#if VDBG
6201 RLOGD("pullLceDataResponse: serial %d", serial);
6202#endif
6203
6204 if (radioService[slotId]->mRadioResponse != NULL) {
6205 RadioResponseInfo responseInfo = {};
6206 populateResponseInfo(responseInfo, serial, responseType, e);
6207
6208 LceDataInfo result = {};
6209 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6210 RLOGE("pullLceDataResponse: Invalid response");
6211 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6212 } else {
6213 convertRilLceDataInfoToHal(response, responseLen, result);
6214 }
6215
6216 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6217 responseInfo, result);
6218 radioService[slotId]->checkReturnStatus(retStatus);
6219 } else {
6220 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6221 }
6222
6223 return 0;
6224}
6225
6226int radio::getModemActivityInfoResponse(int slotId,
6227 int responseType, int serial, RIL_Errno e,
6228 void *response, size_t responseLen) {
6229#if VDBG
6230 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6231#endif
6232
6233 if (radioService[slotId]->mRadioResponse != NULL) {
6234 RadioResponseInfo responseInfo = {};
6235 populateResponseInfo(responseInfo, serial, responseType, e);
6236 ActivityStatsInfo info;
6237 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6238 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6239 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6240 } else {
6241 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6242 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6243 info.idleModeTimeMs = resp->idle_mode_time_ms;
6244 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6245 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6246 }
6247 info.rxModeTimeMs = resp->rx_mode_time_ms;
6248 }
6249
6250 Return<void> retStatus
6251 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6252 info);
6253 radioService[slotId]->checkReturnStatus(retStatus);
6254 } else {
6255 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6256 slotId);
6257 }
6258
6259 return 0;
6260}
6261
6262int radio::setAllowedCarriersResponse(int slotId,
6263 int responseType, int serial, RIL_Errno e,
6264 void *response, size_t responseLen) {
6265#if VDBG
6266 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6267#endif
6268
6269 if (radioService[slotId]->mRadioResponse != NULL) {
6270 RadioResponseInfo responseInfo = {};
6271 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6272 Return<void> retStatus
6273 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6274 ret);
6275 radioService[slotId]->checkReturnStatus(retStatus);
6276 } else {
6277 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6278 slotId);
6279 }
6280
6281 return 0;
6282}
6283
6284int radio::getAllowedCarriersResponse(int slotId,
6285 int responseType, int serial, RIL_Errno e,
6286 void *response, size_t responseLen) {
6287#if VDBG
6288 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6289#endif
6290
6291 if (radioService[slotId]->mRadioResponse != NULL) {
6292 RadioResponseInfo responseInfo = {};
6293 populateResponseInfo(responseInfo, serial, responseType, e);
6294 CarrierRestrictions carrierInfo = {};
6295 bool allAllowed = true;
6296 if (response == NULL) {
6297#if VDBG
6298 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6299#endif
6300 carrierInfo.allowedCarriers.resize(0);
6301 carrierInfo.excludedCarriers.resize(0);
6302 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6303 RLOGE("getAllowedCarriersResponse Invalid response");
6304 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6305 } else {
6306 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6307 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6308 allAllowed = false;
6309 }
6310
6311 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6312 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6313 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6314 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6315 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6316 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6317 carrierInfo.allowedCarriers[i].matchData =
6318 convertCharPtrToHidlString(carrier->match_data);
6319 }
6320
6321 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6322 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6323 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6324 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6325 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6326 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6327 carrierInfo.excludedCarriers[i].matchData =
6328 convertCharPtrToHidlString(carrier->match_data);
6329 }
6330 }
6331
6332 Return<void> retStatus
6333 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6334 allAllowed, carrierInfo);
6335 radioService[slotId]->checkReturnStatus(retStatus);
6336 } else {
6337 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6338 slotId);
6339 }
6340
6341 return 0;
6342}
6343
6344int radio::sendDeviceStateResponse(int slotId,
6345 int responseType, int serial, RIL_Errno e,
6346 void *response, size_t responselen) {
6347#if VDBG
6348 RLOGD("sendDeviceStateResponse: serial %d", serial);
6349#endif
6350
6351 if (radioService[slotId]->mRadioResponse != NULL) {
6352 RadioResponseInfo responseInfo = {};
6353 populateResponseInfo(responseInfo, serial, responseType, e);
6354 Return<void> retStatus
6355 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6356 radioService[slotId]->checkReturnStatus(retStatus);
6357 } else {
6358 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6359 }
6360
6361 return 0;
6362}
6363
6364int radio::setIndicationFilterResponse(int slotId,
6365 int responseType, int serial, RIL_Errno e,
6366 void *response, size_t responselen) {
6367#if VDBG
6368 RLOGD("setIndicationFilterResponse: serial %d", serial);
6369#endif
6370
6371 if (radioService[slotId]->mRadioResponse != NULL) {
6372 RadioResponseInfo responseInfo = {};
6373 populateResponseInfo(responseInfo, serial, responseType, e);
6374 Return<void> retStatus
6375 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6376 radioService[slotId]->checkReturnStatus(retStatus);
6377 } else {
6378 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6379 slotId);
6380 }
6381
6382 return 0;
6383}
6384
6385
6386int radio::setSimCardPowerResponse(int slotId,
6387 int responseType, int serial, RIL_Errno e,
6388 void *response, size_t responseLen) {
6389#if VDBG
6390 RLOGD("setSimCardPowerResponse: serial %d", serial);
6391#endif
6392
6393 if (radioService[slotId]->mRadioResponse != NULL) {
6394 RadioResponseInfo responseInfo = {};
6395 populateResponseInfo(responseInfo, serial, responseType, e);
6396 Return<void> retStatus
6397 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6398 radioService[slotId]->checkReturnStatus(retStatus);
6399 } else {
6400 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6401 }
6402
6403 return 0;
6404}
6405
6406int radio::sendRequestRawResponse(int slotId,
6407 int responseType, int serial, RIL_Errno e,
6408 void *response, size_t responseLen) {
6409#if VDBG
6410 RLOGD("sendRequestRawResponse: serial %d", serial);
6411#endif
6412
6413 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6414 RadioResponseInfo responseInfo = {};
6415 populateResponseInfo(responseInfo, serial, responseType, e);
6416 hidl_vec<uint8_t> data;
6417
6418 if (response == NULL) {
6419 RLOGE("sendRequestRawResponse: Invalid response");
6420 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6421 } else {
6422 data.setToExternal((uint8_t *) response, responseLen);
6423 }
6424 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6425 sendRequestRawResponse(responseInfo, data);
6426 checkReturnStatus(slotId, retStatus, false);
6427 } else {
6428 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6429 slotId);
6430 }
6431
6432 return 0;
6433}
6434
6435int radio::sendRequestStringsResponse(int slotId,
6436 int responseType, int serial, RIL_Errno e,
6437 void *response, size_t responseLen) {
6438#if VDBG
6439 RLOGD("sendRequestStringsResponse: serial %d", serial);
6440#endif
6441
6442 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6443 RadioResponseInfo responseInfo = {};
6444 populateResponseInfo(responseInfo, serial, responseType, e);
6445 hidl_vec<hidl_string> data;
6446
6447 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
6448 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6449 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6450 } else {
6451 char **resp = (char **) response;
6452 int numStrings = responseLen / sizeof(char *);
6453 data.resize(numStrings);
6454 for (int i = 0; i < numStrings; i++) {
6455 data[i] = convertCharPtrToHidlString(resp[i]);
6456 }
6457 }
6458 Return<void> retStatus
6459 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6460 responseInfo, data);
6461 checkReturnStatus(slotId, retStatus, false);
6462 } else {
6463 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6464 "NULL", slotId);
6465 }
6466
6467 return 0;
6468}
6469
6470// Radio Indication functions
6471
6472RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6473 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6474 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6475}
6476
6477int radio::radioStateChangedInd(int slotId,
6478 int indicationType, int token, RIL_Errno e, void *response,
6479 size_t responseLen) {
6480 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6481 RadioState radioState =
6482 (RadioState) CALL_ONSTATEREQUEST(slotId);
6483 RLOGD("radioStateChangedInd: radioState %d", radioState);
6484 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6485 convertIntToRadioIndicationType(indicationType), radioState);
6486 radioService[slotId]->checkReturnStatus(retStatus);
6487 } else {
6488 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6489 }
6490
6491 return 0;
6492}
6493
6494int radio::callStateChangedInd(int slotId,
6495 int indicationType, int token, RIL_Errno e, void *response,
6496 size_t responseLen) {
6497 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6498#if VDBG
6499 RLOGD("callStateChangedInd");
6500#endif
6501 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6502 convertIntToRadioIndicationType(indicationType));
6503 radioService[slotId]->checkReturnStatus(retStatus);
6504 } else {
6505 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6506 }
6507
6508 return 0;
6509}
6510
6511int radio::networkStateChangedInd(int slotId,
6512 int indicationType, int token, RIL_Errno e, void *response,
6513 size_t responseLen) {
6514 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6515#if VDBG
6516 RLOGD("networkStateChangedInd");
6517#endif
6518 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6519 convertIntToRadioIndicationType(indicationType));
6520 radioService[slotId]->checkReturnStatus(retStatus);
6521 } else {
6522 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6523 slotId);
6524 }
6525
6526 return 0;
6527}
6528
6529uint8_t hexCharToInt(uint8_t c) {
6530 if (c >= '0' && c <= '9') return (c - '0');
6531 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6532 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6533
6534 return INVALID_HEX_CHAR;
6535}
6536
6537uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6538 if (responseLen % 2 != 0) {
6539 return NULL;
6540 }
6541
6542 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6543 if (bytes == NULL) {
6544 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6545 return NULL;
6546 }
6547 uint8_t *hexString = (uint8_t *)response;
6548
6549 for (size_t i = 0; i < responseLen; i += 2) {
6550 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6551 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6552
6553 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6554 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6555 hexString[i], hexString[i + 1]);
6556 free(bytes);
6557 return NULL;
6558 }
6559 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6560 }
6561
6562 return bytes;
6563}
6564
6565int radio::newSmsInd(int slotId, int indicationType,
6566 int token, RIL_Errno e, void *response, size_t responseLen) {
6567 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6568 if (response == NULL || responseLen == 0) {
6569 RLOGE("newSmsInd: invalid response");
6570 return 0;
6571 }
6572
6573 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6574 if (bytes == NULL) {
6575 RLOGE("newSmsInd: convertHexStringToBytes failed");
6576 return 0;
6577 }
6578
6579 hidl_vec<uint8_t> pdu;
6580 pdu.setToExternal(bytes, responseLen/2);
6581#if VDBG
6582 RLOGD("newSmsInd");
6583#endif
6584 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6585 convertIntToRadioIndicationType(indicationType), pdu);
6586 radioService[slotId]->checkReturnStatus(retStatus);
6587 free(bytes);
6588 } else {
6589 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6590 }
6591
6592 return 0;
6593}
6594
6595int radio::newSmsStatusReportInd(int slotId,
6596 int indicationType, int token, RIL_Errno e, void *response,
6597 size_t responseLen) {
6598 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6599 if (response == NULL || responseLen == 0) {
6600 RLOGE("newSmsStatusReportInd: invalid response");
6601 return 0;
6602 }
6603
6604 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6605 if (bytes == NULL) {
6606 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6607 return 0;
6608 }
6609
6610 hidl_vec<uint8_t> pdu;
6611 pdu.setToExternal(bytes, responseLen/2);
6612#if VDBG
6613 RLOGD("newSmsStatusReportInd");
6614#endif
6615 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6616 convertIntToRadioIndicationType(indicationType), pdu);
6617 radioService[slotId]->checkReturnStatus(retStatus);
6618 free(bytes);
6619 } else {
6620 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6621 }
6622
6623 return 0;
6624}
6625
6626int radio::newSmsOnSimInd(int slotId, int indicationType,
6627 int token, RIL_Errno e, void *response, size_t responseLen) {
6628 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6629 if (response == NULL || responseLen != sizeof(int)) {
6630 RLOGE("newSmsOnSimInd: invalid response");
6631 return 0;
6632 }
6633 int32_t recordNumber = ((int32_t *) response)[0];
6634#if VDBG
6635 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6636#endif
6637 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6638 convertIntToRadioIndicationType(indicationType), recordNumber);
6639 radioService[slotId]->checkReturnStatus(retStatus);
6640 } else {
6641 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6642 }
6643
6644 return 0;
6645}
6646
6647int radio::onUssdInd(int slotId, int indicationType,
6648 int token, RIL_Errno e, void *response, size_t responseLen) {
6649 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6650 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6651 RLOGE("onUssdInd: invalid response");
6652 return 0;
6653 }
6654 char **strings = (char **) response;
6655 char *mode = strings[0];
6656 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6657 UssdModeType modeType = (UssdModeType) atoi(mode);
6658#if VDBG
6659 RLOGD("onUssdInd: mode %s", mode);
6660#endif
6661 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6662 convertIntToRadioIndicationType(indicationType), modeType, msg);
6663 radioService[slotId]->checkReturnStatus(retStatus);
6664 } else {
6665 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6666 }
6667
6668 return 0;
6669}
6670
6671int radio::nitzTimeReceivedInd(int slotId,
6672 int indicationType, int token, RIL_Errno e, void *response,
6673 size_t responseLen) {
6674 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6675 if (response == NULL || responseLen == 0) {
6676 RLOGE("nitzTimeReceivedInd: invalid response");
6677 return 0;
6678 }
6679 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6680 int64_t timeReceived = android::elapsedRealtime();
6681#if VDBG
6682 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6683 timeReceived);
6684#endif
6685 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6686 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6687 radioService[slotId]->checkReturnStatus(retStatus);
6688 } else {
6689 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6690 return -1;
6691 }
6692
6693 return 0;
6694}
6695
Martin Bouchet6e9a4972017-09-23 04:55:52 -03006696void convertRilSignalStrengthToHalV5(void *response, size_t responseLen,
6697 SignalStrength& signalStrength) {
6698 RIL_SignalStrength_v5 *rilSignalStrength = (RIL_SignalStrength_v5 *) response;
6699
6700 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6701 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6702 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6703 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6704 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6705 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6706 signalStrength.evdo.signalNoiseRatio =
6707 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6708 signalStrength.lte.signalStrength = 99;
6709 signalStrength.lte.rsrp = INT_MAX;
6710 signalStrength.lte.rsrq = INT_MAX;
6711 signalStrength.lte.rssnr = INT_MAX;
6712 signalStrength.lte.cqi = INT_MAX;
6713 signalStrength.lte.timingAdvance = INT_MAX;
6714 signalStrength.tdScdma.rscp = INT_MAX;
6715}
6716
6717void convertRilSignalStrengthToHalV6(void *response, size_t responseLen,
6718 SignalStrength& signalStrength) {
6719 RIL_SignalStrength_v6 *rilSignalStrength = (RIL_SignalStrength_v6 *) response;
6720
6721 // Fixup LTE for backwards compatibility
6722 // signalStrength: -1 -> 99
6723 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6724 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6725 }
6726 // rsrp: -1 -> INT_MAX all other negative value to positive.
6727 // So remap here
6728 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6729 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6730 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6731 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6732 }
6733 // rsrq: -1 -> INT_MAX
6734 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6735 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6736 }
6737 // Not remapping rssnr is already using INT_MAX
6738 // cqi: -1 -> INT_MAX
6739 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6740 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6741 }
6742
6743 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6744 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6745 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6746 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6747 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6748 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6749 signalStrength.evdo.signalNoiseRatio =
6750 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6751 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6752 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6753 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6754 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6755 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6756 signalStrength.lte.timingAdvance = INT_MAX;
6757 signalStrength.tdScdma.rscp = INT_MAX;
6758}
6759
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03006760void convertRilSignalStrengthToHalV8(void *response, size_t responseLen,
6761 SignalStrength& signalStrength) {
6762 RIL_SignalStrength_v8 *rilSignalStrength = (RIL_SignalStrength_v8 *) response;
6763
6764 // Fixup LTE for backwards compatibility
6765 // signalStrength: -1 -> 99
6766 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6767 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6768 }
6769 // rsrp: -1 -> INT_MAX all other negative value to positive.
6770 // So remap here
6771 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6772 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6773 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6774 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6775 }
6776 // rsrq: -1 -> INT_MAX
6777 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6778 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6779 }
6780 // Not remapping rssnr is already using INT_MAX
6781 // cqi: -1 -> INT_MAX
6782 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6783 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6784 }
6785
6786 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6787 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6788 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6789 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6790 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6791 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6792 signalStrength.evdo.signalNoiseRatio =
6793 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6794 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6795 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6796 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6797 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6798 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6799 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6800 signalStrength.tdScdma.rscp = INT_MAX;
6801}
6802
6803void convertRilSignalStrengthToHalV10(void *response, size_t responseLen,
6804 SignalStrength& signalStrength) {
6805 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6806
6807 // Fixup LTE for backwards compatibility
6808 // signalStrength: -1 -> 99
6809 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6810 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6811 }
6812 // rsrp: -1 -> INT_MAX all other negative value to positive.
6813 // So remap here
6814 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6815 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6816 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6817 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6818 }
6819 // rsrq: -1 -> INT_MAX
6820 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6821 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6822 }
6823 // Not remapping rssnr is already using INT_MAX
6824 // cqi: -1 -> INT_MAX
6825 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6826 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6827 }
6828
6829 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6830 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6831 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6832 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6833 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6834 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6835 signalStrength.evdo.signalNoiseRatio =
6836 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6837 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6838 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6839 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6840 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6841 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6842 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6843 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6844}
6845
6846void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6847 SignalStrength& signalStrength) {
Martin Bouchet6e9a4972017-09-23 04:55:52 -03006848 if (responseLen == sizeof(RIL_SignalStrength_v5)) {
6849 convertRilSignalStrengthToHalV5(response, responseLen, signalStrength);
6850 } else if (responseLen == sizeof(RIL_SignalStrength_v6)) {
6851 convertRilSignalStrengthToHalV6(response, responseLen, signalStrength);
6852 } else if (responseLen == sizeof(RIL_SignalStrength_v8)) {
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03006853 convertRilSignalStrengthToHalV8(response, responseLen, signalStrength);
6854 } else {
6855 convertRilSignalStrengthToHalV10(response, responseLen, signalStrength);
6856 }
6857}
6858
6859int radio::currentSignalStrengthInd(int slotId,
6860 int indicationType, int token, RIL_Errno e,
6861 void *response, size_t responseLen) {
6862 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6863 if (response == NULL || (responseLen != sizeof(RIL_SignalStrength_v10)
6864 && responseLen != sizeof(RIL_SignalStrength_v8))) {
6865 RLOGE("currentSignalStrengthInd: invalid response");
6866 return 0;
6867 }
6868
6869 SignalStrength signalStrength = {};
6870 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6871
6872#if VDBG
6873 RLOGD("currentSignalStrengthInd");
6874#endif
6875 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6876 convertIntToRadioIndicationType(indicationType), signalStrength);
6877 radioService[slotId]->checkReturnStatus(retStatus);
6878 } else {
6879 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6880 slotId);
6881 }
6882
6883 return 0;
6884}
6885
6886void convertRilDataCallToHal(RIL_Data_Call_Response_v6 *dcResponse,
6887 SetupDataCallResult& dcResult) {
6888 dcResult.status = (DataCallFailCause) dcResponse->status;
6889 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6890 dcResult.cid = dcResponse->cid;
6891 dcResult.active = dcResponse->active;
6892 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6893 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6894 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6895 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6896 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6897 dcResult.pcscf = hidl_string();
6898 dcResult.mtu = 0;
6899}
6900
6901void convertRilDataCallToHal(RIL_Data_Call_Response_v9 *dcResponse,
6902 SetupDataCallResult& dcResult) {
6903 dcResult.status = (DataCallFailCause) dcResponse->status;
6904 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6905 dcResult.cid = dcResponse->cid;
6906 dcResult.active = dcResponse->active;
6907 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6908 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6909 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6910 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6911 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6912 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6913 dcResult.mtu = 0;
6914}
6915
6916void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6917 SetupDataCallResult& dcResult) {
6918 dcResult.status = (DataCallFailCause) dcResponse->status;
6919 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6920 dcResult.cid = dcResponse->cid;
6921 dcResult.active = dcResponse->active;
6922 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6923 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6924 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6925 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6926 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6927 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6928 dcResult.mtu = dcResponse->mtu;
6929}
6930
6931void convertRilDataCallListToHal(void *response, size_t responseLen,
6932 hidl_vec<SetupDataCallResult>& dcResultList) {
6933 int num;
6934
6935 if ((responseLen % sizeof(RIL_Data_Call_Response_v11)) == 0) {
6936 num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6937 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6938 dcResultList.resize(num);
6939 for (int i = 0; i < num; i++) {
6940 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6941 }
6942 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v9)) == 0) {
6943 num = responseLen / sizeof(RIL_Data_Call_Response_v9);
6944 RIL_Data_Call_Response_v9 *dcResponse = (RIL_Data_Call_Response_v9 *) response;
6945 dcResultList.resize(num);
6946 for (int i = 0; i < num; i++) {
6947 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6948 }
6949 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v6)) == 0) {
6950 num = responseLen / sizeof(RIL_Data_Call_Response_v6);
6951 RIL_Data_Call_Response_v6 *dcResponse = (RIL_Data_Call_Response_v6 *) response;
6952 dcResultList.resize(num);
6953 for (int i = 0; i < num; i++) {
6954 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6955 }
6956 }
6957}
6958
6959int radio::dataCallListChangedInd(int slotId,
6960 int indicationType, int token, RIL_Errno e, void *response,
6961 size_t responseLen) {
6962 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6963 if ((response == NULL && responseLen != 0)
6964 || (responseLen % sizeof(RIL_Data_Call_Response_v11) != 0
6965 && responseLen % sizeof(RIL_Data_Call_Response_v9) != 0
6966 && responseLen % sizeof(RIL_Data_Call_Response_v6) != 0)) {
6967 RLOGE("dataCallListChangedInd: invalid response");
6968 return 0;
6969 }
6970 hidl_vec<SetupDataCallResult> dcList;
6971 convertRilDataCallListToHal(response, responseLen, dcList);
6972#if VDBG
6973 RLOGD("dataCallListChangedInd");
6974#endif
6975 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
6976 convertIntToRadioIndicationType(indicationType), dcList);
6977 radioService[slotId]->checkReturnStatus(retStatus);
6978 } else {
6979 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6980 }
6981
6982 return 0;
6983}
6984
6985int radio::suppSvcNotifyInd(int slotId, int indicationType,
6986 int token, RIL_Errno e, void *response, size_t responseLen) {
6987 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6988 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
6989 RLOGE("suppSvcNotifyInd: invalid response");
6990 return 0;
6991 }
6992
6993 SuppSvcNotification suppSvc = {};
6994 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6995 suppSvc.isMT = ssn->notificationType;
6996 suppSvc.code = ssn->code;
6997 suppSvc.index = ssn->index;
6998 suppSvc.type = ssn->type;
6999 suppSvc.number = convertCharPtrToHidlString(ssn->number);
7000
7001#if VDBG
7002 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
7003 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
7004#endif
7005 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
7006 convertIntToRadioIndicationType(indicationType), suppSvc);
7007 radioService[slotId]->checkReturnStatus(retStatus);
7008 } else {
7009 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7010 }
7011
7012 return 0;
7013}
7014
7015int radio::stkSessionEndInd(int slotId, int indicationType,
7016 int token, RIL_Errno e, void *response, size_t responseLen) {
7017 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7018#if VDBG
7019 RLOGD("stkSessionEndInd");
7020#endif
7021 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
7022 convertIntToRadioIndicationType(indicationType));
7023 radioService[slotId]->checkReturnStatus(retStatus);
7024 } else {
7025 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
7026 }
7027
7028 return 0;
7029}
7030
7031int radio::stkProactiveCommandInd(int slotId,
7032 int indicationType, int token, RIL_Errno e, void *response,
7033 size_t responseLen) {
7034 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7035 if (response == NULL || responseLen == 0) {
7036 RLOGE("stkProactiveCommandInd: invalid response");
7037 return 0;
7038 }
7039#if VDBG
7040 RLOGD("stkProactiveCommandInd");
7041#endif
7042 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
7043 convertIntToRadioIndicationType(indicationType),
7044 convertCharPtrToHidlString((char *) response));
7045 radioService[slotId]->checkReturnStatus(retStatus);
7046 } else {
7047 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
7048 }
7049
7050 return 0;
7051}
7052
7053int radio::stkEventNotifyInd(int slotId, int indicationType,
7054 int token, RIL_Errno e, void *response, size_t responseLen) {
7055 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7056 if (response == NULL || responseLen == 0) {
7057 RLOGE("stkEventNotifyInd: invalid response");
7058 return 0;
7059 }
7060#if VDBG
7061 RLOGD("stkEventNotifyInd");
7062#endif
7063 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
7064 convertIntToRadioIndicationType(indicationType),
7065 convertCharPtrToHidlString((char *) response));
7066 radioService[slotId]->checkReturnStatus(retStatus);
7067 } else {
7068 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7069 }
7070
7071 return 0;
7072}
7073
7074int radio::stkCallSetupInd(int slotId, int indicationType,
7075 int token, RIL_Errno e, void *response, size_t responseLen) {
7076 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7077 if (response == NULL || responseLen != sizeof(int)) {
7078 RLOGE("stkCallSetupInd: invalid response");
7079 return 0;
7080 }
7081 int32_t timeout = ((int32_t *) response)[0];
7082#if VDBG
7083 RLOGD("stkCallSetupInd: timeout %d", timeout);
7084#endif
7085 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
7086 convertIntToRadioIndicationType(indicationType), timeout);
7087 radioService[slotId]->checkReturnStatus(retStatus);
7088 } else {
7089 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
7090 }
7091
7092 return 0;
7093}
7094
7095int radio::simSmsStorageFullInd(int slotId,
7096 int indicationType, int token, RIL_Errno e, void *response,
7097 size_t responseLen) {
7098 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7099#if VDBG
7100 RLOGD("simSmsStorageFullInd");
7101#endif
7102 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
7103 convertIntToRadioIndicationType(indicationType));
7104 radioService[slotId]->checkReturnStatus(retStatus);
7105 } else {
7106 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
7107 }
7108
7109 return 0;
7110}
7111
7112int radio::simRefreshInd(int slotId, int indicationType,
7113 int token, RIL_Errno e, void *response, size_t responseLen) {
7114 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7115 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
7116 RLOGE("simRefreshInd: invalid response");
7117 return 0;
7118 }
7119
7120 SimRefreshResult refreshResult = {};
7121 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
7122 refreshResult.type =
7123 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
7124 refreshResult.efId = simRefreshResponse->ef_id;
7125 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
7126
7127#if VDBG
7128 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
7129#endif
7130 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
7131 convertIntToRadioIndicationType(indicationType), refreshResult);
7132 radioService[slotId]->checkReturnStatus(retStatus);
7133 } else {
7134 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
7135 }
7136
7137 return 0;
7138}
7139
7140void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
7141 CdmaSignalInfoRecord& record) {
7142 record.isPresent = signalInfoRecord->isPresent;
7143 record.signalType = signalInfoRecord->signalType;
7144 record.alertPitch = signalInfoRecord->alertPitch;
7145 record.signal = signalInfoRecord->signal;
7146}
7147
7148int radio::callRingInd(int slotId, int indicationType,
7149 int token, RIL_Errno e, void *response, size_t responseLen) {
7150 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7151 bool isGsm;
7152 CdmaSignalInfoRecord record = {};
7153 if (response == NULL || responseLen == 0) {
7154 isGsm = true;
7155 } else {
7156 isGsm = false;
7157 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
7158 RLOGE("callRingInd: invalid response");
7159 return 0;
7160 }
7161 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
7162 }
7163
7164#if VDBG
7165 RLOGD("callRingInd: isGsm %d", isGsm);
7166#endif
7167 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
7168 convertIntToRadioIndicationType(indicationType), isGsm, record);
7169 radioService[slotId]->checkReturnStatus(retStatus);
7170 } else {
7171 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7172 }
7173
7174 return 0;
7175}
7176
7177int radio::simStatusChangedInd(int slotId,
7178 int indicationType, int token, RIL_Errno e, void *response,
7179 size_t responseLen) {
7180 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7181#if VDBG
7182 RLOGD("simStatusChangedInd");
7183#endif
7184 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7185 convertIntToRadioIndicationType(indicationType));
7186 radioService[slotId]->checkReturnStatus(retStatus);
7187 } else {
7188 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7189 }
7190
7191 return 0;
7192}
7193
7194int radio::cdmaNewSmsInd(int slotId, int indicationType,
7195 int token, RIL_Errno e, void *response, size_t responseLen) {
7196 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7197 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7198 RLOGE("cdmaNewSmsInd: invalid response");
7199 return 0;
7200 }
7201
7202 CdmaSmsMessage msg = {};
7203 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7204 msg.teleserviceId = rilMsg->uTeleserviceID;
7205 msg.isServicePresent = rilMsg->bIsServicePresent;
7206 msg.serviceCategory = rilMsg->uServicecategory;
7207 msg.address.digitMode =
7208 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7209 msg.address.numberMode =
7210 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7211 msg.address.numberType =
7212 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7213 msg.address.numberPlan =
7214 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7215
7216 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7217 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7218
7219 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
7220 rilMsg->sSubAddress.subaddressType;
7221 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7222
7223 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7224 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7225
7226 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7227 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7228
7229#if VDBG
7230 RLOGD("cdmaNewSmsInd");
7231#endif
7232 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7233 convertIntToRadioIndicationType(indicationType), msg);
7234 radioService[slotId]->checkReturnStatus(retStatus);
7235 } else {
7236 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7237 }
7238
7239 return 0;
7240}
7241
7242int radio::newBroadcastSmsInd(int slotId,
7243 int indicationType, int token, RIL_Errno e, void *response,
7244 size_t responseLen) {
7245 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7246 if (response == NULL || responseLen == 0) {
7247 RLOGE("newBroadcastSmsInd: invalid response");
7248 return 0;
7249 }
7250
7251 hidl_vec<uint8_t> data;
7252 data.setToExternal((uint8_t *) response, responseLen);
7253#if VDBG
7254 RLOGD("newBroadcastSmsInd");
7255#endif
7256 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7257 convertIntToRadioIndicationType(indicationType), data);
7258 radioService[slotId]->checkReturnStatus(retStatus);
7259 } else {
7260 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7261 }
7262
7263 return 0;
7264}
7265
7266int radio::cdmaRuimSmsStorageFullInd(int slotId,
7267 int indicationType, int token, RIL_Errno e, void *response,
7268 size_t responseLen) {
7269 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7270#if VDBG
7271 RLOGD("cdmaRuimSmsStorageFullInd");
7272#endif
7273 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7274 convertIntToRadioIndicationType(indicationType));
7275 radioService[slotId]->checkReturnStatus(retStatus);
7276 } else {
7277 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7278 slotId);
7279 }
7280
7281 return 0;
7282}
7283
7284int radio::restrictedStateChangedInd(int slotId,
7285 int indicationType, int token, RIL_Errno e, void *response,
7286 size_t responseLen) {
7287 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7288 if (response == NULL || responseLen != sizeof(int)) {
7289 RLOGE("restrictedStateChangedInd: invalid response");
7290 return 0;
7291 }
7292 int32_t state = ((int32_t *) response)[0];
7293#if VDBG
7294 RLOGD("restrictedStateChangedInd: state %d", state);
7295#endif
7296 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7297 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7298 radioService[slotId]->checkReturnStatus(retStatus);
7299 } else {
7300 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7301 slotId);
7302 }
7303
7304 return 0;
7305}
7306
7307int radio::enterEmergencyCallbackModeInd(int slotId,
7308 int indicationType, int token, RIL_Errno e, void *response,
7309 size_t responseLen) {
7310 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7311#if VDBG
7312 RLOGD("enterEmergencyCallbackModeInd");
7313#endif
7314 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7315 convertIntToRadioIndicationType(indicationType));
7316 radioService[slotId]->checkReturnStatus(retStatus);
7317 } else {
7318 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7319 slotId);
7320 }
7321
7322 return 0;
7323}
7324
7325int radio::cdmaCallWaitingInd(int slotId,
7326 int indicationType, int token, RIL_Errno e, void *response,
7327 size_t responseLen) {
7328 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7329 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7330 RLOGE("cdmaCallWaitingInd: invalid response");
7331 return 0;
7332 }
7333
7334 CdmaCallWaiting callWaitingRecord = {};
7335 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7336 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7337 callWaitingRecord.numberPresentation =
7338 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7339 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7340 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7341 callWaitingRecord.signalInfoRecord);
7342 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7343 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7344
7345#if VDBG
7346 RLOGD("cdmaCallWaitingInd");
7347#endif
7348 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7349 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7350 radioService[slotId]->checkReturnStatus(retStatus);
7351 } else {
7352 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7353 }
7354
7355 return 0;
7356}
7357
7358int radio::cdmaOtaProvisionStatusInd(int slotId,
7359 int indicationType, int token, RIL_Errno e, void *response,
7360 size_t responseLen) {
7361 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7362 if (response == NULL || responseLen != sizeof(int)) {
7363 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7364 return 0;
7365 }
7366 int32_t status = ((int32_t *) response)[0];
7367#if VDBG
7368 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7369#endif
7370 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7371 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7372 radioService[slotId]->checkReturnStatus(retStatus);
7373 } else {
7374 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7375 slotId);
7376 }
7377
7378 return 0;
7379}
7380
7381int radio::cdmaInfoRecInd(int slotId,
7382 int indicationType, int token, RIL_Errno e, void *response,
7383 size_t responseLen) {
7384 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7385 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7386 RLOGE("cdmaInfoRecInd: invalid response");
7387 return 0;
7388 }
7389
7390 CdmaInformationRecords records = {};
7391 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7392
7393 char* string8 = NULL;
7394 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7395 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7396 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7397 "additional ones", recordsRil->numberOfInfoRecs,
7398 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7399 }
7400 records.infoRec.resize(num);
7401 for (int i = 0 ; i < num ; i++) {
7402 CdmaInformationRecord *record = &records.infoRec[i];
7403 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7404 record->name = (CdmaInfoRecName) infoRec->name;
7405 // All vectors should be size 0 except one which will be size 1. Set everything to
7406 // size 0 initially.
7407 record->display.resize(0);
7408 record->number.resize(0);
7409 record->signal.resize(0);
7410 record->redir.resize(0);
7411 record->lineCtrl.resize(0);
7412 record->clir.resize(0);
7413 record->audioCtrl.resize(0);
7414 switch (infoRec->name) {
7415 case RIL_CDMA_DISPLAY_INFO_REC:
7416 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7417 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7418 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7419 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7420 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7421 return 0;
7422 }
7423 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7424 if (string8 == NULL) {
7425 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7426 "responseCdmaInformationRecords");
7427 return 0;
7428 }
7429 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7430 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7431
7432 record->display.resize(1);
7433 record->display[0].alphaBuf = string8;
7434 free(string8);
7435 string8 = NULL;
7436 break;
7437 }
7438
7439 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7440 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7441 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7442 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7443 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7444 "expected not more than %d", (int) infoRec->rec.number.len,
7445 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7446 return 0;
7447 }
7448 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7449 if (string8 == NULL) {
7450 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7451 "responseCdmaInformationRecords");
7452 return 0;
7453 }
7454 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7455 string8[(int)infoRec->rec.number.len] = '\0';
7456
7457 record->number.resize(1);
7458 record->number[0].number = string8;
7459 free(string8);
7460 string8 = NULL;
7461 record->number[0].numberType = infoRec->rec.number.number_type;
7462 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7463 record->number[0].pi = infoRec->rec.number.pi;
7464 record->number[0].si = infoRec->rec.number.si;
7465 break;
7466 }
7467
7468 case RIL_CDMA_SIGNAL_INFO_REC: {
7469 record->signal.resize(1);
7470 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7471 record->signal[0].signalType = infoRec->rec.signal.signalType;
7472 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7473 record->signal[0].signal = infoRec->rec.signal.signal;
7474 break;
7475 }
7476
7477 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7478 if (infoRec->rec.redir.redirectingNumber.len >
7479 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7480 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7481 "expected not more than %d\n",
7482 (int)infoRec->rec.redir.redirectingNumber.len,
7483 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7484 return 0;
7485 }
7486 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7487 sizeof(char));
7488 if (string8 == NULL) {
7489 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7490 "responseCdmaInformationRecords");
7491 return 0;
7492 }
7493 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7494 infoRec->rec.redir.redirectingNumber.len);
7495 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7496
7497 record->redir.resize(1);
7498 record->redir[0].redirectingNumber.number = string8;
7499 free(string8);
7500 string8 = NULL;
7501 record->redir[0].redirectingNumber.numberType =
7502 infoRec->rec.redir.redirectingNumber.number_type;
7503 record->redir[0].redirectingNumber.numberPlan =
7504 infoRec->rec.redir.redirectingNumber.number_plan;
7505 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7506 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7507 record->redir[0].redirectingReason =
7508 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7509 break;
7510 }
7511
7512 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7513 record->lineCtrl.resize(1);
7514 record->lineCtrl[0].lineCtrlPolarityIncluded =
7515 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7516 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7517 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7518 record->lineCtrl[0].lineCtrlPowerDenial =
7519 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7520 break;
7521 }
7522
7523 case RIL_CDMA_T53_CLIR_INFO_REC: {
7524 record->clir.resize(1);
7525 record->clir[0].cause = infoRec->rec.clir.cause;
7526 break;
7527 }
7528
7529 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7530 record->audioCtrl.resize(1);
7531 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7532 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7533 break;
7534 }
7535
7536 case RIL_CDMA_T53_RELEASE_INFO_REC:
7537 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7538 return 0;
7539
7540 default:
7541 RLOGE("cdmaInfoRecInd: Incorrect name value");
7542 return 0;
7543 }
7544 }
7545
7546#if VDBG
7547 RLOGD("cdmaInfoRecInd");
7548#endif
7549 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7550 convertIntToRadioIndicationType(indicationType), records);
7551 radioService[slotId]->checkReturnStatus(retStatus);
7552 } else {
7553 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7554 }
7555
7556 return 0;
7557}
7558
7559int radio::indicateRingbackToneInd(int slotId,
7560 int indicationType, int token, RIL_Errno e, void *response,
7561 size_t responseLen) {
7562 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7563 if (response == NULL || responseLen != sizeof(int)) {
7564 RLOGE("indicateRingbackToneInd: invalid response");
7565 return 0;
7566 }
7567 bool start = ((int32_t *) response)[0];
7568#if VDBG
7569 RLOGD("indicateRingbackToneInd: start %d", start);
7570#endif
7571 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7572 convertIntToRadioIndicationType(indicationType), start);
7573 radioService[slotId]->checkReturnStatus(retStatus);
7574 } else {
7575 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7576 }
7577
7578 return 0;
7579}
7580
7581int radio::resendIncallMuteInd(int slotId,
7582 int indicationType, int token, RIL_Errno e, void *response,
7583 size_t responseLen) {
7584 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7585#if VDBG
7586 RLOGD("resendIncallMuteInd");
7587#endif
7588 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7589 convertIntToRadioIndicationType(indicationType));
7590 radioService[slotId]->checkReturnStatus(retStatus);
7591 } else {
7592 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7593 }
7594
7595 return 0;
7596}
7597
7598int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7599 int indicationType, int token, RIL_Errno e,
7600 void *response, size_t responseLen) {
7601 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7602 if (response == NULL || responseLen != sizeof(int)) {
7603 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7604 return 0;
7605 }
7606 int32_t cdmaSource = ((int32_t *) response)[0];
7607#if VDBG
7608 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7609#endif
7610 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7611 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7612 (CdmaSubscriptionSource) cdmaSource);
7613 radioService[slotId]->checkReturnStatus(retStatus);
7614 } else {
7615 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7616 slotId);
7617 }
7618
7619 return 0;
7620}
7621
7622int radio::cdmaPrlChangedInd(int slotId,
7623 int indicationType, int token, RIL_Errno e, void *response,
7624 size_t responseLen) {
7625 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7626 if (response == NULL || responseLen != sizeof(int)) {
7627 RLOGE("cdmaPrlChangedInd: invalid response");
7628 return 0;
7629 }
7630 int32_t version = ((int32_t *) response)[0];
7631#if VDBG
7632 RLOGD("cdmaPrlChangedInd: version %d", version);
7633#endif
7634 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7635 convertIntToRadioIndicationType(indicationType), version);
7636 radioService[slotId]->checkReturnStatus(retStatus);
7637 } else {
7638 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7639 }
7640
7641 return 0;
7642}
7643
7644int radio::exitEmergencyCallbackModeInd(int slotId,
7645 int indicationType, int token, RIL_Errno e, void *response,
7646 size_t responseLen) {
7647 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7648#if VDBG
7649 RLOGD("exitEmergencyCallbackModeInd");
7650#endif
7651 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7652 convertIntToRadioIndicationType(indicationType));
7653 radioService[slotId]->checkReturnStatus(retStatus);
7654 } else {
7655 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7656 slotId);
7657 }
7658
7659 return 0;
7660}
7661
7662int radio::rilConnectedInd(int slotId,
7663 int indicationType, int token, RIL_Errno e, void *response,
7664 size_t responseLen) {
7665 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7666 RLOGD("rilConnectedInd");
7667 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7668 convertIntToRadioIndicationType(indicationType));
7669 radioService[slotId]->checkReturnStatus(retStatus);
7670 } else {
7671 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7672 }
7673
7674 return 0;
7675}
7676
7677int radio::voiceRadioTechChangedInd(int slotId,
7678 int indicationType, int token, RIL_Errno e, void *response,
7679 size_t responseLen) {
7680 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7681 if (response == NULL || responseLen != sizeof(int)) {
7682 RLOGE("voiceRadioTechChangedInd: invalid response");
7683 return 0;
7684 }
7685 int32_t rat = ((int32_t *) response)[0];
7686#if VDBG
7687 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7688#endif
7689 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7690 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7691 radioService[slotId]->checkReturnStatus(retStatus);
7692 } else {
7693 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7694 slotId);
7695 }
7696
7697 return 0;
7698}
7699
7700void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7701 int num = responseLen / sizeof(RIL_CellInfo_v12);
7702 records.resize(num);
7703
7704 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7705 for (int i = 0; i < num; i++) {
7706 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7707 records[i].registered = rillCellInfo->registered;
7708 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7709 records[i].timeStamp = rillCellInfo->timeStamp;
7710 // All vectors should be size 0 except one which will be size 1. Set everything to
7711 // size 0 initially.
7712 records[i].gsm.resize(0);
7713 records[i].wcdma.resize(0);
7714 records[i].cdma.resize(0);
7715 records[i].lte.resize(0);
7716 records[i].tdscdma.resize(0);
7717 switch(rillCellInfo->cellInfoType) {
7718 case RIL_CELL_INFO_TYPE_GSM: {
7719 records[i].gsm.resize(1);
7720 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7721 cellInfoGsm->cellIdentityGsm.mcc =
7722 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7723 cellInfoGsm->cellIdentityGsm.mnc =
7724 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7725 cellInfoGsm->cellIdentityGsm.lac =
7726 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7727 cellInfoGsm->cellIdentityGsm.cid =
7728 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7729 cellInfoGsm->cellIdentityGsm.arfcn =
7730 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7731 cellInfoGsm->cellIdentityGsm.bsic =
7732 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7733 cellInfoGsm->signalStrengthGsm.signalStrength =
7734 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7735 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7736 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7737 cellInfoGsm->signalStrengthGsm.timingAdvance =
7738 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7739 break;
7740 }
7741
7742 case RIL_CELL_INFO_TYPE_WCDMA: {
7743 records[i].wcdma.resize(1);
7744 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7745 cellInfoWcdma->cellIdentityWcdma.mcc =
7746 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7747 cellInfoWcdma->cellIdentityWcdma.mnc =
7748 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7749 cellInfoWcdma->cellIdentityWcdma.lac =
7750 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7751 cellInfoWcdma->cellIdentityWcdma.cid =
7752 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7753 cellInfoWcdma->cellIdentityWcdma.psc =
7754 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7755 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7756 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7757 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7758 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7759 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7760 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7761 break;
7762 }
7763
7764 case RIL_CELL_INFO_TYPE_CDMA: {
7765 records[i].cdma.resize(1);
7766 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7767 cellInfoCdma->cellIdentityCdma.networkId =
7768 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7769 cellInfoCdma->cellIdentityCdma.systemId =
7770 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7771 cellInfoCdma->cellIdentityCdma.baseStationId =
7772 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7773 cellInfoCdma->cellIdentityCdma.longitude =
7774 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7775 cellInfoCdma->cellIdentityCdma.latitude =
7776 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7777 cellInfoCdma->signalStrengthCdma.dbm =
7778 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7779 cellInfoCdma->signalStrengthCdma.ecio =
7780 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7781 cellInfoCdma->signalStrengthEvdo.dbm =
7782 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7783 cellInfoCdma->signalStrengthEvdo.ecio =
7784 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7785 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7786 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7787 break;
7788 }
7789
7790 case RIL_CELL_INFO_TYPE_LTE: {
7791 records[i].lte.resize(1);
7792 CellInfoLte *cellInfoLte = &records[i].lte[0];
7793 cellInfoLte->cellIdentityLte.mcc =
7794 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7795 cellInfoLte->cellIdentityLte.mnc =
7796 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7797 cellInfoLte->cellIdentityLte.ci =
7798 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7799 cellInfoLte->cellIdentityLte.pci =
7800 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7801 cellInfoLte->cellIdentityLte.tac =
7802 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7803 cellInfoLte->cellIdentityLte.earfcn =
7804 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7805 cellInfoLte->signalStrengthLte.signalStrength =
7806 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7807 cellInfoLte->signalStrengthLte.rsrp =
7808 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7809 cellInfoLte->signalStrengthLte.rsrq =
7810 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7811 cellInfoLte->signalStrengthLte.rssnr =
7812 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7813 cellInfoLte->signalStrengthLte.cqi =
7814 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7815 cellInfoLte->signalStrengthLte.timingAdvance =
7816 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7817 break;
7818 }
7819
7820 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7821 records[i].tdscdma.resize(1);
7822 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7823 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7824 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7825 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7826 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7827 cellInfoTdscdma->cellIdentityTdscdma.lac =
7828 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7829 cellInfoTdscdma->cellIdentityTdscdma.cid =
7830 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7831 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7832 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7833 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7834 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7835 break;
7836 }
7837 default: {
7838 break;
7839 }
7840 }
7841 rillCellInfo += 1;
7842 }
7843}
7844
7845int radio::cellInfoListInd(int slotId,
7846 int indicationType, int token, RIL_Errno e, void *response,
7847 size_t responseLen) {
7848 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7849 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7850 RLOGE("cellInfoListInd: invalid response");
7851 return 0;
7852 }
7853
7854 hidl_vec<CellInfo> records;
7855 convertRilCellInfoListToHal(response, responseLen, records);
7856
7857#if VDBG
7858 RLOGD("cellInfoListInd");
7859#endif
7860 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7861 convertIntToRadioIndicationType(indicationType), records);
7862 radioService[slotId]->checkReturnStatus(retStatus);
7863 } else {
7864 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7865 }
7866
7867 return 0;
7868}
7869
7870int radio::imsNetworkStateChangedInd(int slotId,
7871 int indicationType, int token, RIL_Errno e, void *response,
7872 size_t responseLen) {
7873 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7874#if VDBG
7875 RLOGD("imsNetworkStateChangedInd");
7876#endif
7877 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7878 convertIntToRadioIndicationType(indicationType));
7879 radioService[slotId]->checkReturnStatus(retStatus);
7880 } else {
7881 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7882 slotId);
7883 }
7884
7885 return 0;
7886}
7887
7888int radio::subscriptionStatusChangedInd(int slotId,
7889 int indicationType, int token, RIL_Errno e, void *response,
7890 size_t responseLen) {
7891 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7892 if (response == NULL || responseLen != sizeof(int)) {
7893 RLOGE("subscriptionStatusChangedInd: invalid response");
7894 return 0;
7895 }
7896 bool activate = ((int32_t *) response)[0];
7897#if VDBG
7898 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7899#endif
7900 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
7901 convertIntToRadioIndicationType(indicationType), activate);
7902 radioService[slotId]->checkReturnStatus(retStatus);
7903 } else {
7904 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
7905 slotId);
7906 }
7907
7908 return 0;
7909}
7910
7911int radio::srvccStateNotifyInd(int slotId,
7912 int indicationType, int token, RIL_Errno e, void *response,
7913 size_t responseLen) {
7914 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7915 if (response == NULL || responseLen != sizeof(int)) {
7916 RLOGE("srvccStateNotifyInd: invalid response");
7917 return 0;
7918 }
7919 int32_t state = ((int32_t *) response)[0];
7920#if VDBG
7921 RLOGD("srvccStateNotifyInd: rat %d", state);
7922#endif
7923 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
7924 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
7925 radioService[slotId]->checkReturnStatus(retStatus);
7926 } else {
7927 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7928 }
7929
7930 return 0;
7931}
7932
7933void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7934 hidl_vec<HardwareConfig>& records) {
7935 int num = responseLen / sizeof(RIL_HardwareConfig);
7936 records.resize(num);
7937
7938 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7939 for (int i = 0; i < num; i++) {
7940 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7941 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7942 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7943 switch (rilHardwareConfig[i].type) {
7944 case RIL_HARDWARE_CONFIG_MODEM: {
7945 records[i].modem.resize(1);
7946 records[i].sim.resize(0);
7947 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7948 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7949 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7950 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7951 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7952 break;
7953 }
7954
7955 case RIL_HARDWARE_CONFIG_SIM: {
7956 records[i].sim.resize(1);
7957 records[i].modem.resize(0);
7958 records[i].sim[0].modemUuid =
7959 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7960 break;
7961 }
7962 }
7963 }
7964}
7965
7966int radio::hardwareConfigChangedInd(int slotId,
7967 int indicationType, int token, RIL_Errno e, void *response,
7968 size_t responseLen) {
7969 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7970 if ((response == NULL && responseLen != 0)
7971 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7972 RLOGE("hardwareConfigChangedInd: invalid response");
7973 return 0;
7974 }
7975
7976 hidl_vec<HardwareConfig> configs;
7977 convertRilHardwareConfigListToHal(response, responseLen, configs);
7978
7979#if VDBG
7980 RLOGD("hardwareConfigChangedInd");
7981#endif
7982 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
7983 convertIntToRadioIndicationType(indicationType), configs);
7984 radioService[slotId]->checkReturnStatus(retStatus);
7985 } else {
7986 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
7987 slotId);
7988 }
7989
7990 return 0;
7991}
7992
7993void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7994 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7995 rc.session = rilRadioCapability->session;
7996 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7997 rc.raf = rilRadioCapability->rat;
7998 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7999 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
8000}
8001
8002int radio::radioCapabilityIndicationInd(int slotId,
8003 int indicationType, int token, RIL_Errno e, void *response,
8004 size_t responseLen) {
8005 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8006 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
8007 RLOGE("radioCapabilityIndicationInd: invalid response");
8008 return 0;
8009 }
8010
8011 RadioCapability rc = {};
8012 convertRilRadioCapabilityToHal(response, responseLen, rc);
8013
8014#if VDBG
8015 RLOGD("radioCapabilityIndicationInd");
8016#endif
8017 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
8018 convertIntToRadioIndicationType(indicationType), rc);
8019 radioService[slotId]->checkReturnStatus(retStatus);
8020 } else {
8021 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
8022 slotId);
8023 }
8024
8025 return 0;
8026}
8027
8028bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
8029 if ((reqType == SS_INTERROGATION) &&
8030 (serType == SS_CFU ||
8031 serType == SS_CF_BUSY ||
8032 serType == SS_CF_NO_REPLY ||
8033 serType == SS_CF_NOT_REACHABLE ||
8034 serType == SS_CF_ALL ||
8035 serType == SS_CF_ALL_CONDITIONAL)) {
8036 return true;
8037 }
8038 return false;
8039}
8040
8041int radio::onSupplementaryServiceIndicationInd(int slotId,
8042 int indicationType, int token, RIL_Errno e,
8043 void *response, size_t responseLen) {
8044 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8045 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
8046 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
8047 return 0;
8048 }
8049
8050 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
8051 StkCcUnsolSsResult ss = {};
8052 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
8053 ss.requestType = (SsRequestType) rilSsResponse->requestType;
8054 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
8055 ss.serviceClass = rilSsResponse->serviceClass;
8056 ss.result = (RadioError) rilSsResponse->result;
8057
8058 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
8059#if VDBG
8060 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
8061 rilSsResponse->cfData.numValidIndexes);
8062#endif
8063 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
8064 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
8065 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
8066 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
8067 }
8068
8069 ss.cfData.resize(1);
8070 ss.ssInfo.resize(0);
8071
8072 /* number of call info's */
8073 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
8074
8075 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
8076 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
8077 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
8078
8079 cfInfo->status = (CallForwardInfoStatus) cf.status;
8080 cfInfo->reason = cf.reason;
8081 cfInfo->serviceClass = cf.serviceClass;
8082 cfInfo->toa = cf.toa;
8083 cfInfo->number = convertCharPtrToHidlString(cf.number);
8084 cfInfo->timeSeconds = cf.timeSeconds;
8085#if VDBG
8086 RLOGD("onSupplementaryServiceIndicationInd: "
8087 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
8088 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
8089#endif
8090 }
8091 } else {
8092 ss.ssInfo.resize(1);
8093 ss.cfData.resize(0);
8094
8095 /* each int */
8096 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
8097 for (int i = 0; i < SS_INFO_MAX; i++) {
8098#if VDBG
8099 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
8100 rilSsResponse->ssInfo[i]);
8101#endif
8102 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
8103 }
8104 }
8105
8106#if VDBG
8107 RLOGD("onSupplementaryServiceIndicationInd");
8108#endif
8109 Return<void> retStatus = radioService[slotId]->mRadioIndication->
8110 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
8111 ss);
8112 radioService[slotId]->checkReturnStatus(retStatus);
8113 } else {
8114 RLOGE("onSupplementaryServiceIndicationInd: "
8115 "radioService[%d]->mRadioIndication == NULL", slotId);
8116 }
8117
8118 return 0;
8119}
8120
8121int radio::stkCallControlAlphaNotifyInd(int slotId,
8122 int indicationType, int token, RIL_Errno e, void *response,
8123 size_t responseLen) {
8124 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8125 if (response == NULL || responseLen == 0) {
8126 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
8127 return 0;
8128 }
8129#if VDBG
8130 RLOGD("stkCallControlAlphaNotifyInd");
8131#endif
8132 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
8133 convertIntToRadioIndicationType(indicationType),
8134 convertCharPtrToHidlString((char *) response));
8135 radioService[slotId]->checkReturnStatus(retStatus);
8136 } else {
8137 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
8138 slotId);
8139 }
8140
8141 return 0;
8142}
8143
8144void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
8145 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
8146 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
8147 lce.confidenceLevel = rilLceDataInfo->confidence_level;
8148 lce.lceSuspended = rilLceDataInfo->lce_suspended;
8149}
8150
8151int radio::lceDataInd(int slotId,
8152 int indicationType, int token, RIL_Errno e, void *response,
8153 size_t responseLen) {
8154 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8155 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
8156 RLOGE("lceDataInd: invalid response");
8157 return 0;
8158 }
8159
8160 LceDataInfo lce = {};
8161 convertRilLceDataInfoToHal(response, responseLen, lce);
8162#if VDBG
8163 RLOGD("lceDataInd");
8164#endif
8165 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
8166 convertIntToRadioIndicationType(indicationType), lce);
8167 radioService[slotId]->checkReturnStatus(retStatus);
8168 } else {
8169 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8170 }
8171
8172 return 0;
8173}
8174
8175int radio::pcoDataInd(int slotId,
8176 int indicationType, int token, RIL_Errno e, void *response,
8177 size_t responseLen) {
8178 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8179 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8180 RLOGE("pcoDataInd: invalid response");
8181 return 0;
8182 }
8183
8184 PcoDataInfo pco = {};
8185 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8186 pco.cid = rilPcoData->cid;
8187 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8188 pco.pcoId = rilPcoData->pco_id;
8189 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8190
8191#if VDBG
8192 RLOGD("pcoDataInd");
8193#endif
8194 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8195 convertIntToRadioIndicationType(indicationType), pco);
8196 radioService[slotId]->checkReturnStatus(retStatus);
8197 } else {
8198 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8199 }
8200
8201 return 0;
8202}
8203
8204int radio::modemResetInd(int slotId,
8205 int indicationType, int token, RIL_Errno e, void *response,
8206 size_t responseLen) {
8207 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8208 if (response == NULL || responseLen == 0) {
8209 RLOGE("modemResetInd: invalid response");
8210 return 0;
8211 }
8212#if VDBG
8213 RLOGD("modemResetInd");
8214#endif
8215 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8216 convertIntToRadioIndicationType(indicationType),
8217 convertCharPtrToHidlString((char *) response));
8218 radioService[slotId]->checkReturnStatus(retStatus);
8219 } else {
8220 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8221 }
8222
8223 return 0;
8224}
8225
8226int radio::oemHookRawInd(int slotId,
8227 int indicationType, int token, RIL_Errno e, void *response,
8228 size_t responseLen) {
8229 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8230 if (response == NULL || responseLen == 0) {
8231 RLOGE("oemHookRawInd: invalid response");
8232 return 0;
8233 }
8234
8235 hidl_vec<uint8_t> data;
8236 data.setToExternal((uint8_t *) response, responseLen);
8237#if VDBG
8238 RLOGD("oemHookRawInd");
8239#endif
8240 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8241 convertIntToRadioIndicationType(indicationType), data);
8242 checkReturnStatus(slotId, retStatus, false);
8243 } else {
8244 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8245 }
8246
8247 return 0;
8248}
8249
8250void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8251 using namespace android::hardware;
8252 int simCount = 1;
8253 const char *serviceNames[] = {
8254 android::RIL_getServiceName()
8255 #if (SIM_COUNT >= 2)
8256 , RIL2_SERVICE_NAME
8257 #if (SIM_COUNT >= 3)
8258 , RIL3_SERVICE_NAME
8259 #if (SIM_COUNT >= 4)
8260 , RIL4_SERVICE_NAME
8261 #endif
8262 #endif
8263 #endif
8264 };
8265
8266 #if (SIM_COUNT >= 2)
8267 simCount = SIM_COUNT;
8268 #endif
8269
8270 configureRpcThreadpool(1, true /* callerWillJoin */);
8271 for (int i = 0; i < simCount; i++) {
8272 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8273 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8274 assert(ret == 0);
8275
8276 radioService[i] = new RadioImpl;
8277 radioService[i]->mSlotId = i;
8278 oemHookService[i] = new OemHookImpl;
8279 oemHookService[i]->mSlotId = i;
8280 RLOGD("registerService: starting IRadio %s", serviceNames[i]);
8281 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8282 status = oemHookService[i]->registerAsService(serviceNames[i]);
8283
8284 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8285 assert(ret == 0);
8286 }
8287
8288 s_vendorFunctions = callbacks;
8289 s_commands = commands;
8290}
8291
8292void rilc_thread_pool() {
8293 joinRpcThreadpool();
8294}
8295
8296pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8297 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8298
8299 #if (SIM_COUNT >= 2)
8300 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8301 #if (SIM_COUNT >= 3)
8302 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8303 #if (SIM_COUNT >= 4)
8304 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8305 #endif
8306 #endif
8307 #endif
8308
8309 return radioServiceRwlockPtr;
8310}