blob: f36ceb3319ffe5b575001d7855f73416a37454c9 [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
1944 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
1945
1946 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
1947 } else {
1948 RIL_InitialAttachApn_v15 iaa = {};
1949
1950 if (dataProfileInfo.apn.size() == 0) {
1951 iaa.apn = (char *) calloc(1, sizeof(char));
1952 if (iaa.apn == NULL) {
1953 RLOGE("Memory allocation failed for request %s",
1954 requestToString(pRI->pCI->requestNumber));
1955 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1956 return Void();
1957 }
1958 iaa.apn[0] = '\0';
1959 } else {
1960 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1961 return Void();
1962 }
1963 }
1964
1965 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
1966 memsetAndFreeStrings(1, iaa.apn);
1967 return Void();
1968 }
1969 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
1970 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
1971 return Void();
1972 }
1973 iaa.authtype = (int) dataProfileInfo.authType;
1974 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1975 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
1976 return Void();
1977 }
1978 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1979 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
1980 return Void();
1981 }
1982 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
1983 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
1984 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
1985 iaa.mtu = dataProfileInfo.mtu;
1986
1987 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
1988 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1989 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1990 iaa.password);
1991 return Void();
1992 }
1993
1994 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
1995 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1996 iaa.password);
1997 return Void();
1998 }
1999
2000 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2001
2002 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2003 iaa.password, iaa.mvnoMatchData);
2004 }
2005
2006 return Void();
2007}
2008
2009Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
2010#if VDBG
2011 RLOGD("getImsRegistrationState: serial %d", serial);
2012#endif
2013 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2014 return Void();
2015}
2016
2017bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2018 RIL_IMS_SMS_Message rism = {};
2019 char **pStrings;
2020 int countStrings = 2;
2021 int dataLen = sizeof(char *) * countStrings;
2022
2023 rism.tech = RADIO_TECH_3GPP;
2024 rism.retry = BOOL_TO_INT(message.retry);
2025 rism.messageRef = message.messageRef;
2026
2027 if (message.gsmMessage.size() != 1) {
2028 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2029 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2030 return false;
2031 }
2032
2033 pStrings = (char **)calloc(countStrings, sizeof(char *));
2034 if (pStrings == NULL) {
2035 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2036 requestToString(pRI->pCI->requestNumber));
2037 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2038 return false;
2039 }
2040
2041 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2042#ifdef MEMSET_FREED
2043 memset(pStrings, 0, datalen);
2044#endif
2045 free(pStrings);
2046 return false;
2047 }
2048
2049 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2050 memsetAndFreeStrings(1, pStrings[0]);
2051#ifdef MEMSET_FREED
2052 memset(pStrings, 0, datalen);
2053#endif
2054 free(pStrings);
2055 return false;
2056 }
2057
2058 rism.message.gsmMessage = pStrings;
2059 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2060 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2061
2062 for (int i = 0 ; i < countStrings ; i++) {
2063 memsetAndFreeStrings(1, pStrings[i]);
2064 }
2065
2066#ifdef MEMSET_FREED
2067 memset(pStrings, 0, datalen);
2068#endif
2069 free(pStrings);
2070
2071 return true;
2072}
2073
2074bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2075 RIL_IMS_SMS_Message rism = {};
2076 RIL_CDMA_SMS_Message rcsm = {};
2077
2078 if (message.cdmaMessage.size() != 1) {
2079 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2080 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2081 return false;
2082 }
2083
2084 rism.tech = RADIO_TECH_3GPP2;
2085 rism.retry = BOOL_TO_INT(message.retry);
2086 rism.messageRef = message.messageRef;
2087 rism.message.cdmaMessage = &rcsm;
2088
2089 constructCdmaSms(rcsm, message.cdmaMessage[0]);
2090
2091 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2092 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI, pRI->socket_id);
2093
2094 return true;
2095}
2096
2097Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2098#if VDBG
2099 RLOGD("sendImsSms: serial %d", serial);
2100#endif
2101 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2102 if (pRI == NULL) {
2103 return Void();
2104 }
2105
2106 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2107
2108 if (RADIO_TECH_3GPP == format) {
2109 dispatchImsGsmSms(message, pRI);
2110 } else if (RADIO_TECH_3GPP2 == format) {
2111 dispatchImsCdmaSms(message, pRI);
2112 } else {
2113 RLOGE("sendImsSms: Invalid radio tech %s",
2114 requestToString(pRI->pCI->requestNumber));
2115 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2116 }
2117 return Void();
2118}
2119
2120Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2121#if VDBG
2122 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2123#endif
2124 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2125 return Void();
2126}
2127
2128Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2129#if VDBG
2130 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2131#endif
2132 if (s_vendorFunctions->version < 15) {
2133 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2134 } else {
2135 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2136 if (pRI == NULL) {
2137 return Void();
2138 }
2139
2140 RIL_OpenChannelParams params = {};
2141
2142 params.p2 = p2;
2143
2144 if (!copyHidlStringToRil(&params.aidPtr, aid, pRI)) {
2145 return Void();
2146 }
2147
2148 CALL_ONREQUEST(pRI->pCI->requestNumber, &params, sizeof(params), pRI, mSlotId);
2149
2150 memsetAndFreeStrings(1, params.aidPtr);
2151 }
2152 return Void();
2153}
2154
2155Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2156#if VDBG
2157 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2158#endif
2159 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2160 return Void();
2161}
2162
2163Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2164#if VDBG
2165 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2166#endif
2167 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2168 return Void();
2169}
2170
2171Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2172#if VDBG
2173 RLOGD("nvReadItem: serial %d", serial);
2174#endif
2175 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2176 if (pRI == NULL) {
2177 return Void();
2178 }
2179
2180 RIL_NV_ReadItem nvri = {};
2181 nvri.itemID = (RIL_NV_Item) itemId;
2182
2183 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2184 return Void();
2185}
2186
2187Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2188#if VDBG
2189 RLOGD("nvWriteItem: serial %d", serial);
2190#endif
2191 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2192 if (pRI == NULL) {
2193 return Void();
2194 }
2195
2196 RIL_NV_WriteItem nvwi = {};
2197
2198 nvwi.itemID = (RIL_NV_Item) item.itemId;
2199
2200 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2201 return Void();
2202 }
2203
2204 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2205
2206 memsetAndFreeStrings(1, nvwi.value);
2207 return Void();
2208}
2209
2210Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2211#if VDBG
2212 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2213#endif
2214 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2215 return Void();
2216}
2217
2218Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2219 int rilResetType = -1;
2220#if VDBG
2221 RLOGD("nvResetConfig: serial %d", serial);
2222#endif
2223 /* Convert ResetNvType to RIL.h values
2224 * RIL_REQUEST_NV_RESET_CONFIG
2225 * 1 - reload all NV items
2226 * 2 - erase NV reset (SCRTN)
2227 * 3 - factory reset (RTN)
2228 */
2229 switch(resetType) {
2230 case ResetNvType::RELOAD:
2231 rilResetType = 1;
2232 break;
2233 case ResetNvType::ERASE:
2234 rilResetType = 2;
2235 break;
2236 case ResetNvType::FACTORY_RESET:
2237 rilResetType = 3;
2238 break;
2239 }
2240 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2241 return Void();
2242}
2243
2244Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2245#if VDBG
2246 RLOGD("setUiccSubscription: serial %d", serial);
2247#endif
2248 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2249 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2250 if (pRI == NULL) {
2251 return Void();
2252 }
2253
2254 RIL_SelectUiccSub rilUiccSub = {};
2255
2256 rilUiccSub.slot = uiccSub.slot;
2257 rilUiccSub.app_index = uiccSub.appIndex;
2258 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2259 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2260
2261 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2262 return Void();
2263}
2264
2265Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2266#if VDBG
2267 RLOGD("setDataAllowed: serial %d", serial);
2268#endif
2269 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2270 return Void();
2271}
2272
2273Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2274#if VDBG
2275 RLOGD("getHardwareConfig: serial %d", serial);
2276#endif
2277 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2278 return Void();
2279}
2280
2281Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2282 const hidl_string& authData, const hidl_string& aid) {
2283#if VDBG
2284 RLOGD("requestIccSimAuthentication: serial %d", serial);
2285#endif
2286 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2287 if (pRI == NULL) {
2288 return Void();
2289 }
2290
2291 RIL_SimAuthentication pf = {};
2292
2293 pf.authContext = authContext;
2294
2295 int len;
2296 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2297 return Void();
2298 }
2299
2300 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2301 memsetAndFreeStrings(1, pf.authData);
2302 return Void();
2303 }
2304
2305 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2306
2307 memsetAndFreeStrings(2, pf.authData, pf.aid);
2308 return Void();
2309}
2310
2311/**
2312 * @param numProfiles number of data profile
2313 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2314 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2315 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2316 * @param numfields number of string-type member in the data profile structure
2317 * @param ... the variadic parameters are pointers to each string-type member
2318 **/
2319template <typename T>
2320void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2321 int numfields, ...) {
2322 va_list args;
2323 va_start(args, numfields);
2324
2325 // Iterate through each string-type field that need to be free.
2326 for (int i = 0; i < numfields; i++) {
2327 // Iterate through each data profile and free that specific string-type field.
2328 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2329 char *T::*ptr = va_arg(args, char *T::*);
2330 for (int j = 0; j < numProfiles; j++) {
2331 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2332 }
2333 }
2334
2335 va_end(args);
2336
2337#ifdef MEMSET_FREED
2338 memset(dataProfiles, 0, numProfiles * sizeof(T));
2339 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2340#endif
2341 free(dataProfiles);
2342 free(dataProfilePtrs);
2343}
2344
2345Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2346 bool isRoaming) {
2347#if VDBG
2348 RLOGD("setDataProfile: serial %d", serial);
2349#endif
2350 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2351 if (pRI == NULL) {
2352 return Void();
2353 }
2354
2355 size_t num = profiles.size();
2356 bool success = false;
2357
2358 if (s_vendorFunctions->version <= 14) {
2359
2360 RIL_DataProfileInfo *dataProfiles =
2361 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2362
2363 if (dataProfiles == NULL) {
2364 RLOGE("Memory allocation failed for request %s",
2365 requestToString(pRI->pCI->requestNumber));
2366 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2367 return Void();
2368 }
2369
2370 RIL_DataProfileInfo **dataProfilePtrs =
2371 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2372 if (dataProfilePtrs == NULL) {
2373 RLOGE("Memory allocation failed for request %s",
2374 requestToString(pRI->pCI->requestNumber));
2375 free(dataProfiles);
2376 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2377 return Void();
2378 }
2379
2380 for (size_t i = 0; i < num; i++) {
2381 dataProfilePtrs[i] = &dataProfiles[i];
2382
2383 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2384
2385 const hidl_string &protocol =
2386 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2387
2388 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2389 success = false;
2390 }
2391
2392 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2393 success = false;
2394 }
2395 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2396 pRI)) {
2397 success = false;
2398 }
2399
2400 if (!success) {
2401 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2402 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2403 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2404 return Void();
2405 }
2406
2407 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2408 dataProfiles[i].authType = (int) profiles[i].authType;
2409 dataProfiles[i].type = (int) profiles[i].type;
2410 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2411 dataProfiles[i].maxConns = profiles[i].maxConns;
2412 dataProfiles[i].waitTime = profiles[i].waitTime;
2413 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2414 }
2415
2416 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2417 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2418
2419 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2420 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2421 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2422 } else {
2423 RIL_DataProfileInfo_v15 *dataProfiles =
2424 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2425
2426 if (dataProfiles == NULL) {
2427 RLOGE("Memory allocation failed for request %s",
2428 requestToString(pRI->pCI->requestNumber));
2429 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2430 return Void();
2431 }
2432
2433 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2434 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2435 if (dataProfilePtrs == NULL) {
2436 RLOGE("Memory allocation failed for request %s",
2437 requestToString(pRI->pCI->requestNumber));
2438 free(dataProfiles);
2439 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2440 return Void();
2441 }
2442
2443 for (size_t i = 0; i < num; i++) {
2444 dataProfilePtrs[i] = &dataProfiles[i];
2445
2446 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2447 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2448 pRI)) {
2449 success = false;
2450 }
2451 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2452 profiles[i].roamingProtocol, pRI)) {
2453 success = false;
2454 }
2455 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2456 success = false;
2457 }
2458 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2459 pRI)) {
2460 success = false;
2461 }
2462
2463 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2464 profiles[i].mvnoMatchData, pRI)) {
2465 success = false;
2466 }
2467
2468 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2469 dataProfiles[i].mvnoType)) {
2470 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2471 success = false;
2472 }
2473
2474 if (!success) {
2475 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2476 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2477 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2478 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2479 return Void();
2480 }
2481
2482 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2483 dataProfiles[i].authType = (int) profiles[i].authType;
2484 dataProfiles[i].type = (int) profiles[i].type;
2485 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2486 dataProfiles[i].maxConns = profiles[i].maxConns;
2487 dataProfiles[i].waitTime = profiles[i].waitTime;
2488 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2489 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2490 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2491 dataProfiles[i].mtu = profiles[i].mtu;
2492 }
2493
2494 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2495 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
2496
2497 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2498 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2499 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2500 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2501 }
2502
2503 return Void();
2504}
2505
2506Return<void> RadioImpl::requestShutdown(int32_t serial) {
2507#if VDBG
2508 RLOGD("requestShutdown: serial %d", serial);
2509#endif
2510 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2511 return Void();
2512}
2513
2514Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2515#if VDBG
2516 RLOGD("getRadioCapability: serial %d", serial);
2517#endif
2518 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2519 return Void();
2520}
2521
2522Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2523#if VDBG
2524 RLOGD("setRadioCapability: serial %d", serial);
2525#endif
2526 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2527 if (pRI == NULL) {
2528 return Void();
2529 }
2530
2531 RIL_RadioCapability rilRc = {};
2532
2533 // TODO : set rilRc.version using HIDL version ?
2534 rilRc.session = rc.session;
2535 rilRc.phase = (int) rc.phase;
2536 rilRc.rat = (int) rc.raf;
2537 rilRc.status = (int) rc.status;
2538 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2539
2540 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
2541
2542 return Void();
2543}
2544
2545Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2546#if VDBG
2547 RLOGD("startLceService: serial %d", serial);
2548#endif
2549 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2550 BOOL_TO_INT(pullMode));
2551 return Void();
2552}
2553
2554Return<void> RadioImpl::stopLceService(int32_t serial) {
2555#if VDBG
2556 RLOGD("stopLceService: serial %d", serial);
2557#endif
2558 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2559 return Void();
2560}
2561
2562Return<void> RadioImpl::pullLceData(int32_t serial) {
2563#if VDBG
2564 RLOGD("pullLceData: serial %d", serial);
2565#endif
2566 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2567 return Void();
2568}
2569
2570Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2571#if VDBG
2572 RLOGD("getModemActivityInfo: serial %d", serial);
2573#endif
2574 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2575 return Void();
2576}
2577
2578Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2579 const CarrierRestrictions& carriers) {
2580#if VDBG
2581 RLOGD("setAllowedCarriers: serial %d", serial);
2582#endif
2583 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2584 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2585 if (pRI == NULL) {
2586 return Void();
2587 }
2588
2589 RIL_CarrierRestrictions cr = {};
2590 RIL_Carrier *allowedCarriers = NULL;
2591 RIL_Carrier *excludedCarriers = NULL;
2592
2593 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2594 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2595 if (allowedCarriers == NULL) {
2596 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2597 requestToString(pRI->pCI->requestNumber));
2598 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2599 return Void();
2600 }
2601 cr.allowed_carriers = allowedCarriers;
2602
2603 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2604 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2605 if (excludedCarriers == NULL) {
2606 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2607 requestToString(pRI->pCI->requestNumber));
2608 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2609#ifdef MEMSET_FREED
2610 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2611#endif
2612 free(allowedCarriers);
2613 return Void();
2614 }
2615 cr.excluded_carriers = excludedCarriers;
2616
2617 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2618 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2619 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2620 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2621 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2622 }
2623
2624 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2625 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2626 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2627 excludedCarriers[i].match_type =
2628 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2629 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2630 }
2631
2632 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
2633
2634#ifdef MEMSET_FREED
2635 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2636 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2637#endif
2638 free(allowedCarriers);
2639 free(excludedCarriers);
2640 return Void();
2641}
2642
2643Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2644#if VDBG
2645 RLOGD("getAllowedCarriers: serial %d", serial);
2646#endif
2647 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2648 return Void();
2649}
2650
2651Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2652 bool state) {
2653#if VDBG
2654 RLOGD("sendDeviceState: serial %d", serial);
2655#endif
2656 if (s_vendorFunctions->version < 15) {
2657 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2658 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2659 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2660 } else {
2661 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2662 RIL_REQUEST_SEND_DEVICE_STATE);
2663 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2664 }
2665 return Void();
2666 }
2667 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2668 BOOL_TO_INT(state));
2669 return Void();
2670}
2671
2672Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2673#if VDBG
2674 RLOGD("setIndicationFilter: serial %d", serial);
2675#endif
2676 if (s_vendorFunctions->version < 15) {
2677 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2678 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2679 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2680 return Void();
2681 }
2682 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2683 return Void();
2684}
2685
2686Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2687#if VDBG
2688 RLOGD("setSimCardPower: serial %d", serial);
2689#endif
2690 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2691 return Void();
2692}
2693
2694Return<void> RadioImpl::responseAcknowledgement() {
2695 android::releaseWakeLock();
2696 return Void();
2697}
2698
2699Return<void> OemHookImpl::setResponseFunctions(
2700 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2701 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2702#if VDBG
2703 RLOGD("OemHookImpl::setResponseFunctions");
2704#endif
2705
2706 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2707 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2708 assert(ret == 0);
2709
2710 mOemHookResponse = oemHookResponseParam;
2711 mOemHookIndication = oemHookIndicationParam;
2712 mCounterOemHook[mSlotId]++;
2713
2714 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2715 assert(ret == 0);
2716
2717 return Void();
2718}
2719
2720Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2721#if VDBG
2722 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2723#endif
2724 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2725 return Void();
2726}
2727
2728Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2729 const hidl_vec<hidl_string>& data) {
2730#if VDBG
2731 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2732#endif
2733 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2734 return Void();
2735}
2736
2737/***************************************************************************************************
2738 * RESPONSE FUNCTIONS
2739 * Functions above are used for requests going from framework to vendor code. The ones below are
2740 * responses for those requests coming back from the vendor code.
2741 **************************************************************************************************/
2742
2743void radio::acknowledgeRequest(int slotId, int serial) {
2744 if (radioService[slotId]->mRadioResponse != NULL) {
2745 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2746 radioService[slotId]->checkReturnStatus(retStatus);
2747 } else {
2748 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2749 }
2750}
2751
2752void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2753 RIL_Errno e) {
2754 responseInfo.serial = serial;
2755 switch (responseType) {
2756 case RESPONSE_SOLICITED:
2757 responseInfo.type = RadioResponseType::SOLICITED;
2758 break;
2759 case RESPONSE_SOLICITED_ACK_EXP:
2760 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2761 break;
2762 }
2763 responseInfo.error = (RadioError) e;
2764}
2765
2766int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2767 void *response, size_t responseLen) {
2768 populateResponseInfo(responseInfo, serial, responseType, e);
2769 int ret = -1;
2770
2771 if (response == NULL && responseLen == 0) {
2772 // Earlier RILs did not send a response for some cases although the interface
2773 // expected an integer as response. Do not return error if response is empty. Instead
2774 // Return -1 in those cases to maintain backward compatibility.
2775 } else if (response == NULL || responseLen != sizeof(int)) {
2776 RLOGE("responseIntOrEmpty: Invalid response");
2777 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2778 } else {
2779 int *p_int = (int *) response;
2780 ret = p_int[0];
2781 }
2782 return ret;
2783}
2784
2785int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2786 void *response, size_t responseLen) {
2787 populateResponseInfo(responseInfo, serial, responseType, e);
2788 int ret = -1;
2789
2790 if (response == NULL || responseLen != sizeof(int)) {
2791 RLOGE("responseInt: Invalid response");
2792 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2793 } else {
2794 int *p_int = (int *) response;
2795 ret = p_int[0];
2796 }
2797 return ret;
2798}
2799
2800int radio::getIccCardStatusResponse(int slotId,
2801 int responseType, int serial, RIL_Errno e,
2802 void *response, size_t responseLen) {
2803 if (radioService[slotId]->mRadioResponse != NULL) {
2804 RadioResponseInfo responseInfo = {};
2805 populateResponseInfo(responseInfo, serial, responseType, e);
2806 CardStatus cardStatus = {};
2807 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2808 RLOGE("getIccCardStatusResponse: Invalid response");
2809 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2810 } else {
2811 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2812 cardStatus.cardState = (CardState) p_cur->card_state;
2813 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2814 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2815 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2816 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2817
2818 RIL_AppStatus *rilAppStatus = p_cur->applications;
2819 cardStatus.applications.resize(p_cur->num_applications);
2820 AppStatus *appStatus = cardStatus.applications.data();
2821#if VDBG
2822 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2823#endif
2824 for (int i = 0; i < p_cur->num_applications; i++) {
2825 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2826 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2827 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2828 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2829 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2830 rilAppStatus[i].app_label_ptr);
2831 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2832 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2833 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2834 }
2835 }
2836
2837 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2838 getIccCardStatusResponse(responseInfo, cardStatus);
2839 radioService[slotId]->checkReturnStatus(retStatus);
2840 } else {
2841 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2842 }
2843
2844 return 0;
2845}
2846
2847int radio::supplyIccPinForAppResponse(int slotId,
2848 int responseType, int serial, RIL_Errno e,
2849 void *response, size_t responseLen) {
2850#if VDBG
2851 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
2852#endif
2853
2854 if (radioService[slotId]->mRadioResponse != NULL) {
2855 RadioResponseInfo responseInfo = {};
2856 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2857 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2858 supplyIccPinForAppResponse(responseInfo, ret);
2859 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
2860 radioService[slotId]->checkReturnStatus(retStatus);
2861 } else {
2862 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2863 slotId);
2864 }
2865
2866 return 0;
2867}
2868
2869int radio::supplyIccPukForAppResponse(int slotId,
2870 int responseType, int serial, RIL_Errno e,
2871 void *response, size_t responseLen) {
2872#if VDBG
2873 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
2874#endif
2875
2876 if (radioService[slotId]->mRadioResponse != NULL) {
2877 RadioResponseInfo responseInfo = {};
2878 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2879 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2880 responseInfo, ret);
2881 radioService[slotId]->checkReturnStatus(retStatus);
2882 } else {
2883 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2884 slotId);
2885 }
2886
2887 return 0;
2888}
2889
2890int radio::supplyIccPin2ForAppResponse(int slotId,
2891 int responseType, int serial, RIL_Errno e,
2892 void *response, size_t responseLen) {
2893#if VDBG
2894 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
2895#endif
2896
2897 if (radioService[slotId]->mRadioResponse != NULL) {
2898 RadioResponseInfo responseInfo = {};
2899 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2900 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2901 supplyIccPin2ForAppResponse(responseInfo, ret);
2902 radioService[slotId]->checkReturnStatus(retStatus);
2903 } else {
2904 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2905 slotId);
2906 }
2907
2908 return 0;
2909}
2910
2911int radio::supplyIccPuk2ForAppResponse(int slotId,
2912 int responseType, int serial, RIL_Errno e,
2913 void *response, size_t responseLen) {
2914#if VDBG
2915 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
2916#endif
2917
2918 if (radioService[slotId]->mRadioResponse != NULL) {
2919 RadioResponseInfo responseInfo = {};
2920 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2921 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2922 supplyIccPuk2ForAppResponse(responseInfo, ret);
2923 radioService[slotId]->checkReturnStatus(retStatus);
2924 } else {
2925 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2926 slotId);
2927 }
2928
2929 return 0;
2930}
2931
2932int radio::changeIccPinForAppResponse(int slotId,
2933 int responseType, int serial, RIL_Errno e,
2934 void *response, size_t responseLen) {
2935#if VDBG
2936 RLOGD("changeIccPinForAppResponse: serial %d", serial);
2937#endif
2938
2939 if (radioService[slotId]->mRadioResponse != NULL) {
2940 RadioResponseInfo responseInfo = {};
2941 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2942 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2943 changeIccPinForAppResponse(responseInfo, ret);
2944 radioService[slotId]->checkReturnStatus(retStatus);
2945 } else {
2946 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2947 slotId);
2948 }
2949
2950 return 0;
2951}
2952
2953int radio::changeIccPin2ForAppResponse(int slotId,
2954 int responseType, int serial, RIL_Errno e,
2955 void *response, size_t responseLen) {
2956#if VDBG
2957 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
2958#endif
2959
2960 if (radioService[slotId]->mRadioResponse != NULL) {
2961 RadioResponseInfo responseInfo = {};
2962 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2963 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2964 changeIccPin2ForAppResponse(responseInfo, ret);
2965 radioService[slotId]->checkReturnStatus(retStatus);
2966 } else {
2967 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2968 slotId);
2969 }
2970
2971 return 0;
2972}
2973
2974int radio::supplyNetworkDepersonalizationResponse(int slotId,
2975 int responseType, int serial, RIL_Errno e,
2976 void *response, size_t responseLen) {
2977#if VDBG
2978 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
2979#endif
2980
2981 if (radioService[slotId]->mRadioResponse != NULL) {
2982 RadioResponseInfo responseInfo = {};
2983 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2984 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2985 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2986 radioService[slotId]->checkReturnStatus(retStatus);
2987 } else {
2988 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
2989 "NULL", slotId);
2990 }
2991
2992 return 0;
2993}
2994
2995int radio::getCurrentCallsResponse(int slotId,
2996 int responseType, int serial, RIL_Errno e,
2997 void *response, size_t responseLen) {
2998#if VDBG
2999 RLOGD("getCurrentCallsResponse: serial %d", serial);
3000#endif
3001
3002 if (radioService[slotId]->mRadioResponse != NULL) {
3003 RadioResponseInfo responseInfo = {};
3004 populateResponseInfo(responseInfo, serial, responseType, e);
3005
3006 hidl_vec<Call> calls;
3007 if ((response == NULL && responseLen != 0)
3008 || (responseLen % sizeof(RIL_Call *)) != 0) {
3009 RLOGE("getCurrentCallsResponse: Invalid response");
3010 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3011 } else {
3012 int num = responseLen / sizeof(RIL_Call *);
3013 calls.resize(num);
3014
3015 for (int i = 0 ; i < num ; i++) {
3016 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3017 /* each call info */
3018 calls[i].state = (CallState) p_cur->state;
Martin Bouchetd9123962017-09-24 03:14:57 -03003019 calls[i].index = p_cur->index & 0xff;
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03003020 calls[i].toa = p_cur->toa;
3021 calls[i].isMpty = p_cur->isMpty;
3022 calls[i].isMT = p_cur->isMT;
3023 calls[i].als = p_cur->als;
3024 calls[i].isVoice = p_cur->isVoice;
3025 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3026 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3027 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3028 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3029 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3030 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3031 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3032 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3033 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3034 // convert uusInfo->uusData to a null-terminated string
3035 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3036 calls[i].uusInfo[0].uusData = nullTermStr;
3037 free(nullTermStr);
3038 }
3039 }
3040 }
3041
3042 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3043 getCurrentCallsResponse(responseInfo, calls);
3044 radioService[slotId]->checkReturnStatus(retStatus);
3045 } else {
3046 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3047 }
3048
3049 return 0;
3050}
3051
3052int radio::dialResponse(int slotId,
3053 int responseType, int serial, RIL_Errno e, void *response,
3054 size_t responseLen) {
3055#if VDBG
3056 RLOGD("dialResponse: serial %d", serial);
3057#endif
3058
3059 if (radioService[slotId]->mRadioResponse != NULL) {
3060 RadioResponseInfo responseInfo = {};
3061 populateResponseInfo(responseInfo, serial, responseType, e);
3062 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3063 radioService[slotId]->checkReturnStatus(retStatus);
3064 } else {
3065 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3066 }
3067
3068 return 0;
3069}
3070
3071int radio::getIMSIForAppResponse(int slotId,
3072 int responseType, int serial, RIL_Errno e, void *response,
3073 size_t responseLen) {
3074#if VDBG
3075 RLOGD("getIMSIForAppResponse: serial %d", serial);
3076#endif
3077
3078 if (radioService[slotId]->mRadioResponse != NULL) {
3079 RadioResponseInfo responseInfo = {};
3080 populateResponseInfo(responseInfo, serial, responseType, e);
3081 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3082 responseInfo, convertCharPtrToHidlString((char *) response));
3083 radioService[slotId]->checkReturnStatus(retStatus);
3084 } else {
3085 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3086 slotId);
3087 }
3088
3089 return 0;
3090}
3091
3092int radio::hangupConnectionResponse(int slotId,
3093 int responseType, int serial, RIL_Errno e,
3094 void *response, size_t responseLen) {
3095#if VDBG
3096 RLOGD("hangupConnectionResponse: serial %d", serial);
3097#endif
3098
3099 if (radioService[slotId]->mRadioResponse != NULL) {
3100 RadioResponseInfo responseInfo = {};
3101 populateResponseInfo(responseInfo, serial, responseType, e);
3102 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3103 responseInfo);
3104 radioService[slotId]->checkReturnStatus(retStatus);
3105 } else {
3106 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3107 slotId);
3108 }
3109
3110 return 0;
3111}
3112
3113int radio::hangupWaitingOrBackgroundResponse(int slotId,
3114 int responseType, int serial, RIL_Errno e,
3115 void *response, size_t responseLen) {
3116#if VDBG
3117 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3118#endif
3119
3120 if (radioService[slotId]->mRadioResponse != NULL) {
3121 RadioResponseInfo responseInfo = {};
3122 populateResponseInfo(responseInfo, serial, responseType, e);
3123 Return<void> retStatus =
3124 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3125 responseInfo);
3126 radioService[slotId]->checkReturnStatus(retStatus);
3127 } else {
3128 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3129 slotId);
3130 }
3131
3132 return 0;
3133}
3134
3135int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3136 RIL_Errno e, void *response,
3137 size_t responseLen) {
3138#if VDBG
3139 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3140#endif
3141
3142 if (radioService[slotId]->mRadioResponse != NULL) {
3143 RadioResponseInfo responseInfo = {};
3144 populateResponseInfo(responseInfo, serial, responseType, e);
3145 Return<void> retStatus =
3146 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3147 responseInfo);
3148 radioService[slotId]->checkReturnStatus(retStatus);
3149 } else {
3150 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3151 slotId);
3152 }
3153
3154 return 0;
3155}
3156
3157int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3158 RIL_Errno e, void *response,
3159 size_t responseLen) {
3160#if VDBG
3161 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3162#endif
3163
3164 if (radioService[slotId]->mRadioResponse != NULL) {
3165 RadioResponseInfo responseInfo = {};
3166 populateResponseInfo(responseInfo, serial, responseType, e);
3167 Return<void> retStatus =
3168 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3169 responseInfo);
3170 radioService[slotId]->checkReturnStatus(retStatus);
3171 } else {
3172 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3173 "== NULL", slotId);
3174 }
3175
3176 return 0;
3177}
3178
3179int radio::conferenceResponse(int slotId, int responseType,
3180 int serial, RIL_Errno e, void *response, size_t responseLen) {
3181#if VDBG
3182 RLOGD("conferenceResponse: serial %d", serial);
3183#endif
3184
3185 if (radioService[slotId]->mRadioResponse != NULL) {
3186 RadioResponseInfo responseInfo = {};
3187 populateResponseInfo(responseInfo, serial, responseType, e);
3188 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3189 responseInfo);
3190 radioService[slotId]->checkReturnStatus(retStatus);
3191 } else {
3192 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3193 slotId);
3194 }
3195
3196 return 0;
3197}
3198
3199int radio::rejectCallResponse(int slotId, int responseType,
3200 int serial, RIL_Errno e, void *response, size_t responseLen) {
3201#if VDBG
3202 RLOGD("rejectCallResponse: serial %d", serial);
3203#endif
3204
3205 if (radioService[slotId]->mRadioResponse != NULL) {
3206 RadioResponseInfo responseInfo = {};
3207 populateResponseInfo(responseInfo, serial, responseType, e);
3208 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3209 responseInfo);
3210 radioService[slotId]->checkReturnStatus(retStatus);
3211 } else {
3212 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3213 slotId);
3214 }
3215
3216 return 0;
3217}
3218
3219int radio::getLastCallFailCauseResponse(int slotId,
3220 int responseType, int serial, RIL_Errno e, void *response,
3221 size_t responseLen) {
3222#if VDBG
3223 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3224#endif
3225
3226 if (radioService[slotId]->mRadioResponse != NULL) {
3227 RadioResponseInfo responseInfo = {};
3228 populateResponseInfo(responseInfo, serial, responseType, e);
3229
3230 LastCallFailCauseInfo info = {};
3231 info.vendorCause = hidl_string();
3232 if (response == NULL) {
3233 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3234 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3235 } else if (responseLen == sizeof(int)) {
3236 int *pInt = (int *) response;
3237 info.causeCode = (LastCallFailCause) pInt[0];
3238 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3239 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3240 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3241 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3242 } else {
3243 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3244 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3245 }
3246
3247 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3248 responseInfo, info);
3249 radioService[slotId]->checkReturnStatus(retStatus);
3250 } else {
3251 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3252 slotId);
3253 }
3254
3255 return 0;
3256}
3257
3258int radio::getSignalStrengthResponse(int slotId,
3259 int responseType, int serial, RIL_Errno e,
3260 void *response, size_t responseLen) {
3261#if VDBG
3262 RLOGD("getSignalStrengthResponse: serial %d", serial);
3263#endif
3264
3265 if (radioService[slotId]->mRadioResponse != NULL) {
3266 RadioResponseInfo responseInfo = {};
3267 populateResponseInfo(responseInfo, serial, responseType, e);
3268 SignalStrength signalStrength = {};
3269 if (response == NULL || (responseLen != sizeof(RIL_SignalStrength_v10)
Martin Bouchet6e9a4972017-09-23 04:55:52 -03003270 && responseLen != sizeof(RIL_SignalStrength_v8)
3271 && responseLen != sizeof(RIL_SignalStrength_v6)
3272 && responseLen != sizeof(RIL_SignalStrength_v5))) {
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03003273 RLOGE("getSignalStrengthResponse: Invalid response");
3274 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3275 } else {
3276 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3277 }
3278
3279 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3280 responseInfo, signalStrength);
3281 radioService[slotId]->checkReturnStatus(retStatus);
3282 } else {
3283 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3284 slotId);
3285 }
3286
3287 return 0;
3288}
3289
3290RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3291 if (rat == NULL) {
3292 return RIL_CELL_INFO_TYPE_NONE;
3293 }
3294
3295 int radioTech = atoi(rat);
3296
3297 switch(radioTech) {
3298
3299 case RADIO_TECH_GPRS:
3300 case RADIO_TECH_EDGE:
3301 case RADIO_TECH_GSM: {
3302 return RIL_CELL_INFO_TYPE_GSM;
3303 }
3304
3305 case RADIO_TECH_UMTS:
3306 case RADIO_TECH_HSDPA:
3307 case RADIO_TECH_HSUPA:
3308 case RADIO_TECH_HSPA:
3309 case RADIO_TECH_HSPAP: {
3310 return RIL_CELL_INFO_TYPE_WCDMA;
3311 }
3312
3313 case RADIO_TECH_IS95A:
3314 case RADIO_TECH_IS95B:
3315 case RADIO_TECH_1xRTT:
3316 case RADIO_TECH_EVDO_0:
3317 case RADIO_TECH_EVDO_A:
3318 case RADIO_TECH_EVDO_B:
3319 case RADIO_TECH_EHRPD: {
3320 return RIL_CELL_INFO_TYPE_CDMA;
3321 }
3322
3323 case RADIO_TECH_LTE:
3324 case RADIO_TECH_LTE_CA: {
3325 return RIL_CELL_INFO_TYPE_LTE;
3326 }
3327
3328 case RADIO_TECH_TD_SCDMA: {
3329 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3330 }
3331
3332 default: {
3333 break;
3334 }
3335 }
3336
3337 return RIL_CELL_INFO_TYPE_NONE;
3338
3339}
3340
3341void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3342
3343 cellIdentity.cellIdentityGsm.resize(0);
3344 cellIdentity.cellIdentityWcdma.resize(0);
3345 cellIdentity.cellIdentityCdma.resize(0);
3346 cellIdentity.cellIdentityTdscdma.resize(0);
3347 cellIdentity.cellIdentityLte.resize(0);
3348 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3349 switch(rilCellIdentity.cellInfoType) {
3350
3351 case RIL_CELL_INFO_TYPE_GSM: {
3352 cellIdentity.cellIdentityGsm.resize(1);
3353 cellIdentity.cellIdentityGsm[0].mcc =
3354 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3355 cellIdentity.cellIdentityGsm[0].mnc =
3356 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3357 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3358 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3359 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3360 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3361 break;
3362 }
3363
3364 case RIL_CELL_INFO_TYPE_WCDMA: {
3365 cellIdentity.cellIdentityWcdma.resize(1);
3366 cellIdentity.cellIdentityWcdma[0].mcc =
3367 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3368 cellIdentity.cellIdentityWcdma[0].mnc =
3369 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3370 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3371 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3372 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3373 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3374 break;
3375 }
3376
3377 case RIL_CELL_INFO_TYPE_CDMA: {
3378 cellIdentity.cellIdentityCdma.resize(1);
3379 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3380 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3381 cellIdentity.cellIdentityCdma[0].baseStationId =
3382 rilCellIdentity.cellIdentityCdma.basestationId;
3383 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3384 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3385 break;
3386 }
3387
3388 case RIL_CELL_INFO_TYPE_LTE: {
3389 cellIdentity.cellIdentityLte.resize(1);
3390 cellIdentity.cellIdentityLte[0].mcc =
3391 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3392 cellIdentity.cellIdentityLte[0].mnc =
3393 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3394 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3395 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3396 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3397 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3398 break;
3399 }
3400
3401 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3402 cellIdentity.cellIdentityTdscdma.resize(1);
3403 cellIdentity.cellIdentityTdscdma[0].mcc =
3404 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3405 cellIdentity.cellIdentityTdscdma[0].mnc =
3406 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3407 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3408 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3409 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3410 break;
3411 }
3412
3413 default: {
3414 break;
3415 }
3416 }
3417}
3418
3419int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3420 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3421 return atoi(response[index]);
3422 }
3423
3424 return -1;
3425}
3426
3427int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
3428 const int hexBase = 16;
3429 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3430 return strtol(response[index], NULL, hexBase);
3431 }
3432
3433 return -1;
3434}
3435
3436/* Fill Cell Identity info from Voice Registration State Response.
3437 * This fucntion is applicable only for RIL Version < 15.
3438 * Response is a "char **".
3439 * First and Second entries are in hex string format
3440 * and rest are integers represented in ascii format. */
3441void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3442 int numStrings, char** response) {
3443
3444 RIL_CellIdentity_v16 rilCellIdentity;
3445 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3446
3447 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3448 switch(rilCellIdentity.cellInfoType) {
3449
3450 case RIL_CELL_INFO_TYPE_GSM: {
3451 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3452 rilCellIdentity.cellIdentityGsm.lac =
3453 convertResponseHexStringEntryToInt(response, 1, numStrings);
3454
3455 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3456 rilCellIdentity.cellIdentityGsm.cid =
3457 convertResponseHexStringEntryToInt(response, 2, numStrings);
3458 break;
3459 }
3460
3461 case RIL_CELL_INFO_TYPE_WCDMA: {
3462 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3463 rilCellIdentity.cellIdentityWcdma.lac =
3464 convertResponseHexStringEntryToInt(response, 1, numStrings);
3465
3466 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3467 rilCellIdentity.cellIdentityWcdma.cid =
3468 convertResponseHexStringEntryToInt(response, 2, numStrings);
3469 rilCellIdentity.cellIdentityWcdma.psc =
3470 convertResponseStringEntryToInt(response, 14, numStrings);
3471 break;
3472 }
3473
3474 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3475 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3476 rilCellIdentity.cellIdentityTdscdma.lac =
3477 convertResponseHexStringEntryToInt(response, 1, numStrings);
3478
3479 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3480 rilCellIdentity.cellIdentityTdscdma.cid =
3481 convertResponseHexStringEntryToInt(response, 2, numStrings);
3482 break;
3483 }
3484
3485 case RIL_CELL_INFO_TYPE_CDMA:{
3486 rilCellIdentity.cellIdentityCdma.basestationId =
3487 convertResponseStringEntryToInt(response, 4, numStrings);
3488 rilCellIdentity.cellIdentityCdma.longitude =
3489 convertResponseStringEntryToInt(response, 5, numStrings);
3490 rilCellIdentity.cellIdentityCdma.latitude =
3491 convertResponseStringEntryToInt(response, 6, numStrings);
3492 rilCellIdentity.cellIdentityCdma.systemId =
3493 convertResponseStringEntryToInt(response, 8, numStrings);
3494 rilCellIdentity.cellIdentityCdma.networkId =
3495 convertResponseStringEntryToInt(response, 9, numStrings);
3496 break;
3497 }
3498
3499 case RIL_CELL_INFO_TYPE_LTE:{
3500 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
3501 rilCellIdentity.cellIdentityLte.tac =
3502 convertResponseHexStringEntryToInt(response, 1, numStrings);
3503
3504 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3505 rilCellIdentity.cellIdentityLte.ci =
3506 convertResponseHexStringEntryToInt(response, 2, numStrings);
3507 break;
3508 }
3509
3510 default: {
3511 break;
3512 }
3513 }
3514
3515 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3516}
3517
3518/* Fill Cell Identity info from Data Registration State Response.
3519 * This fucntion is applicable only for RIL Version < 15.
3520 * Response is a "char **".
3521 * First and Second entries are in hex string format
3522 * and rest are integers represented in ascii format. */
3523void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3524 int numStrings, char** response) {
3525
3526 RIL_CellIdentity_v16 rilCellIdentity;
3527 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3528
3529 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3530 switch(rilCellIdentity.cellInfoType) {
3531 case RIL_CELL_INFO_TYPE_GSM: {
3532 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3533 rilCellIdentity.cellIdentityGsm.lac =
3534 convertResponseHexStringEntryToInt(response, 1, numStrings);
3535
3536 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3537 rilCellIdentity.cellIdentityGsm.cid =
3538 convertResponseHexStringEntryToInt(response, 2, numStrings);
3539 break;
3540 }
3541 case RIL_CELL_INFO_TYPE_WCDMA: {
3542 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3543 rilCellIdentity.cellIdentityWcdma.lac =
3544 convertResponseHexStringEntryToInt(response, 1, numStrings);
3545
3546 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3547 rilCellIdentity.cellIdentityWcdma.cid =
3548 convertResponseHexStringEntryToInt(response, 2, numStrings);
3549 break;
3550 }
3551 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3552 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3553 rilCellIdentity.cellIdentityTdscdma.lac =
3554 convertResponseHexStringEntryToInt(response, 1, numStrings);
3555
3556 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3557 rilCellIdentity.cellIdentityTdscdma.cid =
3558 convertResponseHexStringEntryToInt(response, 2, numStrings);
3559 break;
3560 }
3561 case RIL_CELL_INFO_TYPE_LTE: {
3562 rilCellIdentity.cellIdentityLte.tac =
3563 convertResponseStringEntryToInt(response, 6, numStrings);
3564 rilCellIdentity.cellIdentityLte.pci =
3565 convertResponseStringEntryToInt(response, 7, numStrings);
3566 rilCellIdentity.cellIdentityLte.ci =
3567 convertResponseStringEntryToInt(response, 8, numStrings);
3568 break;
3569 }
3570 default: {
3571 break;
3572 }
3573 }
3574
3575 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3576}
3577
3578int radio::getVoiceRegistrationStateResponse(int slotId,
3579 int responseType, int serial, RIL_Errno e,
3580 void *response, size_t responseLen) {
3581#if VDBG
3582 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3583#endif
3584
3585 if (radioService[slotId]->mRadioResponse != NULL) {
3586 RadioResponseInfo responseInfo = {};
3587 populateResponseInfo(responseInfo, serial, responseType, e);
3588
3589 VoiceRegStateResult voiceRegResponse = {};
3590 int numStrings = responseLen / sizeof(char *);
3591 if (response == NULL) {
3592 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3593 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3594 } else if (s_vendorFunctions->version <= 14) {
3595 if (numStrings != 15) {
3596 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3597 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3598 } else {
3599 char **resp = (char **) response;
3600 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3601 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3602 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3603 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3604 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3605 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3606 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3607 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3608 numStrings, resp);
3609 }
3610 } else {
3611 RIL_VoiceRegistrationStateResponse *voiceRegState =
3612 (RIL_VoiceRegistrationStateResponse *)response;
3613
3614 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3615 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3616 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3617 } else {
3618 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3619 voiceRegResponse.rat = voiceRegState->rat;;
3620 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3621 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3622 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3623 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3624 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3625 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3626 voiceRegState->cellIdentity);
3627 }
3628 }
3629
3630 Return<void> retStatus =
3631 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3632 responseInfo, voiceRegResponse);
3633 radioService[slotId]->checkReturnStatus(retStatus);
3634 } else {
3635 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3636 slotId);
3637 }
3638
3639 return 0;
3640}
3641
3642int radio::getDataRegistrationStateResponse(int slotId,
3643 int responseType, int serial, RIL_Errno e,
3644 void *response, size_t responseLen) {
3645#if VDBG
3646 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3647#endif
3648
3649 if (radioService[slotId]->mRadioResponse != NULL) {
3650 RadioResponseInfo responseInfo = {};
3651 populateResponseInfo(responseInfo, serial, responseType, e);
3652 DataRegStateResult dataRegResponse = {};
3653 if (response == NULL) {
3654 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3655 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3656 } else if (s_vendorFunctions->version <= 14) {
3657 int numStrings = responseLen / sizeof(char *);
3658 if ((numStrings != 6) && (numStrings != 11)) {
3659 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3660 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3661 } else {
3662 char **resp = (char **) response;
3663 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3664 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3665 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3666 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3667 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3668 numStrings, resp);
3669 }
3670 } else {
3671 RIL_DataRegistrationStateResponse *dataRegState =
3672 (RIL_DataRegistrationStateResponse *)response;
3673
3674 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3675 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3676 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3677 } else {
3678 dataRegResponse.regState = (RegState) dataRegState->regState;
3679 dataRegResponse.rat = dataRegState->rat;;
3680 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3681 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3682 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3683 }
3684 }
3685
3686 Return<void> retStatus =
3687 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3688 dataRegResponse);
3689 radioService[slotId]->checkReturnStatus(retStatus);
3690 } else {
3691 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3692 slotId);
3693 }
3694
3695 return 0;
3696}
3697
3698int radio::getOperatorResponse(int slotId,
3699 int responseType, int serial, RIL_Errno e, void *response,
3700 size_t responseLen) {
3701#if VDBG
3702 RLOGD("getOperatorResponse: serial %d", serial);
3703#endif
Martin Bouchetf7c75aa2017-09-24 04:51:55 -03003704 int mqanelements;
3705 char value[PROPERTY_VALUE_MAX];
3706 property_get("ro.ril.telephony.mqanelements", value, "4");
3707 mqanelements = atoi(value);
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03003708
3709 if (radioService[slotId]->mRadioResponse != NULL) {
3710 RadioResponseInfo responseInfo = {};
3711 populateResponseInfo(responseInfo, serial, responseType, e);
3712 hidl_string longName;
3713 hidl_string shortName;
3714 hidl_string numeric;
3715 int numStrings = responseLen / sizeof(char *);
Martin Bouchetf7c75aa2017-09-24 04:51:55 -03003716 if (response == NULL || numStrings != mqanelements - 2) {
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03003717 RLOGE("getOperatorResponse Invalid response: NULL");
3718 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3719
3720 } else {
3721 char **resp = (char **) response;
3722 longName = convertCharPtrToHidlString(resp[0]);
Martin Bouchetf7c75aa2017-09-24 04:51:55 -03003723 shortName = convertCharPtrToHidlString(resp[0]);
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03003724 numeric = convertCharPtrToHidlString(resp[2]);
3725 }
3726 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3727 responseInfo, longName, shortName, numeric);
3728 radioService[slotId]->checkReturnStatus(retStatus);
3729 } else {
3730 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3731 slotId);
3732 }
3733
3734 return 0;
3735}
3736
3737int radio::setRadioPowerResponse(int slotId,
3738 int responseType, int serial, RIL_Errno e, void *response,
3739 size_t responseLen) {
3740 RLOGD("setRadioPowerResponse: serial %d", serial);
3741
3742 if (radioService[slotId]->mRadioResponse != NULL) {
3743 RadioResponseInfo responseInfo = {};
3744 populateResponseInfo(responseInfo, serial, responseType, e);
3745 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3746 responseInfo);
3747 radioService[slotId]->checkReturnStatus(retStatus);
3748 } else {
3749 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3750 slotId);
3751 }
3752
3753 return 0;
3754}
3755
3756int radio::sendDtmfResponse(int slotId,
3757 int responseType, int serial, RIL_Errno e, void *response,
3758 size_t responseLen) {
3759#if VDBG
3760 RLOGD("sendDtmfResponse: serial %d", serial);
3761#endif
3762
3763 if (radioService[slotId]->mRadioResponse != NULL) {
3764 RadioResponseInfo responseInfo = {};
3765 populateResponseInfo(responseInfo, serial, responseType, e);
3766 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3767 responseInfo);
3768 radioService[slotId]->checkReturnStatus(retStatus);
3769 } else {
3770 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3771 slotId);
3772 }
3773
3774 return 0;
3775}
3776
3777SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3778 RIL_Errno e, void *response, size_t responseLen) {
3779 populateResponseInfo(responseInfo, serial, responseType, e);
3780 SendSmsResult result = {};
3781
3782 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3783 RLOGE("Invalid response: NULL");
3784 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3785 result.ackPDU = hidl_string();
3786 } else {
3787 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3788 result.messageRef = resp->messageRef;
3789 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3790 result.errorCode = resp->errorCode;
3791 }
3792 return result;
3793}
3794
3795int radio::sendSmsResponse(int slotId,
3796 int responseType, int serial, RIL_Errno e, void *response,
3797 size_t responseLen) {
3798#if VDBG
3799 RLOGD("sendSmsResponse: serial %d", serial);
3800#endif
3801
3802 if (radioService[slotId]->mRadioResponse != NULL) {
3803 RadioResponseInfo responseInfo = {};
3804 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3805 responseLen);
3806
3807 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3808 result);
3809 radioService[slotId]->checkReturnStatus(retStatus);
3810 } else {
3811 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3812 }
3813
3814 return 0;
3815}
3816
3817int radio::sendSMSExpectMoreResponse(int slotId,
3818 int responseType, int serial, RIL_Errno e, void *response,
3819 size_t responseLen) {
3820#if VDBG
3821 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3822#endif
3823
3824 if (radioService[slotId]->mRadioResponse != NULL) {
3825 RadioResponseInfo responseInfo = {};
3826 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3827 responseLen);
3828
3829 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3830 responseInfo, result);
3831 radioService[slotId]->checkReturnStatus(retStatus);
3832 } else {
3833 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3834 }
3835
3836 return 0;
3837}
3838
3839int radio::setupDataCallResponse(int slotId,
3840 int responseType, int serial, RIL_Errno e, void *response,
3841 size_t responseLen) {
3842#if VDBG
3843 RLOGD("setupDataCallResponse: serial %d", serial);
3844#endif
3845
3846 if (radioService[slotId]->mRadioResponse != NULL) {
3847 RadioResponseInfo responseInfo = {};
3848 populateResponseInfo(responseInfo, serial, responseType, e);
3849
3850 SetupDataCallResult result = {};
3851
3852 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11) != 0
3853 && responseLen % sizeof(RIL_Data_Call_Response_v9) != 0
3854 && responseLen % sizeof(RIL_Data_Call_Response_v6) != 0)) {
3855 if (response != NULL) {
3856 RLOGE("setupDataCallResponse: Invalid response");
3857 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3858 }
3859 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3860 result.type = hidl_string();
3861 result.ifname = hidl_string();
3862 result.addresses = hidl_string();
3863 result.dnses = hidl_string();
3864 result.gateways = hidl_string();
3865 result.pcscf = hidl_string();
3866 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v11)) == 0) {
3867 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3868 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v9)) == 0) {
3869 convertRilDataCallToHal((RIL_Data_Call_Response_v9 *) response, result);
3870 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v6)) == 0) {
3871 convertRilDataCallToHal((RIL_Data_Call_Response_v6 *) response, result);
3872 }
3873
3874 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3875 responseInfo, result);
3876 radioService[slotId]->checkReturnStatus(retStatus);
3877 } else {
3878 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3879 }
3880
3881 return 0;
3882}
3883
3884IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3885 RIL_Errno e, void *response, size_t responseLen) {
3886 populateResponseInfo(responseInfo, serial, responseType, e);
3887 IccIoResult result = {};
3888
3889 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3890 RLOGE("Invalid response: NULL");
3891 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3892 result.simResponse = hidl_string();
3893 } else {
3894 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3895 result.sw1 = resp->sw1;
3896 result.sw2 = resp->sw2;
3897 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3898 }
3899 return result;
3900}
3901
3902int radio::iccIOForAppResponse(int slotId,
3903 int responseType, int serial, RIL_Errno e, void *response,
3904 size_t responseLen) {
3905#if VDBG
3906 RLOGD("iccIOForAppResponse: serial %d", serial);
3907#endif
3908
3909 if (radioService[slotId]->mRadioResponse != NULL) {
3910 RadioResponseInfo responseInfo = {};
3911 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3912 responseLen);
3913
3914 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3915 responseInfo, result);
3916 radioService[slotId]->checkReturnStatus(retStatus);
3917 } else {
3918 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3919 }
3920
3921 return 0;
3922}
3923
3924int radio::sendUssdResponse(int slotId,
3925 int responseType, int serial, RIL_Errno e, void *response,
3926 size_t responseLen) {
3927#if VDBG
3928 RLOGD("sendUssdResponse: serial %d", serial);
3929#endif
3930
3931 if (radioService[slotId]->mRadioResponse != NULL) {
3932 RadioResponseInfo responseInfo = {};
3933 populateResponseInfo(responseInfo, serial, responseType, e);
3934 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3935 responseInfo);
3936 radioService[slotId]->checkReturnStatus(retStatus);
3937 } else {
3938 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3939 slotId);
3940 }
3941
3942 return 0;
3943}
3944
3945int radio::cancelPendingUssdResponse(int slotId,
3946 int responseType, int serial, RIL_Errno e, void *response,
3947 size_t responseLen) {
3948#if VDBG
3949 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3950#endif
3951
3952 if (radioService[slotId]->mRadioResponse != NULL) {
3953 RadioResponseInfo responseInfo = {};
3954 populateResponseInfo(responseInfo, serial, responseType, e);
3955 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3956 responseInfo);
3957 radioService[slotId]->checkReturnStatus(retStatus);
3958 } else {
3959 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3960 slotId);
3961 }
3962
3963 return 0;
3964}
3965
3966int radio::getClirResponse(int slotId,
3967 int responseType, int serial, RIL_Errno e, void *response,
3968 size_t responseLen) {
3969#if VDBG
3970 RLOGD("getClirResponse: serial %d", serial);
3971#endif
3972
3973 if (radioService[slotId]->mRadioResponse != NULL) {
3974 RadioResponseInfo responseInfo = {};
3975 populateResponseInfo(responseInfo, serial, responseType, e);
3976 int n = -1, m = -1;
3977 int numInts = responseLen / sizeof(int);
3978 if (response == NULL || numInts != 2) {
3979 RLOGE("getClirResponse Invalid response: NULL");
3980 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3981 } else {
3982 int *pInt = (int *) response;
3983 n = pInt[0];
3984 m = pInt[1];
3985 }
3986 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3987 n, m);
3988 radioService[slotId]->checkReturnStatus(retStatus);
3989 } else {
3990 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3991 }
3992
3993 return 0;
3994}
3995
3996int radio::setClirResponse(int slotId,
3997 int responseType, int serial, RIL_Errno e, void *response,
3998 size_t responseLen) {
3999#if VDBG
4000 RLOGD("setClirResponse: serial %d", serial);
4001#endif
4002
4003 if (radioService[slotId]->mRadioResponse != NULL) {
4004 RadioResponseInfo responseInfo = {};
4005 populateResponseInfo(responseInfo, serial, responseType, e);
4006 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
4007 responseInfo);
4008 radioService[slotId]->checkReturnStatus(retStatus);
4009 } else {
4010 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4011 }
4012
4013 return 0;
4014}
4015
4016int radio::getCallForwardStatusResponse(int slotId,
4017 int responseType, int serial, RIL_Errno e,
4018 void *response, size_t responseLen) {
4019#if VDBG
4020 RLOGD("getCallForwardStatusResponse: serial %d", serial);
4021#endif
4022
4023 if (radioService[slotId]->mRadioResponse != NULL) {
4024 RadioResponseInfo responseInfo = {};
4025 populateResponseInfo(responseInfo, serial, responseType, e);
4026 hidl_vec<CallForwardInfo> callForwardInfos;
4027
4028 if ((response == NULL && responseLen != 0)
4029 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4030 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4031 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4032 } else {
4033 int num = responseLen / sizeof(RIL_CallForwardInfo *);
4034 callForwardInfos.resize(num);
4035 for (int i = 0 ; i < num; i++) {
4036 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4037 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4038 callForwardInfos[i].reason = resp->reason;
4039 callForwardInfos[i].serviceClass = resp->serviceClass;
4040 callForwardInfos[i].toa = resp->toa;
4041 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4042 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4043 }
4044 }
4045
4046 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4047 responseInfo, callForwardInfos);
4048 radioService[slotId]->checkReturnStatus(retStatus);
4049 } else {
4050 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4051 slotId);
4052 }
4053
4054 return 0;
4055}
4056
4057int radio::setCallForwardResponse(int slotId,
4058 int responseType, int serial, RIL_Errno e, void *response,
4059 size_t responseLen) {
4060#if VDBG
4061 RLOGD("setCallForwardResponse: serial %d", serial);
4062#endif
4063
4064 if (radioService[slotId]->mRadioResponse != NULL) {
4065 RadioResponseInfo responseInfo = {};
4066 populateResponseInfo(responseInfo, serial, responseType, e);
4067 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4068 responseInfo);
4069 radioService[slotId]->checkReturnStatus(retStatus);
4070 } else {
4071 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4072 }
4073
4074 return 0;
4075}
4076
4077int radio::getCallWaitingResponse(int slotId,
4078 int responseType, int serial, RIL_Errno e, void *response,
4079 size_t responseLen) {
4080#if VDBG
4081 RLOGD("getCallWaitingResponse: serial %d", serial);
4082#endif
4083
4084 if (radioService[slotId]->mRadioResponse != NULL) {
4085 RadioResponseInfo responseInfo = {};
4086 populateResponseInfo(responseInfo, serial, responseType, e);
4087 bool enable = false;
4088 int serviceClass = -1;
4089 int numInts = responseLen / sizeof(int);
4090 if (response == NULL || numInts != 2) {
4091 RLOGE("getCallWaitingResponse Invalid response: NULL");
4092 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4093 } else {
4094 int *pInt = (int *) response;
4095 enable = pInt[0] == 1 ? true : false;
4096 serviceClass = pInt[1];
4097 }
4098 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4099 responseInfo, enable, serviceClass);
4100 radioService[slotId]->checkReturnStatus(retStatus);
4101 } else {
4102 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4103 }
4104
4105 return 0;
4106}
4107
4108int radio::setCallWaitingResponse(int slotId,
4109 int responseType, int serial, RIL_Errno e, void *response,
4110 size_t responseLen) {
4111#if VDBG
4112 RLOGD("setCallWaitingResponse: serial %d", serial);
4113#endif
4114
4115 if (radioService[slotId]->mRadioResponse != NULL) {
4116 RadioResponseInfo responseInfo = {};
4117 populateResponseInfo(responseInfo, serial, responseType, e);
4118 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4119 responseInfo);
4120 radioService[slotId]->checkReturnStatus(retStatus);
4121 } else {
4122 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4123 }
4124
4125 return 0;
4126}
4127
4128int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4129 int responseType, int serial, RIL_Errno e,
4130 void *response, size_t responseLen) {
4131#if VDBG
4132 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4133#endif
4134
4135 if (radioService[slotId]->mRadioResponse != NULL) {
4136 RadioResponseInfo responseInfo = {};
4137 populateResponseInfo(responseInfo, serial, responseType, e);
4138 Return<void> retStatus =
4139 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4140 responseInfo);
4141 radioService[slotId]->checkReturnStatus(retStatus);
4142 } else {
4143 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4144 "== NULL", slotId);
4145 }
4146
4147 return 0;
4148}
4149
4150int radio::acceptCallResponse(int slotId,
4151 int responseType, int serial, RIL_Errno e,
4152 void *response, size_t responseLen) {
4153#if VDBG
4154 RLOGD("acceptCallResponse: serial %d", serial);
4155#endif
4156
4157 if (radioService[slotId]->mRadioResponse != NULL) {
4158 RadioResponseInfo responseInfo = {};
4159 populateResponseInfo(responseInfo, serial, responseType, e);
4160 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4161 responseInfo);
4162 radioService[slotId]->checkReturnStatus(retStatus);
4163 } else {
4164 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4165 slotId);
4166 }
4167
4168 return 0;
4169}
4170
4171int radio::deactivateDataCallResponse(int slotId,
4172 int responseType, int serial, RIL_Errno e,
4173 void *response, size_t responseLen) {
4174#if VDBG
4175 RLOGD("deactivateDataCallResponse: serial %d", serial);
4176#endif
4177
4178 if (radioService[slotId]->mRadioResponse != NULL) {
4179 RadioResponseInfo responseInfo = {};
4180 populateResponseInfo(responseInfo, serial, responseType, e);
4181 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4182 responseInfo);
4183 radioService[slotId]->checkReturnStatus(retStatus);
4184 } else {
4185 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4186 slotId);
4187 }
4188
4189 return 0;
4190}
4191
4192int radio::getFacilityLockForAppResponse(int slotId,
4193 int responseType, int serial, RIL_Errno e,
4194 void *response, size_t responseLen) {
4195#if VDBG
4196 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4197#endif
4198
4199 if (radioService[slotId]->mRadioResponse != NULL) {
4200 RadioResponseInfo responseInfo = {};
4201 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4202 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4203 getFacilityLockForAppResponse(responseInfo, ret);
4204 radioService[slotId]->checkReturnStatus(retStatus);
4205 } else {
4206 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4207 slotId);
4208 }
4209
4210 return 0;
4211}
4212
4213int radio::setFacilityLockForAppResponse(int slotId,
4214 int responseType, int serial, RIL_Errno e,
4215 void *response, size_t responseLen) {
4216#if VDBG
4217 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4218#endif
4219
4220 if (radioService[slotId]->mRadioResponse != NULL) {
4221 RadioResponseInfo responseInfo = {};
4222 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4223 Return<void> retStatus
4224 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4225 ret);
4226 radioService[slotId]->checkReturnStatus(retStatus);
4227 } else {
4228 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4229 slotId);
4230 }
4231
4232 return 0;
4233}
4234
4235int radio::setBarringPasswordResponse(int slotId,
4236 int responseType, int serial, RIL_Errno e,
4237 void *response, size_t responseLen) {
4238#if VDBG
4239 RLOGD("acceptCallResponse: serial %d", serial);
4240#endif
4241
4242 if (radioService[slotId]->mRadioResponse != NULL) {
4243 RadioResponseInfo responseInfo = {};
4244 populateResponseInfo(responseInfo, serial, responseType, e);
4245 Return<void> retStatus
4246 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4247 radioService[slotId]->checkReturnStatus(retStatus);
4248 } else {
4249 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4250 slotId);
4251 }
4252
4253 return 0;
4254}
4255
4256int radio::getNetworkSelectionModeResponse(int slotId,
4257 int responseType, int serial, RIL_Errno e, void *response,
4258 size_t responseLen) {
4259#if VDBG
4260 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4261#endif
4262
4263 if (radioService[slotId]->mRadioResponse != NULL) {
4264 RadioResponseInfo responseInfo = {};
4265 populateResponseInfo(responseInfo, serial, responseType, e);
4266 bool manual = false;
4267 int serviceClass;
4268 if (response == NULL || responseLen != sizeof(int)) {
4269 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4270 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4271 } else {
4272 int *pInt = (int *) response;
4273 manual = pInt[0] == 1 ? true : false;
4274 }
4275 Return<void> retStatus
4276 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4277 responseInfo,
4278 manual);
4279 radioService[slotId]->checkReturnStatus(retStatus);
4280 } else {
4281 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4282 slotId);
4283 }
4284
4285 return 0;
4286}
4287
4288int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4289 RIL_Errno e, void *response,
4290 size_t responseLen) {
4291#if VDBG
4292 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4293#endif
4294
4295 if (radioService[slotId]->mRadioResponse != NULL) {
4296 RadioResponseInfo responseInfo = {};
4297 populateResponseInfo(responseInfo, serial, responseType, e);
4298 Return<void> retStatus
4299 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4300 responseInfo);
4301 radioService[slotId]->checkReturnStatus(retStatus);
4302 } else {
4303 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4304 "== NULL", slotId);
4305 }
4306
4307 return 0;
4308}
4309
4310int radio::setNetworkSelectionModeManualResponse(int slotId,
4311 int responseType, int serial, RIL_Errno e,
4312 void *response, size_t responseLen) {
4313#if VDBG
4314 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4315#endif
4316
4317 if (radioService[slotId]->mRadioResponse != NULL) {
4318 RadioResponseInfo responseInfo = {};
4319 populateResponseInfo(responseInfo, serial, responseType, e);
4320 Return<void> retStatus
4321 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4322 responseInfo);
4323 radioService[slotId]->checkReturnStatus(retStatus);
4324 } else {
4325 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4326 "== NULL", slotId);
4327 }
4328
4329 return 0;
4330}
4331
4332int convertOperatorStatusToInt(const char *str) {
4333 if (strncmp("unknown", str, 9) == 0) {
4334 return (int) OperatorStatus::UNKNOWN;
4335 } else if (strncmp("available", str, 9) == 0) {
4336 return (int) OperatorStatus::AVAILABLE;
4337 } else if (strncmp("current", str, 9) == 0) {
4338 return (int) OperatorStatus::CURRENT;
4339 } else if (strncmp("forbidden", str, 9) == 0) {
4340 return (int) OperatorStatus::FORBIDDEN;
4341 } else {
4342 return -1;
4343 }
4344}
4345
4346int radio::getAvailableNetworksResponse(int slotId,
4347 int responseType, int serial, RIL_Errno e, void *response,
4348 size_t responseLen) {
4349#if VDBG
4350 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4351#endif
Martin Bouchetf7c75aa2017-09-24 04:51:55 -03004352 int mqanelements;
4353 char value[PROPERTY_VALUE_MAX];
4354 property_get("ro.ril.telephony.mqanelements", value, "4");
4355 mqanelements = atoi(value);
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03004356
4357 if (radioService[slotId]->mRadioResponse != NULL) {
4358 RadioResponseInfo responseInfo = {};
4359 populateResponseInfo(responseInfo, serial, responseType, e);
4360 hidl_vec<OperatorInfo> networks;
4361 if ((response == NULL && responseLen != 0)
Martin Bouchetf7c75aa2017-09-24 04:51:55 -03004362 || responseLen % (mqanelements * sizeof(char *))!= 0) {
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03004363 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4364 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4365 } else {
4366 char **resp = (char **) response;
4367 int numStrings = responseLen / sizeof(char *);
Martin Bouchetf7c75aa2017-09-24 04:51:55 -03004368 networks.resize(numStrings/mqanelements);
4369 for (int i = 0, j = 0; i < numStrings; i = i + mqanelements, j++) {
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03004370 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
Martin Bouchetf7c75aa2017-09-24 04:51:55 -03004371 networks[j].alphaShort = convertCharPtrToHidlString(resp[i]);
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03004372 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4373 int status = convertOperatorStatusToInt(resp[i + 3]);
4374 if (status == -1) {
4375 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4376 } else {
4377 networks[j].status = (OperatorStatus) status;
4378 }
4379 }
4380 }
4381 Return<void> retStatus
4382 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4383 networks);
4384 radioService[slotId]->checkReturnStatus(retStatus);
4385 } else {
4386 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4387 slotId);
4388 }
4389
4390 return 0;
4391}
4392
4393int radio::startDtmfResponse(int slotId,
4394 int responseType, int serial, RIL_Errno e,
4395 void *response, size_t responseLen) {
4396#if VDBG
4397 RLOGD("startDtmfResponse: serial %d", serial);
4398#endif
4399
4400 if (radioService[slotId]->mRadioResponse != NULL) {
4401 RadioResponseInfo responseInfo = {};
4402 populateResponseInfo(responseInfo, serial, responseType, e);
4403 Return<void> retStatus
4404 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4405 radioService[slotId]->checkReturnStatus(retStatus);
4406 } else {
4407 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4408 }
4409
4410 return 0;
4411}
4412
4413int radio::stopDtmfResponse(int slotId,
4414 int responseType, int serial, RIL_Errno e,
4415 void *response, size_t responseLen) {
4416#if VDBG
4417 RLOGD("stopDtmfResponse: serial %d", serial);
4418#endif
4419
4420 if (radioService[slotId]->mRadioResponse != NULL) {
4421 RadioResponseInfo responseInfo = {};
4422 populateResponseInfo(responseInfo, serial, responseType, e);
4423 Return<void> retStatus
4424 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4425 radioService[slotId]->checkReturnStatus(retStatus);
4426 } else {
4427 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4428 }
4429
4430 return 0;
4431}
4432
4433int radio::getBasebandVersionResponse(int slotId,
4434 int responseType, int serial, RIL_Errno e,
4435 void *response, size_t responseLen) {
4436#if VDBG
4437 RLOGD("getBasebandVersionResponse: serial %d", serial);
4438#endif
4439
4440 if (radioService[slotId]->mRadioResponse != NULL) {
4441 RadioResponseInfo responseInfo = {};
4442 populateResponseInfo(responseInfo, serial, responseType, e);
4443 Return<void> retStatus
4444 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4445 convertCharPtrToHidlString((char *) response));
4446 radioService[slotId]->checkReturnStatus(retStatus);
4447 } else {
4448 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4449 }
4450
4451 return 0;
4452}
4453
4454int radio::separateConnectionResponse(int slotId,
4455 int responseType, int serial, RIL_Errno e,
4456 void *response, size_t responseLen) {
4457#if VDBG
4458 RLOGD("separateConnectionResponse: serial %d", serial);
4459#endif
4460
4461 if (radioService[slotId]->mRadioResponse != NULL) {
4462 RadioResponseInfo responseInfo = {};
4463 populateResponseInfo(responseInfo, serial, responseType, e);
4464 Return<void> retStatus
4465 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4466 radioService[slotId]->checkReturnStatus(retStatus);
4467 } else {
4468 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4469 slotId);
4470 }
4471
4472 return 0;
4473}
4474
4475int radio::setMuteResponse(int slotId,
4476 int responseType, int serial, RIL_Errno e,
4477 void *response, size_t responseLen) {
4478#if VDBG
4479 RLOGD("setMuteResponse: serial %d", serial);
4480#endif
4481
4482 if (radioService[slotId]->mRadioResponse != NULL) {
4483 RadioResponseInfo responseInfo = {};
4484 populateResponseInfo(responseInfo, serial, responseType, e);
4485 Return<void> retStatus
4486 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4487 radioService[slotId]->checkReturnStatus(retStatus);
4488 } else {
4489 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4490 }
4491
4492 return 0;
4493}
4494
4495int radio::getMuteResponse(int slotId,
4496 int responseType, int serial, RIL_Errno e, void *response,
4497 size_t responseLen) {
4498#if VDBG
4499 RLOGD("getMuteResponse: serial %d", serial);
4500#endif
4501
4502 if (radioService[slotId]->mRadioResponse != NULL) {
4503 RadioResponseInfo responseInfo = {};
4504 populateResponseInfo(responseInfo, serial, responseType, e);
4505 bool enable = false;
4506 int serviceClass;
4507 if (response == NULL || responseLen != sizeof(int)) {
4508 RLOGE("getMuteResponse Invalid response: NULL");
4509 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4510 } else {
4511 int *pInt = (int *) response;
4512 enable = pInt[0] == 1 ? true : false;
4513 }
4514 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4515 enable);
4516 radioService[slotId]->checkReturnStatus(retStatus);
4517 } else {
4518 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4519 }
4520
4521 return 0;
4522}
4523
4524int radio::getClipResponse(int slotId,
4525 int responseType, int serial, RIL_Errno e,
4526 void *response, size_t responseLen) {
4527#if VDBG
4528 RLOGD("getClipResponse: serial %d", serial);
4529#endif
4530
4531 if (radioService[slotId]->mRadioResponse != NULL) {
4532 RadioResponseInfo responseInfo = {};
4533 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4534 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4535 (ClipStatus) ret);
4536 radioService[slotId]->checkReturnStatus(retStatus);
4537 } else {
4538 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4539 }
4540
4541 return 0;
4542}
4543
4544int radio::getDataCallListResponse(int slotId,
4545 int responseType, int serial, RIL_Errno e,
4546 void *response, size_t responseLen) {
4547#if VDBG
4548 RLOGD("getDataCallListResponse: serial %d", serial);
4549#endif
4550
4551 if (radioService[slotId]->mRadioResponse != NULL) {
4552 RadioResponseInfo responseInfo = {};
4553 populateResponseInfo(responseInfo, serial, responseType, e);
4554
4555 hidl_vec<SetupDataCallResult> ret;
4556 if ((response == NULL && responseLen != 0)
4557 || (responseLen % sizeof(RIL_Data_Call_Response_v11) != 0
4558 && responseLen % sizeof(RIL_Data_Call_Response_v9) != 0
4559 && responseLen % sizeof(RIL_Data_Call_Response_v6) != 0)) {
4560 RLOGE("getDataCallListResponse: invalid response");
4561 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4562 } else {
4563 convertRilDataCallListToHal(response, responseLen, ret);
4564 }
4565
4566 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4567 responseInfo, ret);
4568 radioService[slotId]->checkReturnStatus(retStatus);
4569 } else {
4570 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4571 }
4572
4573 return 0;
4574}
4575
4576int radio::setSuppServiceNotificationsResponse(int slotId,
4577 int responseType, int serial, RIL_Errno e,
4578 void *response, size_t responseLen) {
4579#if VDBG
4580 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4581#endif
4582
4583 if (radioService[slotId]->mRadioResponse != NULL) {
4584 RadioResponseInfo responseInfo = {};
4585 populateResponseInfo(responseInfo, serial, responseType, e);
4586 Return<void> retStatus
4587 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4588 responseInfo);
4589 radioService[slotId]->checkReturnStatus(retStatus);
4590 } else {
4591 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4592 "== NULL", slotId);
4593 }
4594
4595 return 0;
4596}
4597
4598int radio::deleteSmsOnSimResponse(int slotId,
4599 int responseType, int serial, RIL_Errno e,
4600 void *response, size_t responseLen) {
4601#if VDBG
4602 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4603#endif
4604
4605 if (radioService[slotId]->mRadioResponse != NULL) {
4606 RadioResponseInfo responseInfo = {};
4607 populateResponseInfo(responseInfo, serial, responseType, e);
4608 Return<void> retStatus
4609 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4610 radioService[slotId]->checkReturnStatus(retStatus);
4611 } else {
4612 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4613 }
4614
4615 return 0;
4616}
4617
4618int radio::setBandModeResponse(int slotId,
4619 int responseType, int serial, RIL_Errno e,
4620 void *response, size_t responseLen) {
4621#if VDBG
4622 RLOGD("setBandModeResponse: serial %d", serial);
4623#endif
4624
4625 if (radioService[slotId]->mRadioResponse != NULL) {
4626 RadioResponseInfo responseInfo = {};
4627 populateResponseInfo(responseInfo, serial, responseType, e);
4628 Return<void> retStatus
4629 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4630 radioService[slotId]->checkReturnStatus(retStatus);
4631 } else {
4632 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4633 }
4634
4635 return 0;
4636}
4637
4638int radio::writeSmsToSimResponse(int slotId,
4639 int responseType, int serial, RIL_Errno e,
4640 void *response, size_t responseLen) {
4641#if VDBG
4642 RLOGD("writeSmsToSimResponse: serial %d", serial);
4643#endif
4644
4645 if (radioService[slotId]->mRadioResponse != NULL) {
4646 RadioResponseInfo responseInfo = {};
4647 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4648 Return<void> retStatus
4649 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4650 radioService[slotId]->checkReturnStatus(retStatus);
4651 } else {
4652 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4653 }
4654
4655 return 0;
4656}
4657
4658int radio::getAvailableBandModesResponse(int slotId,
4659 int responseType, int serial, RIL_Errno e, void *response,
4660 size_t responseLen) {
4661#if VDBG
4662 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4663#endif
4664
4665 if (radioService[slotId]->mRadioResponse != NULL) {
4666 RadioResponseInfo responseInfo = {};
4667 populateResponseInfo(responseInfo, serial, responseType, e);
4668 hidl_vec<RadioBandMode> modes;
4669 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
4670 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4671 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4672 } else {
4673 int *pInt = (int *) response;
4674 int numInts = responseLen / sizeof(int);
4675 modes.resize(numInts);
4676 for (int i = 0; i < numInts; i++) {
4677 modes[i] = (RadioBandMode) pInt[i];
4678 }
4679 }
4680 Return<void> retStatus
4681 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4682 modes);
4683 radioService[slotId]->checkReturnStatus(retStatus);
4684 } else {
4685 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4686 slotId);
4687 }
4688
4689 return 0;
4690}
4691
4692int radio::sendEnvelopeResponse(int slotId,
4693 int responseType, int serial, RIL_Errno e,
4694 void *response, size_t responseLen) {
4695#if VDBG
4696 RLOGD("sendEnvelopeResponse: serial %d", serial);
4697#endif
4698
4699 if (radioService[slotId]->mRadioResponse != NULL) {
4700 RadioResponseInfo responseInfo = {};
4701 populateResponseInfo(responseInfo, serial, responseType, e);
4702 Return<void> retStatus
4703 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4704 convertCharPtrToHidlString((char *) response));
4705 radioService[slotId]->checkReturnStatus(retStatus);
4706 } else {
4707 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4708 }
4709
4710 return 0;
4711}
4712
4713int radio::sendTerminalResponseToSimResponse(int slotId,
4714 int responseType, int serial, RIL_Errno e,
4715 void *response, size_t responseLen) {
4716#if VDBG
4717 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4718#endif
4719
4720 if (radioService[slotId]->mRadioResponse != NULL) {
4721 RadioResponseInfo responseInfo = {};
4722 populateResponseInfo(responseInfo, serial, responseType, e);
4723 Return<void> retStatus
4724 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4725 responseInfo);
4726 radioService[slotId]->checkReturnStatus(retStatus);
4727 } else {
4728 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4729 slotId);
4730 }
4731
4732 return 0;
4733}
4734
4735int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4736 int responseType, int serial,
4737 RIL_Errno e, void *response,
4738 size_t responseLen) {
4739#if VDBG
4740 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4741#endif
4742
4743 if (radioService[slotId]->mRadioResponse != NULL) {
4744 RadioResponseInfo responseInfo = {};
4745 populateResponseInfo(responseInfo, serial, responseType, e);
4746 Return<void> retStatus
4747 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4748 responseInfo);
4749 radioService[slotId]->checkReturnStatus(retStatus);
4750 } else {
4751 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4752 "== NULL", slotId);
4753 }
4754
4755 return 0;
4756}
4757
4758int radio::explicitCallTransferResponse(int slotId,
4759 int responseType, int serial, RIL_Errno e,
4760 void *response, size_t responseLen) {
4761#if VDBG
4762 RLOGD("explicitCallTransferResponse: serial %d", serial);
4763#endif
4764
4765 if (radioService[slotId]->mRadioResponse != NULL) {
4766 RadioResponseInfo responseInfo = {};
4767 populateResponseInfo(responseInfo, serial, responseType, e);
4768 Return<void> retStatus
4769 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4770 radioService[slotId]->checkReturnStatus(retStatus);
4771 } else {
4772 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4773 slotId);
4774 }
4775
4776 return 0;
4777}
4778
4779int radio::setPreferredNetworkTypeResponse(int slotId,
4780 int responseType, int serial, RIL_Errno e,
4781 void *response, size_t responseLen) {
4782#if VDBG
4783 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4784#endif
4785
4786 if (radioService[slotId]->mRadioResponse != NULL) {
4787 RadioResponseInfo responseInfo = {};
4788 populateResponseInfo(responseInfo, serial, responseType, e);
4789 Return<void> retStatus
4790 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4791 responseInfo);
4792 radioService[slotId]->checkReturnStatus(retStatus);
4793 } else {
4794 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4795 slotId);
4796 }
4797
4798 return 0;
4799}
4800
4801
4802int radio::getPreferredNetworkTypeResponse(int slotId,
4803 int responseType, int serial, RIL_Errno e,
4804 void *response, size_t responseLen) {
4805#if VDBG
4806 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4807#endif
4808
4809 if (radioService[slotId]->mRadioResponse != NULL) {
4810 RadioResponseInfo responseInfo = {};
4811 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4812 Return<void> retStatus
4813 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4814 responseInfo, (PreferredNetworkType) ret);
4815 radioService[slotId]->checkReturnStatus(retStatus);
4816 } else {
4817 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4818 slotId);
4819 }
4820
4821 return 0;
4822}
4823
4824int radio::getNeighboringCidsResponse(int slotId,
4825 int responseType, int serial, RIL_Errno e,
4826 void *response, size_t responseLen) {
4827#if VDBG
4828 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4829#endif
4830
4831 if (radioService[slotId]->mRadioResponse != NULL) {
4832 RadioResponseInfo responseInfo = {};
4833 populateResponseInfo(responseInfo, serial, responseType, e);
4834 hidl_vec<NeighboringCell> cells;
4835
4836 if ((response == NULL && responseLen != 0)
4837 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4838 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4839 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4840 } else {
4841 int num = responseLen / sizeof(RIL_NeighboringCell *);
4842 cells.resize(num);
4843 for (int i = 0 ; i < num; i++) {
4844 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4845 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4846 cells[i].rssi = resp->rssi;
4847 }
4848 }
4849
4850 Return<void> retStatus
4851 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4852 cells);
4853 radioService[slotId]->checkReturnStatus(retStatus);
4854 } else {
4855 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4856 slotId);
4857 }
4858
4859 return 0;
4860}
4861
4862int radio::setLocationUpdatesResponse(int slotId,
4863 int responseType, int serial, RIL_Errno e,
4864 void *response, size_t responseLen) {
4865#if VDBG
4866 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4867#endif
4868
4869 if (radioService[slotId]->mRadioResponse != NULL) {
4870 RadioResponseInfo responseInfo = {};
4871 populateResponseInfo(responseInfo, serial, responseType, e);
4872 Return<void> retStatus
4873 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4874 radioService[slotId]->checkReturnStatus(retStatus);
4875 } else {
4876 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4877 slotId);
4878 }
4879
4880 return 0;
4881}
4882
4883int radio::setCdmaSubscriptionSourceResponse(int slotId,
4884 int responseType, int serial, RIL_Errno e,
4885 void *response, size_t responseLen) {
4886#if VDBG
4887 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4888#endif
4889
4890 if (radioService[slotId]->mRadioResponse != NULL) {
4891 RadioResponseInfo responseInfo = {};
4892 populateResponseInfo(responseInfo, serial, responseType, e);
4893 Return<void> retStatus
4894 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4895 responseInfo);
4896 radioService[slotId]->checkReturnStatus(retStatus);
4897 } else {
4898 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4899 slotId);
4900 }
4901
4902 return 0;
4903}
4904
4905int radio::setCdmaRoamingPreferenceResponse(int slotId,
4906 int responseType, int serial, RIL_Errno e,
4907 void *response, size_t responseLen) {
4908#if VDBG
4909 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4910#endif
4911
4912 if (radioService[slotId]->mRadioResponse != NULL) {
4913 RadioResponseInfo responseInfo = {};
4914 populateResponseInfo(responseInfo, serial, responseType, e);
4915 Return<void> retStatus
4916 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4917 responseInfo);
4918 radioService[slotId]->checkReturnStatus(retStatus);
4919 } else {
4920 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4921 slotId);
4922 }
4923
4924 return 0;
4925}
4926
4927int radio::getCdmaRoamingPreferenceResponse(int slotId,
4928 int responseType, int serial, RIL_Errno e,
4929 void *response, size_t responseLen) {
4930#if VDBG
4931 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4932#endif
4933
4934 if (radioService[slotId]->mRadioResponse != NULL) {
4935 RadioResponseInfo responseInfo = {};
4936 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4937 Return<void> retStatus
4938 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4939 responseInfo, (CdmaRoamingType) ret);
4940 radioService[slotId]->checkReturnStatus(retStatus);
4941 } else {
4942 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4943 slotId);
4944 }
4945
4946 return 0;
4947}
4948
4949int radio::setTTYModeResponse(int slotId,
4950 int responseType, int serial, RIL_Errno e,
4951 void *response, size_t responseLen) {
4952#if VDBG
4953 RLOGD("setTTYModeResponse: serial %d", serial);
4954#endif
4955
4956 if (radioService[slotId]->mRadioResponse != NULL) {
4957 RadioResponseInfo responseInfo = {};
4958 populateResponseInfo(responseInfo, serial, responseType, e);
4959 Return<void> retStatus
4960 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4961 radioService[slotId]->checkReturnStatus(retStatus);
4962 } else {
4963 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4964 }
4965
4966 return 0;
4967}
4968
4969int radio::getTTYModeResponse(int slotId,
4970 int responseType, int serial, RIL_Errno e,
4971 void *response, size_t responseLen) {
4972#if VDBG
4973 RLOGD("getTTYModeResponse: serial %d", serial);
4974#endif
4975
4976 if (radioService[slotId]->mRadioResponse != NULL) {
4977 RadioResponseInfo responseInfo = {};
4978 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4979 Return<void> retStatus
4980 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4981 (TtyMode) ret);
4982 radioService[slotId]->checkReturnStatus(retStatus);
4983 } else {
4984 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4985 }
4986
4987 return 0;
4988}
4989
4990int radio::setPreferredVoicePrivacyResponse(int slotId,
4991 int responseType, int serial, RIL_Errno e,
4992 void *response, size_t responseLen) {
4993#if VDBG
4994 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
4995#endif
4996
4997 if (radioService[slotId]->mRadioResponse != NULL) {
4998 RadioResponseInfo responseInfo = {};
4999 populateResponseInfo(responseInfo, serial, responseType, e);
5000 Return<void> retStatus
5001 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
5002 responseInfo);
5003 radioService[slotId]->checkReturnStatus(retStatus);
5004 } else {
5005 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5006 slotId);
5007 }
5008
5009 return 0;
5010}
5011
5012int radio::getPreferredVoicePrivacyResponse(int slotId,
5013 int responseType, int serial, RIL_Errno e,
5014 void *response, size_t responseLen) {
5015#if VDBG
5016 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
5017#endif
5018
5019 if (radioService[slotId]->mRadioResponse != NULL) {
5020 RadioResponseInfo responseInfo = {};
5021 populateResponseInfo(responseInfo, serial, responseType, e);
5022 bool enable = false;
5023 int numInts = responseLen / sizeof(int);
5024 if (response == NULL || numInts != 1) {
5025 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
5026 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5027 } else {
5028 int *pInt = (int *) response;
5029 enable = pInt[0] == 1 ? true : false;
5030 }
5031 Return<void> retStatus
5032 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5033 responseInfo, enable);
5034 radioService[slotId]->checkReturnStatus(retStatus);
5035 } else {
5036 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5037 slotId);
5038 }
5039
5040 return 0;
5041}
5042
5043int radio::sendCDMAFeatureCodeResponse(int slotId,
5044 int responseType, int serial, RIL_Errno e,
5045 void *response, size_t responseLen) {
5046#if VDBG
5047 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5048#endif
5049
5050 if (radioService[slotId]->mRadioResponse != NULL) {
5051 RadioResponseInfo responseInfo = {};
5052 populateResponseInfo(responseInfo, serial, responseType, e);
5053 Return<void> retStatus
5054 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5055 radioService[slotId]->checkReturnStatus(retStatus);
5056 } else {
5057 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5058 slotId);
5059 }
5060
5061 return 0;
5062}
5063
5064int radio::sendBurstDtmfResponse(int slotId,
5065 int responseType, int serial, RIL_Errno e,
5066 void *response, size_t responseLen) {
5067#if VDBG
5068 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5069#endif
5070
5071 if (radioService[slotId]->mRadioResponse != NULL) {
5072 RadioResponseInfo responseInfo = {};
5073 populateResponseInfo(responseInfo, serial, responseType, e);
5074 Return<void> retStatus
5075 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5076 radioService[slotId]->checkReturnStatus(retStatus);
5077 } else {
5078 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5079 }
5080
5081 return 0;
5082}
5083
5084int radio::sendCdmaSmsResponse(int slotId,
5085 int responseType, int serial, RIL_Errno e, void *response,
5086 size_t responseLen) {
5087#if VDBG
5088 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5089#endif
5090
5091 if (radioService[slotId]->mRadioResponse != NULL) {
5092 RadioResponseInfo responseInfo = {};
5093 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5094 responseLen);
5095
5096 Return<void> retStatus
5097 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5098 radioService[slotId]->checkReturnStatus(retStatus);
5099 } else {
5100 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5101 }
5102
5103 return 0;
5104}
5105
5106int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5107 int responseType, int serial, RIL_Errno e,
5108 void *response, size_t responseLen) {
5109#if VDBG
5110 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5111#endif
5112
5113 if (radioService[slotId]->mRadioResponse != NULL) {
5114 RadioResponseInfo responseInfo = {};
5115 populateResponseInfo(responseInfo, serial, responseType, e);
5116 Return<void> retStatus
5117 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5118 responseInfo);
5119 radioService[slotId]->checkReturnStatus(retStatus);
5120 } else {
5121 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5122 "== NULL", slotId);
5123 }
5124
5125 return 0;
5126}
5127
5128int radio::getGsmBroadcastConfigResponse(int slotId,
5129 int responseType, int serial, RIL_Errno e,
5130 void *response, size_t responseLen) {
5131#if VDBG
5132 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5133#endif
5134
5135 if (radioService[slotId]->mRadioResponse != NULL) {
5136 RadioResponseInfo responseInfo = {};
5137 populateResponseInfo(responseInfo, serial, responseType, e);
5138 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5139
5140 if ((response == NULL && responseLen != 0)
5141 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5142 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5143 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5144 } else {
5145 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5146 configs.resize(num);
5147 for (int i = 0 ; i < num; i++) {
5148 RIL_GSM_BroadcastSmsConfigInfo *resp =
5149 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5150 configs[i].fromServiceId = resp->fromServiceId;
5151 configs[i].toServiceId = resp->toServiceId;
5152 configs[i].fromCodeScheme = resp->fromCodeScheme;
5153 configs[i].toCodeScheme = resp->toCodeScheme;
5154 configs[i].selected = resp->selected == 1 ? true : false;
5155 }
5156 }
5157
5158 Return<void> retStatus
5159 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5160 configs);
5161 radioService[slotId]->checkReturnStatus(retStatus);
5162 } else {
5163 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5164 slotId);
5165 }
5166
5167 return 0;
5168}
5169
5170int radio::setGsmBroadcastConfigResponse(int slotId,
5171 int responseType, int serial, RIL_Errno e,
5172 void *response, size_t responseLen) {
5173#if VDBG
5174 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5175#endif
5176
5177 if (radioService[slotId]->mRadioResponse != NULL) {
5178 RadioResponseInfo responseInfo = {};
5179 populateResponseInfo(responseInfo, serial, responseType, e);
5180 Return<void> retStatus
5181 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5182 radioService[slotId]->checkReturnStatus(retStatus);
5183 } else {
5184 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5185 slotId);
5186 }
5187
5188 return 0;
5189}
5190
5191int radio::setGsmBroadcastActivationResponse(int slotId,
5192 int responseType, int serial, RIL_Errno e,
5193 void *response, size_t responseLen) {
5194#if VDBG
5195 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5196#endif
5197
5198 if (radioService[slotId]->mRadioResponse != NULL) {
5199 RadioResponseInfo responseInfo = {};
5200 populateResponseInfo(responseInfo, serial, responseType, e);
5201 Return<void> retStatus
5202 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5203 responseInfo);
5204 radioService[slotId]->checkReturnStatus(retStatus);
5205 } else {
5206 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5207 slotId);
5208 }
5209
5210 return 0;
5211}
5212
5213int radio::getCdmaBroadcastConfigResponse(int slotId,
5214 int responseType, int serial, RIL_Errno e,
5215 void *response, size_t responseLen) {
5216#if VDBG
5217 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5218#endif
5219
5220 if (radioService[slotId]->mRadioResponse != NULL) {
5221 RadioResponseInfo responseInfo = {};
5222 populateResponseInfo(responseInfo, serial, responseType, e);
5223 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5224
5225 if ((response == NULL && responseLen != 0)
5226 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5227 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5228 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5229 } else {
5230 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5231 configs.resize(num);
5232 for (int i = 0 ; i < num; i++) {
5233 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5234 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5235 configs[i].serviceCategory = resp->service_category;
5236 configs[i].language = resp->language;
5237 configs[i].selected = resp->selected == 1 ? true : false;
5238 }
5239 }
5240
5241 Return<void> retStatus
5242 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5243 configs);
5244 radioService[slotId]->checkReturnStatus(retStatus);
5245 } else {
5246 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5247 slotId);
5248 }
5249
5250 return 0;
5251}
5252
5253int radio::setCdmaBroadcastConfigResponse(int slotId,
5254 int responseType, int serial, RIL_Errno e,
5255 void *response, size_t responseLen) {
5256#if VDBG
5257 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5258#endif
5259
5260 if (radioService[slotId]->mRadioResponse != NULL) {
5261 RadioResponseInfo responseInfo = {};
5262 populateResponseInfo(responseInfo, serial, responseType, e);
5263 Return<void> retStatus
5264 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5265 responseInfo);
5266 radioService[slotId]->checkReturnStatus(retStatus);
5267 } else {
5268 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5269 slotId);
5270 }
5271
5272 return 0;
5273}
5274
5275int radio::setCdmaBroadcastActivationResponse(int slotId,
5276 int responseType, int serial, RIL_Errno e,
5277 void *response, size_t responseLen) {
5278#if VDBG
5279 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5280#endif
5281
5282 if (radioService[slotId]->mRadioResponse != NULL) {
5283 RadioResponseInfo responseInfo = {};
5284 populateResponseInfo(responseInfo, serial, responseType, e);
5285 Return<void> retStatus
5286 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5287 responseInfo);
5288 radioService[slotId]->checkReturnStatus(retStatus);
5289 } else {
5290 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5291 slotId);
5292 }
5293
5294 return 0;
5295}
5296
5297int radio::getCDMASubscriptionResponse(int slotId,
5298 int responseType, int serial, RIL_Errno e, void *response,
5299 size_t responseLen) {
5300#if VDBG
5301 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5302#endif
5303
5304 if (radioService[slotId]->mRadioResponse != NULL) {
5305 RadioResponseInfo responseInfo = {};
5306 populateResponseInfo(responseInfo, serial, responseType, e);
5307
5308 int numStrings = responseLen / sizeof(char *);
5309 hidl_string emptyString;
5310 if (response == NULL || numStrings != 5) {
5311 RLOGE("getOperatorResponse Invalid response: NULL");
5312 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5313 Return<void> retStatus
5314 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5315 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5316 radioService[slotId]->checkReturnStatus(retStatus);
5317 } else {
5318 char **resp = (char **) response;
5319 Return<void> retStatus
5320 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5321 responseInfo,
5322 convertCharPtrToHidlString(resp[0]),
5323 convertCharPtrToHidlString(resp[1]),
5324 convertCharPtrToHidlString(resp[2]),
5325 convertCharPtrToHidlString(resp[3]),
5326 convertCharPtrToHidlString(resp[4]));
5327 radioService[slotId]->checkReturnStatus(retStatus);
5328 }
5329 } else {
5330 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5331 slotId);
5332 }
5333
5334 return 0;
5335}
5336
5337int radio::writeSmsToRuimResponse(int slotId,
5338 int responseType, int serial, RIL_Errno e,
5339 void *response, size_t responseLen) {
5340#if VDBG
5341 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5342#endif
5343
5344 if (radioService[slotId]->mRadioResponse != NULL) {
5345 RadioResponseInfo responseInfo = {};
5346 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5347 Return<void> retStatus
5348 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5349 radioService[slotId]->checkReturnStatus(retStatus);
5350 } else {
5351 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5352 }
5353
5354 return 0;
5355}
5356
5357int radio::deleteSmsOnRuimResponse(int slotId,
5358 int responseType, int serial, RIL_Errno e,
5359 void *response, size_t responseLen) {
5360#if VDBG
5361 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5362#endif
5363
5364 if (radioService[slotId]->mRadioResponse != NULL) {
5365 RadioResponseInfo responseInfo = {};
5366 populateResponseInfo(responseInfo, serial, responseType, e);
5367 Return<void> retStatus
5368 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5369 radioService[slotId]->checkReturnStatus(retStatus);
5370 } else {
5371 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5372 }
5373
5374 return 0;
5375}
5376
5377int radio::getDeviceIdentityResponse(int slotId,
5378 int responseType, int serial, RIL_Errno e, void *response,
5379 size_t responseLen) {
5380#if VDBG
5381 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5382#endif
5383
5384 if (radioService[slotId]->mRadioResponse != NULL) {
5385 RadioResponseInfo responseInfo = {};
5386 populateResponseInfo(responseInfo, serial, responseType, e);
5387
5388 int numStrings = responseLen / sizeof(char *);
5389 hidl_string emptyString;
5390 if (response == NULL || numStrings != 4) {
5391 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5392 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5393 Return<void> retStatus
5394 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5395 emptyString, emptyString, emptyString, emptyString);
5396 radioService[slotId]->checkReturnStatus(retStatus);
5397 } else {
5398 char **resp = (char **) response;
5399 Return<void> retStatus
5400 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5401 convertCharPtrToHidlString(resp[0]),
5402 convertCharPtrToHidlString(resp[1]),
5403 convertCharPtrToHidlString(resp[2]),
5404 convertCharPtrToHidlString(resp[3]));
5405 radioService[slotId]->checkReturnStatus(retStatus);
5406 }
5407 } else {
5408 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5409 slotId);
5410 }
5411
5412 return 0;
5413}
5414
5415int radio::exitEmergencyCallbackModeResponse(int slotId,
5416 int responseType, int serial, RIL_Errno e,
5417 void *response, size_t responseLen) {
5418#if VDBG
5419 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5420#endif
5421
5422 if (radioService[slotId]->mRadioResponse != NULL) {
5423 RadioResponseInfo responseInfo = {};
5424 populateResponseInfo(responseInfo, serial, responseType, e);
5425 Return<void> retStatus
5426 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5427 responseInfo);
5428 radioService[slotId]->checkReturnStatus(retStatus);
5429 } else {
5430 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5431 slotId);
5432 }
5433
5434 return 0;
5435}
5436
5437int radio::getSmscAddressResponse(int slotId,
5438 int responseType, int serial, RIL_Errno e,
5439 void *response, size_t responseLen) {
5440#if VDBG
5441 RLOGD("getSmscAddressResponse: serial %d", serial);
5442#endif
5443
5444 if (radioService[slotId]->mRadioResponse != NULL) {
5445 RadioResponseInfo responseInfo = {};
5446 populateResponseInfo(responseInfo, serial, responseType, e);
5447 Return<void> retStatus
5448 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5449 convertCharPtrToHidlString((char *) response));
5450 radioService[slotId]->checkReturnStatus(retStatus);
5451 } else {
5452 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5453 }
5454
5455 return 0;
5456}
5457
5458int radio::setSmscAddressResponse(int slotId,
5459 int responseType, int serial, RIL_Errno e,
5460 void *response, size_t responseLen) {
5461#if VDBG
5462 RLOGD("setSmscAddressResponse: serial %d", serial);
5463#endif
5464
5465 if (radioService[slotId]->mRadioResponse != NULL) {
5466 RadioResponseInfo responseInfo = {};
5467 populateResponseInfo(responseInfo, serial, responseType, e);
5468 Return<void> retStatus
5469 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5470 radioService[slotId]->checkReturnStatus(retStatus);
5471 } else {
5472 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5473 }
5474
5475 return 0;
5476}
5477
5478int radio::reportSmsMemoryStatusResponse(int slotId,
5479 int responseType, int serial, RIL_Errno e,
5480 void *response, size_t responseLen) {
5481#if VDBG
5482 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5483#endif
5484
5485 if (radioService[slotId]->mRadioResponse != NULL) {
5486 RadioResponseInfo responseInfo = {};
5487 populateResponseInfo(responseInfo, serial, responseType, e);
5488 Return<void> retStatus
5489 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5490 radioService[slotId]->checkReturnStatus(retStatus);
5491 } else {
5492 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5493 slotId);
5494 }
5495
5496 return 0;
5497}
5498
5499int radio::reportStkServiceIsRunningResponse(int slotId,
5500 int responseType, int serial, RIL_Errno e,
5501 void *response, size_t responseLen) {
5502#if VDBG
5503 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5504#endif
5505
5506 if (radioService[slotId]->mRadioResponse != NULL) {
5507 RadioResponseInfo responseInfo = {};
5508 populateResponseInfo(responseInfo, serial, responseType, e);
5509 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5510 reportStkServiceIsRunningResponse(responseInfo);
5511 radioService[slotId]->checkReturnStatus(retStatus);
5512 } else {
5513 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5514 slotId);
5515 }
5516
5517 return 0;
5518}
5519
5520int radio::getCdmaSubscriptionSourceResponse(int slotId,
5521 int responseType, int serial, RIL_Errno e,
5522 void *response, size_t responseLen) {
5523#if VDBG
5524 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5525#endif
5526
5527 if (radioService[slotId]->mRadioResponse != NULL) {
5528 RadioResponseInfo responseInfo = {};
5529 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5530 Return<void> retStatus
5531 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5532 responseInfo, (CdmaSubscriptionSource) ret);
5533 radioService[slotId]->checkReturnStatus(retStatus);
5534 } else {
5535 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5536 slotId);
5537 }
5538
5539 return 0;
5540}
5541
5542int radio::requestIsimAuthenticationResponse(int slotId,
5543 int responseType, int serial, RIL_Errno e,
5544 void *response, size_t responseLen) {
5545#if VDBG
5546 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5547#endif
5548
5549 if (radioService[slotId]->mRadioResponse != NULL) {
5550 RadioResponseInfo responseInfo = {};
5551 populateResponseInfo(responseInfo, serial, responseType, e);
5552 Return<void> retStatus
5553 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5554 responseInfo,
5555 convertCharPtrToHidlString((char *) response));
5556 radioService[slotId]->checkReturnStatus(retStatus);
5557 } else {
5558 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5559 slotId);
5560 }
5561
5562 return 0;
5563}
5564
5565int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5566 int responseType,
5567 int serial, RIL_Errno e, void *response,
5568 size_t responseLen) {
5569#if VDBG
5570 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5571#endif
5572
5573 if (radioService[slotId]->mRadioResponse != NULL) {
5574 RadioResponseInfo responseInfo = {};
5575 populateResponseInfo(responseInfo, serial, responseType, e);
5576 Return<void> retStatus
5577 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5578 responseInfo);
5579 radioService[slotId]->checkReturnStatus(retStatus);
5580 } else {
5581 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5582 "== NULL", slotId);
5583 }
5584
5585 return 0;
5586}
5587
5588int radio::sendEnvelopeWithStatusResponse(int slotId,
5589 int responseType, int serial, RIL_Errno e, void *response,
5590 size_t responseLen) {
5591#if VDBG
5592 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5593#endif
5594
5595 if (radioService[slotId]->mRadioResponse != NULL) {
5596 RadioResponseInfo responseInfo = {};
5597 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5598 response, responseLen);
5599
5600 Return<void> retStatus
5601 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5602 result);
5603 radioService[slotId]->checkReturnStatus(retStatus);
5604 } else {
5605 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5606 slotId);
5607 }
5608
5609 return 0;
5610}
5611
5612int radio::getVoiceRadioTechnologyResponse(int slotId,
5613 int responseType, int serial, RIL_Errno e,
5614 void *response, size_t responseLen) {
5615#if VDBG
5616 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5617#endif
5618
5619 if (radioService[slotId]->mRadioResponse != NULL) {
5620 RadioResponseInfo responseInfo = {};
5621 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5622 Return<void> retStatus
5623 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5624 responseInfo, (RadioTechnology) ret);
5625 radioService[slotId]->checkReturnStatus(retStatus);
5626 } else {
5627 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5628 slotId);
5629 }
5630
5631 return 0;
5632}
5633
5634int radio::getCellInfoListResponse(int slotId,
5635 int responseType,
5636 int serial, RIL_Errno e, void *response,
5637 size_t responseLen) {
5638#if VDBG
5639 RLOGD("getCellInfoListResponse: serial %d", serial);
5640#endif
5641
5642 if (radioService[slotId]->mRadioResponse != NULL) {
5643 RadioResponseInfo responseInfo = {};
5644 populateResponseInfo(responseInfo, serial, responseType, e);
5645
5646 hidl_vec<CellInfo> ret;
5647 if ((response == NULL && responseLen != 0)
5648 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5649 RLOGE("getCellInfoListResponse: Invalid response");
5650 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5651 } else {
5652 convertRilCellInfoListToHal(response, responseLen, ret);
5653 }
5654
5655 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5656 responseInfo, ret);
5657 radioService[slotId]->checkReturnStatus(retStatus);
5658 } else {
5659 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5660 }
5661
5662 return 0;
5663}
5664
5665int radio::setCellInfoListRateResponse(int slotId,
5666 int responseType,
5667 int serial, RIL_Errno e, void *response,
5668 size_t responseLen) {
5669#if VDBG
5670 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5671#endif
5672
5673 if (radioService[slotId]->mRadioResponse != NULL) {
5674 RadioResponseInfo responseInfo = {};
5675 populateResponseInfo(responseInfo, serial, responseType, e);
5676 Return<void> retStatus
5677 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5678 radioService[slotId]->checkReturnStatus(retStatus);
5679 } else {
5680 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5681 slotId);
5682 }
5683
5684 return 0;
5685}
5686
5687int radio::setInitialAttachApnResponse(int slotId,
5688 int responseType, int serial, RIL_Errno e,
5689 void *response, size_t responseLen) {
5690#if VDBG
5691 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5692#endif
5693
5694 if (radioService[slotId]->mRadioResponse != NULL) {
5695 RadioResponseInfo responseInfo = {};
5696 populateResponseInfo(responseInfo, serial, responseType, e);
5697 Return<void> retStatus
5698 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5699 radioService[slotId]->checkReturnStatus(retStatus);
5700 } else {
5701 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5702 slotId);
5703 }
5704
5705 return 0;
5706}
5707
5708int radio::getImsRegistrationStateResponse(int slotId,
5709 int responseType, int serial, RIL_Errno e,
5710 void *response, size_t responseLen) {
5711#if VDBG
5712 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5713#endif
5714
5715 if (radioService[slotId]->mRadioResponse != NULL) {
5716 RadioResponseInfo responseInfo = {};
5717 populateResponseInfo(responseInfo, serial, responseType, e);
5718 bool isRegistered = false;
5719 int ratFamily = 0;
5720 int numInts = responseLen / sizeof(int);
5721 if (response == NULL || numInts != 2) {
5722 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5723 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5724 } else {
5725 int *pInt = (int *) response;
5726 isRegistered = pInt[0] == 1 ? true : false;
5727 ratFamily = pInt[1];
5728 }
5729 Return<void> retStatus
5730 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5731 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5732 radioService[slotId]->checkReturnStatus(retStatus);
5733 } else {
5734 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5735 slotId);
5736 }
5737
5738 return 0;
5739}
5740
5741int radio::sendImsSmsResponse(int slotId,
5742 int responseType, int serial, RIL_Errno e, void *response,
5743 size_t responseLen) {
5744#if VDBG
5745 RLOGD("sendImsSmsResponse: serial %d", serial);
5746#endif
5747
5748 if (radioService[slotId]->mRadioResponse != NULL) {
5749 RadioResponseInfo responseInfo = {};
5750 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5751 responseLen);
5752
5753 Return<void> retStatus
5754 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5755 radioService[slotId]->checkReturnStatus(retStatus);
5756 } else {
5757 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5758 }
5759
5760 return 0;
5761}
5762
5763int radio::iccTransmitApduBasicChannelResponse(int slotId,
5764 int responseType, int serial, RIL_Errno e,
5765 void *response, size_t responseLen) {
5766#if VDBG
5767 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5768#endif
5769
5770 if (radioService[slotId]->mRadioResponse != NULL) {
5771 RadioResponseInfo responseInfo = {};
5772 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5773 responseLen);
5774
5775 Return<void> retStatus
5776 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5777 responseInfo, result);
5778 radioService[slotId]->checkReturnStatus(retStatus);
5779 } else {
5780 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5781 "== NULL", slotId);
5782 }
5783
5784 return 0;
5785}
5786
5787int radio::iccOpenLogicalChannelResponse(int slotId,
5788 int responseType, int serial, RIL_Errno e, void *response,
5789 size_t responseLen) {
5790#if VDBG
5791 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5792#endif
5793
5794 if (radioService[slotId]->mRadioResponse != NULL) {
5795 RadioResponseInfo responseInfo = {};
5796 populateResponseInfo(responseInfo, serial, responseType, e);
5797 int channelId = -1;
5798 hidl_vec<int8_t> selectResponse;
5799 int numInts = responseLen / sizeof(int);
5800 if (response == NULL || responseLen % sizeof(int) != 0) {
5801 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5802 if (response != NULL) {
5803 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5804 }
5805 } else {
5806 int *pInt = (int *) response;
5807 channelId = pInt[0];
5808 selectResponse.resize(numInts - 1);
5809 for (int i = 1; i < numInts; i++) {
5810 selectResponse[i - 1] = (int8_t) pInt[i];
5811 }
5812 }
5813 Return<void> retStatus
5814 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5815 channelId, selectResponse);
5816 radioService[slotId]->checkReturnStatus(retStatus);
5817 } else {
5818 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5819 slotId);
5820 }
5821
5822 return 0;
5823}
5824
5825int radio::iccCloseLogicalChannelResponse(int slotId,
5826 int responseType, int serial, RIL_Errno e,
5827 void *response, size_t responseLen) {
5828#if VDBG
5829 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5830#endif
5831
5832 if (radioService[slotId]->mRadioResponse != NULL) {
5833 RadioResponseInfo responseInfo = {};
5834 populateResponseInfo(responseInfo, serial, responseType, e);
5835 Return<void> retStatus
5836 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5837 responseInfo);
5838 radioService[slotId]->checkReturnStatus(retStatus);
5839 } else {
5840 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5841 slotId);
5842 }
5843
5844 return 0;
5845}
5846
5847int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5848 int responseType, int serial, RIL_Errno e,
5849 void *response, size_t responseLen) {
5850#if VDBG
5851 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5852#endif
5853
5854 if (radioService[slotId]->mRadioResponse != NULL) {
5855 RadioResponseInfo responseInfo = {};
5856 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5857 responseLen);
5858
5859 Return<void> retStatus
5860 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5861 responseInfo, result);
5862 radioService[slotId]->checkReturnStatus(retStatus);
5863 } else {
5864 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5865 "== NULL", slotId);
5866 }
5867
5868 return 0;
5869}
5870
5871int radio::nvReadItemResponse(int slotId,
5872 int responseType, int serial, RIL_Errno e,
5873 void *response, size_t responseLen) {
5874#if VDBG
5875 RLOGD("nvReadItemResponse: serial %d", serial);
5876#endif
5877
5878 if (radioService[slotId]->mRadioResponse != NULL) {
5879 RadioResponseInfo responseInfo = {};
5880 populateResponseInfo(responseInfo, serial, responseType, e);
5881 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5882 responseInfo,
5883 convertCharPtrToHidlString((char *) response));
5884 radioService[slotId]->checkReturnStatus(retStatus);
5885 } else {
5886 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5887 }
5888
5889 return 0;
5890}
5891
5892int radio::nvWriteItemResponse(int slotId,
5893 int responseType, int serial, RIL_Errno e,
5894 void *response, size_t responseLen) {
5895#if VDBG
5896 RLOGD("nvWriteItemResponse: serial %d", serial);
5897#endif
5898
5899 if (radioService[slotId]->mRadioResponse != NULL) {
5900 RadioResponseInfo responseInfo = {};
5901 populateResponseInfo(responseInfo, serial, responseType, e);
5902 Return<void> retStatus
5903 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5904 radioService[slotId]->checkReturnStatus(retStatus);
5905 } else {
5906 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5907 }
5908
5909 return 0;
5910}
5911
5912int radio::nvWriteCdmaPrlResponse(int slotId,
5913 int responseType, int serial, RIL_Errno e,
5914 void *response, size_t responseLen) {
5915#if VDBG
5916 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5917#endif
5918
5919 if (radioService[slotId]->mRadioResponse != NULL) {
5920 RadioResponseInfo responseInfo = {};
5921 populateResponseInfo(responseInfo, serial, responseType, e);
5922 Return<void> retStatus
5923 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5924 radioService[slotId]->checkReturnStatus(retStatus);
5925 } else {
5926 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5927 }
5928
5929 return 0;
5930}
5931
5932int radio::nvResetConfigResponse(int slotId,
5933 int responseType, int serial, RIL_Errno e,
5934 void *response, size_t responseLen) {
5935#if VDBG
5936 RLOGD("nvResetConfigResponse: serial %d", serial);
5937#endif
5938
5939 if (radioService[slotId]->mRadioResponse != NULL) {
5940 RadioResponseInfo responseInfo = {};
5941 populateResponseInfo(responseInfo, serial, responseType, e);
5942 Return<void> retStatus
5943 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5944 radioService[slotId]->checkReturnStatus(retStatus);
5945 } else {
5946 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5947 }
5948
5949 return 0;
5950}
5951
5952int radio::setUiccSubscriptionResponse(int slotId,
5953 int responseType, int serial, RIL_Errno e,
5954 void *response, size_t responseLen) {
5955#if VDBG
5956 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5957#endif
5958
5959 if (radioService[slotId]->mRadioResponse != NULL) {
5960 RadioResponseInfo responseInfo = {};
5961 populateResponseInfo(responseInfo, serial, responseType, e);
5962 Return<void> retStatus
5963 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5964 radioService[slotId]->checkReturnStatus(retStatus);
5965 } else {
5966 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5967 slotId);
5968 }
5969
5970 return 0;
5971}
5972
5973int radio::setDataAllowedResponse(int slotId,
5974 int responseType, int serial, RIL_Errno e,
5975 void *response, size_t responseLen) {
5976#if VDBG
5977 RLOGD("setDataAllowedResponse: serial %d", serial);
5978#endif
5979
5980 if (radioService[slotId]->mRadioResponse != NULL) {
5981 RadioResponseInfo responseInfo = {};
5982 populateResponseInfo(responseInfo, serial, responseType, e);
5983 Return<void> retStatus
5984 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5985 radioService[slotId]->checkReturnStatus(retStatus);
5986 } else {
5987 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5988 }
5989
5990 return 0;
5991}
5992
5993int radio::getHardwareConfigResponse(int slotId,
5994 int responseType, int serial, RIL_Errno e,
5995 void *response, size_t responseLen) {
5996#if VDBG
5997 RLOGD("getHardwareConfigResponse: serial %d", serial);
5998#endif
5999
6000 if (radioService[slotId]->mRadioResponse != NULL) {
6001 RadioResponseInfo responseInfo = {};
6002 populateResponseInfo(responseInfo, serial, responseType, e);
6003
6004 hidl_vec<HardwareConfig> result;
6005 if ((response == NULL && responseLen != 0)
6006 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
6007 RLOGE("hardwareConfigChangedInd: invalid response");
6008 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6009 } else {
6010 convertRilHardwareConfigListToHal(response, responseLen, result);
6011 }
6012
6013 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
6014 responseInfo, result);
6015 radioService[slotId]->checkReturnStatus(retStatus);
6016 } else {
6017 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6018 }
6019
6020 return 0;
6021}
6022
6023int radio::requestIccSimAuthenticationResponse(int slotId,
6024 int responseType, int serial, RIL_Errno e,
6025 void *response, size_t responseLen) {
6026#if VDBG
6027 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6028#endif
6029
6030 if (radioService[slotId]->mRadioResponse != NULL) {
6031 RadioResponseInfo responseInfo = {};
6032 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6033 responseLen);
6034
6035 Return<void> retStatus
6036 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6037 responseInfo, result);
6038 radioService[slotId]->checkReturnStatus(retStatus);
6039 } else {
6040 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6041 "== NULL", slotId);
6042 }
6043
6044 return 0;
6045}
6046
6047int radio::setDataProfileResponse(int slotId,
6048 int responseType, int serial, RIL_Errno e,
6049 void *response, size_t responseLen) {
6050#if VDBG
6051 RLOGD("setDataProfileResponse: serial %d", serial);
6052#endif
6053
6054 if (radioService[slotId]->mRadioResponse != NULL) {
6055 RadioResponseInfo responseInfo = {};
6056 populateResponseInfo(responseInfo, serial, responseType, e);
6057 Return<void> retStatus
6058 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6059 radioService[slotId]->checkReturnStatus(retStatus);
6060 } else {
6061 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6062 }
6063
6064 return 0;
6065}
6066
6067int radio::requestShutdownResponse(int slotId,
6068 int responseType, int serial, RIL_Errno e,
6069 void *response, size_t responseLen) {
6070#if VDBG
6071 RLOGD("requestShutdownResponse: serial %d", serial);
6072#endif
6073
6074 if (radioService[slotId]->mRadioResponse != NULL) {
6075 RadioResponseInfo responseInfo = {};
6076 populateResponseInfo(responseInfo, serial, responseType, e);
6077 Return<void> retStatus
6078 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6079 radioService[slotId]->checkReturnStatus(retStatus);
6080 } else {
6081 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6082 }
6083
6084 return 0;
6085}
6086
6087void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6088 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6089 populateResponseInfo(responseInfo, serial, responseType, e);
6090
6091 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6092 RLOGE("responseRadioCapability: Invalid response");
6093 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6094 rc.logicalModemUuid = hidl_string();
6095 } else {
6096 convertRilRadioCapabilityToHal(response, responseLen, rc);
6097 }
6098}
6099
6100int radio::getRadioCapabilityResponse(int slotId,
6101 int responseType, int serial, RIL_Errno e,
6102 void *response, size_t responseLen) {
6103#if VDBG
6104 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6105#endif
6106
6107 if (radioService[slotId]->mRadioResponse != NULL) {
6108 RadioResponseInfo responseInfo = {};
6109 RadioCapability result = {};
6110 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6111 result);
6112 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6113 responseInfo, result);
6114 radioService[slotId]->checkReturnStatus(retStatus);
6115 } else {
6116 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6117 }
6118
6119 return 0;
6120}
6121
6122int radio::setRadioCapabilityResponse(int slotId,
6123 int responseType, int serial, RIL_Errno e,
6124 void *response, size_t responseLen) {
6125#if VDBG
6126 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6127#endif
6128
6129 if (radioService[slotId]->mRadioResponse != NULL) {
6130 RadioResponseInfo responseInfo = {};
6131 RadioCapability result = {};
6132 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6133 result);
6134 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6135 responseInfo, result);
6136 radioService[slotId]->checkReturnStatus(retStatus);
6137 } else {
6138 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6139 }
6140
6141 return 0;
6142}
6143
6144LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6145 RIL_Errno e, void *response, size_t responseLen) {
6146 populateResponseInfo(responseInfo, serial, responseType, e);
6147 LceStatusInfo result = {};
6148
6149 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6150 RLOGE("Invalid response: NULL");
6151 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6152 } else {
6153 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6154 result.lceStatus = (LceStatus) resp->lce_status;
6155 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6156 }
6157 return result;
6158}
6159
6160int radio::startLceServiceResponse(int slotId,
6161 int responseType, int serial, RIL_Errno e,
6162 void *response, size_t responseLen) {
6163#if VDBG
6164 RLOGD("startLceServiceResponse: serial %d", serial);
6165#endif
6166
6167 if (radioService[slotId]->mRadioResponse != NULL) {
6168 RadioResponseInfo responseInfo = {};
6169 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6170 response, responseLen);
6171
6172 Return<void> retStatus
6173 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6174 result);
6175 radioService[slotId]->checkReturnStatus(retStatus);
6176 } else {
6177 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6178 }
6179
6180 return 0;
6181}
6182
6183int radio::stopLceServiceResponse(int slotId,
6184 int responseType, int serial, RIL_Errno e,
6185 void *response, size_t responseLen) {
6186#if VDBG
6187 RLOGD("stopLceServiceResponse: serial %d", serial);
6188#endif
6189
6190 if (radioService[slotId]->mRadioResponse != NULL) {
6191 RadioResponseInfo responseInfo = {};
6192 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6193 response, responseLen);
6194
6195 Return<void> retStatus
6196 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6197 result);
6198 radioService[slotId]->checkReturnStatus(retStatus);
6199 } else {
6200 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6201 }
6202
6203 return 0;
6204}
6205
6206int radio::pullLceDataResponse(int slotId,
6207 int responseType, int serial, RIL_Errno e,
6208 void *response, size_t responseLen) {
6209#if VDBG
6210 RLOGD("pullLceDataResponse: serial %d", serial);
6211#endif
6212
6213 if (radioService[slotId]->mRadioResponse != NULL) {
6214 RadioResponseInfo responseInfo = {};
6215 populateResponseInfo(responseInfo, serial, responseType, e);
6216
6217 LceDataInfo result = {};
6218 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6219 RLOGE("pullLceDataResponse: Invalid response");
6220 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6221 } else {
6222 convertRilLceDataInfoToHal(response, responseLen, result);
6223 }
6224
6225 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6226 responseInfo, result);
6227 radioService[slotId]->checkReturnStatus(retStatus);
6228 } else {
6229 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6230 }
6231
6232 return 0;
6233}
6234
6235int radio::getModemActivityInfoResponse(int slotId,
6236 int responseType, int serial, RIL_Errno e,
6237 void *response, size_t responseLen) {
6238#if VDBG
6239 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6240#endif
6241
6242 if (radioService[slotId]->mRadioResponse != NULL) {
6243 RadioResponseInfo responseInfo = {};
6244 populateResponseInfo(responseInfo, serial, responseType, e);
6245 ActivityStatsInfo info;
6246 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6247 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6248 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6249 } else {
6250 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6251 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6252 info.idleModeTimeMs = resp->idle_mode_time_ms;
6253 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6254 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6255 }
6256 info.rxModeTimeMs = resp->rx_mode_time_ms;
6257 }
6258
6259 Return<void> retStatus
6260 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6261 info);
6262 radioService[slotId]->checkReturnStatus(retStatus);
6263 } else {
6264 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6265 slotId);
6266 }
6267
6268 return 0;
6269}
6270
6271int radio::setAllowedCarriersResponse(int slotId,
6272 int responseType, int serial, RIL_Errno e,
6273 void *response, size_t responseLen) {
6274#if VDBG
6275 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6276#endif
6277
6278 if (radioService[slotId]->mRadioResponse != NULL) {
6279 RadioResponseInfo responseInfo = {};
6280 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6281 Return<void> retStatus
6282 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6283 ret);
6284 radioService[slotId]->checkReturnStatus(retStatus);
6285 } else {
6286 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6287 slotId);
6288 }
6289
6290 return 0;
6291}
6292
6293int radio::getAllowedCarriersResponse(int slotId,
6294 int responseType, int serial, RIL_Errno e,
6295 void *response, size_t responseLen) {
6296#if VDBG
6297 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6298#endif
6299
6300 if (radioService[slotId]->mRadioResponse != NULL) {
6301 RadioResponseInfo responseInfo = {};
6302 populateResponseInfo(responseInfo, serial, responseType, e);
6303 CarrierRestrictions carrierInfo = {};
6304 bool allAllowed = true;
6305 if (response == NULL) {
6306#if VDBG
6307 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6308#endif
6309 carrierInfo.allowedCarriers.resize(0);
6310 carrierInfo.excludedCarriers.resize(0);
6311 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6312 RLOGE("getAllowedCarriersResponse Invalid response");
6313 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6314 } else {
6315 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6316 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6317 allAllowed = false;
6318 }
6319
6320 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6321 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6322 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6323 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6324 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6325 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6326 carrierInfo.allowedCarriers[i].matchData =
6327 convertCharPtrToHidlString(carrier->match_data);
6328 }
6329
6330 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6331 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6332 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6333 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6334 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6335 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6336 carrierInfo.excludedCarriers[i].matchData =
6337 convertCharPtrToHidlString(carrier->match_data);
6338 }
6339 }
6340
6341 Return<void> retStatus
6342 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6343 allAllowed, carrierInfo);
6344 radioService[slotId]->checkReturnStatus(retStatus);
6345 } else {
6346 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6347 slotId);
6348 }
6349
6350 return 0;
6351}
6352
6353int radio::sendDeviceStateResponse(int slotId,
6354 int responseType, int serial, RIL_Errno e,
6355 void *response, size_t responselen) {
6356#if VDBG
6357 RLOGD("sendDeviceStateResponse: serial %d", serial);
6358#endif
6359
6360 if (radioService[slotId]->mRadioResponse != NULL) {
6361 RadioResponseInfo responseInfo = {};
6362 populateResponseInfo(responseInfo, serial, responseType, e);
6363 Return<void> retStatus
6364 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6365 radioService[slotId]->checkReturnStatus(retStatus);
6366 } else {
6367 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6368 }
6369
6370 return 0;
6371}
6372
6373int radio::setIndicationFilterResponse(int slotId,
6374 int responseType, int serial, RIL_Errno e,
6375 void *response, size_t responselen) {
6376#if VDBG
6377 RLOGD("setIndicationFilterResponse: serial %d", serial);
6378#endif
6379
6380 if (radioService[slotId]->mRadioResponse != NULL) {
6381 RadioResponseInfo responseInfo = {};
6382 populateResponseInfo(responseInfo, serial, responseType, e);
6383 Return<void> retStatus
6384 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6385 radioService[slotId]->checkReturnStatus(retStatus);
6386 } else {
6387 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6388 slotId);
6389 }
6390
6391 return 0;
6392}
6393
6394
6395int radio::setSimCardPowerResponse(int slotId,
6396 int responseType, int serial, RIL_Errno e,
6397 void *response, size_t responseLen) {
6398#if VDBG
6399 RLOGD("setSimCardPowerResponse: serial %d", serial);
6400#endif
6401
6402 if (radioService[slotId]->mRadioResponse != NULL) {
6403 RadioResponseInfo responseInfo = {};
6404 populateResponseInfo(responseInfo, serial, responseType, e);
6405 Return<void> retStatus
6406 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6407 radioService[slotId]->checkReturnStatus(retStatus);
6408 } else {
6409 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6410 }
6411
6412 return 0;
6413}
6414
6415int radio::sendRequestRawResponse(int slotId,
6416 int responseType, int serial, RIL_Errno e,
6417 void *response, size_t responseLen) {
6418#if VDBG
6419 RLOGD("sendRequestRawResponse: serial %d", serial);
6420#endif
6421
6422 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6423 RadioResponseInfo responseInfo = {};
6424 populateResponseInfo(responseInfo, serial, responseType, e);
6425 hidl_vec<uint8_t> data;
6426
6427 if (response == NULL) {
6428 RLOGE("sendRequestRawResponse: Invalid response");
6429 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6430 } else {
6431 data.setToExternal((uint8_t *) response, responseLen);
6432 }
6433 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6434 sendRequestRawResponse(responseInfo, data);
6435 checkReturnStatus(slotId, retStatus, false);
6436 } else {
6437 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6438 slotId);
6439 }
6440
6441 return 0;
6442}
6443
6444int radio::sendRequestStringsResponse(int slotId,
6445 int responseType, int serial, RIL_Errno e,
6446 void *response, size_t responseLen) {
6447#if VDBG
6448 RLOGD("sendRequestStringsResponse: serial %d", serial);
6449#endif
6450
6451 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6452 RadioResponseInfo responseInfo = {};
6453 populateResponseInfo(responseInfo, serial, responseType, e);
6454 hidl_vec<hidl_string> data;
6455
6456 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
6457 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6458 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6459 } else {
6460 char **resp = (char **) response;
6461 int numStrings = responseLen / sizeof(char *);
6462 data.resize(numStrings);
6463 for (int i = 0; i < numStrings; i++) {
6464 data[i] = convertCharPtrToHidlString(resp[i]);
6465 }
6466 }
6467 Return<void> retStatus
6468 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6469 responseInfo, data);
6470 checkReturnStatus(slotId, retStatus, false);
6471 } else {
6472 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6473 "NULL", slotId);
6474 }
6475
6476 return 0;
6477}
6478
6479// Radio Indication functions
6480
6481RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6482 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6483 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6484}
6485
6486int radio::radioStateChangedInd(int slotId,
6487 int indicationType, int token, RIL_Errno e, void *response,
6488 size_t responseLen) {
6489 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6490 RadioState radioState =
6491 (RadioState) CALL_ONSTATEREQUEST(slotId);
6492 RLOGD("radioStateChangedInd: radioState %d", radioState);
6493 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6494 convertIntToRadioIndicationType(indicationType), radioState);
6495 radioService[slotId]->checkReturnStatus(retStatus);
6496 } else {
6497 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6498 }
6499
6500 return 0;
6501}
6502
6503int radio::callStateChangedInd(int slotId,
6504 int indicationType, int token, RIL_Errno e, void *response,
6505 size_t responseLen) {
6506 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6507#if VDBG
6508 RLOGD("callStateChangedInd");
6509#endif
6510 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6511 convertIntToRadioIndicationType(indicationType));
6512 radioService[slotId]->checkReturnStatus(retStatus);
6513 } else {
6514 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6515 }
6516
6517 return 0;
6518}
6519
6520int radio::networkStateChangedInd(int slotId,
6521 int indicationType, int token, RIL_Errno e, void *response,
6522 size_t responseLen) {
6523 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6524#if VDBG
6525 RLOGD("networkStateChangedInd");
6526#endif
6527 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6528 convertIntToRadioIndicationType(indicationType));
6529 radioService[slotId]->checkReturnStatus(retStatus);
6530 } else {
6531 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6532 slotId);
6533 }
6534
6535 return 0;
6536}
6537
6538uint8_t hexCharToInt(uint8_t c) {
6539 if (c >= '0' && c <= '9') return (c - '0');
6540 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6541 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6542
6543 return INVALID_HEX_CHAR;
6544}
6545
6546uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6547 if (responseLen % 2 != 0) {
6548 return NULL;
6549 }
6550
6551 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6552 if (bytes == NULL) {
6553 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6554 return NULL;
6555 }
6556 uint8_t *hexString = (uint8_t *)response;
6557
6558 for (size_t i = 0; i < responseLen; i += 2) {
6559 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6560 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6561
6562 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6563 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6564 hexString[i], hexString[i + 1]);
6565 free(bytes);
6566 return NULL;
6567 }
6568 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6569 }
6570
6571 return bytes;
6572}
6573
6574int radio::newSmsInd(int slotId, int indicationType,
6575 int token, RIL_Errno e, void *response, size_t responseLen) {
6576 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6577 if (response == NULL || responseLen == 0) {
6578 RLOGE("newSmsInd: invalid response");
6579 return 0;
6580 }
6581
6582 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6583 if (bytes == NULL) {
6584 RLOGE("newSmsInd: convertHexStringToBytes failed");
6585 return 0;
6586 }
6587
6588 hidl_vec<uint8_t> pdu;
6589 pdu.setToExternal(bytes, responseLen/2);
6590#if VDBG
6591 RLOGD("newSmsInd");
6592#endif
6593 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6594 convertIntToRadioIndicationType(indicationType), pdu);
6595 radioService[slotId]->checkReturnStatus(retStatus);
6596 free(bytes);
6597 } else {
6598 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6599 }
6600
6601 return 0;
6602}
6603
6604int radio::newSmsStatusReportInd(int slotId,
6605 int indicationType, int token, RIL_Errno e, void *response,
6606 size_t responseLen) {
6607 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6608 if (response == NULL || responseLen == 0) {
6609 RLOGE("newSmsStatusReportInd: invalid response");
6610 return 0;
6611 }
6612
6613 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6614 if (bytes == NULL) {
6615 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6616 return 0;
6617 }
6618
6619 hidl_vec<uint8_t> pdu;
6620 pdu.setToExternal(bytes, responseLen/2);
6621#if VDBG
6622 RLOGD("newSmsStatusReportInd");
6623#endif
6624 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6625 convertIntToRadioIndicationType(indicationType), pdu);
6626 radioService[slotId]->checkReturnStatus(retStatus);
6627 free(bytes);
6628 } else {
6629 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6630 }
6631
6632 return 0;
6633}
6634
6635int radio::newSmsOnSimInd(int slotId, int indicationType,
6636 int token, RIL_Errno e, void *response, size_t responseLen) {
6637 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6638 if (response == NULL || responseLen != sizeof(int)) {
6639 RLOGE("newSmsOnSimInd: invalid response");
6640 return 0;
6641 }
6642 int32_t recordNumber = ((int32_t *) response)[0];
6643#if VDBG
6644 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6645#endif
6646 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6647 convertIntToRadioIndicationType(indicationType), recordNumber);
6648 radioService[slotId]->checkReturnStatus(retStatus);
6649 } else {
6650 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6651 }
6652
6653 return 0;
6654}
6655
6656int radio::onUssdInd(int slotId, int indicationType,
6657 int token, RIL_Errno e, void *response, size_t responseLen) {
6658 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6659 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6660 RLOGE("onUssdInd: invalid response");
6661 return 0;
6662 }
6663 char **strings = (char **) response;
6664 char *mode = strings[0];
6665 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6666 UssdModeType modeType = (UssdModeType) atoi(mode);
6667#if VDBG
6668 RLOGD("onUssdInd: mode %s", mode);
6669#endif
6670 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6671 convertIntToRadioIndicationType(indicationType), modeType, msg);
6672 radioService[slotId]->checkReturnStatus(retStatus);
6673 } else {
6674 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6675 }
6676
6677 return 0;
6678}
6679
6680int radio::nitzTimeReceivedInd(int slotId,
6681 int indicationType, int token, RIL_Errno e, void *response,
6682 size_t responseLen) {
6683 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6684 if (response == NULL || responseLen == 0) {
6685 RLOGE("nitzTimeReceivedInd: invalid response");
6686 return 0;
6687 }
6688 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6689 int64_t timeReceived = android::elapsedRealtime();
6690#if VDBG
6691 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6692 timeReceived);
6693#endif
6694 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6695 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6696 radioService[slotId]->checkReturnStatus(retStatus);
6697 } else {
6698 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6699 return -1;
6700 }
6701
6702 return 0;
6703}
6704
Martin Bouchet6e9a4972017-09-23 04:55:52 -03006705void convertRilSignalStrengthToHalV5(void *response, size_t responseLen,
6706 SignalStrength& signalStrength) {
6707 RIL_SignalStrength_v5 *rilSignalStrength = (RIL_SignalStrength_v5 *) response;
Martin Bouchetdb968d42017-09-23 05:23:52 -03006708 int gsmSignalStrength;
6709 int cdmaDbm;
6710 int evdoDbm;
Martin Bouchet6e9a4972017-09-23 04:55:52 -03006711
Martin Bouchetdb968d42017-09-23 05:23:52 -03006712 gsmSignalStrength = rilSignalStrength->GW_SignalStrength.signalStrength & 0xFF;
6713
6714#ifdef MODEM_TYPE_XMM6260
6715 if (gsmSignalStrength < 0 ||
6716 (gsmSignalStrength > 31 && rilSignalStrength->GW_SignalStrength.signalStrength != 99)) {
6717 gsmSignalStrength = rilSignalStrength->CDMA_SignalStrength.dbm;
6718 }
6719#else
6720 if (gsmSignalStrength < 0) {
6721 gsmSignalStrength = 99;
6722 } else if (gsmSignalStrength > 31 && gsmSignalStrength != 99) {
6723 gsmSignalStrength = 31;
6724 }
6725#endif
6726
6727#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM)
6728 cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm & 0xFF;
6729 if (cdmaDbm < 0) {
6730 cdmaDbm = 99;
6731 } else if (cdmaDbm > 31 && cdmaDbm != 99) {
6732 cdmaDbm = 31;
6733 }
6734#else
6735 cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6736#endif
6737
6738#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM)
6739 evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm & 0xFF;
6740 if (evdoDbm < 0) {
6741 evdoDbm = 99;
6742 } else if (evdoDbm > 31 && evdoDbm != 99) {
6743 evdoDbm = 31;
6744 }
6745#else
6746 evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6747#endif
6748
6749 signalStrength.gw.signalStrength = gsmSignalStrength;
Martin Bouchet6e9a4972017-09-23 04:55:52 -03006750 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
Martin Bouchetdb968d42017-09-23 05:23:52 -03006751 signalStrength.cdma.dbm = cdmaDbm;
Martin Bouchet6e9a4972017-09-23 04:55:52 -03006752 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
Martin Bouchetdb968d42017-09-23 05:23:52 -03006753 signalStrength.evdo.dbm = evdoDbm;
Martin Bouchet6e9a4972017-09-23 04:55:52 -03006754 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6755 signalStrength.evdo.signalNoiseRatio =
6756 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6757 signalStrength.lte.signalStrength = 99;
6758 signalStrength.lte.rsrp = INT_MAX;
6759 signalStrength.lte.rsrq = INT_MAX;
6760 signalStrength.lte.rssnr = INT_MAX;
6761 signalStrength.lte.cqi = INT_MAX;
6762 signalStrength.lte.timingAdvance = INT_MAX;
6763 signalStrength.tdScdma.rscp = INT_MAX;
6764}
6765
6766void convertRilSignalStrengthToHalV6(void *response, size_t responseLen,
6767 SignalStrength& signalStrength) {
6768 RIL_SignalStrength_v6 *rilSignalStrength = (RIL_SignalStrength_v6 *) response;
Martin Bouchetdb968d42017-09-23 05:23:52 -03006769 int gsmSignalStrength;
6770 int cdmaDbm;
6771 int evdoDbm;
6772
6773 gsmSignalStrength = rilSignalStrength->GW_SignalStrength.signalStrength & 0xFF;
6774
6775#ifdef MODEM_TYPE_XMM6260
6776 if (gsmSignalStrength < 0 ||
6777 (gsmSignalStrength > 31 && rilSignalStrength->GW_SignalStrength.signalStrength != 99)) {
6778 gsmSignalStrength = rilSignalStrength->CDMA_SignalStrength.dbm;
6779 }
6780#else
6781 if (gsmSignalStrength < 0) {
6782 gsmSignalStrength = 99;
6783 } else if (gsmSignalStrength > 31 && gsmSignalStrength != 99) {
6784 gsmSignalStrength = 31;
6785 }
6786#endif
6787
6788#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM)
6789 cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm & 0xFF;
6790 if (cdmaDbm < 0) {
6791 cdmaDbm = 99;
6792 } else if (cdmaDbm > 31 && cdmaDbm != 99) {
6793 cdmaDbm = 31;
6794 }
6795#else
6796 cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6797#endif
6798
6799#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM)
6800 evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm & 0xFF;
6801 if (evdoDbm < 0) {
6802 evdoDbm = 99;
6803 } else if (evdoDbm > 31 && evdoDbm != 99) {
6804 evdoDbm = 31;
6805 }
6806#else
6807 evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6808#endif
Martin Bouchet6e9a4972017-09-23 04:55:52 -03006809
6810 // Fixup LTE for backwards compatibility
6811 // signalStrength: -1 -> 99
6812 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6813 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6814 }
6815 // rsrp: -1 -> INT_MAX all other negative value to positive.
6816 // So remap here
6817 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6818 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6819 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6820 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6821 }
6822 // rsrq: -1 -> INT_MAX
6823 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6824 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6825 }
6826 // Not remapping rssnr is already using INT_MAX
6827 // cqi: -1 -> INT_MAX
6828 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6829 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6830 }
6831
Martin Bouchetdb968d42017-09-23 05:23:52 -03006832 signalStrength.gw.signalStrength = gsmSignalStrength;
Martin Bouchet6e9a4972017-09-23 04:55:52 -03006833 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
Martin Bouchetdb968d42017-09-23 05:23:52 -03006834 signalStrength.cdma.dbm = cdmaDbm;
Martin Bouchet6e9a4972017-09-23 04:55:52 -03006835 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
Martin Bouchetdb968d42017-09-23 05:23:52 -03006836 signalStrength.evdo.dbm = evdoDbm;
Martin Bouchet6e9a4972017-09-23 04:55:52 -03006837 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6838 signalStrength.evdo.signalNoiseRatio =
6839 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6840 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6841 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6842 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6843 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6844 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6845 signalStrength.lte.timingAdvance = INT_MAX;
6846 signalStrength.tdScdma.rscp = INT_MAX;
6847}
6848
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03006849void convertRilSignalStrengthToHalV8(void *response, size_t responseLen,
6850 SignalStrength& signalStrength) {
6851 RIL_SignalStrength_v8 *rilSignalStrength = (RIL_SignalStrength_v8 *) response;
Martin Bouchetdb968d42017-09-23 05:23:52 -03006852 int gsmSignalStrength;
6853 int cdmaDbm;
6854 int evdoDbm;
6855
6856 gsmSignalStrength = rilSignalStrength->GW_SignalStrength.signalStrength & 0xFF;
6857
6858#ifdef MODEM_TYPE_XMM6260
6859 if (gsmSignalStrength < 0 ||
6860 (gsmSignalStrength > 31 && rilSignalStrength->GW_SignalStrength.signalStrength != 99)) {
6861 gsmSignalStrength = rilSignalStrength->CDMA_SignalStrength.dbm;
6862 }
6863#else
6864 if (gsmSignalStrength < 0) {
6865 gsmSignalStrength = 99;
6866 } else if (gsmSignalStrength > 31 && gsmSignalStrength != 99) {
6867 gsmSignalStrength = 31;
6868 }
6869#endif
6870
6871#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM)
6872 cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm & 0xFF;
6873 if (cdmaDbm < 0) {
6874 cdmaDbm = 99;
6875 } else if (cdmaDbm > 31 && cdmaDbm != 99) {
6876 cdmaDbm = 31;
6877 }
6878#else
6879 cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6880#endif
6881
6882#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM)
6883 evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm & 0xFF;
6884 if (evdoDbm < 0) {
6885 evdoDbm = 99;
6886 } else if (evdoDbm > 31 && evdoDbm != 99) {
6887 evdoDbm = 31;
6888 }
6889#else
6890 evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6891#endif
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03006892
6893 // Fixup LTE for backwards compatibility
6894 // signalStrength: -1 -> 99
6895 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6896 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6897 }
6898 // rsrp: -1 -> INT_MAX all other negative value to positive.
6899 // So remap here
6900 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6901 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6902 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6903 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6904 }
6905 // rsrq: -1 -> INT_MAX
6906 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6907 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6908 }
6909 // Not remapping rssnr is already using INT_MAX
6910 // cqi: -1 -> INT_MAX
6911 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6912 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6913 }
6914
Martin Bouchetdb968d42017-09-23 05:23:52 -03006915 signalStrength.gw.signalStrength = gsmSignalStrength;
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03006916 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
Martin Bouchetdb968d42017-09-23 05:23:52 -03006917 signalStrength.cdma.dbm = cdmaDbm;
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03006918 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
Martin Bouchetdb968d42017-09-23 05:23:52 -03006919 signalStrength.evdo.dbm = evdoDbm;
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03006920 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6921 signalStrength.evdo.signalNoiseRatio =
6922 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6923 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6924 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6925 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6926 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6927 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6928 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6929 signalStrength.tdScdma.rscp = INT_MAX;
6930}
6931
6932void convertRilSignalStrengthToHalV10(void *response, size_t responseLen,
6933 SignalStrength& signalStrength) {
6934 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
Martin Bouchetdb968d42017-09-23 05:23:52 -03006935 int gsmSignalStrength;
6936 int cdmaDbm;
6937 int evdoDbm;
6938
6939 gsmSignalStrength = rilSignalStrength->GW_SignalStrength.signalStrength & 0xFF;
6940
6941#ifdef MODEM_TYPE_XMM6260
6942 if (gsmSignalStrength < 0 ||
6943 (gsmSignalStrength > 31 && rilSignalStrength->GW_SignalStrength.signalStrength != 99)) {
6944 gsmSignalStrength = rilSignalStrength->CDMA_SignalStrength.dbm;
6945 }
6946#else
6947 if (gsmSignalStrength < 0) {
6948 gsmSignalStrength = 99;
6949 } else if (gsmSignalStrength > 31 && gsmSignalStrength != 99) {
6950 gsmSignalStrength = 31;
6951 }
6952#endif
6953
6954#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM)
6955 cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm & 0xFF;
6956 if (cdmaDbm < 0) {
6957 cdmaDbm = 99;
6958 } else if (cdmaDbm > 31 && cdmaDbm != 99) {
6959 cdmaDbm = 31;
6960 }
6961#else
6962 cdmaDbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6963#endif
6964
6965#if defined(MODEM_TYPE_XMM6262) || defined(SAMSUNG_NEXT_GEN_MODEM)
6966 evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm & 0xFF;
6967 if (evdoDbm < 0) {
6968 evdoDbm = 99;
6969 } else if (evdoDbm > 31 && evdoDbm != 99) {
6970 evdoDbm = 31;
6971 }
6972#else
6973 evdoDbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6974#endif
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03006975
6976 // Fixup LTE for backwards compatibility
6977 // signalStrength: -1 -> 99
6978 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6979 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6980 }
6981 // rsrp: -1 -> INT_MAX all other negative value to positive.
6982 // So remap here
6983 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6984 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6985 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6986 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6987 }
6988 // rsrq: -1 -> INT_MAX
6989 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6990 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6991 }
6992 // Not remapping rssnr is already using INT_MAX
6993 // cqi: -1 -> INT_MAX
6994 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6995 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6996 }
6997
Martin Bouchetdb968d42017-09-23 05:23:52 -03006998 signalStrength.gw.signalStrength = gsmSignalStrength;
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03006999 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
Martin Bouchetdb968d42017-09-23 05:23:52 -03007000 signalStrength.cdma.dbm = cdmaDbm;
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03007001 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
Martin Bouchetdb968d42017-09-23 05:23:52 -03007002 signalStrength.evdo.dbm = evdoDbm;
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03007003 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
7004 signalStrength.evdo.signalNoiseRatio =
7005 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
7006 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
7007 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
7008 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
7009 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
7010 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
7011 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
7012 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
7013}
7014
7015void convertRilSignalStrengthToHal(void *response, size_t responseLen,
7016 SignalStrength& signalStrength) {
Martin Bouchet6e9a4972017-09-23 04:55:52 -03007017 if (responseLen == sizeof(RIL_SignalStrength_v5)) {
7018 convertRilSignalStrengthToHalV5(response, responseLen, signalStrength);
7019 } else if (responseLen == sizeof(RIL_SignalStrength_v6)) {
7020 convertRilSignalStrengthToHalV6(response, responseLen, signalStrength);
7021 } else if (responseLen == sizeof(RIL_SignalStrength_v8)) {
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03007022 convertRilSignalStrengthToHalV8(response, responseLen, signalStrength);
7023 } else {
7024 convertRilSignalStrengthToHalV10(response, responseLen, signalStrength);
7025 }
7026}
7027
7028int radio::currentSignalStrengthInd(int slotId,
7029 int indicationType, int token, RIL_Errno e,
7030 void *response, size_t responseLen) {
7031 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7032 if (response == NULL || (responseLen != sizeof(RIL_SignalStrength_v10)
7033 && responseLen != sizeof(RIL_SignalStrength_v8))) {
7034 RLOGE("currentSignalStrengthInd: invalid response");
7035 return 0;
7036 }
7037
7038 SignalStrength signalStrength = {};
7039 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
7040
7041#if VDBG
7042 RLOGD("currentSignalStrengthInd");
7043#endif
7044 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
7045 convertIntToRadioIndicationType(indicationType), signalStrength);
7046 radioService[slotId]->checkReturnStatus(retStatus);
7047 } else {
7048 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
7049 slotId);
7050 }
7051
7052 return 0;
7053}
7054
7055void convertRilDataCallToHal(RIL_Data_Call_Response_v6 *dcResponse,
7056 SetupDataCallResult& dcResult) {
7057 dcResult.status = (DataCallFailCause) dcResponse->status;
7058 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
7059 dcResult.cid = dcResponse->cid;
7060 dcResult.active = dcResponse->active;
7061 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
7062 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
7063 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
7064 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
Martin Bouchet00634442017-09-23 05:43:12 -03007065#if defined(MODEM_TYPE_XMM6262) || defined(MODEM_TYPE_XMM6260)
7066 dcResult.gateways = convertCharPtrToHidlString(dcResponse->addresses);
7067#else
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03007068 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
Martin Bouchet00634442017-09-23 05:43:12 -03007069#endif
Martin Bouchet0d4bbaf2017-09-23 04:54:37 -03007070 dcResult.pcscf = hidl_string();
7071 dcResult.mtu = 0;
7072}
7073
7074void convertRilDataCallToHal(RIL_Data_Call_Response_v9 *dcResponse,
7075 SetupDataCallResult& dcResult) {
7076 dcResult.status = (DataCallFailCause) dcResponse->status;
7077 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
7078 dcResult.cid = dcResponse->cid;
7079 dcResult.active = dcResponse->active;
7080 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
7081 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
7082 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
7083 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
7084 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
7085 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
7086 dcResult.mtu = 0;
7087}
7088
7089void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
7090 SetupDataCallResult& dcResult) {
7091 dcResult.status = (DataCallFailCause) dcResponse->status;
7092 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
7093 dcResult.cid = dcResponse->cid;
7094 dcResult.active = dcResponse->active;
7095 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
7096 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
7097 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
7098 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
7099 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
7100 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
7101 dcResult.mtu = dcResponse->mtu;
7102}
7103
7104void convertRilDataCallListToHal(void *response, size_t responseLen,
7105 hidl_vec<SetupDataCallResult>& dcResultList) {
7106 int num;
7107
7108 if ((responseLen % sizeof(RIL_Data_Call_Response_v11)) == 0) {
7109 num = responseLen / sizeof(RIL_Data_Call_Response_v11);
7110 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
7111 dcResultList.resize(num);
7112 for (int i = 0; i < num; i++) {
7113 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
7114 }
7115 } else if ((responseLen % sizeof(RIL_Data_Call_Response_v9)) == 0) {
7116 num = responseLen / sizeof(RIL_Data_Call_Response_v9);
7117 RIL_Data_Call_Response_v9 *dcResponse = (RIL_Data_Call_Response_v9 *) 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_v6)) == 0) {
7123 num = responseLen / sizeof(RIL_Data_Call_Response_v6);
7124 RIL_Data_Call_Response_v6 *dcResponse = (RIL_Data_Call_Response_v6 *) response;
7125 dcResultList.resize(num);
7126 for (int i = 0; i < num; i++) {
7127 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
7128 }
7129 }
7130}
7131
7132int radio::dataCallListChangedInd(int slotId,
7133 int indicationType, int token, RIL_Errno e, void *response,
7134 size_t responseLen) {
7135 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7136 if ((response == NULL && responseLen != 0)
7137 || (responseLen % sizeof(RIL_Data_Call_Response_v11) != 0
7138 && responseLen % sizeof(RIL_Data_Call_Response_v9) != 0
7139 && responseLen % sizeof(RIL_Data_Call_Response_v6) != 0)) {
7140 RLOGE("dataCallListChangedInd: invalid response");
7141 return 0;
7142 }
7143 hidl_vec<SetupDataCallResult> dcList;
7144 convertRilDataCallListToHal(response, responseLen, dcList);
7145#if VDBG
7146 RLOGD("dataCallListChangedInd");
7147#endif
7148 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
7149 convertIntToRadioIndicationType(indicationType), dcList);
7150 radioService[slotId]->checkReturnStatus(retStatus);
7151 } else {
7152 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7153 }
7154
7155 return 0;
7156}
7157
7158int radio::suppSvcNotifyInd(int slotId, int indicationType,
7159 int token, RIL_Errno e, void *response, size_t responseLen) {
7160 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7161 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
7162 RLOGE("suppSvcNotifyInd: invalid response");
7163 return 0;
7164 }
7165
7166 SuppSvcNotification suppSvc = {};
7167 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
7168 suppSvc.isMT = ssn->notificationType;
7169 suppSvc.code = ssn->code;
7170 suppSvc.index = ssn->index;
7171 suppSvc.type = ssn->type;
7172 suppSvc.number = convertCharPtrToHidlString(ssn->number);
7173
7174#if VDBG
7175 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
7176 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
7177#endif
7178 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
7179 convertIntToRadioIndicationType(indicationType), suppSvc);
7180 radioService[slotId]->checkReturnStatus(retStatus);
7181 } else {
7182 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7183 }
7184
7185 return 0;
7186}
7187
7188int radio::stkSessionEndInd(int slotId, int indicationType,
7189 int token, RIL_Errno e, void *response, size_t responseLen) {
7190 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7191#if VDBG
7192 RLOGD("stkSessionEndInd");
7193#endif
7194 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
7195 convertIntToRadioIndicationType(indicationType));
7196 radioService[slotId]->checkReturnStatus(retStatus);
7197 } else {
7198 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
7199 }
7200
7201 return 0;
7202}
7203
7204int radio::stkProactiveCommandInd(int slotId,
7205 int indicationType, int token, RIL_Errno e, void *response,
7206 size_t responseLen) {
7207 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7208 if (response == NULL || responseLen == 0) {
7209 RLOGE("stkProactiveCommandInd: invalid response");
7210 return 0;
7211 }
7212#if VDBG
7213 RLOGD("stkProactiveCommandInd");
7214#endif
7215 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
7216 convertIntToRadioIndicationType(indicationType),
7217 convertCharPtrToHidlString((char *) response));
7218 radioService[slotId]->checkReturnStatus(retStatus);
7219 } else {
7220 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
7221 }
7222
7223 return 0;
7224}
7225
7226int radio::stkEventNotifyInd(int slotId, int indicationType,
7227 int token, RIL_Errno e, void *response, size_t responseLen) {
7228 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7229 if (response == NULL || responseLen == 0) {
7230 RLOGE("stkEventNotifyInd: invalid response");
7231 return 0;
7232 }
7233#if VDBG
7234 RLOGD("stkEventNotifyInd");
7235#endif
7236 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
7237 convertIntToRadioIndicationType(indicationType),
7238 convertCharPtrToHidlString((char *) response));
7239 radioService[slotId]->checkReturnStatus(retStatus);
7240 } else {
7241 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7242 }
7243
7244 return 0;
7245}
7246
7247int radio::stkCallSetupInd(int slotId, int indicationType,
7248 int token, RIL_Errno e, void *response, size_t responseLen) {
7249 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7250 if (response == NULL || responseLen != sizeof(int)) {
7251 RLOGE("stkCallSetupInd: invalid response");
7252 return 0;
7253 }
7254 int32_t timeout = ((int32_t *) response)[0];
7255#if VDBG
7256 RLOGD("stkCallSetupInd: timeout %d", timeout);
7257#endif
7258 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
7259 convertIntToRadioIndicationType(indicationType), timeout);
7260 radioService[slotId]->checkReturnStatus(retStatus);
7261 } else {
7262 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
7263 }
7264
7265 return 0;
7266}
7267
7268int radio::simSmsStorageFullInd(int slotId,
7269 int indicationType, int token, RIL_Errno e, void *response,
7270 size_t responseLen) {
7271 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7272#if VDBG
7273 RLOGD("simSmsStorageFullInd");
7274#endif
7275 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
7276 convertIntToRadioIndicationType(indicationType));
7277 radioService[slotId]->checkReturnStatus(retStatus);
7278 } else {
7279 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
7280 }
7281
7282 return 0;
7283}
7284
7285int radio::simRefreshInd(int slotId, int indicationType,
7286 int token, RIL_Errno e, void *response, size_t responseLen) {
7287 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7288 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
7289 RLOGE("simRefreshInd: invalid response");
7290 return 0;
7291 }
7292
7293 SimRefreshResult refreshResult = {};
7294 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
7295 refreshResult.type =
7296 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
7297 refreshResult.efId = simRefreshResponse->ef_id;
7298 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
7299
7300#if VDBG
7301 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
7302#endif
7303 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
7304 convertIntToRadioIndicationType(indicationType), refreshResult);
7305 radioService[slotId]->checkReturnStatus(retStatus);
7306 } else {
7307 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
7308 }
7309
7310 return 0;
7311}
7312
7313void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
7314 CdmaSignalInfoRecord& record) {
7315 record.isPresent = signalInfoRecord->isPresent;
7316 record.signalType = signalInfoRecord->signalType;
7317 record.alertPitch = signalInfoRecord->alertPitch;
7318 record.signal = signalInfoRecord->signal;
7319}
7320
7321int radio::callRingInd(int slotId, int indicationType,
7322 int token, RIL_Errno e, void *response, size_t responseLen) {
7323 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7324 bool isGsm;
7325 CdmaSignalInfoRecord record = {};
7326 if (response == NULL || responseLen == 0) {
7327 isGsm = true;
7328 } else {
7329 isGsm = false;
7330 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
7331 RLOGE("callRingInd: invalid response");
7332 return 0;
7333 }
7334 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
7335 }
7336
7337#if VDBG
7338 RLOGD("callRingInd: isGsm %d", isGsm);
7339#endif
7340 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
7341 convertIntToRadioIndicationType(indicationType), isGsm, record);
7342 radioService[slotId]->checkReturnStatus(retStatus);
7343 } else {
7344 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7345 }
7346
7347 return 0;
7348}
7349
7350int radio::simStatusChangedInd(int slotId,
7351 int indicationType, int token, RIL_Errno e, void *response,
7352 size_t responseLen) {
7353 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7354#if VDBG
7355 RLOGD("simStatusChangedInd");
7356#endif
7357 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7358 convertIntToRadioIndicationType(indicationType));
7359 radioService[slotId]->checkReturnStatus(retStatus);
7360 } else {
7361 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7362 }
7363
7364 return 0;
7365}
7366
7367int radio::cdmaNewSmsInd(int slotId, int indicationType,
7368 int token, RIL_Errno e, void *response, size_t responseLen) {
7369 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7370 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7371 RLOGE("cdmaNewSmsInd: invalid response");
7372 return 0;
7373 }
7374
7375 CdmaSmsMessage msg = {};
7376 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7377 msg.teleserviceId = rilMsg->uTeleserviceID;
7378 msg.isServicePresent = rilMsg->bIsServicePresent;
7379 msg.serviceCategory = rilMsg->uServicecategory;
7380 msg.address.digitMode =
7381 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7382 msg.address.numberMode =
7383 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7384 msg.address.numberType =
7385 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7386 msg.address.numberPlan =
7387 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7388
7389 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7390 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7391
7392 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
7393 rilMsg->sSubAddress.subaddressType;
7394 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7395
7396 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7397 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7398
7399 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7400 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7401
7402#if VDBG
7403 RLOGD("cdmaNewSmsInd");
7404#endif
7405 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7406 convertIntToRadioIndicationType(indicationType), msg);
7407 radioService[slotId]->checkReturnStatus(retStatus);
7408 } else {
7409 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7410 }
7411
7412 return 0;
7413}
7414
7415int radio::newBroadcastSmsInd(int slotId,
7416 int indicationType, int token, RIL_Errno e, void *response,
7417 size_t responseLen) {
7418 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7419 if (response == NULL || responseLen == 0) {
7420 RLOGE("newBroadcastSmsInd: invalid response");
7421 return 0;
7422 }
7423
7424 hidl_vec<uint8_t> data;
7425 data.setToExternal((uint8_t *) response, responseLen);
7426#if VDBG
7427 RLOGD("newBroadcastSmsInd");
7428#endif
7429 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7430 convertIntToRadioIndicationType(indicationType), data);
7431 radioService[slotId]->checkReturnStatus(retStatus);
7432 } else {
7433 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7434 }
7435
7436 return 0;
7437}
7438
7439int radio::cdmaRuimSmsStorageFullInd(int slotId,
7440 int indicationType, int token, RIL_Errno e, void *response,
7441 size_t responseLen) {
7442 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7443#if VDBG
7444 RLOGD("cdmaRuimSmsStorageFullInd");
7445#endif
7446 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7447 convertIntToRadioIndicationType(indicationType));
7448 radioService[slotId]->checkReturnStatus(retStatus);
7449 } else {
7450 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7451 slotId);
7452 }
7453
7454 return 0;
7455}
7456
7457int radio::restrictedStateChangedInd(int slotId,
7458 int indicationType, int token, RIL_Errno e, void *response,
7459 size_t responseLen) {
7460 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7461 if (response == NULL || responseLen != sizeof(int)) {
7462 RLOGE("restrictedStateChangedInd: invalid response");
7463 return 0;
7464 }
7465 int32_t state = ((int32_t *) response)[0];
7466#if VDBG
7467 RLOGD("restrictedStateChangedInd: state %d", state);
7468#endif
7469 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7470 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7471 radioService[slotId]->checkReturnStatus(retStatus);
7472 } else {
7473 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7474 slotId);
7475 }
7476
7477 return 0;
7478}
7479
7480int radio::enterEmergencyCallbackModeInd(int slotId,
7481 int indicationType, int token, RIL_Errno e, void *response,
7482 size_t responseLen) {
7483 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7484#if VDBG
7485 RLOGD("enterEmergencyCallbackModeInd");
7486#endif
7487 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7488 convertIntToRadioIndicationType(indicationType));
7489 radioService[slotId]->checkReturnStatus(retStatus);
7490 } else {
7491 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7492 slotId);
7493 }
7494
7495 return 0;
7496}
7497
7498int radio::cdmaCallWaitingInd(int slotId,
7499 int indicationType, int token, RIL_Errno e, void *response,
7500 size_t responseLen) {
7501 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7502 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7503 RLOGE("cdmaCallWaitingInd: invalid response");
7504 return 0;
7505 }
7506
7507 CdmaCallWaiting callWaitingRecord = {};
7508 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7509 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7510 callWaitingRecord.numberPresentation =
7511 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7512 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7513 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7514 callWaitingRecord.signalInfoRecord);
7515 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7516 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7517
7518#if VDBG
7519 RLOGD("cdmaCallWaitingInd");
7520#endif
7521 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7522 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7523 radioService[slotId]->checkReturnStatus(retStatus);
7524 } else {
7525 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7526 }
7527
7528 return 0;
7529}
7530
7531int radio::cdmaOtaProvisionStatusInd(int slotId,
7532 int indicationType, int token, RIL_Errno e, void *response,
7533 size_t responseLen) {
7534 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7535 if (response == NULL || responseLen != sizeof(int)) {
7536 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7537 return 0;
7538 }
7539 int32_t status = ((int32_t *) response)[0];
7540#if VDBG
7541 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7542#endif
7543 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7544 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7545 radioService[slotId]->checkReturnStatus(retStatus);
7546 } else {
7547 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7548 slotId);
7549 }
7550
7551 return 0;
7552}
7553
7554int radio::cdmaInfoRecInd(int slotId,
7555 int indicationType, int token, RIL_Errno e, void *response,
7556 size_t responseLen) {
7557 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7558 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7559 RLOGE("cdmaInfoRecInd: invalid response");
7560 return 0;
7561 }
7562
7563 CdmaInformationRecords records = {};
7564 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7565
7566 char* string8 = NULL;
7567 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7568 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7569 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7570 "additional ones", recordsRil->numberOfInfoRecs,
7571 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7572 }
7573 records.infoRec.resize(num);
7574 for (int i = 0 ; i < num ; i++) {
7575 CdmaInformationRecord *record = &records.infoRec[i];
7576 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7577 record->name = (CdmaInfoRecName) infoRec->name;
7578 // All vectors should be size 0 except one which will be size 1. Set everything to
7579 // size 0 initially.
7580 record->display.resize(0);
7581 record->number.resize(0);
7582 record->signal.resize(0);
7583 record->redir.resize(0);
7584 record->lineCtrl.resize(0);
7585 record->clir.resize(0);
7586 record->audioCtrl.resize(0);
7587 switch (infoRec->name) {
7588 case RIL_CDMA_DISPLAY_INFO_REC:
7589 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7590 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7591 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7592 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7593 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7594 return 0;
7595 }
7596 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7597 if (string8 == NULL) {
7598 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7599 "responseCdmaInformationRecords");
7600 return 0;
7601 }
7602 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7603 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7604
7605 record->display.resize(1);
7606 record->display[0].alphaBuf = string8;
7607 free(string8);
7608 string8 = NULL;
7609 break;
7610 }
7611
7612 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7613 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7614 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7615 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7616 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7617 "expected not more than %d", (int) infoRec->rec.number.len,
7618 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7619 return 0;
7620 }
7621 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7622 if (string8 == NULL) {
7623 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7624 "responseCdmaInformationRecords");
7625 return 0;
7626 }
7627 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7628 string8[(int)infoRec->rec.number.len] = '\0';
7629
7630 record->number.resize(1);
7631 record->number[0].number = string8;
7632 free(string8);
7633 string8 = NULL;
7634 record->number[0].numberType = infoRec->rec.number.number_type;
7635 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7636 record->number[0].pi = infoRec->rec.number.pi;
7637 record->number[0].si = infoRec->rec.number.si;
7638 break;
7639 }
7640
7641 case RIL_CDMA_SIGNAL_INFO_REC: {
7642 record->signal.resize(1);
7643 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7644 record->signal[0].signalType = infoRec->rec.signal.signalType;
7645 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7646 record->signal[0].signal = infoRec->rec.signal.signal;
7647 break;
7648 }
7649
7650 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7651 if (infoRec->rec.redir.redirectingNumber.len >
7652 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7653 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7654 "expected not more than %d\n",
7655 (int)infoRec->rec.redir.redirectingNumber.len,
7656 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7657 return 0;
7658 }
7659 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7660 sizeof(char));
7661 if (string8 == NULL) {
7662 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7663 "responseCdmaInformationRecords");
7664 return 0;
7665 }
7666 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7667 infoRec->rec.redir.redirectingNumber.len);
7668 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7669
7670 record->redir.resize(1);
7671 record->redir[0].redirectingNumber.number = string8;
7672 free(string8);
7673 string8 = NULL;
7674 record->redir[0].redirectingNumber.numberType =
7675 infoRec->rec.redir.redirectingNumber.number_type;
7676 record->redir[0].redirectingNumber.numberPlan =
7677 infoRec->rec.redir.redirectingNumber.number_plan;
7678 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7679 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7680 record->redir[0].redirectingReason =
7681 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7682 break;
7683 }
7684
7685 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7686 record->lineCtrl.resize(1);
7687 record->lineCtrl[0].lineCtrlPolarityIncluded =
7688 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7689 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7690 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7691 record->lineCtrl[0].lineCtrlPowerDenial =
7692 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7693 break;
7694 }
7695
7696 case RIL_CDMA_T53_CLIR_INFO_REC: {
7697 record->clir.resize(1);
7698 record->clir[0].cause = infoRec->rec.clir.cause;
7699 break;
7700 }
7701
7702 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7703 record->audioCtrl.resize(1);
7704 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7705 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7706 break;
7707 }
7708
7709 case RIL_CDMA_T53_RELEASE_INFO_REC:
7710 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7711 return 0;
7712
7713 default:
7714 RLOGE("cdmaInfoRecInd: Incorrect name value");
7715 return 0;
7716 }
7717 }
7718
7719#if VDBG
7720 RLOGD("cdmaInfoRecInd");
7721#endif
7722 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7723 convertIntToRadioIndicationType(indicationType), records);
7724 radioService[slotId]->checkReturnStatus(retStatus);
7725 } else {
7726 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7727 }
7728
7729 return 0;
7730}
7731
7732int radio::indicateRingbackToneInd(int slotId,
7733 int indicationType, int token, RIL_Errno e, void *response,
7734 size_t responseLen) {
7735 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7736 if (response == NULL || responseLen != sizeof(int)) {
7737 RLOGE("indicateRingbackToneInd: invalid response");
7738 return 0;
7739 }
7740 bool start = ((int32_t *) response)[0];
7741#if VDBG
7742 RLOGD("indicateRingbackToneInd: start %d", start);
7743#endif
7744 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7745 convertIntToRadioIndicationType(indicationType), start);
7746 radioService[slotId]->checkReturnStatus(retStatus);
7747 } else {
7748 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7749 }
7750
7751 return 0;
7752}
7753
7754int radio::resendIncallMuteInd(int slotId,
7755 int indicationType, int token, RIL_Errno e, void *response,
7756 size_t responseLen) {
7757 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7758#if VDBG
7759 RLOGD("resendIncallMuteInd");
7760#endif
7761 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7762 convertIntToRadioIndicationType(indicationType));
7763 radioService[slotId]->checkReturnStatus(retStatus);
7764 } else {
7765 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7766 }
7767
7768 return 0;
7769}
7770
7771int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7772 int indicationType, int token, RIL_Errno e,
7773 void *response, size_t responseLen) {
7774 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7775 if (response == NULL || responseLen != sizeof(int)) {
7776 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7777 return 0;
7778 }
7779 int32_t cdmaSource = ((int32_t *) response)[0];
7780#if VDBG
7781 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7782#endif
7783 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7784 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7785 (CdmaSubscriptionSource) cdmaSource);
7786 radioService[slotId]->checkReturnStatus(retStatus);
7787 } else {
7788 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7789 slotId);
7790 }
7791
7792 return 0;
7793}
7794
7795int radio::cdmaPrlChangedInd(int slotId,
7796 int indicationType, int token, RIL_Errno e, void *response,
7797 size_t responseLen) {
7798 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7799 if (response == NULL || responseLen != sizeof(int)) {
7800 RLOGE("cdmaPrlChangedInd: invalid response");
7801 return 0;
7802 }
7803 int32_t version = ((int32_t *) response)[0];
7804#if VDBG
7805 RLOGD("cdmaPrlChangedInd: version %d", version);
7806#endif
7807 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7808 convertIntToRadioIndicationType(indicationType), version);
7809 radioService[slotId]->checkReturnStatus(retStatus);
7810 } else {
7811 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7812 }
7813
7814 return 0;
7815}
7816
7817int radio::exitEmergencyCallbackModeInd(int slotId,
7818 int indicationType, int token, RIL_Errno e, void *response,
7819 size_t responseLen) {
7820 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7821#if VDBG
7822 RLOGD("exitEmergencyCallbackModeInd");
7823#endif
7824 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7825 convertIntToRadioIndicationType(indicationType));
7826 radioService[slotId]->checkReturnStatus(retStatus);
7827 } else {
7828 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7829 slotId);
7830 }
7831
7832 return 0;
7833}
7834
7835int radio::rilConnectedInd(int slotId,
7836 int indicationType, int token, RIL_Errno e, void *response,
7837 size_t responseLen) {
7838 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7839 RLOGD("rilConnectedInd");
7840 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7841 convertIntToRadioIndicationType(indicationType));
7842 radioService[slotId]->checkReturnStatus(retStatus);
7843 } else {
7844 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7845 }
7846
7847 return 0;
7848}
7849
7850int radio::voiceRadioTechChangedInd(int slotId,
7851 int indicationType, int token, RIL_Errno e, void *response,
7852 size_t responseLen) {
7853 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7854 if (response == NULL || responseLen != sizeof(int)) {
7855 RLOGE("voiceRadioTechChangedInd: invalid response");
7856 return 0;
7857 }
7858 int32_t rat = ((int32_t *) response)[0];
7859#if VDBG
7860 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7861#endif
7862 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7863 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7864 radioService[slotId]->checkReturnStatus(retStatus);
7865 } else {
7866 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7867 slotId);
7868 }
7869
7870 return 0;
7871}
7872
7873void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7874 int num = responseLen / sizeof(RIL_CellInfo_v12);
7875 records.resize(num);
7876
7877 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7878 for (int i = 0; i < num; i++) {
7879 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7880 records[i].registered = rillCellInfo->registered;
7881 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7882 records[i].timeStamp = rillCellInfo->timeStamp;
7883 // All vectors should be size 0 except one which will be size 1. Set everything to
7884 // size 0 initially.
7885 records[i].gsm.resize(0);
7886 records[i].wcdma.resize(0);
7887 records[i].cdma.resize(0);
7888 records[i].lte.resize(0);
7889 records[i].tdscdma.resize(0);
7890 switch(rillCellInfo->cellInfoType) {
7891 case RIL_CELL_INFO_TYPE_GSM: {
7892 records[i].gsm.resize(1);
7893 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7894 cellInfoGsm->cellIdentityGsm.mcc =
7895 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7896 cellInfoGsm->cellIdentityGsm.mnc =
7897 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7898 cellInfoGsm->cellIdentityGsm.lac =
7899 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7900 cellInfoGsm->cellIdentityGsm.cid =
7901 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7902 cellInfoGsm->cellIdentityGsm.arfcn =
7903 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7904 cellInfoGsm->cellIdentityGsm.bsic =
7905 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7906 cellInfoGsm->signalStrengthGsm.signalStrength =
7907 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7908 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7909 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7910 cellInfoGsm->signalStrengthGsm.timingAdvance =
7911 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7912 break;
7913 }
7914
7915 case RIL_CELL_INFO_TYPE_WCDMA: {
7916 records[i].wcdma.resize(1);
7917 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7918 cellInfoWcdma->cellIdentityWcdma.mcc =
7919 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7920 cellInfoWcdma->cellIdentityWcdma.mnc =
7921 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7922 cellInfoWcdma->cellIdentityWcdma.lac =
7923 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7924 cellInfoWcdma->cellIdentityWcdma.cid =
7925 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7926 cellInfoWcdma->cellIdentityWcdma.psc =
7927 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7928 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7929 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7930 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7931 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7932 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7933 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7934 break;
7935 }
7936
7937 case RIL_CELL_INFO_TYPE_CDMA: {
7938 records[i].cdma.resize(1);
7939 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7940 cellInfoCdma->cellIdentityCdma.networkId =
7941 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7942 cellInfoCdma->cellIdentityCdma.systemId =
7943 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7944 cellInfoCdma->cellIdentityCdma.baseStationId =
7945 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7946 cellInfoCdma->cellIdentityCdma.longitude =
7947 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7948 cellInfoCdma->cellIdentityCdma.latitude =
7949 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7950 cellInfoCdma->signalStrengthCdma.dbm =
7951 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7952 cellInfoCdma->signalStrengthCdma.ecio =
7953 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7954 cellInfoCdma->signalStrengthEvdo.dbm =
7955 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7956 cellInfoCdma->signalStrengthEvdo.ecio =
7957 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7958 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7959 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7960 break;
7961 }
7962
7963 case RIL_CELL_INFO_TYPE_LTE: {
7964 records[i].lte.resize(1);
7965 CellInfoLte *cellInfoLte = &records[i].lte[0];
7966 cellInfoLte->cellIdentityLte.mcc =
7967 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7968 cellInfoLte->cellIdentityLte.mnc =
7969 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7970 cellInfoLte->cellIdentityLte.ci =
7971 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7972 cellInfoLte->cellIdentityLte.pci =
7973 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7974 cellInfoLte->cellIdentityLte.tac =
7975 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7976 cellInfoLte->cellIdentityLte.earfcn =
7977 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7978 cellInfoLte->signalStrengthLte.signalStrength =
7979 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7980 cellInfoLte->signalStrengthLte.rsrp =
7981 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7982 cellInfoLte->signalStrengthLte.rsrq =
7983 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7984 cellInfoLte->signalStrengthLte.rssnr =
7985 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7986 cellInfoLte->signalStrengthLte.cqi =
7987 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7988 cellInfoLte->signalStrengthLte.timingAdvance =
7989 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7990 break;
7991 }
7992
7993 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7994 records[i].tdscdma.resize(1);
7995 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7996 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7997 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7998 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7999 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
8000 cellInfoTdscdma->cellIdentityTdscdma.lac =
8001 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
8002 cellInfoTdscdma->cellIdentityTdscdma.cid =
8003 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
8004 cellInfoTdscdma->cellIdentityTdscdma.cpid =
8005 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
8006 cellInfoTdscdma->signalStrengthTdscdma.rscp =
8007 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
8008 break;
8009 }
8010 default: {
8011 break;
8012 }
8013 }
8014 rillCellInfo += 1;
8015 }
8016}
8017
8018int radio::cellInfoListInd(int slotId,
8019 int indicationType, int token, RIL_Errno e, void *response,
8020 size_t responseLen) {
8021 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8022 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
8023 RLOGE("cellInfoListInd: invalid response");
8024 return 0;
8025 }
8026
8027 hidl_vec<CellInfo> records;
8028 convertRilCellInfoListToHal(response, responseLen, records);
8029
8030#if VDBG
8031 RLOGD("cellInfoListInd");
8032#endif
8033 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
8034 convertIntToRadioIndicationType(indicationType), records);
8035 radioService[slotId]->checkReturnStatus(retStatus);
8036 } else {
8037 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
8038 }
8039
8040 return 0;
8041}
8042
8043int radio::imsNetworkStateChangedInd(int slotId,
8044 int indicationType, int token, RIL_Errno e, void *response,
8045 size_t responseLen) {
8046 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8047#if VDBG
8048 RLOGD("imsNetworkStateChangedInd");
8049#endif
8050 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
8051 convertIntToRadioIndicationType(indicationType));
8052 radioService[slotId]->checkReturnStatus(retStatus);
8053 } else {
8054 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
8055 slotId);
8056 }
8057
8058 return 0;
8059}
8060
8061int radio::subscriptionStatusChangedInd(int slotId,
8062 int indicationType, int token, RIL_Errno e, void *response,
8063 size_t responseLen) {
8064 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8065 if (response == NULL || responseLen != sizeof(int)) {
8066 RLOGE("subscriptionStatusChangedInd: invalid response");
8067 return 0;
8068 }
8069 bool activate = ((int32_t *) response)[0];
8070#if VDBG
8071 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
8072#endif
8073 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
8074 convertIntToRadioIndicationType(indicationType), activate);
8075 radioService[slotId]->checkReturnStatus(retStatus);
8076 } else {
8077 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
8078 slotId);
8079 }
8080
8081 return 0;
8082}
8083
8084int radio::srvccStateNotifyInd(int slotId,
8085 int indicationType, int token, RIL_Errno e, void *response,
8086 size_t responseLen) {
8087 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8088 if (response == NULL || responseLen != sizeof(int)) {
8089 RLOGE("srvccStateNotifyInd: invalid response");
8090 return 0;
8091 }
8092 int32_t state = ((int32_t *) response)[0];
8093#if VDBG
8094 RLOGD("srvccStateNotifyInd: rat %d", state);
8095#endif
8096 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
8097 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
8098 radioService[slotId]->checkReturnStatus(retStatus);
8099 } else {
8100 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
8101 }
8102
8103 return 0;
8104}
8105
8106void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
8107 hidl_vec<HardwareConfig>& records) {
8108 int num = responseLen / sizeof(RIL_HardwareConfig);
8109 records.resize(num);
8110
8111 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
8112 for (int i = 0; i < num; i++) {
8113 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
8114 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
8115 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
8116 switch (rilHardwareConfig[i].type) {
8117 case RIL_HARDWARE_CONFIG_MODEM: {
8118 records[i].modem.resize(1);
8119 records[i].sim.resize(0);
8120 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
8121 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
8122 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
8123 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
8124 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
8125 break;
8126 }
8127
8128 case RIL_HARDWARE_CONFIG_SIM: {
8129 records[i].sim.resize(1);
8130 records[i].modem.resize(0);
8131 records[i].sim[0].modemUuid =
8132 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
8133 break;
8134 }
8135 }
8136 }
8137}
8138
8139int radio::hardwareConfigChangedInd(int slotId,
8140 int indicationType, int token, RIL_Errno e, void *response,
8141 size_t responseLen) {
8142 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8143 if ((response == NULL && responseLen != 0)
8144 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
8145 RLOGE("hardwareConfigChangedInd: invalid response");
8146 return 0;
8147 }
8148
8149 hidl_vec<HardwareConfig> configs;
8150 convertRilHardwareConfigListToHal(response, responseLen, configs);
8151
8152#if VDBG
8153 RLOGD("hardwareConfigChangedInd");
8154#endif
8155 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
8156 convertIntToRadioIndicationType(indicationType), configs);
8157 radioService[slotId]->checkReturnStatus(retStatus);
8158 } else {
8159 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
8160 slotId);
8161 }
8162
8163 return 0;
8164}
8165
8166void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
8167 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
8168 rc.session = rilRadioCapability->session;
8169 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
8170 rc.raf = rilRadioCapability->rat;
8171 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
8172 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
8173}
8174
8175int radio::radioCapabilityIndicationInd(int slotId,
8176 int indicationType, int token, RIL_Errno e, void *response,
8177 size_t responseLen) {
8178 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8179 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
8180 RLOGE("radioCapabilityIndicationInd: invalid response");
8181 return 0;
8182 }
8183
8184 RadioCapability rc = {};
8185 convertRilRadioCapabilityToHal(response, responseLen, rc);
8186
8187#if VDBG
8188 RLOGD("radioCapabilityIndicationInd");
8189#endif
8190 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
8191 convertIntToRadioIndicationType(indicationType), rc);
8192 radioService[slotId]->checkReturnStatus(retStatus);
8193 } else {
8194 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
8195 slotId);
8196 }
8197
8198 return 0;
8199}
8200
8201bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
8202 if ((reqType == SS_INTERROGATION) &&
8203 (serType == SS_CFU ||
8204 serType == SS_CF_BUSY ||
8205 serType == SS_CF_NO_REPLY ||
8206 serType == SS_CF_NOT_REACHABLE ||
8207 serType == SS_CF_ALL ||
8208 serType == SS_CF_ALL_CONDITIONAL)) {
8209 return true;
8210 }
8211 return false;
8212}
8213
8214int radio::onSupplementaryServiceIndicationInd(int slotId,
8215 int indicationType, int token, RIL_Errno e,
8216 void *response, size_t responseLen) {
8217 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8218 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
8219 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
8220 return 0;
8221 }
8222
8223 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
8224 StkCcUnsolSsResult ss = {};
8225 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
8226 ss.requestType = (SsRequestType) rilSsResponse->requestType;
8227 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
8228 ss.serviceClass = rilSsResponse->serviceClass;
8229 ss.result = (RadioError) rilSsResponse->result;
8230
8231 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
8232#if VDBG
8233 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
8234 rilSsResponse->cfData.numValidIndexes);
8235#endif
8236 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
8237 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
8238 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
8239 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
8240 }
8241
8242 ss.cfData.resize(1);
8243 ss.ssInfo.resize(0);
8244
8245 /* number of call info's */
8246 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
8247
8248 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
8249 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
8250 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
8251
8252 cfInfo->status = (CallForwardInfoStatus) cf.status;
8253 cfInfo->reason = cf.reason;
8254 cfInfo->serviceClass = cf.serviceClass;
8255 cfInfo->toa = cf.toa;
8256 cfInfo->number = convertCharPtrToHidlString(cf.number);
8257 cfInfo->timeSeconds = cf.timeSeconds;
8258#if VDBG
8259 RLOGD("onSupplementaryServiceIndicationInd: "
8260 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
8261 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
8262#endif
8263 }
8264 } else {
8265 ss.ssInfo.resize(1);
8266 ss.cfData.resize(0);
8267
8268 /* each int */
8269 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
8270 for (int i = 0; i < SS_INFO_MAX; i++) {
8271#if VDBG
8272 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
8273 rilSsResponse->ssInfo[i]);
8274#endif
8275 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
8276 }
8277 }
8278
8279#if VDBG
8280 RLOGD("onSupplementaryServiceIndicationInd");
8281#endif
8282 Return<void> retStatus = radioService[slotId]->mRadioIndication->
8283 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
8284 ss);
8285 radioService[slotId]->checkReturnStatus(retStatus);
8286 } else {
8287 RLOGE("onSupplementaryServiceIndicationInd: "
8288 "radioService[%d]->mRadioIndication == NULL", slotId);
8289 }
8290
8291 return 0;
8292}
8293
8294int radio::stkCallControlAlphaNotifyInd(int slotId,
8295 int indicationType, int token, RIL_Errno e, void *response,
8296 size_t responseLen) {
8297 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8298 if (response == NULL || responseLen == 0) {
8299 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
8300 return 0;
8301 }
8302#if VDBG
8303 RLOGD("stkCallControlAlphaNotifyInd");
8304#endif
8305 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
8306 convertIntToRadioIndicationType(indicationType),
8307 convertCharPtrToHidlString((char *) response));
8308 radioService[slotId]->checkReturnStatus(retStatus);
8309 } else {
8310 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
8311 slotId);
8312 }
8313
8314 return 0;
8315}
8316
8317void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
8318 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
8319 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
8320 lce.confidenceLevel = rilLceDataInfo->confidence_level;
8321 lce.lceSuspended = rilLceDataInfo->lce_suspended;
8322}
8323
8324int radio::lceDataInd(int slotId,
8325 int indicationType, int token, RIL_Errno e, void *response,
8326 size_t responseLen) {
8327 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8328 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
8329 RLOGE("lceDataInd: invalid response");
8330 return 0;
8331 }
8332
8333 LceDataInfo lce = {};
8334 convertRilLceDataInfoToHal(response, responseLen, lce);
8335#if VDBG
8336 RLOGD("lceDataInd");
8337#endif
8338 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
8339 convertIntToRadioIndicationType(indicationType), lce);
8340 radioService[slotId]->checkReturnStatus(retStatus);
8341 } else {
8342 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8343 }
8344
8345 return 0;
8346}
8347
8348int radio::pcoDataInd(int slotId,
8349 int indicationType, int token, RIL_Errno e, void *response,
8350 size_t responseLen) {
8351 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8352 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8353 RLOGE("pcoDataInd: invalid response");
8354 return 0;
8355 }
8356
8357 PcoDataInfo pco = {};
8358 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8359 pco.cid = rilPcoData->cid;
8360 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8361 pco.pcoId = rilPcoData->pco_id;
8362 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8363
8364#if VDBG
8365 RLOGD("pcoDataInd");
8366#endif
8367 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8368 convertIntToRadioIndicationType(indicationType), pco);
8369 radioService[slotId]->checkReturnStatus(retStatus);
8370 } else {
8371 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8372 }
8373
8374 return 0;
8375}
8376
8377int radio::modemResetInd(int slotId,
8378 int indicationType, int token, RIL_Errno e, void *response,
8379 size_t responseLen) {
8380 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8381 if (response == NULL || responseLen == 0) {
8382 RLOGE("modemResetInd: invalid response");
8383 return 0;
8384 }
8385#if VDBG
8386 RLOGD("modemResetInd");
8387#endif
8388 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8389 convertIntToRadioIndicationType(indicationType),
8390 convertCharPtrToHidlString((char *) response));
8391 radioService[slotId]->checkReturnStatus(retStatus);
8392 } else {
8393 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8394 }
8395
8396 return 0;
8397}
8398
8399int radio::oemHookRawInd(int slotId,
8400 int indicationType, int token, RIL_Errno e, void *response,
8401 size_t responseLen) {
8402 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8403 if (response == NULL || responseLen == 0) {
8404 RLOGE("oemHookRawInd: invalid response");
8405 return 0;
8406 }
8407
8408 hidl_vec<uint8_t> data;
8409 data.setToExternal((uint8_t *) response, responseLen);
8410#if VDBG
8411 RLOGD("oemHookRawInd");
8412#endif
8413 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8414 convertIntToRadioIndicationType(indicationType), data);
8415 checkReturnStatus(slotId, retStatus, false);
8416 } else {
8417 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8418 }
8419
8420 return 0;
8421}
8422
8423void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8424 using namespace android::hardware;
8425 int simCount = 1;
8426 const char *serviceNames[] = {
8427 android::RIL_getServiceName()
8428 #if (SIM_COUNT >= 2)
8429 , RIL2_SERVICE_NAME
8430 #if (SIM_COUNT >= 3)
8431 , RIL3_SERVICE_NAME
8432 #if (SIM_COUNT >= 4)
8433 , RIL4_SERVICE_NAME
8434 #endif
8435 #endif
8436 #endif
8437 };
8438
8439 #if (SIM_COUNT >= 2)
8440 simCount = SIM_COUNT;
8441 #endif
8442
8443 configureRpcThreadpool(1, true /* callerWillJoin */);
8444 for (int i = 0; i < simCount; i++) {
8445 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8446 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8447 assert(ret == 0);
8448
8449 radioService[i] = new RadioImpl;
8450 radioService[i]->mSlotId = i;
8451 oemHookService[i] = new OemHookImpl;
8452 oemHookService[i]->mSlotId = i;
8453 RLOGD("registerService: starting IRadio %s", serviceNames[i]);
8454 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8455 status = oemHookService[i]->registerAsService(serviceNames[i]);
8456
8457 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8458 assert(ret == 0);
8459 }
8460
8461 s_vendorFunctions = callbacks;
8462 s_commands = commands;
8463}
8464
8465void rilc_thread_pool() {
8466 joinRpcThreadpool();
8467}
8468
8469pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8470 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8471
8472 #if (SIM_COUNT >= 2)
8473 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8474 #if (SIM_COUNT >= 3)
8475 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8476 #if (SIM_COUNT >= 4)
8477 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8478 #endif
8479 #endif
8480 #endif
8481
8482 return radioServiceRwlockPtr;
8483}