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