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