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