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