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