2 * Copyright (c) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #define LOG_TAG "RILC"
19 #include <android/hardware/radio/1.1/IRadio.h>
20 #include <android/hardware/radio/1.1/IRadioResponse.h>
21 #include <android/hardware/radio/1.1/IRadioIndication.h>
22 #include <android/hardware/radio/1.1/types.h>
24 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
26 #include <hwbinder/IPCThreadState.h>
27 #include <hwbinder/ProcessState.h>
28 #include <telephony/ril.h>
29 #include <telephony/ril_mnc.h>
30 #include <ril_service.h>
31 #include <hidl/HidlTransportSupport.h>
32 #include <utils/SystemClock.h>
35 #define INVALID_HEX_CHAR 16
37 using namespace android::hardware::radio;
38 using namespace android::hardware::radio::V1_0;
39 using namespace android::hardware::radio::deprecated::V1_0;
40 using ::android::hardware::configureRpcThreadpool;
41 using ::android::hardware::joinRpcThreadpool;
42 using ::android::hardware::Return;
43 using ::android::hardware::hidl_string;
44 using ::android::hardware::hidl_vec;
45 using ::android::hardware::hidl_array;
46 using ::android::hardware::Void;
47 using android::CommandInfo;
48 using android::RequestInfo;
49 using android::requestToString;
52 #define BOOL_TO_INT(x) (x ? 1 : 0)
53 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
54 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
56 #if defined(ANDROID_MULTI_SIM)
57 #define CALL_ONREQUEST(a, b, c, d, e) \
58 s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e)))
59 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a))
61 #define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d))
62 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
65 #ifdef OEM_HOOK_DISABLED
66 constexpr bool kOemHookEnabled = false;
68 constexpr bool kOemHookEnabled = true;
71 RIL_RadioFunctions *s_vendorFunctions = NULL;
72 static CommandInfo *s_commands;
78 sp<RadioImpl> radioService[SIM_COUNT];
79 sp<OemHookImpl> oemHookService[SIM_COUNT];
80 int64_t nitzTimeReceived[SIM_COUNT];
81 // counter used for synchronization. It is incremented every time response callbacks are updated.
82 volatile int32_t mCounterRadio[SIM_COUNT];
83 volatile int32_t mCounterOemHook[SIM_COUNT];
85 sp<RadioImpl> radioService[1];
86 sp<OemHookImpl> oemHookService[1];
87 int64_t nitzTimeReceived[1];
88 // counter used for synchronization. It is incremented every time response callbacks are updated.
89 volatile int32_t mCounterRadio[1];
90 volatile int32_t mCounterOemHook[1];
93 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
96 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
98 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
100 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
105 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
106 hidl_vec<HardwareConfig>& records);
108 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
110 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
112 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
113 SignalStrength& signalStrength);
115 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
116 SetupDataCallResult& dcResult);
118 void convertRilDataCallListToHal(void *response, size_t responseLen,
119 hidl_vec<SetupDataCallResult>& dcResultList);
121 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
123 struct RadioImpl : public V1_1::IRadio {
125 sp<IRadioResponse> mRadioResponse;
126 sp<IRadioIndication> mRadioIndication;
127 sp<V1_1::IRadioResponse> mRadioResponseV1_1;
128 sp<V1_1::IRadioIndication> mRadioIndicationV1_1;
130 Return<void> setResponseFunctions(
131 const ::android::sp<IRadioResponse>& radioResponse,
132 const ::android::sp<IRadioIndication>& radioIndication);
134 Return<void> getIccCardStatus(int32_t serial);
136 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
137 const hidl_string& aid);
139 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
140 const hidl_string& pin, const hidl_string& aid);
142 Return<void> supplyIccPin2ForApp(int32_t serial,
143 const hidl_string& pin2,
144 const hidl_string& aid);
146 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
147 const hidl_string& pin2, const hidl_string& aid);
149 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
150 const hidl_string& newPin, const hidl_string& aid);
152 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
153 const hidl_string& newPin2, const hidl_string& aid);
155 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
157 Return<void> getCurrentCalls(int32_t serial);
159 Return<void> dial(int32_t serial, const Dial& dialInfo);
161 Return<void> getImsiForApp(int32_t serial,
162 const ::android::hardware::hidl_string& aid);
164 Return<void> hangup(int32_t serial, int32_t gsmIndex);
166 Return<void> hangupWaitingOrBackground(int32_t serial);
168 Return<void> hangupForegroundResumeBackground(int32_t serial);
170 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
172 Return<void> conference(int32_t serial);
174 Return<void> rejectCall(int32_t serial);
176 Return<void> getLastCallFailCause(int32_t serial);
178 Return<void> getSignalStrength(int32_t serial);
180 Return<void> getVoiceRegistrationState(int32_t serial);
182 Return<void> getDataRegistrationState(int32_t serial);
184 Return<void> getOperator(int32_t serial);
186 Return<void> setRadioPower(int32_t serial, bool on);
188 Return<void> sendDtmf(int32_t serial,
189 const ::android::hardware::hidl_string& s);
191 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
193 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
195 Return<void> setupDataCall(int32_t serial,
196 RadioTechnology radioTechnology,
197 const DataProfileInfo& profileInfo,
202 Return<void> iccIOForApp(int32_t serial,
205 Return<void> sendUssd(int32_t serial,
206 const ::android::hardware::hidl_string& ussd);
208 Return<void> cancelPendingUssd(int32_t serial);
210 Return<void> getClir(int32_t serial);
212 Return<void> setClir(int32_t serial, int32_t status);
214 Return<void> getCallForwardStatus(int32_t serial,
215 const CallForwardInfo& callInfo);
217 Return<void> setCallForward(int32_t serial,
218 const CallForwardInfo& callInfo);
220 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
222 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
224 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
225 bool success, SmsAcknowledgeFailCause cause);
227 Return<void> acceptCall(int32_t serial);
229 Return<void> deactivateDataCall(int32_t serial,
230 int32_t cid, bool reasonRadioShutDown);
232 Return<void> getFacilityLockForApp(int32_t serial,
233 const ::android::hardware::hidl_string& facility,
234 const ::android::hardware::hidl_string& password,
235 int32_t serviceClass,
236 const ::android::hardware::hidl_string& appId);
238 Return<void> setFacilityLockForApp(int32_t serial,
239 const ::android::hardware::hidl_string& facility,
241 const ::android::hardware::hidl_string& password,
242 int32_t serviceClass,
243 const ::android::hardware::hidl_string& appId);
245 Return<void> setBarringPassword(int32_t serial,
246 const ::android::hardware::hidl_string& facility,
247 const ::android::hardware::hidl_string& oldPassword,
248 const ::android::hardware::hidl_string& newPassword);
250 Return<void> getNetworkSelectionMode(int32_t serial);
252 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
254 Return<void> setNetworkSelectionModeManual(int32_t serial,
255 const ::android::hardware::hidl_string& operatorNumeric);
257 Return<void> getAvailableNetworks(int32_t serial);
259 Return<void> startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request);
261 Return<void> stopNetworkScan(int32_t serial);
263 Return<void> startDtmf(int32_t serial,
264 const ::android::hardware::hidl_string& s);
266 Return<void> stopDtmf(int32_t serial);
268 Return<void> getBasebandVersion(int32_t serial);
270 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
272 Return<void> setMute(int32_t serial, bool enable);
274 Return<void> getMute(int32_t serial);
276 Return<void> getClip(int32_t serial);
278 Return<void> getDataCallList(int32_t serial);
280 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
282 Return<void> writeSmsToSim(int32_t serial,
283 const SmsWriteArgs& smsWriteArgs);
285 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
287 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
289 Return<void> getAvailableBandModes(int32_t serial);
291 Return<void> sendEnvelope(int32_t serial,
292 const ::android::hardware::hidl_string& command);
294 Return<void> sendTerminalResponseToSim(int32_t serial,
295 const ::android::hardware::hidl_string& commandResponse);
297 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
299 Return<void> explicitCallTransfer(int32_t serial);
301 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
303 Return<void> getPreferredNetworkType(int32_t serial);
305 Return<void> getNeighboringCids(int32_t serial);
307 Return<void> setLocationUpdates(int32_t serial, bool enable);
309 Return<void> setCdmaSubscriptionSource(int32_t serial,
310 CdmaSubscriptionSource cdmaSub);
312 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
314 Return<void> getCdmaRoamingPreference(int32_t serial);
316 Return<void> setTTYMode(int32_t serial, TtyMode mode);
318 Return<void> getTTYMode(int32_t serial);
320 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
322 Return<void> getPreferredVoicePrivacy(int32_t serial);
324 Return<void> sendCDMAFeatureCode(int32_t serial,
325 const ::android::hardware::hidl_string& featureCode);
327 Return<void> sendBurstDtmf(int32_t serial,
328 const ::android::hardware::hidl_string& dtmf,
332 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
334 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
335 const CdmaSmsAck& smsAck);
337 Return<void> getGsmBroadcastConfig(int32_t serial);
339 Return<void> setGsmBroadcastConfig(int32_t serial,
340 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
342 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
344 Return<void> getCdmaBroadcastConfig(int32_t serial);
346 Return<void> setCdmaBroadcastConfig(int32_t serial,
347 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
349 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
351 Return<void> getCDMASubscription(int32_t serial);
353 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
355 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
357 Return<void> getDeviceIdentity(int32_t serial);
359 Return<void> exitEmergencyCallbackMode(int32_t serial);
361 Return<void> getSmscAddress(int32_t serial);
363 Return<void> setSmscAddress(int32_t serial,
364 const ::android::hardware::hidl_string& smsc);
366 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
368 Return<void> reportStkServiceIsRunning(int32_t serial);
370 Return<void> getCdmaSubscriptionSource(int32_t serial);
372 Return<void> requestIsimAuthentication(int32_t serial,
373 const ::android::hardware::hidl_string& challenge);
375 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
377 const ::android::hardware::hidl_string& ackPdu);
379 Return<void> sendEnvelopeWithStatus(int32_t serial,
380 const ::android::hardware::hidl_string& contents);
382 Return<void> getVoiceRadioTechnology(int32_t serial);
384 Return<void> getCellInfoList(int32_t serial);
386 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
388 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
389 bool modemCognitive, bool isRoaming);
391 Return<void> getImsRegistrationState(int32_t serial);
393 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
395 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
397 Return<void> iccOpenLogicalChannel(int32_t serial,
398 const ::android::hardware::hidl_string& aid, int32_t p2);
400 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
402 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
404 Return<void> nvReadItem(int32_t serial, NvItem itemId);
406 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
408 Return<void> nvWriteCdmaPrl(int32_t serial,
409 const ::android::hardware::hidl_vec<uint8_t>& prl);
411 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
413 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
415 Return<void> setDataAllowed(int32_t serial, bool allow);
417 Return<void> getHardwareConfig(int32_t serial);
419 Return<void> requestIccSimAuthentication(int32_t serial,
421 const ::android::hardware::hidl_string& authData,
422 const ::android::hardware::hidl_string& aid);
424 Return<void> setDataProfile(int32_t serial,
425 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
427 Return<void> requestShutdown(int32_t serial);
429 Return<void> getRadioCapability(int32_t serial);
431 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
433 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
435 Return<void> stopLceService(int32_t serial);
437 Return<void> pullLceData(int32_t serial);
439 Return<void> getModemActivityInfo(int32_t serial);
441 Return<void> setAllowedCarriers(int32_t serial,
443 const CarrierRestrictions& carriers);
445 Return<void> getAllowedCarriers(int32_t serial);
447 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
449 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
451 Return<void> startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive);
453 Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
455 Return<void> setSimCardPower(int32_t serial, bool powerUp);
456 Return<void> setSimCardPower_1_1(int32_t serial,
457 const V1_1::CardPowerState state);
459 Return<void> responseAcknowledgement();
461 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
462 const V1_1::ImsiEncryptionInfo& message);
464 void checkReturnStatus(Return<void>& ret);
467 struct OemHookImpl : public IOemHook {
469 sp<IOemHookResponse> mOemHookResponse;
470 sp<IOemHookIndication> mOemHookIndication;
472 Return<void> setResponseFunctions(
473 const ::android::sp<IOemHookResponse>& oemHookResponse,
474 const ::android::sp<IOemHookIndication>& oemHookIndication);
476 Return<void> sendRequestRaw(int32_t serial,
477 const ::android::hardware::hidl_vec<uint8_t>& data);
479 Return<void> sendRequestStrings(int32_t serial,
480 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
483 void memsetAndFreeStrings(int numPointers, ...) {
485 va_start(ap, numPointers);
486 for (int i = 0; i < numPointers; i++) {
487 char *ptr = va_arg(ap, char *);
490 #define MAX_STRING_LENGTH 4096
491 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
499 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
500 pRI->pCI->responseFunction((int) pRI->socket_id,
501 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
505 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
506 * request with error RIL_E_NO_MEMORY. The size() method is used to determine the size of the
507 * destination buffer into which the HIDL string is copied. If there is a discrepancy between
508 * the string length reported by the size() method, and the length of the string returned by
509 * the c_str() method, the function will return false indicating a failure.
511 * Returns true on success, and false on failure.
513 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI, bool allowEmpty) {
514 size_t len = src.size();
515 if (len == 0 && !allowEmpty) {
519 *dest = (char *) calloc(len + 1, sizeof(char));
521 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
522 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
525 if (strlcpy(*dest, src.c_str(), len + 1) >= (len + 1)) {
526 RLOGE("Copy of the HIDL string has been truncated, as "
527 "the string length reported by size() does not "
528 "match the length of string returned by c_str().");
531 sendErrorResponse(pRI, RIL_E_INTERNAL_ERR);
537 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
538 return copyHidlStringToRil(dest, src, pRI, false);
541 hidl_string convertCharPtrToHidlString(const char *ptr) {
544 // TODO: replace this with strnlen
545 ret.setToExternal(ptr, strlen(ptr));
550 bool dispatchVoid(int serial, int slotId, int request) {
551 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
555 CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
559 bool dispatchString(int serial, int slotId, int request, const char * str) {
560 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
566 if (!copyHidlStringToRil(&pString, str, pRI)) {
570 CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
572 memsetAndFreeStrings(1, pString);
576 bool dispatchStrings(int serial, int slotId, int request, bool allowEmpty, int countStrings, ...) {
577 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
583 pStrings = (char **)calloc(countStrings, sizeof(char *));
584 if (pStrings == NULL) {
585 RLOGE("Memory allocation failed for request %s", requestToString(request));
586 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
590 va_start(ap, countStrings);
591 for (int i = 0; i < countStrings; i++) {
592 const char* str = va_arg(ap, const char *);
593 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI, allowEmpty)) {
595 for (int j = 0; j < i; j++) {
596 memsetAndFreeStrings(1, pStrings[j]);
604 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
606 if (pStrings != NULL) {
607 for (int i = 0 ; i < countStrings ; i++) {
608 memsetAndFreeStrings(1, pStrings[i]);
612 memset(pStrings, 0, countStrings * sizeof(char *));
619 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
620 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
625 int countStrings = data.size();
627 pStrings = (char **)calloc(countStrings, sizeof(char *));
628 if (pStrings == NULL) {
629 RLOGE("Memory allocation failed for request %s", requestToString(request));
630 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
634 for (int i = 0; i < countStrings; i++) {
635 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
636 for (int j = 0; j < i; j++) {
637 memsetAndFreeStrings(1, pStrings[j]);
644 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
646 if (pStrings != NULL) {
647 for (int i = 0 ; i < countStrings ; i++) {
648 memsetAndFreeStrings(1, pStrings[i]);
652 memset(pStrings, 0, countStrings * sizeof(char *));
659 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
660 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
665 int *pInts = (int *)calloc(countInts, sizeof(int));
668 RLOGE("Memory allocation failed for request %s", requestToString(request));
669 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
673 va_start(ap, countInts);
674 for (int i = 0; i < countInts; i++) {
675 pInts[i] = va_arg(ap, int);
679 CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
683 memset(pInts, 0, countInts * sizeof(int));
690 bool dispatchCallForwardStatus(int serial, int slotId, int request,
691 const CallForwardInfo& callInfo) {
692 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
697 RIL_CallForwardInfo cf;
698 cf.status = (int) callInfo.status;
699 cf.reason = callInfo.reason;
700 cf.serviceClass = callInfo.serviceClass;
701 cf.toa = callInfo.toa;
702 cf.timeSeconds = callInfo.timeSeconds;
704 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
708 CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
710 memsetAndFreeStrings(1, cf.number);
715 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
716 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
721 const uint8_t *uData = rawBytes.data();
723 CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
728 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
729 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
734 RIL_SIM_APDU apdu = {};
736 apdu.sessionid = message.sessionId;
737 apdu.cla = message.cla;
738 apdu.instruction = message.instruction;
739 apdu.p1 = message.p1;
740 apdu.p2 = message.p2;
741 apdu.p3 = message.p3;
743 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
747 CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
749 memsetAndFreeStrings(1, apdu.data);
754 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
755 if (ret.isOk() == false) {
756 RLOGE("checkReturnStatus: unable to call response/indication callback");
757 // Remote process hosting the callbacks must be dead. Reset the callback objects;
758 // there's no other recovery to be done here. When the client process is back up, it will
759 // call setResponseFunctions()
761 // Caller should already hold rdlock, release that first
762 // note the current counter to avoid overwriting updates made by another thread before
763 // write lock is acquired.
764 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
765 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
766 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
770 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
773 // make sure the counter value has not changed
774 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
775 if (isRadioService) {
776 radioService[slotId]->mRadioResponse = NULL;
777 radioService[slotId]->mRadioIndication = NULL;
778 radioService[slotId]->mRadioResponseV1_1 = NULL;
779 radioService[slotId]->mRadioIndicationV1_1 = NULL;
781 oemHookService[slotId]->mOemHookResponse = NULL;
782 oemHookService[slotId]->mOemHookIndication = NULL;
784 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
786 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
787 "got updated on another thread");
791 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
795 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
800 void RadioImpl::checkReturnStatus(Return<void>& ret) {
801 ::checkReturnStatus(mSlotId, ret, true);
804 Return<void> RadioImpl::setResponseFunctions(
805 const ::android::sp<IRadioResponse>& radioResponseParam,
806 const ::android::sp<IRadioIndication>& radioIndicationParam) {
807 RLOGD("setResponseFunctions");
809 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
810 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
813 mRadioResponse = radioResponseParam;
814 mRadioIndication = radioIndicationParam;
815 mRadioResponseV1_1 = V1_1::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
816 mRadioIndicationV1_1 = V1_1::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
817 if (mRadioResponseV1_1 == nullptr || mRadioIndicationV1_1 == nullptr) {
818 mRadioResponseV1_1 = nullptr;
819 mRadioIndicationV1_1 = nullptr;
822 mCounterRadio[mSlotId]++;
824 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
827 // client is connected. Send initial indications.
828 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
833 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
835 RLOGD("getIccCardStatus: serial %d", serial);
837 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
841 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
842 const hidl_string& aid) {
844 RLOGD("supplyIccPinForApp: serial %d", serial);
846 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN, true,
847 2, pin.c_str(), aid.c_str());
851 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
852 const hidl_string& pin, const hidl_string& aid) {
854 RLOGD("supplyIccPukForApp: serial %d", serial);
856 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK, true,
857 3, puk.c_str(), pin.c_str(), aid.c_str());
861 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
862 const hidl_string& aid) {
864 RLOGD("supplyIccPin2ForApp: serial %d", serial);
866 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2, true,
867 2, pin2.c_str(), aid.c_str());
871 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
872 const hidl_string& pin2, const hidl_string& aid) {
874 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
876 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2, true,
877 3, puk2.c_str(), pin2.c_str(), aid.c_str());
881 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
882 const hidl_string& newPin, const hidl_string& aid) {
884 RLOGD("changeIccPinForApp: serial %d", serial);
886 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN, true,
887 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
891 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
892 const hidl_string& newPin2, const hidl_string& aid) {
894 RLOGD("changeIccPin2ForApp: serial %d", serial);
896 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2, true,
897 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
901 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
902 const hidl_string& netPin) {
904 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
906 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, true,
911 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
913 RLOGD("getCurrentCalls: serial %d", serial);
915 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
919 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
921 RLOGD("dial: serial %d", serial);
923 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
928 RIL_UUS_Info uusInfo = {};
929 int32_t sizeOfDial = sizeof(dial);
931 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
934 dial.clir = (int) dialInfo.clir;
936 if (dialInfo.uusInfo.size() != 0) {
937 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
938 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
940 if (dialInfo.uusInfo[0].uusData.size() == 0) {
941 uusInfo.uusData = NULL;
942 uusInfo.uusLength = 0;
944 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
945 memsetAndFreeStrings(1, dial.address);
948 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
951 dial.uusInfo = &uusInfo;
954 CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
956 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
961 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
963 RLOGD("getImsiForApp: serial %d", serial);
965 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI, false,
970 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
972 RLOGD("hangup: serial %d", serial);
974 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
978 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
980 RLOGD("hangupWaitingOrBackground: serial %d", serial);
982 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
986 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
988 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
990 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
994 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
996 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
998 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
1002 Return<void> RadioImpl::conference(int32_t serial) {
1004 RLOGD("conference: serial %d", serial);
1006 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
1010 Return<void> RadioImpl::rejectCall(int32_t serial) {
1012 RLOGD("rejectCall: serial %d", serial);
1014 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
1018 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
1020 RLOGD("getLastCallFailCause: serial %d", serial);
1022 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
1026 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
1028 RLOGD("getSignalStrength: serial %d", serial);
1030 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
1034 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
1036 RLOGD("getVoiceRegistrationState: serial %d", serial);
1038 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
1042 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
1044 RLOGD("getDataRegistrationState: serial %d", serial);
1046 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1050 Return<void> RadioImpl::getOperator(int32_t serial) {
1052 RLOGD("getOperator: serial %d", serial);
1054 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1058 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
1059 RLOGD("setRadioPower: serial %d on %d", serial, on);
1060 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1064 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1066 RLOGD("sendDtmf: serial %d", serial);
1068 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1072 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1074 RLOGD("sendSms: serial %d", serial);
1076 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, false,
1077 2, message.smscPdu.c_str(), message.pdu.c_str());
1081 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1083 RLOGD("sendSMSExpectMore: serial %d", serial);
1085 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, false,
1086 2, message.smscPdu.c_str(), message.pdu.c_str());
1090 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1092 case MvnoType::IMSI:
1093 str = (char *)"imsi";
1096 str = (char *)"gid";
1099 str = (char *)"spn";
1101 case MvnoType::NONE:
1108 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1109 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1110 bool roamingAllowed, bool isRoaming) {
1113 RLOGD("setupDataCall: serial %d", serial);
1116 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1117 const hidl_string &protocol =
1118 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1119 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 7,
1120 std::to_string((int) radioTechnology + 2).c_str(),
1121 std::to_string((int) dataProfileInfo.profileId).c_str(),
1122 dataProfileInfo.apn.c_str(),
1123 dataProfileInfo.user.c_str(),
1124 dataProfileInfo.password.c_str(),
1125 std::to_string((int) dataProfileInfo.authType).c_str(),
1127 } else if (s_vendorFunctions->version >= 15) {
1128 char *mvnoTypeStr = NULL;
1129 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1130 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1131 RIL_REQUEST_SETUP_DATA_CALL);
1133 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1137 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
1138 std::to_string((int) radioTechnology + 2).c_str(),
1139 std::to_string((int) dataProfileInfo.profileId).c_str(),
1140 dataProfileInfo.apn.c_str(),
1141 dataProfileInfo.user.c_str(),
1142 dataProfileInfo.password.c_str(),
1143 std::to_string((int) dataProfileInfo.authType).c_str(),
1144 dataProfileInfo.protocol.c_str(),
1145 dataProfileInfo.roamingProtocol.c_str(),
1146 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1147 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1148 modemCognitive ? "1" : "0",
1149 std::to_string(dataProfileInfo.mtu).c_str(),
1151 dataProfileInfo.mvnoMatchData.c_str(),
1152 roamingAllowed ? "1" : "0");
1154 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1155 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1156 RIL_REQUEST_SETUP_DATA_CALL);
1158 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1164 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1166 RLOGD("iccIOForApp: serial %d", serial);
1168 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1173 RIL_SIM_IO_v6 rilIccIo = {};
1174 rilIccIo.command = iccIo.command;
1175 rilIccIo.fileid = iccIo.fileId;
1176 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1180 rilIccIo.p1 = iccIo.p1;
1181 rilIccIo.p2 = iccIo.p2;
1182 rilIccIo.p3 = iccIo.p3;
1184 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1185 memsetAndFreeStrings(1, rilIccIo.path);
1189 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1190 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1194 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1195 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1199 CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1201 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1206 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1208 RLOGD("sendUssd: serial %d", serial);
1210 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1214 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1216 RLOGD("cancelPendingUssd: serial %d", serial);
1218 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1222 Return<void> RadioImpl::getClir(int32_t serial) {
1224 RLOGD("getClir: serial %d", serial);
1226 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1230 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1232 RLOGD("setClir: serial %d", serial);
1234 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1238 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1240 RLOGD("getCallForwardStatus: serial %d", serial);
1242 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1247 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1249 RLOGD("setCallForward: serial %d", serial);
1251 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1256 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1258 RLOGD("getCallWaiting: serial %d", serial);
1260 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1264 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1266 RLOGD("setCallWaiting: serial %d", serial);
1268 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1273 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1274 bool success, SmsAcknowledgeFailCause cause) {
1276 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1278 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1283 Return<void> RadioImpl::acceptCall(int32_t serial) {
1285 RLOGD("acceptCall: serial %d", serial);
1287 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1291 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1292 int32_t cid, bool reasonRadioShutDown) {
1294 RLOGD("deactivateDataCall: serial %d", serial);
1296 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, false,
1297 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1301 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1302 const hidl_string& password, int32_t serviceClass,
1303 const hidl_string& appId) {
1305 RLOGD("getFacilityLockForApp: serial %d", serial);
1307 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK, true,
1308 4, facility.c_str(), password.c_str(),
1309 (std::to_string(serviceClass)).c_str(), appId.c_str());
1313 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1314 bool lockState, const hidl_string& password,
1315 int32_t serviceClass, const hidl_string& appId) {
1317 RLOGD("setFacilityLockForApp: serial %d", serial);
1319 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK, true,
1320 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1321 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1325 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1326 const hidl_string& oldPassword,
1327 const hidl_string& newPassword) {
1329 RLOGD("setBarringPassword: serial %d", serial);
1331 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD, true,
1332 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1336 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1338 RLOGD("getNetworkSelectionMode: serial %d", serial);
1340 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1344 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1346 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1348 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1352 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1353 const hidl_string& operatorNumeric) {
1355 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1357 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1358 operatorNumeric.c_str());
1362 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1364 RLOGD("getAvailableNetworks: serial %d", serial);
1366 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1370 Return<void> RadioImpl::startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request) {
1372 RLOGD("startNetworkScan: serial %d", serial);
1375 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1380 if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
1381 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1385 RIL_NetworkScanRequest scan_request = {};
1387 scan_request.type = (RIL_ScanType) request.type;
1388 scan_request.interval = request.interval;
1389 scan_request.specifiers_length = request.specifiers.size();
1390 for (size_t i = 0; i < request.specifiers.size(); ++i) {
1391 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
1392 request.specifiers[i].utranBands.size() > MAX_BANDS ||
1393 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
1394 request.specifiers[i].channels.size() > MAX_CHANNELS) {
1395 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1398 const V1_1::RadioAccessSpecifier& ras_from =
1399 request.specifiers[i];
1400 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
1402 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
1403 ras_to.channels_length = ras_from.channels.size();
1405 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
1406 const std::vector<uint32_t> * bands = nullptr;
1407 switch (request.specifiers[i].radioAccessNetwork) {
1408 case V1_1::RadioAccessNetworks::GERAN:
1409 ras_to.bands_length = ras_from.geranBands.size();
1410 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
1412 case V1_1::RadioAccessNetworks::UTRAN:
1413 ras_to.bands_length = ras_from.utranBands.size();
1414 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
1416 case V1_1::RadioAccessNetworks::EUTRAN:
1417 ras_to.bands_length = ras_from.eutranBands.size();
1418 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
1421 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1424 // safe to copy to geran_bands because it's a union member
1425 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
1426 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
1430 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
1436 Return<void> RadioImpl::stopNetworkScan(int32_t serial) {
1438 RLOGD("stopNetworkScan: serial %d", serial);
1440 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1444 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1446 RLOGD("startDtmf: serial %d", serial);
1448 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1453 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1455 RLOGD("stopDtmf: serial %d", serial);
1457 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1461 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1463 RLOGD("getBasebandVersion: serial %d", serial);
1465 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1469 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1471 RLOGD("separateConnection: serial %d", serial);
1473 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1477 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1479 RLOGD("setMute: serial %d", serial);
1481 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1485 Return<void> RadioImpl::getMute(int32_t serial) {
1487 RLOGD("getMute: serial %d", serial);
1489 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1493 Return<void> RadioImpl::getClip(int32_t serial) {
1495 RLOGD("getClip: serial %d", serial);
1497 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1501 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1503 RLOGD("getDataCallList: serial %d", serial);
1505 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1509 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1511 RLOGD("setSuppServiceNotifications: serial %d", serial);
1513 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1514 BOOL_TO_INT(enable));
1518 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1520 RLOGD("writeSmsToSim: serial %d", serial);
1522 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1527 RIL_SMS_WriteArgs args;
1528 args.status = (int) smsWriteArgs.status;
1530 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1534 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1535 memsetAndFreeStrings(1, args.pdu);
1539 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
1541 memsetAndFreeStrings(2, args.smsc, args.pdu);
1546 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1548 RLOGD("deleteSmsOnSim: serial %d", serial);
1550 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1554 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1556 RLOGD("setBandMode: serial %d", serial);
1558 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1562 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1564 RLOGD("getAvailableBandModes: serial %d", serial);
1566 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1570 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1572 RLOGD("sendEnvelope: serial %d", serial);
1574 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1579 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1580 const hidl_string& commandResponse) {
1582 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1584 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1585 commandResponse.c_str());
1589 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1591 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1593 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1594 1, BOOL_TO_INT(accept));
1598 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1600 RLOGD("explicitCallTransfer: serial %d", serial);
1602 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1606 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1608 RLOGD("setPreferredNetworkType: serial %d", serial);
1610 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1614 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1616 RLOGD("getPreferredNetworkType: serial %d", serial);
1618 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1622 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1624 RLOGD("getNeighboringCids: serial %d", serial);
1626 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1630 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1632 RLOGD("setLocationUpdates: serial %d", serial);
1634 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1638 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1640 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1642 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1646 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1648 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1650 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1654 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1656 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1658 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1662 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1664 RLOGD("setTTYMode: serial %d", serial);
1666 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1670 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1672 RLOGD("getTTYMode: serial %d", serial);
1674 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1678 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1680 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1682 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1683 1, BOOL_TO_INT(enable));
1687 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1689 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1691 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1695 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1697 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1699 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1700 featureCode.c_str());
1704 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1707 RLOGD("sendBurstDtmf: serial %d", serial);
1709 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF, false,
1710 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1711 (std::to_string(off)).c_str());
1715 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1716 rcsm.uTeleserviceID = sms.teleserviceId;
1717 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1718 rcsm.uServicecategory = sms.serviceCategory;
1719 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1720 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1721 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1722 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1724 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1725 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1726 for (int i = 0; i < digitLimit; i++) {
1727 rcsm.sAddress.digits[i] = sms.address.digits[i];
1730 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1731 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1733 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1734 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1735 for (int i = 0; i < digitLimit; i++) {
1736 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1739 rcsm.uBearerDataLen = sms.bearerData.size();
1740 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1741 for (int i = 0; i < digitLimit; i++) {
1742 rcsm.aBearerData[i] = sms.bearerData[i];
1746 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1748 RLOGD("sendCdmaSms: serial %d", serial);
1750 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1755 RIL_CDMA_SMS_Message rcsm = {};
1756 constructCdmaSms(rcsm, sms);
1758 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
1762 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1764 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1766 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1771 RIL_CDMA_SMS_Ack rcsa = {};
1773 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1774 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1776 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
1780 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1782 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1784 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1788 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1789 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1792 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1794 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1795 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1800 int num = configInfo.size();
1801 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1802 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1804 for (int i = 0 ; i < num ; i++ ) {
1805 gsmBciPtrs[i] = &gsmBci[i];
1806 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1807 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1808 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1809 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1810 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1813 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs,
1814 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
1818 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1820 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1822 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1823 1, BOOL_TO_INT(!activate));
1827 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1829 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1831 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1835 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1836 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1839 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1841 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1842 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1847 int num = configInfo.size();
1848 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1849 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1851 for (int i = 0 ; i < num ; i++ ) {
1852 cdmaBciPtrs[i] = &cdmaBci[i];
1853 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1854 cdmaBci[i].language = configInfo[i].language;
1855 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1858 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs,
1859 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
1863 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1865 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1867 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1868 1, BOOL_TO_INT(!activate));
1872 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1874 RLOGD("getCDMASubscription: serial %d", serial);
1876 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1880 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1882 RLOGD("writeSmsToRuim: serial %d", serial);
1884 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1885 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1890 RIL_CDMA_SMS_WriteArgs rcsw = {};
1891 rcsw.status = (int) cdmaSms.status;
1892 constructCdmaSms(rcsw.message, cdmaSms.message);
1894 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
1898 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1900 RLOGD("deleteSmsOnRuim: serial %d", serial);
1902 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1906 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1908 RLOGD("getDeviceIdentity: serial %d", serial);
1910 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1914 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1916 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1918 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1922 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1924 RLOGD("getSmscAddress: serial %d", serial);
1926 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1930 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1932 RLOGD("setSmscAddress: serial %d", serial);
1934 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1939 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1941 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1943 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1944 BOOL_TO_INT(available));
1948 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1950 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1952 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1956 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1958 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1960 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1964 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1966 RLOGD("requestIsimAuthentication: serial %d", serial);
1968 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1973 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1974 const hidl_string& ackPdu) {
1976 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1978 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, false,
1979 2, success ? "1" : "0", ackPdu.c_str());
1983 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1985 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1987 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1992 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1994 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1996 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
2000 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
2002 RLOGD("getCellInfoList: serial %d", serial);
2004 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
2008 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
2010 RLOGD("setCellInfoListRate: serial %d", serial);
2012 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
2016 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
2017 bool modemCognitive, bool isRoaming) {
2019 RLOGD("setInitialAttachApn: serial %d", serial);
2021 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2022 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
2027 if (s_vendorFunctions->version <= 14) {
2028 RIL_InitialAttachApn iaa = {};
2030 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2034 const hidl_string &protocol =
2035 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
2037 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
2038 memsetAndFreeStrings(1, iaa.apn);
2041 iaa.authtype = (int) dataProfileInfo.authType;
2042 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2043 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2046 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2047 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
2051 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2053 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
2055 RIL_InitialAttachApn_v15 iaa = {};
2057 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2061 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
2062 memsetAndFreeStrings(1, iaa.apn);
2065 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
2066 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2069 iaa.authtype = (int) dataProfileInfo.authType;
2070 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2071 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
2074 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2075 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
2078 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
2079 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
2080 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
2081 iaa.mtu = dataProfileInfo.mtu;
2083 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
2084 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2085 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2090 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
2091 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2096 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2098 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2099 iaa.password, iaa.mvnoMatchData);
2105 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
2107 RLOGD("getImsRegistrationState: serial %d", serial);
2109 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2113 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2114 RIL_IMS_SMS_Message rism = {};
2116 int countStrings = 2;
2117 int dataLen = sizeof(char *) * countStrings;
2119 rism.tech = RADIO_TECH_3GPP;
2120 rism.retry = BOOL_TO_INT(message.retry);
2121 rism.messageRef = message.messageRef;
2123 if (message.gsmMessage.size() != 1) {
2124 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2125 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2129 pStrings = (char **)calloc(countStrings, sizeof(char *));
2130 if (pStrings == NULL) {
2131 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2132 requestToString(pRI->pCI->requestNumber));
2133 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2137 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2139 memset(pStrings, 0, dataLen);
2145 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2146 memsetAndFreeStrings(1, pStrings[0]);
2148 memset(pStrings, 0, dataLen);
2154 rism.message.gsmMessage = pStrings;
2155 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2156 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2158 for (int i = 0 ; i < countStrings ; i++) {
2159 memsetAndFreeStrings(1, pStrings[i]);
2163 memset(pStrings, 0, dataLen);
2171 RIL_IMS_SMS_Message imsSms;
2172 RIL_CDMA_SMS_Message cdmaSms;
2175 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2176 ImsCdmaSms temp = {};
2178 if (message.cdmaMessage.size() != 1) {
2179 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2180 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2184 temp.imsSms.tech = RADIO_TECH_3GPP2;
2185 temp.imsSms.retry = BOOL_TO_INT(message.retry);
2186 temp.imsSms.messageRef = message.messageRef;
2187 temp.imsSms.message.cdmaMessage = &temp.cdmaSms;
2189 constructCdmaSms(temp.cdmaSms, message.cdmaMessage[0]);
2191 // Vendor code expects payload length to include actual msg payload
2192 // (sizeof(RIL_CDMA_SMS_Message)) instead of (RIL_CDMA_SMS_Message *) + size of other fields in
2193 // RIL_IMS_SMS_Message
2194 int payloadLen = sizeof(RIL_RadioTechnologyFamily) + sizeof(uint8_t) + sizeof(int32_t)
2195 + sizeof(RIL_CDMA_SMS_Message);
2197 CALL_ONREQUEST(pRI->pCI->requestNumber, &temp.imsSms, payloadLen, pRI, pRI->socket_id);
2202 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2204 RLOGD("sendImsSms: serial %d", serial);
2206 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2211 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2213 if (RADIO_TECH_3GPP == format) {
2214 dispatchImsGsmSms(message, pRI);
2215 } else if (RADIO_TECH_3GPP2 == format) {
2216 dispatchImsCdmaSms(message, pRI);
2218 RLOGE("sendImsSms: Invalid radio tech %s",
2219 requestToString(pRI->pCI->requestNumber));
2220 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2225 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2227 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2229 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2233 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2235 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2237 if (s_vendorFunctions->version < 15) {
2238 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2240 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2245 RIL_OpenChannelParams params = {};
2249 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2253 CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId);
2255 memsetAndFreeStrings(1, params.aidPtr);
2260 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2262 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2264 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2268 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2270 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2272 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2276 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2278 RLOGD("nvReadItem: serial %d", serial);
2280 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2285 RIL_NV_ReadItem nvri = {};
2286 nvri.itemID = (RIL_NV_Item) itemId;
2288 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2292 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2294 RLOGD("nvWriteItem: serial %d", serial);
2296 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2301 RIL_NV_WriteItem nvwi = {};
2303 nvwi.itemID = (RIL_NV_Item) item.itemId;
2305 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2309 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2311 memsetAndFreeStrings(1, nvwi.value);
2315 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2317 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2319 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2323 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2324 int rilResetType = -1;
2326 RLOGD("nvResetConfig: serial %d", serial);
2328 /* Convert ResetNvType to RIL.h values
2329 * RIL_REQUEST_NV_RESET_CONFIG
2330 * 1 - reload all NV items
2331 * 2 - erase NV reset (SCRTN)
2332 * 3 - factory reset (RTN)
2335 case ResetNvType::RELOAD:
2338 case ResetNvType::ERASE:
2341 case ResetNvType::FACTORY_RESET:
2345 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2349 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2351 RLOGD("setUiccSubscription: serial %d", serial);
2353 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2354 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2359 RIL_SelectUiccSub rilUiccSub = {};
2361 rilUiccSub.slot = uiccSub.slot;
2362 rilUiccSub.app_index = uiccSub.appIndex;
2363 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2364 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2366 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2370 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2372 RLOGD("setDataAllowed: serial %d", serial);
2374 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2378 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2380 RLOGD("getHardwareConfig: serial %d", serial);
2382 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2386 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2387 const hidl_string& authData, const hidl_string& aid) {
2389 RLOGD("requestIccSimAuthentication: serial %d", serial);
2391 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2396 RIL_SimAuthentication pf = {};
2398 pf.authContext = authContext;
2400 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2404 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2405 memsetAndFreeStrings(1, pf.authData);
2409 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2411 memsetAndFreeStrings(2, pf.authData, pf.aid);
2416 * @param numProfiles number of data profile
2417 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2418 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2419 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2420 * @param numfields number of string-type member in the data profile structure
2421 * @param ... the variadic parameters are pointers to each string-type member
2423 template <typename T>
2424 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2425 int numfields, ...) {
2427 va_start(args, numfields);
2429 // Iterate through each string-type field that need to be free.
2430 for (int i = 0; i < numfields; i++) {
2431 // Iterate through each data profile and free that specific string-type field.
2432 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2433 char *T::*ptr = va_arg(args, char *T::*);
2434 for (int j = 0; j < numProfiles; j++) {
2435 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2442 memset(dataProfiles, 0, numProfiles * sizeof(T));
2443 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2446 free(dataProfilePtrs);
2449 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2452 RLOGD("setDataProfile: serial %d", serial);
2454 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2459 size_t num = profiles.size();
2460 bool success = false;
2462 if (s_vendorFunctions->version <= 14) {
2464 RIL_DataProfileInfo *dataProfiles =
2465 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2467 if (dataProfiles == NULL) {
2468 RLOGE("Memory allocation failed for request %s",
2469 requestToString(pRI->pCI->requestNumber));
2470 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2474 RIL_DataProfileInfo **dataProfilePtrs =
2475 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2476 if (dataProfilePtrs == NULL) {
2477 RLOGE("Memory allocation failed for request %s",
2478 requestToString(pRI->pCI->requestNumber));
2480 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2484 for (size_t i = 0; i < num; i++) {
2485 dataProfilePtrs[i] = &dataProfiles[i];
2487 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2489 const hidl_string &protocol =
2490 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2492 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI, true)) {
2496 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2500 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2506 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2507 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2508 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2512 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2513 dataProfiles[i].authType = (int) profiles[i].authType;
2514 dataProfiles[i].type = (int) profiles[i].type;
2515 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2516 dataProfiles[i].maxConns = profiles[i].maxConns;
2517 dataProfiles[i].waitTime = profiles[i].waitTime;
2518 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2521 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2522 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2524 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2525 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2526 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2528 RIL_DataProfileInfo_v15 *dataProfiles =
2529 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2531 if (dataProfiles == NULL) {
2532 RLOGE("Memory allocation failed for request %s",
2533 requestToString(pRI->pCI->requestNumber));
2534 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2538 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2539 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2540 if (dataProfilePtrs == NULL) {
2541 RLOGE("Memory allocation failed for request %s",
2542 requestToString(pRI->pCI->requestNumber));
2544 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2548 for (size_t i = 0; i < num; i++) {
2549 dataProfilePtrs[i] = &dataProfiles[i];
2551 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2552 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2556 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2557 profiles[i].roamingProtocol, pRI, true)) {
2560 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2564 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2568 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2569 profiles[i].mvnoMatchData, pRI, true)) {
2573 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2574 dataProfiles[i].mvnoType)) {
2575 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2580 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2581 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2582 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2583 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2587 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2588 dataProfiles[i].authType = (int) profiles[i].authType;
2589 dataProfiles[i].type = (int) profiles[i].type;
2590 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2591 dataProfiles[i].maxConns = profiles[i].maxConns;
2592 dataProfiles[i].waitTime = profiles[i].waitTime;
2593 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2594 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2595 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2596 dataProfiles[i].mtu = profiles[i].mtu;
2599 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2600 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
2602 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2603 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2604 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2605 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2611 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2613 RLOGD("requestShutdown: serial %d", serial);
2615 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2619 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2621 RLOGD("getRadioCapability: serial %d", serial);
2623 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2627 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2629 RLOGD("setRadioCapability: serial %d", serial);
2631 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2636 RIL_RadioCapability rilRc = {};
2638 // TODO : set rilRc.version using HIDL version ?
2639 rilRc.session = rc.session;
2640 rilRc.phase = (int) rc.phase;
2641 rilRc.rat = (int) rc.raf;
2642 rilRc.status = (int) rc.status;
2643 strlcpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), sizeof(rilRc.logicalModemUuid));
2645 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
2650 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2652 RLOGD("startLceService: serial %d", serial);
2654 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2655 BOOL_TO_INT(pullMode));
2659 Return<void> RadioImpl::stopLceService(int32_t serial) {
2661 RLOGD("stopLceService: serial %d", serial);
2663 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2667 Return<void> RadioImpl::pullLceData(int32_t serial) {
2669 RLOGD("pullLceData: serial %d", serial);
2671 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2675 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2677 RLOGD("getModemActivityInfo: serial %d", serial);
2679 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2683 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2684 const CarrierRestrictions& carriers) {
2686 RLOGD("setAllowedCarriers: serial %d", serial);
2688 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2689 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2694 RIL_CarrierRestrictions cr = {};
2695 RIL_Carrier *allowedCarriers = NULL;
2696 RIL_Carrier *excludedCarriers = NULL;
2698 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2699 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2700 if (allowedCarriers == NULL) {
2701 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2702 requestToString(pRI->pCI->requestNumber));
2703 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2706 cr.allowed_carriers = allowedCarriers;
2708 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2709 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2710 if (excludedCarriers == NULL) {
2711 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2712 requestToString(pRI->pCI->requestNumber));
2713 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2715 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2717 free(allowedCarriers);
2720 cr.excluded_carriers = excludedCarriers;
2722 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2723 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2724 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2725 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2726 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2729 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2730 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2731 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2732 excludedCarriers[i].match_type =
2733 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2734 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2737 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
2740 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2741 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2743 free(allowedCarriers);
2744 free(excludedCarriers);
2748 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2750 RLOGD("getAllowedCarriers: serial %d", serial);
2752 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2756 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2759 RLOGD("sendDeviceState: serial %d", serial);
2761 if (s_vendorFunctions->version < 15) {
2762 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2763 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2764 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2766 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2767 RIL_REQUEST_SEND_DEVICE_STATE);
2768 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2772 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2773 BOOL_TO_INT(state));
2777 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2779 RLOGD("setIndicationFilter: serial %d", serial);
2781 if (s_vendorFunctions->version < 15) {
2782 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2783 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2784 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2787 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2791 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2793 RLOGD("setSimCardPower: serial %d", serial);
2795 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2799 Return<void> RadioImpl::setSimCardPower_1_1(int32_t serial, const V1_1::CardPowerState state) {
2801 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
2803 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
2807 Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial,
2808 const V1_1::ImsiEncryptionInfo& data) {
2810 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
2812 RequestInfo *pRI = android::addRequestToList(
2813 serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
2818 RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
2820 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
2823 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
2824 memsetAndFreeStrings(1, imsiEncryption.mnc);
2827 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
2828 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
2831 imsiEncryption.carrierKeyLength = data.carrierKey.size();
2832 imsiEncryption.carrierKey = new uint8_t[imsiEncryption.carrierKeyLength];
2833 memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), imsiEncryption.carrierKeyLength);
2834 imsiEncryption.expirationTime = data.expirationTime;
2835 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
2836 sizeof(RIL_CarrierInfoForImsiEncryption), pRI, mSlotId);
2837 delete(imsiEncryption.carrierKey);
2841 Return<void> RadioImpl::startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive) {
2843 RLOGD("%s(): %d", __FUNCTION__, serial);
2845 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_KEEPALIVE);
2850 RIL_KeepaliveRequest kaReq = {};
2852 kaReq.type = static_cast<RIL_KeepaliveType>(keepalive.type);
2853 switch(kaReq.type) {
2855 if (keepalive.sourceAddress.size() != 4 ||
2856 keepalive.destinationAddress.size() != 4) {
2857 RLOGE("Invalid address for keepalive!");
2858 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2863 if (keepalive.sourceAddress.size() != 16 ||
2864 keepalive.destinationAddress.size() != 16) {
2865 RLOGE("Invalid address for keepalive!");
2866 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2871 RLOGE("Unknown packet keepalive type!");
2872 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2876 ::memcpy(kaReq.sourceAddress, keepalive.sourceAddress.data(), keepalive.sourceAddress.size());
2877 kaReq.sourcePort = keepalive.sourcePort;
2879 ::memcpy(kaReq.destinationAddress,
2880 keepalive.destinationAddress.data(), keepalive.destinationAddress.size());
2881 kaReq.destinationPort = keepalive.destinationPort;
2883 kaReq.maxKeepaliveIntervalMillis = keepalive.maxKeepaliveIntervalMillis;
2884 kaReq.cid = keepalive.cid; // This is the context ID of the data call
2886 CALL_ONREQUEST(pRI->pCI->requestNumber, &kaReq, sizeof(RIL_KeepaliveRequest), pRI, mSlotId);
2890 Return<void> RadioImpl::stopKeepalive(int32_t serial, int32_t sessionHandle) {
2892 RLOGD("%s(): %d", __FUNCTION__, serial);
2894 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_STOP_KEEPALIVE);
2899 CALL_ONREQUEST(pRI->pCI->requestNumber, &sessionHandle, sizeof(uint32_t), pRI, mSlotId);
2903 Return<void> RadioImpl::responseAcknowledgement() {
2904 android::releaseWakeLock();
2908 Return<void> OemHookImpl::setResponseFunctions(
2909 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2910 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2912 RLOGD("OemHookImpl::setResponseFunctions");
2915 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2916 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2919 mOemHookResponse = oemHookResponseParam;
2920 mOemHookIndication = oemHookIndicationParam;
2921 mCounterOemHook[mSlotId]++;
2923 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2929 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2931 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2933 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2937 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2938 const hidl_vec<hidl_string>& data) {
2940 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2942 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2946 /***************************************************************************************************
2947 * RESPONSE FUNCTIONS
2948 * Functions above are used for requests going from framework to vendor code. The ones below are
2949 * responses for those requests coming back from the vendor code.
2950 **************************************************************************************************/
2952 void radio::acknowledgeRequest(int slotId, int serial) {
2953 if (radioService[slotId]->mRadioResponse != NULL) {
2954 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2955 radioService[slotId]->checkReturnStatus(retStatus);
2957 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2961 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2963 responseInfo.serial = serial;
2964 switch (responseType) {
2965 case RESPONSE_SOLICITED:
2966 responseInfo.type = RadioResponseType::SOLICITED;
2968 case RESPONSE_SOLICITED_ACK_EXP:
2969 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2972 responseInfo.error = (RadioError) e;
2975 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2976 void *response, size_t responseLen) {
2977 populateResponseInfo(responseInfo, serial, responseType, e);
2980 if (response == NULL && responseLen == 0) {
2981 // Earlier RILs did not send a response for some cases although the interface
2982 // expected an integer as response. Do not return error if response is empty. Instead
2983 // Return -1 in those cases to maintain backward compatibility.
2984 } else if (response == NULL || responseLen != sizeof(int)) {
2985 RLOGE("responseIntOrEmpty: Invalid response");
2986 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2988 int *p_int = (int *) response;
2994 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2995 void *response, size_t responseLen) {
2996 populateResponseInfo(responseInfo, serial, responseType, e);
2999 if (response == NULL || responseLen != sizeof(int)) {
3000 RLOGE("responseInt: Invalid response");
3001 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3003 int *p_int = (int *) response;
3009 int radio::getIccCardStatusResponse(int slotId,
3010 int responseType, int serial, RIL_Errno e,
3011 void *response, size_t responseLen) {
3012 if (radioService[slotId]->mRadioResponse != NULL) {
3013 RadioResponseInfo responseInfo = {};
3014 populateResponseInfo(responseInfo, serial, responseType, e);
3015 CardStatus cardStatus = {CardState::ABSENT, PinState::UNKNOWN, -1, -1, -1, {}};
3016 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
3017 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)
3018 || p_cur->gsm_umts_subscription_app_index >= p_cur->num_applications
3019 || p_cur->cdma_subscription_app_index >= p_cur->num_applications
3020 || p_cur->ims_subscription_app_index >= p_cur->num_applications) {
3021 RLOGE("getIccCardStatusResponse: Invalid response");
3022 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3024 cardStatus.cardState = (CardState) p_cur->card_state;
3025 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
3026 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
3027 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
3028 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
3030 RIL_AppStatus *rilAppStatus = p_cur->applications;
3031 cardStatus.applications.resize(p_cur->num_applications);
3032 AppStatus *appStatus = cardStatus.applications.data();
3034 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
3036 for (int i = 0; i < p_cur->num_applications; i++) {
3037 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
3038 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
3039 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
3040 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
3041 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
3042 rilAppStatus[i].app_label_ptr);
3043 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
3044 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
3045 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
3049 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3050 getIccCardStatusResponse(responseInfo, cardStatus);
3051 radioService[slotId]->checkReturnStatus(retStatus);
3053 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3059 int radio::supplyIccPinForAppResponse(int slotId,
3060 int responseType, int serial, RIL_Errno e,
3061 void *response, size_t responseLen) {
3063 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
3066 if (radioService[slotId]->mRadioResponse != NULL) {
3067 RadioResponseInfo responseInfo = {};
3068 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3069 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3070 supplyIccPinForAppResponse(responseInfo, ret);
3071 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
3072 radioService[slotId]->checkReturnStatus(retStatus);
3074 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3081 int radio::supplyIccPukForAppResponse(int slotId,
3082 int responseType, int serial, RIL_Errno e,
3083 void *response, size_t responseLen) {
3085 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
3088 if (radioService[slotId]->mRadioResponse != NULL) {
3089 RadioResponseInfo responseInfo = {};
3090 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3091 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
3093 radioService[slotId]->checkReturnStatus(retStatus);
3095 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
3102 int radio::supplyIccPin2ForAppResponse(int slotId,
3103 int responseType, int serial, RIL_Errno e,
3104 void *response, size_t responseLen) {
3106 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
3109 if (radioService[slotId]->mRadioResponse != NULL) {
3110 RadioResponseInfo responseInfo = {};
3111 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3112 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3113 supplyIccPin2ForAppResponse(responseInfo, ret);
3114 radioService[slotId]->checkReturnStatus(retStatus);
3116 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3123 int radio::supplyIccPuk2ForAppResponse(int slotId,
3124 int responseType, int serial, RIL_Errno e,
3125 void *response, size_t responseLen) {
3127 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
3130 if (radioService[slotId]->mRadioResponse != NULL) {
3131 RadioResponseInfo responseInfo = {};
3132 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3133 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3134 supplyIccPuk2ForAppResponse(responseInfo, ret);
3135 radioService[slotId]->checkReturnStatus(retStatus);
3137 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3144 int radio::changeIccPinForAppResponse(int slotId,
3145 int responseType, int serial, RIL_Errno e,
3146 void *response, size_t responseLen) {
3148 RLOGD("changeIccPinForAppResponse: serial %d", serial);
3151 if (radioService[slotId]->mRadioResponse != NULL) {
3152 RadioResponseInfo responseInfo = {};
3153 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3154 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3155 changeIccPinForAppResponse(responseInfo, ret);
3156 radioService[slotId]->checkReturnStatus(retStatus);
3158 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3165 int radio::changeIccPin2ForAppResponse(int slotId,
3166 int responseType, int serial, RIL_Errno e,
3167 void *response, size_t responseLen) {
3169 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
3172 if (radioService[slotId]->mRadioResponse != NULL) {
3173 RadioResponseInfo responseInfo = {};
3174 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3175 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3176 changeIccPin2ForAppResponse(responseInfo, ret);
3177 radioService[slotId]->checkReturnStatus(retStatus);
3179 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3186 int radio::supplyNetworkDepersonalizationResponse(int slotId,
3187 int responseType, int serial, RIL_Errno e,
3188 void *response, size_t responseLen) {
3190 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
3193 if (radioService[slotId]->mRadioResponse != NULL) {
3194 RadioResponseInfo responseInfo = {};
3195 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3196 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3197 supplyNetworkDepersonalizationResponse(responseInfo, ret);
3198 radioService[slotId]->checkReturnStatus(retStatus);
3200 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
3207 int radio::getCurrentCallsResponse(int slotId,
3208 int responseType, int serial, RIL_Errno e,
3209 void *response, size_t responseLen) {
3211 RLOGD("getCurrentCallsResponse: serial %d", serial);
3214 if (radioService[slotId]->mRadioResponse != NULL) {
3215 RadioResponseInfo responseInfo = {};
3216 populateResponseInfo(responseInfo, serial, responseType, e);
3218 hidl_vec<Call> calls;
3219 if ((response == NULL && responseLen != 0)
3220 || (responseLen % sizeof(RIL_Call *)) != 0) {
3221 RLOGE("getCurrentCallsResponse: Invalid response");
3222 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3224 int num = responseLen / sizeof(RIL_Call *);
3227 for (int i = 0 ; i < num ; i++) {
3228 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3229 /* each call info */
3230 calls[i].state = (CallState) p_cur->state;
3231 calls[i].index = p_cur->index;
3232 calls[i].toa = p_cur->toa;
3233 calls[i].isMpty = p_cur->isMpty;
3234 calls[i].isMT = p_cur->isMT;
3235 calls[i].als = p_cur->als;
3236 calls[i].isVoice = p_cur->isVoice;
3237 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3238 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3239 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3240 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3241 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3242 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3243 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3244 calls[i].uusInfo.resize(1);
3245 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3246 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3247 // convert uusInfo->uusData to a null-terminated string
3248 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3249 calls[i].uusInfo[0].uusData = nullTermStr;
3255 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3256 getCurrentCallsResponse(responseInfo, calls);
3257 radioService[slotId]->checkReturnStatus(retStatus);
3259 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3265 int radio::dialResponse(int slotId,
3266 int responseType, int serial, RIL_Errno e, void *response,
3267 size_t responseLen) {
3269 RLOGD("dialResponse: serial %d", serial);
3272 if (radioService[slotId]->mRadioResponse != NULL) {
3273 RadioResponseInfo responseInfo = {};
3274 populateResponseInfo(responseInfo, serial, responseType, e);
3275 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3276 radioService[slotId]->checkReturnStatus(retStatus);
3278 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3284 int radio::getIMSIForAppResponse(int slotId,
3285 int responseType, int serial, RIL_Errno e, void *response,
3286 size_t responseLen) {
3288 RLOGD("getIMSIForAppResponse: serial %d", serial);
3291 if (radioService[slotId]->mRadioResponse != NULL) {
3292 RadioResponseInfo responseInfo = {};
3293 populateResponseInfo(responseInfo, serial, responseType, e);
3294 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3295 responseInfo, convertCharPtrToHidlString((char *) response));
3296 radioService[slotId]->checkReturnStatus(retStatus);
3298 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3305 int radio::hangupConnectionResponse(int slotId,
3306 int responseType, int serial, RIL_Errno e,
3307 void *response, size_t responseLen) {
3309 RLOGD("hangupConnectionResponse: serial %d", serial);
3312 if (radioService[slotId]->mRadioResponse != NULL) {
3313 RadioResponseInfo responseInfo = {};
3314 populateResponseInfo(responseInfo, serial, responseType, e);
3315 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3317 radioService[slotId]->checkReturnStatus(retStatus);
3319 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3326 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3327 int responseType, int serial, RIL_Errno e,
3328 void *response, size_t responseLen) {
3330 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3333 if (radioService[slotId]->mRadioResponse != NULL) {
3334 RadioResponseInfo responseInfo = {};
3335 populateResponseInfo(responseInfo, serial, responseType, e);
3336 Return<void> retStatus =
3337 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3339 radioService[slotId]->checkReturnStatus(retStatus);
3341 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3348 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3349 RIL_Errno e, void *response,
3350 size_t responseLen) {
3352 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3355 if (radioService[slotId]->mRadioResponse != NULL) {
3356 RadioResponseInfo responseInfo = {};
3357 populateResponseInfo(responseInfo, serial, responseType, e);
3358 Return<void> retStatus =
3359 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3361 radioService[slotId]->checkReturnStatus(retStatus);
3363 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3370 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3371 RIL_Errno e, void *response,
3372 size_t responseLen) {
3374 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3377 if (radioService[slotId]->mRadioResponse != NULL) {
3378 RadioResponseInfo responseInfo = {};
3379 populateResponseInfo(responseInfo, serial, responseType, e);
3380 Return<void> retStatus =
3381 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3383 radioService[slotId]->checkReturnStatus(retStatus);
3385 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3392 int radio::conferenceResponse(int slotId, int responseType,
3393 int serial, RIL_Errno e, void *response, size_t responseLen) {
3395 RLOGD("conferenceResponse: serial %d", serial);
3398 if (radioService[slotId]->mRadioResponse != NULL) {
3399 RadioResponseInfo responseInfo = {};
3400 populateResponseInfo(responseInfo, serial, responseType, e);
3401 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3403 radioService[slotId]->checkReturnStatus(retStatus);
3405 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3412 int radio::rejectCallResponse(int slotId, int responseType,
3413 int serial, RIL_Errno e, void *response, size_t responseLen) {
3415 RLOGD("rejectCallResponse: serial %d", serial);
3418 if (radioService[slotId]->mRadioResponse != NULL) {
3419 RadioResponseInfo responseInfo = {};
3420 populateResponseInfo(responseInfo, serial, responseType, e);
3421 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3423 radioService[slotId]->checkReturnStatus(retStatus);
3425 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3432 int radio::getLastCallFailCauseResponse(int slotId,
3433 int responseType, int serial, RIL_Errno e, void *response,
3434 size_t responseLen) {
3436 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3439 if (radioService[slotId]->mRadioResponse != NULL) {
3440 RadioResponseInfo responseInfo = {};
3441 populateResponseInfo(responseInfo, serial, responseType, e);
3443 LastCallFailCauseInfo info = {};
3444 info.vendorCause = hidl_string();
3445 if (response == NULL) {
3446 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3447 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3448 } else if (responseLen == sizeof(int)) {
3449 int *pInt = (int *) response;
3450 info.causeCode = (LastCallFailCause) pInt[0];
3451 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3452 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3453 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3454 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3456 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3457 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3460 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3461 responseInfo, info);
3462 radioService[slotId]->checkReturnStatus(retStatus);
3464 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3471 int radio::getSignalStrengthResponse(int slotId,
3472 int responseType, int serial, RIL_Errno e,
3473 void *response, size_t responseLen) {
3475 RLOGD("getSignalStrengthResponse: serial %d", serial);
3478 if (radioService[slotId]->mRadioResponse != NULL) {
3479 RadioResponseInfo responseInfo = {};
3480 populateResponseInfo(responseInfo, serial, responseType, e);
3481 SignalStrength signalStrength = {};
3482 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3483 RLOGE("getSignalStrengthResponse: Invalid response");
3484 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3486 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3489 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3490 responseInfo, signalStrength);
3491 radioService[slotId]->checkReturnStatus(retStatus);
3493 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3500 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3502 return RIL_CELL_INFO_TYPE_NONE;
3505 int radioTech = atoi(rat);
3509 case RADIO_TECH_GPRS:
3510 case RADIO_TECH_EDGE:
3511 case RADIO_TECH_GSM: {
3512 return RIL_CELL_INFO_TYPE_GSM;
3515 case RADIO_TECH_UMTS:
3516 case RADIO_TECH_HSDPA:
3517 case RADIO_TECH_HSUPA:
3518 case RADIO_TECH_HSPA:
3519 case RADIO_TECH_HSPAP: {
3520 return RIL_CELL_INFO_TYPE_WCDMA;
3523 case RADIO_TECH_IS95A:
3524 case RADIO_TECH_IS95B:
3525 case RADIO_TECH_1xRTT:
3526 case RADIO_TECH_EVDO_0:
3527 case RADIO_TECH_EVDO_A:
3528 case RADIO_TECH_EVDO_B:
3529 case RADIO_TECH_EHRPD: {
3530 return RIL_CELL_INFO_TYPE_CDMA;
3533 case RADIO_TECH_LTE:
3534 case RADIO_TECH_LTE_CA: {
3535 return RIL_CELL_INFO_TYPE_LTE;
3538 case RADIO_TECH_TD_SCDMA: {
3539 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3547 return RIL_CELL_INFO_TYPE_NONE;
3551 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3553 cellIdentity.cellIdentityGsm.resize(0);
3554 cellIdentity.cellIdentityWcdma.resize(0);
3555 cellIdentity.cellIdentityCdma.resize(0);
3556 cellIdentity.cellIdentityTdscdma.resize(0);
3557 cellIdentity.cellIdentityLte.resize(0);
3558 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3559 switch(rilCellIdentity.cellInfoType) {
3561 case RIL_CELL_INFO_TYPE_GSM: {
3562 cellIdentity.cellIdentityGsm.resize(1);
3563 cellIdentity.cellIdentityGsm[0].mcc =
3564 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3565 cellIdentity.cellIdentityGsm[0].mnc =
3566 ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
3567 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3568 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3569 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3570 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3574 case RIL_CELL_INFO_TYPE_WCDMA: {
3575 cellIdentity.cellIdentityWcdma.resize(1);
3576 cellIdentity.cellIdentityWcdma[0].mcc =
3577 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3578 cellIdentity.cellIdentityWcdma[0].mnc =
3579 ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
3580 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3581 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3582 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3583 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3587 case RIL_CELL_INFO_TYPE_CDMA: {
3588 cellIdentity.cellIdentityCdma.resize(1);
3589 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3590 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3591 cellIdentity.cellIdentityCdma[0].baseStationId =
3592 rilCellIdentity.cellIdentityCdma.basestationId;
3593 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3594 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3598 case RIL_CELL_INFO_TYPE_LTE: {
3599 cellIdentity.cellIdentityLte.resize(1);
3600 cellIdentity.cellIdentityLte[0].mcc =
3601 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3602 cellIdentity.cellIdentityLte[0].mnc =
3603 ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
3604 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3605 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3606 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3607 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3611 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3612 cellIdentity.cellIdentityTdscdma.resize(1);
3613 cellIdentity.cellIdentityTdscdma[0].mcc =
3614 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3615 cellIdentity.cellIdentityTdscdma[0].mnc =
3616 ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
3617 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3618 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3619 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3629 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3630 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3631 return atoi(response[index]);
3637 int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
3638 const int hexBase = 16;
3639 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3640 return strtol(response[index], NULL, hexBase);
3646 /* Fill Cell Identity info from Voice Registration State Response.
3647 * This fucntion is applicable only for RIL Version < 15.
3648 * Response is a "char **".
3649 * First and Second entries are in hex string format
3650 * and rest are integers represented in ascii format. */
3651 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3652 int numStrings, char** response) {
3654 RIL_CellIdentity_v16 rilCellIdentity;
3655 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3657 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3658 switch(rilCellIdentity.cellInfoType) {
3660 case RIL_CELL_INFO_TYPE_GSM: {
3661 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3662 rilCellIdentity.cellIdentityGsm.lac =
3663 convertResponseHexStringEntryToInt(response, 1, numStrings);
3665 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3666 rilCellIdentity.cellIdentityGsm.cid =
3667 convertResponseHexStringEntryToInt(response, 2, numStrings);
3671 case RIL_CELL_INFO_TYPE_WCDMA: {
3672 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3673 rilCellIdentity.cellIdentityWcdma.lac =
3674 convertResponseHexStringEntryToInt(response, 1, numStrings);
3676 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3677 rilCellIdentity.cellIdentityWcdma.cid =
3678 convertResponseHexStringEntryToInt(response, 2, numStrings);
3679 rilCellIdentity.cellIdentityWcdma.psc =
3680 convertResponseStringEntryToInt(response, 14, numStrings);
3684 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3685 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3686 rilCellIdentity.cellIdentityTdscdma.lac =
3687 convertResponseHexStringEntryToInt(response, 1, numStrings);
3689 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3690 rilCellIdentity.cellIdentityTdscdma.cid =
3691 convertResponseHexStringEntryToInt(response, 2, numStrings);
3695 case RIL_CELL_INFO_TYPE_CDMA:{
3696 rilCellIdentity.cellIdentityCdma.basestationId =
3697 convertResponseStringEntryToInt(response, 4, numStrings);
3698 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
3699 rilCellIdentity.cellIdentityCdma.latitude =
3700 convertResponseStringEntryToInt(response, 5, numStrings);
3701 rilCellIdentity.cellIdentityCdma.longitude =
3702 convertResponseStringEntryToInt(response, 6, numStrings);
3703 rilCellIdentity.cellIdentityCdma.systemId =
3704 convertResponseStringEntryToInt(response, 8, numStrings);
3705 rilCellIdentity.cellIdentityCdma.networkId =
3706 convertResponseStringEntryToInt(response, 9, numStrings);
3710 case RIL_CELL_INFO_TYPE_LTE:{
3711 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
3712 rilCellIdentity.cellIdentityLte.tac =
3713 convertResponseHexStringEntryToInt(response, 1, numStrings);
3715 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3716 rilCellIdentity.cellIdentityLte.ci =
3717 convertResponseHexStringEntryToInt(response, 2, numStrings);
3726 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3729 /* Fill Cell Identity info from Data Registration State Response.
3730 * This fucntion is applicable only for RIL Version < 15.
3731 * Response is a "char **".
3732 * First and Second entries are in hex string format
3733 * and rest are integers represented in ascii format. */
3734 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3735 int numStrings, char** response) {
3737 RIL_CellIdentity_v16 rilCellIdentity;
3738 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3740 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3741 switch(rilCellIdentity.cellInfoType) {
3742 case RIL_CELL_INFO_TYPE_GSM: {
3743 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3744 rilCellIdentity.cellIdentityGsm.lac =
3745 convertResponseHexStringEntryToInt(response, 1, numStrings);
3747 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3748 rilCellIdentity.cellIdentityGsm.cid =
3749 convertResponseHexStringEntryToInt(response, 2, numStrings);
3752 case RIL_CELL_INFO_TYPE_WCDMA: {
3753 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3754 rilCellIdentity.cellIdentityWcdma.lac =
3755 convertResponseHexStringEntryToInt(response, 1, numStrings);
3757 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3758 rilCellIdentity.cellIdentityWcdma.cid =
3759 convertResponseHexStringEntryToInt(response, 2, numStrings);
3762 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3763 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3764 rilCellIdentity.cellIdentityTdscdma.lac =
3765 convertResponseHexStringEntryToInt(response, 1, numStrings);
3767 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3768 rilCellIdentity.cellIdentityTdscdma.cid =
3769 convertResponseHexStringEntryToInt(response, 2, numStrings);
3772 case RIL_CELL_INFO_TYPE_LTE: {
3773 rilCellIdentity.cellIdentityLte.tac =
3774 convertResponseStringEntryToInt(response, 6, numStrings);
3775 rilCellIdentity.cellIdentityLte.pci =
3776 convertResponseStringEntryToInt(response, 7, numStrings);
3777 rilCellIdentity.cellIdentityLte.ci =
3778 convertResponseStringEntryToInt(response, 8, numStrings);
3786 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3789 int radio::getVoiceRegistrationStateResponse(int slotId,
3790 int responseType, int serial, RIL_Errno e,
3791 void *response, size_t responseLen) {
3793 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3796 if (radioService[slotId]->mRadioResponse != NULL) {
3797 RadioResponseInfo responseInfo = {};
3798 populateResponseInfo(responseInfo, serial, responseType, e);
3800 VoiceRegStateResult voiceRegResponse = {};
3801 int numStrings = responseLen / sizeof(char *);
3802 if (response == NULL) {
3803 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3804 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3805 } else if (s_vendorFunctions->version <= 14) {
3806 if (numStrings != 15) {
3807 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3808 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3810 char **resp = (char **) response;
3811 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3812 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3813 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3814 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3815 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3816 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3817 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3818 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3822 RIL_VoiceRegistrationStateResponse *voiceRegState =
3823 (RIL_VoiceRegistrationStateResponse *)response;
3825 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3826 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3827 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3829 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3830 voiceRegResponse.rat = voiceRegState->rat;;
3831 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3832 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3833 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3834 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3835 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3836 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3837 voiceRegState->cellIdentity);
3841 Return<void> retStatus =
3842 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3843 responseInfo, voiceRegResponse);
3844 radioService[slotId]->checkReturnStatus(retStatus);
3846 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3853 int radio::getDataRegistrationStateResponse(int slotId,
3854 int responseType, int serial, RIL_Errno e,
3855 void *response, size_t responseLen) {
3857 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3860 if (radioService[slotId]->mRadioResponse != NULL) {
3861 RadioResponseInfo responseInfo = {};
3862 populateResponseInfo(responseInfo, serial, responseType, e);
3863 DataRegStateResult dataRegResponse = {};
3864 if (response == NULL) {
3865 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3866 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3867 } else if (s_vendorFunctions->version <= 14) {
3868 int numStrings = responseLen / sizeof(char *);
3869 if ((numStrings != 6) && (numStrings != 11)) {
3870 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3871 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3873 char **resp = (char **) response;
3874 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3875 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3876 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3877 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3878 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3882 RIL_DataRegistrationStateResponse *dataRegState =
3883 (RIL_DataRegistrationStateResponse *)response;
3885 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3886 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3887 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3889 dataRegResponse.regState = (RegState) dataRegState->regState;
3890 dataRegResponse.rat = dataRegState->rat;;
3891 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3892 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3893 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3897 Return<void> retStatus =
3898 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3900 radioService[slotId]->checkReturnStatus(retStatus);
3902 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3909 int radio::getOperatorResponse(int slotId,
3910 int responseType, int serial, RIL_Errno e, void *response,
3911 size_t responseLen) {
3913 RLOGD("getOperatorResponse: serial %d", serial);
3916 if (radioService[slotId]->mRadioResponse != NULL) {
3917 RadioResponseInfo responseInfo = {};
3918 populateResponseInfo(responseInfo, serial, responseType, e);
3919 hidl_string longName;
3920 hidl_string shortName;
3921 hidl_string numeric;
3922 int numStrings = responseLen / sizeof(char *);
3923 if (response == NULL || numStrings != 3) {
3924 RLOGE("getOperatorResponse Invalid response: NULL");
3925 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3928 char **resp = (char **) response;
3929 longName = convertCharPtrToHidlString(resp[0]);
3930 shortName = convertCharPtrToHidlString(resp[1]);
3931 numeric = convertCharPtrToHidlString(resp[2]);
3933 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3934 responseInfo, longName, shortName, numeric);
3935 radioService[slotId]->checkReturnStatus(retStatus);
3937 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3944 int radio::setRadioPowerResponse(int slotId,
3945 int responseType, int serial, RIL_Errno e, void *response,
3946 size_t responseLen) {
3947 RLOGD("setRadioPowerResponse: serial %d", serial);
3949 if (radioService[slotId]->mRadioResponse != NULL) {
3950 RadioResponseInfo responseInfo = {};
3951 populateResponseInfo(responseInfo, serial, responseType, e);
3952 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3954 radioService[slotId]->checkReturnStatus(retStatus);
3956 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3963 int radio::sendDtmfResponse(int slotId,
3964 int responseType, int serial, RIL_Errno e, void *response,
3965 size_t responseLen) {
3967 RLOGD("sendDtmfResponse: serial %d", serial);
3970 if (radioService[slotId]->mRadioResponse != NULL) {
3971 RadioResponseInfo responseInfo = {};
3972 populateResponseInfo(responseInfo, serial, responseType, e);
3973 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3975 radioService[slotId]->checkReturnStatus(retStatus);
3977 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3984 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3985 RIL_Errno e, void *response, size_t responseLen) {
3986 populateResponseInfo(responseInfo, serial, responseType, e);
3987 SendSmsResult result = {};
3989 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3990 RLOGE("Invalid response: NULL");
3991 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3992 result.ackPDU = hidl_string();
3994 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3995 result.messageRef = resp->messageRef;
3996 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3997 result.errorCode = resp->errorCode;
4002 int radio::sendSmsResponse(int slotId,
4003 int responseType, int serial, RIL_Errno e, void *response,
4004 size_t responseLen) {
4006 RLOGD("sendSmsResponse: serial %d", serial);
4009 if (radioService[slotId]->mRadioResponse != NULL) {
4010 RadioResponseInfo responseInfo = {};
4011 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4014 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
4016 radioService[slotId]->checkReturnStatus(retStatus);
4018 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4024 int radio::sendSMSExpectMoreResponse(int slotId,
4025 int responseType, int serial, RIL_Errno e, void *response,
4026 size_t responseLen) {
4028 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
4031 if (radioService[slotId]->mRadioResponse != NULL) {
4032 RadioResponseInfo responseInfo = {};
4033 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4036 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
4037 responseInfo, result);
4038 radioService[slotId]->checkReturnStatus(retStatus);
4040 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4046 int radio::setupDataCallResponse(int slotId,
4047 int responseType, int serial, RIL_Errno e, void *response,
4048 size_t responseLen) {
4050 RLOGD("setupDataCallResponse: serial %d", serial);
4053 if (radioService[slotId]->mRadioResponse != NULL) {
4054 RadioResponseInfo responseInfo = {};
4055 populateResponseInfo(responseInfo, serial, responseType, e);
4057 SetupDataCallResult result = {};
4058 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
4059 if (response != NULL) {
4060 RLOGE("setupDataCallResponse: Invalid response");
4061 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4063 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
4064 result.type = hidl_string();
4065 result.ifname = hidl_string();
4066 result.addresses = hidl_string();
4067 result.dnses = hidl_string();
4068 result.gateways = hidl_string();
4069 result.pcscf = hidl_string();
4071 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
4074 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
4075 responseInfo, result);
4076 radioService[slotId]->checkReturnStatus(retStatus);
4078 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4084 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
4085 RIL_Errno e, void *response, size_t responseLen) {
4086 populateResponseInfo(responseInfo, serial, responseType, e);
4087 IccIoResult result = {};
4089 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
4090 RLOGE("Invalid response: NULL");
4091 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4092 result.simResponse = hidl_string();
4094 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
4095 result.sw1 = resp->sw1;
4096 result.sw2 = resp->sw2;
4097 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
4102 int radio::iccIOForAppResponse(int slotId,
4103 int responseType, int serial, RIL_Errno e, void *response,
4104 size_t responseLen) {
4106 RLOGD("iccIOForAppResponse: serial %d", serial);
4109 if (radioService[slotId]->mRadioResponse != NULL) {
4110 RadioResponseInfo responseInfo = {};
4111 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
4114 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
4115 responseInfo, result);
4116 radioService[slotId]->checkReturnStatus(retStatus);
4118 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4124 int radio::sendUssdResponse(int slotId,
4125 int responseType, int serial, RIL_Errno e, void *response,
4126 size_t responseLen) {
4128 RLOGD("sendUssdResponse: serial %d", serial);
4131 if (radioService[slotId]->mRadioResponse != NULL) {
4132 RadioResponseInfo responseInfo = {};
4133 populateResponseInfo(responseInfo, serial, responseType, e);
4134 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
4136 radioService[slotId]->checkReturnStatus(retStatus);
4138 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
4145 int radio::cancelPendingUssdResponse(int slotId,
4146 int responseType, int serial, RIL_Errno e, void *response,
4147 size_t responseLen) {
4149 RLOGD("cancelPendingUssdResponse: serial %d", serial);
4152 if (radioService[slotId]->mRadioResponse != NULL) {
4153 RadioResponseInfo responseInfo = {};
4154 populateResponseInfo(responseInfo, serial, responseType, e);
4155 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
4157 radioService[slotId]->checkReturnStatus(retStatus);
4159 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
4166 int radio::getClirResponse(int slotId,
4167 int responseType, int serial, RIL_Errno e, void *response,
4168 size_t responseLen) {
4170 RLOGD("getClirResponse: serial %d", serial);
4173 if (radioService[slotId]->mRadioResponse != NULL) {
4174 RadioResponseInfo responseInfo = {};
4175 populateResponseInfo(responseInfo, serial, responseType, e);
4177 int numInts = responseLen / sizeof(int);
4178 if (response == NULL || numInts != 2) {
4179 RLOGE("getClirResponse Invalid response: NULL");
4180 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4182 int *pInt = (int *) response;
4186 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
4188 radioService[slotId]->checkReturnStatus(retStatus);
4190 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4196 int radio::setClirResponse(int slotId,
4197 int responseType, int serial, RIL_Errno e, void *response,
4198 size_t responseLen) {
4200 RLOGD("setClirResponse: serial %d", serial);
4203 if (radioService[slotId]->mRadioResponse != NULL) {
4204 RadioResponseInfo responseInfo = {};
4205 populateResponseInfo(responseInfo, serial, responseType, e);
4206 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
4208 radioService[slotId]->checkReturnStatus(retStatus);
4210 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4216 int radio::getCallForwardStatusResponse(int slotId,
4217 int responseType, int serial, RIL_Errno e,
4218 void *response, size_t responseLen) {
4220 RLOGD("getCallForwardStatusResponse: serial %d", serial);
4223 if (radioService[slotId]->mRadioResponse != NULL) {
4224 RadioResponseInfo responseInfo = {};
4225 populateResponseInfo(responseInfo, serial, responseType, e);
4226 hidl_vec<CallForwardInfo> callForwardInfos;
4228 if ((response == NULL && responseLen != 0)
4229 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4230 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4231 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4233 int num = responseLen / sizeof(RIL_CallForwardInfo *);
4234 callForwardInfos.resize(num);
4235 for (int i = 0 ; i < num; i++) {
4236 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4237 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4238 callForwardInfos[i].reason = resp->reason;
4239 callForwardInfos[i].serviceClass = resp->serviceClass;
4240 callForwardInfos[i].toa = resp->toa;
4241 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4242 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4246 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4247 responseInfo, callForwardInfos);
4248 radioService[slotId]->checkReturnStatus(retStatus);
4250 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4257 int radio::setCallForwardResponse(int slotId,
4258 int responseType, int serial, RIL_Errno e, void *response,
4259 size_t responseLen) {
4261 RLOGD("setCallForwardResponse: serial %d", serial);
4264 if (radioService[slotId]->mRadioResponse != NULL) {
4265 RadioResponseInfo responseInfo = {};
4266 populateResponseInfo(responseInfo, serial, responseType, e);
4267 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4269 radioService[slotId]->checkReturnStatus(retStatus);
4271 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4277 int radio::getCallWaitingResponse(int slotId,
4278 int responseType, int serial, RIL_Errno e, void *response,
4279 size_t responseLen) {
4281 RLOGD("getCallWaitingResponse: serial %d", serial);
4284 if (radioService[slotId]->mRadioResponse != NULL) {
4285 RadioResponseInfo responseInfo = {};
4286 populateResponseInfo(responseInfo, serial, responseType, e);
4287 bool enable = false;
4288 int serviceClass = -1;
4289 int numInts = responseLen / sizeof(int);
4290 if (response == NULL || numInts != 2) {
4291 RLOGE("getCallWaitingResponse Invalid response: NULL");
4292 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4294 int *pInt = (int *) response;
4295 enable = pInt[0] == 1 ? true : false;
4296 serviceClass = pInt[1];
4298 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4299 responseInfo, enable, serviceClass);
4300 radioService[slotId]->checkReturnStatus(retStatus);
4302 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4308 int radio::setCallWaitingResponse(int slotId,
4309 int responseType, int serial, RIL_Errno e, void *response,
4310 size_t responseLen) {
4312 RLOGD("setCallWaitingResponse: serial %d", serial);
4315 if (radioService[slotId]->mRadioResponse != NULL) {
4316 RadioResponseInfo responseInfo = {};
4317 populateResponseInfo(responseInfo, serial, responseType, e);
4318 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4320 radioService[slotId]->checkReturnStatus(retStatus);
4322 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4328 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4329 int responseType, int serial, RIL_Errno e,
4330 void *response, size_t responseLen) {
4332 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4335 if (radioService[slotId]->mRadioResponse != NULL) {
4336 RadioResponseInfo responseInfo = {};
4337 populateResponseInfo(responseInfo, serial, responseType, e);
4338 Return<void> retStatus =
4339 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4341 radioService[slotId]->checkReturnStatus(retStatus);
4343 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4350 int radio::acceptCallResponse(int slotId,
4351 int responseType, int serial, RIL_Errno e,
4352 void *response, size_t responseLen) {
4354 RLOGD("acceptCallResponse: serial %d", serial);
4357 if (radioService[slotId]->mRadioResponse != NULL) {
4358 RadioResponseInfo responseInfo = {};
4359 populateResponseInfo(responseInfo, serial, responseType, e);
4360 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4362 radioService[slotId]->checkReturnStatus(retStatus);
4364 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4371 int radio::deactivateDataCallResponse(int slotId,
4372 int responseType, int serial, RIL_Errno e,
4373 void *response, size_t responseLen) {
4375 RLOGD("deactivateDataCallResponse: serial %d", serial);
4378 if (radioService[slotId]->mRadioResponse != NULL) {
4379 RadioResponseInfo responseInfo = {};
4380 populateResponseInfo(responseInfo, serial, responseType, e);
4381 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4383 radioService[slotId]->checkReturnStatus(retStatus);
4385 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4392 int radio::getFacilityLockForAppResponse(int slotId,
4393 int responseType, int serial, RIL_Errno e,
4394 void *response, size_t responseLen) {
4396 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4399 if (radioService[slotId]->mRadioResponse != NULL) {
4400 RadioResponseInfo responseInfo = {};
4401 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4402 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4403 getFacilityLockForAppResponse(responseInfo, ret);
4404 radioService[slotId]->checkReturnStatus(retStatus);
4406 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4413 int radio::setFacilityLockForAppResponse(int slotId,
4414 int responseType, int serial, RIL_Errno e,
4415 void *response, size_t responseLen) {
4417 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4420 if (radioService[slotId]->mRadioResponse != NULL) {
4421 RadioResponseInfo responseInfo = {};
4422 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4423 Return<void> retStatus
4424 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4426 radioService[slotId]->checkReturnStatus(retStatus);
4428 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4435 int radio::setBarringPasswordResponse(int slotId,
4436 int responseType, int serial, RIL_Errno e,
4437 void *response, size_t responseLen) {
4439 RLOGD("acceptCallResponse: serial %d", serial);
4442 if (radioService[slotId]->mRadioResponse != NULL) {
4443 RadioResponseInfo responseInfo = {};
4444 populateResponseInfo(responseInfo, serial, responseType, e);
4445 Return<void> retStatus
4446 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4447 radioService[slotId]->checkReturnStatus(retStatus);
4449 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4456 int radio::getNetworkSelectionModeResponse(int slotId,
4457 int responseType, int serial, RIL_Errno e, void *response,
4458 size_t responseLen) {
4460 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4463 if (radioService[slotId]->mRadioResponse != NULL) {
4464 RadioResponseInfo responseInfo = {};
4465 populateResponseInfo(responseInfo, serial, responseType, e);
4466 bool manual = false;
4467 if (response == NULL || responseLen != sizeof(int)) {
4468 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4469 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4471 int *pInt = (int *) response;
4472 manual = pInt[0] == 1 ? true : false;
4474 Return<void> retStatus
4475 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4478 radioService[slotId]->checkReturnStatus(retStatus);
4480 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4487 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4488 RIL_Errno e, void *response,
4489 size_t responseLen) {
4491 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4494 if (radioService[slotId]->mRadioResponse != NULL) {
4495 RadioResponseInfo responseInfo = {};
4496 populateResponseInfo(responseInfo, serial, responseType, e);
4497 Return<void> retStatus
4498 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4500 radioService[slotId]->checkReturnStatus(retStatus);
4502 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4509 int radio::setNetworkSelectionModeManualResponse(int slotId,
4510 int responseType, int serial, RIL_Errno e,
4511 void *response, size_t responseLen) {
4513 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4516 if (radioService[slotId]->mRadioResponse != NULL) {
4517 RadioResponseInfo responseInfo = {};
4518 populateResponseInfo(responseInfo, serial, responseType, e);
4519 Return<void> retStatus
4520 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4522 radioService[slotId]->checkReturnStatus(retStatus);
4524 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4531 int convertOperatorStatusToInt(const char *str) {
4532 if (strncmp("unknown", str, 9) == 0) {
4533 return (int) OperatorStatus::UNKNOWN;
4534 } else if (strncmp("available", str, 9) == 0) {
4535 return (int) OperatorStatus::AVAILABLE;
4536 } else if (strncmp("current", str, 9) == 0) {
4537 return (int) OperatorStatus::CURRENT;
4538 } else if (strncmp("forbidden", str, 9) == 0) {
4539 return (int) OperatorStatus::FORBIDDEN;
4545 int radio::getAvailableNetworksResponse(int slotId,
4546 int responseType, int serial, RIL_Errno e, void *response,
4547 size_t responseLen) {
4549 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4552 if (radioService[slotId]->mRadioResponse != NULL) {
4553 RadioResponseInfo responseInfo = {};
4554 populateResponseInfo(responseInfo, serial, responseType, e);
4555 hidl_vec<OperatorInfo> networks;
4556 if ((response == NULL && responseLen != 0)
4557 || responseLen % (4 * sizeof(char *))!= 0) {
4558 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4559 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4561 char **resp = (char **) response;
4562 int numStrings = responseLen / sizeof(char *);
4563 networks.resize(numStrings/4);
4564 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4565 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4566 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4567 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4568 int status = convertOperatorStatusToInt(resp[i + 3]);
4570 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4572 networks[j].status = (OperatorStatus) status;
4576 Return<void> retStatus
4577 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4579 radioService[slotId]->checkReturnStatus(retStatus);
4581 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4588 int radio::startDtmfResponse(int slotId,
4589 int responseType, int serial, RIL_Errno e,
4590 void *response, size_t responseLen) {
4592 RLOGD("startDtmfResponse: serial %d", serial);
4595 if (radioService[slotId]->mRadioResponse != NULL) {
4596 RadioResponseInfo responseInfo = {};
4597 populateResponseInfo(responseInfo, serial, responseType, e);
4598 Return<void> retStatus
4599 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4600 radioService[slotId]->checkReturnStatus(retStatus);
4602 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4608 int radio::stopDtmfResponse(int slotId,
4609 int responseType, int serial, RIL_Errno e,
4610 void *response, size_t responseLen) {
4612 RLOGD("stopDtmfResponse: serial %d", serial);
4615 if (radioService[slotId]->mRadioResponse != NULL) {
4616 RadioResponseInfo responseInfo = {};
4617 populateResponseInfo(responseInfo, serial, responseType, e);
4618 Return<void> retStatus
4619 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4620 radioService[slotId]->checkReturnStatus(retStatus);
4622 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4628 int radio::getBasebandVersionResponse(int slotId,
4629 int responseType, int serial, RIL_Errno e,
4630 void *response, size_t responseLen) {
4632 RLOGD("getBasebandVersionResponse: serial %d", serial);
4635 if (radioService[slotId]->mRadioResponse != NULL) {
4636 RadioResponseInfo responseInfo = {};
4637 populateResponseInfo(responseInfo, serial, responseType, e);
4638 Return<void> retStatus
4639 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4640 convertCharPtrToHidlString((char *) response));
4641 radioService[slotId]->checkReturnStatus(retStatus);
4643 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4649 int radio::separateConnectionResponse(int slotId,
4650 int responseType, int serial, RIL_Errno e,
4651 void *response, size_t responseLen) {
4653 RLOGD("separateConnectionResponse: serial %d", serial);
4656 if (radioService[slotId]->mRadioResponse != NULL) {
4657 RadioResponseInfo responseInfo = {};
4658 populateResponseInfo(responseInfo, serial, responseType, e);
4659 Return<void> retStatus
4660 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4661 radioService[slotId]->checkReturnStatus(retStatus);
4663 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4670 int radio::setMuteResponse(int slotId,
4671 int responseType, int serial, RIL_Errno e,
4672 void *response, size_t responseLen) {
4674 RLOGD("setMuteResponse: serial %d", serial);
4677 if (radioService[slotId]->mRadioResponse != NULL) {
4678 RadioResponseInfo responseInfo = {};
4679 populateResponseInfo(responseInfo, serial, responseType, e);
4680 Return<void> retStatus
4681 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4682 radioService[slotId]->checkReturnStatus(retStatus);
4684 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4690 int radio::getMuteResponse(int slotId,
4691 int responseType, int serial, RIL_Errno e, void *response,
4692 size_t responseLen) {
4694 RLOGD("getMuteResponse: serial %d", serial);
4697 if (radioService[slotId]->mRadioResponse != NULL) {
4698 RadioResponseInfo responseInfo = {};
4699 populateResponseInfo(responseInfo, serial, responseType, e);
4700 bool enable = false;
4701 if (response == NULL || responseLen != sizeof(int)) {
4702 RLOGE("getMuteResponse Invalid response: NULL");
4703 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4705 int *pInt = (int *) response;
4706 enable = pInt[0] == 1 ? true : false;
4708 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4710 radioService[slotId]->checkReturnStatus(retStatus);
4712 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4718 int radio::getClipResponse(int slotId,
4719 int responseType, int serial, RIL_Errno e,
4720 void *response, size_t responseLen) {
4722 RLOGD("getClipResponse: serial %d", serial);
4725 if (radioService[slotId]->mRadioResponse != NULL) {
4726 RadioResponseInfo responseInfo = {};
4727 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4728 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4730 radioService[slotId]->checkReturnStatus(retStatus);
4732 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4738 int radio::getDataCallListResponse(int slotId,
4739 int responseType, int serial, RIL_Errno e,
4740 void *response, size_t responseLen) {
4742 RLOGD("getDataCallListResponse: serial %d", serial);
4745 if (radioService[slotId]->mRadioResponse != NULL) {
4746 RadioResponseInfo responseInfo = {};
4747 populateResponseInfo(responseInfo, serial, responseType, e);
4749 hidl_vec<SetupDataCallResult> ret;
4750 if ((response == NULL && responseLen != 0)
4751 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4752 RLOGE("getDataCallListResponse: invalid response");
4753 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4755 convertRilDataCallListToHal(response, responseLen, ret);
4758 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4760 radioService[slotId]->checkReturnStatus(retStatus);
4762 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4768 int radio::setSuppServiceNotificationsResponse(int slotId,
4769 int responseType, int serial, RIL_Errno e,
4770 void *response, size_t responseLen) {
4772 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4775 if (radioService[slotId]->mRadioResponse != NULL) {
4776 RadioResponseInfo responseInfo = {};
4777 populateResponseInfo(responseInfo, serial, responseType, e);
4778 Return<void> retStatus
4779 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4781 radioService[slotId]->checkReturnStatus(retStatus);
4783 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4790 int radio::deleteSmsOnSimResponse(int slotId,
4791 int responseType, int serial, RIL_Errno e,
4792 void *response, size_t responseLen) {
4794 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4797 if (radioService[slotId]->mRadioResponse != NULL) {
4798 RadioResponseInfo responseInfo = {};
4799 populateResponseInfo(responseInfo, serial, responseType, e);
4800 Return<void> retStatus
4801 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4802 radioService[slotId]->checkReturnStatus(retStatus);
4804 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4810 int radio::setBandModeResponse(int slotId,
4811 int responseType, int serial, RIL_Errno e,
4812 void *response, size_t responseLen) {
4814 RLOGD("setBandModeResponse: serial %d", serial);
4817 if (radioService[slotId]->mRadioResponse != NULL) {
4818 RadioResponseInfo responseInfo = {};
4819 populateResponseInfo(responseInfo, serial, responseType, e);
4820 Return<void> retStatus
4821 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4822 radioService[slotId]->checkReturnStatus(retStatus);
4824 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4830 int radio::writeSmsToSimResponse(int slotId,
4831 int responseType, int serial, RIL_Errno e,
4832 void *response, size_t responseLen) {
4834 RLOGD("writeSmsToSimResponse: serial %d", serial);
4837 if (radioService[slotId]->mRadioResponse != NULL) {
4838 RadioResponseInfo responseInfo = {};
4839 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4840 Return<void> retStatus
4841 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4842 radioService[slotId]->checkReturnStatus(retStatus);
4844 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4850 int radio::getAvailableBandModesResponse(int slotId,
4851 int responseType, int serial, RIL_Errno e, void *response,
4852 size_t responseLen) {
4854 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4857 if (radioService[slotId]->mRadioResponse != NULL) {
4858 RadioResponseInfo responseInfo = {};
4859 populateResponseInfo(responseInfo, serial, responseType, e);
4860 hidl_vec<RadioBandMode> modes;
4861 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
4862 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4863 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4865 int *pInt = (int *) response;
4866 int numInts = responseLen / sizeof(int);
4867 modes.resize(numInts);
4868 for (int i = 0; i < numInts; i++) {
4869 modes[i] = (RadioBandMode) pInt[i];
4872 Return<void> retStatus
4873 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4875 radioService[slotId]->checkReturnStatus(retStatus);
4877 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4884 int radio::sendEnvelopeResponse(int slotId,
4885 int responseType, int serial, RIL_Errno e,
4886 void *response, size_t responseLen) {
4888 RLOGD("sendEnvelopeResponse: serial %d", serial);
4891 if (radioService[slotId]->mRadioResponse != NULL) {
4892 RadioResponseInfo responseInfo = {};
4893 populateResponseInfo(responseInfo, serial, responseType, e);
4894 Return<void> retStatus
4895 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4896 convertCharPtrToHidlString((char *) response));
4897 radioService[slotId]->checkReturnStatus(retStatus);
4899 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4905 int radio::sendTerminalResponseToSimResponse(int slotId,
4906 int responseType, int serial, RIL_Errno e,
4907 void *response, size_t responseLen) {
4909 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4912 if (radioService[slotId]->mRadioResponse != NULL) {
4913 RadioResponseInfo responseInfo = {};
4914 populateResponseInfo(responseInfo, serial, responseType, e);
4915 Return<void> retStatus
4916 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4918 radioService[slotId]->checkReturnStatus(retStatus);
4920 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4927 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4928 int responseType, int serial,
4929 RIL_Errno e, void *response,
4930 size_t responseLen) {
4932 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4935 if (radioService[slotId]->mRadioResponse != NULL) {
4936 RadioResponseInfo responseInfo = {};
4937 populateResponseInfo(responseInfo, serial, responseType, e);
4938 Return<void> retStatus
4939 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4941 radioService[slotId]->checkReturnStatus(retStatus);
4943 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4950 int radio::explicitCallTransferResponse(int slotId,
4951 int responseType, int serial, RIL_Errno e,
4952 void *response, size_t responseLen) {
4954 RLOGD("explicitCallTransferResponse: serial %d", serial);
4957 if (radioService[slotId]->mRadioResponse != NULL) {
4958 RadioResponseInfo responseInfo = {};
4959 populateResponseInfo(responseInfo, serial, responseType, e);
4960 Return<void> retStatus
4961 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4962 radioService[slotId]->checkReturnStatus(retStatus);
4964 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4971 int radio::setPreferredNetworkTypeResponse(int slotId,
4972 int responseType, int serial, RIL_Errno e,
4973 void *response, size_t responseLen) {
4975 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4978 if (radioService[slotId]->mRadioResponse != NULL) {
4979 RadioResponseInfo responseInfo = {};
4980 populateResponseInfo(responseInfo, serial, responseType, e);
4981 Return<void> retStatus
4982 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4984 radioService[slotId]->checkReturnStatus(retStatus);
4986 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4994 int radio::getPreferredNetworkTypeResponse(int slotId,
4995 int responseType, int serial, RIL_Errno e,
4996 void *response, size_t responseLen) {
4998 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
5001 if (radioService[slotId]->mRadioResponse != NULL) {
5002 RadioResponseInfo responseInfo = {};
5003 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5004 Return<void> retStatus
5005 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
5006 responseInfo, (PreferredNetworkType) ret);
5007 radioService[slotId]->checkReturnStatus(retStatus);
5009 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
5016 int radio::getNeighboringCidsResponse(int slotId,
5017 int responseType, int serial, RIL_Errno e,
5018 void *response, size_t responseLen) {
5020 RLOGD("getNeighboringCidsResponse: serial %d", serial);
5023 if (radioService[slotId]->mRadioResponse != NULL) {
5024 RadioResponseInfo responseInfo = {};
5025 populateResponseInfo(responseInfo, serial, responseType, e);
5026 hidl_vec<NeighboringCell> cells;
5028 if ((response == NULL && responseLen != 0)
5029 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
5030 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
5031 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5033 int num = responseLen / sizeof(RIL_NeighboringCell *);
5035 for (int i = 0 ; i < num; i++) {
5036 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
5037 cells[i].cid = convertCharPtrToHidlString(resp->cid);
5038 cells[i].rssi = resp->rssi;
5042 Return<void> retStatus
5043 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
5045 radioService[slotId]->checkReturnStatus(retStatus);
5047 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
5054 int radio::setLocationUpdatesResponse(int slotId,
5055 int responseType, int serial, RIL_Errno e,
5056 void *response, size_t responseLen) {
5058 RLOGD("setLocationUpdatesResponse: serial %d", serial);
5061 if (radioService[slotId]->mRadioResponse != NULL) {
5062 RadioResponseInfo responseInfo = {};
5063 populateResponseInfo(responseInfo, serial, responseType, e);
5064 Return<void> retStatus
5065 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
5066 radioService[slotId]->checkReturnStatus(retStatus);
5068 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
5075 int radio::setCdmaSubscriptionSourceResponse(int slotId,
5076 int responseType, int serial, RIL_Errno e,
5077 void *response, size_t responseLen) {
5079 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
5082 if (radioService[slotId]->mRadioResponse != NULL) {
5083 RadioResponseInfo responseInfo = {};
5084 populateResponseInfo(responseInfo, serial, responseType, e);
5085 Return<void> retStatus
5086 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
5088 radioService[slotId]->checkReturnStatus(retStatus);
5090 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5097 int radio::setCdmaRoamingPreferenceResponse(int slotId,
5098 int responseType, int serial, RIL_Errno e,
5099 void *response, size_t responseLen) {
5101 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
5104 if (radioService[slotId]->mRadioResponse != NULL) {
5105 RadioResponseInfo responseInfo = {};
5106 populateResponseInfo(responseInfo, serial, responseType, e);
5107 Return<void> retStatus
5108 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
5110 radioService[slotId]->checkReturnStatus(retStatus);
5112 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5119 int radio::getCdmaRoamingPreferenceResponse(int slotId,
5120 int responseType, int serial, RIL_Errno e,
5121 void *response, size_t responseLen) {
5123 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
5126 if (radioService[slotId]->mRadioResponse != NULL) {
5127 RadioResponseInfo responseInfo = {};
5128 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5129 Return<void> retStatus
5130 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
5131 responseInfo, (CdmaRoamingType) ret);
5132 radioService[slotId]->checkReturnStatus(retStatus);
5134 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5141 int radio::setTTYModeResponse(int slotId,
5142 int responseType, int serial, RIL_Errno e,
5143 void *response, size_t responseLen) {
5145 RLOGD("setTTYModeResponse: serial %d", serial);
5148 if (radioService[slotId]->mRadioResponse != NULL) {
5149 RadioResponseInfo responseInfo = {};
5150 populateResponseInfo(responseInfo, serial, responseType, e);
5151 Return<void> retStatus
5152 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
5153 radioService[slotId]->checkReturnStatus(retStatus);
5155 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5161 int radio::getTTYModeResponse(int slotId,
5162 int responseType, int serial, RIL_Errno e,
5163 void *response, size_t responseLen) {
5165 RLOGD("getTTYModeResponse: serial %d", serial);
5168 if (radioService[slotId]->mRadioResponse != NULL) {
5169 RadioResponseInfo responseInfo = {};
5170 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5171 Return<void> retStatus
5172 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
5174 radioService[slotId]->checkReturnStatus(retStatus);
5176 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5182 int radio::setPreferredVoicePrivacyResponse(int slotId,
5183 int responseType, int serial, RIL_Errno e,
5184 void *response, size_t responseLen) {
5186 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
5189 if (radioService[slotId]->mRadioResponse != NULL) {
5190 RadioResponseInfo responseInfo = {};
5191 populateResponseInfo(responseInfo, serial, responseType, e);
5192 Return<void> retStatus
5193 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
5195 radioService[slotId]->checkReturnStatus(retStatus);
5197 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5204 int radio::getPreferredVoicePrivacyResponse(int slotId,
5205 int responseType, int serial, RIL_Errno e,
5206 void *response, size_t responseLen) {
5208 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
5211 if (radioService[slotId]->mRadioResponse != NULL) {
5212 RadioResponseInfo responseInfo = {};
5213 populateResponseInfo(responseInfo, serial, responseType, e);
5214 bool enable = false;
5215 int numInts = responseLen / sizeof(int);
5216 if (response == NULL || numInts != 1) {
5217 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
5218 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5220 int *pInt = (int *) response;
5221 enable = pInt[0] == 1 ? true : false;
5223 Return<void> retStatus
5224 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5225 responseInfo, enable);
5226 radioService[slotId]->checkReturnStatus(retStatus);
5228 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5235 int radio::sendCDMAFeatureCodeResponse(int slotId,
5236 int responseType, int serial, RIL_Errno e,
5237 void *response, size_t responseLen) {
5239 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5242 if (radioService[slotId]->mRadioResponse != NULL) {
5243 RadioResponseInfo responseInfo = {};
5244 populateResponseInfo(responseInfo, serial, responseType, e);
5245 Return<void> retStatus
5246 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5247 radioService[slotId]->checkReturnStatus(retStatus);
5249 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5256 int radio::sendBurstDtmfResponse(int slotId,
5257 int responseType, int serial, RIL_Errno e,
5258 void *response, size_t responseLen) {
5260 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5263 if (radioService[slotId]->mRadioResponse != NULL) {
5264 RadioResponseInfo responseInfo = {};
5265 populateResponseInfo(responseInfo, serial, responseType, e);
5266 Return<void> retStatus
5267 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5268 radioService[slotId]->checkReturnStatus(retStatus);
5270 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5276 int radio::sendCdmaSmsResponse(int slotId,
5277 int responseType, int serial, RIL_Errno e, void *response,
5278 size_t responseLen) {
5280 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5283 if (radioService[slotId]->mRadioResponse != NULL) {
5284 RadioResponseInfo responseInfo = {};
5285 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5288 Return<void> retStatus
5289 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5290 radioService[slotId]->checkReturnStatus(retStatus);
5292 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5298 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5299 int responseType, int serial, RIL_Errno e,
5300 void *response, size_t responseLen) {
5302 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5305 if (radioService[slotId]->mRadioResponse != NULL) {
5306 RadioResponseInfo responseInfo = {};
5307 populateResponseInfo(responseInfo, serial, responseType, e);
5308 Return<void> retStatus
5309 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5311 radioService[slotId]->checkReturnStatus(retStatus);
5313 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5320 int radio::getGsmBroadcastConfigResponse(int slotId,
5321 int responseType, int serial, RIL_Errno e,
5322 void *response, size_t responseLen) {
5324 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5327 if (radioService[slotId]->mRadioResponse != NULL) {
5328 RadioResponseInfo responseInfo = {};
5329 populateResponseInfo(responseInfo, serial, responseType, e);
5330 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5332 if ((response == NULL && responseLen != 0)
5333 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5334 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5335 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5337 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5338 configs.resize(num);
5339 for (int i = 0 ; i < num; i++) {
5340 RIL_GSM_BroadcastSmsConfigInfo *resp =
5341 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5342 configs[i].fromServiceId = resp->fromServiceId;
5343 configs[i].toServiceId = resp->toServiceId;
5344 configs[i].fromCodeScheme = resp->fromCodeScheme;
5345 configs[i].toCodeScheme = resp->toCodeScheme;
5346 configs[i].selected = resp->selected == 1 ? true : false;
5350 Return<void> retStatus
5351 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5353 radioService[slotId]->checkReturnStatus(retStatus);
5355 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5362 int radio::setGsmBroadcastConfigResponse(int slotId,
5363 int responseType, int serial, RIL_Errno e,
5364 void *response, size_t responseLen) {
5366 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5369 if (radioService[slotId]->mRadioResponse != NULL) {
5370 RadioResponseInfo responseInfo = {};
5371 populateResponseInfo(responseInfo, serial, responseType, e);
5372 Return<void> retStatus
5373 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5374 radioService[slotId]->checkReturnStatus(retStatus);
5376 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5383 int radio::setGsmBroadcastActivationResponse(int slotId,
5384 int responseType, int serial, RIL_Errno e,
5385 void *response, size_t responseLen) {
5387 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5390 if (radioService[slotId]->mRadioResponse != NULL) {
5391 RadioResponseInfo responseInfo = {};
5392 populateResponseInfo(responseInfo, serial, responseType, e);
5393 Return<void> retStatus
5394 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5396 radioService[slotId]->checkReturnStatus(retStatus);
5398 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5405 int radio::getCdmaBroadcastConfigResponse(int slotId,
5406 int responseType, int serial, RIL_Errno e,
5407 void *response, size_t responseLen) {
5409 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5412 if (radioService[slotId]->mRadioResponse != NULL) {
5413 RadioResponseInfo responseInfo = {};
5414 populateResponseInfo(responseInfo, serial, responseType, e);
5415 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5417 if ((response == NULL && responseLen != 0)
5418 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5419 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5420 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5422 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5423 configs.resize(num);
5424 for (int i = 0 ; i < num; i++) {
5425 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5426 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5427 configs[i].serviceCategory = resp->service_category;
5428 configs[i].language = resp->language;
5429 configs[i].selected = resp->selected == 1 ? true : false;
5433 Return<void> retStatus
5434 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5436 radioService[slotId]->checkReturnStatus(retStatus);
5438 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5445 int radio::setCdmaBroadcastConfigResponse(int slotId,
5446 int responseType, int serial, RIL_Errno e,
5447 void *response, size_t responseLen) {
5449 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5452 if (radioService[slotId]->mRadioResponse != NULL) {
5453 RadioResponseInfo responseInfo = {};
5454 populateResponseInfo(responseInfo, serial, responseType, e);
5455 Return<void> retStatus
5456 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5458 radioService[slotId]->checkReturnStatus(retStatus);
5460 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5467 int radio::setCdmaBroadcastActivationResponse(int slotId,
5468 int responseType, int serial, RIL_Errno e,
5469 void *response, size_t responseLen) {
5471 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5474 if (radioService[slotId]->mRadioResponse != NULL) {
5475 RadioResponseInfo responseInfo = {};
5476 populateResponseInfo(responseInfo, serial, responseType, e);
5477 Return<void> retStatus
5478 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5480 radioService[slotId]->checkReturnStatus(retStatus);
5482 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5489 int radio::getCDMASubscriptionResponse(int slotId,
5490 int responseType, int serial, RIL_Errno e, void *response,
5491 size_t responseLen) {
5493 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5496 if (radioService[slotId]->mRadioResponse != NULL) {
5497 RadioResponseInfo responseInfo = {};
5498 populateResponseInfo(responseInfo, serial, responseType, e);
5500 int numStrings = responseLen / sizeof(char *);
5501 hidl_string emptyString;
5502 if (response == NULL || numStrings != 5) {
5503 RLOGE("getOperatorResponse Invalid response: NULL");
5504 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5505 Return<void> retStatus
5506 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5507 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5508 radioService[slotId]->checkReturnStatus(retStatus);
5510 char **resp = (char **) response;
5511 Return<void> retStatus
5512 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5514 convertCharPtrToHidlString(resp[0]),
5515 convertCharPtrToHidlString(resp[1]),
5516 convertCharPtrToHidlString(resp[2]),
5517 convertCharPtrToHidlString(resp[3]),
5518 convertCharPtrToHidlString(resp[4]));
5519 radioService[slotId]->checkReturnStatus(retStatus);
5522 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5529 int radio::writeSmsToRuimResponse(int slotId,
5530 int responseType, int serial, RIL_Errno e,
5531 void *response, size_t responseLen) {
5533 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5536 if (radioService[slotId]->mRadioResponse != NULL) {
5537 RadioResponseInfo responseInfo = {};
5538 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5539 Return<void> retStatus
5540 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5541 radioService[slotId]->checkReturnStatus(retStatus);
5543 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5549 int radio::deleteSmsOnRuimResponse(int slotId,
5550 int responseType, int serial, RIL_Errno e,
5551 void *response, size_t responseLen) {
5553 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5556 if (radioService[slotId]->mRadioResponse != NULL) {
5557 RadioResponseInfo responseInfo = {};
5558 populateResponseInfo(responseInfo, serial, responseType, e);
5559 Return<void> retStatus
5560 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5561 radioService[slotId]->checkReturnStatus(retStatus);
5563 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5569 int radio::getDeviceIdentityResponse(int slotId,
5570 int responseType, int serial, RIL_Errno e, void *response,
5571 size_t responseLen) {
5573 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5576 if (radioService[slotId]->mRadioResponse != NULL) {
5577 RadioResponseInfo responseInfo = {};
5578 populateResponseInfo(responseInfo, serial, responseType, e);
5580 int numStrings = responseLen / sizeof(char *);
5581 hidl_string emptyString;
5582 if (response == NULL || numStrings != 4) {
5583 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5584 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5585 Return<void> retStatus
5586 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5587 emptyString, emptyString, emptyString, emptyString);
5588 radioService[slotId]->checkReturnStatus(retStatus);
5590 char **resp = (char **) response;
5591 Return<void> retStatus
5592 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5593 convertCharPtrToHidlString(resp[0]),
5594 convertCharPtrToHidlString(resp[1]),
5595 convertCharPtrToHidlString(resp[2]),
5596 convertCharPtrToHidlString(resp[3]));
5597 radioService[slotId]->checkReturnStatus(retStatus);
5600 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5607 int radio::exitEmergencyCallbackModeResponse(int slotId,
5608 int responseType, int serial, RIL_Errno e,
5609 void *response, size_t responseLen) {
5611 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5614 if (radioService[slotId]->mRadioResponse != NULL) {
5615 RadioResponseInfo responseInfo = {};
5616 populateResponseInfo(responseInfo, serial, responseType, e);
5617 Return<void> retStatus
5618 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5620 radioService[slotId]->checkReturnStatus(retStatus);
5622 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5629 int radio::getSmscAddressResponse(int slotId,
5630 int responseType, int serial, RIL_Errno e,
5631 void *response, size_t responseLen) {
5633 RLOGD("getSmscAddressResponse: serial %d", serial);
5636 if (radioService[slotId]->mRadioResponse != NULL) {
5637 RadioResponseInfo responseInfo = {};
5638 populateResponseInfo(responseInfo, serial, responseType, e);
5639 Return<void> retStatus
5640 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5641 convertCharPtrToHidlString((char *) response));
5642 radioService[slotId]->checkReturnStatus(retStatus);
5644 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5650 int radio::setSmscAddressResponse(int slotId,
5651 int responseType, int serial, RIL_Errno e,
5652 void *response, size_t responseLen) {
5654 RLOGD("setSmscAddressResponse: serial %d", serial);
5657 if (radioService[slotId]->mRadioResponse != NULL) {
5658 RadioResponseInfo responseInfo = {};
5659 populateResponseInfo(responseInfo, serial, responseType, e);
5660 Return<void> retStatus
5661 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5662 radioService[slotId]->checkReturnStatus(retStatus);
5664 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5670 int radio::reportSmsMemoryStatusResponse(int slotId,
5671 int responseType, int serial, RIL_Errno e,
5672 void *response, size_t responseLen) {
5674 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5677 if (radioService[slotId]->mRadioResponse != NULL) {
5678 RadioResponseInfo responseInfo = {};
5679 populateResponseInfo(responseInfo, serial, responseType, e);
5680 Return<void> retStatus
5681 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5682 radioService[slotId]->checkReturnStatus(retStatus);
5684 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5691 int radio::reportStkServiceIsRunningResponse(int slotId,
5692 int responseType, int serial, RIL_Errno e,
5693 void *response, size_t responseLen) {
5695 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5698 if (radioService[slotId]->mRadioResponse != NULL) {
5699 RadioResponseInfo responseInfo = {};
5700 populateResponseInfo(responseInfo, serial, responseType, e);
5701 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5702 reportStkServiceIsRunningResponse(responseInfo);
5703 radioService[slotId]->checkReturnStatus(retStatus);
5705 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5712 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5713 int responseType, int serial, RIL_Errno e,
5714 void *response, size_t responseLen) {
5716 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5719 if (radioService[slotId]->mRadioResponse != NULL) {
5720 RadioResponseInfo responseInfo = {};
5721 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5722 Return<void> retStatus
5723 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5724 responseInfo, (CdmaSubscriptionSource) ret);
5725 radioService[slotId]->checkReturnStatus(retStatus);
5727 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5734 int radio::requestIsimAuthenticationResponse(int slotId,
5735 int responseType, int serial, RIL_Errno e,
5736 void *response, size_t responseLen) {
5738 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5741 if (radioService[slotId]->mRadioResponse != NULL) {
5742 RadioResponseInfo responseInfo = {};
5743 populateResponseInfo(responseInfo, serial, responseType, e);
5744 Return<void> retStatus
5745 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5747 convertCharPtrToHidlString((char *) response));
5748 radioService[slotId]->checkReturnStatus(retStatus);
5750 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5757 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5759 int serial, RIL_Errno e, void *response,
5760 size_t responseLen) {
5762 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5765 if (radioService[slotId]->mRadioResponse != NULL) {
5766 RadioResponseInfo responseInfo = {};
5767 populateResponseInfo(responseInfo, serial, responseType, e);
5768 Return<void> retStatus
5769 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5771 radioService[slotId]->checkReturnStatus(retStatus);
5773 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5780 int radio::sendEnvelopeWithStatusResponse(int slotId,
5781 int responseType, int serial, RIL_Errno e, void *response,
5782 size_t responseLen) {
5784 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5787 if (radioService[slotId]->mRadioResponse != NULL) {
5788 RadioResponseInfo responseInfo = {};
5789 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5790 response, responseLen);
5792 Return<void> retStatus
5793 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5795 radioService[slotId]->checkReturnStatus(retStatus);
5797 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5804 int radio::getVoiceRadioTechnologyResponse(int slotId,
5805 int responseType, int serial, RIL_Errno e,
5806 void *response, size_t responseLen) {
5808 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5811 if (radioService[slotId]->mRadioResponse != NULL) {
5812 RadioResponseInfo responseInfo = {};
5813 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5814 Return<void> retStatus
5815 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5816 responseInfo, (RadioTechnology) ret);
5817 radioService[slotId]->checkReturnStatus(retStatus);
5819 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5826 int radio::getCellInfoListResponse(int slotId,
5828 int serial, RIL_Errno e, void *response,
5829 size_t responseLen) {
5831 RLOGD("getCellInfoListResponse: serial %d", serial);
5834 if (radioService[slotId]->mRadioResponse != NULL) {
5835 RadioResponseInfo responseInfo = {};
5836 populateResponseInfo(responseInfo, serial, responseType, e);
5838 hidl_vec<CellInfo> ret;
5839 if ((response == NULL && responseLen != 0)
5840 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5841 RLOGE("getCellInfoListResponse: Invalid response");
5842 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5844 convertRilCellInfoListToHal(response, responseLen, ret);
5847 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5849 radioService[slotId]->checkReturnStatus(retStatus);
5851 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5857 int radio::setCellInfoListRateResponse(int slotId,
5859 int serial, RIL_Errno e, void *response,
5860 size_t responseLen) {
5862 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5865 if (radioService[slotId]->mRadioResponse != NULL) {
5866 RadioResponseInfo responseInfo = {};
5867 populateResponseInfo(responseInfo, serial, responseType, e);
5868 Return<void> retStatus
5869 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5870 radioService[slotId]->checkReturnStatus(retStatus);
5872 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5879 int radio::setInitialAttachApnResponse(int slotId,
5880 int responseType, int serial, RIL_Errno e,
5881 void *response, size_t responseLen) {
5883 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5886 if (radioService[slotId]->mRadioResponse != NULL) {
5887 RadioResponseInfo responseInfo = {};
5888 populateResponseInfo(responseInfo, serial, responseType, e);
5889 Return<void> retStatus
5890 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5891 radioService[slotId]->checkReturnStatus(retStatus);
5893 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5900 int radio::getImsRegistrationStateResponse(int slotId,
5901 int responseType, int serial, RIL_Errno e,
5902 void *response, size_t responseLen) {
5904 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5907 if (radioService[slotId]->mRadioResponse != NULL) {
5908 RadioResponseInfo responseInfo = {};
5909 populateResponseInfo(responseInfo, serial, responseType, e);
5910 bool isRegistered = false;
5912 int numInts = responseLen / sizeof(int);
5913 if (response == NULL || numInts != 2) {
5914 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5915 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5917 int *pInt = (int *) response;
5918 isRegistered = pInt[0] == 1 ? true : false;
5919 ratFamily = pInt[1];
5921 Return<void> retStatus
5922 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5923 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5924 radioService[slotId]->checkReturnStatus(retStatus);
5926 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5933 int radio::sendImsSmsResponse(int slotId,
5934 int responseType, int serial, RIL_Errno e, void *response,
5935 size_t responseLen) {
5937 RLOGD("sendImsSmsResponse: serial %d", serial);
5940 if (radioService[slotId]->mRadioResponse != NULL) {
5941 RadioResponseInfo responseInfo = {};
5942 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5945 Return<void> retStatus
5946 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5947 radioService[slotId]->checkReturnStatus(retStatus);
5949 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5955 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5956 int responseType, int serial, RIL_Errno e,
5957 void *response, size_t responseLen) {
5959 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5962 if (radioService[slotId]->mRadioResponse != NULL) {
5963 RadioResponseInfo responseInfo = {};
5964 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5967 Return<void> retStatus
5968 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5969 responseInfo, result);
5970 radioService[slotId]->checkReturnStatus(retStatus);
5972 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5979 int radio::iccOpenLogicalChannelResponse(int slotId,
5980 int responseType, int serial, RIL_Errno e, void *response,
5981 size_t responseLen) {
5983 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5986 if (radioService[slotId]->mRadioResponse != NULL) {
5987 RadioResponseInfo responseInfo = {};
5988 populateResponseInfo(responseInfo, serial, responseType, e);
5990 hidl_vec<int8_t> selectResponse;
5991 int numInts = responseLen / sizeof(int);
5992 if (response == NULL || responseLen % sizeof(int) != 0) {
5993 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5994 if (response != NULL) {
5995 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5998 int *pInt = (int *) response;
5999 channelId = pInt[0];
6000 selectResponse.resize(numInts - 1);
6001 for (int i = 1; i < numInts; i++) {
6002 selectResponse[i - 1] = (int8_t) pInt[i];
6005 Return<void> retStatus
6006 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
6007 channelId, selectResponse);
6008 radioService[slotId]->checkReturnStatus(retStatus);
6010 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
6017 int radio::iccCloseLogicalChannelResponse(int slotId,
6018 int responseType, int serial, RIL_Errno e,
6019 void *response, size_t responseLen) {
6021 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
6024 if (radioService[slotId]->mRadioResponse != NULL) {
6025 RadioResponseInfo responseInfo = {};
6026 populateResponseInfo(responseInfo, serial, responseType, e);
6027 Return<void> retStatus
6028 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
6030 radioService[slotId]->checkReturnStatus(retStatus);
6032 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
6039 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
6040 int responseType, int serial, RIL_Errno e,
6041 void *response, size_t responseLen) {
6043 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
6046 if (radioService[slotId]->mRadioResponse != NULL) {
6047 RadioResponseInfo responseInfo = {};
6048 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6051 Return<void> retStatus
6052 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
6053 responseInfo, result);
6054 radioService[slotId]->checkReturnStatus(retStatus);
6056 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
6063 int radio::nvReadItemResponse(int slotId,
6064 int responseType, int serial, RIL_Errno e,
6065 void *response, size_t responseLen) {
6067 RLOGD("nvReadItemResponse: serial %d", serial);
6070 if (radioService[slotId]->mRadioResponse != NULL) {
6071 RadioResponseInfo responseInfo = {};
6072 populateResponseInfo(responseInfo, serial, responseType, e);
6073 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
6075 convertCharPtrToHidlString((char *) response));
6076 radioService[slotId]->checkReturnStatus(retStatus);
6078 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6084 int radio::nvWriteItemResponse(int slotId,
6085 int responseType, int serial, RIL_Errno e,
6086 void *response, size_t responseLen) {
6088 RLOGD("nvWriteItemResponse: serial %d", serial);
6091 if (radioService[slotId]->mRadioResponse != NULL) {
6092 RadioResponseInfo responseInfo = {};
6093 populateResponseInfo(responseInfo, serial, responseType, e);
6094 Return<void> retStatus
6095 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
6096 radioService[slotId]->checkReturnStatus(retStatus);
6098 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6104 int radio::nvWriteCdmaPrlResponse(int slotId,
6105 int responseType, int serial, RIL_Errno e,
6106 void *response, size_t responseLen) {
6108 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
6111 if (radioService[slotId]->mRadioResponse != NULL) {
6112 RadioResponseInfo responseInfo = {};
6113 populateResponseInfo(responseInfo, serial, responseType, e);
6114 Return<void> retStatus
6115 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
6116 radioService[slotId]->checkReturnStatus(retStatus);
6118 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6124 int radio::nvResetConfigResponse(int slotId,
6125 int responseType, int serial, RIL_Errno e,
6126 void *response, size_t responseLen) {
6128 RLOGD("nvResetConfigResponse: serial %d", serial);
6131 if (radioService[slotId]->mRadioResponse != NULL) {
6132 RadioResponseInfo responseInfo = {};
6133 populateResponseInfo(responseInfo, serial, responseType, e);
6134 Return<void> retStatus
6135 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
6136 radioService[slotId]->checkReturnStatus(retStatus);
6138 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6144 int radio::setUiccSubscriptionResponse(int slotId,
6145 int responseType, int serial, RIL_Errno e,
6146 void *response, size_t responseLen) {
6148 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
6151 if (radioService[slotId]->mRadioResponse != NULL) {
6152 RadioResponseInfo responseInfo = {};
6153 populateResponseInfo(responseInfo, serial, responseType, e);
6154 Return<void> retStatus
6155 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
6156 radioService[slotId]->checkReturnStatus(retStatus);
6158 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
6165 int radio::setDataAllowedResponse(int slotId,
6166 int responseType, int serial, RIL_Errno e,
6167 void *response, size_t responseLen) {
6169 RLOGD("setDataAllowedResponse: serial %d", serial);
6172 if (radioService[slotId]->mRadioResponse != NULL) {
6173 RadioResponseInfo responseInfo = {};
6174 populateResponseInfo(responseInfo, serial, responseType, e);
6175 Return<void> retStatus
6176 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
6177 radioService[slotId]->checkReturnStatus(retStatus);
6179 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6185 int radio::getHardwareConfigResponse(int slotId,
6186 int responseType, int serial, RIL_Errno e,
6187 void *response, size_t responseLen) {
6189 RLOGD("getHardwareConfigResponse: serial %d", serial);
6192 if (radioService[slotId]->mRadioResponse != NULL) {
6193 RadioResponseInfo responseInfo = {};
6194 populateResponseInfo(responseInfo, serial, responseType, e);
6196 hidl_vec<HardwareConfig> result;
6197 if ((response == NULL && responseLen != 0)
6198 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
6199 RLOGE("hardwareConfigChangedInd: invalid response");
6200 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6202 convertRilHardwareConfigListToHal(response, responseLen, result);
6205 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
6206 responseInfo, result);
6207 radioService[slotId]->checkReturnStatus(retStatus);
6209 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6215 int radio::requestIccSimAuthenticationResponse(int slotId,
6216 int responseType, int serial, RIL_Errno e,
6217 void *response, size_t responseLen) {
6219 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6222 if (radioService[slotId]->mRadioResponse != NULL) {
6223 RadioResponseInfo responseInfo = {};
6224 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6227 Return<void> retStatus
6228 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6229 responseInfo, result);
6230 radioService[slotId]->checkReturnStatus(retStatus);
6232 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6239 int radio::setDataProfileResponse(int slotId,
6240 int responseType, int serial, RIL_Errno e,
6241 void *response, size_t responseLen) {
6243 RLOGD("setDataProfileResponse: serial %d", serial);
6246 if (radioService[slotId]->mRadioResponse != NULL) {
6247 RadioResponseInfo responseInfo = {};
6248 populateResponseInfo(responseInfo, serial, responseType, e);
6249 Return<void> retStatus
6250 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6251 radioService[slotId]->checkReturnStatus(retStatus);
6253 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6259 int radio::requestShutdownResponse(int slotId,
6260 int responseType, int serial, RIL_Errno e,
6261 void *response, size_t responseLen) {
6263 RLOGD("requestShutdownResponse: serial %d", serial);
6266 if (radioService[slotId]->mRadioResponse != NULL) {
6267 RadioResponseInfo responseInfo = {};
6268 populateResponseInfo(responseInfo, serial, responseType, e);
6269 Return<void> retStatus
6270 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6271 radioService[slotId]->checkReturnStatus(retStatus);
6273 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6279 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6280 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6281 populateResponseInfo(responseInfo, serial, responseType, e);
6283 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6284 RLOGE("responseRadioCapability: Invalid response");
6285 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6286 rc.logicalModemUuid = hidl_string();
6288 convertRilRadioCapabilityToHal(response, responseLen, rc);
6292 int radio::getRadioCapabilityResponse(int slotId,
6293 int responseType, int serial, RIL_Errno e,
6294 void *response, size_t responseLen) {
6296 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6299 if (radioService[slotId]->mRadioResponse != NULL) {
6300 RadioResponseInfo responseInfo = {};
6301 RadioCapability result = {};
6302 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6304 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6305 responseInfo, result);
6306 radioService[slotId]->checkReturnStatus(retStatus);
6308 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6314 int radio::setRadioCapabilityResponse(int slotId,
6315 int responseType, int serial, RIL_Errno e,
6316 void *response, size_t responseLen) {
6318 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6321 if (radioService[slotId]->mRadioResponse != NULL) {
6322 RadioResponseInfo responseInfo = {};
6323 RadioCapability result = {};
6324 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6326 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6327 responseInfo, result);
6328 radioService[slotId]->checkReturnStatus(retStatus);
6330 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6336 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6337 RIL_Errno e, void *response, size_t responseLen) {
6338 populateResponseInfo(responseInfo, serial, responseType, e);
6339 LceStatusInfo result = {};
6341 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6342 RLOGE("Invalid response: NULL");
6343 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6345 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6346 result.lceStatus = (LceStatus) resp->lce_status;
6347 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6352 int radio::startLceServiceResponse(int slotId,
6353 int responseType, int serial, RIL_Errno e,
6354 void *response, size_t responseLen) {
6356 RLOGD("startLceServiceResponse: serial %d", serial);
6359 if (radioService[slotId]->mRadioResponse != NULL) {
6360 RadioResponseInfo responseInfo = {};
6361 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6362 response, responseLen);
6364 Return<void> retStatus
6365 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6367 radioService[slotId]->checkReturnStatus(retStatus);
6369 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6375 int radio::stopLceServiceResponse(int slotId,
6376 int responseType, int serial, RIL_Errno e,
6377 void *response, size_t responseLen) {
6379 RLOGD("stopLceServiceResponse: serial %d", serial);
6382 if (radioService[slotId]->mRadioResponse != NULL) {
6383 RadioResponseInfo responseInfo = {};
6384 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6385 response, responseLen);
6387 Return<void> retStatus
6388 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6390 radioService[slotId]->checkReturnStatus(retStatus);
6392 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6398 int radio::pullLceDataResponse(int slotId,
6399 int responseType, int serial, RIL_Errno e,
6400 void *response, size_t responseLen) {
6402 RLOGD("pullLceDataResponse: serial %d", serial);
6405 if (radioService[slotId]->mRadioResponse != NULL) {
6406 RadioResponseInfo responseInfo = {};
6407 populateResponseInfo(responseInfo, serial, responseType, e);
6409 LceDataInfo result = {};
6410 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6411 RLOGE("pullLceDataResponse: Invalid response");
6412 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6414 convertRilLceDataInfoToHal(response, responseLen, result);
6417 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6418 responseInfo, result);
6419 radioService[slotId]->checkReturnStatus(retStatus);
6421 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6427 int radio::getModemActivityInfoResponse(int slotId,
6428 int responseType, int serial, RIL_Errno e,
6429 void *response, size_t responseLen) {
6431 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6434 if (radioService[slotId]->mRadioResponse != NULL) {
6435 RadioResponseInfo responseInfo = {};
6436 populateResponseInfo(responseInfo, serial, responseType, e);
6437 ActivityStatsInfo info;
6438 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6439 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6440 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6442 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6443 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6444 info.idleModeTimeMs = resp->idle_mode_time_ms;
6445 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6446 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6448 info.rxModeTimeMs = resp->rx_mode_time_ms;
6451 Return<void> retStatus
6452 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6454 radioService[slotId]->checkReturnStatus(retStatus);
6456 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6463 int radio::setAllowedCarriersResponse(int slotId,
6464 int responseType, int serial, RIL_Errno e,
6465 void *response, size_t responseLen) {
6467 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6470 if (radioService[slotId]->mRadioResponse != NULL) {
6471 RadioResponseInfo responseInfo = {};
6472 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6473 Return<void> retStatus
6474 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6476 radioService[slotId]->checkReturnStatus(retStatus);
6478 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6485 int radio::getAllowedCarriersResponse(int slotId,
6486 int responseType, int serial, RIL_Errno e,
6487 void *response, size_t responseLen) {
6489 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6492 if (radioService[slotId]->mRadioResponse != NULL) {
6493 RadioResponseInfo responseInfo = {};
6494 populateResponseInfo(responseInfo, serial, responseType, e);
6495 CarrierRestrictions carrierInfo = {};
6496 bool allAllowed = true;
6497 if (response == NULL) {
6499 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6501 carrierInfo.allowedCarriers.resize(0);
6502 carrierInfo.excludedCarriers.resize(0);
6503 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6504 RLOGE("getAllowedCarriersResponse Invalid response");
6505 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6507 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6508 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6512 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6513 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6514 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6515 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6516 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6517 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6518 carrierInfo.allowedCarriers[i].matchData =
6519 convertCharPtrToHidlString(carrier->match_data);
6522 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6523 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6524 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6525 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6526 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6527 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6528 carrierInfo.excludedCarriers[i].matchData =
6529 convertCharPtrToHidlString(carrier->match_data);
6533 Return<void> retStatus
6534 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6535 allAllowed, carrierInfo);
6536 radioService[slotId]->checkReturnStatus(retStatus);
6538 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6545 int radio::sendDeviceStateResponse(int slotId,
6546 int responseType, int serial, RIL_Errno e,
6547 void *response, size_t responselen) {
6549 RLOGD("sendDeviceStateResponse: serial %d", serial);
6552 if (radioService[slotId]->mRadioResponse != NULL) {
6553 RadioResponseInfo responseInfo = {};
6554 populateResponseInfo(responseInfo, serial, responseType, e);
6555 Return<void> retStatus
6556 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6557 radioService[slotId]->checkReturnStatus(retStatus);
6559 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6565 int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
6566 int responseType, int serial, RIL_Errno e,
6567 void *response, size_t responseLen) {
6568 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
6569 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6570 RadioResponseInfo responseInfo = {};
6571 populateResponseInfo(responseInfo, serial, responseType, e);
6572 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6573 setCarrierInfoForImsiEncryptionResponse(responseInfo);
6574 radioService[slotId]->checkReturnStatus(retStatus);
6576 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponseV1_1 == "
6582 int radio::setIndicationFilterResponse(int slotId,
6583 int responseType, int serial, RIL_Errno e,
6584 void *response, size_t responselen) {
6586 RLOGD("setIndicationFilterResponse: serial %d", serial);
6589 if (radioService[slotId]->mRadioResponse != NULL) {
6590 RadioResponseInfo responseInfo = {};
6591 populateResponseInfo(responseInfo, serial, responseType, e);
6592 Return<void> retStatus
6593 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6594 radioService[slotId]->checkReturnStatus(retStatus);
6596 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6603 int radio::setSimCardPowerResponse(int slotId,
6604 int responseType, int serial, RIL_Errno e,
6605 void *response, size_t responseLen) {
6607 RLOGD("setSimCardPowerResponse: serial %d", serial);
6610 if (radioService[slotId]->mRadioResponse != NULL
6611 || radioService[slotId]->mRadioResponseV1_1 != NULL) {
6612 RadioResponseInfo responseInfo = {};
6613 populateResponseInfo(responseInfo, serial, responseType, e);
6614 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6615 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6616 setSimCardPowerResponse_1_1(responseInfo);
6617 radioService[slotId]->checkReturnStatus(retStatus);
6619 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_1 == NULL",
6621 Return<void> retStatus
6622 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6623 radioService[slotId]->checkReturnStatus(retStatus);
6626 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL && "
6627 "radioService[%d]->mRadioResponseV1_1 == NULL", slotId, slotId);
6632 int radio::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6633 void *response, size_t responseLen) {
6635 RLOGD("startNetworkScanResponse: serial %d", serial);
6638 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6639 RadioResponseInfo responseInfo = {};
6640 populateResponseInfo(responseInfo, serial, responseType, e);
6641 Return<void> retStatus
6642 = radioService[slotId]->mRadioResponseV1_1->startNetworkScanResponse(responseInfo);
6643 radioService[slotId]->checkReturnStatus(retStatus);
6645 RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6651 int radio::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6652 void *response, size_t responseLen) {
6654 RLOGD("stopNetworkScanResponse: serial %d", serial);
6657 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6658 RadioResponseInfo responseInfo = {};
6659 populateResponseInfo(responseInfo, serial, responseType, e);
6660 Return<void> retStatus
6661 = radioService[slotId]->mRadioResponseV1_1->stopNetworkScanResponse(responseInfo);
6662 radioService[slotId]->checkReturnStatus(retStatus);
6664 RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6670 void convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus *rilStatus,
6671 V1_1::KeepaliveStatus& halStatus) {
6672 halStatus.sessionHandle = rilStatus->sessionHandle;
6673 halStatus.code = static_cast<V1_1::KeepaliveStatusCode>(rilStatus->code);
6676 int radio::startKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
6677 void *response, size_t responseLen) {
6679 RLOGD("%s(): %d", __FUNCTION__, serial);
6681 RadioResponseInfo responseInfo = {};
6682 populateResponseInfo(responseInfo, serial, responseType, e);
6684 // If we don't have a radio service, there's nothing we can do
6685 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
6686 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
6690 V1_1::KeepaliveStatus ks = {};
6691 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
6692 RLOGE("%s: invalid response - %d", __FUNCTION__, static_cast<int>(e));
6693 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6695 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
6698 Return<void> retStatus =
6699 radioService[slotId]->mRadioResponseV1_1->startKeepaliveResponse(responseInfo, ks);
6700 radioService[slotId]->checkReturnStatus(retStatus);
6704 int radio::stopKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
6705 void *response, size_t responseLen) {
6707 RLOGD("%s(): %d", __FUNCTION__, serial);
6709 RadioResponseInfo responseInfo = {};
6710 populateResponseInfo(responseInfo, serial, responseType, e);
6712 // If we don't have a radio service, there's nothing we can do
6713 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
6714 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
6718 Return<void> retStatus =
6719 radioService[slotId]->mRadioResponseV1_1->stopKeepaliveResponse(responseInfo);
6720 radioService[slotId]->checkReturnStatus(retStatus);
6724 int radio::sendRequestRawResponse(int slotId,
6725 int responseType, int serial, RIL_Errno e,
6726 void *response, size_t responseLen) {
6728 RLOGD("sendRequestRawResponse: serial %d", serial);
6731 if (!kOemHookEnabled) return 0;
6733 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6734 RadioResponseInfo responseInfo = {};
6735 populateResponseInfo(responseInfo, serial, responseType, e);
6736 hidl_vec<uint8_t> data;
6738 if (response == NULL) {
6739 RLOGE("sendRequestRawResponse: Invalid response");
6740 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6742 data.setToExternal((uint8_t *) response, responseLen);
6744 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6745 sendRequestRawResponse(responseInfo, data);
6746 checkReturnStatus(slotId, retStatus, false);
6748 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6755 int radio::sendRequestStringsResponse(int slotId,
6756 int responseType, int serial, RIL_Errno e,
6757 void *response, size_t responseLen) {
6759 RLOGD("sendRequestStringsResponse: serial %d", serial);
6762 if (!kOemHookEnabled) return 0;
6764 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6765 RadioResponseInfo responseInfo = {};
6766 populateResponseInfo(responseInfo, serial, responseType, e);
6767 hidl_vec<hidl_string> data;
6769 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
6770 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6771 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6773 char **resp = (char **) response;
6774 int numStrings = responseLen / sizeof(char *);
6775 data.resize(numStrings);
6776 for (int i = 0; i < numStrings; i++) {
6777 data[i] = convertCharPtrToHidlString(resp[i]);
6780 Return<void> retStatus
6781 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6782 responseInfo, data);
6783 checkReturnStatus(slotId, retStatus, false);
6785 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6792 /***************************************************************************************************
6793 * INDICATION FUNCTIONS
6794 * The below function handle unsolicited messages coming from the Radio
6795 * (messages for which there is no pending request)
6796 **************************************************************************************************/
6798 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6799 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6800 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6803 int radio::radioStateChangedInd(int slotId,
6804 int indicationType, int token, RIL_Errno e, void *response,
6805 size_t responseLen) {
6806 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6807 RadioState radioState =
6808 (RadioState) CALL_ONSTATEREQUEST(slotId);
6809 RLOGD("radioStateChangedInd: radioState %d", radioState);
6810 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6811 convertIntToRadioIndicationType(indicationType), radioState);
6812 radioService[slotId]->checkReturnStatus(retStatus);
6814 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6820 int radio::callStateChangedInd(int slotId,
6821 int indicationType, int token, RIL_Errno e, void *response,
6822 size_t responseLen) {
6823 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6825 RLOGD("callStateChangedInd");
6827 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6828 convertIntToRadioIndicationType(indicationType));
6829 radioService[slotId]->checkReturnStatus(retStatus);
6831 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6837 int radio::networkStateChangedInd(int slotId,
6838 int indicationType, int token, RIL_Errno e, void *response,
6839 size_t responseLen) {
6840 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6842 RLOGD("networkStateChangedInd");
6844 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6845 convertIntToRadioIndicationType(indicationType));
6846 radioService[slotId]->checkReturnStatus(retStatus);
6848 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6855 uint8_t hexCharToInt(uint8_t c) {
6856 if (c >= '0' && c <= '9') return (c - '0');
6857 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6858 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6860 return INVALID_HEX_CHAR;
6863 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6864 if (responseLen % 2 != 0) {
6868 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6869 if (bytes == NULL) {
6870 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6873 uint8_t *hexString = (uint8_t *)response;
6875 for (size_t i = 0; i < responseLen; i += 2) {
6876 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6877 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6879 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6880 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6881 hexString[i], hexString[i + 1]);
6885 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6891 int radio::newSmsInd(int slotId, int indicationType,
6892 int token, RIL_Errno e, void *response, size_t responseLen) {
6893 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6894 if (response == NULL || responseLen == 0) {
6895 RLOGE("newSmsInd: invalid response");
6899 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6900 if (bytes == NULL) {
6901 RLOGE("newSmsInd: convertHexStringToBytes failed");
6905 hidl_vec<uint8_t> pdu;
6906 pdu.setToExternal(bytes, responseLen/2);
6910 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6911 convertIntToRadioIndicationType(indicationType), pdu);
6912 radioService[slotId]->checkReturnStatus(retStatus);
6915 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6921 int radio::newSmsStatusReportInd(int slotId,
6922 int indicationType, int token, RIL_Errno e, void *response,
6923 size_t responseLen) {
6924 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6925 if (response == NULL || responseLen == 0) {
6926 RLOGE("newSmsStatusReportInd: invalid response");
6930 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6931 if (bytes == NULL) {
6932 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6936 hidl_vec<uint8_t> pdu;
6937 pdu.setToExternal(bytes, responseLen/2);
6939 RLOGD("newSmsStatusReportInd");
6941 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6942 convertIntToRadioIndicationType(indicationType), pdu);
6943 radioService[slotId]->checkReturnStatus(retStatus);
6946 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6952 int radio::newSmsOnSimInd(int slotId, int indicationType,
6953 int token, RIL_Errno e, void *response, size_t responseLen) {
6954 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6955 if (response == NULL || responseLen != sizeof(int)) {
6956 RLOGE("newSmsOnSimInd: invalid response");
6959 int32_t recordNumber = ((int32_t *) response)[0];
6961 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6963 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6964 convertIntToRadioIndicationType(indicationType), recordNumber);
6965 radioService[slotId]->checkReturnStatus(retStatus);
6967 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6973 int radio::onUssdInd(int slotId, int indicationType,
6974 int token, RIL_Errno e, void *response, size_t responseLen) {
6975 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6976 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6977 RLOGE("onUssdInd: invalid response");
6980 char **strings = (char **) response;
6981 char *mode = strings[0];
6982 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6983 UssdModeType modeType = (UssdModeType) atoi(mode);
6985 RLOGD("onUssdInd: mode %s", mode);
6987 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6988 convertIntToRadioIndicationType(indicationType), modeType, msg);
6989 radioService[slotId]->checkReturnStatus(retStatus);
6991 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6997 int radio::nitzTimeReceivedInd(int slotId,
6998 int indicationType, int token, RIL_Errno e, void *response,
6999 size_t responseLen) {
7000 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7001 if (response == NULL || responseLen == 0) {
7002 RLOGE("nitzTimeReceivedInd: invalid response");
7005 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
7007 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
7008 nitzTimeReceived[slotId]);
7010 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
7011 convertIntToRadioIndicationType(indicationType), nitzTime,
7012 nitzTimeReceived[slotId]);
7013 radioService[slotId]->checkReturnStatus(retStatus);
7015 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7022 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
7023 SignalStrength& signalStrength) {
7024 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
7026 // Fixup LTE for backwards compatibility
7027 // signalStrength: -1 -> 99
7028 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
7029 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
7031 // rsrp: -1 -> INT_MAX all other negative value to positive.
7033 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
7034 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
7035 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
7036 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
7038 // rsrq: -1 -> INT_MAX
7039 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
7040 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
7042 // Not remapping rssnr is already using INT_MAX
7043 // cqi: -1 -> INT_MAX
7044 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
7045 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
7048 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
7049 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
7050 // RIL_SignalStrength_v10 not support gw.timingAdvance. Set to INT_MAX as
7052 signalStrength.gw.timingAdvance = INT_MAX;
7054 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
7055 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
7056 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
7057 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
7058 signalStrength.evdo.signalNoiseRatio =
7059 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
7060 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
7061 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
7062 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
7063 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
7064 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
7065 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
7066 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
7069 int radio::currentSignalStrengthInd(int slotId,
7070 int indicationType, int token, RIL_Errno e,
7071 void *response, size_t responseLen) {
7072 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7073 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
7074 RLOGE("currentSignalStrengthInd: invalid response");
7078 SignalStrength signalStrength = {};
7079 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
7082 RLOGD("currentSignalStrengthInd");
7084 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
7085 convertIntToRadioIndicationType(indicationType), signalStrength);
7086 radioService[slotId]->checkReturnStatus(retStatus);
7088 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
7095 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
7096 SetupDataCallResult& dcResult) {
7097 dcResult.status = (DataCallFailCause) dcResponse->status;
7098 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
7099 dcResult.cid = dcResponse->cid;
7100 dcResult.active = dcResponse->active;
7101 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
7102 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
7103 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
7104 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
7105 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
7106 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
7107 dcResult.mtu = dcResponse->mtu;
7110 void convertRilDataCallListToHal(void *response, size_t responseLen,
7111 hidl_vec<SetupDataCallResult>& dcResultList) {
7112 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
7114 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
7115 dcResultList.resize(num);
7116 for (int i = 0; i < num; i++) {
7117 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
7121 int radio::dataCallListChangedInd(int slotId,
7122 int indicationType, int token, RIL_Errno e, void *response,
7123 size_t responseLen) {
7124 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7125 if ((response == NULL && responseLen != 0)
7126 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
7127 RLOGE("dataCallListChangedInd: invalid response");
7130 hidl_vec<SetupDataCallResult> dcList;
7131 convertRilDataCallListToHal(response, responseLen, dcList);
7133 RLOGD("dataCallListChangedInd");
7135 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
7136 convertIntToRadioIndicationType(indicationType), dcList);
7137 radioService[slotId]->checkReturnStatus(retStatus);
7139 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7145 int radio::suppSvcNotifyInd(int slotId, int indicationType,
7146 int token, RIL_Errno e, void *response, size_t responseLen) {
7147 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7148 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
7149 RLOGE("suppSvcNotifyInd: invalid response");
7153 SuppSvcNotification suppSvc = {};
7154 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
7155 suppSvc.isMT = ssn->notificationType;
7156 suppSvc.code = ssn->code;
7157 suppSvc.index = ssn->index;
7158 suppSvc.type = ssn->type;
7159 suppSvc.number = convertCharPtrToHidlString(ssn->number);
7162 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
7163 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
7165 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
7166 convertIntToRadioIndicationType(indicationType), suppSvc);
7167 radioService[slotId]->checkReturnStatus(retStatus);
7169 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7175 int radio::stkSessionEndInd(int slotId, int indicationType,
7176 int token, RIL_Errno e, void *response, size_t responseLen) {
7177 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7179 RLOGD("stkSessionEndInd");
7181 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
7182 convertIntToRadioIndicationType(indicationType));
7183 radioService[slotId]->checkReturnStatus(retStatus);
7185 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
7191 int radio::stkProactiveCommandInd(int slotId,
7192 int indicationType, int token, RIL_Errno e, void *response,
7193 size_t responseLen) {
7194 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7195 if (response == NULL || responseLen == 0) {
7196 RLOGE("stkProactiveCommandInd: invalid response");
7200 RLOGD("stkProactiveCommandInd");
7202 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
7203 convertIntToRadioIndicationType(indicationType),
7204 convertCharPtrToHidlString((char *) response));
7205 radioService[slotId]->checkReturnStatus(retStatus);
7207 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
7213 int radio::stkEventNotifyInd(int slotId, int indicationType,
7214 int token, RIL_Errno e, void *response, size_t responseLen) {
7215 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7216 if (response == NULL || responseLen == 0) {
7217 RLOGE("stkEventNotifyInd: invalid response");
7221 RLOGD("stkEventNotifyInd");
7223 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
7224 convertIntToRadioIndicationType(indicationType),
7225 convertCharPtrToHidlString((char *) response));
7226 radioService[slotId]->checkReturnStatus(retStatus);
7228 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7234 int radio::stkCallSetupInd(int slotId, int indicationType,
7235 int token, RIL_Errno e, void *response, size_t responseLen) {
7236 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7237 if (response == NULL || responseLen != sizeof(int)) {
7238 RLOGE("stkCallSetupInd: invalid response");
7241 int32_t timeout = ((int32_t *) response)[0];
7243 RLOGD("stkCallSetupInd: timeout %d", timeout);
7245 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
7246 convertIntToRadioIndicationType(indicationType), timeout);
7247 radioService[slotId]->checkReturnStatus(retStatus);
7249 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
7255 int radio::simSmsStorageFullInd(int slotId,
7256 int indicationType, int token, RIL_Errno e, void *response,
7257 size_t responseLen) {
7258 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7260 RLOGD("simSmsStorageFullInd");
7262 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
7263 convertIntToRadioIndicationType(indicationType));
7264 radioService[slotId]->checkReturnStatus(retStatus);
7266 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
7272 int radio::simRefreshInd(int slotId, int indicationType,
7273 int token, RIL_Errno e, void *response, size_t responseLen) {
7274 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7275 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
7276 RLOGE("simRefreshInd: invalid response");
7280 SimRefreshResult refreshResult = {};
7281 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
7282 refreshResult.type =
7283 (V1_0::SimRefreshType) simRefreshResponse->result;
7284 refreshResult.efId = simRefreshResponse->ef_id;
7285 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
7288 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
7290 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
7291 convertIntToRadioIndicationType(indicationType), refreshResult);
7292 radioService[slotId]->checkReturnStatus(retStatus);
7294 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
7300 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
7301 CdmaSignalInfoRecord& record) {
7302 record.isPresent = signalInfoRecord->isPresent;
7303 record.signalType = signalInfoRecord->signalType;
7304 record.alertPitch = signalInfoRecord->alertPitch;
7305 record.signal = signalInfoRecord->signal;
7308 int radio::callRingInd(int slotId, int indicationType,
7309 int token, RIL_Errno e, void *response, size_t responseLen) {
7310 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7312 CdmaSignalInfoRecord record = {};
7313 if (response == NULL || responseLen == 0) {
7317 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
7318 RLOGE("callRingInd: invalid response");
7321 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
7325 RLOGD("callRingInd: isGsm %d", isGsm);
7327 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
7328 convertIntToRadioIndicationType(indicationType), isGsm, record);
7329 radioService[slotId]->checkReturnStatus(retStatus);
7331 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7337 int radio::simStatusChangedInd(int slotId,
7338 int indicationType, int token, RIL_Errno e, void *response,
7339 size_t responseLen) {
7340 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7342 RLOGD("simStatusChangedInd");
7344 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7345 convertIntToRadioIndicationType(indicationType));
7346 radioService[slotId]->checkReturnStatus(retStatus);
7348 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7354 int radio::cdmaNewSmsInd(int slotId, int indicationType,
7355 int token, RIL_Errno e, void *response, size_t responseLen) {
7356 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7357 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7358 RLOGE("cdmaNewSmsInd: invalid response");
7362 CdmaSmsMessage msg = {};
7363 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7364 msg.teleserviceId = rilMsg->uTeleserviceID;
7365 msg.isServicePresent = rilMsg->bIsServicePresent;
7366 msg.serviceCategory = rilMsg->uServicecategory;
7367 msg.address.digitMode =
7368 (V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7369 msg.address.numberMode =
7370 (V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7371 msg.address.numberType =
7372 (V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7373 msg.address.numberPlan =
7374 (V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7376 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7377 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7379 msg.subAddress.subaddressType = (V1_0::CdmaSmsSubaddressType)
7380 rilMsg->sSubAddress.subaddressType;
7381 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7383 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7384 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7386 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7387 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7390 RLOGD("cdmaNewSmsInd");
7392 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7393 convertIntToRadioIndicationType(indicationType), msg);
7394 radioService[slotId]->checkReturnStatus(retStatus);
7396 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7402 int radio::newBroadcastSmsInd(int slotId,
7403 int indicationType, int token, RIL_Errno e, void *response,
7404 size_t responseLen) {
7405 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7406 if (response == NULL || responseLen == 0) {
7407 RLOGE("newBroadcastSmsInd: invalid response");
7411 hidl_vec<uint8_t> data;
7412 data.setToExternal((uint8_t *) response, responseLen);
7414 RLOGD("newBroadcastSmsInd");
7416 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7417 convertIntToRadioIndicationType(indicationType), data);
7418 radioService[slotId]->checkReturnStatus(retStatus);
7420 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7426 int radio::cdmaRuimSmsStorageFullInd(int slotId,
7427 int indicationType, int token, RIL_Errno e, void *response,
7428 size_t responseLen) {
7429 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7431 RLOGD("cdmaRuimSmsStorageFullInd");
7433 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7434 convertIntToRadioIndicationType(indicationType));
7435 radioService[slotId]->checkReturnStatus(retStatus);
7437 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7444 int radio::restrictedStateChangedInd(int slotId,
7445 int indicationType, int token, RIL_Errno e, void *response,
7446 size_t responseLen) {
7447 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7448 if (response == NULL || responseLen != sizeof(int)) {
7449 RLOGE("restrictedStateChangedInd: invalid response");
7452 int32_t state = ((int32_t *) response)[0];
7454 RLOGD("restrictedStateChangedInd: state %d", state);
7456 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7457 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7458 radioService[slotId]->checkReturnStatus(retStatus);
7460 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7467 int radio::enterEmergencyCallbackModeInd(int slotId,
7468 int indicationType, int token, RIL_Errno e, void *response,
7469 size_t responseLen) {
7470 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7472 RLOGD("enterEmergencyCallbackModeInd");
7474 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7475 convertIntToRadioIndicationType(indicationType));
7476 radioService[slotId]->checkReturnStatus(retStatus);
7478 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7485 int radio::cdmaCallWaitingInd(int slotId,
7486 int indicationType, int token, RIL_Errno e, void *response,
7487 size_t responseLen) {
7488 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7489 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7490 RLOGE("cdmaCallWaitingInd: invalid response");
7494 CdmaCallWaiting callWaitingRecord = {};
7495 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7496 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7497 callWaitingRecord.numberPresentation =
7498 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7499 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7500 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7501 callWaitingRecord.signalInfoRecord);
7502 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7503 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7506 RLOGD("cdmaCallWaitingInd");
7508 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7509 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7510 radioService[slotId]->checkReturnStatus(retStatus);
7512 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7518 int radio::cdmaOtaProvisionStatusInd(int slotId,
7519 int indicationType, int token, RIL_Errno e, void *response,
7520 size_t responseLen) {
7521 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7522 if (response == NULL || responseLen != sizeof(int)) {
7523 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7526 int32_t status = ((int32_t *) response)[0];
7528 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7530 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7531 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7532 radioService[slotId]->checkReturnStatus(retStatus);
7534 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7541 int radio::cdmaInfoRecInd(int slotId,
7542 int indicationType, int token, RIL_Errno e, void *response,
7543 size_t responseLen) {
7544 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7545 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7546 RLOGE("cdmaInfoRecInd: invalid response");
7550 CdmaInformationRecords records = {};
7551 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7553 char* string8 = NULL;
7554 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7555 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7556 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7557 "additional ones", recordsRil->numberOfInfoRecs,
7558 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7560 records.infoRec.resize(num);
7561 for (int i = 0 ; i < num ; i++) {
7562 CdmaInformationRecord *record = &records.infoRec[i];
7563 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7564 record->name = (CdmaInfoRecName) infoRec->name;
7565 // All vectors should be size 0 except one which will be size 1. Set everything to
7566 // size 0 initially.
7567 record->display.resize(0);
7568 record->number.resize(0);
7569 record->signal.resize(0);
7570 record->redir.resize(0);
7571 record->lineCtrl.resize(0);
7572 record->clir.resize(0);
7573 record->audioCtrl.resize(0);
7574 switch (infoRec->name) {
7575 case RIL_CDMA_DISPLAY_INFO_REC:
7576 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7577 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7578 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7579 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7580 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7583 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7584 if (string8 == NULL) {
7585 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7586 "responseCdmaInformationRecords");
7589 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7590 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7592 record->display.resize(1);
7593 record->display[0].alphaBuf = string8;
7599 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7600 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7601 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7602 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7603 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7604 "expected not more than %d", (int) infoRec->rec.number.len,
7605 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7608 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7609 if (string8 == NULL) {
7610 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7611 "responseCdmaInformationRecords");
7614 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7615 string8[(int)infoRec->rec.number.len] = '\0';
7617 record->number.resize(1);
7618 record->number[0].number = string8;
7621 record->number[0].numberType = infoRec->rec.number.number_type;
7622 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7623 record->number[0].pi = infoRec->rec.number.pi;
7624 record->number[0].si = infoRec->rec.number.si;
7628 case RIL_CDMA_SIGNAL_INFO_REC: {
7629 record->signal.resize(1);
7630 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7631 record->signal[0].signalType = infoRec->rec.signal.signalType;
7632 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7633 record->signal[0].signal = infoRec->rec.signal.signal;
7637 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7638 if (infoRec->rec.redir.redirectingNumber.len >
7639 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7640 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7641 "expected not more than %d\n",
7642 (int)infoRec->rec.redir.redirectingNumber.len,
7643 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7646 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7648 if (string8 == NULL) {
7649 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7650 "responseCdmaInformationRecords");
7653 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7654 infoRec->rec.redir.redirectingNumber.len);
7655 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7657 record->redir.resize(1);
7658 record->redir[0].redirectingNumber.number = string8;
7661 record->redir[0].redirectingNumber.numberType =
7662 infoRec->rec.redir.redirectingNumber.number_type;
7663 record->redir[0].redirectingNumber.numberPlan =
7664 infoRec->rec.redir.redirectingNumber.number_plan;
7665 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7666 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7667 record->redir[0].redirectingReason =
7668 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7672 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7673 record->lineCtrl.resize(1);
7674 record->lineCtrl[0].lineCtrlPolarityIncluded =
7675 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7676 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7677 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7678 record->lineCtrl[0].lineCtrlPowerDenial =
7679 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7683 case RIL_CDMA_T53_CLIR_INFO_REC: {
7684 record->clir.resize(1);
7685 record->clir[0].cause = infoRec->rec.clir.cause;
7689 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7690 record->audioCtrl.resize(1);
7691 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7692 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7696 case RIL_CDMA_T53_RELEASE_INFO_REC:
7697 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7701 RLOGE("cdmaInfoRecInd: Incorrect name value");
7707 RLOGD("cdmaInfoRecInd");
7709 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7710 convertIntToRadioIndicationType(indicationType), records);
7711 radioService[slotId]->checkReturnStatus(retStatus);
7713 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7719 int radio::indicateRingbackToneInd(int slotId,
7720 int indicationType, int token, RIL_Errno e, void *response,
7721 size_t responseLen) {
7722 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7723 if (response == NULL || responseLen != sizeof(int)) {
7724 RLOGE("indicateRingbackToneInd: invalid response");
7727 bool start = ((int32_t *) response)[0];
7729 RLOGD("indicateRingbackToneInd: start %d", start);
7731 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7732 convertIntToRadioIndicationType(indicationType), start);
7733 radioService[slotId]->checkReturnStatus(retStatus);
7735 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7741 int radio::resendIncallMuteInd(int slotId,
7742 int indicationType, int token, RIL_Errno e, void *response,
7743 size_t responseLen) {
7744 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7746 RLOGD("resendIncallMuteInd");
7748 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7749 convertIntToRadioIndicationType(indicationType));
7750 radioService[slotId]->checkReturnStatus(retStatus);
7752 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7758 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7759 int indicationType, int token, RIL_Errno e,
7760 void *response, size_t responseLen) {
7761 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7762 if (response == NULL || responseLen != sizeof(int)) {
7763 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7766 int32_t cdmaSource = ((int32_t *) response)[0];
7768 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7770 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7771 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7772 (CdmaSubscriptionSource) cdmaSource);
7773 radioService[slotId]->checkReturnStatus(retStatus);
7775 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7782 int radio::cdmaPrlChangedInd(int slotId,
7783 int indicationType, int token, RIL_Errno e, void *response,
7784 size_t responseLen) {
7785 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7786 if (response == NULL || responseLen != sizeof(int)) {
7787 RLOGE("cdmaPrlChangedInd: invalid response");
7790 int32_t version = ((int32_t *) response)[0];
7792 RLOGD("cdmaPrlChangedInd: version %d", version);
7794 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7795 convertIntToRadioIndicationType(indicationType), version);
7796 radioService[slotId]->checkReturnStatus(retStatus);
7798 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7804 int radio::exitEmergencyCallbackModeInd(int slotId,
7805 int indicationType, int token, RIL_Errno e, void *response,
7806 size_t responseLen) {
7807 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7809 RLOGD("exitEmergencyCallbackModeInd");
7811 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7812 convertIntToRadioIndicationType(indicationType));
7813 radioService[slotId]->checkReturnStatus(retStatus);
7815 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7822 int radio::rilConnectedInd(int slotId,
7823 int indicationType, int token, RIL_Errno e, void *response,
7824 size_t responseLen) {
7825 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7826 RLOGD("rilConnectedInd");
7827 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7828 convertIntToRadioIndicationType(indicationType));
7829 radioService[slotId]->checkReturnStatus(retStatus);
7831 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7837 int radio::voiceRadioTechChangedInd(int slotId,
7838 int indicationType, int token, RIL_Errno e, void *response,
7839 size_t responseLen) {
7840 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7841 if (response == NULL || responseLen != sizeof(int)) {
7842 RLOGE("voiceRadioTechChangedInd: invalid response");
7845 int32_t rat = ((int32_t *) response)[0];
7847 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7849 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7850 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7851 radioService[slotId]->checkReturnStatus(retStatus);
7853 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7860 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7861 int num = responseLen / sizeof(RIL_CellInfo_v12);
7862 records.resize(num);
7864 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7865 for (int i = 0; i < num; i++) {
7866 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7867 records[i].registered = rillCellInfo->registered;
7868 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7869 records[i].timeStamp = rillCellInfo->timeStamp;
7870 // All vectors should be size 0 except one which will be size 1. Set everything to
7871 // size 0 initially.
7872 records[i].gsm.resize(0);
7873 records[i].wcdma.resize(0);
7874 records[i].cdma.resize(0);
7875 records[i].lte.resize(0);
7876 records[i].tdscdma.resize(0);
7877 switch(rillCellInfo->cellInfoType) {
7878 case RIL_CELL_INFO_TYPE_GSM: {
7879 records[i].gsm.resize(1);
7880 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7881 cellInfoGsm->cellIdentityGsm.mcc =
7882 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7883 cellInfoGsm->cellIdentityGsm.mnc =
7884 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7885 cellInfoGsm->cellIdentityGsm.lac =
7886 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7887 cellInfoGsm->cellIdentityGsm.cid =
7888 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7889 cellInfoGsm->cellIdentityGsm.arfcn =
7890 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7891 cellInfoGsm->cellIdentityGsm.bsic =
7892 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7893 cellInfoGsm->signalStrengthGsm.signalStrength =
7894 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7895 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7896 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7897 cellInfoGsm->signalStrengthGsm.timingAdvance =
7898 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7902 case RIL_CELL_INFO_TYPE_WCDMA: {
7903 records[i].wcdma.resize(1);
7904 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7905 cellInfoWcdma->cellIdentityWcdma.mcc =
7906 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7907 cellInfoWcdma->cellIdentityWcdma.mnc =
7908 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7909 cellInfoWcdma->cellIdentityWcdma.lac =
7910 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7911 cellInfoWcdma->cellIdentityWcdma.cid =
7912 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7913 cellInfoWcdma->cellIdentityWcdma.psc =
7914 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7915 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7916 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7917 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7918 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7919 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7920 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7924 case RIL_CELL_INFO_TYPE_CDMA: {
7925 records[i].cdma.resize(1);
7926 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7927 cellInfoCdma->cellIdentityCdma.networkId =
7928 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7929 cellInfoCdma->cellIdentityCdma.systemId =
7930 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7931 cellInfoCdma->cellIdentityCdma.baseStationId =
7932 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7933 cellInfoCdma->cellIdentityCdma.longitude =
7934 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7935 cellInfoCdma->cellIdentityCdma.latitude =
7936 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7937 cellInfoCdma->signalStrengthCdma.dbm =
7938 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7939 cellInfoCdma->signalStrengthCdma.ecio =
7940 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7941 cellInfoCdma->signalStrengthEvdo.dbm =
7942 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7943 cellInfoCdma->signalStrengthEvdo.ecio =
7944 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7945 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7946 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7950 case RIL_CELL_INFO_TYPE_LTE: {
7951 records[i].lte.resize(1);
7952 CellInfoLte *cellInfoLte = &records[i].lte[0];
7953 cellInfoLte->cellIdentityLte.mcc =
7954 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7955 cellInfoLte->cellIdentityLte.mnc =
7956 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7957 cellInfoLte->cellIdentityLte.ci =
7958 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7959 cellInfoLte->cellIdentityLte.pci =
7960 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7961 cellInfoLte->cellIdentityLte.tac =
7962 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7963 cellInfoLte->cellIdentityLte.earfcn =
7964 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7965 cellInfoLte->signalStrengthLte.signalStrength =
7966 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7967 cellInfoLte->signalStrengthLte.rsrp =
7968 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7969 cellInfoLte->signalStrengthLte.rsrq =
7970 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7971 cellInfoLte->signalStrengthLte.rssnr =
7972 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7973 cellInfoLte->signalStrengthLte.cqi =
7974 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7975 cellInfoLte->signalStrengthLte.timingAdvance =
7976 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7980 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7981 records[i].tdscdma.resize(1);
7982 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7983 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7984 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7985 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7986 ril::util::mnc::decode(
7987 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7988 cellInfoTdscdma->cellIdentityTdscdma.lac =
7989 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7990 cellInfoTdscdma->cellIdentityTdscdma.cid =
7991 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7992 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7993 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7994 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7995 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
8006 int radio::cellInfoListInd(int slotId,
8007 int indicationType, int token, RIL_Errno e, void *response,
8008 size_t responseLen) {
8009 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8010 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
8011 RLOGE("cellInfoListInd: invalid response");
8015 hidl_vec<CellInfo> records;
8016 convertRilCellInfoListToHal(response, responseLen, records);
8019 RLOGD("cellInfoListInd");
8021 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
8022 convertIntToRadioIndicationType(indicationType), records);
8023 radioService[slotId]->checkReturnStatus(retStatus);
8025 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
8031 int radio::imsNetworkStateChangedInd(int slotId,
8032 int indicationType, int token, RIL_Errno e, void *response,
8033 size_t responseLen) {
8034 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8036 RLOGD("imsNetworkStateChangedInd");
8038 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
8039 convertIntToRadioIndicationType(indicationType));
8040 radioService[slotId]->checkReturnStatus(retStatus);
8042 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
8049 int radio::subscriptionStatusChangedInd(int slotId,
8050 int indicationType, int token, RIL_Errno e, void *response,
8051 size_t responseLen) {
8052 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8053 if (response == NULL || responseLen != sizeof(int)) {
8054 RLOGE("subscriptionStatusChangedInd: invalid response");
8057 bool activate = ((int32_t *) response)[0];
8059 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
8061 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
8062 convertIntToRadioIndicationType(indicationType), activate);
8063 radioService[slotId]->checkReturnStatus(retStatus);
8065 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
8072 int radio::srvccStateNotifyInd(int slotId,
8073 int indicationType, int token, RIL_Errno e, void *response,
8074 size_t responseLen) {
8075 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8076 if (response == NULL || responseLen != sizeof(int)) {
8077 RLOGE("srvccStateNotifyInd: invalid response");
8080 int32_t state = ((int32_t *) response)[0];
8082 RLOGD("srvccStateNotifyInd: rat %d", state);
8084 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
8085 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
8086 radioService[slotId]->checkReturnStatus(retStatus);
8088 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
8094 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
8095 hidl_vec<HardwareConfig>& records) {
8096 int num = responseLen / sizeof(RIL_HardwareConfig);
8097 records.resize(num);
8099 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
8100 for (int i = 0; i < num; i++) {
8101 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
8102 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
8103 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
8104 switch (rilHardwareConfig[i].type) {
8105 case RIL_HARDWARE_CONFIG_MODEM: {
8106 records[i].modem.resize(1);
8107 records[i].sim.resize(0);
8108 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
8109 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
8110 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
8111 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
8112 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
8116 case RIL_HARDWARE_CONFIG_SIM: {
8117 records[i].sim.resize(1);
8118 records[i].modem.resize(0);
8119 records[i].sim[0].modemUuid =
8120 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
8127 int radio::hardwareConfigChangedInd(int slotId,
8128 int indicationType, int token, RIL_Errno e, void *response,
8129 size_t responseLen) {
8130 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8131 if ((response == NULL && responseLen != 0)
8132 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
8133 RLOGE("hardwareConfigChangedInd: invalid response");
8137 hidl_vec<HardwareConfig> configs;
8138 convertRilHardwareConfigListToHal(response, responseLen, configs);
8141 RLOGD("hardwareConfigChangedInd");
8143 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
8144 convertIntToRadioIndicationType(indicationType), configs);
8145 radioService[slotId]->checkReturnStatus(retStatus);
8147 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
8154 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
8155 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
8156 rc.session = rilRadioCapability->session;
8157 rc.phase = (V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
8158 rc.raf = rilRadioCapability->rat;
8159 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
8160 rc.status = (V1_0::RadioCapabilityStatus) rilRadioCapability->status;
8163 int radio::radioCapabilityIndicationInd(int slotId,
8164 int indicationType, int token, RIL_Errno e, void *response,
8165 size_t responseLen) {
8166 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8167 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
8168 RLOGE("radioCapabilityIndicationInd: invalid response");
8172 RadioCapability rc = {};
8173 convertRilRadioCapabilityToHal(response, responseLen, rc);
8176 RLOGD("radioCapabilityIndicationInd");
8178 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
8179 convertIntToRadioIndicationType(indicationType), rc);
8180 radioService[slotId]->checkReturnStatus(retStatus);
8182 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
8189 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
8190 if ((reqType == SS_INTERROGATION) &&
8191 (serType == SS_CFU ||
8192 serType == SS_CF_BUSY ||
8193 serType == SS_CF_NO_REPLY ||
8194 serType == SS_CF_NOT_REACHABLE ||
8195 serType == SS_CF_ALL ||
8196 serType == SS_CF_ALL_CONDITIONAL)) {
8202 int radio::onSupplementaryServiceIndicationInd(int slotId,
8203 int indicationType, int token, RIL_Errno e,
8204 void *response, size_t responseLen) {
8205 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8206 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
8207 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
8211 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
8212 StkCcUnsolSsResult ss = {};
8213 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
8214 ss.requestType = (SsRequestType) rilSsResponse->requestType;
8215 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
8216 ss.serviceClass = rilSsResponse->serviceClass;
8217 ss.result = (RadioError) rilSsResponse->result;
8219 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
8221 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
8222 rilSsResponse->cfData.numValidIndexes);
8224 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
8225 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
8226 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
8227 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
8230 ss.cfData.resize(1);
8231 ss.ssInfo.resize(0);
8233 /* number of call info's */
8234 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
8236 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
8237 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
8238 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
8240 cfInfo->status = (CallForwardInfoStatus) cf.status;
8241 cfInfo->reason = cf.reason;
8242 cfInfo->serviceClass = cf.serviceClass;
8243 cfInfo->toa = cf.toa;
8244 cfInfo->number = convertCharPtrToHidlString(cf.number);
8245 cfInfo->timeSeconds = cf.timeSeconds;
8247 RLOGD("onSupplementaryServiceIndicationInd: "
8248 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
8249 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
8253 ss.ssInfo.resize(1);
8254 ss.cfData.resize(0);
8257 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
8258 for (int i = 0; i < SS_INFO_MAX; i++) {
8260 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
8261 rilSsResponse->ssInfo[i]);
8263 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
8268 RLOGD("onSupplementaryServiceIndicationInd");
8270 Return<void> retStatus = radioService[slotId]->mRadioIndication->
8271 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
8273 radioService[slotId]->checkReturnStatus(retStatus);
8275 RLOGE("onSupplementaryServiceIndicationInd: "
8276 "radioService[%d]->mRadioIndication == NULL", slotId);
8282 int radio::stkCallControlAlphaNotifyInd(int slotId,
8283 int indicationType, int token, RIL_Errno e, void *response,
8284 size_t responseLen) {
8285 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8286 if (response == NULL || responseLen == 0) {
8287 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
8291 RLOGD("stkCallControlAlphaNotifyInd");
8293 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
8294 convertIntToRadioIndicationType(indicationType),
8295 convertCharPtrToHidlString((char *) response));
8296 radioService[slotId]->checkReturnStatus(retStatus);
8298 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
8305 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
8306 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
8307 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
8308 lce.confidenceLevel = rilLceDataInfo->confidence_level;
8309 lce.lceSuspended = rilLceDataInfo->lce_suspended;
8312 int radio::lceDataInd(int slotId,
8313 int indicationType, int token, RIL_Errno e, void *response,
8314 size_t responseLen) {
8315 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8316 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
8317 RLOGE("lceDataInd: invalid response");
8321 LceDataInfo lce = {};
8322 convertRilLceDataInfoToHal(response, responseLen, lce);
8324 RLOGD("lceDataInd");
8326 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
8327 convertIntToRadioIndicationType(indicationType), lce);
8328 radioService[slotId]->checkReturnStatus(retStatus);
8330 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8336 int radio::pcoDataInd(int slotId,
8337 int indicationType, int token, RIL_Errno e, void *response,
8338 size_t responseLen) {
8339 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8340 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8341 RLOGE("pcoDataInd: invalid response");
8345 PcoDataInfo pco = {};
8346 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8347 pco.cid = rilPcoData->cid;
8348 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8349 pco.pcoId = rilPcoData->pco_id;
8350 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8353 RLOGD("pcoDataInd");
8355 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8356 convertIntToRadioIndicationType(indicationType), pco);
8357 radioService[slotId]->checkReturnStatus(retStatus);
8359 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8365 int radio::modemResetInd(int slotId,
8366 int indicationType, int token, RIL_Errno e, void *response,
8367 size_t responseLen) {
8368 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8369 if (response == NULL || responseLen == 0) {
8370 RLOGE("modemResetInd: invalid response");
8374 RLOGD("modemResetInd");
8376 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8377 convertIntToRadioIndicationType(indicationType),
8378 convertCharPtrToHidlString((char *) response));
8379 radioService[slotId]->checkReturnStatus(retStatus);
8381 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8387 int radio::networkScanResultInd(int slotId,
8388 int indicationType, int token, RIL_Errno e, void *response,
8389 size_t responseLen) {
8391 RLOGD("networkScanResultInd");
8393 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8394 if (response == NULL || responseLen == 0) {
8395 RLOGE("networkScanResultInd: invalid response");
8398 RLOGD("networkScanResultInd");
8401 RLOGD("networkScanResultInd");
8404 RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
8406 V1_1::NetworkScanResult result;
8407 result.status = (V1_1::ScanStatus) networkScanResult->status;
8408 result.error = (RadioError) networkScanResult->error;
8409 convertRilCellInfoListToHal(
8410 networkScanResult->network_infos,
8411 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
8412 result.networkInfos);
8414 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->networkScanResult(
8415 convertIntToRadioIndicationType(indicationType), result);
8416 radioService[slotId]->checkReturnStatus(retStatus);
8418 RLOGE("networkScanResultInd: radioService[%d]->mRadioIndicationV1_1 == NULL", slotId);
8423 int radio::carrierInfoForImsiEncryption(int slotId,
8424 int indicationType, int token, RIL_Errno e, void *response,
8425 size_t responseLen) {
8426 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8427 if (response == NULL || responseLen == 0) {
8428 RLOGE("carrierInfoForImsiEncryption: invalid response");
8431 RLOGD("carrierInfoForImsiEncryption");
8432 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->
8433 carrierInfoForImsiEncryption(convertIntToRadioIndicationType(indicationType));
8434 radioService[slotId]->checkReturnStatus(retStatus);
8436 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndicationV1_1 == NULL",
8443 int radio::keepaliveStatusInd(int slotId,
8444 int indicationType, int token, RIL_Errno e, void *response,
8445 size_t responseLen) {
8447 RLOGD("%s(): token=%d", __FUNCTION__, token);
8449 if (radioService[slotId] == NULL || radioService[slotId]->mRadioIndication == NULL) {
8450 RLOGE("%s: radioService[%d]->mRadioIndication == NULL", __FUNCTION__, slotId);
8454 auto ret = V1_1::IRadioIndication::castFrom(
8455 radioService[slotId]->mRadioIndication);
8457 RLOGE("%s: ret.isOk() == false for radioService[%d]", __FUNCTION__, slotId);
8460 sp<V1_1::IRadioIndication> radioIndicationV1_1 = ret;
8462 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
8463 RLOGE("%s: invalid response", __FUNCTION__);
8467 V1_1::KeepaliveStatus ks;
8468 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
8470 Return<void> retStatus = radioIndicationV1_1->keepaliveStatus(
8471 convertIntToRadioIndicationType(indicationType), ks);
8472 radioService[slotId]->checkReturnStatus(retStatus);
8476 int radio::oemHookRawInd(int slotId,
8477 int indicationType, int token, RIL_Errno e, void *response,
8478 size_t responseLen) {
8479 if (!kOemHookEnabled) return 0;
8481 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8482 if (response == NULL || responseLen == 0) {
8483 RLOGE("oemHookRawInd: invalid response");
8487 hidl_vec<uint8_t> data;
8488 data.setToExternal((uint8_t *) response, responseLen);
8490 RLOGD("oemHookRawInd");
8492 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8493 convertIntToRadioIndicationType(indicationType), data);
8494 checkReturnStatus(slotId, retStatus, false);
8496 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8502 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8503 using namespace android::hardware;
8505 const char *serviceNames[] = {
8506 android::RIL_getServiceName()
8507 #if (SIM_COUNT >= 2)
8509 #if (SIM_COUNT >= 3)
8511 #if (SIM_COUNT >= 4)
8518 #if (SIM_COUNT >= 2)
8519 simCount = SIM_COUNT;
8522 s_vendorFunctions = callbacks;
8523 s_commands = commands;
8525 configureRpcThreadpool(1, true /* callerWillJoin */);
8526 for (int i = 0; i < simCount; i++) {
8527 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8528 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8531 radioService[i] = new RadioImpl;
8532 radioService[i]->mSlotId = i;
8533 RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
8535 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8537 if (kOemHookEnabled) {
8538 oemHookService[i] = new OemHookImpl;
8539 oemHookService[i]->mSlotId = i;
8540 status = oemHookService[i]->registerAsService(serviceNames[i]);
8543 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8548 void rilc_thread_pool() {
8549 joinRpcThreadpool();
8552 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8553 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8555 #if (SIM_COUNT >= 2)
8556 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8557 #if (SIM_COUNT >= 3)
8558 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8559 #if (SIM_COUNT >= 4)
8560 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8565 return radioServiceRwlockPtr;
8568 // should acquire write lock for the corresponding service before calling this
8569 void radio::setNitzTimeReceived(int slotId, long timeReceived) {
8570 nitzTimeReceived[slotId] = timeReceived;