blob: 0c7a2c0fccde3850535bf6e37e3463aba2059cb8 [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)
3269 && responseLen != sizeof(RIL_SignalStrength_v8))) {
3270 RLOGE("getSignalStrengthResponse: Invalid response");
3271 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3272 } else {
3273 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3274 }
3275
3276 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3277 responseInfo, signalStrength);
3278 radioService[slotId]->checkReturnStatus(retStatus);
3279 } else {
3280 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3281 slotId);
3282 }
3283
3284 return 0;
3285}
3286
3287RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3288 if (rat == NULL) {
3289 return RIL_CELL_INFO_TYPE_NONE;
3290 }
3291
3292 int radioTech = atoi(rat);
3293
3294 switch(radioTech) {
3295
3296 case RADIO_TECH_GPRS:
3297 case RADIO_TECH_EDGE:
3298 case RADIO_TECH_GSM: {
3299 return RIL_CELL_INFO_TYPE_GSM;
3300 }
3301
3302 case RADIO_TECH_UMTS:
3303 case RADIO_TECH_HSDPA:
3304 case RADIO_TECH_HSUPA:
3305 case RADIO_TECH_HSPA:
3306 case RADIO_TECH_HSPAP: {
3307 return RIL_CELL_INFO_TYPE_WCDMA;
3308 }
3309
3310 case RADIO_TECH_IS95A:
3311 case RADIO_TECH_IS95B:
3312 case RADIO_TECH_1xRTT:
3313 case RADIO_TECH_EVDO_0:
3314 case RADIO_TECH_EVDO_A:
3315 case RADIO_TECH_EVDO_B:
3316 case RADIO_TECH_EHRPD: {
3317 return RIL_CELL_INFO_TYPE_CDMA;
3318 }
3319
3320 case RADIO_TECH_LTE:
3321 case RADIO_TECH_LTE_CA: {
3322 return RIL_CELL_INFO_TYPE_LTE;
3323 }
3324
3325 case RADIO_TECH_TD_SCDMA: {
3326 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3327 }
3328
3329 default: {
3330 break;
3331 }
3332 }
3333
3334 return RIL_CELL_INFO_TYPE_NONE;
3335
3336}
3337
3338void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3339
3340 cellIdentity.cellIdentityGsm.resize(0);
3341 cellIdentity.cellIdentityWcdma.resize(0);
3342 cellIdentity.cellIdentityCdma.resize(0);
3343 cellIdentity.cellIdentityTdscdma.resize(0);
3344 cellIdentity.cellIdentityLte.resize(0);
3345 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3346 switch(rilCellIdentity.cellInfoType) {
3347
3348 case RIL_CELL_INFO_TYPE_GSM: {
3349 cellIdentity.cellIdentityGsm.resize(1);
3350 cellIdentity.cellIdentityGsm[0].mcc =
3351 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3352 cellIdentity.cellIdentityGsm[0].mnc =
3353 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3354 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3355 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3356 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3357 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3358 break;
3359 }
3360
3361 case RIL_CELL_INFO_TYPE_WCDMA: {
3362 cellIdentity.cellIdentityWcdma.resize(1);
3363 cellIdentity.cellIdentityWcdma[0].mcc =
3364 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3365 cellIdentity.cellIdentityWcdma[0].mnc =
3366 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3367 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3368 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3369 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3370 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3371 break;
3372 }
3373
3374 case RIL_CELL_INFO_TYPE_CDMA: {
3375 cellIdentity.cellIdentityCdma.resize(1);
3376 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3377 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3378 cellIdentity.cellIdentityCdma[0].baseStationId =
3379 rilCellIdentity.cellIdentityCdma.basestationId;
3380 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3381 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3382 break;
3383 }
3384
3385 case RIL_CELL_INFO_TYPE_LTE: {
3386 cellIdentity.cellIdentityLte.resize(1);
3387 cellIdentity.cellIdentityLte[0].mcc =
3388 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3389 cellIdentity.cellIdentityLte[0].mnc =
3390 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3391 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3392 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3393 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3394 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3395 break;
3396 }
3397
3398 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3399 cellIdentity.cellIdentityTdscdma.resize(1);
3400 cellIdentity.cellIdentityTdscdma[0].mcc =
3401 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3402 cellIdentity.cellIdentityTdscdma[0].mnc =
3403 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3404 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3405 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3406 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3407 break;
3408 }
3409
3410 default: {
3411 break;
3412 }
3413 }
3414}
3415
3416int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3417 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3418 return atoi(response[index]);
3419 }
3420
3421 return -1;
3422}
3423
3424int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
3425 const int hexBase = 16;
3426 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3427 return strtol(response[index], NULL, hexBase);
3428 }
3429
3430 return -1;
3431}
3432
3433/* Fill Cell Identity info from Voice Registration State Response.
3434 * This fucntion is applicable only for RIL Version < 15.
3435 * Response is a "char **".
3436 * First and Second entries are in hex string format
3437 * and rest are integers represented in ascii format. */
3438void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3439 int numStrings, char** response) {
3440
3441 RIL_CellIdentity_v16 rilCellIdentity;
3442 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3443
3444 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3445 switch(rilCellIdentity.cellInfoType) {
3446
3447 case RIL_CELL_INFO_TYPE_GSM: {
3448 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3449 rilCellIdentity.cellIdentityGsm.lac =
3450 convertResponseHexStringEntryToInt(response, 1, numStrings);
3451
3452 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3453 rilCellIdentity.cellIdentityGsm.cid =
3454 convertResponseHexStringEntryToInt(response, 2, numStrings);
3455 break;
3456 }
3457
3458 case RIL_CELL_INFO_TYPE_WCDMA: {
3459 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3460 rilCellIdentity.cellIdentityWcdma.lac =
3461 convertResponseHexStringEntryToInt(response, 1, numStrings);
3462
3463 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3464 rilCellIdentity.cellIdentityWcdma.cid =
3465 convertResponseHexStringEntryToInt(response, 2, numStrings);
3466 rilCellIdentity.cellIdentityWcdma.psc =
3467 convertResponseStringEntryToInt(response, 14, numStrings);
3468 break;
3469 }
3470
3471 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3472 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3473 rilCellIdentity.cellIdentityTdscdma.lac =
3474 convertResponseHexStringEntryToInt(response, 1, numStrings);
3475
3476 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3477 rilCellIdentity.cellIdentityTdscdma.cid =
3478 convertResponseHexStringEntryToInt(response, 2, numStrings);
3479 break;
3480 }
3481
3482 case RIL_CELL_INFO_TYPE_CDMA:{
3483 rilCellIdentity.cellIdentityCdma.basestationId =
3484 convertResponseStringEntryToInt(response, 4, numStrings);
3485 rilCellIdentity.cellIdentityCdma.longitude =
3486 convertResponseStringEntryToInt(response, 5, numStrings);
3487 rilCellIdentity.cellIdentityCdma.latitude =
3488 convertResponseStringEntryToInt(response, 6, numStrings);
3489 rilCellIdentity.cellIdentityCdma.systemId =
3490 convertResponseStringEntryToInt(response, 8, numStrings);
3491 rilCellIdentity.cellIdentityCdma.networkId =
3492 convertResponseStringEntryToInt(response, 9, numStrings);
3493 break;
3494 }
3495
3496 case RIL_CELL_INFO_TYPE_LTE:{
3497 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
3498 rilCellIdentity.cellIdentityLte.tac =
3499 convertResponseHexStringEntryToInt(response, 1, numStrings);
3500
3501 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3502 rilCellIdentity.cellIdentityLte.ci =
3503 convertResponseHexStringEntryToInt(response, 2, numStrings);
3504 break;
3505 }
3506
3507 default: {
3508 break;
3509 }
3510 }
3511
3512 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3513}
3514
3515/* Fill Cell Identity info from Data Registration State Response.
3516 * This fucntion is applicable only for RIL Version < 15.
3517 * Response is a "char **".
3518 * First and Second entries are in hex string format
3519 * and rest are integers represented in ascii format. */
3520void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3521 int numStrings, char** response) {
3522
3523 RIL_CellIdentity_v16 rilCellIdentity;
3524 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3525
3526 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3527 switch(rilCellIdentity.cellInfoType) {
3528 case RIL_CELL_INFO_TYPE_GSM: {
3529 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3530 rilCellIdentity.cellIdentityGsm.lac =
3531 convertResponseHexStringEntryToInt(response, 1, numStrings);
3532
3533 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3534 rilCellIdentity.cellIdentityGsm.cid =
3535 convertResponseHexStringEntryToInt(response, 2, numStrings);
3536 break;
3537 }
3538 case RIL_CELL_INFO_TYPE_WCDMA: {
3539 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3540 rilCellIdentity.cellIdentityWcdma.lac =
3541 convertResponseHexStringEntryToInt(response, 1, numStrings);
3542
3543 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3544 rilCellIdentity.cellIdentityWcdma.cid =
3545 convertResponseHexStringEntryToInt(response, 2, numStrings);
3546 break;
3547 }
3548 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3549 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3550 rilCellIdentity.cellIdentityTdscdma.lac =
3551 convertResponseHexStringEntryToInt(response, 1, numStrings);
3552
3553 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3554 rilCellIdentity.cellIdentityTdscdma.cid =
3555 convertResponseHexStringEntryToInt(response, 2, numStrings);
3556 break;
3557 }
3558 case RIL_CELL_INFO_TYPE_LTE: {
3559 rilCellIdentity.cellIdentityLte.tac =
3560 convertResponseStringEntryToInt(response, 6, numStrings);
3561 rilCellIdentity.cellIdentityLte.pci =
3562 convertResponseStringEntryToInt(response, 7, numStrings);
3563 rilCellIdentity.cellIdentityLte.ci =
3564 convertResponseStringEntryToInt(response, 8, numStrings);
3565 break;
3566 }
3567 default: {
3568 break;
3569 }
3570 }
3571
3572 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3573}
3574
3575int radio::getVoiceRegistrationStateResponse(int slotId,
3576 int responseType, int serial, RIL_Errno e,
3577 void *response, size_t responseLen) {
3578#if VDBG
3579 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3580#endif
3581
3582 if (radioService[slotId]->mRadioResponse != NULL) {
3583 RadioResponseInfo responseInfo = {};
3584 populateResponseInfo(responseInfo, serial, responseType, e);
3585
3586 VoiceRegStateResult voiceRegResponse = {};
3587 int numStrings = responseLen / sizeof(char *);
3588 if (response == NULL) {
3589 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3590 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3591 } else if (s_vendorFunctions->version <= 14) {
3592 if (numStrings != 15) {
3593 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3594 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3595 } else {
3596 char **resp = (char **) response;
3597 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3598 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3599 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3600 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3601 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3602 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3603 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3604 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3605 numStrings, resp);
3606 }
3607 } else {
3608 RIL_VoiceRegistrationStateResponse *voiceRegState =
3609 (RIL_VoiceRegistrationStateResponse *)response;
3610
3611 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3612 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3613 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3614 } else {
3615 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3616 voiceRegResponse.rat = voiceRegState->rat;;
3617 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3618 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3619 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3620 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3621 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3622 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3623 voiceRegState->cellIdentity);
3624 }
3625 }
3626
3627 Return<void> retStatus =
3628 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3629 responseInfo, voiceRegResponse);
3630 radioService[slotId]->checkReturnStatus(retStatus);
3631 } else {
3632 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3633 slotId);
3634 }
3635
3636 return 0;
3637}
3638
3639int radio::getDataRegistrationStateResponse(int slotId,
3640 int responseType, int serial, RIL_Errno e,
3641 void *response, size_t responseLen) {
3642#if VDBG
3643 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3644#endif
3645
3646 if (radioService[slotId]->mRadioResponse != NULL) {
3647 RadioResponseInfo responseInfo = {};
3648 populateResponseInfo(responseInfo, serial, responseType, e);
3649 DataRegStateResult dataRegResponse = {};
3650 if (response == NULL) {
3651 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3652 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3653 } else if (s_vendorFunctions->version <= 14) {
3654 int numStrings = responseLen / sizeof(char *);
3655 if ((numStrings != 6) && (numStrings != 11)) {
3656 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3657 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3658 } else {
3659 char **resp = (char **) response;
3660 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3661 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3662 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3663 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3664 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3665 numStrings, resp);
3666 }
3667 } else {
3668 RIL_DataRegistrationStateResponse *dataRegState =
3669 (RIL_DataRegistrationStateResponse *)response;
3670
3671 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3672 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3673 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3674 } else {
3675 dataRegResponse.regState = (RegState) dataRegState->regState;
3676 dataRegResponse.rat = dataRegState->rat;;
3677 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3678 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3679 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3680 }
3681 }
3682
3683 Return<void> retStatus =
3684 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3685 dataRegResponse);
3686 radioService[slotId]->checkReturnStatus(retStatus);
3687 } else {
3688 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3689 slotId);
3690 }
3691
3692 return 0;
3693}
3694
3695int radio::getOperatorResponse(int slotId,
3696 int responseType, int serial, RIL_Errno e, void *response,
3697 size_t responseLen) {
3698#if VDBG
3699 RLOGD("getOperatorResponse: serial %d", serial);
3700#endif
3701
3702 if (radioService[slotId]->mRadioResponse != NULL) {
3703 RadioResponseInfo responseInfo = {};
3704 populateResponseInfo(responseInfo, serial, responseType, e);
3705 hidl_string longName;
3706 hidl_string shortName;
3707 hidl_string numeric;
3708 int numStrings = responseLen / sizeof(char *);
3709 if (response == NULL || numStrings != 3) {
3710 RLOGE("getOperatorResponse Invalid response: NULL");
3711 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3712
3713 } else {
3714 char **resp = (char **) response;
3715 longName = convertCharPtrToHidlString(resp[0]);
3716 shortName = convertCharPtrToHidlString(resp[1]);
3717 numeric = convertCharPtrToHidlString(resp[2]);
3718 }
3719 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3720 responseInfo, longName, shortName, numeric);
3721 radioService[slotId]->checkReturnStatus(retStatus);
3722 } else {
3723 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3724 slotId);
3725 }
3726
3727 return 0;
3728}
3729
3730int radio::setRadioPowerResponse(int slotId,
3731 int responseType, int serial, RIL_Errno e, void *response,
3732 size_t responseLen) {
3733 RLOGD("setRadioPowerResponse: serial %d", serial);
3734
3735 if (radioService[slotId]->mRadioResponse != NULL) {
3736 RadioResponseInfo responseInfo = {};
3737 populateResponseInfo(responseInfo, serial, responseType, e);
3738 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3739 responseInfo);
3740 radioService[slotId]->checkReturnStatus(retStatus);
3741 } else {
3742 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3743 slotId);
3744 }
3745
3746 return 0;
3747}
3748
3749int radio::sendDtmfResponse(int slotId,
3750 int responseType, int serial, RIL_Errno e, void *response,
3751 size_t responseLen) {
3752#if VDBG
3753 RLOGD("sendDtmfResponse: serial %d", serial);
3754#endif
3755
3756 if (radioService[slotId]->mRadioResponse != NULL) {
3757 RadioResponseInfo responseInfo = {};
3758 populateResponseInfo(responseInfo, serial, responseType, e);
3759 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3760 responseInfo);
3761 radioService[slotId]->checkReturnStatus(retStatus);
3762 } else {
3763 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3764 slotId);
3765 }
3766
3767 return 0;
3768}
3769
3770SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3771 RIL_Errno e, void *response, size_t responseLen) {
3772 populateResponseInfo(responseInfo, serial, responseType, e);
3773 SendSmsResult result = {};
3774
3775 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3776 RLOGE("Invalid response: NULL");
3777 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3778 result.ackPDU = hidl_string();
3779 } else {
3780 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3781 result.messageRef = resp->messageRef;
3782 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3783 result.errorCode = resp->errorCode;
3784 }
3785 return result;
3786}
3787
3788int radio::sendSmsResponse(int slotId,
3789 int responseType, int serial, RIL_Errno e, void *response,
3790 size_t responseLen) {
3791#if VDBG
3792 RLOGD("sendSmsResponse: serial %d", serial);
3793#endif
3794
3795 if (radioService[slotId]->mRadioResponse != NULL) {
3796 RadioResponseInfo responseInfo = {};
3797 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3798 responseLen);
3799
3800 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3801 result);
3802 radioService[slotId]->checkReturnStatus(retStatus);
3803 } else {
3804 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3805 }
3806
3807 return 0;
3808}
3809
3810int radio::sendSMSExpectMoreResponse(int slotId,
3811 int responseType, int serial, RIL_Errno e, void *response,
3812 size_t responseLen) {
3813#if VDBG
3814 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3815#endif
3816
3817 if (radioService[slotId]->mRadioResponse != NULL) {
3818 RadioResponseInfo responseInfo = {};
3819 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3820 responseLen);
3821
3822 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3823 responseInfo, result);
3824 radioService[slotId]->checkReturnStatus(retStatus);
3825 } else {
3826 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3827 }
3828
3829 return 0;
3830}
3831
3832int radio::setupDataCallResponse(int slotId,
3833 int responseType, int serial, RIL_Errno e, void *response,
3834 size_t responseLen) {
3835#if VDBG
3836 RLOGD("setupDataCallResponse: serial %d", serial);
3837#endif
3838
3839 if (radioService[slotId]->mRadioResponse != NULL) {
3840 RadioResponseInfo responseInfo = {};
3841 populateResponseInfo(responseInfo, serial, responseType, e);
3842
3843 SetupDataCallResult result = {};
3844
3845 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11) != 0
3846 && responseLen % sizeof(RIL_Data_Call_Response_v9) != 0
3847 && responseLen % sizeof(RIL_Data_Call_Response_v6) != 0)) {
3848 if (response != NULL) {
3849 RLOGE("setupDataCallResponse: Invalid response");
3850 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3851 }
3852 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3853 result.type = hidl_string();
3854 result.ifname = hidl_string();
3855 result.addresses = hidl_string();
3856 result.dnses = hidl_string();
3857 result.gateways = hidl_string();
3858 result.pcscf = hidl_string();
3859 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v11)) == 0) {
3860 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3861 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v9)) == 0) {
3862 convertRilDataCallToHal((RIL_Data_Call_Response_v9 *) response, result);
3863 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v6)) == 0) {
3864 convertRilDataCallToHal((RIL_Data_Call_Response_v6 *) response, result);
3865 }
3866
3867 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3868 responseInfo, result);
3869 radioService[slotId]->checkReturnStatus(retStatus);
3870 } else {
3871 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3872 }
3873
3874 return 0;
3875}
3876
3877IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3878 RIL_Errno e, void *response, size_t responseLen) {
3879 populateResponseInfo(responseInfo, serial, responseType, e);
3880 IccIoResult result = {};
3881
3882 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3883 RLOGE("Invalid response: NULL");
3884 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3885 result.simResponse = hidl_string();
3886 } else {
3887 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3888 result.sw1 = resp->sw1;
3889 result.sw2 = resp->sw2;
3890 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3891 }
3892 return result;
3893}
3894
3895int radio::iccIOForAppResponse(int slotId,
3896 int responseType, int serial, RIL_Errno e, void *response,
3897 size_t responseLen) {
3898#if VDBG
3899 RLOGD("iccIOForAppResponse: serial %d", serial);
3900#endif
3901
3902 if (radioService[slotId]->mRadioResponse != NULL) {
3903 RadioResponseInfo responseInfo = {};
3904 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3905 responseLen);
3906
3907 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3908 responseInfo, result);
3909 radioService[slotId]->checkReturnStatus(retStatus);
3910 } else {
3911 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3912 }
3913
3914 return 0;
3915}
3916
3917int radio::sendUssdResponse(int slotId,
3918 int responseType, int serial, RIL_Errno e, void *response,
3919 size_t responseLen) {
3920#if VDBG
3921 RLOGD("sendUssdResponse: serial %d", serial);
3922#endif
3923
3924 if (radioService[slotId]->mRadioResponse != NULL) {
3925 RadioResponseInfo responseInfo = {};
3926 populateResponseInfo(responseInfo, serial, responseType, e);
3927 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3928 responseInfo);
3929 radioService[slotId]->checkReturnStatus(retStatus);
3930 } else {
3931 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3932 slotId);
3933 }
3934
3935 return 0;
3936}
3937
3938int radio::cancelPendingUssdResponse(int slotId,
3939 int responseType, int serial, RIL_Errno e, void *response,
3940 size_t responseLen) {
3941#if VDBG
3942 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3943#endif
3944
3945 if (radioService[slotId]->mRadioResponse != NULL) {
3946 RadioResponseInfo responseInfo = {};
3947 populateResponseInfo(responseInfo, serial, responseType, e);
3948 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3949 responseInfo);
3950 radioService[slotId]->checkReturnStatus(retStatus);
3951 } else {
3952 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3953 slotId);
3954 }
3955
3956 return 0;
3957}
3958
3959int radio::getClirResponse(int slotId,
3960 int responseType, int serial, RIL_Errno e, void *response,
3961 size_t responseLen) {
3962#if VDBG
3963 RLOGD("getClirResponse: serial %d", serial);
3964#endif
3965
3966 if (radioService[slotId]->mRadioResponse != NULL) {
3967 RadioResponseInfo responseInfo = {};
3968 populateResponseInfo(responseInfo, serial, responseType, e);
3969 int n = -1, m = -1;
3970 int numInts = responseLen / sizeof(int);
3971 if (response == NULL || numInts != 2) {
3972 RLOGE("getClirResponse Invalid response: NULL");
3973 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3974 } else {
3975 int *pInt = (int *) response;
3976 n = pInt[0];
3977 m = pInt[1];
3978 }
3979 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3980 n, m);
3981 radioService[slotId]->checkReturnStatus(retStatus);
3982 } else {
3983 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3984 }
3985
3986 return 0;
3987}
3988
3989int radio::setClirResponse(int slotId,
3990 int responseType, int serial, RIL_Errno e, void *response,
3991 size_t responseLen) {
3992#if VDBG
3993 RLOGD("setClirResponse: serial %d", serial);
3994#endif
3995
3996 if (radioService[slotId]->mRadioResponse != NULL) {
3997 RadioResponseInfo responseInfo = {};
3998 populateResponseInfo(responseInfo, serial, responseType, e);
3999 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
4000 responseInfo);
4001 radioService[slotId]->checkReturnStatus(retStatus);
4002 } else {
4003 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4004 }
4005
4006 return 0;
4007}
4008
4009int radio::getCallForwardStatusResponse(int slotId,
4010 int responseType, int serial, RIL_Errno e,
4011 void *response, size_t responseLen) {
4012#if VDBG
4013 RLOGD("getCallForwardStatusResponse: serial %d", serial);
4014#endif
4015
4016 if (radioService[slotId]->mRadioResponse != NULL) {
4017 RadioResponseInfo responseInfo = {};
4018 populateResponseInfo(responseInfo, serial, responseType, e);
4019 hidl_vec<CallForwardInfo> callForwardInfos;
4020
4021 if ((response == NULL && responseLen != 0)
4022 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4023 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4024 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4025 } else {
4026 int num = responseLen / sizeof(RIL_CallForwardInfo *);
4027 callForwardInfos.resize(num);
4028 for (int i = 0 ; i < num; i++) {
4029 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4030 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4031 callForwardInfos[i].reason = resp->reason;
4032 callForwardInfos[i].serviceClass = resp->serviceClass;
4033 callForwardInfos[i].toa = resp->toa;
4034 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4035 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4036 }
4037 }
4038
4039 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4040 responseInfo, callForwardInfos);
4041 radioService[slotId]->checkReturnStatus(retStatus);
4042 } else {
4043 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4044 slotId);
4045 }
4046
4047 return 0;
4048}
4049
4050int radio::setCallForwardResponse(int slotId,
4051 int responseType, int serial, RIL_Errno e, void *response,
4052 size_t responseLen) {
4053#if VDBG
4054 RLOGD("setCallForwardResponse: serial %d", serial);
4055#endif
4056
4057 if (radioService[slotId]->mRadioResponse != NULL) {
4058 RadioResponseInfo responseInfo = {};
4059 populateResponseInfo(responseInfo, serial, responseType, e);
4060 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4061 responseInfo);
4062 radioService[slotId]->checkReturnStatus(retStatus);
4063 } else {
4064 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4065 }
4066
4067 return 0;
4068}
4069
4070int radio::getCallWaitingResponse(int slotId,
4071 int responseType, int serial, RIL_Errno e, void *response,
4072 size_t responseLen) {
4073#if VDBG
4074 RLOGD("getCallWaitingResponse: serial %d", serial);
4075#endif
4076
4077 if (radioService[slotId]->mRadioResponse != NULL) {
4078 RadioResponseInfo responseInfo = {};
4079 populateResponseInfo(responseInfo, serial, responseType, e);
4080 bool enable = false;
4081 int serviceClass = -1;
4082 int numInts = responseLen / sizeof(int);
4083 if (response == NULL || numInts != 2) {
4084 RLOGE("getCallWaitingResponse Invalid response: NULL");
4085 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4086 } else {
4087 int *pInt = (int *) response;
4088 enable = pInt[0] == 1 ? true : false;
4089 serviceClass = pInt[1];
4090 }
4091 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4092 responseInfo, enable, serviceClass);
4093 radioService[slotId]->checkReturnStatus(retStatus);
4094 } else {
4095 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4096 }
4097
4098 return 0;
4099}
4100
4101int radio::setCallWaitingResponse(int slotId,
4102 int responseType, int serial, RIL_Errno e, void *response,
4103 size_t responseLen) {
4104#if VDBG
4105 RLOGD("setCallWaitingResponse: serial %d", serial);
4106#endif
4107
4108 if (radioService[slotId]->mRadioResponse != NULL) {
4109 RadioResponseInfo responseInfo = {};
4110 populateResponseInfo(responseInfo, serial, responseType, e);
4111 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4112 responseInfo);
4113 radioService[slotId]->checkReturnStatus(retStatus);
4114 } else {
4115 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4116 }
4117
4118 return 0;
4119}
4120
4121int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4122 int responseType, int serial, RIL_Errno e,
4123 void *response, size_t responseLen) {
4124#if VDBG
4125 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4126#endif
4127
4128 if (radioService[slotId]->mRadioResponse != NULL) {
4129 RadioResponseInfo responseInfo = {};
4130 populateResponseInfo(responseInfo, serial, responseType, e);
4131 Return<void> retStatus =
4132 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4133 responseInfo);
4134 radioService[slotId]->checkReturnStatus(retStatus);
4135 } else {
4136 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4137 "== NULL", slotId);
4138 }
4139
4140 return 0;
4141}
4142
4143int radio::acceptCallResponse(int slotId,
4144 int responseType, int serial, RIL_Errno e,
4145 void *response, size_t responseLen) {
4146#if VDBG
4147 RLOGD("acceptCallResponse: serial %d", serial);
4148#endif
4149
4150 if (radioService[slotId]->mRadioResponse != NULL) {
4151 RadioResponseInfo responseInfo = {};
4152 populateResponseInfo(responseInfo, serial, responseType, e);
4153 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4154 responseInfo);
4155 radioService[slotId]->checkReturnStatus(retStatus);
4156 } else {
4157 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4158 slotId);
4159 }
4160
4161 return 0;
4162}
4163
4164int radio::deactivateDataCallResponse(int slotId,
4165 int responseType, int serial, RIL_Errno e,
4166 void *response, size_t responseLen) {
4167#if VDBG
4168 RLOGD("deactivateDataCallResponse: serial %d", serial);
4169#endif
4170
4171 if (radioService[slotId]->mRadioResponse != NULL) {
4172 RadioResponseInfo responseInfo = {};
4173 populateResponseInfo(responseInfo, serial, responseType, e);
4174 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4175 responseInfo);
4176 radioService[slotId]->checkReturnStatus(retStatus);
4177 } else {
4178 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4179 slotId);
4180 }
4181
4182 return 0;
4183}
4184
4185int radio::getFacilityLockForAppResponse(int slotId,
4186 int responseType, int serial, RIL_Errno e,
4187 void *response, size_t responseLen) {
4188#if VDBG
4189 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4190#endif
4191
4192 if (radioService[slotId]->mRadioResponse != NULL) {
4193 RadioResponseInfo responseInfo = {};
4194 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4195 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4196 getFacilityLockForAppResponse(responseInfo, ret);
4197 radioService[slotId]->checkReturnStatus(retStatus);
4198 } else {
4199 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4200 slotId);
4201 }
4202
4203 return 0;
4204}
4205
4206int radio::setFacilityLockForAppResponse(int slotId,
4207 int responseType, int serial, RIL_Errno e,
4208 void *response, size_t responseLen) {
4209#if VDBG
4210 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4211#endif
4212
4213 if (radioService[slotId]->mRadioResponse != NULL) {
4214 RadioResponseInfo responseInfo = {};
4215 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4216 Return<void> retStatus
4217 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4218 ret);
4219 radioService[slotId]->checkReturnStatus(retStatus);
4220 } else {
4221 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4222 slotId);
4223 }
4224
4225 return 0;
4226}
4227
4228int radio::setBarringPasswordResponse(int slotId,
4229 int responseType, int serial, RIL_Errno e,
4230 void *response, size_t responseLen) {
4231#if VDBG
4232 RLOGD("acceptCallResponse: serial %d", serial);
4233#endif
4234
4235 if (radioService[slotId]->mRadioResponse != NULL) {
4236 RadioResponseInfo responseInfo = {};
4237 populateResponseInfo(responseInfo, serial, responseType, e);
4238 Return<void> retStatus
4239 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4240 radioService[slotId]->checkReturnStatus(retStatus);
4241 } else {
4242 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4243 slotId);
4244 }
4245
4246 return 0;
4247}
4248
4249int radio::getNetworkSelectionModeResponse(int slotId,
4250 int responseType, int serial, RIL_Errno e, void *response,
4251 size_t responseLen) {
4252#if VDBG
4253 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4254#endif
4255
4256 if (radioService[slotId]->mRadioResponse != NULL) {
4257 RadioResponseInfo responseInfo = {};
4258 populateResponseInfo(responseInfo, serial, responseType, e);
4259 bool manual = false;
4260 int serviceClass;
4261 if (response == NULL || responseLen != sizeof(int)) {
4262 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4263 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4264 } else {
4265 int *pInt = (int *) response;
4266 manual = pInt[0] == 1 ? true : false;
4267 }
4268 Return<void> retStatus
4269 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4270 responseInfo,
4271 manual);
4272 radioService[slotId]->checkReturnStatus(retStatus);
4273 } else {
4274 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4275 slotId);
4276 }
4277
4278 return 0;
4279}
4280
4281int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4282 RIL_Errno e, void *response,
4283 size_t responseLen) {
4284#if VDBG
4285 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4286#endif
4287
4288 if (radioService[slotId]->mRadioResponse != NULL) {
4289 RadioResponseInfo responseInfo = {};
4290 populateResponseInfo(responseInfo, serial, responseType, e);
4291 Return<void> retStatus
4292 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4293 responseInfo);
4294 radioService[slotId]->checkReturnStatus(retStatus);
4295 } else {
4296 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4297 "== NULL", slotId);
4298 }
4299
4300 return 0;
4301}
4302
4303int radio::setNetworkSelectionModeManualResponse(int slotId,
4304 int responseType, int serial, RIL_Errno e,
4305 void *response, size_t responseLen) {
4306#if VDBG
4307 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4308#endif
4309
4310 if (radioService[slotId]->mRadioResponse != NULL) {
4311 RadioResponseInfo responseInfo = {};
4312 populateResponseInfo(responseInfo, serial, responseType, e);
4313 Return<void> retStatus
4314 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4315 responseInfo);
4316 radioService[slotId]->checkReturnStatus(retStatus);
4317 } else {
4318 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4319 "== NULL", slotId);
4320 }
4321
4322 return 0;
4323}
4324
4325int convertOperatorStatusToInt(const char *str) {
4326 if (strncmp("unknown", str, 9) == 0) {
4327 return (int) OperatorStatus::UNKNOWN;
4328 } else if (strncmp("available", str, 9) == 0) {
4329 return (int) OperatorStatus::AVAILABLE;
4330 } else if (strncmp("current", str, 9) == 0) {
4331 return (int) OperatorStatus::CURRENT;
4332 } else if (strncmp("forbidden", str, 9) == 0) {
4333 return (int) OperatorStatus::FORBIDDEN;
4334 } else {
4335 return -1;
4336 }
4337}
4338
4339int radio::getAvailableNetworksResponse(int slotId,
4340 int responseType, int serial, RIL_Errno e, void *response,
4341 size_t responseLen) {
4342#if VDBG
4343 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4344#endif
4345
4346 if (radioService[slotId]->mRadioResponse != NULL) {
4347 RadioResponseInfo responseInfo = {};
4348 populateResponseInfo(responseInfo, serial, responseType, e);
4349 hidl_vec<OperatorInfo> networks;
4350 if ((response == NULL && responseLen != 0)
4351 || responseLen % (4 * sizeof(char *))!= 0) {
4352 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4353 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4354 } else {
4355 char **resp = (char **) response;
4356 int numStrings = responseLen / sizeof(char *);
4357 networks.resize(numStrings/4);
4358 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4359 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4360 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4361 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4362 int status = convertOperatorStatusToInt(resp[i + 3]);
4363 if (status == -1) {
4364 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4365 } else {
4366 networks[j].status = (OperatorStatus) status;
4367 }
4368 }
4369 }
4370 Return<void> retStatus
4371 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4372 networks);
4373 radioService[slotId]->checkReturnStatus(retStatus);
4374 } else {
4375 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4376 slotId);
4377 }
4378
4379 return 0;
4380}
4381
4382int radio::startDtmfResponse(int slotId,
4383 int responseType, int serial, RIL_Errno e,
4384 void *response, size_t responseLen) {
4385#if VDBG
4386 RLOGD("startDtmfResponse: serial %d", serial);
4387#endif
4388
4389 if (radioService[slotId]->mRadioResponse != NULL) {
4390 RadioResponseInfo responseInfo = {};
4391 populateResponseInfo(responseInfo, serial, responseType, e);
4392 Return<void> retStatus
4393 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4394 radioService[slotId]->checkReturnStatus(retStatus);
4395 } else {
4396 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4397 }
4398
4399 return 0;
4400}
4401
4402int radio::stopDtmfResponse(int slotId,
4403 int responseType, int serial, RIL_Errno e,
4404 void *response, size_t responseLen) {
4405#if VDBG
4406 RLOGD("stopDtmfResponse: serial %d", serial);
4407#endif
4408
4409 if (radioService[slotId]->mRadioResponse != NULL) {
4410 RadioResponseInfo responseInfo = {};
4411 populateResponseInfo(responseInfo, serial, responseType, e);
4412 Return<void> retStatus
4413 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4414 radioService[slotId]->checkReturnStatus(retStatus);
4415 } else {
4416 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4417 }
4418
4419 return 0;
4420}
4421
4422int radio::getBasebandVersionResponse(int slotId,
4423 int responseType, int serial, RIL_Errno e,
4424 void *response, size_t responseLen) {
4425#if VDBG
4426 RLOGD("getBasebandVersionResponse: serial %d", serial);
4427#endif
4428
4429 if (radioService[slotId]->mRadioResponse != NULL) {
4430 RadioResponseInfo responseInfo = {};
4431 populateResponseInfo(responseInfo, serial, responseType, e);
4432 Return<void> retStatus
4433 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4434 convertCharPtrToHidlString((char *) response));
4435 radioService[slotId]->checkReturnStatus(retStatus);
4436 } else {
4437 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4438 }
4439
4440 return 0;
4441}
4442
4443int radio::separateConnectionResponse(int slotId,
4444 int responseType, int serial, RIL_Errno e,
4445 void *response, size_t responseLen) {
4446#if VDBG
4447 RLOGD("separateConnectionResponse: serial %d", serial);
4448#endif
4449
4450 if (radioService[slotId]->mRadioResponse != NULL) {
4451 RadioResponseInfo responseInfo = {};
4452 populateResponseInfo(responseInfo, serial, responseType, e);
4453 Return<void> retStatus
4454 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4455 radioService[slotId]->checkReturnStatus(retStatus);
4456 } else {
4457 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4458 slotId);
4459 }
4460
4461 return 0;
4462}
4463
4464int radio::setMuteResponse(int slotId,
4465 int responseType, int serial, RIL_Errno e,
4466 void *response, size_t responseLen) {
4467#if VDBG
4468 RLOGD("setMuteResponse: serial %d", serial);
4469#endif
4470
4471 if (radioService[slotId]->mRadioResponse != NULL) {
4472 RadioResponseInfo responseInfo = {};
4473 populateResponseInfo(responseInfo, serial, responseType, e);
4474 Return<void> retStatus
4475 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4476 radioService[slotId]->checkReturnStatus(retStatus);
4477 } else {
4478 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4479 }
4480
4481 return 0;
4482}
4483
4484int radio::getMuteResponse(int slotId,
4485 int responseType, int serial, RIL_Errno e, void *response,
4486 size_t responseLen) {
4487#if VDBG
4488 RLOGD("getMuteResponse: serial %d", serial);
4489#endif
4490
4491 if (radioService[slotId]->mRadioResponse != NULL) {
4492 RadioResponseInfo responseInfo = {};
4493 populateResponseInfo(responseInfo, serial, responseType, e);
4494 bool enable = false;
4495 int serviceClass;
4496 if (response == NULL || responseLen != sizeof(int)) {
4497 RLOGE("getMuteResponse Invalid response: NULL");
4498 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4499 } else {
4500 int *pInt = (int *) response;
4501 enable = pInt[0] == 1 ? true : false;
4502 }
4503 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4504 enable);
4505 radioService[slotId]->checkReturnStatus(retStatus);
4506 } else {
4507 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4508 }
4509
4510 return 0;
4511}
4512
4513int radio::getClipResponse(int slotId,
4514 int responseType, int serial, RIL_Errno e,
4515 void *response, size_t responseLen) {
4516#if VDBG
4517 RLOGD("getClipResponse: serial %d", serial);
4518#endif
4519
4520 if (radioService[slotId]->mRadioResponse != NULL) {
4521 RadioResponseInfo responseInfo = {};
4522 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4523 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4524 (ClipStatus) ret);
4525 radioService[slotId]->checkReturnStatus(retStatus);
4526 } else {
4527 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4528 }
4529
4530 return 0;
4531}
4532
4533int radio::getDataCallListResponse(int slotId,
4534 int responseType, int serial, RIL_Errno e,
4535 void *response, size_t responseLen) {
4536#if VDBG
4537 RLOGD("getDataCallListResponse: serial %d", serial);
4538#endif
4539
4540 if (radioService[slotId]->mRadioResponse != NULL) {
4541 RadioResponseInfo responseInfo = {};
4542 populateResponseInfo(responseInfo, serial, responseType, e);
4543
4544 hidl_vec<SetupDataCallResult> ret;
4545 if ((response == NULL && responseLen != 0)
4546 || (responseLen % sizeof(RIL_Data_Call_Response_v11) != 0
4547 && responseLen % sizeof(RIL_Data_Call_Response_v9) != 0
4548 && responseLen % sizeof(RIL_Data_Call_Response_v6) != 0)) {
4549 RLOGE("getDataCallListResponse: invalid response");
4550 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4551 } else {
4552 convertRilDataCallListToHal(response, responseLen, ret);
4553 }
4554
4555 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4556 responseInfo, ret);
4557 radioService[slotId]->checkReturnStatus(retStatus);
4558 } else {
4559 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4560 }
4561
4562 return 0;
4563}
4564
4565int radio::setSuppServiceNotificationsResponse(int slotId,
4566 int responseType, int serial, RIL_Errno e,
4567 void *response, size_t responseLen) {
4568#if VDBG
4569 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4570#endif
4571
4572 if (radioService[slotId]->mRadioResponse != NULL) {
4573 RadioResponseInfo responseInfo = {};
4574 populateResponseInfo(responseInfo, serial, responseType, e);
4575 Return<void> retStatus
4576 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4577 responseInfo);
4578 radioService[slotId]->checkReturnStatus(retStatus);
4579 } else {
4580 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4581 "== NULL", slotId);
4582 }
4583
4584 return 0;
4585}
4586
4587int radio::deleteSmsOnSimResponse(int slotId,
4588 int responseType, int serial, RIL_Errno e,
4589 void *response, size_t responseLen) {
4590#if VDBG
4591 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4592#endif
4593
4594 if (radioService[slotId]->mRadioResponse != NULL) {
4595 RadioResponseInfo responseInfo = {};
4596 populateResponseInfo(responseInfo, serial, responseType, e);
4597 Return<void> retStatus
4598 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4599 radioService[slotId]->checkReturnStatus(retStatus);
4600 } else {
4601 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4602 }
4603
4604 return 0;
4605}
4606
4607int radio::setBandModeResponse(int slotId,
4608 int responseType, int serial, RIL_Errno e,
4609 void *response, size_t responseLen) {
4610#if VDBG
4611 RLOGD("setBandModeResponse: serial %d", serial);
4612#endif
4613
4614 if (radioService[slotId]->mRadioResponse != NULL) {
4615 RadioResponseInfo responseInfo = {};
4616 populateResponseInfo(responseInfo, serial, responseType, e);
4617 Return<void> retStatus
4618 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4619 radioService[slotId]->checkReturnStatus(retStatus);
4620 } else {
4621 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4622 }
4623
4624 return 0;
4625}
4626
4627int radio::writeSmsToSimResponse(int slotId,
4628 int responseType, int serial, RIL_Errno e,
4629 void *response, size_t responseLen) {
4630#if VDBG
4631 RLOGD("writeSmsToSimResponse: serial %d", serial);
4632#endif
4633
4634 if (radioService[slotId]->mRadioResponse != NULL) {
4635 RadioResponseInfo responseInfo = {};
4636 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4637 Return<void> retStatus
4638 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4639 radioService[slotId]->checkReturnStatus(retStatus);
4640 } else {
4641 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4642 }
4643
4644 return 0;
4645}
4646
4647int radio::getAvailableBandModesResponse(int slotId,
4648 int responseType, int serial, RIL_Errno e, void *response,
4649 size_t responseLen) {
4650#if VDBG
4651 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4652#endif
4653
4654 if (radioService[slotId]->mRadioResponse != NULL) {
4655 RadioResponseInfo responseInfo = {};
4656 populateResponseInfo(responseInfo, serial, responseType, e);
4657 hidl_vec<RadioBandMode> modes;
4658 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
4659 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4660 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4661 } else {
4662 int *pInt = (int *) response;
4663 int numInts = responseLen / sizeof(int);
4664 modes.resize(numInts);
4665 for (int i = 0; i < numInts; i++) {
4666 modes[i] = (RadioBandMode) pInt[i];
4667 }
4668 }
4669 Return<void> retStatus
4670 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4671 modes);
4672 radioService[slotId]->checkReturnStatus(retStatus);
4673 } else {
4674 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4675 slotId);
4676 }
4677
4678 return 0;
4679}
4680
4681int radio::sendEnvelopeResponse(int slotId,
4682 int responseType, int serial, RIL_Errno e,
4683 void *response, size_t responseLen) {
4684#if VDBG
4685 RLOGD("sendEnvelopeResponse: serial %d", serial);
4686#endif
4687
4688 if (radioService[slotId]->mRadioResponse != NULL) {
4689 RadioResponseInfo responseInfo = {};
4690 populateResponseInfo(responseInfo, serial, responseType, e);
4691 Return<void> retStatus
4692 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4693 convertCharPtrToHidlString((char *) response));
4694 radioService[slotId]->checkReturnStatus(retStatus);
4695 } else {
4696 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4697 }
4698
4699 return 0;
4700}
4701
4702int radio::sendTerminalResponseToSimResponse(int slotId,
4703 int responseType, int serial, RIL_Errno e,
4704 void *response, size_t responseLen) {
4705#if VDBG
4706 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4707#endif
4708
4709 if (radioService[slotId]->mRadioResponse != NULL) {
4710 RadioResponseInfo responseInfo = {};
4711 populateResponseInfo(responseInfo, serial, responseType, e);
4712 Return<void> retStatus
4713 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4714 responseInfo);
4715 radioService[slotId]->checkReturnStatus(retStatus);
4716 } else {
4717 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4718 slotId);
4719 }
4720
4721 return 0;
4722}
4723
4724int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4725 int responseType, int serial,
4726 RIL_Errno e, void *response,
4727 size_t responseLen) {
4728#if VDBG
4729 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4730#endif
4731
4732 if (radioService[slotId]->mRadioResponse != NULL) {
4733 RadioResponseInfo responseInfo = {};
4734 populateResponseInfo(responseInfo, serial, responseType, e);
4735 Return<void> retStatus
4736 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4737 responseInfo);
4738 radioService[slotId]->checkReturnStatus(retStatus);
4739 } else {
4740 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4741 "== NULL", slotId);
4742 }
4743
4744 return 0;
4745}
4746
4747int radio::explicitCallTransferResponse(int slotId,
4748 int responseType, int serial, RIL_Errno e,
4749 void *response, size_t responseLen) {
4750#if VDBG
4751 RLOGD("explicitCallTransferResponse: serial %d", serial);
4752#endif
4753
4754 if (radioService[slotId]->mRadioResponse != NULL) {
4755 RadioResponseInfo responseInfo = {};
4756 populateResponseInfo(responseInfo, serial, responseType, e);
4757 Return<void> retStatus
4758 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4759 radioService[slotId]->checkReturnStatus(retStatus);
4760 } else {
4761 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4762 slotId);
4763 }
4764
4765 return 0;
4766}
4767
4768int radio::setPreferredNetworkTypeResponse(int slotId,
4769 int responseType, int serial, RIL_Errno e,
4770 void *response, size_t responseLen) {
4771#if VDBG
4772 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4773#endif
4774
4775 if (radioService[slotId]->mRadioResponse != NULL) {
4776 RadioResponseInfo responseInfo = {};
4777 populateResponseInfo(responseInfo, serial, responseType, e);
4778 Return<void> retStatus
4779 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4780 responseInfo);
4781 radioService[slotId]->checkReturnStatus(retStatus);
4782 } else {
4783 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4784 slotId);
4785 }
4786
4787 return 0;
4788}
4789
4790
4791int radio::getPreferredNetworkTypeResponse(int slotId,
4792 int responseType, int serial, RIL_Errno e,
4793 void *response, size_t responseLen) {
4794#if VDBG
4795 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4796#endif
4797
4798 if (radioService[slotId]->mRadioResponse != NULL) {
4799 RadioResponseInfo responseInfo = {};
4800 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4801 Return<void> retStatus
4802 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4803 responseInfo, (PreferredNetworkType) ret);
4804 radioService[slotId]->checkReturnStatus(retStatus);
4805 } else {
4806 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4807 slotId);
4808 }
4809
4810 return 0;
4811}
4812
4813int radio::getNeighboringCidsResponse(int slotId,
4814 int responseType, int serial, RIL_Errno e,
4815 void *response, size_t responseLen) {
4816#if VDBG
4817 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4818#endif
4819
4820 if (radioService[slotId]->mRadioResponse != NULL) {
4821 RadioResponseInfo responseInfo = {};
4822 populateResponseInfo(responseInfo, serial, responseType, e);
4823 hidl_vec<NeighboringCell> cells;
4824
4825 if ((response == NULL && responseLen != 0)
4826 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4827 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4828 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4829 } else {
4830 int num = responseLen / sizeof(RIL_NeighboringCell *);
4831 cells.resize(num);
4832 for (int i = 0 ; i < num; i++) {
4833 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4834 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4835 cells[i].rssi = resp->rssi;
4836 }
4837 }
4838
4839 Return<void> retStatus
4840 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4841 cells);
4842 radioService[slotId]->checkReturnStatus(retStatus);
4843 } else {
4844 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4845 slotId);
4846 }
4847
4848 return 0;
4849}
4850
4851int radio::setLocationUpdatesResponse(int slotId,
4852 int responseType, int serial, RIL_Errno e,
4853 void *response, size_t responseLen) {
4854#if VDBG
4855 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4856#endif
4857
4858 if (radioService[slotId]->mRadioResponse != NULL) {
4859 RadioResponseInfo responseInfo = {};
4860 populateResponseInfo(responseInfo, serial, responseType, e);
4861 Return<void> retStatus
4862 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4863 radioService[slotId]->checkReturnStatus(retStatus);
4864 } else {
4865 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4866 slotId);
4867 }
4868
4869 return 0;
4870}
4871
4872int radio::setCdmaSubscriptionSourceResponse(int slotId,
4873 int responseType, int serial, RIL_Errno e,
4874 void *response, size_t responseLen) {
4875#if VDBG
4876 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4877#endif
4878
4879 if (radioService[slotId]->mRadioResponse != NULL) {
4880 RadioResponseInfo responseInfo = {};
4881 populateResponseInfo(responseInfo, serial, responseType, e);
4882 Return<void> retStatus
4883 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4884 responseInfo);
4885 radioService[slotId]->checkReturnStatus(retStatus);
4886 } else {
4887 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4888 slotId);
4889 }
4890
4891 return 0;
4892}
4893
4894int radio::setCdmaRoamingPreferenceResponse(int slotId,
4895 int responseType, int serial, RIL_Errno e,
4896 void *response, size_t responseLen) {
4897#if VDBG
4898 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4899#endif
4900
4901 if (radioService[slotId]->mRadioResponse != NULL) {
4902 RadioResponseInfo responseInfo = {};
4903 populateResponseInfo(responseInfo, serial, responseType, e);
4904 Return<void> retStatus
4905 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4906 responseInfo);
4907 radioService[slotId]->checkReturnStatus(retStatus);
4908 } else {
4909 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4910 slotId);
4911 }
4912
4913 return 0;
4914}
4915
4916int radio::getCdmaRoamingPreferenceResponse(int slotId,
4917 int responseType, int serial, RIL_Errno e,
4918 void *response, size_t responseLen) {
4919#if VDBG
4920 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4921#endif
4922
4923 if (radioService[slotId]->mRadioResponse != NULL) {
4924 RadioResponseInfo responseInfo = {};
4925 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4926 Return<void> retStatus
4927 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4928 responseInfo, (CdmaRoamingType) ret);
4929 radioService[slotId]->checkReturnStatus(retStatus);
4930 } else {
4931 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4932 slotId);
4933 }
4934
4935 return 0;
4936}
4937
4938int radio::setTTYModeResponse(int slotId,
4939 int responseType, int serial, RIL_Errno e,
4940 void *response, size_t responseLen) {
4941#if VDBG
4942 RLOGD("setTTYModeResponse: serial %d", serial);
4943#endif
4944
4945 if (radioService[slotId]->mRadioResponse != NULL) {
4946 RadioResponseInfo responseInfo = {};
4947 populateResponseInfo(responseInfo, serial, responseType, e);
4948 Return<void> retStatus
4949 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4950 radioService[slotId]->checkReturnStatus(retStatus);
4951 } else {
4952 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4953 }
4954
4955 return 0;
4956}
4957
4958int radio::getTTYModeResponse(int slotId,
4959 int responseType, int serial, RIL_Errno e,
4960 void *response, size_t responseLen) {
4961#if VDBG
4962 RLOGD("getTTYModeResponse: serial %d", serial);
4963#endif
4964
4965 if (radioService[slotId]->mRadioResponse != NULL) {
4966 RadioResponseInfo responseInfo = {};
4967 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4968 Return<void> retStatus
4969 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4970 (TtyMode) ret);
4971 radioService[slotId]->checkReturnStatus(retStatus);
4972 } else {
4973 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4974 }
4975
4976 return 0;
4977}
4978
4979int radio::setPreferredVoicePrivacyResponse(int slotId,
4980 int responseType, int serial, RIL_Errno e,
4981 void *response, size_t responseLen) {
4982#if VDBG
4983 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
4984#endif
4985
4986 if (radioService[slotId]->mRadioResponse != NULL) {
4987 RadioResponseInfo responseInfo = {};
4988 populateResponseInfo(responseInfo, serial, responseType, e);
4989 Return<void> retStatus
4990 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4991 responseInfo);
4992 radioService[slotId]->checkReturnStatus(retStatus);
4993 } else {
4994 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4995 slotId);
4996 }
4997
4998 return 0;
4999}
5000
5001int radio::getPreferredVoicePrivacyResponse(int slotId,
5002 int responseType, int serial, RIL_Errno e,
5003 void *response, size_t responseLen) {
5004#if VDBG
5005 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
5006#endif
5007
5008 if (radioService[slotId]->mRadioResponse != NULL) {
5009 RadioResponseInfo responseInfo = {};
5010 populateResponseInfo(responseInfo, serial, responseType, e);
5011 bool enable = false;
5012 int numInts = responseLen / sizeof(int);
5013 if (response == NULL || numInts != 1) {
5014 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
5015 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5016 } else {
5017 int *pInt = (int *) response;
5018 enable = pInt[0] == 1 ? true : false;
5019 }
5020 Return<void> retStatus
5021 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5022 responseInfo, enable);
5023 radioService[slotId]->checkReturnStatus(retStatus);
5024 } else {
5025 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5026 slotId);
5027 }
5028
5029 return 0;
5030}
5031
5032int radio::sendCDMAFeatureCodeResponse(int slotId,
5033 int responseType, int serial, RIL_Errno e,
5034 void *response, size_t responseLen) {
5035#if VDBG
5036 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5037#endif
5038
5039 if (radioService[slotId]->mRadioResponse != NULL) {
5040 RadioResponseInfo responseInfo = {};
5041 populateResponseInfo(responseInfo, serial, responseType, e);
5042 Return<void> retStatus
5043 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5044 radioService[slotId]->checkReturnStatus(retStatus);
5045 } else {
5046 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5047 slotId);
5048 }
5049
5050 return 0;
5051}
5052
5053int radio::sendBurstDtmfResponse(int slotId,
5054 int responseType, int serial, RIL_Errno e,
5055 void *response, size_t responseLen) {
5056#if VDBG
5057 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5058#endif
5059
5060 if (radioService[slotId]->mRadioResponse != NULL) {
5061 RadioResponseInfo responseInfo = {};
5062 populateResponseInfo(responseInfo, serial, responseType, e);
5063 Return<void> retStatus
5064 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5065 radioService[slotId]->checkReturnStatus(retStatus);
5066 } else {
5067 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5068 }
5069
5070 return 0;
5071}
5072
5073int radio::sendCdmaSmsResponse(int slotId,
5074 int responseType, int serial, RIL_Errno e, void *response,
5075 size_t responseLen) {
5076#if VDBG
5077 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5078#endif
5079
5080 if (radioService[slotId]->mRadioResponse != NULL) {
5081 RadioResponseInfo responseInfo = {};
5082 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5083 responseLen);
5084
5085 Return<void> retStatus
5086 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5087 radioService[slotId]->checkReturnStatus(retStatus);
5088 } else {
5089 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5090 }
5091
5092 return 0;
5093}
5094
5095int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5096 int responseType, int serial, RIL_Errno e,
5097 void *response, size_t responseLen) {
5098#if VDBG
5099 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5100#endif
5101
5102 if (radioService[slotId]->mRadioResponse != NULL) {
5103 RadioResponseInfo responseInfo = {};
5104 populateResponseInfo(responseInfo, serial, responseType, e);
5105 Return<void> retStatus
5106 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5107 responseInfo);
5108 radioService[slotId]->checkReturnStatus(retStatus);
5109 } else {
5110 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5111 "== NULL", slotId);
5112 }
5113
5114 return 0;
5115}
5116
5117int radio::getGsmBroadcastConfigResponse(int slotId,
5118 int responseType, int serial, RIL_Errno e,
5119 void *response, size_t responseLen) {
5120#if VDBG
5121 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5122#endif
5123
5124 if (radioService[slotId]->mRadioResponse != NULL) {
5125 RadioResponseInfo responseInfo = {};
5126 populateResponseInfo(responseInfo, serial, responseType, e);
5127 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5128
5129 if ((response == NULL && responseLen != 0)
5130 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5131 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5132 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5133 } else {
5134 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5135 configs.resize(num);
5136 for (int i = 0 ; i < num; i++) {
5137 RIL_GSM_BroadcastSmsConfigInfo *resp =
5138 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5139 configs[i].fromServiceId = resp->fromServiceId;
5140 configs[i].toServiceId = resp->toServiceId;
5141 configs[i].fromCodeScheme = resp->fromCodeScheme;
5142 configs[i].toCodeScheme = resp->toCodeScheme;
5143 configs[i].selected = resp->selected == 1 ? true : false;
5144 }
5145 }
5146
5147 Return<void> retStatus
5148 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5149 configs);
5150 radioService[slotId]->checkReturnStatus(retStatus);
5151 } else {
5152 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5153 slotId);
5154 }
5155
5156 return 0;
5157}
5158
5159int radio::setGsmBroadcastConfigResponse(int slotId,
5160 int responseType, int serial, RIL_Errno e,
5161 void *response, size_t responseLen) {
5162#if VDBG
5163 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5164#endif
5165
5166 if (radioService[slotId]->mRadioResponse != NULL) {
5167 RadioResponseInfo responseInfo = {};
5168 populateResponseInfo(responseInfo, serial, responseType, e);
5169 Return<void> retStatus
5170 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5171 radioService[slotId]->checkReturnStatus(retStatus);
5172 } else {
5173 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5174 slotId);
5175 }
5176
5177 return 0;
5178}
5179
5180int radio::setGsmBroadcastActivationResponse(int slotId,
5181 int responseType, int serial, RIL_Errno e,
5182 void *response, size_t responseLen) {
5183#if VDBG
5184 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5185#endif
5186
5187 if (radioService[slotId]->mRadioResponse != NULL) {
5188 RadioResponseInfo responseInfo = {};
5189 populateResponseInfo(responseInfo, serial, responseType, e);
5190 Return<void> retStatus
5191 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5192 responseInfo);
5193 radioService[slotId]->checkReturnStatus(retStatus);
5194 } else {
5195 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5196 slotId);
5197 }
5198
5199 return 0;
5200}
5201
5202int radio::getCdmaBroadcastConfigResponse(int slotId,
5203 int responseType, int serial, RIL_Errno e,
5204 void *response, size_t responseLen) {
5205#if VDBG
5206 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5207#endif
5208
5209 if (radioService[slotId]->mRadioResponse != NULL) {
5210 RadioResponseInfo responseInfo = {};
5211 populateResponseInfo(responseInfo, serial, responseType, e);
5212 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5213
5214 if ((response == NULL && responseLen != 0)
5215 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5216 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5217 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5218 } else {
5219 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5220 configs.resize(num);
5221 for (int i = 0 ; i < num; i++) {
5222 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5223 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5224 configs[i].serviceCategory = resp->service_category;
5225 configs[i].language = resp->language;
5226 configs[i].selected = resp->selected == 1 ? true : false;
5227 }
5228 }
5229
5230 Return<void> retStatus
5231 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5232 configs);
5233 radioService[slotId]->checkReturnStatus(retStatus);
5234 } else {
5235 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5236 slotId);
5237 }
5238
5239 return 0;
5240}
5241
5242int radio::setCdmaBroadcastConfigResponse(int slotId,
5243 int responseType, int serial, RIL_Errno e,
5244 void *response, size_t responseLen) {
5245#if VDBG
5246 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5247#endif
5248
5249 if (radioService[slotId]->mRadioResponse != NULL) {
5250 RadioResponseInfo responseInfo = {};
5251 populateResponseInfo(responseInfo, serial, responseType, e);
5252 Return<void> retStatus
5253 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5254 responseInfo);
5255 radioService[slotId]->checkReturnStatus(retStatus);
5256 } else {
5257 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5258 slotId);
5259 }
5260
5261 return 0;
5262}
5263
5264int radio::setCdmaBroadcastActivationResponse(int slotId,
5265 int responseType, int serial, RIL_Errno e,
5266 void *response, size_t responseLen) {
5267#if VDBG
5268 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5269#endif
5270
5271 if (radioService[slotId]->mRadioResponse != NULL) {
5272 RadioResponseInfo responseInfo = {};
5273 populateResponseInfo(responseInfo, serial, responseType, e);
5274 Return<void> retStatus
5275 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5276 responseInfo);
5277 radioService[slotId]->checkReturnStatus(retStatus);
5278 } else {
5279 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5280 slotId);
5281 }
5282
5283 return 0;
5284}
5285
5286int radio::getCDMASubscriptionResponse(int slotId,
5287 int responseType, int serial, RIL_Errno e, void *response,
5288 size_t responseLen) {
5289#if VDBG
5290 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5291#endif
5292
5293 if (radioService[slotId]->mRadioResponse != NULL) {
5294 RadioResponseInfo responseInfo = {};
5295 populateResponseInfo(responseInfo, serial, responseType, e);
5296
5297 int numStrings = responseLen / sizeof(char *);
5298 hidl_string emptyString;
5299 if (response == NULL || numStrings != 5) {
5300 RLOGE("getOperatorResponse Invalid response: NULL");
5301 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5302 Return<void> retStatus
5303 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5304 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5305 radioService[slotId]->checkReturnStatus(retStatus);
5306 } else {
5307 char **resp = (char **) response;
5308 Return<void> retStatus
5309 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5310 responseInfo,
5311 convertCharPtrToHidlString(resp[0]),
5312 convertCharPtrToHidlString(resp[1]),
5313 convertCharPtrToHidlString(resp[2]),
5314 convertCharPtrToHidlString(resp[3]),
5315 convertCharPtrToHidlString(resp[4]));
5316 radioService[slotId]->checkReturnStatus(retStatus);
5317 }
5318 } else {
5319 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5320 slotId);
5321 }
5322
5323 return 0;
5324}
5325
5326int radio::writeSmsToRuimResponse(int slotId,
5327 int responseType, int serial, RIL_Errno e,
5328 void *response, size_t responseLen) {
5329#if VDBG
5330 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5331#endif
5332
5333 if (radioService[slotId]->mRadioResponse != NULL) {
5334 RadioResponseInfo responseInfo = {};
5335 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5336 Return<void> retStatus
5337 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5338 radioService[slotId]->checkReturnStatus(retStatus);
5339 } else {
5340 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5341 }
5342
5343 return 0;
5344}
5345
5346int radio::deleteSmsOnRuimResponse(int slotId,
5347 int responseType, int serial, RIL_Errno e,
5348 void *response, size_t responseLen) {
5349#if VDBG
5350 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5351#endif
5352
5353 if (radioService[slotId]->mRadioResponse != NULL) {
5354 RadioResponseInfo responseInfo = {};
5355 populateResponseInfo(responseInfo, serial, responseType, e);
5356 Return<void> retStatus
5357 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5358 radioService[slotId]->checkReturnStatus(retStatus);
5359 } else {
5360 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5361 }
5362
5363 return 0;
5364}
5365
5366int radio::getDeviceIdentityResponse(int slotId,
5367 int responseType, int serial, RIL_Errno e, void *response,
5368 size_t responseLen) {
5369#if VDBG
5370 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5371#endif
5372
5373 if (radioService[slotId]->mRadioResponse != NULL) {
5374 RadioResponseInfo responseInfo = {};
5375 populateResponseInfo(responseInfo, serial, responseType, e);
5376
5377 int numStrings = responseLen / sizeof(char *);
5378 hidl_string emptyString;
5379 if (response == NULL || numStrings != 4) {
5380 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5381 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5382 Return<void> retStatus
5383 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5384 emptyString, emptyString, emptyString, emptyString);
5385 radioService[slotId]->checkReturnStatus(retStatus);
5386 } else {
5387 char **resp = (char **) response;
5388 Return<void> retStatus
5389 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5390 convertCharPtrToHidlString(resp[0]),
5391 convertCharPtrToHidlString(resp[1]),
5392 convertCharPtrToHidlString(resp[2]),
5393 convertCharPtrToHidlString(resp[3]));
5394 radioService[slotId]->checkReturnStatus(retStatus);
5395 }
5396 } else {
5397 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5398 slotId);
5399 }
5400
5401 return 0;
5402}
5403
5404int radio::exitEmergencyCallbackModeResponse(int slotId,
5405 int responseType, int serial, RIL_Errno e,
5406 void *response, size_t responseLen) {
5407#if VDBG
5408 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5409#endif
5410
5411 if (radioService[slotId]->mRadioResponse != NULL) {
5412 RadioResponseInfo responseInfo = {};
5413 populateResponseInfo(responseInfo, serial, responseType, e);
5414 Return<void> retStatus
5415 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5416 responseInfo);
5417 radioService[slotId]->checkReturnStatus(retStatus);
5418 } else {
5419 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5420 slotId);
5421 }
5422
5423 return 0;
5424}
5425
5426int radio::getSmscAddressResponse(int slotId,
5427 int responseType, int serial, RIL_Errno e,
5428 void *response, size_t responseLen) {
5429#if VDBG
5430 RLOGD("getSmscAddressResponse: serial %d", serial);
5431#endif
5432
5433 if (radioService[slotId]->mRadioResponse != NULL) {
5434 RadioResponseInfo responseInfo = {};
5435 populateResponseInfo(responseInfo, serial, responseType, e);
5436 Return<void> retStatus
5437 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5438 convertCharPtrToHidlString((char *) response));
5439 radioService[slotId]->checkReturnStatus(retStatus);
5440 } else {
5441 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5442 }
5443
5444 return 0;
5445}
5446
5447int radio::setSmscAddressResponse(int slotId,
5448 int responseType, int serial, RIL_Errno e,
5449 void *response, size_t responseLen) {
5450#if VDBG
5451 RLOGD("setSmscAddressResponse: serial %d", serial);
5452#endif
5453
5454 if (radioService[slotId]->mRadioResponse != NULL) {
5455 RadioResponseInfo responseInfo = {};
5456 populateResponseInfo(responseInfo, serial, responseType, e);
5457 Return<void> retStatus
5458 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5459 radioService[slotId]->checkReturnStatus(retStatus);
5460 } else {
5461 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5462 }
5463
5464 return 0;
5465}
5466
5467int radio::reportSmsMemoryStatusResponse(int slotId,
5468 int responseType, int serial, RIL_Errno e,
5469 void *response, size_t responseLen) {
5470#if VDBG
5471 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5472#endif
5473
5474 if (radioService[slotId]->mRadioResponse != NULL) {
5475 RadioResponseInfo responseInfo = {};
5476 populateResponseInfo(responseInfo, serial, responseType, e);
5477 Return<void> retStatus
5478 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5479 radioService[slotId]->checkReturnStatus(retStatus);
5480 } else {
5481 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5482 slotId);
5483 }
5484
5485 return 0;
5486}
5487
5488int radio::reportStkServiceIsRunningResponse(int slotId,
5489 int responseType, int serial, RIL_Errno e,
5490 void *response, size_t responseLen) {
5491#if VDBG
5492 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5493#endif
5494
5495 if (radioService[slotId]->mRadioResponse != NULL) {
5496 RadioResponseInfo responseInfo = {};
5497 populateResponseInfo(responseInfo, serial, responseType, e);
5498 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5499 reportStkServiceIsRunningResponse(responseInfo);
5500 radioService[slotId]->checkReturnStatus(retStatus);
5501 } else {
5502 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5503 slotId);
5504 }
5505
5506 return 0;
5507}
5508
5509int radio::getCdmaSubscriptionSourceResponse(int slotId,
5510 int responseType, int serial, RIL_Errno e,
5511 void *response, size_t responseLen) {
5512#if VDBG
5513 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5514#endif
5515
5516 if (radioService[slotId]->mRadioResponse != NULL) {
5517 RadioResponseInfo responseInfo = {};
5518 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5519 Return<void> retStatus
5520 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5521 responseInfo, (CdmaSubscriptionSource) ret);
5522 radioService[slotId]->checkReturnStatus(retStatus);
5523 } else {
5524 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5525 slotId);
5526 }
5527
5528 return 0;
5529}
5530
5531int radio::requestIsimAuthenticationResponse(int slotId,
5532 int responseType, int serial, RIL_Errno e,
5533 void *response, size_t responseLen) {
5534#if VDBG
5535 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5536#endif
5537
5538 if (radioService[slotId]->mRadioResponse != NULL) {
5539 RadioResponseInfo responseInfo = {};
5540 populateResponseInfo(responseInfo, serial, responseType, e);
5541 Return<void> retStatus
5542 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5543 responseInfo,
5544 convertCharPtrToHidlString((char *) response));
5545 radioService[slotId]->checkReturnStatus(retStatus);
5546 } else {
5547 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5548 slotId);
5549 }
5550
5551 return 0;
5552}
5553
5554int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5555 int responseType,
5556 int serial, RIL_Errno e, void *response,
5557 size_t responseLen) {
5558#if VDBG
5559 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5560#endif
5561
5562 if (radioService[slotId]->mRadioResponse != NULL) {
5563 RadioResponseInfo responseInfo = {};
5564 populateResponseInfo(responseInfo, serial, responseType, e);
5565 Return<void> retStatus
5566 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5567 responseInfo);
5568 radioService[slotId]->checkReturnStatus(retStatus);
5569 } else {
5570 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5571 "== NULL", slotId);
5572 }
5573
5574 return 0;
5575}
5576
5577int radio::sendEnvelopeWithStatusResponse(int slotId,
5578 int responseType, int serial, RIL_Errno e, void *response,
5579 size_t responseLen) {
5580#if VDBG
5581 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5582#endif
5583
5584 if (radioService[slotId]->mRadioResponse != NULL) {
5585 RadioResponseInfo responseInfo = {};
5586 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5587 response, responseLen);
5588
5589 Return<void> retStatus
5590 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5591 result);
5592 radioService[slotId]->checkReturnStatus(retStatus);
5593 } else {
5594 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5595 slotId);
5596 }
5597
5598 return 0;
5599}
5600
5601int radio::getVoiceRadioTechnologyResponse(int slotId,
5602 int responseType, int serial, RIL_Errno e,
5603 void *response, size_t responseLen) {
5604#if VDBG
5605 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5606#endif
5607
5608 if (radioService[slotId]->mRadioResponse != NULL) {
5609 RadioResponseInfo responseInfo = {};
5610 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5611 Return<void> retStatus
5612 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5613 responseInfo, (RadioTechnology) ret);
5614 radioService[slotId]->checkReturnStatus(retStatus);
5615 } else {
5616 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5617 slotId);
5618 }
5619
5620 return 0;
5621}
5622
5623int radio::getCellInfoListResponse(int slotId,
5624 int responseType,
5625 int serial, RIL_Errno e, void *response,
5626 size_t responseLen) {
5627#if VDBG
5628 RLOGD("getCellInfoListResponse: serial %d", serial);
5629#endif
5630
5631 if (radioService[slotId]->mRadioResponse != NULL) {
5632 RadioResponseInfo responseInfo = {};
5633 populateResponseInfo(responseInfo, serial, responseType, e);
5634
5635 hidl_vec<CellInfo> ret;
5636 if ((response == NULL && responseLen != 0)
5637 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5638 RLOGE("getCellInfoListResponse: Invalid response");
5639 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5640 } else {
5641 convertRilCellInfoListToHal(response, responseLen, ret);
5642 }
5643
5644 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5645 responseInfo, ret);
5646 radioService[slotId]->checkReturnStatus(retStatus);
5647 } else {
5648 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5649 }
5650
5651 return 0;
5652}
5653
5654int radio::setCellInfoListRateResponse(int slotId,
5655 int responseType,
5656 int serial, RIL_Errno e, void *response,
5657 size_t responseLen) {
5658#if VDBG
5659 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5660#endif
5661
5662 if (radioService[slotId]->mRadioResponse != NULL) {
5663 RadioResponseInfo responseInfo = {};
5664 populateResponseInfo(responseInfo, serial, responseType, e);
5665 Return<void> retStatus
5666 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5667 radioService[slotId]->checkReturnStatus(retStatus);
5668 } else {
5669 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5670 slotId);
5671 }
5672
5673 return 0;
5674}
5675
5676int radio::setInitialAttachApnResponse(int slotId,
5677 int responseType, int serial, RIL_Errno e,
5678 void *response, size_t responseLen) {
5679#if VDBG
5680 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5681#endif
5682
5683 if (radioService[slotId]->mRadioResponse != NULL) {
5684 RadioResponseInfo responseInfo = {};
5685 populateResponseInfo(responseInfo, serial, responseType, e);
5686 Return<void> retStatus
5687 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5688 radioService[slotId]->checkReturnStatus(retStatus);
5689 } else {
5690 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5691 slotId);
5692 }
5693
5694 return 0;
5695}
5696
5697int radio::getImsRegistrationStateResponse(int slotId,
5698 int responseType, int serial, RIL_Errno e,
5699 void *response, size_t responseLen) {
5700#if VDBG
5701 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5702#endif
5703
5704 if (radioService[slotId]->mRadioResponse != NULL) {
5705 RadioResponseInfo responseInfo = {};
5706 populateResponseInfo(responseInfo, serial, responseType, e);
5707 bool isRegistered = false;
5708 int ratFamily = 0;
5709 int numInts = responseLen / sizeof(int);
5710 if (response == NULL || numInts != 2) {
5711 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5712 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5713 } else {
5714 int *pInt = (int *) response;
5715 isRegistered = pInt[0] == 1 ? true : false;
5716 ratFamily = pInt[1];
5717 }
5718 Return<void> retStatus
5719 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5720 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5721 radioService[slotId]->checkReturnStatus(retStatus);
5722 } else {
5723 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5724 slotId);
5725 }
5726
5727 return 0;
5728}
5729
5730int radio::sendImsSmsResponse(int slotId,
5731 int responseType, int serial, RIL_Errno e, void *response,
5732 size_t responseLen) {
5733#if VDBG
5734 RLOGD("sendImsSmsResponse: serial %d", serial);
5735#endif
5736
5737 if (radioService[slotId]->mRadioResponse != NULL) {
5738 RadioResponseInfo responseInfo = {};
5739 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5740 responseLen);
5741
5742 Return<void> retStatus
5743 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5744 radioService[slotId]->checkReturnStatus(retStatus);
5745 } else {
5746 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5747 }
5748
5749 return 0;
5750}
5751
5752int radio::iccTransmitApduBasicChannelResponse(int slotId,
5753 int responseType, int serial, RIL_Errno e,
5754 void *response, size_t responseLen) {
5755#if VDBG
5756 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5757#endif
5758
5759 if (radioService[slotId]->mRadioResponse != NULL) {
5760 RadioResponseInfo responseInfo = {};
5761 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5762 responseLen);
5763
5764 Return<void> retStatus
5765 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5766 responseInfo, result);
5767 radioService[slotId]->checkReturnStatus(retStatus);
5768 } else {
5769 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5770 "== NULL", slotId);
5771 }
5772
5773 return 0;
5774}
5775
5776int radio::iccOpenLogicalChannelResponse(int slotId,
5777 int responseType, int serial, RIL_Errno e, void *response,
5778 size_t responseLen) {
5779#if VDBG
5780 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5781#endif
5782
5783 if (radioService[slotId]->mRadioResponse != NULL) {
5784 RadioResponseInfo responseInfo = {};
5785 populateResponseInfo(responseInfo, serial, responseType, e);
5786 int channelId = -1;
5787 hidl_vec<int8_t> selectResponse;
5788 int numInts = responseLen / sizeof(int);
5789 if (response == NULL || responseLen % sizeof(int) != 0) {
5790 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5791 if (response != NULL) {
5792 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5793 }
5794 } else {
5795 int *pInt = (int *) response;
5796 channelId = pInt[0];
5797 selectResponse.resize(numInts - 1);
5798 for (int i = 1; i < numInts; i++) {
5799 selectResponse[i - 1] = (int8_t) pInt[i];
5800 }
5801 }
5802 Return<void> retStatus
5803 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5804 channelId, selectResponse);
5805 radioService[slotId]->checkReturnStatus(retStatus);
5806 } else {
5807 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5808 slotId);
5809 }
5810
5811 return 0;
5812}
5813
5814int radio::iccCloseLogicalChannelResponse(int slotId,
5815 int responseType, int serial, RIL_Errno e,
5816 void *response, size_t responseLen) {
5817#if VDBG
5818 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5819#endif
5820
5821 if (radioService[slotId]->mRadioResponse != NULL) {
5822 RadioResponseInfo responseInfo = {};
5823 populateResponseInfo(responseInfo, serial, responseType, e);
5824 Return<void> retStatus
5825 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5826 responseInfo);
5827 radioService[slotId]->checkReturnStatus(retStatus);
5828 } else {
5829 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5830 slotId);
5831 }
5832
5833 return 0;
5834}
5835
5836int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5837 int responseType, int serial, RIL_Errno e,
5838 void *response, size_t responseLen) {
5839#if VDBG
5840 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5841#endif
5842
5843 if (radioService[slotId]->mRadioResponse != NULL) {
5844 RadioResponseInfo responseInfo = {};
5845 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5846 responseLen);
5847
5848 Return<void> retStatus
5849 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5850 responseInfo, result);
5851 radioService[slotId]->checkReturnStatus(retStatus);
5852 } else {
5853 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5854 "== NULL", slotId);
5855 }
5856
5857 return 0;
5858}
5859
5860int radio::nvReadItemResponse(int slotId,
5861 int responseType, int serial, RIL_Errno e,
5862 void *response, size_t responseLen) {
5863#if VDBG
5864 RLOGD("nvReadItemResponse: serial %d", serial);
5865#endif
5866
5867 if (radioService[slotId]->mRadioResponse != NULL) {
5868 RadioResponseInfo responseInfo = {};
5869 populateResponseInfo(responseInfo, serial, responseType, e);
5870 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5871 responseInfo,
5872 convertCharPtrToHidlString((char *) response));
5873 radioService[slotId]->checkReturnStatus(retStatus);
5874 } else {
5875 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5876 }
5877
5878 return 0;
5879}
5880
5881int radio::nvWriteItemResponse(int slotId,
5882 int responseType, int serial, RIL_Errno e,
5883 void *response, size_t responseLen) {
5884#if VDBG
5885 RLOGD("nvWriteItemResponse: serial %d", serial);
5886#endif
5887
5888 if (radioService[slotId]->mRadioResponse != NULL) {
5889 RadioResponseInfo responseInfo = {};
5890 populateResponseInfo(responseInfo, serial, responseType, e);
5891 Return<void> retStatus
5892 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5893 radioService[slotId]->checkReturnStatus(retStatus);
5894 } else {
5895 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5896 }
5897
5898 return 0;
5899}
5900
5901int radio::nvWriteCdmaPrlResponse(int slotId,
5902 int responseType, int serial, RIL_Errno e,
5903 void *response, size_t responseLen) {
5904#if VDBG
5905 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5906#endif
5907
5908 if (radioService[slotId]->mRadioResponse != NULL) {
5909 RadioResponseInfo responseInfo = {};
5910 populateResponseInfo(responseInfo, serial, responseType, e);
5911 Return<void> retStatus
5912 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5913 radioService[slotId]->checkReturnStatus(retStatus);
5914 } else {
5915 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5916 }
5917
5918 return 0;
5919}
5920
5921int radio::nvResetConfigResponse(int slotId,
5922 int responseType, int serial, RIL_Errno e,
5923 void *response, size_t responseLen) {
5924#if VDBG
5925 RLOGD("nvResetConfigResponse: serial %d", serial);
5926#endif
5927
5928 if (radioService[slotId]->mRadioResponse != NULL) {
5929 RadioResponseInfo responseInfo = {};
5930 populateResponseInfo(responseInfo, serial, responseType, e);
5931 Return<void> retStatus
5932 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5933 radioService[slotId]->checkReturnStatus(retStatus);
5934 } else {
5935 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5936 }
5937
5938 return 0;
5939}
5940
5941int radio::setUiccSubscriptionResponse(int slotId,
5942 int responseType, int serial, RIL_Errno e,
5943 void *response, size_t responseLen) {
5944#if VDBG
5945 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5946#endif
5947
5948 if (radioService[slotId]->mRadioResponse != NULL) {
5949 RadioResponseInfo responseInfo = {};
5950 populateResponseInfo(responseInfo, serial, responseType, e);
5951 Return<void> retStatus
5952 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5953 radioService[slotId]->checkReturnStatus(retStatus);
5954 } else {
5955 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5956 slotId);
5957 }
5958
5959 return 0;
5960}
5961
5962int radio::setDataAllowedResponse(int slotId,
5963 int responseType, int serial, RIL_Errno e,
5964 void *response, size_t responseLen) {
5965#if VDBG
5966 RLOGD("setDataAllowedResponse: serial %d", serial);
5967#endif
5968
5969 if (radioService[slotId]->mRadioResponse != NULL) {
5970 RadioResponseInfo responseInfo = {};
5971 populateResponseInfo(responseInfo, serial, responseType, e);
5972 Return<void> retStatus
5973 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5974 radioService[slotId]->checkReturnStatus(retStatus);
5975 } else {
5976 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5977 }
5978
5979 return 0;
5980}
5981
5982int radio::getHardwareConfigResponse(int slotId,
5983 int responseType, int serial, RIL_Errno e,
5984 void *response, size_t responseLen) {
5985#if VDBG
5986 RLOGD("getHardwareConfigResponse: serial %d", serial);
5987#endif
5988
5989 if (radioService[slotId]->mRadioResponse != NULL) {
5990 RadioResponseInfo responseInfo = {};
5991 populateResponseInfo(responseInfo, serial, responseType, e);
5992
5993 hidl_vec<HardwareConfig> result;
5994 if ((response == NULL && responseLen != 0)
5995 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
5996 RLOGE("hardwareConfigChangedInd: invalid response");
5997 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5998 } else {
5999 convertRilHardwareConfigListToHal(response, responseLen, result);
6000 }
6001
6002 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
6003 responseInfo, result);
6004 radioService[slotId]->checkReturnStatus(retStatus);
6005 } else {
6006 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6007 }
6008
6009 return 0;
6010}
6011
6012int radio::requestIccSimAuthenticationResponse(int slotId,
6013 int responseType, int serial, RIL_Errno e,
6014 void *response, size_t responseLen) {
6015#if VDBG
6016 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6017#endif
6018
6019 if (radioService[slotId]->mRadioResponse != NULL) {
6020 RadioResponseInfo responseInfo = {};
6021 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6022 responseLen);
6023
6024 Return<void> retStatus
6025 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6026 responseInfo, result);
6027 radioService[slotId]->checkReturnStatus(retStatus);
6028 } else {
6029 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6030 "== NULL", slotId);
6031 }
6032
6033 return 0;
6034}
6035
6036int radio::setDataProfileResponse(int slotId,
6037 int responseType, int serial, RIL_Errno e,
6038 void *response, size_t responseLen) {
6039#if VDBG
6040 RLOGD("setDataProfileResponse: serial %d", serial);
6041#endif
6042
6043 if (radioService[slotId]->mRadioResponse != NULL) {
6044 RadioResponseInfo responseInfo = {};
6045 populateResponseInfo(responseInfo, serial, responseType, e);
6046 Return<void> retStatus
6047 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6048 radioService[slotId]->checkReturnStatus(retStatus);
6049 } else {
6050 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6051 }
6052
6053 return 0;
6054}
6055
6056int radio::requestShutdownResponse(int slotId,
6057 int responseType, int serial, RIL_Errno e,
6058 void *response, size_t responseLen) {
6059#if VDBG
6060 RLOGD("requestShutdownResponse: serial %d", serial);
6061#endif
6062
6063 if (radioService[slotId]->mRadioResponse != NULL) {
6064 RadioResponseInfo responseInfo = {};
6065 populateResponseInfo(responseInfo, serial, responseType, e);
6066 Return<void> retStatus
6067 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6068 radioService[slotId]->checkReturnStatus(retStatus);
6069 } else {
6070 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6071 }
6072
6073 return 0;
6074}
6075
6076void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6077 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6078 populateResponseInfo(responseInfo, serial, responseType, e);
6079
6080 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6081 RLOGE("responseRadioCapability: Invalid response");
6082 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6083 rc.logicalModemUuid = hidl_string();
6084 } else {
6085 convertRilRadioCapabilityToHal(response, responseLen, rc);
6086 }
6087}
6088
6089int radio::getRadioCapabilityResponse(int slotId,
6090 int responseType, int serial, RIL_Errno e,
6091 void *response, size_t responseLen) {
6092#if VDBG
6093 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6094#endif
6095
6096 if (radioService[slotId]->mRadioResponse != NULL) {
6097 RadioResponseInfo responseInfo = {};
6098 RadioCapability result = {};
6099 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6100 result);
6101 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6102 responseInfo, result);
6103 radioService[slotId]->checkReturnStatus(retStatus);
6104 } else {
6105 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6106 }
6107
6108 return 0;
6109}
6110
6111int radio::setRadioCapabilityResponse(int slotId,
6112 int responseType, int serial, RIL_Errno e,
6113 void *response, size_t responseLen) {
6114#if VDBG
6115 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6116#endif
6117
6118 if (radioService[slotId]->mRadioResponse != NULL) {
6119 RadioResponseInfo responseInfo = {};
6120 RadioCapability result = {};
6121 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6122 result);
6123 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6124 responseInfo, result);
6125 radioService[slotId]->checkReturnStatus(retStatus);
6126 } else {
6127 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6128 }
6129
6130 return 0;
6131}
6132
6133LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6134 RIL_Errno e, void *response, size_t responseLen) {
6135 populateResponseInfo(responseInfo, serial, responseType, e);
6136 LceStatusInfo result = {};
6137
6138 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6139 RLOGE("Invalid response: NULL");
6140 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6141 } else {
6142 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6143 result.lceStatus = (LceStatus) resp->lce_status;
6144 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6145 }
6146 return result;
6147}
6148
6149int radio::startLceServiceResponse(int slotId,
6150 int responseType, int serial, RIL_Errno e,
6151 void *response, size_t responseLen) {
6152#if VDBG
6153 RLOGD("startLceServiceResponse: serial %d", serial);
6154#endif
6155
6156 if (radioService[slotId]->mRadioResponse != NULL) {
6157 RadioResponseInfo responseInfo = {};
6158 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6159 response, responseLen);
6160
6161 Return<void> retStatus
6162 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6163 result);
6164 radioService[slotId]->checkReturnStatus(retStatus);
6165 } else {
6166 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6167 }
6168
6169 return 0;
6170}
6171
6172int radio::stopLceServiceResponse(int slotId,
6173 int responseType, int serial, RIL_Errno e,
6174 void *response, size_t responseLen) {
6175#if VDBG
6176 RLOGD("stopLceServiceResponse: serial %d", serial);
6177#endif
6178
6179 if (radioService[slotId]->mRadioResponse != NULL) {
6180 RadioResponseInfo responseInfo = {};
6181 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6182 response, responseLen);
6183
6184 Return<void> retStatus
6185 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6186 result);
6187 radioService[slotId]->checkReturnStatus(retStatus);
6188 } else {
6189 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6190 }
6191
6192 return 0;
6193}
6194
6195int radio::pullLceDataResponse(int slotId,
6196 int responseType, int serial, RIL_Errno e,
6197 void *response, size_t responseLen) {
6198#if VDBG
6199 RLOGD("pullLceDataResponse: serial %d", serial);
6200#endif
6201
6202 if (radioService[slotId]->mRadioResponse != NULL) {
6203 RadioResponseInfo responseInfo = {};
6204 populateResponseInfo(responseInfo, serial, responseType, e);
6205
6206 LceDataInfo result = {};
6207 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6208 RLOGE("pullLceDataResponse: Invalid response");
6209 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6210 } else {
6211 convertRilLceDataInfoToHal(response, responseLen, result);
6212 }
6213
6214 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6215 responseInfo, result);
6216 radioService[slotId]->checkReturnStatus(retStatus);
6217 } else {
6218 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6219 }
6220
6221 return 0;
6222}
6223
6224int radio::getModemActivityInfoResponse(int slotId,
6225 int responseType, int serial, RIL_Errno e,
6226 void *response, size_t responseLen) {
6227#if VDBG
6228 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6229#endif
6230
6231 if (radioService[slotId]->mRadioResponse != NULL) {
6232 RadioResponseInfo responseInfo = {};
6233 populateResponseInfo(responseInfo, serial, responseType, e);
6234 ActivityStatsInfo info;
6235 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6236 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6237 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6238 } else {
6239 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6240 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6241 info.idleModeTimeMs = resp->idle_mode_time_ms;
6242 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6243 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6244 }
6245 info.rxModeTimeMs = resp->rx_mode_time_ms;
6246 }
6247
6248 Return<void> retStatus
6249 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6250 info);
6251 radioService[slotId]->checkReturnStatus(retStatus);
6252 } else {
6253 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6254 slotId);
6255 }
6256
6257 return 0;
6258}
6259
6260int radio::setAllowedCarriersResponse(int slotId,
6261 int responseType, int serial, RIL_Errno e,
6262 void *response, size_t responseLen) {
6263#if VDBG
6264 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6265#endif
6266
6267 if (radioService[slotId]->mRadioResponse != NULL) {
6268 RadioResponseInfo responseInfo = {};
6269 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6270 Return<void> retStatus
6271 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6272 ret);
6273 radioService[slotId]->checkReturnStatus(retStatus);
6274 } else {
6275 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6276 slotId);
6277 }
6278
6279 return 0;
6280}
6281
6282int radio::getAllowedCarriersResponse(int slotId,
6283 int responseType, int serial, RIL_Errno e,
6284 void *response, size_t responseLen) {
6285#if VDBG
6286 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6287#endif
6288
6289 if (radioService[slotId]->mRadioResponse != NULL) {
6290 RadioResponseInfo responseInfo = {};
6291 populateResponseInfo(responseInfo, serial, responseType, e);
6292 CarrierRestrictions carrierInfo = {};
6293 bool allAllowed = true;
6294 if (response == NULL) {
6295#if VDBG
6296 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6297#endif
6298 carrierInfo.allowedCarriers.resize(0);
6299 carrierInfo.excludedCarriers.resize(0);
6300 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6301 RLOGE("getAllowedCarriersResponse Invalid response");
6302 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6303 } else {
6304 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6305 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6306 allAllowed = false;
6307 }
6308
6309 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6310 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6311 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6312 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6313 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6314 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6315 carrierInfo.allowedCarriers[i].matchData =
6316 convertCharPtrToHidlString(carrier->match_data);
6317 }
6318
6319 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6320 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6321 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6322 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6323 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6324 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6325 carrierInfo.excludedCarriers[i].matchData =
6326 convertCharPtrToHidlString(carrier->match_data);
6327 }
6328 }
6329
6330 Return<void> retStatus
6331 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6332 allAllowed, carrierInfo);
6333 radioService[slotId]->checkReturnStatus(retStatus);
6334 } else {
6335 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6336 slotId);
6337 }
6338
6339 return 0;
6340}
6341
6342int radio::sendDeviceStateResponse(int slotId,
6343 int responseType, int serial, RIL_Errno e,
6344 void *response, size_t responselen) {
6345#if VDBG
6346 RLOGD("sendDeviceStateResponse: serial %d", serial);
6347#endif
6348
6349 if (radioService[slotId]->mRadioResponse != NULL) {
6350 RadioResponseInfo responseInfo = {};
6351 populateResponseInfo(responseInfo, serial, responseType, e);
6352 Return<void> retStatus
6353 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6354 radioService[slotId]->checkReturnStatus(retStatus);
6355 } else {
6356 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6357 }
6358
6359 return 0;
6360}
6361
6362int radio::setIndicationFilterResponse(int slotId,
6363 int responseType, int serial, RIL_Errno e,
6364 void *response, size_t responselen) {
6365#if VDBG
6366 RLOGD("setIndicationFilterResponse: serial %d", serial);
6367#endif
6368
6369 if (radioService[slotId]->mRadioResponse != NULL) {
6370 RadioResponseInfo responseInfo = {};
6371 populateResponseInfo(responseInfo, serial, responseType, e);
6372 Return<void> retStatus
6373 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6374 radioService[slotId]->checkReturnStatus(retStatus);
6375 } else {
6376 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6377 slotId);
6378 }
6379
6380 return 0;
6381}
6382
6383
6384int radio::setSimCardPowerResponse(int slotId,
6385 int responseType, int serial, RIL_Errno e,
6386 void *response, size_t responseLen) {
6387#if VDBG
6388 RLOGD("setSimCardPowerResponse: serial %d", serial);
6389#endif
6390
6391 if (radioService[slotId]->mRadioResponse != NULL) {
6392 RadioResponseInfo responseInfo = {};
6393 populateResponseInfo(responseInfo, serial, responseType, e);
6394 Return<void> retStatus
6395 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6396 radioService[slotId]->checkReturnStatus(retStatus);
6397 } else {
6398 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6399 }
6400
6401 return 0;
6402}
6403
6404int radio::sendRequestRawResponse(int slotId,
6405 int responseType, int serial, RIL_Errno e,
6406 void *response, size_t responseLen) {
6407#if VDBG
6408 RLOGD("sendRequestRawResponse: serial %d", serial);
6409#endif
6410
6411 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6412 RadioResponseInfo responseInfo = {};
6413 populateResponseInfo(responseInfo, serial, responseType, e);
6414 hidl_vec<uint8_t> data;
6415
6416 if (response == NULL) {
6417 RLOGE("sendRequestRawResponse: Invalid response");
6418 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6419 } else {
6420 data.setToExternal((uint8_t *) response, responseLen);
6421 }
6422 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6423 sendRequestRawResponse(responseInfo, data);
6424 checkReturnStatus(slotId, retStatus, false);
6425 } else {
6426 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6427 slotId);
6428 }
6429
6430 return 0;
6431}
6432
6433int radio::sendRequestStringsResponse(int slotId,
6434 int responseType, int serial, RIL_Errno e,
6435 void *response, size_t responseLen) {
6436#if VDBG
6437 RLOGD("sendRequestStringsResponse: serial %d", serial);
6438#endif
6439
6440 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6441 RadioResponseInfo responseInfo = {};
6442 populateResponseInfo(responseInfo, serial, responseType, e);
6443 hidl_vec<hidl_string> data;
6444
6445 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
6446 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6447 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6448 } else {
6449 char **resp = (char **) response;
6450 int numStrings = responseLen / sizeof(char *);
6451 data.resize(numStrings);
6452 for (int i = 0; i < numStrings; i++) {
6453 data[i] = convertCharPtrToHidlString(resp[i]);
6454 }
6455 }
6456 Return<void> retStatus
6457 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6458 responseInfo, data);
6459 checkReturnStatus(slotId, retStatus, false);
6460 } else {
6461 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6462 "NULL", slotId);
6463 }
6464
6465 return 0;
6466}
6467
6468// Radio Indication functions
6469
6470RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6471 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6472 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6473}
6474
6475int radio::radioStateChangedInd(int slotId,
6476 int indicationType, int token, RIL_Errno e, void *response,
6477 size_t responseLen) {
6478 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6479 RadioState radioState =
6480 (RadioState) CALL_ONSTATEREQUEST(slotId);
6481 RLOGD("radioStateChangedInd: radioState %d", radioState);
6482 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6483 convertIntToRadioIndicationType(indicationType), radioState);
6484 radioService[slotId]->checkReturnStatus(retStatus);
6485 } else {
6486 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6487 }
6488
6489 return 0;
6490}
6491
6492int radio::callStateChangedInd(int slotId,
6493 int indicationType, int token, RIL_Errno e, void *response,
6494 size_t responseLen) {
6495 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6496#if VDBG
6497 RLOGD("callStateChangedInd");
6498#endif
6499 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6500 convertIntToRadioIndicationType(indicationType));
6501 radioService[slotId]->checkReturnStatus(retStatus);
6502 } else {
6503 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6504 }
6505
6506 return 0;
6507}
6508
6509int radio::networkStateChangedInd(int slotId,
6510 int indicationType, int token, RIL_Errno e, void *response,
6511 size_t responseLen) {
6512 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6513#if VDBG
6514 RLOGD("networkStateChangedInd");
6515#endif
6516 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6517 convertIntToRadioIndicationType(indicationType));
6518 radioService[slotId]->checkReturnStatus(retStatus);
6519 } else {
6520 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6521 slotId);
6522 }
6523
6524 return 0;
6525}
6526
6527uint8_t hexCharToInt(uint8_t c) {
6528 if (c >= '0' && c <= '9') return (c - '0');
6529 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6530 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6531
6532 return INVALID_HEX_CHAR;
6533}
6534
6535uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6536 if (responseLen % 2 != 0) {
6537 return NULL;
6538 }
6539
6540 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6541 if (bytes == NULL) {
6542 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6543 return NULL;
6544 }
6545 uint8_t *hexString = (uint8_t *)response;
6546
6547 for (size_t i = 0; i < responseLen; i += 2) {
6548 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6549 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6550
6551 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6552 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6553 hexString[i], hexString[i + 1]);
6554 free(bytes);
6555 return NULL;
6556 }
6557 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6558 }
6559
6560 return bytes;
6561}
6562
6563int radio::newSmsInd(int slotId, int indicationType,
6564 int token, RIL_Errno e, void *response, size_t responseLen) {
6565 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6566 if (response == NULL || responseLen == 0) {
6567 RLOGE("newSmsInd: invalid response");
6568 return 0;
6569 }
6570
6571 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6572 if (bytes == NULL) {
6573 RLOGE("newSmsInd: convertHexStringToBytes failed");
6574 return 0;
6575 }
6576
6577 hidl_vec<uint8_t> pdu;
6578 pdu.setToExternal(bytes, responseLen/2);
6579#if VDBG
6580 RLOGD("newSmsInd");
6581#endif
6582 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6583 convertIntToRadioIndicationType(indicationType), pdu);
6584 radioService[slotId]->checkReturnStatus(retStatus);
6585 free(bytes);
6586 } else {
6587 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6588 }
6589
6590 return 0;
6591}
6592
6593int radio::newSmsStatusReportInd(int slotId,
6594 int indicationType, int token, RIL_Errno e, void *response,
6595 size_t responseLen) {
6596 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6597 if (response == NULL || responseLen == 0) {
6598 RLOGE("newSmsStatusReportInd: invalid response");
6599 return 0;
6600 }
6601
6602 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6603 if (bytes == NULL) {
6604 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6605 return 0;
6606 }
6607
6608 hidl_vec<uint8_t> pdu;
6609 pdu.setToExternal(bytes, responseLen/2);
6610#if VDBG
6611 RLOGD("newSmsStatusReportInd");
6612#endif
6613 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6614 convertIntToRadioIndicationType(indicationType), pdu);
6615 radioService[slotId]->checkReturnStatus(retStatus);
6616 free(bytes);
6617 } else {
6618 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6619 }
6620
6621 return 0;
6622}
6623
6624int radio::newSmsOnSimInd(int slotId, int indicationType,
6625 int token, RIL_Errno e, void *response, size_t responseLen) {
6626 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6627 if (response == NULL || responseLen != sizeof(int)) {
6628 RLOGE("newSmsOnSimInd: invalid response");
6629 return 0;
6630 }
6631 int32_t recordNumber = ((int32_t *) response)[0];
6632#if VDBG
6633 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6634#endif
6635 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6636 convertIntToRadioIndicationType(indicationType), recordNumber);
6637 radioService[slotId]->checkReturnStatus(retStatus);
6638 } else {
6639 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6640 }
6641
6642 return 0;
6643}
6644
6645int radio::onUssdInd(int slotId, int indicationType,
6646 int token, RIL_Errno e, void *response, size_t responseLen) {
6647 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6648 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6649 RLOGE("onUssdInd: invalid response");
6650 return 0;
6651 }
6652 char **strings = (char **) response;
6653 char *mode = strings[0];
6654 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6655 UssdModeType modeType = (UssdModeType) atoi(mode);
6656#if VDBG
6657 RLOGD("onUssdInd: mode %s", mode);
6658#endif
6659 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6660 convertIntToRadioIndicationType(indicationType), modeType, msg);
6661 radioService[slotId]->checkReturnStatus(retStatus);
6662 } else {
6663 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6664 }
6665
6666 return 0;
6667}
6668
6669int radio::nitzTimeReceivedInd(int slotId,
6670 int indicationType, int token, RIL_Errno e, void *response,
6671 size_t responseLen) {
6672 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6673 if (response == NULL || responseLen == 0) {
6674 RLOGE("nitzTimeReceivedInd: invalid response");
6675 return 0;
6676 }
6677 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6678 int64_t timeReceived = android::elapsedRealtime();
6679#if VDBG
6680 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6681 timeReceived);
6682#endif
6683 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6684 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6685 radioService[slotId]->checkReturnStatus(retStatus);
6686 } else {
6687 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6688 return -1;
6689 }
6690
6691 return 0;
6692}
6693
6694void convertRilSignalStrengthToHalV8(void *response, size_t responseLen,
6695 SignalStrength& signalStrength) {
6696 RIL_SignalStrength_v8 *rilSignalStrength = (RIL_SignalStrength_v8 *) response;
6697
6698 // Fixup LTE for backwards compatibility
6699 // signalStrength: -1 -> 99
6700 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6701 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6702 }
6703 // rsrp: -1 -> INT_MAX all other negative value to positive.
6704 // So remap here
6705 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6706 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6707 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6708 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6709 }
6710 // rsrq: -1 -> INT_MAX
6711 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6712 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6713 }
6714 // Not remapping rssnr is already using INT_MAX
6715 // cqi: -1 -> INT_MAX
6716 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6717 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6718 }
6719
6720 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6721 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6722 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6723 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6724 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6725 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6726 signalStrength.evdo.signalNoiseRatio =
6727 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6728 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6729 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6730 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6731 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6732 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6733 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6734 signalStrength.tdScdma.rscp = INT_MAX;
6735}
6736
6737void convertRilSignalStrengthToHalV10(void *response, size_t responseLen,
6738 SignalStrength& signalStrength) {
6739 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6740
6741 // Fixup LTE for backwards compatibility
6742 // signalStrength: -1 -> 99
6743 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6744 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6745 }
6746 // rsrp: -1 -> INT_MAX all other negative value to positive.
6747 // So remap here
6748 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6749 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6750 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6751 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6752 }
6753 // rsrq: -1 -> INT_MAX
6754 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6755 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6756 }
6757 // Not remapping rssnr is already using INT_MAX
6758 // cqi: -1 -> INT_MAX
6759 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6760 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6761 }
6762
6763 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6764 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6765 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6766 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6767 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6768 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6769 signalStrength.evdo.signalNoiseRatio =
6770 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6771 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6772 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6773 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6774 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6775 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6776 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6777 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6778}
6779
6780void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6781 SignalStrength& signalStrength) {
6782 if (responseLen == sizeof(RIL_SignalStrength_v8)) {
6783 convertRilSignalStrengthToHalV8(response, responseLen, signalStrength);
6784 } else {
6785 convertRilSignalStrengthToHalV10(response, responseLen, signalStrength);
6786 }
6787}
6788
6789int radio::currentSignalStrengthInd(int slotId,
6790 int indicationType, int token, RIL_Errno e,
6791 void *response, size_t responseLen) {
6792 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6793 if (response == NULL || (responseLen != sizeof(RIL_SignalStrength_v10)
6794 && responseLen != sizeof(RIL_SignalStrength_v8))) {
6795 RLOGE("currentSignalStrengthInd: invalid response");
6796 return 0;
6797 }
6798
6799 SignalStrength signalStrength = {};
6800 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6801
6802#if VDBG
6803 RLOGD("currentSignalStrengthInd");
6804#endif
6805 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6806 convertIntToRadioIndicationType(indicationType), signalStrength);
6807 radioService[slotId]->checkReturnStatus(retStatus);
6808 } else {
6809 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6810 slotId);
6811 }
6812
6813 return 0;
6814}
6815
6816void convertRilDataCallToHal(RIL_Data_Call_Response_v6 *dcResponse,
6817 SetupDataCallResult& dcResult) {
6818 dcResult.status = (DataCallFailCause) dcResponse->status;
6819 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6820 dcResult.cid = dcResponse->cid;
6821 dcResult.active = dcResponse->active;
6822 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6823 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6824 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6825 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6826 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6827 dcResult.pcscf = hidl_string();
6828 dcResult.mtu = 0;
6829}
6830
6831void convertRilDataCallToHal(RIL_Data_Call_Response_v9 *dcResponse,
6832 SetupDataCallResult& dcResult) {
6833 dcResult.status = (DataCallFailCause) dcResponse->status;
6834 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6835 dcResult.cid = dcResponse->cid;
6836 dcResult.active = dcResponse->active;
6837 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6838 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6839 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6840 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6841 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6842 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6843 dcResult.mtu = 0;
6844}
6845
6846void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6847 SetupDataCallResult& dcResult) {
6848 dcResult.status = (DataCallFailCause) dcResponse->status;
6849 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6850 dcResult.cid = dcResponse->cid;
6851 dcResult.active = dcResponse->active;
6852 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6853 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6854 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6855 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6856 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6857 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6858 dcResult.mtu = dcResponse->mtu;
6859}
6860
6861void convertRilDataCallListToHal(void *response, size_t responseLen,
6862 hidl_vec<SetupDataCallResult>& dcResultList) {
6863 int num;
6864
6865 if ((responseLen % sizeof(RIL_Data_Call_Response_v11)) == 0) {
6866 num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6867 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6868 dcResultList.resize(num);
6869 for (int i = 0; i < num; i++) {
6870 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6871 }
6872 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v9)) == 0) {
6873 num = responseLen / sizeof(RIL_Data_Call_Response_v9);
6874 RIL_Data_Call_Response_v9 *dcResponse = (RIL_Data_Call_Response_v9 *) response;
6875 dcResultList.resize(num);
6876 for (int i = 0; i < num; i++) {
6877 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6878 }
6879 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v6)) == 0) {
6880 num = responseLen / sizeof(RIL_Data_Call_Response_v6);
6881 RIL_Data_Call_Response_v6 *dcResponse = (RIL_Data_Call_Response_v6 *) response;
6882 dcResultList.resize(num);
6883 for (int i = 0; i < num; i++) {
6884 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6885 }
6886 }
6887}
6888
6889int radio::dataCallListChangedInd(int slotId,
6890 int indicationType, int token, RIL_Errno e, void *response,
6891 size_t responseLen) {
6892 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6893 if ((response == NULL && responseLen != 0)
6894 || (responseLen % sizeof(RIL_Data_Call_Response_v11) != 0
6895 && responseLen % sizeof(RIL_Data_Call_Response_v9) != 0
6896 && responseLen % sizeof(RIL_Data_Call_Response_v6) != 0)) {
6897 RLOGE("dataCallListChangedInd: invalid response");
6898 return 0;
6899 }
6900 hidl_vec<SetupDataCallResult> dcList;
6901 convertRilDataCallListToHal(response, responseLen, dcList);
6902#if VDBG
6903 RLOGD("dataCallListChangedInd");
6904#endif
6905 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
6906 convertIntToRadioIndicationType(indicationType), dcList);
6907 radioService[slotId]->checkReturnStatus(retStatus);
6908 } else {
6909 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6910 }
6911
6912 return 0;
6913}
6914
6915int radio::suppSvcNotifyInd(int slotId, int indicationType,
6916 int token, RIL_Errno e, void *response, size_t responseLen) {
6917 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6918 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
6919 RLOGE("suppSvcNotifyInd: invalid response");
6920 return 0;
6921 }
6922
6923 SuppSvcNotification suppSvc = {};
6924 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6925 suppSvc.isMT = ssn->notificationType;
6926 suppSvc.code = ssn->code;
6927 suppSvc.index = ssn->index;
6928 suppSvc.type = ssn->type;
6929 suppSvc.number = convertCharPtrToHidlString(ssn->number);
6930
6931#if VDBG
6932 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
6933 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
6934#endif
6935 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
6936 convertIntToRadioIndicationType(indicationType), suppSvc);
6937 radioService[slotId]->checkReturnStatus(retStatus);
6938 } else {
6939 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6940 }
6941
6942 return 0;
6943}
6944
6945int radio::stkSessionEndInd(int slotId, int indicationType,
6946 int token, RIL_Errno e, void *response, size_t responseLen) {
6947 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6948#if VDBG
6949 RLOGD("stkSessionEndInd");
6950#endif
6951 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
6952 convertIntToRadioIndicationType(indicationType));
6953 radioService[slotId]->checkReturnStatus(retStatus);
6954 } else {
6955 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
6956 }
6957
6958 return 0;
6959}
6960
6961int radio::stkProactiveCommandInd(int slotId,
6962 int indicationType, int token, RIL_Errno e, void *response,
6963 size_t responseLen) {
6964 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6965 if (response == NULL || responseLen == 0) {
6966 RLOGE("stkProactiveCommandInd: invalid response");
6967 return 0;
6968 }
6969#if VDBG
6970 RLOGD("stkProactiveCommandInd");
6971#endif
6972 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
6973 convertIntToRadioIndicationType(indicationType),
6974 convertCharPtrToHidlString((char *) response));
6975 radioService[slotId]->checkReturnStatus(retStatus);
6976 } else {
6977 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
6978 }
6979
6980 return 0;
6981}
6982
6983int radio::stkEventNotifyInd(int slotId, int indicationType,
6984 int token, RIL_Errno e, void *response, size_t responseLen) {
6985 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6986 if (response == NULL || responseLen == 0) {
6987 RLOGE("stkEventNotifyInd: invalid response");
6988 return 0;
6989 }
6990#if VDBG
6991 RLOGD("stkEventNotifyInd");
6992#endif
6993 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
6994 convertIntToRadioIndicationType(indicationType),
6995 convertCharPtrToHidlString((char *) response));
6996 radioService[slotId]->checkReturnStatus(retStatus);
6997 } else {
6998 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6999 }
7000
7001 return 0;
7002}
7003
7004int radio::stkCallSetupInd(int slotId, int indicationType,
7005 int token, RIL_Errno e, void *response, size_t responseLen) {
7006 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7007 if (response == NULL || responseLen != sizeof(int)) {
7008 RLOGE("stkCallSetupInd: invalid response");
7009 return 0;
7010 }
7011 int32_t timeout = ((int32_t *) response)[0];
7012#if VDBG
7013 RLOGD("stkCallSetupInd: timeout %d", timeout);
7014#endif
7015 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
7016 convertIntToRadioIndicationType(indicationType), timeout);
7017 radioService[slotId]->checkReturnStatus(retStatus);
7018 } else {
7019 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
7020 }
7021
7022 return 0;
7023}
7024
7025int radio::simSmsStorageFullInd(int slotId,
7026 int indicationType, int token, RIL_Errno e, void *response,
7027 size_t responseLen) {
7028 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7029#if VDBG
7030 RLOGD("simSmsStorageFullInd");
7031#endif
7032 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
7033 convertIntToRadioIndicationType(indicationType));
7034 radioService[slotId]->checkReturnStatus(retStatus);
7035 } else {
7036 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
7037 }
7038
7039 return 0;
7040}
7041
7042int radio::simRefreshInd(int slotId, int indicationType,
7043 int token, RIL_Errno e, void *response, size_t responseLen) {
7044 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7045 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
7046 RLOGE("simRefreshInd: invalid response");
7047 return 0;
7048 }
7049
7050 SimRefreshResult refreshResult = {};
7051 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
7052 refreshResult.type =
7053 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
7054 refreshResult.efId = simRefreshResponse->ef_id;
7055 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
7056
7057#if VDBG
7058 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
7059#endif
7060 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
7061 convertIntToRadioIndicationType(indicationType), refreshResult);
7062 radioService[slotId]->checkReturnStatus(retStatus);
7063 } else {
7064 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
7065 }
7066
7067 return 0;
7068}
7069
7070void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
7071 CdmaSignalInfoRecord& record) {
7072 record.isPresent = signalInfoRecord->isPresent;
7073 record.signalType = signalInfoRecord->signalType;
7074 record.alertPitch = signalInfoRecord->alertPitch;
7075 record.signal = signalInfoRecord->signal;
7076}
7077
7078int radio::callRingInd(int slotId, int indicationType,
7079 int token, RIL_Errno e, void *response, size_t responseLen) {
7080 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7081 bool isGsm;
7082 CdmaSignalInfoRecord record = {};
7083 if (response == NULL || responseLen == 0) {
7084 isGsm = true;
7085 } else {
7086 isGsm = false;
7087 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
7088 RLOGE("callRingInd: invalid response");
7089 return 0;
7090 }
7091 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
7092 }
7093
7094#if VDBG
7095 RLOGD("callRingInd: isGsm %d", isGsm);
7096#endif
7097 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
7098 convertIntToRadioIndicationType(indicationType), isGsm, record);
7099 radioService[slotId]->checkReturnStatus(retStatus);
7100 } else {
7101 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7102 }
7103
7104 return 0;
7105}
7106
7107int radio::simStatusChangedInd(int slotId,
7108 int indicationType, int token, RIL_Errno e, void *response,
7109 size_t responseLen) {
7110 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7111#if VDBG
7112 RLOGD("simStatusChangedInd");
7113#endif
7114 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7115 convertIntToRadioIndicationType(indicationType));
7116 radioService[slotId]->checkReturnStatus(retStatus);
7117 } else {
7118 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7119 }
7120
7121 return 0;
7122}
7123
7124int radio::cdmaNewSmsInd(int slotId, int indicationType,
7125 int token, RIL_Errno e, void *response, size_t responseLen) {
7126 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7127 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7128 RLOGE("cdmaNewSmsInd: invalid response");
7129 return 0;
7130 }
7131
7132 CdmaSmsMessage msg = {};
7133 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7134 msg.teleserviceId = rilMsg->uTeleserviceID;
7135 msg.isServicePresent = rilMsg->bIsServicePresent;
7136 msg.serviceCategory = rilMsg->uServicecategory;
7137 msg.address.digitMode =
7138 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7139 msg.address.numberMode =
7140 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7141 msg.address.numberType =
7142 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7143 msg.address.numberPlan =
7144 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7145
7146 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7147 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7148
7149 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
7150 rilMsg->sSubAddress.subaddressType;
7151 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7152
7153 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7154 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7155
7156 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7157 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7158
7159#if VDBG
7160 RLOGD("cdmaNewSmsInd");
7161#endif
7162 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7163 convertIntToRadioIndicationType(indicationType), msg);
7164 radioService[slotId]->checkReturnStatus(retStatus);
7165 } else {
7166 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7167 }
7168
7169 return 0;
7170}
7171
7172int radio::newBroadcastSmsInd(int slotId,
7173 int indicationType, int token, RIL_Errno e, void *response,
7174 size_t responseLen) {
7175 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7176 if (response == NULL || responseLen == 0) {
7177 RLOGE("newBroadcastSmsInd: invalid response");
7178 return 0;
7179 }
7180
7181 hidl_vec<uint8_t> data;
7182 data.setToExternal((uint8_t *) response, responseLen);
7183#if VDBG
7184 RLOGD("newBroadcastSmsInd");
7185#endif
7186 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7187 convertIntToRadioIndicationType(indicationType), data);
7188 radioService[slotId]->checkReturnStatus(retStatus);
7189 } else {
7190 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7191 }
7192
7193 return 0;
7194}
7195
7196int radio::cdmaRuimSmsStorageFullInd(int slotId,
7197 int indicationType, int token, RIL_Errno e, void *response,
7198 size_t responseLen) {
7199 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7200#if VDBG
7201 RLOGD("cdmaRuimSmsStorageFullInd");
7202#endif
7203 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7204 convertIntToRadioIndicationType(indicationType));
7205 radioService[slotId]->checkReturnStatus(retStatus);
7206 } else {
7207 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7208 slotId);
7209 }
7210
7211 return 0;
7212}
7213
7214int radio::restrictedStateChangedInd(int slotId,
7215 int indicationType, int token, RIL_Errno e, void *response,
7216 size_t responseLen) {
7217 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7218 if (response == NULL || responseLen != sizeof(int)) {
7219 RLOGE("restrictedStateChangedInd: invalid response");
7220 return 0;
7221 }
7222 int32_t state = ((int32_t *) response)[0];
7223#if VDBG
7224 RLOGD("restrictedStateChangedInd: state %d", state);
7225#endif
7226 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7227 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7228 radioService[slotId]->checkReturnStatus(retStatus);
7229 } else {
7230 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7231 slotId);
7232 }
7233
7234 return 0;
7235}
7236
7237int radio::enterEmergencyCallbackModeInd(int slotId,
7238 int indicationType, int token, RIL_Errno e, void *response,
7239 size_t responseLen) {
7240 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7241#if VDBG
7242 RLOGD("enterEmergencyCallbackModeInd");
7243#endif
7244 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7245 convertIntToRadioIndicationType(indicationType));
7246 radioService[slotId]->checkReturnStatus(retStatus);
7247 } else {
7248 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7249 slotId);
7250 }
7251
7252 return 0;
7253}
7254
7255int radio::cdmaCallWaitingInd(int slotId,
7256 int indicationType, int token, RIL_Errno e, void *response,
7257 size_t responseLen) {
7258 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7259 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7260 RLOGE("cdmaCallWaitingInd: invalid response");
7261 return 0;
7262 }
7263
7264 CdmaCallWaiting callWaitingRecord = {};
7265 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7266 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7267 callWaitingRecord.numberPresentation =
7268 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7269 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7270 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7271 callWaitingRecord.signalInfoRecord);
7272 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7273 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7274
7275#if VDBG
7276 RLOGD("cdmaCallWaitingInd");
7277#endif
7278 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7279 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7280 radioService[slotId]->checkReturnStatus(retStatus);
7281 } else {
7282 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7283 }
7284
7285 return 0;
7286}
7287
7288int radio::cdmaOtaProvisionStatusInd(int slotId,
7289 int indicationType, int token, RIL_Errno e, void *response,
7290 size_t responseLen) {
7291 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7292 if (response == NULL || responseLen != sizeof(int)) {
7293 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7294 return 0;
7295 }
7296 int32_t status = ((int32_t *) response)[0];
7297#if VDBG
7298 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7299#endif
7300 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7301 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7302 radioService[slotId]->checkReturnStatus(retStatus);
7303 } else {
7304 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7305 slotId);
7306 }
7307
7308 return 0;
7309}
7310
7311int radio::cdmaInfoRecInd(int slotId,
7312 int indicationType, int token, RIL_Errno e, void *response,
7313 size_t responseLen) {
7314 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7315 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7316 RLOGE("cdmaInfoRecInd: invalid response");
7317 return 0;
7318 }
7319
7320 CdmaInformationRecords records = {};
7321 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7322
7323 char* string8 = NULL;
7324 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7325 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7326 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7327 "additional ones", recordsRil->numberOfInfoRecs,
7328 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7329 }
7330 records.infoRec.resize(num);
7331 for (int i = 0 ; i < num ; i++) {
7332 CdmaInformationRecord *record = &records.infoRec[i];
7333 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7334 record->name = (CdmaInfoRecName) infoRec->name;
7335 // All vectors should be size 0 except one which will be size 1. Set everything to
7336 // size 0 initially.
7337 record->display.resize(0);
7338 record->number.resize(0);
7339 record->signal.resize(0);
7340 record->redir.resize(0);
7341 record->lineCtrl.resize(0);
7342 record->clir.resize(0);
7343 record->audioCtrl.resize(0);
7344 switch (infoRec->name) {
7345 case RIL_CDMA_DISPLAY_INFO_REC:
7346 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7347 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7348 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7349 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7350 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7351 return 0;
7352 }
7353 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7354 if (string8 == NULL) {
7355 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7356 "responseCdmaInformationRecords");
7357 return 0;
7358 }
7359 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7360 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7361
7362 record->display.resize(1);
7363 record->display[0].alphaBuf = string8;
7364 free(string8);
7365 string8 = NULL;
7366 break;
7367 }
7368
7369 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7370 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7371 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7372 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7373 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7374 "expected not more than %d", (int) infoRec->rec.number.len,
7375 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7376 return 0;
7377 }
7378 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7379 if (string8 == NULL) {
7380 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7381 "responseCdmaInformationRecords");
7382 return 0;
7383 }
7384 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7385 string8[(int)infoRec->rec.number.len] = '\0';
7386
7387 record->number.resize(1);
7388 record->number[0].number = string8;
7389 free(string8);
7390 string8 = NULL;
7391 record->number[0].numberType = infoRec->rec.number.number_type;
7392 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7393 record->number[0].pi = infoRec->rec.number.pi;
7394 record->number[0].si = infoRec->rec.number.si;
7395 break;
7396 }
7397
7398 case RIL_CDMA_SIGNAL_INFO_REC: {
7399 record->signal.resize(1);
7400 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7401 record->signal[0].signalType = infoRec->rec.signal.signalType;
7402 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7403 record->signal[0].signal = infoRec->rec.signal.signal;
7404 break;
7405 }
7406
7407 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7408 if (infoRec->rec.redir.redirectingNumber.len >
7409 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7410 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7411 "expected not more than %d\n",
7412 (int)infoRec->rec.redir.redirectingNumber.len,
7413 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7414 return 0;
7415 }
7416 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7417 sizeof(char));
7418 if (string8 == NULL) {
7419 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7420 "responseCdmaInformationRecords");
7421 return 0;
7422 }
7423 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7424 infoRec->rec.redir.redirectingNumber.len);
7425 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7426
7427 record->redir.resize(1);
7428 record->redir[0].redirectingNumber.number = string8;
7429 free(string8);
7430 string8 = NULL;
7431 record->redir[0].redirectingNumber.numberType =
7432 infoRec->rec.redir.redirectingNumber.number_type;
7433 record->redir[0].redirectingNumber.numberPlan =
7434 infoRec->rec.redir.redirectingNumber.number_plan;
7435 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7436 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7437 record->redir[0].redirectingReason =
7438 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7439 break;
7440 }
7441
7442 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7443 record->lineCtrl.resize(1);
7444 record->lineCtrl[0].lineCtrlPolarityIncluded =
7445 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7446 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7447 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7448 record->lineCtrl[0].lineCtrlPowerDenial =
7449 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7450 break;
7451 }
7452
7453 case RIL_CDMA_T53_CLIR_INFO_REC: {
7454 record->clir.resize(1);
7455 record->clir[0].cause = infoRec->rec.clir.cause;
7456 break;
7457 }
7458
7459 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7460 record->audioCtrl.resize(1);
7461 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7462 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7463 break;
7464 }
7465
7466 case RIL_CDMA_T53_RELEASE_INFO_REC:
7467 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7468 return 0;
7469
7470 default:
7471 RLOGE("cdmaInfoRecInd: Incorrect name value");
7472 return 0;
7473 }
7474 }
7475
7476#if VDBG
7477 RLOGD("cdmaInfoRecInd");
7478#endif
7479 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7480 convertIntToRadioIndicationType(indicationType), records);
7481 radioService[slotId]->checkReturnStatus(retStatus);
7482 } else {
7483 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7484 }
7485
7486 return 0;
7487}
7488
7489int radio::indicateRingbackToneInd(int slotId,
7490 int indicationType, int token, RIL_Errno e, void *response,
7491 size_t responseLen) {
7492 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7493 if (response == NULL || responseLen != sizeof(int)) {
7494 RLOGE("indicateRingbackToneInd: invalid response");
7495 return 0;
7496 }
7497 bool start = ((int32_t *) response)[0];
7498#if VDBG
7499 RLOGD("indicateRingbackToneInd: start %d", start);
7500#endif
7501 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7502 convertIntToRadioIndicationType(indicationType), start);
7503 radioService[slotId]->checkReturnStatus(retStatus);
7504 } else {
7505 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7506 }
7507
7508 return 0;
7509}
7510
7511int radio::resendIncallMuteInd(int slotId,
7512 int indicationType, int token, RIL_Errno e, void *response,
7513 size_t responseLen) {
7514 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7515#if VDBG
7516 RLOGD("resendIncallMuteInd");
7517#endif
7518 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7519 convertIntToRadioIndicationType(indicationType));
7520 radioService[slotId]->checkReturnStatus(retStatus);
7521 } else {
7522 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7523 }
7524
7525 return 0;
7526}
7527
7528int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7529 int indicationType, int token, RIL_Errno e,
7530 void *response, size_t responseLen) {
7531 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7532 if (response == NULL || responseLen != sizeof(int)) {
7533 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7534 return 0;
7535 }
7536 int32_t cdmaSource = ((int32_t *) response)[0];
7537#if VDBG
7538 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7539#endif
7540 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7541 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7542 (CdmaSubscriptionSource) cdmaSource);
7543 radioService[slotId]->checkReturnStatus(retStatus);
7544 } else {
7545 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7546 slotId);
7547 }
7548
7549 return 0;
7550}
7551
7552int radio::cdmaPrlChangedInd(int slotId,
7553 int indicationType, int token, RIL_Errno e, void *response,
7554 size_t responseLen) {
7555 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7556 if (response == NULL || responseLen != sizeof(int)) {
7557 RLOGE("cdmaPrlChangedInd: invalid response");
7558 return 0;
7559 }
7560 int32_t version = ((int32_t *) response)[0];
7561#if VDBG
7562 RLOGD("cdmaPrlChangedInd: version %d", version);
7563#endif
7564 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7565 convertIntToRadioIndicationType(indicationType), version);
7566 radioService[slotId]->checkReturnStatus(retStatus);
7567 } else {
7568 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7569 }
7570
7571 return 0;
7572}
7573
7574int radio::exitEmergencyCallbackModeInd(int slotId,
7575 int indicationType, int token, RIL_Errno e, void *response,
7576 size_t responseLen) {
7577 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7578#if VDBG
7579 RLOGD("exitEmergencyCallbackModeInd");
7580#endif
7581 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7582 convertIntToRadioIndicationType(indicationType));
7583 radioService[slotId]->checkReturnStatus(retStatus);
7584 } else {
7585 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7586 slotId);
7587 }
7588
7589 return 0;
7590}
7591
7592int radio::rilConnectedInd(int slotId,
7593 int indicationType, int token, RIL_Errno e, void *response,
7594 size_t responseLen) {
7595 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7596 RLOGD("rilConnectedInd");
7597 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7598 convertIntToRadioIndicationType(indicationType));
7599 radioService[slotId]->checkReturnStatus(retStatus);
7600 } else {
7601 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7602 }
7603
7604 return 0;
7605}
7606
7607int radio::voiceRadioTechChangedInd(int slotId,
7608 int indicationType, int token, RIL_Errno e, void *response,
7609 size_t responseLen) {
7610 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7611 if (response == NULL || responseLen != sizeof(int)) {
7612 RLOGE("voiceRadioTechChangedInd: invalid response");
7613 return 0;
7614 }
7615 int32_t rat = ((int32_t *) response)[0];
7616#if VDBG
7617 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7618#endif
7619 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7620 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7621 radioService[slotId]->checkReturnStatus(retStatus);
7622 } else {
7623 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7624 slotId);
7625 }
7626
7627 return 0;
7628}
7629
7630void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7631 int num = responseLen / sizeof(RIL_CellInfo_v12);
7632 records.resize(num);
7633
7634 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7635 for (int i = 0; i < num; i++) {
7636 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7637 records[i].registered = rillCellInfo->registered;
7638 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7639 records[i].timeStamp = rillCellInfo->timeStamp;
7640 // All vectors should be size 0 except one which will be size 1. Set everything to
7641 // size 0 initially.
7642 records[i].gsm.resize(0);
7643 records[i].wcdma.resize(0);
7644 records[i].cdma.resize(0);
7645 records[i].lte.resize(0);
7646 records[i].tdscdma.resize(0);
7647 switch(rillCellInfo->cellInfoType) {
7648 case RIL_CELL_INFO_TYPE_GSM: {
7649 records[i].gsm.resize(1);
7650 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7651 cellInfoGsm->cellIdentityGsm.mcc =
7652 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7653 cellInfoGsm->cellIdentityGsm.mnc =
7654 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7655 cellInfoGsm->cellIdentityGsm.lac =
7656 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7657 cellInfoGsm->cellIdentityGsm.cid =
7658 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7659 cellInfoGsm->cellIdentityGsm.arfcn =
7660 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7661 cellInfoGsm->cellIdentityGsm.bsic =
7662 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7663 cellInfoGsm->signalStrengthGsm.signalStrength =
7664 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7665 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7666 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7667 cellInfoGsm->signalStrengthGsm.timingAdvance =
7668 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7669 break;
7670 }
7671
7672 case RIL_CELL_INFO_TYPE_WCDMA: {
7673 records[i].wcdma.resize(1);
7674 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7675 cellInfoWcdma->cellIdentityWcdma.mcc =
7676 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7677 cellInfoWcdma->cellIdentityWcdma.mnc =
7678 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7679 cellInfoWcdma->cellIdentityWcdma.lac =
7680 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7681 cellInfoWcdma->cellIdentityWcdma.cid =
7682 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7683 cellInfoWcdma->cellIdentityWcdma.psc =
7684 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7685 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7686 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7687 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7688 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7689 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7690 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7691 break;
7692 }
7693
7694 case RIL_CELL_INFO_TYPE_CDMA: {
7695 records[i].cdma.resize(1);
7696 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7697 cellInfoCdma->cellIdentityCdma.networkId =
7698 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7699 cellInfoCdma->cellIdentityCdma.systemId =
7700 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7701 cellInfoCdma->cellIdentityCdma.baseStationId =
7702 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7703 cellInfoCdma->cellIdentityCdma.longitude =
7704 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7705 cellInfoCdma->cellIdentityCdma.latitude =
7706 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7707 cellInfoCdma->signalStrengthCdma.dbm =
7708 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7709 cellInfoCdma->signalStrengthCdma.ecio =
7710 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7711 cellInfoCdma->signalStrengthEvdo.dbm =
7712 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7713 cellInfoCdma->signalStrengthEvdo.ecio =
7714 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7715 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7716 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7717 break;
7718 }
7719
7720 case RIL_CELL_INFO_TYPE_LTE: {
7721 records[i].lte.resize(1);
7722 CellInfoLte *cellInfoLte = &records[i].lte[0];
7723 cellInfoLte->cellIdentityLte.mcc =
7724 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7725 cellInfoLte->cellIdentityLte.mnc =
7726 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7727 cellInfoLte->cellIdentityLte.ci =
7728 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7729 cellInfoLte->cellIdentityLte.pci =
7730 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7731 cellInfoLte->cellIdentityLte.tac =
7732 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7733 cellInfoLte->cellIdentityLte.earfcn =
7734 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7735 cellInfoLte->signalStrengthLte.signalStrength =
7736 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7737 cellInfoLte->signalStrengthLte.rsrp =
7738 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7739 cellInfoLte->signalStrengthLte.rsrq =
7740 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7741 cellInfoLte->signalStrengthLte.rssnr =
7742 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7743 cellInfoLte->signalStrengthLte.cqi =
7744 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7745 cellInfoLte->signalStrengthLte.timingAdvance =
7746 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7747 break;
7748 }
7749
7750 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7751 records[i].tdscdma.resize(1);
7752 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7753 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7754 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7755 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7756 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7757 cellInfoTdscdma->cellIdentityTdscdma.lac =
7758 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7759 cellInfoTdscdma->cellIdentityTdscdma.cid =
7760 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7761 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7762 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7763 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7764 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7765 break;
7766 }
7767 default: {
7768 break;
7769 }
7770 }
7771 rillCellInfo += 1;
7772 }
7773}
7774
7775int radio::cellInfoListInd(int slotId,
7776 int indicationType, int token, RIL_Errno e, void *response,
7777 size_t responseLen) {
7778 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7779 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7780 RLOGE("cellInfoListInd: invalid response");
7781 return 0;
7782 }
7783
7784 hidl_vec<CellInfo> records;
7785 convertRilCellInfoListToHal(response, responseLen, records);
7786
7787#if VDBG
7788 RLOGD("cellInfoListInd");
7789#endif
7790 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7791 convertIntToRadioIndicationType(indicationType), records);
7792 radioService[slotId]->checkReturnStatus(retStatus);
7793 } else {
7794 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7795 }
7796
7797 return 0;
7798}
7799
7800int radio::imsNetworkStateChangedInd(int slotId,
7801 int indicationType, int token, RIL_Errno e, void *response,
7802 size_t responseLen) {
7803 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7804#if VDBG
7805 RLOGD("imsNetworkStateChangedInd");
7806#endif
7807 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7808 convertIntToRadioIndicationType(indicationType));
7809 radioService[slotId]->checkReturnStatus(retStatus);
7810 } else {
7811 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7812 slotId);
7813 }
7814
7815 return 0;
7816}
7817
7818int radio::subscriptionStatusChangedInd(int slotId,
7819 int indicationType, int token, RIL_Errno e, void *response,
7820 size_t responseLen) {
7821 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7822 if (response == NULL || responseLen != sizeof(int)) {
7823 RLOGE("subscriptionStatusChangedInd: invalid response");
7824 return 0;
7825 }
7826 bool activate = ((int32_t *) response)[0];
7827#if VDBG
7828 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7829#endif
7830 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
7831 convertIntToRadioIndicationType(indicationType), activate);
7832 radioService[slotId]->checkReturnStatus(retStatus);
7833 } else {
7834 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
7835 slotId);
7836 }
7837
7838 return 0;
7839}
7840
7841int radio::srvccStateNotifyInd(int slotId,
7842 int indicationType, int token, RIL_Errno e, void *response,
7843 size_t responseLen) {
7844 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7845 if (response == NULL || responseLen != sizeof(int)) {
7846 RLOGE("srvccStateNotifyInd: invalid response");
7847 return 0;
7848 }
7849 int32_t state = ((int32_t *) response)[0];
7850#if VDBG
7851 RLOGD("srvccStateNotifyInd: rat %d", state);
7852#endif
7853 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
7854 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
7855 radioService[slotId]->checkReturnStatus(retStatus);
7856 } else {
7857 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7858 }
7859
7860 return 0;
7861}
7862
7863void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7864 hidl_vec<HardwareConfig>& records) {
7865 int num = responseLen / sizeof(RIL_HardwareConfig);
7866 records.resize(num);
7867
7868 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7869 for (int i = 0; i < num; i++) {
7870 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7871 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7872 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7873 switch (rilHardwareConfig[i].type) {
7874 case RIL_HARDWARE_CONFIG_MODEM: {
7875 records[i].modem.resize(1);
7876 records[i].sim.resize(0);
7877 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7878 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7879 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7880 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7881 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7882 break;
7883 }
7884
7885 case RIL_HARDWARE_CONFIG_SIM: {
7886 records[i].sim.resize(1);
7887 records[i].modem.resize(0);
7888 records[i].sim[0].modemUuid =
7889 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7890 break;
7891 }
7892 }
7893 }
7894}
7895
7896int radio::hardwareConfigChangedInd(int slotId,
7897 int indicationType, int token, RIL_Errno e, void *response,
7898 size_t responseLen) {
7899 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7900 if ((response == NULL && responseLen != 0)
7901 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7902 RLOGE("hardwareConfigChangedInd: invalid response");
7903 return 0;
7904 }
7905
7906 hidl_vec<HardwareConfig> configs;
7907 convertRilHardwareConfigListToHal(response, responseLen, configs);
7908
7909#if VDBG
7910 RLOGD("hardwareConfigChangedInd");
7911#endif
7912 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
7913 convertIntToRadioIndicationType(indicationType), configs);
7914 radioService[slotId]->checkReturnStatus(retStatus);
7915 } else {
7916 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
7917 slotId);
7918 }
7919
7920 return 0;
7921}
7922
7923void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7924 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7925 rc.session = rilRadioCapability->session;
7926 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7927 rc.raf = rilRadioCapability->rat;
7928 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7929 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
7930}
7931
7932int radio::radioCapabilityIndicationInd(int slotId,
7933 int indicationType, int token, RIL_Errno e, void *response,
7934 size_t responseLen) {
7935 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7936 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
7937 RLOGE("radioCapabilityIndicationInd: invalid response");
7938 return 0;
7939 }
7940
7941 RadioCapability rc = {};
7942 convertRilRadioCapabilityToHal(response, responseLen, rc);
7943
7944#if VDBG
7945 RLOGD("radioCapabilityIndicationInd");
7946#endif
7947 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
7948 convertIntToRadioIndicationType(indicationType), rc);
7949 radioService[slotId]->checkReturnStatus(retStatus);
7950 } else {
7951 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
7952 slotId);
7953 }
7954
7955 return 0;
7956}
7957
7958bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
7959 if ((reqType == SS_INTERROGATION) &&
7960 (serType == SS_CFU ||
7961 serType == SS_CF_BUSY ||
7962 serType == SS_CF_NO_REPLY ||
7963 serType == SS_CF_NOT_REACHABLE ||
7964 serType == SS_CF_ALL ||
7965 serType == SS_CF_ALL_CONDITIONAL)) {
7966 return true;
7967 }
7968 return false;
7969}
7970
7971int radio::onSupplementaryServiceIndicationInd(int slotId,
7972 int indicationType, int token, RIL_Errno e,
7973 void *response, size_t responseLen) {
7974 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7975 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
7976 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
7977 return 0;
7978 }
7979
7980 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
7981 StkCcUnsolSsResult ss = {};
7982 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
7983 ss.requestType = (SsRequestType) rilSsResponse->requestType;
7984 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
7985 ss.serviceClass = rilSsResponse->serviceClass;
7986 ss.result = (RadioError) rilSsResponse->result;
7987
7988 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
7989#if VDBG
7990 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
7991 rilSsResponse->cfData.numValidIndexes);
7992#endif
7993 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
7994 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
7995 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
7996 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
7997 }
7998
7999 ss.cfData.resize(1);
8000 ss.ssInfo.resize(0);
8001
8002 /* number of call info's */
8003 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
8004
8005 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
8006 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
8007 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
8008
8009 cfInfo->status = (CallForwardInfoStatus) cf.status;
8010 cfInfo->reason = cf.reason;
8011 cfInfo->serviceClass = cf.serviceClass;
8012 cfInfo->toa = cf.toa;
8013 cfInfo->number = convertCharPtrToHidlString(cf.number);
8014 cfInfo->timeSeconds = cf.timeSeconds;
8015#if VDBG
8016 RLOGD("onSupplementaryServiceIndicationInd: "
8017 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
8018 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
8019#endif
8020 }
8021 } else {
8022 ss.ssInfo.resize(1);
8023 ss.cfData.resize(0);
8024
8025 /* each int */
8026 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
8027 for (int i = 0; i < SS_INFO_MAX; i++) {
8028#if VDBG
8029 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
8030 rilSsResponse->ssInfo[i]);
8031#endif
8032 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
8033 }
8034 }
8035
8036#if VDBG
8037 RLOGD("onSupplementaryServiceIndicationInd");
8038#endif
8039 Return<void> retStatus = radioService[slotId]->mRadioIndication->
8040 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
8041 ss);
8042 radioService[slotId]->checkReturnStatus(retStatus);
8043 } else {
8044 RLOGE("onSupplementaryServiceIndicationInd: "
8045 "radioService[%d]->mRadioIndication == NULL", slotId);
8046 }
8047
8048 return 0;
8049}
8050
8051int radio::stkCallControlAlphaNotifyInd(int slotId,
8052 int indicationType, int token, RIL_Errno e, void *response,
8053 size_t responseLen) {
8054 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8055 if (response == NULL || responseLen == 0) {
8056 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
8057 return 0;
8058 }
8059#if VDBG
8060 RLOGD("stkCallControlAlphaNotifyInd");
8061#endif
8062 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
8063 convertIntToRadioIndicationType(indicationType),
8064 convertCharPtrToHidlString((char *) response));
8065 radioService[slotId]->checkReturnStatus(retStatus);
8066 } else {
8067 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
8068 slotId);
8069 }
8070
8071 return 0;
8072}
8073
8074void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
8075 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
8076 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
8077 lce.confidenceLevel = rilLceDataInfo->confidence_level;
8078 lce.lceSuspended = rilLceDataInfo->lce_suspended;
8079}
8080
8081int radio::lceDataInd(int slotId,
8082 int indicationType, int token, RIL_Errno e, void *response,
8083 size_t responseLen) {
8084 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8085 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
8086 RLOGE("lceDataInd: invalid response");
8087 return 0;
8088 }
8089
8090 LceDataInfo lce = {};
8091 convertRilLceDataInfoToHal(response, responseLen, lce);
8092#if VDBG
8093 RLOGD("lceDataInd");
8094#endif
8095 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
8096 convertIntToRadioIndicationType(indicationType), lce);
8097 radioService[slotId]->checkReturnStatus(retStatus);
8098 } else {
8099 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8100 }
8101
8102 return 0;
8103}
8104
8105int radio::pcoDataInd(int slotId,
8106 int indicationType, int token, RIL_Errno e, void *response,
8107 size_t responseLen) {
8108 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8109 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8110 RLOGE("pcoDataInd: invalid response");
8111 return 0;
8112 }
8113
8114 PcoDataInfo pco = {};
8115 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8116 pco.cid = rilPcoData->cid;
8117 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8118 pco.pcoId = rilPcoData->pco_id;
8119 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8120
8121#if VDBG
8122 RLOGD("pcoDataInd");
8123#endif
8124 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8125 convertIntToRadioIndicationType(indicationType), pco);
8126 radioService[slotId]->checkReturnStatus(retStatus);
8127 } else {
8128 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8129 }
8130
8131 return 0;
8132}
8133
8134int radio::modemResetInd(int slotId,
8135 int indicationType, int token, RIL_Errno e, void *response,
8136 size_t responseLen) {
8137 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8138 if (response == NULL || responseLen == 0) {
8139 RLOGE("modemResetInd: invalid response");
8140 return 0;
8141 }
8142#if VDBG
8143 RLOGD("modemResetInd");
8144#endif
8145 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8146 convertIntToRadioIndicationType(indicationType),
8147 convertCharPtrToHidlString((char *) response));
8148 radioService[slotId]->checkReturnStatus(retStatus);
8149 } else {
8150 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8151 }
8152
8153 return 0;
8154}
8155
8156int radio::oemHookRawInd(int slotId,
8157 int indicationType, int token, RIL_Errno e, void *response,
8158 size_t responseLen) {
8159 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8160 if (response == NULL || responseLen == 0) {
8161 RLOGE("oemHookRawInd: invalid response");
8162 return 0;
8163 }
8164
8165 hidl_vec<uint8_t> data;
8166 data.setToExternal((uint8_t *) response, responseLen);
8167#if VDBG
8168 RLOGD("oemHookRawInd");
8169#endif
8170 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8171 convertIntToRadioIndicationType(indicationType), data);
8172 checkReturnStatus(slotId, retStatus, false);
8173 } else {
8174 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8175 }
8176
8177 return 0;
8178}
8179
8180void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8181 using namespace android::hardware;
8182 int simCount = 1;
8183 const char *serviceNames[] = {
8184 android::RIL_getServiceName()
8185 #if (SIM_COUNT >= 2)
8186 , RIL2_SERVICE_NAME
8187 #if (SIM_COUNT >= 3)
8188 , RIL3_SERVICE_NAME
8189 #if (SIM_COUNT >= 4)
8190 , RIL4_SERVICE_NAME
8191 #endif
8192 #endif
8193 #endif
8194 };
8195
8196 #if (SIM_COUNT >= 2)
8197 simCount = SIM_COUNT;
8198 #endif
8199
8200 configureRpcThreadpool(1, true /* callerWillJoin */);
8201 for (int i = 0; i < simCount; i++) {
8202 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8203 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8204 assert(ret == 0);
8205
8206 radioService[i] = new RadioImpl;
8207 radioService[i]->mSlotId = i;
8208 oemHookService[i] = new OemHookImpl;
8209 oemHookService[i]->mSlotId = i;
8210 RLOGD("registerService: starting IRadio %s", serviceNames[i]);
8211 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8212 status = oemHookService[i]->registerAsService(serviceNames[i]);
8213
8214 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8215 assert(ret == 0);
8216 }
8217
8218 s_vendorFunctions = callbacks;
8219 s_commands = commands;
8220}
8221
8222void rilc_thread_pool() {
8223 joinRpcThreadpool();
8224}
8225
8226pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8227 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8228
8229 #if (SIM_COUNT >= 2)
8230 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8231 #if (SIM_COUNT >= 3)
8232 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8233 #if (SIM_COUNT >= 4)
8234 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8235 #endif
8236 #endif
8237 #endif
8238
8239 return radioServiceRwlockPtr;
8240}