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