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.0/IRadio.h>
20 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
22 #include <hwbinder/IPCThreadState.h>
23 #include <hwbinder/ProcessState.h>
24 #include <ril_service.h>
25 #include <hidl/HidlTransportSupport.h>
26 #include <utils/SystemClock.h>
29 #define INVALID_HEX_CHAR 16
31 // Enable verbose logging
34 using namespace android::hardware::radio::V1_0;
35 using namespace android::hardware::radio::deprecated::V1_0;
36 using ::android::hardware::configureRpcThreadpool;
37 using ::android::hardware::joinRpcThreadpool;
38 using ::android::hardware::Return;
39 using ::android::hardware::hidl_string;
40 using ::android::hardware::hidl_vec;
41 using ::android::hardware::hidl_array;
42 using ::android::hardware::Void;
43 using android::CommandInfo;
44 using android::RequestInfo;
45 using android::requestToString;
48 #define BOOL_TO_INT(x) (x ? 1 : 0)
49 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
50 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
52 #if defined(ANDROID_MULTI_SIM)
53 #define CALL_ONREQUEST(a, b, c, d, e) \
54 s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e)))
55 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a))
57 #define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d))
58 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
61 RIL_RadioFunctions *s_vendorFunctions = NULL;
62 static CommandInfo *s_commands;
68 sp<RadioImpl> radioService[SIM_COUNT];
69 sp<OemHookImpl> oemHookService[SIM_COUNT];
70 // counter used for synchronization. It is incremented every time response callbacks are updated.
71 volatile int32_t mCounterRadio[SIM_COUNT];
72 volatile int32_t mCounterOemHook[SIM_COUNT];
74 sp<RadioImpl> radioService[1];
75 sp<OemHookImpl> oemHookService[1];
76 // counter used for synchronization. It is incremented every time response callbacks are updated.
77 volatile int32_t mCounterRadio[1];
78 volatile int32_t mCounterOemHook[1];
81 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
84 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
86 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
88 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
93 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
94 hidl_vec<HardwareConfig>& records);
96 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
98 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
100 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
101 SignalStrength& signalStrength);
103 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
104 SetupDataCallResult& dcResult);
106 void convertRilDataCallListToHal(void *response, size_t responseLen,
107 hidl_vec<SetupDataCallResult>& dcResultList);
109 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
111 struct RadioImpl : public IRadio {
113 sp<IRadioResponse> mRadioResponse;
114 sp<IRadioIndication> mRadioIndication;
116 Return<void> setResponseFunctions(
117 const ::android::sp<IRadioResponse>& radioResponse,
118 const ::android::sp<IRadioIndication>& radioIndication);
120 Return<void> getIccCardStatus(int32_t serial);
122 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
123 const hidl_string& aid);
125 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
126 const hidl_string& pin, const hidl_string& aid);
128 Return<void> supplyIccPin2ForApp(int32_t serial,
129 const hidl_string& pin2,
130 const hidl_string& aid);
132 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
133 const hidl_string& pin2, const hidl_string& aid);
135 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
136 const hidl_string& newPin, const hidl_string& aid);
138 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
139 const hidl_string& newPin2, const hidl_string& aid);
141 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
143 Return<void> getCurrentCalls(int32_t serial);
145 Return<void> dial(int32_t serial, const Dial& dialInfo);
147 Return<void> getImsiForApp(int32_t serial,
148 const ::android::hardware::hidl_string& aid);
150 Return<void> hangup(int32_t serial, int32_t gsmIndex);
152 Return<void> hangupWaitingOrBackground(int32_t serial);
154 Return<void> hangupForegroundResumeBackground(int32_t serial);
156 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
158 Return<void> conference(int32_t serial);
160 Return<void> rejectCall(int32_t serial);
162 Return<void> getLastCallFailCause(int32_t serial);
164 Return<void> getSignalStrength(int32_t serial);
166 Return<void> getVoiceRegistrationState(int32_t serial);
168 Return<void> getDataRegistrationState(int32_t serial);
170 Return<void> getOperator(int32_t serial);
172 Return<void> setRadioPower(int32_t serial, bool on);
174 Return<void> sendDtmf(int32_t serial,
175 const ::android::hardware::hidl_string& s);
177 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
179 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
181 Return<void> setupDataCall(int32_t serial,
182 RadioTechnology radioTechnology,
183 const DataProfileInfo& profileInfo,
188 Return<void> iccIOForApp(int32_t serial,
191 Return<void> sendUssd(int32_t serial,
192 const ::android::hardware::hidl_string& ussd);
194 Return<void> cancelPendingUssd(int32_t serial);
196 Return<void> getClir(int32_t serial);
198 Return<void> setClir(int32_t serial, int32_t status);
200 Return<void> getCallForwardStatus(int32_t serial,
201 const CallForwardInfo& callInfo);
203 Return<void> setCallForward(int32_t serial,
204 const CallForwardInfo& callInfo);
206 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
208 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
210 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
211 bool success, SmsAcknowledgeFailCause cause);
213 Return<void> acceptCall(int32_t serial);
215 Return<void> deactivateDataCall(int32_t serial,
216 int32_t cid, bool reasonRadioShutDown);
218 Return<void> getFacilityLockForApp(int32_t serial,
219 const ::android::hardware::hidl_string& facility,
220 const ::android::hardware::hidl_string& password,
221 int32_t serviceClass,
222 const ::android::hardware::hidl_string& appId);
224 Return<void> setFacilityLockForApp(int32_t serial,
225 const ::android::hardware::hidl_string& facility,
227 const ::android::hardware::hidl_string& password,
228 int32_t serviceClass,
229 const ::android::hardware::hidl_string& appId);
231 Return<void> setBarringPassword(int32_t serial,
232 const ::android::hardware::hidl_string& facility,
233 const ::android::hardware::hidl_string& oldPassword,
234 const ::android::hardware::hidl_string& newPassword);
236 Return<void> getNetworkSelectionMode(int32_t serial);
238 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
240 Return<void> setNetworkSelectionModeManual(int32_t serial,
241 const ::android::hardware::hidl_string& operatorNumeric);
243 Return<void> getAvailableNetworks(int32_t serial);
245 Return<void> startDtmf(int32_t serial,
246 const ::android::hardware::hidl_string& s);
248 Return<void> stopDtmf(int32_t serial);
250 Return<void> getBasebandVersion(int32_t serial);
252 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
254 Return<void> setMute(int32_t serial, bool enable);
256 Return<void> getMute(int32_t serial);
258 Return<void> getClip(int32_t serial);
260 Return<void> getDataCallList(int32_t serial);
262 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
264 Return<void> writeSmsToSim(int32_t serial,
265 const SmsWriteArgs& smsWriteArgs);
267 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
269 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
271 Return<void> getAvailableBandModes(int32_t serial);
273 Return<void> sendEnvelope(int32_t serial,
274 const ::android::hardware::hidl_string& command);
276 Return<void> sendTerminalResponseToSim(int32_t serial,
277 const ::android::hardware::hidl_string& commandResponse);
279 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
281 Return<void> explicitCallTransfer(int32_t serial);
283 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
285 Return<void> getPreferredNetworkType(int32_t serial);
287 Return<void> getNeighboringCids(int32_t serial);
289 Return<void> setLocationUpdates(int32_t serial, bool enable);
291 Return<void> setCdmaSubscriptionSource(int32_t serial,
292 CdmaSubscriptionSource cdmaSub);
294 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
296 Return<void> getCdmaRoamingPreference(int32_t serial);
298 Return<void> setTTYMode(int32_t serial, TtyMode mode);
300 Return<void> getTTYMode(int32_t serial);
302 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
304 Return<void> getPreferredVoicePrivacy(int32_t serial);
306 Return<void> sendCDMAFeatureCode(int32_t serial,
307 const ::android::hardware::hidl_string& featureCode);
309 Return<void> sendBurstDtmf(int32_t serial,
310 const ::android::hardware::hidl_string& dtmf,
314 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
316 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
317 const CdmaSmsAck& smsAck);
319 Return<void> getGsmBroadcastConfig(int32_t serial);
321 Return<void> setGsmBroadcastConfig(int32_t serial,
322 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
324 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
326 Return<void> getCdmaBroadcastConfig(int32_t serial);
328 Return<void> setCdmaBroadcastConfig(int32_t serial,
329 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
331 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
333 Return<void> getCDMASubscription(int32_t serial);
335 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
337 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
339 Return<void> getDeviceIdentity(int32_t serial);
341 Return<void> exitEmergencyCallbackMode(int32_t serial);
343 Return<void> getSmscAddress(int32_t serial);
345 Return<void> setSmscAddress(int32_t serial,
346 const ::android::hardware::hidl_string& smsc);
348 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
350 Return<void> reportStkServiceIsRunning(int32_t serial);
352 Return<void> getCdmaSubscriptionSource(int32_t serial);
354 Return<void> requestIsimAuthentication(int32_t serial,
355 const ::android::hardware::hidl_string& challenge);
357 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
359 const ::android::hardware::hidl_string& ackPdu);
361 Return<void> sendEnvelopeWithStatus(int32_t serial,
362 const ::android::hardware::hidl_string& contents);
364 Return<void> getVoiceRadioTechnology(int32_t serial);
366 Return<void> getCellInfoList(int32_t serial);
368 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
370 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
371 bool modemCognitive, bool isRoaming);
373 Return<void> getImsRegistrationState(int32_t serial);
375 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
377 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
379 Return<void> iccOpenLogicalChannel(int32_t serial,
380 const ::android::hardware::hidl_string& aid, int32_t p2);
382 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
384 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
386 Return<void> nvReadItem(int32_t serial, NvItem itemId);
388 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
390 Return<void> nvWriteCdmaPrl(int32_t serial,
391 const ::android::hardware::hidl_vec<uint8_t>& prl);
393 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
395 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
397 Return<void> setDataAllowed(int32_t serial, bool allow);
399 Return<void> getHardwareConfig(int32_t serial);
401 Return<void> requestIccSimAuthentication(int32_t serial,
403 const ::android::hardware::hidl_string& authData,
404 const ::android::hardware::hidl_string& aid);
406 Return<void> setDataProfile(int32_t serial,
407 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
409 Return<void> requestShutdown(int32_t serial);
411 Return<void> getRadioCapability(int32_t serial);
413 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
415 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
417 Return<void> stopLceService(int32_t serial);
419 Return<void> pullLceData(int32_t serial);
421 Return<void> getModemActivityInfo(int32_t serial);
423 Return<void> setAllowedCarriers(int32_t serial,
425 const CarrierRestrictions& carriers);
427 Return<void> getAllowedCarriers(int32_t serial);
429 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
431 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
433 Return<void> setSimCardPower(int32_t serial, bool powerUp);
435 Return<void> responseAcknowledgement();
437 void checkReturnStatus(Return<void>& ret);
440 struct OemHookImpl : public IOemHook {
442 sp<IOemHookResponse> mOemHookResponse;
443 sp<IOemHookIndication> mOemHookIndication;
445 Return<void> setResponseFunctions(
446 const ::android::sp<IOemHookResponse>& oemHookResponse,
447 const ::android::sp<IOemHookIndication>& oemHookIndication);
449 Return<void> sendRequestRaw(int32_t serial,
450 const ::android::hardware::hidl_vec<uint8_t>& data);
452 Return<void> sendRequestStrings(int32_t serial,
453 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
456 void memsetAndFreeStrings(int numPointers, ...) {
458 va_start(ap, numPointers);
459 for (int i = 0; i < numPointers; i++) {
460 char *ptr = va_arg(ap, char *);
463 // TODO: Should pass in the maximum length of the string
472 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
473 pRI->pCI->responseFunction((int) pRI->socket_id,
474 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
478 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
479 * request with error RIL_E_NO_MEMORY.
480 * Returns true on success, and false on failure.
482 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
483 size_t len = src.size();
488 *dest = (char *) calloc(len + 1, sizeof(char));
490 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
491 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
494 strncpy(*dest, src.c_str(), len + 1);
498 hidl_string convertCharPtrToHidlString(const char *ptr) {
501 // TODO: replace this with strnlen
502 ret.setToExternal(ptr, strlen(ptr));
507 bool dispatchVoid(int serial, int slotId, int request) {
508 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
512 CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
516 bool dispatchString(int serial, int slotId, int request, const char * str) {
517 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
523 if (!copyHidlStringToRil(&pString, str, pRI)) {
527 CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
529 memsetAndFreeStrings(1, pString);
533 bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) {
534 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
540 pStrings = (char **)calloc(countStrings, sizeof(char *));
541 if (pStrings == NULL) {
542 RLOGE("Memory allocation failed for request %s", requestToString(request));
543 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
547 va_start(ap, countStrings);
548 for (int i = 0; i < countStrings; i++) {
549 const char* str = va_arg(ap, const char *);
550 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI)) {
552 for (int j = 0; j < i; j++) {
553 memsetAndFreeStrings(1, pStrings[j]);
561 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
563 if (pStrings != NULL) {
564 for (int i = 0 ; i < countStrings ; i++) {
565 memsetAndFreeStrings(1, pStrings[i]);
569 memset(pStrings, 0, countStrings * sizeof(char *));
576 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
577 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
582 int countStrings = data.size();
584 pStrings = (char **)calloc(countStrings, sizeof(char *));
585 if (pStrings == NULL) {
586 RLOGE("Memory allocation failed for request %s", requestToString(request));
587 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
591 for (int i = 0; i < countStrings; i++) {
592 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
593 for (int j = 0; j < i; j++) {
594 memsetAndFreeStrings(1, pStrings[j]);
601 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
603 if (pStrings != NULL) {
604 for (int i = 0 ; i < countStrings ; i++) {
605 memsetAndFreeStrings(1, pStrings[i]);
609 memset(pStrings, 0, countStrings * sizeof(char *));
616 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
617 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
622 int *pInts = (int *)calloc(countInts, sizeof(int));
625 RLOGE("Memory allocation failed for request %s", requestToString(request));
626 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
630 va_start(ap, countInts);
631 for (int i = 0; i < countInts; i++) {
632 pInts[i] = va_arg(ap, int);
636 CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
640 memset(pInts, 0, countInts * sizeof(int));
647 bool dispatchCallForwardStatus(int serial, int slotId, int request,
648 const CallForwardInfo& callInfo) {
649 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
654 RIL_CallForwardInfo cf;
655 cf.status = (int) callInfo.status;
656 cf.reason = callInfo.reason;
657 cf.serviceClass = callInfo.serviceClass;
658 cf.toa = callInfo.toa;
659 cf.timeSeconds = callInfo.timeSeconds;
661 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
665 CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
667 memsetAndFreeStrings(1, cf.number);
672 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
673 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
678 const uint8_t *uData = rawBytes.data();
680 CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
685 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
686 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
691 RIL_SIM_APDU apdu = {};
693 apdu.sessionid = message.sessionId;
694 apdu.cla = message.cla;
695 apdu.instruction = message.instruction;
696 apdu.p1 = message.p1;
697 apdu.p2 = message.p2;
698 apdu.p3 = message.p3;
700 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
704 CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
706 memsetAndFreeStrings(1, apdu.data);
711 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
712 if (ret.isOk() == false) {
713 RLOGE("checkReturnStatus: unable to call response/indication callback");
714 // Remote process hosting the callbacks must be dead. Reset the callback objects;
715 // there's no other recovery to be done here. When the client process is back up, it will
716 // call setResponseFunctions()
718 // Caller should already hold rdlock, release that first
719 // note the current counter to avoid overwriting updates made by another thread before
720 // write lock is acquired.
721 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
722 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
723 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
727 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
730 // make sure the counter value has not changed
731 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
732 if (isRadioService) {
733 radioService[slotId]->mRadioResponse = NULL;
734 radioService[slotId]->mRadioIndication = NULL;
736 oemHookService[slotId]->mOemHookResponse = NULL;
737 oemHookService[slotId]->mOemHookIndication = NULL;
739 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
741 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
742 "got updated on another thread");
746 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
750 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
755 void RadioImpl::checkReturnStatus(Return<void>& ret) {
756 ::checkReturnStatus(mSlotId, ret, true);
759 Return<void> RadioImpl::setResponseFunctions(
760 const ::android::sp<IRadioResponse>& radioResponseParam,
761 const ::android::sp<IRadioIndication>& radioIndicationParam) {
762 RLOGD("setResponseFunctions");
764 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
765 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
768 mRadioResponse = radioResponseParam;
769 mRadioIndication = radioIndicationParam;
770 mCounterRadio[mSlotId]++;
772 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
775 // client is connected. Send initial indications.
776 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
781 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
783 RLOGD("getIccCardStatus: serial %d", serial);
785 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
789 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
790 const hidl_string& aid) {
792 RLOGD("supplyIccPinForApp: serial %d", serial);
794 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
795 2, pin.c_str(), aid.c_str());
799 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
800 const hidl_string& pin, const hidl_string& aid) {
802 RLOGD("supplyIccPukForApp: serial %d", serial);
804 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
805 3, puk.c_str(), pin.c_str(), aid.c_str());
809 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
810 const hidl_string& aid) {
812 RLOGD("supplyIccPin2ForApp: serial %d", serial);
814 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
815 2, pin2.c_str(), aid.c_str());
819 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
820 const hidl_string& pin2, const hidl_string& aid) {
822 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
824 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
825 3, puk2.c_str(), pin2.c_str(), aid.c_str());
829 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
830 const hidl_string& newPin, const hidl_string& aid) {
832 RLOGD("changeIccPinForApp: serial %d", serial);
834 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
835 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
839 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
840 const hidl_string& newPin2, const hidl_string& aid) {
842 RLOGD("changeIccPin2ForApp: serial %d", serial);
844 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
845 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
849 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
850 const hidl_string& netPin) {
852 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
854 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
859 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
861 RLOGD("getCurrentCalls: serial %d", serial);
863 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
867 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
869 RLOGD("dial: serial %d", serial);
871 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
876 RIL_UUS_Info uusInfo = {};
877 int32_t sizeOfDial = sizeof(dial);
879 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
882 dial.clir = (int) dialInfo.clir;
884 if (dialInfo.uusInfo.size() != 0) {
885 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
886 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
888 if (dialInfo.uusInfo[0].uusData.size() == 0) {
889 uusInfo.uusData = NULL;
890 uusInfo.uusLength = 0;
892 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
893 memsetAndFreeStrings(1, dial.address);
896 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
899 dial.uusInfo = &uusInfo;
902 CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
904 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
909 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
911 RLOGD("getImsiForApp: serial %d", serial);
913 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
918 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
920 RLOGD("hangup: serial %d", serial);
922 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
926 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
928 RLOGD("hangupWaitingOrBackground: serial %d", serial);
930 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
934 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
936 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
938 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
942 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
944 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
946 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
950 Return<void> RadioImpl::conference(int32_t serial) {
952 RLOGD("conference: serial %d", serial);
954 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
958 Return<void> RadioImpl::rejectCall(int32_t serial) {
960 RLOGD("rejectCall: serial %d", serial);
962 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
966 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
968 RLOGD("getLastCallFailCause: serial %d", serial);
970 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
974 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
976 RLOGD("getSignalStrength: serial %d", serial);
978 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
982 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
984 RLOGD("getVoiceRegistrationState: serial %d", serial);
986 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
990 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
992 RLOGD("getDataRegistrationState: serial %d", serial);
994 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
998 Return<void> RadioImpl::getOperator(int32_t serial) {
1000 RLOGD("getOperator: serial %d", serial);
1002 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1006 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
1007 RLOGD("setRadioPower: serial %d on %d", serial, on);
1008 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1012 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1014 RLOGD("sendDtmf: serial %d", serial);
1016 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1020 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1022 RLOGD("sendSms: serial %d", serial);
1024 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
1025 2, message.smscPdu.c_str(), message.pdu.c_str());
1029 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1031 RLOGD("sendSMSExpectMore: serial %d", serial);
1033 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
1034 2, message.smscPdu.c_str(), message.pdu.c_str());
1038 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1040 case MvnoType::IMSI:
1041 str = (char *)"imsi";
1044 str = (char *)"gid";
1047 str = (char *)"spn";
1049 case MvnoType::NONE:
1056 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1057 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1058 bool roamingAllowed, bool isRoaming) {
1061 RLOGD("setupDataCall: serial %d", serial);
1064 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1065 const hidl_string &protocol =
1066 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1067 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
1068 std::to_string((int) radioTechnology + 2).c_str(),
1069 std::to_string((int) dataProfileInfo.profileId).c_str(),
1070 dataProfileInfo.apn.c_str(),
1071 dataProfileInfo.user.c_str(),
1072 dataProfileInfo.password.c_str(),
1073 std::to_string((int) dataProfileInfo.authType).c_str(),
1075 } else if (s_vendorFunctions->version >= 15) {
1076 char *mvnoTypeStr = NULL;
1077 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1078 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1079 RIL_REQUEST_SETUP_DATA_CALL);
1081 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1085 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1086 std::to_string((int) radioTechnology + 2).c_str(),
1087 std::to_string((int) dataProfileInfo.profileId).c_str(),
1088 dataProfileInfo.apn.c_str(),
1089 dataProfileInfo.user.c_str(),
1090 dataProfileInfo.password.c_str(),
1091 std::to_string((int) dataProfileInfo.authType).c_str(),
1092 dataProfileInfo.protocol.c_str(),
1093 dataProfileInfo.roamingProtocol.c_str(),
1094 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1095 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1096 modemCognitive ? "1" : "0",
1097 std::to_string(dataProfileInfo.mtu).c_str(),
1099 dataProfileInfo.mvnoMatchData.c_str(),
1100 roamingAllowed ? "1" : "0");
1102 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1103 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1104 RIL_REQUEST_SETUP_DATA_CALL);
1106 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1112 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1114 RLOGD("iccIOForApp: serial %d", serial);
1116 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1121 RIL_SIM_IO_v6 rilIccIo = {};
1122 rilIccIo.command = iccIo.command;
1123 rilIccIo.fileid = iccIo.fileId;
1124 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1128 rilIccIo.p1 = iccIo.p1;
1129 rilIccIo.p2 = iccIo.p2;
1130 rilIccIo.p3 = iccIo.p3;
1132 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1133 memsetAndFreeStrings(1, rilIccIo.path);
1137 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1138 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1142 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1143 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1147 CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1149 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1154 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1156 RLOGD("sendUssd: serial %d", serial);
1158 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1162 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1164 RLOGD("cancelPendingUssd: serial %d", serial);
1166 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1170 Return<void> RadioImpl::getClir(int32_t serial) {
1172 RLOGD("getClir: serial %d", serial);
1174 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1178 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1180 RLOGD("setClir: serial %d", serial);
1182 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1186 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1188 RLOGD("getCallForwardStatus: serial %d", serial);
1190 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1195 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1197 RLOGD("setCallForward: serial %d", serial);
1199 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1204 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1206 RLOGD("getCallWaiting: serial %d", serial);
1208 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1212 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1214 RLOGD("setCallWaiting: serial %d", serial);
1216 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1221 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1222 bool success, SmsAcknowledgeFailCause cause) {
1224 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1226 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1231 Return<void> RadioImpl::acceptCall(int32_t serial) {
1233 RLOGD("acceptCall: serial %d", serial);
1235 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1239 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1240 int32_t cid, bool reasonRadioShutDown) {
1242 RLOGD("deactivateDataCall: serial %d", serial);
1244 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1245 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1249 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1250 const hidl_string& password, int32_t serviceClass,
1251 const hidl_string& appId) {
1253 RLOGD("getFacilityLockForApp: serial %d", serial);
1255 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1256 4, facility.c_str(), password.c_str(),
1257 (std::to_string(serviceClass)).c_str(), appId.c_str());
1261 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1262 bool lockState, const hidl_string& password,
1263 int32_t serviceClass, const hidl_string& appId) {
1265 RLOGD("setFacilityLockForApp: serial %d", serial);
1267 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1268 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1269 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1273 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1274 const hidl_string& oldPassword,
1275 const hidl_string& newPassword) {
1277 RLOGD("setBarringPassword: serial %d", serial);
1279 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1280 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1284 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1286 RLOGD("getNetworkSelectionMode: serial %d", serial);
1288 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1292 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1294 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1296 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1300 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1301 const hidl_string& operatorNumeric) {
1303 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1305 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1306 operatorNumeric.c_str());
1310 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1312 RLOGD("getAvailableNetworks: serial %d", serial);
1314 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1318 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1320 RLOGD("startDtmf: serial %d", serial);
1322 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1327 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1329 RLOGD("stopDtmf: serial %d", serial);
1331 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1335 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1337 RLOGD("getBasebandVersion: serial %d", serial);
1339 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1343 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1345 RLOGD("separateConnection: serial %d", serial);
1347 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1351 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1353 RLOGD("setMute: serial %d", serial);
1355 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1359 Return<void> RadioImpl::getMute(int32_t serial) {
1361 RLOGD("getMute: serial %d", serial);
1363 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1367 Return<void> RadioImpl::getClip(int32_t serial) {
1369 RLOGD("getClip: serial %d", serial);
1371 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1375 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1377 RLOGD("getDataCallList: serial %d", serial);
1379 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1383 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1385 RLOGD("setSuppServiceNotifications: serial %d", serial);
1387 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1388 BOOL_TO_INT(enable));
1392 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1394 RLOGD("writeSmsToSim: serial %d", serial);
1396 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1401 RIL_SMS_WriteArgs args;
1402 args.status = (int) smsWriteArgs.status;
1405 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1409 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1410 memsetAndFreeStrings(1, args.pdu);
1414 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
1416 memsetAndFreeStrings(2, args.smsc, args.pdu);
1421 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1423 RLOGD("deleteSmsOnSim: serial %d", serial);
1425 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1429 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1431 RLOGD("setBandMode: serial %d", serial);
1433 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1437 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1439 RLOGD("getAvailableBandModes: serial %d", serial);
1441 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1445 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1447 RLOGD("sendEnvelope: serial %d", serial);
1449 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1454 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1455 const hidl_string& commandResponse) {
1457 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1459 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1460 commandResponse.c_str());
1464 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1466 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1468 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1469 1, BOOL_TO_INT(accept));
1473 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1475 RLOGD("explicitCallTransfer: serial %d", serial);
1477 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1481 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1483 RLOGD("setPreferredNetworkType: serial %d", serial);
1485 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1489 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1491 RLOGD("getPreferredNetworkType: serial %d", serial);
1493 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1497 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1499 RLOGD("getNeighboringCids: serial %d", serial);
1501 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1505 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1507 RLOGD("setLocationUpdates: serial %d", serial);
1509 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1513 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1515 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1517 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1521 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1523 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1525 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1529 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1531 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1533 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1537 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1539 RLOGD("setTTYMode: serial %d", serial);
1541 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1545 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1547 RLOGD("getTTYMode: serial %d", serial);
1549 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1553 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1555 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1557 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1558 1, BOOL_TO_INT(enable));
1562 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1564 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1566 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1570 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1572 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1574 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1575 featureCode.c_str());
1579 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1582 RLOGD("sendBurstDtmf: serial %d", serial);
1584 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1585 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1586 (std::to_string(off)).c_str());
1590 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1591 rcsm.uTeleserviceID = sms.teleserviceId;
1592 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1593 rcsm.uServicecategory = sms.serviceCategory;
1594 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1595 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1596 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1597 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1599 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1600 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1601 for (int i = 0; i < digitLimit; i++) {
1602 rcsm.sAddress.digits[i] = sms.address.digits[i];
1605 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1606 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1608 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1609 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1610 for (int i = 0; i < digitLimit; i++) {
1611 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1614 rcsm.uBearerDataLen = sms.bearerData.size();
1615 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1616 for (int i = 0; i < digitLimit; i++) {
1617 rcsm.aBearerData[i] = sms.bearerData[i];
1621 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1623 RLOGD("sendCdmaSms: serial %d", serial);
1625 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1630 RIL_CDMA_SMS_Message rcsm = {};
1631 constructCdmaSms(rcsm, sms);
1633 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
1637 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1639 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1641 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1646 RIL_CDMA_SMS_Ack rcsa = {};
1648 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1649 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1651 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
1655 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1657 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1659 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1663 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1664 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1667 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1669 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1670 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1675 int num = configInfo.size();
1676 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1677 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1679 for (int i = 0 ; i < num ; i++ ) {
1680 gsmBciPtrs[i] = &gsmBci[i];
1681 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1682 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1683 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1684 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1685 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1688 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs,
1689 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
1693 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1695 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1697 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1698 1, BOOL_TO_INT(!activate));
1702 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1704 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1706 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1710 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1711 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1714 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1716 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1717 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1722 int num = configInfo.size();
1723 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1724 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1726 for (int i = 0 ; i < num ; i++ ) {
1727 cdmaBciPtrs[i] = &cdmaBci[i];
1728 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1729 cdmaBci[i].language = configInfo[i].language;
1730 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1733 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs,
1734 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
1738 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1740 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1742 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1743 1, BOOL_TO_INT(!activate));
1747 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1749 RLOGD("getCDMASubscription: serial %d", serial);
1751 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1755 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1757 RLOGD("writeSmsToRuim: serial %d", serial);
1759 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1760 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1765 RIL_CDMA_SMS_WriteArgs rcsw = {};
1766 rcsw.status = (int) cdmaSms.status;
1767 constructCdmaSms(rcsw.message, cdmaSms.message);
1769 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
1773 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1775 RLOGD("deleteSmsOnRuim: serial %d", serial);
1777 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1781 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1783 RLOGD("getDeviceIdentity: serial %d", serial);
1785 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1789 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1791 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1793 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1797 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1799 RLOGD("getSmscAddress: serial %d", serial);
1801 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1805 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1807 RLOGD("setSmscAddress: serial %d", serial);
1809 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1814 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1816 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1818 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1819 BOOL_TO_INT(available));
1823 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1825 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1827 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1831 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1833 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1835 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1839 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1841 RLOGD("requestIsimAuthentication: serial %d", serial);
1843 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1848 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1849 const hidl_string& ackPdu) {
1851 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1853 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1854 2, success ? "1" : "0", ackPdu.c_str());
1858 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1860 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1862 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1867 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1869 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1871 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1875 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1877 RLOGD("getCellInfoList: serial %d", serial);
1879 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1883 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1885 RLOGD("setCellInfoListRate: serial %d", serial);
1887 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1891 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1892 bool modemCognitive, bool isRoaming) {
1894 RLOGD("setInitialAttachApn: serial %d", serial);
1896 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1897 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
1902 if (s_vendorFunctions->version <= 14) {
1903 RIL_InitialAttachApn iaa = {};
1905 if (dataProfileInfo.apn.size() == 0) {
1906 iaa.apn = (char *) calloc(1, sizeof(char));
1907 if (iaa.apn == NULL) {
1908 RLOGE("Memory allocation failed for request %s",
1909 requestToString(pRI->pCI->requestNumber));
1910 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1915 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1920 const hidl_string &protocol =
1921 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1923 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
1924 memsetAndFreeStrings(1, iaa.apn);
1927 iaa.authtype = (int) dataProfileInfo.authType;
1928 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1929 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
1932 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1933 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
1937 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
1939 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
1941 RIL_InitialAttachApn_v15 iaa = {};
1943 if (dataProfileInfo.apn.size() == 0) {
1944 iaa.apn = (char *) calloc(1, sizeof(char));
1945 if (iaa.apn == NULL) {
1946 RLOGE("Memory allocation failed for request %s",
1947 requestToString(pRI->pCI->requestNumber));
1948 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1953 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1958 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
1959 memsetAndFreeStrings(1, iaa.apn);
1962 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
1963 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
1966 iaa.authtype = (int) dataProfileInfo.authType;
1967 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1968 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
1971 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1972 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
1975 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
1976 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
1977 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
1978 iaa.mtu = dataProfileInfo.mtu;
1980 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
1981 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1982 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1987 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
1988 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1993 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
1995 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1996 iaa.password, iaa.mvnoMatchData);
2002 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
2004 RLOGD("getImsRegistrationState: serial %d", serial);
2006 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2010 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2011 RIL_IMS_SMS_Message rism = {};
2013 int countStrings = 2;
2014 int dataLen = sizeof(char *) * countStrings;
2016 rism.tech = RADIO_TECH_3GPP;
2017 rism.retry = BOOL_TO_INT(message.retry);
2018 rism.messageRef = message.messageRef;
2020 if (message.gsmMessage.size() != 1) {
2021 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2022 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2026 pStrings = (char **)calloc(countStrings, sizeof(char *));
2027 if (pStrings == NULL) {
2028 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2029 requestToString(pRI->pCI->requestNumber));
2030 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2034 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2036 memset(pStrings, 0, datalen);
2042 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2043 memsetAndFreeStrings(1, pStrings[0]);
2045 memset(pStrings, 0, datalen);
2051 rism.message.gsmMessage = pStrings;
2052 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2053 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2055 for (int i = 0 ; i < countStrings ; i++) {
2056 memsetAndFreeStrings(1, pStrings[i]);
2060 memset(pStrings, 0, datalen);
2067 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2068 RIL_IMS_SMS_Message rism = {};
2069 RIL_CDMA_SMS_Message rcsm = {};
2071 if (message.cdmaMessage.size() != 1) {
2072 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2073 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2077 rism.tech = RADIO_TECH_3GPP2;
2078 rism.retry = BOOL_TO_INT(message.retry);
2079 rism.messageRef = message.messageRef;
2080 rism.message.cdmaMessage = &rcsm;
2082 constructCdmaSms(rcsm, message.cdmaMessage[0]);
2084 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2085 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI, pRI->socket_id);
2090 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2092 RLOGD("sendImsSms: serial %d", serial);
2094 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2099 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2101 if (RADIO_TECH_3GPP == format) {
2102 dispatchImsGsmSms(message, pRI);
2103 } else if (RADIO_TECH_3GPP2 == format) {
2104 dispatchImsCdmaSms(message, pRI);
2106 RLOGE("sendImsSms: Invalid radio tech %s",
2107 requestToString(pRI->pCI->requestNumber));
2108 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2113 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2115 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2117 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2121 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2123 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2125 if (s_vendorFunctions->version < 15) {
2126 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2128 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2133 RIL_OpenChannelParams params = {};
2137 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2141 CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId);
2143 memsetAndFreeStrings(1, params.aidPtr);
2148 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2150 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2152 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2156 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2158 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2160 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2164 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2166 RLOGD("nvReadItem: serial %d", serial);
2168 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2173 RIL_NV_ReadItem nvri = {};
2174 nvri.itemID = (RIL_NV_Item) itemId;
2176 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2180 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2182 RLOGD("nvWriteItem: serial %d", serial);
2184 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2189 RIL_NV_WriteItem nvwi = {};
2191 nvwi.itemID = (RIL_NV_Item) item.itemId;
2193 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2197 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2199 memsetAndFreeStrings(1, nvwi.value);
2203 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2205 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2207 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2211 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2212 int rilResetType = -1;
2214 RLOGD("nvResetConfig: serial %d", serial);
2216 /* Convert ResetNvType to RIL.h values
2217 * RIL_REQUEST_NV_RESET_CONFIG
2218 * 1 - reload all NV items
2219 * 2 - erase NV reset (SCRTN)
2220 * 3 - factory reset (RTN)
2223 case ResetNvType::RELOAD:
2226 case ResetNvType::ERASE:
2229 case ResetNvType::FACTORY_RESET:
2233 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2237 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2239 RLOGD("setUiccSubscription: serial %d", serial);
2241 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2242 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2247 RIL_SelectUiccSub rilUiccSub = {};
2249 rilUiccSub.slot = uiccSub.slot;
2250 rilUiccSub.app_index = uiccSub.appIndex;
2251 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2252 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2254 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2258 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2260 RLOGD("setDataAllowed: serial %d", serial);
2262 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2266 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2268 RLOGD("getHardwareConfig: serial %d", serial);
2270 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2274 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2275 const hidl_string& authData, const hidl_string& aid) {
2277 RLOGD("requestIccSimAuthentication: serial %d", serial);
2279 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2284 RIL_SimAuthentication pf = {};
2286 pf.authContext = authContext;
2289 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2293 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2294 memsetAndFreeStrings(1, pf.authData);
2298 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2300 memsetAndFreeStrings(2, pf.authData, pf.aid);
2305 * @param numProfiles number of data profile
2306 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2307 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2308 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2309 * @param numfields number of string-type member in the data profile structure
2310 * @param ... the variadic parameters are pointers to each string-type member
2312 template <typename T>
2313 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2314 int numfields, ...) {
2316 va_start(args, numfields);
2318 // Iterate through each string-type field that need to be free.
2319 for (int i = 0; i < numfields; i++) {
2320 // Iterate through each data profile and free that specific string-type field.
2321 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2322 char *T::*ptr = va_arg(args, char *T::*);
2323 for (int j = 0; j < numProfiles; j++) {
2324 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2331 memset(dataProfiles, 0, numProfiles * sizeof(T));
2332 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2335 free(dataProfilePtrs);
2338 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2341 RLOGD("setDataProfile: serial %d", serial);
2343 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2348 size_t num = profiles.size();
2349 bool success = false;
2351 if (s_vendorFunctions->version <= 14) {
2353 RIL_DataProfileInfo *dataProfiles =
2354 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2356 if (dataProfiles == NULL) {
2357 RLOGE("Memory allocation failed for request %s",
2358 requestToString(pRI->pCI->requestNumber));
2359 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2363 RIL_DataProfileInfo **dataProfilePtrs =
2364 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2365 if (dataProfilePtrs == NULL) {
2366 RLOGE("Memory allocation failed for request %s",
2367 requestToString(pRI->pCI->requestNumber));
2369 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2373 for (size_t i = 0; i < num; i++) {
2374 dataProfilePtrs[i] = &dataProfiles[i];
2376 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2378 const hidl_string &protocol =
2379 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2381 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2385 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2388 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2394 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2395 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2396 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2400 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2401 dataProfiles[i].authType = (int) profiles[i].authType;
2402 dataProfiles[i].type = (int) profiles[i].type;
2403 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2404 dataProfiles[i].maxConns = profiles[i].maxConns;
2405 dataProfiles[i].waitTime = profiles[i].waitTime;
2406 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2409 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2410 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2412 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2413 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2414 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2416 RIL_DataProfileInfo_v15 *dataProfiles =
2417 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2419 if (dataProfiles == NULL) {
2420 RLOGE("Memory allocation failed for request %s",
2421 requestToString(pRI->pCI->requestNumber));
2422 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2426 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2427 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2428 if (dataProfilePtrs == NULL) {
2429 RLOGE("Memory allocation failed for request %s",
2430 requestToString(pRI->pCI->requestNumber));
2432 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2436 for (size_t i = 0; i < num; i++) {
2437 dataProfilePtrs[i] = &dataProfiles[i];
2439 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2440 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2444 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2445 profiles[i].roamingProtocol, pRI)) {
2448 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2451 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2456 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2457 profiles[i].mvnoMatchData, pRI)) {
2461 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2462 dataProfiles[i].mvnoType)) {
2463 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2468 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2469 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2470 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2471 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2475 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2476 dataProfiles[i].authType = (int) profiles[i].authType;
2477 dataProfiles[i].type = (int) profiles[i].type;
2478 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2479 dataProfiles[i].maxConns = profiles[i].maxConns;
2480 dataProfiles[i].waitTime = profiles[i].waitTime;
2481 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2482 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2483 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2484 dataProfiles[i].mtu = profiles[i].mtu;
2487 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2488 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
2490 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2491 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2492 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2493 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2499 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2501 RLOGD("requestShutdown: serial %d", serial);
2503 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2507 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2509 RLOGD("getRadioCapability: serial %d", serial);
2511 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2515 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2517 RLOGD("setRadioCapability: serial %d", serial);
2519 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2524 RIL_RadioCapability rilRc = {};
2526 // TODO : set rilRc.version using HIDL version ?
2527 rilRc.session = rc.session;
2528 rilRc.phase = (int) rc.phase;
2529 rilRc.rat = (int) rc.raf;
2530 rilRc.status = (int) rc.status;
2531 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2533 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
2538 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2540 RLOGD("startLceService: serial %d", serial);
2542 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2543 BOOL_TO_INT(pullMode));
2547 Return<void> RadioImpl::stopLceService(int32_t serial) {
2549 RLOGD("stopLceService: serial %d", serial);
2551 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2555 Return<void> RadioImpl::pullLceData(int32_t serial) {
2557 RLOGD("pullLceData: serial %d", serial);
2559 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2563 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2565 RLOGD("getModemActivityInfo: serial %d", serial);
2567 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2571 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2572 const CarrierRestrictions& carriers) {
2574 RLOGD("setAllowedCarriers: serial %d", serial);
2576 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2577 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2582 RIL_CarrierRestrictions cr = {};
2583 RIL_Carrier *allowedCarriers = NULL;
2584 RIL_Carrier *excludedCarriers = NULL;
2586 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2587 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2588 if (allowedCarriers == NULL) {
2589 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2590 requestToString(pRI->pCI->requestNumber));
2591 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2594 cr.allowed_carriers = allowedCarriers;
2596 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2597 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2598 if (excludedCarriers == NULL) {
2599 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2600 requestToString(pRI->pCI->requestNumber));
2601 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2603 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2605 free(allowedCarriers);
2608 cr.excluded_carriers = excludedCarriers;
2610 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2611 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2612 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2613 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2614 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2617 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2618 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2619 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2620 excludedCarriers[i].match_type =
2621 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2622 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2625 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
2628 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2629 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2631 free(allowedCarriers);
2632 free(excludedCarriers);
2636 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2638 RLOGD("getAllowedCarriers: serial %d", serial);
2640 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2644 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2647 RLOGD("sendDeviceState: serial %d", serial);
2649 if (s_vendorFunctions->version < 15) {
2650 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2651 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2652 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2654 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2655 RIL_REQUEST_SEND_DEVICE_STATE);
2656 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2660 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2661 BOOL_TO_INT(state));
2665 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2667 RLOGD("setIndicationFilter: serial %d", serial);
2669 if (s_vendorFunctions->version < 15) {
2670 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2671 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2672 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2675 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2679 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2681 RLOGD("setSimCardPower: serial %d", serial);
2683 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2687 Return<void> RadioImpl::responseAcknowledgement() {
2688 android::releaseWakeLock();
2692 Return<void> OemHookImpl::setResponseFunctions(
2693 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2694 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2696 RLOGD("OemHookImpl::setResponseFunctions");
2699 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2700 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2703 mOemHookResponse = oemHookResponseParam;
2704 mOemHookIndication = oemHookIndicationParam;
2705 mCounterOemHook[mSlotId]++;
2707 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2713 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2715 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2717 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2721 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2722 const hidl_vec<hidl_string>& data) {
2724 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2726 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2730 /***************************************************************************************************
2731 * RESPONSE FUNCTIONS
2732 * Functions above are used for requests going from framework to vendor code. The ones below are
2733 * responses for those requests coming back from the vendor code.
2734 **************************************************************************************************/
2736 void radio::acknowledgeRequest(int slotId, int serial) {
2737 if (radioService[slotId]->mRadioResponse != NULL) {
2738 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2739 radioService[slotId]->checkReturnStatus(retStatus);
2741 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2745 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2747 responseInfo.serial = serial;
2748 switch (responseType) {
2749 case RESPONSE_SOLICITED:
2750 responseInfo.type = RadioResponseType::SOLICITED;
2752 case RESPONSE_SOLICITED_ACK_EXP:
2753 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2756 responseInfo.error = (RadioError) e;
2759 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2760 void *response, size_t responseLen) {
2761 populateResponseInfo(responseInfo, serial, responseType, e);
2764 if (response == NULL && responseLen == 0) {
2765 // Earlier RILs did not send a response for some cases although the interface
2766 // expected an integer as response. Do not return error if response is empty. Instead
2767 // Return -1 in those cases to maintain backward compatibility.
2768 } else if (response == NULL || responseLen != sizeof(int)) {
2769 RLOGE("responseIntOrEmpty: Invalid response");
2770 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2772 int *p_int = (int *) response;
2778 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2779 void *response, size_t responseLen) {
2780 populateResponseInfo(responseInfo, serial, responseType, e);
2783 if (response == NULL || responseLen != sizeof(int)) {
2784 RLOGE("responseInt: Invalid response");
2785 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2787 int *p_int = (int *) response;
2793 int radio::getIccCardStatusResponse(int slotId,
2794 int responseType, int serial, RIL_Errno e,
2795 void *response, size_t responseLen) {
2796 if (radioService[slotId]->mRadioResponse != NULL) {
2797 RadioResponseInfo responseInfo = {};
2798 populateResponseInfo(responseInfo, serial, responseType, e);
2799 CardStatus cardStatus = {};
2800 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2801 RLOGE("getIccCardStatusResponse: Invalid response");
2802 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2804 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2805 cardStatus.cardState = (CardState) p_cur->card_state;
2806 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2807 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2808 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2809 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2811 RIL_AppStatus *rilAppStatus = p_cur->applications;
2812 cardStatus.applications.resize(p_cur->num_applications);
2813 AppStatus *appStatus = cardStatus.applications.data();
2815 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2817 for (int i = 0; i < p_cur->num_applications; i++) {
2818 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2819 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2820 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2821 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2822 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2823 rilAppStatus[i].app_label_ptr);
2824 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2825 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2826 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2830 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2831 getIccCardStatusResponse(responseInfo, cardStatus);
2832 radioService[slotId]->checkReturnStatus(retStatus);
2834 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2840 int radio::supplyIccPinForAppResponse(int slotId,
2841 int responseType, int serial, RIL_Errno e,
2842 void *response, size_t responseLen) {
2844 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
2847 if (radioService[slotId]->mRadioResponse != NULL) {
2848 RadioResponseInfo responseInfo = {};
2849 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2850 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2851 supplyIccPinForAppResponse(responseInfo, ret);
2852 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
2853 radioService[slotId]->checkReturnStatus(retStatus);
2855 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2862 int radio::supplyIccPukForAppResponse(int slotId,
2863 int responseType, int serial, RIL_Errno e,
2864 void *response, size_t responseLen) {
2866 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
2869 if (radioService[slotId]->mRadioResponse != NULL) {
2870 RadioResponseInfo responseInfo = {};
2871 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2872 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2874 radioService[slotId]->checkReturnStatus(retStatus);
2876 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2883 int radio::supplyIccPin2ForAppResponse(int slotId,
2884 int responseType, int serial, RIL_Errno e,
2885 void *response, size_t responseLen) {
2887 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
2890 if (radioService[slotId]->mRadioResponse != NULL) {
2891 RadioResponseInfo responseInfo = {};
2892 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2893 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2894 supplyIccPin2ForAppResponse(responseInfo, ret);
2895 radioService[slotId]->checkReturnStatus(retStatus);
2897 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2904 int radio::supplyIccPuk2ForAppResponse(int slotId,
2905 int responseType, int serial, RIL_Errno e,
2906 void *response, size_t responseLen) {
2908 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
2911 if (radioService[slotId]->mRadioResponse != NULL) {
2912 RadioResponseInfo responseInfo = {};
2913 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2914 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2915 supplyIccPuk2ForAppResponse(responseInfo, ret);
2916 radioService[slotId]->checkReturnStatus(retStatus);
2918 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2925 int radio::changeIccPinForAppResponse(int slotId,
2926 int responseType, int serial, RIL_Errno e,
2927 void *response, size_t responseLen) {
2929 RLOGD("changeIccPinForAppResponse: serial %d", serial);
2932 if (radioService[slotId]->mRadioResponse != NULL) {
2933 RadioResponseInfo responseInfo = {};
2934 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2935 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2936 changeIccPinForAppResponse(responseInfo, ret);
2937 radioService[slotId]->checkReturnStatus(retStatus);
2939 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2946 int radio::changeIccPin2ForAppResponse(int slotId,
2947 int responseType, int serial, RIL_Errno e,
2948 void *response, size_t responseLen) {
2950 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
2953 if (radioService[slotId]->mRadioResponse != NULL) {
2954 RadioResponseInfo responseInfo = {};
2955 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2956 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2957 changeIccPin2ForAppResponse(responseInfo, ret);
2958 radioService[slotId]->checkReturnStatus(retStatus);
2960 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2967 int radio::supplyNetworkDepersonalizationResponse(int slotId,
2968 int responseType, int serial, RIL_Errno e,
2969 void *response, size_t responseLen) {
2971 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
2974 if (radioService[slotId]->mRadioResponse != NULL) {
2975 RadioResponseInfo responseInfo = {};
2976 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2977 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2978 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2979 radioService[slotId]->checkReturnStatus(retStatus);
2981 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
2988 int radio::getCurrentCallsResponse(int slotId,
2989 int responseType, int serial, RIL_Errno e,
2990 void *response, size_t responseLen) {
2992 RLOGD("getCurrentCallsResponse: serial %d", serial);
2995 if (radioService[slotId]->mRadioResponse != NULL) {
2996 RadioResponseInfo responseInfo = {};
2997 populateResponseInfo(responseInfo, serial, responseType, e);
2999 hidl_vec<Call> calls;
3000 if ((response == NULL && responseLen != 0)
3001 || (responseLen % sizeof(RIL_Call *)) != 0) {
3002 RLOGE("getCurrentCallsResponse: Invalid response");
3003 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3005 int num = responseLen / sizeof(RIL_Call *);
3008 for (int i = 0 ; i < num ; i++) {
3009 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3010 /* each call info */
3011 calls[i].state = (CallState) p_cur->state;
3012 calls[i].index = p_cur->index;
3013 calls[i].toa = p_cur->toa;
3014 calls[i].isMpty = p_cur->isMpty;
3015 calls[i].isMT = p_cur->isMT;
3016 calls[i].als = p_cur->als;
3017 calls[i].isVoice = p_cur->isVoice;
3018 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3019 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3020 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3021 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3022 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3023 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3024 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3025 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3026 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3027 // convert uusInfo->uusData to a null-terminated string
3028 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3029 calls[i].uusInfo[0].uusData = nullTermStr;
3035 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3036 getCurrentCallsResponse(responseInfo, calls);
3037 radioService[slotId]->checkReturnStatus(retStatus);
3039 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3045 int radio::dialResponse(int slotId,
3046 int responseType, int serial, RIL_Errno e, void *response,
3047 size_t responseLen) {
3049 RLOGD("dialResponse: serial %d", serial);
3052 if (radioService[slotId]->mRadioResponse != NULL) {
3053 RadioResponseInfo responseInfo = {};
3054 populateResponseInfo(responseInfo, serial, responseType, e);
3055 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3056 radioService[slotId]->checkReturnStatus(retStatus);
3058 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3064 int radio::getIMSIForAppResponse(int slotId,
3065 int responseType, int serial, RIL_Errno e, void *response,
3066 size_t responseLen) {
3068 RLOGD("getIMSIForAppResponse: serial %d", serial);
3071 if (radioService[slotId]->mRadioResponse != NULL) {
3072 RadioResponseInfo responseInfo = {};
3073 populateResponseInfo(responseInfo, serial, responseType, e);
3074 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3075 responseInfo, convertCharPtrToHidlString((char *) response));
3076 radioService[slotId]->checkReturnStatus(retStatus);
3078 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3085 int radio::hangupConnectionResponse(int slotId,
3086 int responseType, int serial, RIL_Errno e,
3087 void *response, size_t responseLen) {
3089 RLOGD("hangupConnectionResponse: serial %d", serial);
3092 if (radioService[slotId]->mRadioResponse != NULL) {
3093 RadioResponseInfo responseInfo = {};
3094 populateResponseInfo(responseInfo, serial, responseType, e);
3095 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3097 radioService[slotId]->checkReturnStatus(retStatus);
3099 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3106 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3107 int responseType, int serial, RIL_Errno e,
3108 void *response, size_t responseLen) {
3110 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3113 if (radioService[slotId]->mRadioResponse != NULL) {
3114 RadioResponseInfo responseInfo = {};
3115 populateResponseInfo(responseInfo, serial, responseType, e);
3116 Return<void> retStatus =
3117 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3119 radioService[slotId]->checkReturnStatus(retStatus);
3121 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3128 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3129 RIL_Errno e, void *response,
3130 size_t responseLen) {
3132 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3135 if (radioService[slotId]->mRadioResponse != NULL) {
3136 RadioResponseInfo responseInfo = {};
3137 populateResponseInfo(responseInfo, serial, responseType, e);
3138 Return<void> retStatus =
3139 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3141 radioService[slotId]->checkReturnStatus(retStatus);
3143 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3150 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3151 RIL_Errno e, void *response,
3152 size_t responseLen) {
3154 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3157 if (radioService[slotId]->mRadioResponse != NULL) {
3158 RadioResponseInfo responseInfo = {};
3159 populateResponseInfo(responseInfo, serial, responseType, e);
3160 Return<void> retStatus =
3161 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3163 radioService[slotId]->checkReturnStatus(retStatus);
3165 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3172 int radio::conferenceResponse(int slotId, int responseType,
3173 int serial, RIL_Errno e, void *response, size_t responseLen) {
3175 RLOGD("conferenceResponse: serial %d", serial);
3178 if (radioService[slotId]->mRadioResponse != NULL) {
3179 RadioResponseInfo responseInfo = {};
3180 populateResponseInfo(responseInfo, serial, responseType, e);
3181 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3183 radioService[slotId]->checkReturnStatus(retStatus);
3185 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3192 int radio::rejectCallResponse(int slotId, int responseType,
3193 int serial, RIL_Errno e, void *response, size_t responseLen) {
3195 RLOGD("rejectCallResponse: serial %d", serial);
3198 if (radioService[slotId]->mRadioResponse != NULL) {
3199 RadioResponseInfo responseInfo = {};
3200 populateResponseInfo(responseInfo, serial, responseType, e);
3201 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3203 radioService[slotId]->checkReturnStatus(retStatus);
3205 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3212 int radio::getLastCallFailCauseResponse(int slotId,
3213 int responseType, int serial, RIL_Errno e, void *response,
3214 size_t responseLen) {
3216 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3219 if (radioService[slotId]->mRadioResponse != NULL) {
3220 RadioResponseInfo responseInfo = {};
3221 populateResponseInfo(responseInfo, serial, responseType, e);
3223 LastCallFailCauseInfo info = {};
3224 info.vendorCause = hidl_string();
3225 if (response == NULL) {
3226 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3227 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3228 } else if (responseLen == sizeof(int)) {
3229 int *pInt = (int *) response;
3230 info.causeCode = (LastCallFailCause) pInt[0];
3231 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3232 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3233 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3234 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3236 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3237 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3240 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3241 responseInfo, info);
3242 radioService[slotId]->checkReturnStatus(retStatus);
3244 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3251 int radio::getSignalStrengthResponse(int slotId,
3252 int responseType, int serial, RIL_Errno e,
3253 void *response, size_t responseLen) {
3255 RLOGD("getSignalStrengthResponse: serial %d", serial);
3258 if (radioService[slotId]->mRadioResponse != NULL) {
3259 RadioResponseInfo responseInfo = {};
3260 populateResponseInfo(responseInfo, serial, responseType, e);
3261 SignalStrength signalStrength = {};
3262 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3263 RLOGE("getSignalStrengthResponse: Invalid response");
3264 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3266 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3269 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3270 responseInfo, signalStrength);
3271 radioService[slotId]->checkReturnStatus(retStatus);
3273 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3280 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3282 return RIL_CELL_INFO_TYPE_NONE;
3285 int radioTech = atoi(rat);
3289 case RADIO_TECH_GPRS:
3290 case RADIO_TECH_EDGE:
3291 case RADIO_TECH_GSM: {
3292 return RIL_CELL_INFO_TYPE_GSM;
3295 case RADIO_TECH_UMTS:
3296 case RADIO_TECH_HSDPA:
3297 case RADIO_TECH_HSUPA:
3298 case RADIO_TECH_HSPA:
3299 case RADIO_TECH_HSPAP: {
3300 return RIL_CELL_INFO_TYPE_WCDMA;
3303 case RADIO_TECH_IS95A:
3304 case RADIO_TECH_IS95B:
3305 case RADIO_TECH_1xRTT:
3306 case RADIO_TECH_EVDO_0:
3307 case RADIO_TECH_EVDO_A:
3308 case RADIO_TECH_EVDO_B:
3309 case RADIO_TECH_EHRPD: {
3310 return RIL_CELL_INFO_TYPE_CDMA;
3313 case RADIO_TECH_LTE:
3314 case RADIO_TECH_LTE_CA: {
3315 return RIL_CELL_INFO_TYPE_LTE;
3318 case RADIO_TECH_TD_SCDMA: {
3319 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3327 return RIL_CELL_INFO_TYPE_NONE;
3331 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3333 cellIdentity.cellIdentityGsm.resize(0);
3334 cellIdentity.cellIdentityWcdma.resize(0);
3335 cellIdentity.cellIdentityCdma.resize(0);
3336 cellIdentity.cellIdentityTdscdma.resize(0);
3337 cellIdentity.cellIdentityLte.resize(0);
3338 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3339 switch(rilCellIdentity.cellInfoType) {
3341 case RIL_CELL_INFO_TYPE_GSM: {
3342 cellIdentity.cellIdentityGsm.resize(1);
3343 cellIdentity.cellIdentityGsm[0].mcc =
3344 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3345 cellIdentity.cellIdentityGsm[0].mnc =
3346 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3347 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3348 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3349 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3350 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3354 case RIL_CELL_INFO_TYPE_WCDMA: {
3355 cellIdentity.cellIdentityWcdma.resize(1);
3356 cellIdentity.cellIdentityWcdma[0].mcc =
3357 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3358 cellIdentity.cellIdentityWcdma[0].mnc =
3359 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3360 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3361 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3362 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3363 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3367 case RIL_CELL_INFO_TYPE_CDMA: {
3368 cellIdentity.cellIdentityCdma.resize(1);
3369 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3370 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3371 cellIdentity.cellIdentityCdma[0].baseStationId =
3372 rilCellIdentity.cellIdentityCdma.basestationId;
3373 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3374 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3378 case RIL_CELL_INFO_TYPE_LTE: {
3379 cellIdentity.cellIdentityLte.resize(1);
3380 cellIdentity.cellIdentityLte[0].mcc =
3381 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3382 cellIdentity.cellIdentityLte[0].mnc =
3383 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3384 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3385 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3386 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3387 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3391 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3392 cellIdentity.cellIdentityTdscdma.resize(1);
3393 cellIdentity.cellIdentityTdscdma[0].mcc =
3394 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3395 cellIdentity.cellIdentityTdscdma[0].mnc =
3396 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3397 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3398 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3399 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3409 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3410 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3411 return atoi(response[index]);
3417 int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
3418 const int hexBase = 16;
3419 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3420 return strtol(response[index], NULL, hexBase);
3426 /* Fill Cell Identity info from Voice Registration State Response.
3427 * This fucntion is applicable only for RIL Version < 15.
3428 * Response is a "char **".
3429 * First and Second entries are in hex string format
3430 * and rest are integers represented in ascii format. */
3431 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3432 int numStrings, char** response) {
3434 RIL_CellIdentity_v16 rilCellIdentity;
3435 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3437 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3438 switch(rilCellIdentity.cellInfoType) {
3440 case RIL_CELL_INFO_TYPE_GSM: {
3441 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3442 rilCellIdentity.cellIdentityGsm.lac =
3443 convertResponseHexStringEntryToInt(response, 1, numStrings);
3445 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3446 rilCellIdentity.cellIdentityGsm.cid =
3447 convertResponseHexStringEntryToInt(response, 2, numStrings);
3451 case RIL_CELL_INFO_TYPE_WCDMA: {
3452 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3453 rilCellIdentity.cellIdentityWcdma.lac =
3454 convertResponseHexStringEntryToInt(response, 1, numStrings);
3456 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3457 rilCellIdentity.cellIdentityWcdma.cid =
3458 convertResponseHexStringEntryToInt(response, 2, numStrings);
3459 rilCellIdentity.cellIdentityWcdma.psc =
3460 convertResponseStringEntryToInt(response, 14, numStrings);
3464 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3465 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3466 rilCellIdentity.cellIdentityTdscdma.lac =
3467 convertResponseHexStringEntryToInt(response, 1, numStrings);
3469 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3470 rilCellIdentity.cellIdentityTdscdma.cid =
3471 convertResponseHexStringEntryToInt(response, 2, numStrings);
3475 case RIL_CELL_INFO_TYPE_CDMA:{
3476 rilCellIdentity.cellIdentityCdma.basestationId =
3477 convertResponseStringEntryToInt(response, 4, numStrings);
3478 rilCellIdentity.cellIdentityCdma.longitude =
3479 convertResponseStringEntryToInt(response, 5, numStrings);
3480 rilCellIdentity.cellIdentityCdma.latitude =
3481 convertResponseStringEntryToInt(response, 6, numStrings);
3482 rilCellIdentity.cellIdentityCdma.systemId =
3483 convertResponseStringEntryToInt(response, 8, numStrings);
3484 rilCellIdentity.cellIdentityCdma.networkId =
3485 convertResponseStringEntryToInt(response, 9, numStrings);
3489 case RIL_CELL_INFO_TYPE_LTE:{
3490 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
3491 rilCellIdentity.cellIdentityLte.tac =
3492 convertResponseHexStringEntryToInt(response, 1, numStrings);
3494 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3495 rilCellIdentity.cellIdentityLte.ci =
3496 convertResponseHexStringEntryToInt(response, 2, numStrings);
3505 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3508 /* Fill Cell Identity info from Data Registration State Response.
3509 * This fucntion is applicable only for RIL Version < 15.
3510 * Response is a "char **".
3511 * First and Second entries are in hex string format
3512 * and rest are integers represented in ascii format. */
3513 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3514 int numStrings, char** response) {
3516 RIL_CellIdentity_v16 rilCellIdentity;
3517 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3519 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3520 switch(rilCellIdentity.cellInfoType) {
3521 case RIL_CELL_INFO_TYPE_GSM: {
3522 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3523 rilCellIdentity.cellIdentityGsm.lac =
3524 convertResponseHexStringEntryToInt(response, 1, numStrings);
3526 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3527 rilCellIdentity.cellIdentityGsm.cid =
3528 convertResponseHexStringEntryToInt(response, 2, numStrings);
3531 case RIL_CELL_INFO_TYPE_WCDMA: {
3532 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3533 rilCellIdentity.cellIdentityWcdma.lac =
3534 convertResponseHexStringEntryToInt(response, 1, numStrings);
3536 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3537 rilCellIdentity.cellIdentityWcdma.cid =
3538 convertResponseHexStringEntryToInt(response, 2, numStrings);
3541 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3542 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3543 rilCellIdentity.cellIdentityTdscdma.lac =
3544 convertResponseHexStringEntryToInt(response, 1, numStrings);
3546 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3547 rilCellIdentity.cellIdentityTdscdma.cid =
3548 convertResponseHexStringEntryToInt(response, 2, numStrings);
3551 case RIL_CELL_INFO_TYPE_LTE: {
3552 rilCellIdentity.cellIdentityLte.tac =
3553 convertResponseStringEntryToInt(response, 6, numStrings);
3554 rilCellIdentity.cellIdentityLte.pci =
3555 convertResponseStringEntryToInt(response, 7, numStrings);
3556 rilCellIdentity.cellIdentityLte.ci =
3557 convertResponseStringEntryToInt(response, 8, numStrings);
3565 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3568 int radio::getVoiceRegistrationStateResponse(int slotId,
3569 int responseType, int serial, RIL_Errno e,
3570 void *response, size_t responseLen) {
3572 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3575 if (radioService[slotId]->mRadioResponse != NULL) {
3576 RadioResponseInfo responseInfo = {};
3577 populateResponseInfo(responseInfo, serial, responseType, e);
3579 VoiceRegStateResult voiceRegResponse = {};
3580 int numStrings = responseLen / sizeof(char *);
3581 if (response == NULL) {
3582 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3583 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3584 } else if (s_vendorFunctions->version <= 14) {
3585 if (numStrings != 15) {
3586 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3587 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3589 char **resp = (char **) response;
3590 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3591 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3592 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3593 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3594 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3595 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3596 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3597 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3601 RIL_VoiceRegistrationStateResponse *voiceRegState =
3602 (RIL_VoiceRegistrationStateResponse *)response;
3604 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3605 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3606 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3608 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3609 voiceRegResponse.rat = voiceRegState->rat;;
3610 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3611 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3612 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3613 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3614 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3615 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3616 voiceRegState->cellIdentity);
3620 Return<void> retStatus =
3621 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3622 responseInfo, voiceRegResponse);
3623 radioService[slotId]->checkReturnStatus(retStatus);
3625 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3632 int radio::getDataRegistrationStateResponse(int slotId,
3633 int responseType, int serial, RIL_Errno e,
3634 void *response, size_t responseLen) {
3636 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3639 if (radioService[slotId]->mRadioResponse != NULL) {
3640 RadioResponseInfo responseInfo = {};
3641 populateResponseInfo(responseInfo, serial, responseType, e);
3642 DataRegStateResult dataRegResponse = {};
3643 if (response == NULL) {
3644 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3645 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3646 } else if (s_vendorFunctions->version <= 14) {
3647 int numStrings = responseLen / sizeof(char *);
3648 if ((numStrings != 6) && (numStrings != 11)) {
3649 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3650 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3652 char **resp = (char **) response;
3653 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3654 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3655 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3656 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3657 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3661 RIL_DataRegistrationStateResponse *dataRegState =
3662 (RIL_DataRegistrationStateResponse *)response;
3664 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3665 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3666 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3668 dataRegResponse.regState = (RegState) dataRegState->regState;
3669 dataRegResponse.rat = dataRegState->rat;;
3670 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3671 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3672 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3676 Return<void> retStatus =
3677 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3679 radioService[slotId]->checkReturnStatus(retStatus);
3681 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3688 int radio::getOperatorResponse(int slotId,
3689 int responseType, int serial, RIL_Errno e, void *response,
3690 size_t responseLen) {
3692 RLOGD("getOperatorResponse: serial %d", serial);
3695 if (radioService[slotId]->mRadioResponse != NULL) {
3696 RadioResponseInfo responseInfo = {};
3697 populateResponseInfo(responseInfo, serial, responseType, e);
3698 hidl_string longName;
3699 hidl_string shortName;
3700 hidl_string numeric;
3701 int numStrings = responseLen / sizeof(char *);
3702 if (response == NULL || numStrings != 3) {
3703 RLOGE("getOperatorResponse Invalid response: NULL");
3704 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3707 char **resp = (char **) response;
3708 longName = convertCharPtrToHidlString(resp[0]);
3709 shortName = convertCharPtrToHidlString(resp[1]);
3710 numeric = convertCharPtrToHidlString(resp[2]);
3712 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3713 responseInfo, longName, shortName, numeric);
3714 radioService[slotId]->checkReturnStatus(retStatus);
3716 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3723 int radio::setRadioPowerResponse(int slotId,
3724 int responseType, int serial, RIL_Errno e, void *response,
3725 size_t responseLen) {
3726 RLOGD("setRadioPowerResponse: serial %d", serial);
3728 if (radioService[slotId]->mRadioResponse != NULL) {
3729 RadioResponseInfo responseInfo = {};
3730 populateResponseInfo(responseInfo, serial, responseType, e);
3731 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3733 radioService[slotId]->checkReturnStatus(retStatus);
3735 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3742 int radio::sendDtmfResponse(int slotId,
3743 int responseType, int serial, RIL_Errno e, void *response,
3744 size_t responseLen) {
3746 RLOGD("sendDtmfResponse: serial %d", serial);
3749 if (radioService[slotId]->mRadioResponse != NULL) {
3750 RadioResponseInfo responseInfo = {};
3751 populateResponseInfo(responseInfo, serial, responseType, e);
3752 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3754 radioService[slotId]->checkReturnStatus(retStatus);
3756 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3763 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3764 RIL_Errno e, void *response, size_t responseLen) {
3765 populateResponseInfo(responseInfo, serial, responseType, e);
3766 SendSmsResult result = {};
3768 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3769 RLOGE("Invalid response: NULL");
3770 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3771 result.ackPDU = hidl_string();
3773 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3774 result.messageRef = resp->messageRef;
3775 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3776 result.errorCode = resp->errorCode;
3781 int radio::sendSmsResponse(int slotId,
3782 int responseType, int serial, RIL_Errno e, void *response,
3783 size_t responseLen) {
3785 RLOGD("sendSmsResponse: serial %d", serial);
3788 if (radioService[slotId]->mRadioResponse != NULL) {
3789 RadioResponseInfo responseInfo = {};
3790 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3793 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3795 radioService[slotId]->checkReturnStatus(retStatus);
3797 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3803 int radio::sendSMSExpectMoreResponse(int slotId,
3804 int responseType, int serial, RIL_Errno e, void *response,
3805 size_t responseLen) {
3807 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3810 if (radioService[slotId]->mRadioResponse != NULL) {
3811 RadioResponseInfo responseInfo = {};
3812 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3815 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3816 responseInfo, result);
3817 radioService[slotId]->checkReturnStatus(retStatus);
3819 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3825 int radio::setupDataCallResponse(int slotId,
3826 int responseType, int serial, RIL_Errno e, void *response,
3827 size_t responseLen) {
3829 RLOGD("setupDataCallResponse: serial %d", serial);
3832 if (radioService[slotId]->mRadioResponse != NULL) {
3833 RadioResponseInfo responseInfo = {};
3834 populateResponseInfo(responseInfo, serial, responseType, e);
3836 SetupDataCallResult result = {};
3837 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
3838 if (response != NULL) {
3839 RLOGE("setupDataCallResponse: Invalid response");
3840 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3842 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3843 result.type = hidl_string();
3844 result.ifname = hidl_string();
3845 result.addresses = hidl_string();
3846 result.dnses = hidl_string();
3847 result.gateways = hidl_string();
3848 result.pcscf = hidl_string();
3850 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3853 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3854 responseInfo, result);
3855 radioService[slotId]->checkReturnStatus(retStatus);
3857 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3863 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3864 RIL_Errno e, void *response, size_t responseLen) {
3865 populateResponseInfo(responseInfo, serial, responseType, e);
3866 IccIoResult result = {};
3868 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3869 RLOGE("Invalid response: NULL");
3870 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3871 result.simResponse = hidl_string();
3873 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3874 result.sw1 = resp->sw1;
3875 result.sw2 = resp->sw2;
3876 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3881 int radio::iccIOForAppResponse(int slotId,
3882 int responseType, int serial, RIL_Errno e, void *response,
3883 size_t responseLen) {
3885 RLOGD("iccIOForAppResponse: serial %d", serial);
3888 if (radioService[slotId]->mRadioResponse != NULL) {
3889 RadioResponseInfo responseInfo = {};
3890 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3893 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3894 responseInfo, result);
3895 radioService[slotId]->checkReturnStatus(retStatus);
3897 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3903 int radio::sendUssdResponse(int slotId,
3904 int responseType, int serial, RIL_Errno e, void *response,
3905 size_t responseLen) {
3907 RLOGD("sendUssdResponse: serial %d", serial);
3910 if (radioService[slotId]->mRadioResponse != NULL) {
3911 RadioResponseInfo responseInfo = {};
3912 populateResponseInfo(responseInfo, serial, responseType, e);
3913 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3915 radioService[slotId]->checkReturnStatus(retStatus);
3917 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3924 int radio::cancelPendingUssdResponse(int slotId,
3925 int responseType, int serial, RIL_Errno e, void *response,
3926 size_t responseLen) {
3928 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3931 if (radioService[slotId]->mRadioResponse != NULL) {
3932 RadioResponseInfo responseInfo = {};
3933 populateResponseInfo(responseInfo, serial, responseType, e);
3934 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3936 radioService[slotId]->checkReturnStatus(retStatus);
3938 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3945 int radio::getClirResponse(int slotId,
3946 int responseType, int serial, RIL_Errno e, void *response,
3947 size_t responseLen) {
3949 RLOGD("getClirResponse: serial %d", serial);
3952 if (radioService[slotId]->mRadioResponse != NULL) {
3953 RadioResponseInfo responseInfo = {};
3954 populateResponseInfo(responseInfo, serial, responseType, e);
3956 int numInts = responseLen / sizeof(int);
3957 if (response == NULL || numInts != 2) {
3958 RLOGE("getClirResponse Invalid response: NULL");
3959 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3961 int *pInt = (int *) response;
3965 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3967 radioService[slotId]->checkReturnStatus(retStatus);
3969 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3975 int radio::setClirResponse(int slotId,
3976 int responseType, int serial, RIL_Errno e, void *response,
3977 size_t responseLen) {
3979 RLOGD("setClirResponse: serial %d", serial);
3982 if (radioService[slotId]->mRadioResponse != NULL) {
3983 RadioResponseInfo responseInfo = {};
3984 populateResponseInfo(responseInfo, serial, responseType, e);
3985 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
3987 radioService[slotId]->checkReturnStatus(retStatus);
3989 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3995 int radio::getCallForwardStatusResponse(int slotId,
3996 int responseType, int serial, RIL_Errno e,
3997 void *response, size_t responseLen) {
3999 RLOGD("getCallForwardStatusResponse: serial %d", serial);
4002 if (radioService[slotId]->mRadioResponse != NULL) {
4003 RadioResponseInfo responseInfo = {};
4004 populateResponseInfo(responseInfo, serial, responseType, e);
4005 hidl_vec<CallForwardInfo> callForwardInfos;
4007 if ((response == NULL && responseLen != 0)
4008 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4009 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4010 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4012 int num = responseLen / sizeof(RIL_CallForwardInfo *);
4013 callForwardInfos.resize(num);
4014 for (int i = 0 ; i < num; i++) {
4015 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4016 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4017 callForwardInfos[i].reason = resp->reason;
4018 callForwardInfos[i].serviceClass = resp->serviceClass;
4019 callForwardInfos[i].toa = resp->toa;
4020 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4021 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4025 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4026 responseInfo, callForwardInfos);
4027 radioService[slotId]->checkReturnStatus(retStatus);
4029 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4036 int radio::setCallForwardResponse(int slotId,
4037 int responseType, int serial, RIL_Errno e, void *response,
4038 size_t responseLen) {
4040 RLOGD("setCallForwardResponse: serial %d", serial);
4043 if (radioService[slotId]->mRadioResponse != NULL) {
4044 RadioResponseInfo responseInfo = {};
4045 populateResponseInfo(responseInfo, serial, responseType, e);
4046 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4048 radioService[slotId]->checkReturnStatus(retStatus);
4050 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4056 int radio::getCallWaitingResponse(int slotId,
4057 int responseType, int serial, RIL_Errno e, void *response,
4058 size_t responseLen) {
4060 RLOGD("getCallWaitingResponse: serial %d", serial);
4063 if (radioService[slotId]->mRadioResponse != NULL) {
4064 RadioResponseInfo responseInfo = {};
4065 populateResponseInfo(responseInfo, serial, responseType, e);
4066 bool enable = false;
4067 int serviceClass = -1;
4068 int numInts = responseLen / sizeof(int);
4069 if (response == NULL || numInts != 2) {
4070 RLOGE("getCallWaitingResponse Invalid response: NULL");
4071 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4073 int *pInt = (int *) response;
4074 enable = pInt[0] == 1 ? true : false;
4075 serviceClass = pInt[1];
4077 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4078 responseInfo, enable, serviceClass);
4079 radioService[slotId]->checkReturnStatus(retStatus);
4081 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4087 int radio::setCallWaitingResponse(int slotId,
4088 int responseType, int serial, RIL_Errno e, void *response,
4089 size_t responseLen) {
4091 RLOGD("setCallWaitingResponse: serial %d", serial);
4094 if (radioService[slotId]->mRadioResponse != NULL) {
4095 RadioResponseInfo responseInfo = {};
4096 populateResponseInfo(responseInfo, serial, responseType, e);
4097 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4099 radioService[slotId]->checkReturnStatus(retStatus);
4101 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4107 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4108 int responseType, int serial, RIL_Errno e,
4109 void *response, size_t responseLen) {
4111 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4114 if (radioService[slotId]->mRadioResponse != NULL) {
4115 RadioResponseInfo responseInfo = {};
4116 populateResponseInfo(responseInfo, serial, responseType, e);
4117 Return<void> retStatus =
4118 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4120 radioService[slotId]->checkReturnStatus(retStatus);
4122 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4129 int radio::acceptCallResponse(int slotId,
4130 int responseType, int serial, RIL_Errno e,
4131 void *response, size_t responseLen) {
4133 RLOGD("acceptCallResponse: serial %d", serial);
4136 if (radioService[slotId]->mRadioResponse != NULL) {
4137 RadioResponseInfo responseInfo = {};
4138 populateResponseInfo(responseInfo, serial, responseType, e);
4139 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4141 radioService[slotId]->checkReturnStatus(retStatus);
4143 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4150 int radio::deactivateDataCallResponse(int slotId,
4151 int responseType, int serial, RIL_Errno e,
4152 void *response, size_t responseLen) {
4154 RLOGD("deactivateDataCallResponse: serial %d", serial);
4157 if (radioService[slotId]->mRadioResponse != NULL) {
4158 RadioResponseInfo responseInfo = {};
4159 populateResponseInfo(responseInfo, serial, responseType, e);
4160 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4162 radioService[slotId]->checkReturnStatus(retStatus);
4164 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4171 int radio::getFacilityLockForAppResponse(int slotId,
4172 int responseType, int serial, RIL_Errno e,
4173 void *response, size_t responseLen) {
4175 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4178 if (radioService[slotId]->mRadioResponse != NULL) {
4179 RadioResponseInfo responseInfo = {};
4180 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4181 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4182 getFacilityLockForAppResponse(responseInfo, ret);
4183 radioService[slotId]->checkReturnStatus(retStatus);
4185 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4192 int radio::setFacilityLockForAppResponse(int slotId,
4193 int responseType, int serial, RIL_Errno e,
4194 void *response, size_t responseLen) {
4196 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4199 if (radioService[slotId]->mRadioResponse != NULL) {
4200 RadioResponseInfo responseInfo = {};
4201 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4202 Return<void> retStatus
4203 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4205 radioService[slotId]->checkReturnStatus(retStatus);
4207 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4214 int radio::setBarringPasswordResponse(int slotId,
4215 int responseType, int serial, RIL_Errno e,
4216 void *response, size_t responseLen) {
4218 RLOGD("acceptCallResponse: serial %d", serial);
4221 if (radioService[slotId]->mRadioResponse != NULL) {
4222 RadioResponseInfo responseInfo = {};
4223 populateResponseInfo(responseInfo, serial, responseType, e);
4224 Return<void> retStatus
4225 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4226 radioService[slotId]->checkReturnStatus(retStatus);
4228 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4235 int radio::getNetworkSelectionModeResponse(int slotId,
4236 int responseType, int serial, RIL_Errno e, void *response,
4237 size_t responseLen) {
4239 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4242 if (radioService[slotId]->mRadioResponse != NULL) {
4243 RadioResponseInfo responseInfo = {};
4244 populateResponseInfo(responseInfo, serial, responseType, e);
4245 bool manual = false;
4247 if (response == NULL || responseLen != sizeof(int)) {
4248 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4249 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4251 int *pInt = (int *) response;
4252 manual = pInt[0] == 1 ? true : false;
4254 Return<void> retStatus
4255 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4258 radioService[slotId]->checkReturnStatus(retStatus);
4260 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4267 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4268 RIL_Errno e, void *response,
4269 size_t responseLen) {
4271 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4274 if (radioService[slotId]->mRadioResponse != NULL) {
4275 RadioResponseInfo responseInfo = {};
4276 populateResponseInfo(responseInfo, serial, responseType, e);
4277 Return<void> retStatus
4278 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4280 radioService[slotId]->checkReturnStatus(retStatus);
4282 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4289 int radio::setNetworkSelectionModeManualResponse(int slotId,
4290 int responseType, int serial, RIL_Errno e,
4291 void *response, size_t responseLen) {
4293 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4296 if (radioService[slotId]->mRadioResponse != NULL) {
4297 RadioResponseInfo responseInfo = {};
4298 populateResponseInfo(responseInfo, serial, responseType, e);
4299 Return<void> retStatus
4300 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4302 radioService[slotId]->checkReturnStatus(retStatus);
4304 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4311 int convertOperatorStatusToInt(const char *str) {
4312 if (strncmp("unknown", str, 9) == 0) {
4313 return (int) OperatorStatus::UNKNOWN;
4314 } else if (strncmp("available", str, 9) == 0) {
4315 return (int) OperatorStatus::AVAILABLE;
4316 } else if (strncmp("current", str, 9) == 0) {
4317 return (int) OperatorStatus::CURRENT;
4318 } else if (strncmp("forbidden", str, 9) == 0) {
4319 return (int) OperatorStatus::FORBIDDEN;
4325 int radio::getAvailableNetworksResponse(int slotId,
4326 int responseType, int serial, RIL_Errno e, void *response,
4327 size_t responseLen) {
4329 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4332 if (radioService[slotId]->mRadioResponse != NULL) {
4333 RadioResponseInfo responseInfo = {};
4334 populateResponseInfo(responseInfo, serial, responseType, e);
4335 hidl_vec<OperatorInfo> networks;
4336 if ((response == NULL && responseLen != 0)
4337 || responseLen % (4 * sizeof(char *))!= 0) {
4338 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4339 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4341 char **resp = (char **) response;
4342 int numStrings = responseLen / sizeof(char *);
4343 networks.resize(numStrings/4);
4344 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4345 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4346 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4347 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4348 int status = convertOperatorStatusToInt(resp[i + 3]);
4350 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4352 networks[j].status = (OperatorStatus) status;
4356 Return<void> retStatus
4357 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4359 radioService[slotId]->checkReturnStatus(retStatus);
4361 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4368 int radio::startDtmfResponse(int slotId,
4369 int responseType, int serial, RIL_Errno e,
4370 void *response, size_t responseLen) {
4372 RLOGD("startDtmfResponse: serial %d", serial);
4375 if (radioService[slotId]->mRadioResponse != NULL) {
4376 RadioResponseInfo responseInfo = {};
4377 populateResponseInfo(responseInfo, serial, responseType, e);
4378 Return<void> retStatus
4379 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4380 radioService[slotId]->checkReturnStatus(retStatus);
4382 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4388 int radio::stopDtmfResponse(int slotId,
4389 int responseType, int serial, RIL_Errno e,
4390 void *response, size_t responseLen) {
4392 RLOGD("stopDtmfResponse: serial %d", serial);
4395 if (radioService[slotId]->mRadioResponse != NULL) {
4396 RadioResponseInfo responseInfo = {};
4397 populateResponseInfo(responseInfo, serial, responseType, e);
4398 Return<void> retStatus
4399 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4400 radioService[slotId]->checkReturnStatus(retStatus);
4402 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4408 int radio::getBasebandVersionResponse(int slotId,
4409 int responseType, int serial, RIL_Errno e,
4410 void *response, size_t responseLen) {
4412 RLOGD("getBasebandVersionResponse: serial %d", serial);
4415 if (radioService[slotId]->mRadioResponse != NULL) {
4416 RadioResponseInfo responseInfo = {};
4417 populateResponseInfo(responseInfo, serial, responseType, e);
4418 Return<void> retStatus
4419 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4420 convertCharPtrToHidlString((char *) response));
4421 radioService[slotId]->checkReturnStatus(retStatus);
4423 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4429 int radio::separateConnectionResponse(int slotId,
4430 int responseType, int serial, RIL_Errno e,
4431 void *response, size_t responseLen) {
4433 RLOGD("separateConnectionResponse: serial %d", serial);
4436 if (radioService[slotId]->mRadioResponse != NULL) {
4437 RadioResponseInfo responseInfo = {};
4438 populateResponseInfo(responseInfo, serial, responseType, e);
4439 Return<void> retStatus
4440 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4441 radioService[slotId]->checkReturnStatus(retStatus);
4443 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4450 int radio::setMuteResponse(int slotId,
4451 int responseType, int serial, RIL_Errno e,
4452 void *response, size_t responseLen) {
4454 RLOGD("setMuteResponse: serial %d", serial);
4457 if (radioService[slotId]->mRadioResponse != NULL) {
4458 RadioResponseInfo responseInfo = {};
4459 populateResponseInfo(responseInfo, serial, responseType, e);
4460 Return<void> retStatus
4461 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4462 radioService[slotId]->checkReturnStatus(retStatus);
4464 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4470 int radio::getMuteResponse(int slotId,
4471 int responseType, int serial, RIL_Errno e, void *response,
4472 size_t responseLen) {
4474 RLOGD("getMuteResponse: serial %d", serial);
4477 if (radioService[slotId]->mRadioResponse != NULL) {
4478 RadioResponseInfo responseInfo = {};
4479 populateResponseInfo(responseInfo, serial, responseType, e);
4480 bool enable = false;
4482 if (response == NULL || responseLen != sizeof(int)) {
4483 RLOGE("getMuteResponse Invalid response: NULL");
4484 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4486 int *pInt = (int *) response;
4487 enable = pInt[0] == 1 ? true : false;
4489 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4491 radioService[slotId]->checkReturnStatus(retStatus);
4493 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4499 int radio::getClipResponse(int slotId,
4500 int responseType, int serial, RIL_Errno e,
4501 void *response, size_t responseLen) {
4503 RLOGD("getClipResponse: serial %d", serial);
4506 if (radioService[slotId]->mRadioResponse != NULL) {
4507 RadioResponseInfo responseInfo = {};
4508 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4509 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4511 radioService[slotId]->checkReturnStatus(retStatus);
4513 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4519 int radio::getDataCallListResponse(int slotId,
4520 int responseType, int serial, RIL_Errno e,
4521 void *response, size_t responseLen) {
4523 RLOGD("getDataCallListResponse: serial %d", serial);
4526 if (radioService[slotId]->mRadioResponse != NULL) {
4527 RadioResponseInfo responseInfo = {};
4528 populateResponseInfo(responseInfo, serial, responseType, e);
4530 hidl_vec<SetupDataCallResult> ret;
4531 if ((response == NULL && responseLen != 0)
4532 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4533 RLOGE("getDataCallListResponse: invalid response");
4534 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4536 convertRilDataCallListToHal(response, responseLen, ret);
4539 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4541 radioService[slotId]->checkReturnStatus(retStatus);
4543 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4549 int radio::setSuppServiceNotificationsResponse(int slotId,
4550 int responseType, int serial, RIL_Errno e,
4551 void *response, size_t responseLen) {
4553 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4556 if (radioService[slotId]->mRadioResponse != NULL) {
4557 RadioResponseInfo responseInfo = {};
4558 populateResponseInfo(responseInfo, serial, responseType, e);
4559 Return<void> retStatus
4560 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4562 radioService[slotId]->checkReturnStatus(retStatus);
4564 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4571 int radio::deleteSmsOnSimResponse(int slotId,
4572 int responseType, int serial, RIL_Errno e,
4573 void *response, size_t responseLen) {
4575 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4578 if (radioService[slotId]->mRadioResponse != NULL) {
4579 RadioResponseInfo responseInfo = {};
4580 populateResponseInfo(responseInfo, serial, responseType, e);
4581 Return<void> retStatus
4582 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4583 radioService[slotId]->checkReturnStatus(retStatus);
4585 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4591 int radio::setBandModeResponse(int slotId,
4592 int responseType, int serial, RIL_Errno e,
4593 void *response, size_t responseLen) {
4595 RLOGD("setBandModeResponse: serial %d", serial);
4598 if (radioService[slotId]->mRadioResponse != NULL) {
4599 RadioResponseInfo responseInfo = {};
4600 populateResponseInfo(responseInfo, serial, responseType, e);
4601 Return<void> retStatus
4602 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4603 radioService[slotId]->checkReturnStatus(retStatus);
4605 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4611 int radio::writeSmsToSimResponse(int slotId,
4612 int responseType, int serial, RIL_Errno e,
4613 void *response, size_t responseLen) {
4615 RLOGD("writeSmsToSimResponse: serial %d", serial);
4618 if (radioService[slotId]->mRadioResponse != NULL) {
4619 RadioResponseInfo responseInfo = {};
4620 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4621 Return<void> retStatus
4622 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4623 radioService[slotId]->checkReturnStatus(retStatus);
4625 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4631 int radio::getAvailableBandModesResponse(int slotId,
4632 int responseType, int serial, RIL_Errno e, void *response,
4633 size_t responseLen) {
4635 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4638 if (radioService[slotId]->mRadioResponse != NULL) {
4639 RadioResponseInfo responseInfo = {};
4640 populateResponseInfo(responseInfo, serial, responseType, e);
4641 hidl_vec<RadioBandMode> modes;
4642 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
4643 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4644 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4646 int *pInt = (int *) response;
4647 int numInts = responseLen / sizeof(int);
4648 modes.resize(numInts);
4649 for (int i = 0; i < numInts; i++) {
4650 modes[i] = (RadioBandMode) pInt[i];
4653 Return<void> retStatus
4654 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4656 radioService[slotId]->checkReturnStatus(retStatus);
4658 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4665 int radio::sendEnvelopeResponse(int slotId,
4666 int responseType, int serial, RIL_Errno e,
4667 void *response, size_t responseLen) {
4669 RLOGD("sendEnvelopeResponse: serial %d", serial);
4672 if (radioService[slotId]->mRadioResponse != NULL) {
4673 RadioResponseInfo responseInfo = {};
4674 populateResponseInfo(responseInfo, serial, responseType, e);
4675 Return<void> retStatus
4676 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4677 convertCharPtrToHidlString((char *) response));
4678 radioService[slotId]->checkReturnStatus(retStatus);
4680 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4686 int radio::sendTerminalResponseToSimResponse(int slotId,
4687 int responseType, int serial, RIL_Errno e,
4688 void *response, size_t responseLen) {
4690 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4693 if (radioService[slotId]->mRadioResponse != NULL) {
4694 RadioResponseInfo responseInfo = {};
4695 populateResponseInfo(responseInfo, serial, responseType, e);
4696 Return<void> retStatus
4697 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4699 radioService[slotId]->checkReturnStatus(retStatus);
4701 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4708 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4709 int responseType, int serial,
4710 RIL_Errno e, void *response,
4711 size_t responseLen) {
4713 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4716 if (radioService[slotId]->mRadioResponse != NULL) {
4717 RadioResponseInfo responseInfo = {};
4718 populateResponseInfo(responseInfo, serial, responseType, e);
4719 Return<void> retStatus
4720 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4722 radioService[slotId]->checkReturnStatus(retStatus);
4724 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4731 int radio::explicitCallTransferResponse(int slotId,
4732 int responseType, int serial, RIL_Errno e,
4733 void *response, size_t responseLen) {
4735 RLOGD("explicitCallTransferResponse: serial %d", serial);
4738 if (radioService[slotId]->mRadioResponse != NULL) {
4739 RadioResponseInfo responseInfo = {};
4740 populateResponseInfo(responseInfo, serial, responseType, e);
4741 Return<void> retStatus
4742 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4743 radioService[slotId]->checkReturnStatus(retStatus);
4745 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4752 int radio::setPreferredNetworkTypeResponse(int slotId,
4753 int responseType, int serial, RIL_Errno e,
4754 void *response, size_t responseLen) {
4756 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4759 if (radioService[slotId]->mRadioResponse != NULL) {
4760 RadioResponseInfo responseInfo = {};
4761 populateResponseInfo(responseInfo, serial, responseType, e);
4762 Return<void> retStatus
4763 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4765 radioService[slotId]->checkReturnStatus(retStatus);
4767 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4775 int radio::getPreferredNetworkTypeResponse(int slotId,
4776 int responseType, int serial, RIL_Errno e,
4777 void *response, size_t responseLen) {
4779 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4782 if (radioService[slotId]->mRadioResponse != NULL) {
4783 RadioResponseInfo responseInfo = {};
4784 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4785 Return<void> retStatus
4786 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4787 responseInfo, (PreferredNetworkType) ret);
4788 radioService[slotId]->checkReturnStatus(retStatus);
4790 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4797 int radio::getNeighboringCidsResponse(int slotId,
4798 int responseType, int serial, RIL_Errno e,
4799 void *response, size_t responseLen) {
4801 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4804 if (radioService[slotId]->mRadioResponse != NULL) {
4805 RadioResponseInfo responseInfo = {};
4806 populateResponseInfo(responseInfo, serial, responseType, e);
4807 hidl_vec<NeighboringCell> cells;
4809 if ((response == NULL && responseLen != 0)
4810 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4811 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4812 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4814 int num = responseLen / sizeof(RIL_NeighboringCell *);
4816 for (int i = 0 ; i < num; i++) {
4817 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4818 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4819 cells[i].rssi = resp->rssi;
4823 Return<void> retStatus
4824 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4826 radioService[slotId]->checkReturnStatus(retStatus);
4828 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4835 int radio::setLocationUpdatesResponse(int slotId,
4836 int responseType, int serial, RIL_Errno e,
4837 void *response, size_t responseLen) {
4839 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4842 if (radioService[slotId]->mRadioResponse != NULL) {
4843 RadioResponseInfo responseInfo = {};
4844 populateResponseInfo(responseInfo, serial, responseType, e);
4845 Return<void> retStatus
4846 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4847 radioService[slotId]->checkReturnStatus(retStatus);
4849 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4856 int radio::setCdmaSubscriptionSourceResponse(int slotId,
4857 int responseType, int serial, RIL_Errno e,
4858 void *response, size_t responseLen) {
4860 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4863 if (radioService[slotId]->mRadioResponse != NULL) {
4864 RadioResponseInfo responseInfo = {};
4865 populateResponseInfo(responseInfo, serial, responseType, e);
4866 Return<void> retStatus
4867 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4869 radioService[slotId]->checkReturnStatus(retStatus);
4871 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4878 int radio::setCdmaRoamingPreferenceResponse(int slotId,
4879 int responseType, int serial, RIL_Errno e,
4880 void *response, size_t responseLen) {
4882 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4885 if (radioService[slotId]->mRadioResponse != NULL) {
4886 RadioResponseInfo responseInfo = {};
4887 populateResponseInfo(responseInfo, serial, responseType, e);
4888 Return<void> retStatus
4889 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4891 radioService[slotId]->checkReturnStatus(retStatus);
4893 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4900 int radio::getCdmaRoamingPreferenceResponse(int slotId,
4901 int responseType, int serial, RIL_Errno e,
4902 void *response, size_t responseLen) {
4904 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4907 if (radioService[slotId]->mRadioResponse != NULL) {
4908 RadioResponseInfo responseInfo = {};
4909 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4910 Return<void> retStatus
4911 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4912 responseInfo, (CdmaRoamingType) ret);
4913 radioService[slotId]->checkReturnStatus(retStatus);
4915 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4922 int radio::setTTYModeResponse(int slotId,
4923 int responseType, int serial, RIL_Errno e,
4924 void *response, size_t responseLen) {
4926 RLOGD("setTTYModeResponse: serial %d", serial);
4929 if (radioService[slotId]->mRadioResponse != NULL) {
4930 RadioResponseInfo responseInfo = {};
4931 populateResponseInfo(responseInfo, serial, responseType, e);
4932 Return<void> retStatus
4933 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4934 radioService[slotId]->checkReturnStatus(retStatus);
4936 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4942 int radio::getTTYModeResponse(int slotId,
4943 int responseType, int serial, RIL_Errno e,
4944 void *response, size_t responseLen) {
4946 RLOGD("getTTYModeResponse: serial %d", serial);
4949 if (radioService[slotId]->mRadioResponse != NULL) {
4950 RadioResponseInfo responseInfo = {};
4951 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4952 Return<void> retStatus
4953 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4955 radioService[slotId]->checkReturnStatus(retStatus);
4957 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4963 int radio::setPreferredVoicePrivacyResponse(int slotId,
4964 int responseType, int serial, RIL_Errno e,
4965 void *response, size_t responseLen) {
4967 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
4970 if (radioService[slotId]->mRadioResponse != NULL) {
4971 RadioResponseInfo responseInfo = {};
4972 populateResponseInfo(responseInfo, serial, responseType, e);
4973 Return<void> retStatus
4974 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4976 radioService[slotId]->checkReturnStatus(retStatus);
4978 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4985 int radio::getPreferredVoicePrivacyResponse(int slotId,
4986 int responseType, int serial, RIL_Errno e,
4987 void *response, size_t responseLen) {
4989 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
4992 if (radioService[slotId]->mRadioResponse != NULL) {
4993 RadioResponseInfo responseInfo = {};
4994 populateResponseInfo(responseInfo, serial, responseType, e);
4995 bool enable = false;
4996 int numInts = responseLen / sizeof(int);
4997 if (response == NULL || numInts != 1) {
4998 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
4999 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5001 int *pInt = (int *) response;
5002 enable = pInt[0] == 1 ? true : false;
5004 Return<void> retStatus
5005 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5006 responseInfo, enable);
5007 radioService[slotId]->checkReturnStatus(retStatus);
5009 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5016 int radio::sendCDMAFeatureCodeResponse(int slotId,
5017 int responseType, int serial, RIL_Errno e,
5018 void *response, size_t responseLen) {
5020 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5023 if (radioService[slotId]->mRadioResponse != NULL) {
5024 RadioResponseInfo responseInfo = {};
5025 populateResponseInfo(responseInfo, serial, responseType, e);
5026 Return<void> retStatus
5027 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5028 radioService[slotId]->checkReturnStatus(retStatus);
5030 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5037 int radio::sendBurstDtmfResponse(int slotId,
5038 int responseType, int serial, RIL_Errno e,
5039 void *response, size_t responseLen) {
5041 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5044 if (radioService[slotId]->mRadioResponse != NULL) {
5045 RadioResponseInfo responseInfo = {};
5046 populateResponseInfo(responseInfo, serial, responseType, e);
5047 Return<void> retStatus
5048 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5049 radioService[slotId]->checkReturnStatus(retStatus);
5051 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5057 int radio::sendCdmaSmsResponse(int slotId,
5058 int responseType, int serial, RIL_Errno e, void *response,
5059 size_t responseLen) {
5061 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5064 if (radioService[slotId]->mRadioResponse != NULL) {
5065 RadioResponseInfo responseInfo = {};
5066 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5069 Return<void> retStatus
5070 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5071 radioService[slotId]->checkReturnStatus(retStatus);
5073 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5079 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5080 int responseType, int serial, RIL_Errno e,
5081 void *response, size_t responseLen) {
5083 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5086 if (radioService[slotId]->mRadioResponse != NULL) {
5087 RadioResponseInfo responseInfo = {};
5088 populateResponseInfo(responseInfo, serial, responseType, e);
5089 Return<void> retStatus
5090 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5092 radioService[slotId]->checkReturnStatus(retStatus);
5094 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5101 int radio::getGsmBroadcastConfigResponse(int slotId,
5102 int responseType, int serial, RIL_Errno e,
5103 void *response, size_t responseLen) {
5105 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5108 if (radioService[slotId]->mRadioResponse != NULL) {
5109 RadioResponseInfo responseInfo = {};
5110 populateResponseInfo(responseInfo, serial, responseType, e);
5111 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5113 if ((response == NULL && responseLen != 0)
5114 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5115 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5116 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5118 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5119 configs.resize(num);
5120 for (int i = 0 ; i < num; i++) {
5121 RIL_GSM_BroadcastSmsConfigInfo *resp =
5122 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5123 configs[i].fromServiceId = resp->fromServiceId;
5124 configs[i].toServiceId = resp->toServiceId;
5125 configs[i].fromCodeScheme = resp->fromCodeScheme;
5126 configs[i].toCodeScheme = resp->toCodeScheme;
5127 configs[i].selected = resp->selected == 1 ? true : false;
5131 Return<void> retStatus
5132 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5134 radioService[slotId]->checkReturnStatus(retStatus);
5136 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5143 int radio::setGsmBroadcastConfigResponse(int slotId,
5144 int responseType, int serial, RIL_Errno e,
5145 void *response, size_t responseLen) {
5147 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5150 if (radioService[slotId]->mRadioResponse != NULL) {
5151 RadioResponseInfo responseInfo = {};
5152 populateResponseInfo(responseInfo, serial, responseType, e);
5153 Return<void> retStatus
5154 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5155 radioService[slotId]->checkReturnStatus(retStatus);
5157 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5164 int radio::setGsmBroadcastActivationResponse(int slotId,
5165 int responseType, int serial, RIL_Errno e,
5166 void *response, size_t responseLen) {
5168 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5171 if (radioService[slotId]->mRadioResponse != NULL) {
5172 RadioResponseInfo responseInfo = {};
5173 populateResponseInfo(responseInfo, serial, responseType, e);
5174 Return<void> retStatus
5175 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5177 radioService[slotId]->checkReturnStatus(retStatus);
5179 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5186 int radio::getCdmaBroadcastConfigResponse(int slotId,
5187 int responseType, int serial, RIL_Errno e,
5188 void *response, size_t responseLen) {
5190 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5193 if (radioService[slotId]->mRadioResponse != NULL) {
5194 RadioResponseInfo responseInfo = {};
5195 populateResponseInfo(responseInfo, serial, responseType, e);
5196 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5198 if ((response == NULL && responseLen != 0)
5199 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5200 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5201 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5203 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5204 configs.resize(num);
5205 for (int i = 0 ; i < num; i++) {
5206 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5207 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5208 configs[i].serviceCategory = resp->service_category;
5209 configs[i].language = resp->language;
5210 configs[i].selected = resp->selected == 1 ? true : false;
5214 Return<void> retStatus
5215 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5217 radioService[slotId]->checkReturnStatus(retStatus);
5219 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5226 int radio::setCdmaBroadcastConfigResponse(int slotId,
5227 int responseType, int serial, RIL_Errno e,
5228 void *response, size_t responseLen) {
5230 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5233 if (radioService[slotId]->mRadioResponse != NULL) {
5234 RadioResponseInfo responseInfo = {};
5235 populateResponseInfo(responseInfo, serial, responseType, e);
5236 Return<void> retStatus
5237 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5239 radioService[slotId]->checkReturnStatus(retStatus);
5241 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5248 int radio::setCdmaBroadcastActivationResponse(int slotId,
5249 int responseType, int serial, RIL_Errno e,
5250 void *response, size_t responseLen) {
5252 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5255 if (radioService[slotId]->mRadioResponse != NULL) {
5256 RadioResponseInfo responseInfo = {};
5257 populateResponseInfo(responseInfo, serial, responseType, e);
5258 Return<void> retStatus
5259 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5261 radioService[slotId]->checkReturnStatus(retStatus);
5263 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5270 int radio::getCDMASubscriptionResponse(int slotId,
5271 int responseType, int serial, RIL_Errno e, void *response,
5272 size_t responseLen) {
5274 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5277 if (radioService[slotId]->mRadioResponse != NULL) {
5278 RadioResponseInfo responseInfo = {};
5279 populateResponseInfo(responseInfo, serial, responseType, e);
5281 int numStrings = responseLen / sizeof(char *);
5282 hidl_string emptyString;
5283 if (response == NULL || numStrings != 5) {
5284 RLOGE("getOperatorResponse Invalid response: NULL");
5285 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5286 Return<void> retStatus
5287 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5288 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5289 radioService[slotId]->checkReturnStatus(retStatus);
5291 char **resp = (char **) response;
5292 Return<void> retStatus
5293 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5295 convertCharPtrToHidlString(resp[0]),
5296 convertCharPtrToHidlString(resp[1]),
5297 convertCharPtrToHidlString(resp[2]),
5298 convertCharPtrToHidlString(resp[3]),
5299 convertCharPtrToHidlString(resp[4]));
5300 radioService[slotId]->checkReturnStatus(retStatus);
5303 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5310 int radio::writeSmsToRuimResponse(int slotId,
5311 int responseType, int serial, RIL_Errno e,
5312 void *response, size_t responseLen) {
5314 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5317 if (radioService[slotId]->mRadioResponse != NULL) {
5318 RadioResponseInfo responseInfo = {};
5319 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5320 Return<void> retStatus
5321 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5322 radioService[slotId]->checkReturnStatus(retStatus);
5324 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5330 int radio::deleteSmsOnRuimResponse(int slotId,
5331 int responseType, int serial, RIL_Errno e,
5332 void *response, size_t responseLen) {
5334 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5337 if (radioService[slotId]->mRadioResponse != NULL) {
5338 RadioResponseInfo responseInfo = {};
5339 populateResponseInfo(responseInfo, serial, responseType, e);
5340 Return<void> retStatus
5341 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5342 radioService[slotId]->checkReturnStatus(retStatus);
5344 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5350 int radio::getDeviceIdentityResponse(int slotId,
5351 int responseType, int serial, RIL_Errno e, void *response,
5352 size_t responseLen) {
5354 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5357 if (radioService[slotId]->mRadioResponse != NULL) {
5358 RadioResponseInfo responseInfo = {};
5359 populateResponseInfo(responseInfo, serial, responseType, e);
5361 int numStrings = responseLen / sizeof(char *);
5362 hidl_string emptyString;
5363 if (response == NULL || numStrings != 4) {
5364 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5365 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5366 Return<void> retStatus
5367 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5368 emptyString, emptyString, emptyString, emptyString);
5369 radioService[slotId]->checkReturnStatus(retStatus);
5371 char **resp = (char **) response;
5372 Return<void> retStatus
5373 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5374 convertCharPtrToHidlString(resp[0]),
5375 convertCharPtrToHidlString(resp[1]),
5376 convertCharPtrToHidlString(resp[2]),
5377 convertCharPtrToHidlString(resp[3]));
5378 radioService[slotId]->checkReturnStatus(retStatus);
5381 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5388 int radio::exitEmergencyCallbackModeResponse(int slotId,
5389 int responseType, int serial, RIL_Errno e,
5390 void *response, size_t responseLen) {
5392 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5395 if (radioService[slotId]->mRadioResponse != NULL) {
5396 RadioResponseInfo responseInfo = {};
5397 populateResponseInfo(responseInfo, serial, responseType, e);
5398 Return<void> retStatus
5399 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5401 radioService[slotId]->checkReturnStatus(retStatus);
5403 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5410 int radio::getSmscAddressResponse(int slotId,
5411 int responseType, int serial, RIL_Errno e,
5412 void *response, size_t responseLen) {
5414 RLOGD("getSmscAddressResponse: serial %d", serial);
5417 if (radioService[slotId]->mRadioResponse != NULL) {
5418 RadioResponseInfo responseInfo = {};
5419 populateResponseInfo(responseInfo, serial, responseType, e);
5420 Return<void> retStatus
5421 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5422 convertCharPtrToHidlString((char *) response));
5423 radioService[slotId]->checkReturnStatus(retStatus);
5425 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5431 int radio::setSmscAddressResponse(int slotId,
5432 int responseType, int serial, RIL_Errno e,
5433 void *response, size_t responseLen) {
5435 RLOGD("setSmscAddressResponse: serial %d", serial);
5438 if (radioService[slotId]->mRadioResponse != NULL) {
5439 RadioResponseInfo responseInfo = {};
5440 populateResponseInfo(responseInfo, serial, responseType, e);
5441 Return<void> retStatus
5442 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5443 radioService[slotId]->checkReturnStatus(retStatus);
5445 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5451 int radio::reportSmsMemoryStatusResponse(int slotId,
5452 int responseType, int serial, RIL_Errno e,
5453 void *response, size_t responseLen) {
5455 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5458 if (radioService[slotId]->mRadioResponse != NULL) {
5459 RadioResponseInfo responseInfo = {};
5460 populateResponseInfo(responseInfo, serial, responseType, e);
5461 Return<void> retStatus
5462 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5463 radioService[slotId]->checkReturnStatus(retStatus);
5465 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5472 int radio::reportStkServiceIsRunningResponse(int slotId,
5473 int responseType, int serial, RIL_Errno e,
5474 void *response, size_t responseLen) {
5476 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5479 if (radioService[slotId]->mRadioResponse != NULL) {
5480 RadioResponseInfo responseInfo = {};
5481 populateResponseInfo(responseInfo, serial, responseType, e);
5482 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5483 reportStkServiceIsRunningResponse(responseInfo);
5484 radioService[slotId]->checkReturnStatus(retStatus);
5486 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5493 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5494 int responseType, int serial, RIL_Errno e,
5495 void *response, size_t responseLen) {
5497 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5500 if (radioService[slotId]->mRadioResponse != NULL) {
5501 RadioResponseInfo responseInfo = {};
5502 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5503 Return<void> retStatus
5504 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5505 responseInfo, (CdmaSubscriptionSource) ret);
5506 radioService[slotId]->checkReturnStatus(retStatus);
5508 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5515 int radio::requestIsimAuthenticationResponse(int slotId,
5516 int responseType, int serial, RIL_Errno e,
5517 void *response, size_t responseLen) {
5519 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5522 if (radioService[slotId]->mRadioResponse != NULL) {
5523 RadioResponseInfo responseInfo = {};
5524 populateResponseInfo(responseInfo, serial, responseType, e);
5525 Return<void> retStatus
5526 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5528 convertCharPtrToHidlString((char *) response));
5529 radioService[slotId]->checkReturnStatus(retStatus);
5531 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5538 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5540 int serial, RIL_Errno e, void *response,
5541 size_t responseLen) {
5543 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5546 if (radioService[slotId]->mRadioResponse != NULL) {
5547 RadioResponseInfo responseInfo = {};
5548 populateResponseInfo(responseInfo, serial, responseType, e);
5549 Return<void> retStatus
5550 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5552 radioService[slotId]->checkReturnStatus(retStatus);
5554 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5561 int radio::sendEnvelopeWithStatusResponse(int slotId,
5562 int responseType, int serial, RIL_Errno e, void *response,
5563 size_t responseLen) {
5565 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5568 if (radioService[slotId]->mRadioResponse != NULL) {
5569 RadioResponseInfo responseInfo = {};
5570 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5571 response, responseLen);
5573 Return<void> retStatus
5574 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5576 radioService[slotId]->checkReturnStatus(retStatus);
5578 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5585 int radio::getVoiceRadioTechnologyResponse(int slotId,
5586 int responseType, int serial, RIL_Errno e,
5587 void *response, size_t responseLen) {
5589 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5592 if (radioService[slotId]->mRadioResponse != NULL) {
5593 RadioResponseInfo responseInfo = {};
5594 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5595 Return<void> retStatus
5596 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5597 responseInfo, (RadioTechnology) ret);
5598 radioService[slotId]->checkReturnStatus(retStatus);
5600 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5607 int radio::getCellInfoListResponse(int slotId,
5609 int serial, RIL_Errno e, void *response,
5610 size_t responseLen) {
5612 RLOGD("getCellInfoListResponse: serial %d", serial);
5615 if (radioService[slotId]->mRadioResponse != NULL) {
5616 RadioResponseInfo responseInfo = {};
5617 populateResponseInfo(responseInfo, serial, responseType, e);
5619 hidl_vec<CellInfo> ret;
5620 if ((response == NULL && responseLen != 0)
5621 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5622 RLOGE("getCellInfoListResponse: Invalid response");
5623 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5625 convertRilCellInfoListToHal(response, responseLen, ret);
5628 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5630 radioService[slotId]->checkReturnStatus(retStatus);
5632 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5638 int radio::setCellInfoListRateResponse(int slotId,
5640 int serial, RIL_Errno e, void *response,
5641 size_t responseLen) {
5643 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5646 if (radioService[slotId]->mRadioResponse != NULL) {
5647 RadioResponseInfo responseInfo = {};
5648 populateResponseInfo(responseInfo, serial, responseType, e);
5649 Return<void> retStatus
5650 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5651 radioService[slotId]->checkReturnStatus(retStatus);
5653 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5660 int radio::setInitialAttachApnResponse(int slotId,
5661 int responseType, int serial, RIL_Errno e,
5662 void *response, size_t responseLen) {
5664 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5667 if (radioService[slotId]->mRadioResponse != NULL) {
5668 RadioResponseInfo responseInfo = {};
5669 populateResponseInfo(responseInfo, serial, responseType, e);
5670 Return<void> retStatus
5671 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5672 radioService[slotId]->checkReturnStatus(retStatus);
5674 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5681 int radio::getImsRegistrationStateResponse(int slotId,
5682 int responseType, int serial, RIL_Errno e,
5683 void *response, size_t responseLen) {
5685 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5688 if (radioService[slotId]->mRadioResponse != NULL) {
5689 RadioResponseInfo responseInfo = {};
5690 populateResponseInfo(responseInfo, serial, responseType, e);
5691 bool isRegistered = false;
5693 int numInts = responseLen / sizeof(int);
5694 if (response == NULL || numInts != 2) {
5695 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5696 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5698 int *pInt = (int *) response;
5699 isRegistered = pInt[0] == 1 ? true : false;
5700 ratFamily = pInt[1];
5702 Return<void> retStatus
5703 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5704 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5705 radioService[slotId]->checkReturnStatus(retStatus);
5707 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5714 int radio::sendImsSmsResponse(int slotId,
5715 int responseType, int serial, RIL_Errno e, void *response,
5716 size_t responseLen) {
5718 RLOGD("sendImsSmsResponse: serial %d", serial);
5721 if (radioService[slotId]->mRadioResponse != NULL) {
5722 RadioResponseInfo responseInfo = {};
5723 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5726 Return<void> retStatus
5727 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5728 radioService[slotId]->checkReturnStatus(retStatus);
5730 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5736 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5737 int responseType, int serial, RIL_Errno e,
5738 void *response, size_t responseLen) {
5740 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5743 if (radioService[slotId]->mRadioResponse != NULL) {
5744 RadioResponseInfo responseInfo = {};
5745 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5748 Return<void> retStatus
5749 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5750 responseInfo, result);
5751 radioService[slotId]->checkReturnStatus(retStatus);
5753 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5760 int radio::iccOpenLogicalChannelResponse(int slotId,
5761 int responseType, int serial, RIL_Errno e, void *response,
5762 size_t responseLen) {
5764 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5767 if (radioService[slotId]->mRadioResponse != NULL) {
5768 RadioResponseInfo responseInfo = {};
5769 populateResponseInfo(responseInfo, serial, responseType, e);
5771 hidl_vec<int8_t> selectResponse;
5772 int numInts = responseLen / sizeof(int);
5773 if (response == NULL || responseLen % sizeof(int) != 0) {
5774 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5775 if (response != NULL) {
5776 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5779 int *pInt = (int *) response;
5780 channelId = pInt[0];
5781 selectResponse.resize(numInts - 1);
5782 for (int i = 1; i < numInts; i++) {
5783 selectResponse[i - 1] = (int8_t) pInt[i];
5786 Return<void> retStatus
5787 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5788 channelId, selectResponse);
5789 radioService[slotId]->checkReturnStatus(retStatus);
5791 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5798 int radio::iccCloseLogicalChannelResponse(int slotId,
5799 int responseType, int serial, RIL_Errno e,
5800 void *response, size_t responseLen) {
5802 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5805 if (radioService[slotId]->mRadioResponse != NULL) {
5806 RadioResponseInfo responseInfo = {};
5807 populateResponseInfo(responseInfo, serial, responseType, e);
5808 Return<void> retStatus
5809 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5811 radioService[slotId]->checkReturnStatus(retStatus);
5813 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5820 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5821 int responseType, int serial, RIL_Errno e,
5822 void *response, size_t responseLen) {
5824 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5827 if (radioService[slotId]->mRadioResponse != NULL) {
5828 RadioResponseInfo responseInfo = {};
5829 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5832 Return<void> retStatus
5833 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5834 responseInfo, result);
5835 radioService[slotId]->checkReturnStatus(retStatus);
5837 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5844 int radio::nvReadItemResponse(int slotId,
5845 int responseType, int serial, RIL_Errno e,
5846 void *response, size_t responseLen) {
5848 RLOGD("nvReadItemResponse: serial %d", serial);
5851 if (radioService[slotId]->mRadioResponse != NULL) {
5852 RadioResponseInfo responseInfo = {};
5853 populateResponseInfo(responseInfo, serial, responseType, e);
5854 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5856 convertCharPtrToHidlString((char *) response));
5857 radioService[slotId]->checkReturnStatus(retStatus);
5859 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5865 int radio::nvWriteItemResponse(int slotId,
5866 int responseType, int serial, RIL_Errno e,
5867 void *response, size_t responseLen) {
5869 RLOGD("nvWriteItemResponse: serial %d", serial);
5872 if (radioService[slotId]->mRadioResponse != NULL) {
5873 RadioResponseInfo responseInfo = {};
5874 populateResponseInfo(responseInfo, serial, responseType, e);
5875 Return<void> retStatus
5876 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5877 radioService[slotId]->checkReturnStatus(retStatus);
5879 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5885 int radio::nvWriteCdmaPrlResponse(int slotId,
5886 int responseType, int serial, RIL_Errno e,
5887 void *response, size_t responseLen) {
5889 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5892 if (radioService[slotId]->mRadioResponse != NULL) {
5893 RadioResponseInfo responseInfo = {};
5894 populateResponseInfo(responseInfo, serial, responseType, e);
5895 Return<void> retStatus
5896 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5897 radioService[slotId]->checkReturnStatus(retStatus);
5899 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5905 int radio::nvResetConfigResponse(int slotId,
5906 int responseType, int serial, RIL_Errno e,
5907 void *response, size_t responseLen) {
5909 RLOGD("nvResetConfigResponse: serial %d", serial);
5912 if (radioService[slotId]->mRadioResponse != NULL) {
5913 RadioResponseInfo responseInfo = {};
5914 populateResponseInfo(responseInfo, serial, responseType, e);
5915 Return<void> retStatus
5916 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5917 radioService[slotId]->checkReturnStatus(retStatus);
5919 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5925 int radio::setUiccSubscriptionResponse(int slotId,
5926 int responseType, int serial, RIL_Errno e,
5927 void *response, size_t responseLen) {
5929 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5932 if (radioService[slotId]->mRadioResponse != NULL) {
5933 RadioResponseInfo responseInfo = {};
5934 populateResponseInfo(responseInfo, serial, responseType, e);
5935 Return<void> retStatus
5936 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5937 radioService[slotId]->checkReturnStatus(retStatus);
5939 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5946 int radio::setDataAllowedResponse(int slotId,
5947 int responseType, int serial, RIL_Errno e,
5948 void *response, size_t responseLen) {
5950 RLOGD("setDataAllowedResponse: serial %d", serial);
5953 if (radioService[slotId]->mRadioResponse != NULL) {
5954 RadioResponseInfo responseInfo = {};
5955 populateResponseInfo(responseInfo, serial, responseType, e);
5956 Return<void> retStatus
5957 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5958 radioService[slotId]->checkReturnStatus(retStatus);
5960 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5966 int radio::getHardwareConfigResponse(int slotId,
5967 int responseType, int serial, RIL_Errno e,
5968 void *response, size_t responseLen) {
5970 RLOGD("getHardwareConfigResponse: serial %d", serial);
5973 if (radioService[slotId]->mRadioResponse != NULL) {
5974 RadioResponseInfo responseInfo = {};
5975 populateResponseInfo(responseInfo, serial, responseType, e);
5977 hidl_vec<HardwareConfig> result;
5978 if ((response == NULL && responseLen != 0)
5979 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
5980 RLOGE("hardwareConfigChangedInd: invalid response");
5981 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5983 convertRilHardwareConfigListToHal(response, responseLen, result);
5986 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
5987 responseInfo, result);
5988 radioService[slotId]->checkReturnStatus(retStatus);
5990 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5996 int radio::requestIccSimAuthenticationResponse(int slotId,
5997 int responseType, int serial, RIL_Errno e,
5998 void *response, size_t responseLen) {
6000 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6003 if (radioService[slotId]->mRadioResponse != NULL) {
6004 RadioResponseInfo responseInfo = {};
6005 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6008 Return<void> retStatus
6009 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6010 responseInfo, result);
6011 radioService[slotId]->checkReturnStatus(retStatus);
6013 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6020 int radio::setDataProfileResponse(int slotId,
6021 int responseType, int serial, RIL_Errno e,
6022 void *response, size_t responseLen) {
6024 RLOGD("setDataProfileResponse: serial %d", serial);
6027 if (radioService[slotId]->mRadioResponse != NULL) {
6028 RadioResponseInfo responseInfo = {};
6029 populateResponseInfo(responseInfo, serial, responseType, e);
6030 Return<void> retStatus
6031 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6032 radioService[slotId]->checkReturnStatus(retStatus);
6034 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6040 int radio::requestShutdownResponse(int slotId,
6041 int responseType, int serial, RIL_Errno e,
6042 void *response, size_t responseLen) {
6044 RLOGD("requestShutdownResponse: serial %d", serial);
6047 if (radioService[slotId]->mRadioResponse != NULL) {
6048 RadioResponseInfo responseInfo = {};
6049 populateResponseInfo(responseInfo, serial, responseType, e);
6050 Return<void> retStatus
6051 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6052 radioService[slotId]->checkReturnStatus(retStatus);
6054 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6060 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6061 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6062 populateResponseInfo(responseInfo, serial, responseType, e);
6064 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6065 RLOGE("responseRadioCapability: Invalid response");
6066 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6067 rc.logicalModemUuid = hidl_string();
6069 convertRilRadioCapabilityToHal(response, responseLen, rc);
6073 int radio::getRadioCapabilityResponse(int slotId,
6074 int responseType, int serial, RIL_Errno e,
6075 void *response, size_t responseLen) {
6077 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6080 if (radioService[slotId]->mRadioResponse != NULL) {
6081 RadioResponseInfo responseInfo = {};
6082 RadioCapability result = {};
6083 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6085 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6086 responseInfo, result);
6087 radioService[slotId]->checkReturnStatus(retStatus);
6089 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6095 int radio::setRadioCapabilityResponse(int slotId,
6096 int responseType, int serial, RIL_Errno e,
6097 void *response, size_t responseLen) {
6099 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6102 if (radioService[slotId]->mRadioResponse != NULL) {
6103 RadioResponseInfo responseInfo = {};
6104 RadioCapability result = {};
6105 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6107 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6108 responseInfo, result);
6109 radioService[slotId]->checkReturnStatus(retStatus);
6111 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6117 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6118 RIL_Errno e, void *response, size_t responseLen) {
6119 populateResponseInfo(responseInfo, serial, responseType, e);
6120 LceStatusInfo result = {};
6122 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6123 RLOGE("Invalid response: NULL");
6124 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6126 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6127 result.lceStatus = (LceStatus) resp->lce_status;
6128 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6133 int radio::startLceServiceResponse(int slotId,
6134 int responseType, int serial, RIL_Errno e,
6135 void *response, size_t responseLen) {
6137 RLOGD("startLceServiceResponse: serial %d", serial);
6140 if (radioService[slotId]->mRadioResponse != NULL) {
6141 RadioResponseInfo responseInfo = {};
6142 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6143 response, responseLen);
6145 Return<void> retStatus
6146 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6148 radioService[slotId]->checkReturnStatus(retStatus);
6150 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6156 int radio::stopLceServiceResponse(int slotId,
6157 int responseType, int serial, RIL_Errno e,
6158 void *response, size_t responseLen) {
6160 RLOGD("stopLceServiceResponse: serial %d", serial);
6163 if (radioService[slotId]->mRadioResponse != NULL) {
6164 RadioResponseInfo responseInfo = {};
6165 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6166 response, responseLen);
6168 Return<void> retStatus
6169 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6171 radioService[slotId]->checkReturnStatus(retStatus);
6173 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6179 int radio::pullLceDataResponse(int slotId,
6180 int responseType, int serial, RIL_Errno e,
6181 void *response, size_t responseLen) {
6183 RLOGD("pullLceDataResponse: serial %d", serial);
6186 if (radioService[slotId]->mRadioResponse != NULL) {
6187 RadioResponseInfo responseInfo = {};
6188 populateResponseInfo(responseInfo, serial, responseType, e);
6190 LceDataInfo result = {};
6191 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6192 RLOGE("pullLceDataResponse: Invalid response");
6193 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6195 convertRilLceDataInfoToHal(response, responseLen, result);
6198 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6199 responseInfo, result);
6200 radioService[slotId]->checkReturnStatus(retStatus);
6202 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6208 int radio::getModemActivityInfoResponse(int slotId,
6209 int responseType, int serial, RIL_Errno e,
6210 void *response, size_t responseLen) {
6212 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6215 if (radioService[slotId]->mRadioResponse != NULL) {
6216 RadioResponseInfo responseInfo = {};
6217 populateResponseInfo(responseInfo, serial, responseType, e);
6218 ActivityStatsInfo info;
6219 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6220 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6221 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6223 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6224 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6225 info.idleModeTimeMs = resp->idle_mode_time_ms;
6226 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6227 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6229 info.rxModeTimeMs = resp->rx_mode_time_ms;
6232 Return<void> retStatus
6233 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6235 radioService[slotId]->checkReturnStatus(retStatus);
6237 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6244 int radio::setAllowedCarriersResponse(int slotId,
6245 int responseType, int serial, RIL_Errno e,
6246 void *response, size_t responseLen) {
6248 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6251 if (radioService[slotId]->mRadioResponse != NULL) {
6252 RadioResponseInfo responseInfo = {};
6253 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6254 Return<void> retStatus
6255 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6257 radioService[slotId]->checkReturnStatus(retStatus);
6259 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6266 int radio::getAllowedCarriersResponse(int slotId,
6267 int responseType, int serial, RIL_Errno e,
6268 void *response, size_t responseLen) {
6270 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6273 if (radioService[slotId]->mRadioResponse != NULL) {
6274 RadioResponseInfo responseInfo = {};
6275 populateResponseInfo(responseInfo, serial, responseType, e);
6276 CarrierRestrictions carrierInfo = {};
6277 bool allAllowed = true;
6278 if (response == NULL) {
6280 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6282 carrierInfo.allowedCarriers.resize(0);
6283 carrierInfo.excludedCarriers.resize(0);
6284 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6285 RLOGE("getAllowedCarriersResponse Invalid response");
6286 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6288 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6289 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6293 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6294 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6295 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6296 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6297 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6298 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6299 carrierInfo.allowedCarriers[i].matchData =
6300 convertCharPtrToHidlString(carrier->match_data);
6303 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6304 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6305 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6306 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6307 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6308 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6309 carrierInfo.excludedCarriers[i].matchData =
6310 convertCharPtrToHidlString(carrier->match_data);
6314 Return<void> retStatus
6315 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6316 allAllowed, carrierInfo);
6317 radioService[slotId]->checkReturnStatus(retStatus);
6319 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6326 int radio::sendDeviceStateResponse(int slotId,
6327 int responseType, int serial, RIL_Errno e,
6328 void *response, size_t responselen) {
6330 RLOGD("sendDeviceStateResponse: serial %d", serial);
6333 if (radioService[slotId]->mRadioResponse != NULL) {
6334 RadioResponseInfo responseInfo = {};
6335 populateResponseInfo(responseInfo, serial, responseType, e);
6336 Return<void> retStatus
6337 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6338 radioService[slotId]->checkReturnStatus(retStatus);
6340 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6346 int radio::setIndicationFilterResponse(int slotId,
6347 int responseType, int serial, RIL_Errno e,
6348 void *response, size_t responselen) {
6350 RLOGD("setIndicationFilterResponse: serial %d", serial);
6353 if (radioService[slotId]->mRadioResponse != NULL) {
6354 RadioResponseInfo responseInfo = {};
6355 populateResponseInfo(responseInfo, serial, responseType, e);
6356 Return<void> retStatus
6357 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6358 radioService[slotId]->checkReturnStatus(retStatus);
6360 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6368 int radio::setSimCardPowerResponse(int slotId,
6369 int responseType, int serial, RIL_Errno e,
6370 void *response, size_t responseLen) {
6372 RLOGD("setSimCardPowerResponse: serial %d", serial);
6375 if (radioService[slotId]->mRadioResponse != NULL) {
6376 RadioResponseInfo responseInfo = {};
6377 populateResponseInfo(responseInfo, serial, responseType, e);
6378 Return<void> retStatus
6379 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6380 radioService[slotId]->checkReturnStatus(retStatus);
6382 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6388 int radio::sendRequestRawResponse(int slotId,
6389 int responseType, int serial, RIL_Errno e,
6390 void *response, size_t responseLen) {
6392 RLOGD("sendRequestRawResponse: serial %d", serial);
6395 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6396 RadioResponseInfo responseInfo = {};
6397 populateResponseInfo(responseInfo, serial, responseType, e);
6398 hidl_vec<uint8_t> data;
6400 if (response == NULL) {
6401 RLOGE("sendRequestRawResponse: Invalid response");
6402 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6404 data.setToExternal((uint8_t *) response, responseLen);
6406 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6407 sendRequestRawResponse(responseInfo, data);
6408 checkReturnStatus(slotId, retStatus, false);
6410 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6417 int radio::sendRequestStringsResponse(int slotId,
6418 int responseType, int serial, RIL_Errno e,
6419 void *response, size_t responseLen) {
6421 RLOGD("sendRequestStringsResponse: serial %d", serial);
6424 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6425 RadioResponseInfo responseInfo = {};
6426 populateResponseInfo(responseInfo, serial, responseType, e);
6427 hidl_vec<hidl_string> data;
6429 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
6430 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6431 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6433 char **resp = (char **) response;
6434 int numStrings = responseLen / sizeof(char *);
6435 data.resize(numStrings);
6436 for (int i = 0; i < numStrings; i++) {
6437 data[i] = convertCharPtrToHidlString(resp[i]);
6440 Return<void> retStatus
6441 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6442 responseInfo, data);
6443 checkReturnStatus(slotId, retStatus, false);
6445 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6452 // Radio Indication functions
6454 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6455 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6456 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6459 int radio::radioStateChangedInd(int slotId,
6460 int indicationType, int token, RIL_Errno e, void *response,
6461 size_t responseLen) {
6462 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6463 RadioState radioState =
6464 (RadioState) CALL_ONSTATEREQUEST(slotId);
6465 RLOGD("radioStateChangedInd: radioState %d", radioState);
6466 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6467 convertIntToRadioIndicationType(indicationType), radioState);
6468 radioService[slotId]->checkReturnStatus(retStatus);
6470 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6476 int radio::callStateChangedInd(int slotId,
6477 int indicationType, int token, RIL_Errno e, void *response,
6478 size_t responseLen) {
6479 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6481 RLOGD("callStateChangedInd");
6483 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6484 convertIntToRadioIndicationType(indicationType));
6485 radioService[slotId]->checkReturnStatus(retStatus);
6487 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6493 int radio::networkStateChangedInd(int slotId,
6494 int indicationType, int token, RIL_Errno e, void *response,
6495 size_t responseLen) {
6496 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6498 RLOGD("networkStateChangedInd");
6500 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6501 convertIntToRadioIndicationType(indicationType));
6502 radioService[slotId]->checkReturnStatus(retStatus);
6504 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6511 uint8_t hexCharToInt(uint8_t c) {
6512 if (c >= '0' && c <= '9') return (c - '0');
6513 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6514 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6516 return INVALID_HEX_CHAR;
6519 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6520 if (responseLen % 2 != 0) {
6524 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6525 if (bytes == NULL) {
6526 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6529 uint8_t *hexString = (uint8_t *)response;
6531 for (size_t i = 0; i < responseLen; i += 2) {
6532 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6533 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6535 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6536 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6537 hexString[i], hexString[i + 1]);
6541 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6547 int radio::newSmsInd(int slotId, int indicationType,
6548 int token, RIL_Errno e, void *response, size_t responseLen) {
6549 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6550 if (response == NULL || responseLen == 0) {
6551 RLOGE("newSmsInd: invalid response");
6555 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6556 if (bytes == NULL) {
6557 RLOGE("newSmsInd: convertHexStringToBytes failed");
6561 hidl_vec<uint8_t> pdu;
6562 pdu.setToExternal(bytes, responseLen/2);
6566 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6567 convertIntToRadioIndicationType(indicationType), pdu);
6568 radioService[slotId]->checkReturnStatus(retStatus);
6571 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6577 int radio::newSmsStatusReportInd(int slotId,
6578 int indicationType, int token, RIL_Errno e, void *response,
6579 size_t responseLen) {
6580 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6581 if (response == NULL || responseLen == 0) {
6582 RLOGE("newSmsStatusReportInd: invalid response");
6586 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6587 if (bytes == NULL) {
6588 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6592 hidl_vec<uint8_t> pdu;
6593 pdu.setToExternal(bytes, responseLen/2);
6595 RLOGD("newSmsStatusReportInd");
6597 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6598 convertIntToRadioIndicationType(indicationType), pdu);
6599 radioService[slotId]->checkReturnStatus(retStatus);
6602 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6608 int radio::newSmsOnSimInd(int slotId, int indicationType,
6609 int token, RIL_Errno e, void *response, size_t responseLen) {
6610 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6611 if (response == NULL || responseLen != sizeof(int)) {
6612 RLOGE("newSmsOnSimInd: invalid response");
6615 int32_t recordNumber = ((int32_t *) response)[0];
6617 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6619 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6620 convertIntToRadioIndicationType(indicationType), recordNumber);
6621 radioService[slotId]->checkReturnStatus(retStatus);
6623 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6629 int radio::onUssdInd(int slotId, int indicationType,
6630 int token, RIL_Errno e, void *response, size_t responseLen) {
6631 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6632 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6633 RLOGE("onUssdInd: invalid response");
6636 char **strings = (char **) response;
6637 char *mode = strings[0];
6638 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6639 UssdModeType modeType = (UssdModeType) atoi(mode);
6641 RLOGD("onUssdInd: mode %s", mode);
6643 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6644 convertIntToRadioIndicationType(indicationType), modeType, msg);
6645 radioService[slotId]->checkReturnStatus(retStatus);
6647 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6653 int radio::nitzTimeReceivedInd(int slotId,
6654 int indicationType, int token, RIL_Errno e, void *response,
6655 size_t responseLen) {
6656 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6657 if (response == NULL || responseLen == 0) {
6658 RLOGE("nitzTimeReceivedInd: invalid response");
6661 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6662 int64_t timeReceived = android::elapsedRealtime();
6664 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6667 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6668 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6669 radioService[slotId]->checkReturnStatus(retStatus);
6671 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6678 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6679 SignalStrength& signalStrength) {
6680 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6682 // Fixup LTE for backwards compatibility
6683 // signalStrength: -1 -> 99
6684 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6685 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6687 // rsrp: -1 -> INT_MAX all other negative value to positive.
6689 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6690 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6691 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6692 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6694 // rsrq: -1 -> INT_MAX
6695 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6696 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6698 // Not remapping rssnr is already using INT_MAX
6699 // cqi: -1 -> INT_MAX
6700 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6701 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6704 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6705 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6706 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6707 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6708 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6709 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6710 signalStrength.evdo.signalNoiseRatio =
6711 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6712 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6713 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6714 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6715 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6716 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6717 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6718 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6721 int radio::currentSignalStrengthInd(int slotId,
6722 int indicationType, int token, RIL_Errno e,
6723 void *response, size_t responseLen) {
6724 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6725 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
6726 RLOGE("currentSignalStrengthInd: invalid response");
6730 SignalStrength signalStrength = {};
6731 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6734 RLOGD("currentSignalStrengthInd");
6736 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6737 convertIntToRadioIndicationType(indicationType), signalStrength);
6738 radioService[slotId]->checkReturnStatus(retStatus);
6740 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6747 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6748 SetupDataCallResult& dcResult) {
6749 dcResult.status = (DataCallFailCause) dcResponse->status;
6750 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6751 dcResult.cid = dcResponse->cid;
6752 dcResult.active = dcResponse->active;
6753 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6754 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6755 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6756 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6757 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6758 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6759 dcResult.mtu = dcResponse->mtu;
6762 void convertRilDataCallListToHal(void *response, size_t responseLen,
6763 hidl_vec<SetupDataCallResult>& dcResultList) {
6764 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6766 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6767 dcResultList.resize(num);
6768 for (int i = 0; i < num; i++) {
6769 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6773 int radio::dataCallListChangedInd(int slotId,
6774 int indicationType, int token, RIL_Errno e, void *response,
6775 size_t responseLen) {
6776 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6777 if ((response == NULL && responseLen != 0)
6778 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
6779 RLOGE("dataCallListChangedInd: invalid response");
6782 hidl_vec<SetupDataCallResult> dcList;
6783 convertRilDataCallListToHal(response, responseLen, dcList);
6785 RLOGD("dataCallListChangedInd");
6787 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
6788 convertIntToRadioIndicationType(indicationType), dcList);
6789 radioService[slotId]->checkReturnStatus(retStatus);
6791 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6797 int radio::suppSvcNotifyInd(int slotId, int indicationType,
6798 int token, RIL_Errno e, void *response, size_t responseLen) {
6799 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6800 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
6801 RLOGE("suppSvcNotifyInd: invalid response");
6805 SuppSvcNotification suppSvc = {};
6806 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6807 suppSvc.isMT = ssn->notificationType;
6808 suppSvc.code = ssn->code;
6809 suppSvc.index = ssn->index;
6810 suppSvc.type = ssn->type;
6811 suppSvc.number = convertCharPtrToHidlString(ssn->number);
6814 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
6815 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
6817 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
6818 convertIntToRadioIndicationType(indicationType), suppSvc);
6819 radioService[slotId]->checkReturnStatus(retStatus);
6821 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6827 int radio::stkSessionEndInd(int slotId, int indicationType,
6828 int token, RIL_Errno e, void *response, size_t responseLen) {
6829 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6831 RLOGD("stkSessionEndInd");
6833 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
6834 convertIntToRadioIndicationType(indicationType));
6835 radioService[slotId]->checkReturnStatus(retStatus);
6837 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
6843 int radio::stkProactiveCommandInd(int slotId,
6844 int indicationType, int token, RIL_Errno e, void *response,
6845 size_t responseLen) {
6846 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6847 if (response == NULL || responseLen == 0) {
6848 RLOGE("stkProactiveCommandInd: invalid response");
6852 RLOGD("stkProactiveCommandInd");
6854 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
6855 convertIntToRadioIndicationType(indicationType),
6856 convertCharPtrToHidlString((char *) response));
6857 radioService[slotId]->checkReturnStatus(retStatus);
6859 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
6865 int radio::stkEventNotifyInd(int slotId, int indicationType,
6866 int token, RIL_Errno e, void *response, size_t responseLen) {
6867 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6868 if (response == NULL || responseLen == 0) {
6869 RLOGE("stkEventNotifyInd: invalid response");
6873 RLOGD("stkEventNotifyInd");
6875 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
6876 convertIntToRadioIndicationType(indicationType),
6877 convertCharPtrToHidlString((char *) response));
6878 radioService[slotId]->checkReturnStatus(retStatus);
6880 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6886 int radio::stkCallSetupInd(int slotId, int indicationType,
6887 int token, RIL_Errno e, void *response, size_t responseLen) {
6888 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6889 if (response == NULL || responseLen != sizeof(int)) {
6890 RLOGE("stkCallSetupInd: invalid response");
6893 int32_t timeout = ((int32_t *) response)[0];
6895 RLOGD("stkCallSetupInd: timeout %d", timeout);
6897 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
6898 convertIntToRadioIndicationType(indicationType), timeout);
6899 radioService[slotId]->checkReturnStatus(retStatus);
6901 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
6907 int radio::simSmsStorageFullInd(int slotId,
6908 int indicationType, int token, RIL_Errno e, void *response,
6909 size_t responseLen) {
6910 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6912 RLOGD("simSmsStorageFullInd");
6914 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
6915 convertIntToRadioIndicationType(indicationType));
6916 radioService[slotId]->checkReturnStatus(retStatus);
6918 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
6924 int radio::simRefreshInd(int slotId, int indicationType,
6925 int token, RIL_Errno e, void *response, size_t responseLen) {
6926 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6927 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
6928 RLOGE("simRefreshInd: invalid response");
6932 SimRefreshResult refreshResult = {};
6933 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
6934 refreshResult.type =
6935 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
6936 refreshResult.efId = simRefreshResponse->ef_id;
6937 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
6940 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
6942 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
6943 convertIntToRadioIndicationType(indicationType), refreshResult);
6944 radioService[slotId]->checkReturnStatus(retStatus);
6946 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
6952 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
6953 CdmaSignalInfoRecord& record) {
6954 record.isPresent = signalInfoRecord->isPresent;
6955 record.signalType = signalInfoRecord->signalType;
6956 record.alertPitch = signalInfoRecord->alertPitch;
6957 record.signal = signalInfoRecord->signal;
6960 int radio::callRingInd(int slotId, int indicationType,
6961 int token, RIL_Errno e, void *response, size_t responseLen) {
6962 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6964 CdmaSignalInfoRecord record = {};
6965 if (response == NULL || responseLen == 0) {
6969 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
6970 RLOGE("callRingInd: invalid response");
6973 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
6977 RLOGD("callRingInd: isGsm %d", isGsm);
6979 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
6980 convertIntToRadioIndicationType(indicationType), isGsm, record);
6981 radioService[slotId]->checkReturnStatus(retStatus);
6983 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
6989 int radio::simStatusChangedInd(int slotId,
6990 int indicationType, int token, RIL_Errno e, void *response,
6991 size_t responseLen) {
6992 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6994 RLOGD("simStatusChangedInd");
6996 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
6997 convertIntToRadioIndicationType(indicationType));
6998 radioService[slotId]->checkReturnStatus(retStatus);
7000 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7006 int radio::cdmaNewSmsInd(int slotId, int indicationType,
7007 int token, RIL_Errno e, void *response, size_t responseLen) {
7008 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7009 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7010 RLOGE("cdmaNewSmsInd: invalid response");
7014 CdmaSmsMessage msg = {};
7015 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7016 msg.teleserviceId = rilMsg->uTeleserviceID;
7017 msg.isServicePresent = rilMsg->bIsServicePresent;
7018 msg.serviceCategory = rilMsg->uServicecategory;
7019 msg.address.digitMode =
7020 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7021 msg.address.numberMode =
7022 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7023 msg.address.numberType =
7024 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7025 msg.address.numberPlan =
7026 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7028 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7029 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7031 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
7032 rilMsg->sSubAddress.subaddressType;
7033 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7035 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7036 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7038 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7039 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7042 RLOGD("cdmaNewSmsInd");
7044 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7045 convertIntToRadioIndicationType(indicationType), msg);
7046 radioService[slotId]->checkReturnStatus(retStatus);
7048 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7054 int radio::newBroadcastSmsInd(int slotId,
7055 int indicationType, int token, RIL_Errno e, void *response,
7056 size_t responseLen) {
7057 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7058 if (response == NULL || responseLen == 0) {
7059 RLOGE("newBroadcastSmsInd: invalid response");
7063 hidl_vec<uint8_t> data;
7064 data.setToExternal((uint8_t *) response, responseLen);
7066 RLOGD("newBroadcastSmsInd");
7068 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7069 convertIntToRadioIndicationType(indicationType), data);
7070 radioService[slotId]->checkReturnStatus(retStatus);
7072 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7078 int radio::cdmaRuimSmsStorageFullInd(int slotId,
7079 int indicationType, int token, RIL_Errno e, void *response,
7080 size_t responseLen) {
7081 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7083 RLOGD("cdmaRuimSmsStorageFullInd");
7085 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7086 convertIntToRadioIndicationType(indicationType));
7087 radioService[slotId]->checkReturnStatus(retStatus);
7089 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7096 int radio::restrictedStateChangedInd(int slotId,
7097 int indicationType, int token, RIL_Errno e, void *response,
7098 size_t responseLen) {
7099 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7100 if (response == NULL || responseLen != sizeof(int)) {
7101 RLOGE("restrictedStateChangedInd: invalid response");
7104 int32_t state = ((int32_t *) response)[0];
7106 RLOGD("restrictedStateChangedInd: state %d", state);
7108 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7109 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7110 radioService[slotId]->checkReturnStatus(retStatus);
7112 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7119 int radio::enterEmergencyCallbackModeInd(int slotId,
7120 int indicationType, int token, RIL_Errno e, void *response,
7121 size_t responseLen) {
7122 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7124 RLOGD("enterEmergencyCallbackModeInd");
7126 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7127 convertIntToRadioIndicationType(indicationType));
7128 radioService[slotId]->checkReturnStatus(retStatus);
7130 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7137 int radio::cdmaCallWaitingInd(int slotId,
7138 int indicationType, int token, RIL_Errno e, void *response,
7139 size_t responseLen) {
7140 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7141 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7142 RLOGE("cdmaCallWaitingInd: invalid response");
7146 CdmaCallWaiting callWaitingRecord = {};
7147 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7148 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7149 callWaitingRecord.numberPresentation =
7150 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7151 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7152 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7153 callWaitingRecord.signalInfoRecord);
7154 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7155 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7158 RLOGD("cdmaCallWaitingInd");
7160 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7161 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7162 radioService[slotId]->checkReturnStatus(retStatus);
7164 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7170 int radio::cdmaOtaProvisionStatusInd(int slotId,
7171 int indicationType, int token, RIL_Errno e, void *response,
7172 size_t responseLen) {
7173 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7174 if (response == NULL || responseLen != sizeof(int)) {
7175 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7178 int32_t status = ((int32_t *) response)[0];
7180 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7182 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7183 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7184 radioService[slotId]->checkReturnStatus(retStatus);
7186 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7193 int radio::cdmaInfoRecInd(int slotId,
7194 int indicationType, int token, RIL_Errno e, void *response,
7195 size_t responseLen) {
7196 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7197 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7198 RLOGE("cdmaInfoRecInd: invalid response");
7202 CdmaInformationRecords records = {};
7203 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7205 char* string8 = NULL;
7206 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7207 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7208 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7209 "additional ones", recordsRil->numberOfInfoRecs,
7210 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7212 records.infoRec.resize(num);
7213 for (int i = 0 ; i < num ; i++) {
7214 CdmaInformationRecord *record = &records.infoRec[i];
7215 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7216 record->name = (CdmaInfoRecName) infoRec->name;
7217 // All vectors should be size 0 except one which will be size 1. Set everything to
7218 // size 0 initially.
7219 record->display.resize(0);
7220 record->number.resize(0);
7221 record->signal.resize(0);
7222 record->redir.resize(0);
7223 record->lineCtrl.resize(0);
7224 record->clir.resize(0);
7225 record->audioCtrl.resize(0);
7226 switch (infoRec->name) {
7227 case RIL_CDMA_DISPLAY_INFO_REC:
7228 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7229 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7230 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7231 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7232 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7235 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7236 if (string8 == NULL) {
7237 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7238 "responseCdmaInformationRecords");
7241 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7242 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7244 record->display.resize(1);
7245 record->display[0].alphaBuf = string8;
7251 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7252 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7253 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7254 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7255 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7256 "expected not more than %d", (int) infoRec->rec.number.len,
7257 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7260 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7261 if (string8 == NULL) {
7262 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7263 "responseCdmaInformationRecords");
7266 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7267 string8[(int)infoRec->rec.number.len] = '\0';
7269 record->number.resize(1);
7270 record->number[0].number = string8;
7273 record->number[0].numberType = infoRec->rec.number.number_type;
7274 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7275 record->number[0].pi = infoRec->rec.number.pi;
7276 record->number[0].si = infoRec->rec.number.si;
7280 case RIL_CDMA_SIGNAL_INFO_REC: {
7281 record->signal.resize(1);
7282 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7283 record->signal[0].signalType = infoRec->rec.signal.signalType;
7284 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7285 record->signal[0].signal = infoRec->rec.signal.signal;
7289 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7290 if (infoRec->rec.redir.redirectingNumber.len >
7291 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7292 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7293 "expected not more than %d\n",
7294 (int)infoRec->rec.redir.redirectingNumber.len,
7295 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7298 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7300 if (string8 == NULL) {
7301 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7302 "responseCdmaInformationRecords");
7305 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7306 infoRec->rec.redir.redirectingNumber.len);
7307 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7309 record->redir.resize(1);
7310 record->redir[0].redirectingNumber.number = string8;
7313 record->redir[0].redirectingNumber.numberType =
7314 infoRec->rec.redir.redirectingNumber.number_type;
7315 record->redir[0].redirectingNumber.numberPlan =
7316 infoRec->rec.redir.redirectingNumber.number_plan;
7317 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7318 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7319 record->redir[0].redirectingReason =
7320 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7324 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7325 record->lineCtrl.resize(1);
7326 record->lineCtrl[0].lineCtrlPolarityIncluded =
7327 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7328 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7329 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7330 record->lineCtrl[0].lineCtrlPowerDenial =
7331 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7335 case RIL_CDMA_T53_CLIR_INFO_REC: {
7336 record->clir.resize(1);
7337 record->clir[0].cause = infoRec->rec.clir.cause;
7341 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7342 record->audioCtrl.resize(1);
7343 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7344 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7348 case RIL_CDMA_T53_RELEASE_INFO_REC:
7349 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7353 RLOGE("cdmaInfoRecInd: Incorrect name value");
7359 RLOGD("cdmaInfoRecInd");
7361 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7362 convertIntToRadioIndicationType(indicationType), records);
7363 radioService[slotId]->checkReturnStatus(retStatus);
7365 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7371 int radio::indicateRingbackToneInd(int slotId,
7372 int indicationType, int token, RIL_Errno e, void *response,
7373 size_t responseLen) {
7374 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7375 if (response == NULL || responseLen != sizeof(int)) {
7376 RLOGE("indicateRingbackToneInd: invalid response");
7379 bool start = ((int32_t *) response)[0];
7381 RLOGD("indicateRingbackToneInd: start %d", start);
7383 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7384 convertIntToRadioIndicationType(indicationType), start);
7385 radioService[slotId]->checkReturnStatus(retStatus);
7387 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7393 int radio::resendIncallMuteInd(int slotId,
7394 int indicationType, int token, RIL_Errno e, void *response,
7395 size_t responseLen) {
7396 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7398 RLOGD("resendIncallMuteInd");
7400 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7401 convertIntToRadioIndicationType(indicationType));
7402 radioService[slotId]->checkReturnStatus(retStatus);
7404 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7410 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7411 int indicationType, int token, RIL_Errno e,
7412 void *response, size_t responseLen) {
7413 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7414 if (response == NULL || responseLen != sizeof(int)) {
7415 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7418 int32_t cdmaSource = ((int32_t *) response)[0];
7420 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7422 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7423 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7424 (CdmaSubscriptionSource) cdmaSource);
7425 radioService[slotId]->checkReturnStatus(retStatus);
7427 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7434 int radio::cdmaPrlChangedInd(int slotId,
7435 int indicationType, int token, RIL_Errno e, void *response,
7436 size_t responseLen) {
7437 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7438 if (response == NULL || responseLen != sizeof(int)) {
7439 RLOGE("cdmaPrlChangedInd: invalid response");
7442 int32_t version = ((int32_t *) response)[0];
7444 RLOGD("cdmaPrlChangedInd: version %d", version);
7446 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7447 convertIntToRadioIndicationType(indicationType), version);
7448 radioService[slotId]->checkReturnStatus(retStatus);
7450 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7456 int radio::exitEmergencyCallbackModeInd(int slotId,
7457 int indicationType, int token, RIL_Errno e, void *response,
7458 size_t responseLen) {
7459 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7461 RLOGD("exitEmergencyCallbackModeInd");
7463 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7464 convertIntToRadioIndicationType(indicationType));
7465 radioService[slotId]->checkReturnStatus(retStatus);
7467 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7474 int radio::rilConnectedInd(int slotId,
7475 int indicationType, int token, RIL_Errno e, void *response,
7476 size_t responseLen) {
7477 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7478 RLOGD("rilConnectedInd");
7479 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7480 convertIntToRadioIndicationType(indicationType));
7481 radioService[slotId]->checkReturnStatus(retStatus);
7483 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7489 int radio::voiceRadioTechChangedInd(int slotId,
7490 int indicationType, int token, RIL_Errno e, void *response,
7491 size_t responseLen) {
7492 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7493 if (response == NULL || responseLen != sizeof(int)) {
7494 RLOGE("voiceRadioTechChangedInd: invalid response");
7497 int32_t rat = ((int32_t *) response)[0];
7499 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7501 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7502 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7503 radioService[slotId]->checkReturnStatus(retStatus);
7505 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7512 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7513 int num = responseLen / sizeof(RIL_CellInfo_v12);
7514 records.resize(num);
7516 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7517 for (int i = 0; i < num; i++) {
7518 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7519 records[i].registered = rillCellInfo->registered;
7520 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7521 records[i].timeStamp = rillCellInfo->timeStamp;
7522 // All vectors should be size 0 except one which will be size 1. Set everything to
7523 // size 0 initially.
7524 records[i].gsm.resize(0);
7525 records[i].wcdma.resize(0);
7526 records[i].cdma.resize(0);
7527 records[i].lte.resize(0);
7528 records[i].tdscdma.resize(0);
7529 switch(rillCellInfo->cellInfoType) {
7530 case RIL_CELL_INFO_TYPE_GSM: {
7531 records[i].gsm.resize(1);
7532 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7533 cellInfoGsm->cellIdentityGsm.mcc =
7534 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7535 cellInfoGsm->cellIdentityGsm.mnc =
7536 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7537 cellInfoGsm->cellIdentityGsm.lac =
7538 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7539 cellInfoGsm->cellIdentityGsm.cid =
7540 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7541 cellInfoGsm->cellIdentityGsm.arfcn =
7542 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7543 cellInfoGsm->cellIdentityGsm.bsic =
7544 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7545 cellInfoGsm->signalStrengthGsm.signalStrength =
7546 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7547 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7548 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7549 cellInfoGsm->signalStrengthGsm.timingAdvance =
7550 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7554 case RIL_CELL_INFO_TYPE_WCDMA: {
7555 records[i].wcdma.resize(1);
7556 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7557 cellInfoWcdma->cellIdentityWcdma.mcc =
7558 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7559 cellInfoWcdma->cellIdentityWcdma.mnc =
7560 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7561 cellInfoWcdma->cellIdentityWcdma.lac =
7562 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7563 cellInfoWcdma->cellIdentityWcdma.cid =
7564 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7565 cellInfoWcdma->cellIdentityWcdma.psc =
7566 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7567 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7568 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7569 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7570 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7571 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7572 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7576 case RIL_CELL_INFO_TYPE_CDMA: {
7577 records[i].cdma.resize(1);
7578 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7579 cellInfoCdma->cellIdentityCdma.networkId =
7580 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7581 cellInfoCdma->cellIdentityCdma.systemId =
7582 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7583 cellInfoCdma->cellIdentityCdma.baseStationId =
7584 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7585 cellInfoCdma->cellIdentityCdma.longitude =
7586 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7587 cellInfoCdma->cellIdentityCdma.latitude =
7588 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7589 cellInfoCdma->signalStrengthCdma.dbm =
7590 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7591 cellInfoCdma->signalStrengthCdma.ecio =
7592 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7593 cellInfoCdma->signalStrengthEvdo.dbm =
7594 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7595 cellInfoCdma->signalStrengthEvdo.ecio =
7596 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7597 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7598 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7602 case RIL_CELL_INFO_TYPE_LTE: {
7603 records[i].lte.resize(1);
7604 CellInfoLte *cellInfoLte = &records[i].lte[0];
7605 cellInfoLte->cellIdentityLte.mcc =
7606 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7607 cellInfoLte->cellIdentityLte.mnc =
7608 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7609 cellInfoLte->cellIdentityLte.ci =
7610 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7611 cellInfoLte->cellIdentityLte.pci =
7612 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7613 cellInfoLte->cellIdentityLte.tac =
7614 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7615 cellInfoLte->cellIdentityLte.earfcn =
7616 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7617 cellInfoLte->signalStrengthLte.signalStrength =
7618 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7619 cellInfoLte->signalStrengthLte.rsrp =
7620 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7621 cellInfoLte->signalStrengthLte.rsrq =
7622 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7623 cellInfoLte->signalStrengthLte.rssnr =
7624 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7625 cellInfoLte->signalStrengthLte.cqi =
7626 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7627 cellInfoLte->signalStrengthLte.timingAdvance =
7628 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7632 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7633 records[i].tdscdma.resize(1);
7634 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7635 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7636 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7637 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7638 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7639 cellInfoTdscdma->cellIdentityTdscdma.lac =
7640 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7641 cellInfoTdscdma->cellIdentityTdscdma.cid =
7642 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7643 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7644 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7645 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7646 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7657 int radio::cellInfoListInd(int slotId,
7658 int indicationType, int token, RIL_Errno e, void *response,
7659 size_t responseLen) {
7660 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7661 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7662 RLOGE("cellInfoListInd: invalid response");
7666 hidl_vec<CellInfo> records;
7667 convertRilCellInfoListToHal(response, responseLen, records);
7670 RLOGD("cellInfoListInd");
7672 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7673 convertIntToRadioIndicationType(indicationType), records);
7674 radioService[slotId]->checkReturnStatus(retStatus);
7676 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7682 int radio::imsNetworkStateChangedInd(int slotId,
7683 int indicationType, int token, RIL_Errno e, void *response,
7684 size_t responseLen) {
7685 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7687 RLOGD("imsNetworkStateChangedInd");
7689 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7690 convertIntToRadioIndicationType(indicationType));
7691 radioService[slotId]->checkReturnStatus(retStatus);
7693 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7700 int radio::subscriptionStatusChangedInd(int slotId,
7701 int indicationType, int token, RIL_Errno e, void *response,
7702 size_t responseLen) {
7703 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7704 if (response == NULL || responseLen != sizeof(int)) {
7705 RLOGE("subscriptionStatusChangedInd: invalid response");
7708 bool activate = ((int32_t *) response)[0];
7710 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7712 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
7713 convertIntToRadioIndicationType(indicationType), activate);
7714 radioService[slotId]->checkReturnStatus(retStatus);
7716 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
7723 int radio::srvccStateNotifyInd(int slotId,
7724 int indicationType, int token, RIL_Errno e, void *response,
7725 size_t responseLen) {
7726 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7727 if (response == NULL || responseLen != sizeof(int)) {
7728 RLOGE("srvccStateNotifyInd: invalid response");
7731 int32_t state = ((int32_t *) response)[0];
7733 RLOGD("srvccStateNotifyInd: rat %d", state);
7735 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
7736 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
7737 radioService[slotId]->checkReturnStatus(retStatus);
7739 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7745 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7746 hidl_vec<HardwareConfig>& records) {
7747 int num = responseLen / sizeof(RIL_HardwareConfig);
7748 records.resize(num);
7750 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7751 for (int i = 0; i < num; i++) {
7752 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7753 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7754 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7755 switch (rilHardwareConfig[i].type) {
7756 case RIL_HARDWARE_CONFIG_MODEM: {
7757 records[i].modem.resize(1);
7758 records[i].sim.resize(0);
7759 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7760 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7761 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7762 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7763 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7767 case RIL_HARDWARE_CONFIG_SIM: {
7768 records[i].sim.resize(1);
7769 records[i].modem.resize(0);
7770 records[i].sim[0].modemUuid =
7771 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7778 int radio::hardwareConfigChangedInd(int slotId,
7779 int indicationType, int token, RIL_Errno e, void *response,
7780 size_t responseLen) {
7781 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7782 if ((response == NULL && responseLen != 0)
7783 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7784 RLOGE("hardwareConfigChangedInd: invalid response");
7788 hidl_vec<HardwareConfig> configs;
7789 convertRilHardwareConfigListToHal(response, responseLen, configs);
7792 RLOGD("hardwareConfigChangedInd");
7794 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
7795 convertIntToRadioIndicationType(indicationType), configs);
7796 radioService[slotId]->checkReturnStatus(retStatus);
7798 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
7805 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7806 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7807 rc.session = rilRadioCapability->session;
7808 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7809 rc.raf = rilRadioCapability->rat;
7810 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7811 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
7814 int radio::radioCapabilityIndicationInd(int slotId,
7815 int indicationType, int token, RIL_Errno e, void *response,
7816 size_t responseLen) {
7817 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7818 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
7819 RLOGE("radioCapabilityIndicationInd: invalid response");
7823 RadioCapability rc = {};
7824 convertRilRadioCapabilityToHal(response, responseLen, rc);
7827 RLOGD("radioCapabilityIndicationInd");
7829 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
7830 convertIntToRadioIndicationType(indicationType), rc);
7831 radioService[slotId]->checkReturnStatus(retStatus);
7833 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
7840 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
7841 if ((reqType == SS_INTERROGATION) &&
7842 (serType == SS_CFU ||
7843 serType == SS_CF_BUSY ||
7844 serType == SS_CF_NO_REPLY ||
7845 serType == SS_CF_NOT_REACHABLE ||
7846 serType == SS_CF_ALL ||
7847 serType == SS_CF_ALL_CONDITIONAL)) {
7853 int radio::onSupplementaryServiceIndicationInd(int slotId,
7854 int indicationType, int token, RIL_Errno e,
7855 void *response, size_t responseLen) {
7856 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7857 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
7858 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
7862 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
7863 StkCcUnsolSsResult ss = {};
7864 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
7865 ss.requestType = (SsRequestType) rilSsResponse->requestType;
7866 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
7867 ss.serviceClass = rilSsResponse->serviceClass;
7868 ss.result = (RadioError) rilSsResponse->result;
7870 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
7872 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
7873 rilSsResponse->cfData.numValidIndexes);
7875 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
7876 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
7877 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
7878 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
7881 ss.cfData.resize(1);
7882 ss.ssInfo.resize(0);
7884 /* number of call info's */
7885 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
7887 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
7888 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
7889 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
7891 cfInfo->status = (CallForwardInfoStatus) cf.status;
7892 cfInfo->reason = cf.reason;
7893 cfInfo->serviceClass = cf.serviceClass;
7894 cfInfo->toa = cf.toa;
7895 cfInfo->number = convertCharPtrToHidlString(cf.number);
7896 cfInfo->timeSeconds = cf.timeSeconds;
7898 RLOGD("onSupplementaryServiceIndicationInd: "
7899 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
7900 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
7904 ss.ssInfo.resize(1);
7905 ss.cfData.resize(0);
7908 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
7909 for (int i = 0; i < SS_INFO_MAX; i++) {
7911 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
7912 rilSsResponse->ssInfo[i]);
7914 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
7919 RLOGD("onSupplementaryServiceIndicationInd");
7921 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7922 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
7924 radioService[slotId]->checkReturnStatus(retStatus);
7926 RLOGE("onSupplementaryServiceIndicationInd: "
7927 "radioService[%d]->mRadioIndication == NULL", slotId);
7933 int radio::stkCallControlAlphaNotifyInd(int slotId,
7934 int indicationType, int token, RIL_Errno e, void *response,
7935 size_t responseLen) {
7936 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7937 if (response == NULL || responseLen == 0) {
7938 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
7942 RLOGD("stkCallControlAlphaNotifyInd");
7944 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
7945 convertIntToRadioIndicationType(indicationType),
7946 convertCharPtrToHidlString((char *) response));
7947 radioService[slotId]->checkReturnStatus(retStatus);
7949 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
7956 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
7957 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
7958 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
7959 lce.confidenceLevel = rilLceDataInfo->confidence_level;
7960 lce.lceSuspended = rilLceDataInfo->lce_suspended;
7963 int radio::lceDataInd(int slotId,
7964 int indicationType, int token, RIL_Errno e, void *response,
7965 size_t responseLen) {
7966 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7967 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
7968 RLOGE("lceDataInd: invalid response");
7972 LceDataInfo lce = {};
7973 convertRilLceDataInfoToHal(response, responseLen, lce);
7975 RLOGD("lceDataInd");
7977 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
7978 convertIntToRadioIndicationType(indicationType), lce);
7979 radioService[slotId]->checkReturnStatus(retStatus);
7981 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7987 int radio::pcoDataInd(int slotId,
7988 int indicationType, int token, RIL_Errno e, void *response,
7989 size_t responseLen) {
7990 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7991 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
7992 RLOGE("pcoDataInd: invalid response");
7996 PcoDataInfo pco = {};
7997 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
7998 pco.cid = rilPcoData->cid;
7999 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8000 pco.pcoId = rilPcoData->pco_id;
8001 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8004 RLOGD("pcoDataInd");
8006 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8007 convertIntToRadioIndicationType(indicationType), pco);
8008 radioService[slotId]->checkReturnStatus(retStatus);
8010 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8016 int radio::modemResetInd(int slotId,
8017 int indicationType, int token, RIL_Errno e, void *response,
8018 size_t responseLen) {
8019 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8020 if (response == NULL || responseLen == 0) {
8021 RLOGE("modemResetInd: invalid response");
8025 RLOGD("modemResetInd");
8027 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8028 convertIntToRadioIndicationType(indicationType),
8029 convertCharPtrToHidlString((char *) response));
8030 radioService[slotId]->checkReturnStatus(retStatus);
8032 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8038 int radio::oemHookRawInd(int slotId,
8039 int indicationType, int token, RIL_Errno e, void *response,
8040 size_t responseLen) {
8041 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8042 if (response == NULL || responseLen == 0) {
8043 RLOGE("oemHookRawInd: invalid response");
8047 hidl_vec<uint8_t> data;
8048 data.setToExternal((uint8_t *) response, responseLen);
8050 RLOGD("oemHookRawInd");
8052 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8053 convertIntToRadioIndicationType(indicationType), data);
8054 checkReturnStatus(slotId, retStatus, false);
8056 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8062 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8063 using namespace android::hardware;
8065 const char *serviceNames[] = {
8066 android::RIL_getServiceName()
8067 #if (SIM_COUNT >= 2)
8069 #if (SIM_COUNT >= 3)
8071 #if (SIM_COUNT >= 4)
8078 #if (SIM_COUNT >= 2)
8079 simCount = SIM_COUNT;
8082 configureRpcThreadpool(1, true /* callerWillJoin */);
8083 for (int i = 0; i < simCount; i++) {
8084 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8085 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8088 radioService[i] = new RadioImpl;
8089 radioService[i]->mSlotId = i;
8090 oemHookService[i] = new OemHookImpl;
8091 oemHookService[i]->mSlotId = i;
8092 RLOGD("registerService: starting IRadio %s", serviceNames[i]);
8093 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8094 status = oemHookService[i]->registerAsService(serviceNames[i]);
8096 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8100 s_vendorFunctions = callbacks;
8101 s_commands = commands;
8104 void rilc_thread_pool() {
8105 joinRpcThreadpool();
8108 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8109 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8111 #if (SIM_COUNT >= 2)
8112 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8113 #if (SIM_COUNT >= 3)
8114 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8115 #if (SIM_COUNT >= 4)
8116 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8121 return radioServiceRwlockPtr;