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 using namespace android::hardware::radio::V1_0;
32 using namespace android::hardware::radio::deprecated::V1_0;
33 using ::android::hardware::configureRpcThreadpool;
34 using ::android::hardware::joinRpcThreadpool;
35 using ::android::hardware::Return;
36 using ::android::hardware::hidl_string;
37 using ::android::hardware::hidl_vec;
38 using ::android::hardware::hidl_array;
39 using ::android::hardware::Void;
40 using android::CommandInfo;
41 using android::RequestInfo;
42 using android::requestToString;
45 #define BOOL_TO_INT(x) (x ? 1 : 0)
46 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
47 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
49 RIL_RadioFunctions *s_vendorFunctions = NULL;
50 static CommandInfo *s_commands;
56 sp<RadioImpl> radioService[SIM_COUNT];
57 sp<OemHookImpl> oemHookService[SIM_COUNT];
58 // counter used for synchronization. It is incremented every time response callbacks are updated.
59 volatile int32_t mCounter[SIM_COUNT];
61 sp<RadioImpl> radioService[1];
62 sp<OemHookImpl> oemHookService[1];
63 // counter used for synchronization. It is incremented every time response callbacks are updated.
64 volatile int32_t mCounter[1];
67 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
70 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
72 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
74 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
79 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
80 hidl_vec<HardwareConfig>& records);
82 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
84 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
86 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
87 SignalStrength& signalStrength);
89 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
90 SetupDataCallResult& dcResult);
92 void convertRilDataCallListToHal(void *response, size_t responseLen,
93 hidl_vec<SetupDataCallResult>& dcResultList);
95 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
97 struct RadioImpl : public IRadio {
99 sp<IRadioResponse> mRadioResponse;
100 sp<IRadioIndication> mRadioIndication;
102 Return<void> setResponseFunctions(
103 const ::android::sp<IRadioResponse>& radioResponse,
104 const ::android::sp<IRadioIndication>& radioIndication);
106 Return<void> getIccCardStatus(int32_t serial);
108 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
109 const hidl_string& aid);
111 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
112 const hidl_string& pin, const hidl_string& aid);
114 Return<void> supplyIccPin2ForApp(int32_t serial,
115 const hidl_string& pin2,
116 const hidl_string& aid);
118 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
119 const hidl_string& pin2, const hidl_string& aid);
121 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
122 const hidl_string& newPin, const hidl_string& aid);
124 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
125 const hidl_string& newPin2, const hidl_string& aid);
127 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
129 Return<void> getCurrentCalls(int32_t serial);
131 Return<void> dial(int32_t serial, const Dial& dialInfo);
133 Return<void> getImsiForApp(int32_t serial,
134 const ::android::hardware::hidl_string& aid);
136 Return<void> hangup(int32_t serial, int32_t gsmIndex);
138 Return<void> hangupWaitingOrBackground(int32_t serial);
140 Return<void> hangupForegroundResumeBackground(int32_t serial);
142 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
144 Return<void> conference(int32_t serial);
146 Return<void> rejectCall(int32_t serial);
148 Return<void> getLastCallFailCause(int32_t serial);
150 Return<void> getSignalStrength(int32_t serial);
152 Return<void> getVoiceRegistrationState(int32_t serial);
154 Return<void> getDataRegistrationState(int32_t serial);
156 Return<void> getOperator(int32_t serial);
158 Return<void> setRadioPower(int32_t serial, bool on);
160 Return<void> sendDtmf(int32_t serial,
161 const ::android::hardware::hidl_string& s);
163 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
165 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
167 Return<void> setupDataCall(int32_t serial,
168 RadioTechnology radioTechnology,
169 const DataProfileInfo& profileInfo,
174 Return<void> iccIOForApp(int32_t serial,
177 Return<void> sendUssd(int32_t serial,
178 const ::android::hardware::hidl_string& ussd);
180 Return<void> cancelPendingUssd(int32_t serial);
182 Return<void> getClir(int32_t serial);
184 Return<void> setClir(int32_t serial, int32_t status);
186 Return<void> getCallForwardStatus(int32_t serial,
187 const CallForwardInfo& callInfo);
189 Return<void> setCallForward(int32_t serial,
190 const CallForwardInfo& callInfo);
192 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
194 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
196 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
197 bool success, SmsAcknowledgeFailCause cause);
199 Return<void> acceptCall(int32_t serial);
201 Return<void> deactivateDataCall(int32_t serial,
202 int32_t cid, bool reasonRadioShutDown);
204 Return<void> getFacilityLockForApp(int32_t serial,
205 const ::android::hardware::hidl_string& facility,
206 const ::android::hardware::hidl_string& password,
207 int32_t serviceClass,
208 const ::android::hardware::hidl_string& appId);
210 Return<void> setFacilityLockForApp(int32_t serial,
211 const ::android::hardware::hidl_string& facility,
213 const ::android::hardware::hidl_string& password,
214 int32_t serviceClass,
215 const ::android::hardware::hidl_string& appId);
217 Return<void> setBarringPassword(int32_t serial,
218 const ::android::hardware::hidl_string& facility,
219 const ::android::hardware::hidl_string& oldPassword,
220 const ::android::hardware::hidl_string& newPassword);
222 Return<void> getNetworkSelectionMode(int32_t serial);
224 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
226 Return<void> setNetworkSelectionModeManual(int32_t serial,
227 const ::android::hardware::hidl_string& operatorNumeric);
229 Return<void> getAvailableNetworks(int32_t serial);
231 Return<void> startDtmf(int32_t serial,
232 const ::android::hardware::hidl_string& s);
234 Return<void> stopDtmf(int32_t serial);
236 Return<void> getBasebandVersion(int32_t serial);
238 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
240 Return<void> setMute(int32_t serial, bool enable);
242 Return<void> getMute(int32_t serial);
244 Return<void> getClip(int32_t serial);
246 Return<void> getDataCallList(int32_t serial);
248 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
250 Return<void> writeSmsToSim(int32_t serial,
251 const SmsWriteArgs& smsWriteArgs);
253 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
255 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
257 Return<void> getAvailableBandModes(int32_t serial);
259 Return<void> sendEnvelope(int32_t serial,
260 const ::android::hardware::hidl_string& command);
262 Return<void> sendTerminalResponseToSim(int32_t serial,
263 const ::android::hardware::hidl_string& commandResponse);
265 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
267 Return<void> explicitCallTransfer(int32_t serial);
269 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
271 Return<void> getPreferredNetworkType(int32_t serial);
273 Return<void> getNeighboringCids(int32_t serial);
275 Return<void> setLocationUpdates(int32_t serial, bool enable);
277 Return<void> setCdmaSubscriptionSource(int32_t serial,
278 CdmaSubscriptionSource cdmaSub);
280 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
282 Return<void> getCdmaRoamingPreference(int32_t serial);
284 Return<void> setTTYMode(int32_t serial, TtyMode mode);
286 Return<void> getTTYMode(int32_t serial);
288 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
290 Return<void> getPreferredVoicePrivacy(int32_t serial);
292 Return<void> sendCDMAFeatureCode(int32_t serial,
293 const ::android::hardware::hidl_string& featureCode);
295 Return<void> sendBurstDtmf(int32_t serial,
296 const ::android::hardware::hidl_string& dtmf,
300 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
302 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
303 const CdmaSmsAck& smsAck);
305 Return<void> getGsmBroadcastConfig(int32_t serial);
307 Return<void> setGsmBroadcastConfig(int32_t serial,
308 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
310 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
312 Return<void> getCdmaBroadcastConfig(int32_t serial);
314 Return<void> setCdmaBroadcastConfig(int32_t serial,
315 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
317 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
319 Return<void> getCDMASubscription(int32_t serial);
321 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
323 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
325 Return<void> getDeviceIdentity(int32_t serial);
327 Return<void> exitEmergencyCallbackMode(int32_t serial);
329 Return<void> getSmscAddress(int32_t serial);
331 Return<void> setSmscAddress(int32_t serial,
332 const ::android::hardware::hidl_string& smsc);
334 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
336 Return<void> reportStkServiceIsRunning(int32_t serial);
338 Return<void> getCdmaSubscriptionSource(int32_t serial);
340 Return<void> requestIsimAuthentication(int32_t serial,
341 const ::android::hardware::hidl_string& challenge);
343 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
345 const ::android::hardware::hidl_string& ackPdu);
347 Return<void> sendEnvelopeWithStatus(int32_t serial,
348 const ::android::hardware::hidl_string& contents);
350 Return<void> getVoiceRadioTechnology(int32_t serial);
352 Return<void> getCellInfoList(int32_t serial);
354 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
356 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
357 bool modemCognitive, bool isRoaming);
359 Return<void> getImsRegistrationState(int32_t serial);
361 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
363 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
365 Return<void> iccOpenLogicalChannel(int32_t serial,
366 const ::android::hardware::hidl_string& aid);
368 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
370 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
372 Return<void> nvReadItem(int32_t serial, NvItem itemId);
374 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
376 Return<void> nvWriteCdmaPrl(int32_t serial,
377 const ::android::hardware::hidl_vec<uint8_t>& prl);
379 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
381 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
383 Return<void> setDataAllowed(int32_t serial, bool allow);
385 Return<void> getHardwareConfig(int32_t serial);
387 Return<void> requestIccSimAuthentication(int32_t serial,
389 const ::android::hardware::hidl_string& authData,
390 const ::android::hardware::hidl_string& aid);
392 Return<void> setDataProfile(int32_t serial,
393 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
395 Return<void> requestShutdown(int32_t serial);
397 Return<void> getRadioCapability(int32_t serial);
399 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
401 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
403 Return<void> stopLceService(int32_t serial);
405 Return<void> pullLceData(int32_t serial);
407 Return<void> getModemActivityInfo(int32_t serial);
409 Return<void> setAllowedCarriers(int32_t serial,
411 const CarrierRestrictions& carriers);
413 Return<void> getAllowedCarriers(int32_t serial);
415 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
417 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
419 Return<void> setSimCardPower(int32_t serial, bool powerUp);
421 Return<void> responseAcknowledgement();
423 void checkReturnStatus(Return<void>& ret);
426 struct OemHookImpl : public IOemHook {
428 sp<IOemHookResponse> mOemHookResponse;
429 sp<IOemHookIndication> mOemHookIndication;
431 Return<void> setResponseFunctions(
432 const ::android::sp<IOemHookResponse>& oemHookResponse,
433 const ::android::sp<IOemHookIndication>& oemHookIndication);
435 Return<void> sendRequestRaw(int32_t serial,
436 const ::android::hardware::hidl_vec<uint8_t>& data);
438 Return<void> sendRequestStrings(int32_t serial,
439 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
442 void memsetAndFreeStrings(int numPointers, ...) {
444 va_start(ap, numPointers);
445 for (int i = 0; i < numPointers; i++) {
446 char *ptr = va_arg(ap, char *);
449 // TODO: Should pass in the maximum length of the string
458 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
459 pRI->pCI->responseFunction((int) pRI->socket_id,
460 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
464 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
465 * request with error RIL_E_NO_MEMORY.
466 * Returns true on success, and false on failure.
468 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
469 size_t len = src.size();
474 *dest = (char *) calloc(len + 1, sizeof(char));
476 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
477 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
480 strncpy(*dest, src, len + 1);
484 hidl_string convertCharPtrToHidlString(const char *ptr) {
487 // TODO: replace this with strnlen
488 ret.setToExternal(ptr, strlen(ptr));
493 bool dispatchVoid(int serial, int slotId, int request) {
494 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
498 s_vendorFunctions->onRequest(request, NULL, 0, pRI);
502 bool dispatchString(int serial, int slotId, int request, const char * str) {
503 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
509 if (!copyHidlStringToRil(&pString, str, pRI)) {
513 s_vendorFunctions->onRequest(request, pString, sizeof(char *), pRI);
515 memsetAndFreeStrings(1, pString);
519 bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) {
520 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
526 pStrings = (char **)calloc(countStrings, sizeof(char *));
527 if (pStrings == NULL) {
528 RLOGE("Memory allocation failed for request %s", requestToString(request));
529 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
533 va_start(ap, countStrings);
534 for (int i = 0; i < countStrings; i++) {
535 const char* str = va_arg(ap, const char *);
536 if (!copyHidlStringToRil(&pStrings[i], str, pRI)) {
538 for (int j = 0; j < i; j++) {
539 memsetAndFreeStrings(1, pStrings[j]);
547 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
549 if (pStrings != NULL) {
550 for (int i = 0 ; i < countStrings ; i++) {
551 memsetAndFreeStrings(1, pStrings[i]);
555 memset(pStrings, 0, countStrings * sizeof(char *));
562 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
563 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
568 int countStrings = data.size();
570 pStrings = (char **)calloc(countStrings, sizeof(char *));
571 if (pStrings == NULL) {
572 RLOGE("Memory allocation failed for request %s", requestToString(request));
573 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
577 for (int i = 0; i < countStrings; i++) {
578 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
579 for (int j = 0; j < i; j++) {
580 memsetAndFreeStrings(1, pStrings[j]);
587 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
589 if (pStrings != NULL) {
590 for (int i = 0 ; i < countStrings ; i++) {
591 memsetAndFreeStrings(1, pStrings[i]);
595 memset(pStrings, 0, countStrings * sizeof(char *));
602 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
603 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
608 int *pInts = (int *)calloc(countInts, sizeof(int));
611 RLOGE("Memory allocation failed for request %s", requestToString(request));
612 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
616 va_start(ap, countInts);
617 for (int i = 0; i < countInts; i++) {
618 pInts[i] = va_arg(ap, int);
622 s_vendorFunctions->onRequest(request, pInts, countInts * sizeof(int), pRI);
626 memset(pInts, 0, countInts * sizeof(int));
633 bool dispatchCallForwardStatus(int serial, int slotId, int request,
634 const CallForwardInfo& callInfo) {
635 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
640 RIL_CallForwardInfo cf;
641 cf.status = (int) callInfo.status;
642 cf.reason = callInfo.reason;
643 cf.serviceClass = callInfo.serviceClass;
644 cf.toa = callInfo.toa;
645 cf.timeSeconds = callInfo.timeSeconds;
647 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
651 s_vendorFunctions->onRequest(request, &cf, sizeof(cf), pRI);
653 memsetAndFreeStrings(1, cf.number);
658 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
659 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
664 const uint8_t *uData = rawBytes.data();
666 s_vendorFunctions->onRequest(request, (void *) uData, rawBytes.size(), pRI);
671 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
672 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
678 memset (&apdu, 0, sizeof(RIL_SIM_APDU));
680 apdu.sessionid = message.sessionId;
681 apdu.cla = message.cla;
682 apdu.instruction = message.instruction;
683 apdu.p1 = message.p1;
684 apdu.p2 = message.p2;
685 apdu.p3 = message.p3;
687 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
691 s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI);
693 memsetAndFreeStrings(1, apdu.data);
698 void checkReturnStatus(int32_t slotId, Return<void>& ret) {
699 if (ret.isOk() == false) {
700 RLOGE("checkReturnStatus: unable to call response/indication callback");
701 // Remote process hosting the callbacks must be dead. Reset the callback objects;
702 // there's no other recovery to be done here. When the client process is back up, it will
703 // call setResponseFunctions()
705 // Caller should already hold rdlock, release that first
706 // note the current counter to avoid overwriting updates made by another thread before
707 // write lock is acquired.
708 int counter = mCounter[slotId];
709 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
710 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
714 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
717 // make sure the counter value has not changed
718 if (counter == mCounter[slotId]) {
719 radioService[slotId]->mRadioResponse = NULL;
720 radioService[slotId]->mRadioIndication = NULL;
721 oemHookService[slotId]->mOemHookResponse = NULL;
722 oemHookService[slotId]->mOemHookIndication = NULL;
725 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
726 "got updated on another thread");
730 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
734 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
739 void RadioImpl::checkReturnStatus(Return<void>& ret) {
740 ::checkReturnStatus(mSlotId, ret);
743 Return<void> RadioImpl::setResponseFunctions(
744 const ::android::sp<IRadioResponse>& radioResponseParam,
745 const ::android::sp<IRadioIndication>& radioIndicationParam) {
746 RLOGD("setResponseFunctions");
748 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
749 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
752 mRadioResponse = radioResponseParam;
753 mRadioIndication = radioIndicationParam;
756 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
762 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
763 RLOGD("getIccCardStatus: serial %d", serial);
764 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
768 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
769 const hidl_string& aid) {
770 RLOGD("supplyIccPinForApp: serial %d", serial);
771 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
772 2, (const char *)pin, (const char *)aid);
776 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
777 const hidl_string& pin, const hidl_string& aid) {
778 RLOGD("supplyIccPukForApp: serial %d", serial);
779 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
780 3, (const char *)puk, (const char *)pin, (const char *)aid);
784 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
785 const hidl_string& aid) {
786 RLOGD("supplyIccPin2ForApp: serial %d", serial);
787 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
788 2, (const char *)pin2, (const char *)aid);
792 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
793 const hidl_string& pin2, const hidl_string& aid) {
794 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
795 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
796 3, (const char *)puk2, (const char *)pin2, (const char *)aid);
800 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
801 const hidl_string& newPin, const hidl_string& aid) {
802 RLOGD("changeIccPinForApp: serial %d", serial);
803 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
804 3, (const char *)oldPin, (const char *)newPin, (const char *)aid);
808 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
809 const hidl_string& newPin2, const hidl_string& aid) {
810 RLOGD("changeIccPin2ForApp: serial %d", serial);
811 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
812 3, (const char *)oldPin2, (const char *)newPin2, (const char *)aid);
816 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
817 const hidl_string& netPin) {
818 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
819 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
820 1, (const char *)netPin);
824 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
825 RLOGD("getCurrentCalls: serial %d", serial);
826 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
830 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
831 RLOGD("dial: serial %d", serial);
832 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
837 RIL_UUS_Info uusInfo = {};
838 int32_t sizeOfDial = sizeof(dial);
840 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
843 dial.clir = (int) dialInfo.clir;
845 if (dialInfo.uusInfo.size() != 0) {
846 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
847 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
849 if (dialInfo.uusInfo[0].uusData.size() == 0) {
850 uusInfo.uusData = NULL;
851 uusInfo.uusLength = 0;
853 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
854 memsetAndFreeStrings(1, dial.address);
857 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
860 dial.uusInfo = &uusInfo;
863 s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI);
865 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
870 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
871 RLOGD("getImsiForApp: serial %d", serial);
872 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
873 1, (const char *) aid);
877 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
878 RLOGD("hangup: serial %d", serial);
879 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
883 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
884 RLOGD("hangupWaitingOrBackground: serial %d", serial);
885 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
889 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
890 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
891 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
895 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
896 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
897 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
901 Return<void> RadioImpl::conference(int32_t serial) {
902 RLOGD("conference: serial %d", serial);
903 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
907 Return<void> RadioImpl::rejectCall(int32_t serial) {
908 RLOGD("rejectCall: serial %d", serial);
909 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
913 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
914 RLOGD("getLastCallFailCause: serial %d", serial);
915 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
919 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
920 RLOGD("getSignalStrength: serial %d", serial);
921 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
925 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
926 RLOGD("getVoiceRegistrationState: serial %d", serial);
927 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
931 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
932 RLOGD("getDataRegistrationState: serial %d", serial);
933 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
937 Return<void> RadioImpl::getOperator(int32_t serial) {
938 RLOGD("getOperator: serial %d", serial);
939 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
943 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
944 RLOGD("setRadioPower: serial %d on %d", serial, on);
945 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
949 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
950 RLOGD("sendDtmf: serial %d", serial);
951 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, (const char *) s);
955 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
956 RLOGD("sendSms: serial %d", serial);
957 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
958 2, (const char *) message.smscPdu, (const char *) message.pdu);
962 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
963 RLOGD("sendSMSExpectMore: serial %d", serial);
964 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
965 2, (const char *) message.smscPdu, (const char *) message.pdu);
969 const char *convertMvnoTypeToString(MvnoType type) {
971 case MvnoType::IMSI: return "imsi";
972 case MvnoType::GID: return "gid";
973 case MvnoType::SPN: return "spn";
974 default: return NULL;
978 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
979 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
980 bool roamingAllowed, bool isRoaming) {
982 RLOGD("setupDataCall: serial %d", serial);
984 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
985 const hidl_string &protocol =
986 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
987 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
988 std::to_string((int) radioTechnology + 2).c_str(),
989 std::to_string((int) dataProfileInfo.profileId).c_str(),
990 dataProfileInfo.apn.c_str(),
991 dataProfileInfo.user.c_str(),
992 dataProfileInfo.password.c_str(),
993 std::to_string((int) dataProfileInfo.authType).c_str(),
995 } else if (s_vendorFunctions->version >= 15) {
996 const char *mvnoTypeStr = convertMvnoTypeToString(dataProfileInfo.mvnoType);
997 if (mvnoTypeStr == NULL) {
998 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
999 RIL_REQUEST_SETUP_DATA_CALL);
1001 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1005 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1006 std::to_string((int) radioTechnology + 2).c_str(),
1007 std::to_string((int) dataProfileInfo.profileId).c_str(),
1008 dataProfileInfo.apn.c_str(),
1009 dataProfileInfo.user.c_str(),
1010 dataProfileInfo.password.c_str(),
1011 std::to_string((int) dataProfileInfo.authType).c_str(),
1012 dataProfileInfo.protocol.c_str(),
1013 dataProfileInfo.roamingProtocol.c_str(),
1014 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1015 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1016 BOOL_TO_INT(modemCognitive),
1017 std::to_string(dataProfileInfo.mtu).c_str(),
1019 dataProfileInfo.mvnoMatchData.c_str(),
1020 BOOL_TO_INT(roamingAllowed));
1022 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1023 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1024 RIL_REQUEST_SETUP_DATA_CALL);
1026 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1032 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1033 RLOGD("iccIOForApp: serial %d", serial);
1034 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1039 RIL_SIM_IO_v6 rilIccIo;
1040 rilIccIo.command = iccIo.command;
1041 rilIccIo.fileid = iccIo.fileId;
1042 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1046 rilIccIo.p1 = iccIo.p1;
1047 rilIccIo.p2 = iccIo.p2;
1048 rilIccIo.p3 = iccIo.p3;
1050 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1051 memsetAndFreeStrings(1, rilIccIo.path);
1055 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1056 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1060 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1061 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1065 s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI);
1067 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1072 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1073 RLOGD("sendUssd: serial %d", serial);
1074 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, (const char *) ussd);
1078 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1079 RLOGD("cancelPendingUssd: serial %d", serial);
1080 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1084 Return<void> RadioImpl::getClir(int32_t serial) {
1085 RLOGD("getClir: serial %d", serial);
1086 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1090 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1091 RLOGD("setClir: serial %d", serial);
1092 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1096 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1097 RLOGD("getCallForwardStatus: serial %d", serial);
1098 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1103 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1104 RLOGD("setCallForward: serial %d", serial);
1105 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1110 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1111 RLOGD("getCallWaiting: serial %d", serial);
1112 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1116 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1117 RLOGD("setCallWaiting: serial %d", serial);
1118 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1123 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1124 bool success, SmsAcknowledgeFailCause cause) {
1125 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1126 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1131 Return<void> RadioImpl::acceptCall(int32_t serial) {
1132 RLOGD("acceptCall: serial %d", serial);
1133 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1137 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1138 int32_t cid, bool reasonRadioShutDown) {
1139 RLOGD("deactivateDataCall: serial %d", serial);
1140 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1141 2, (const char *) (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1145 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1146 const hidl_string& password, int32_t serviceClass,
1147 const hidl_string& appId) {
1148 RLOGD("getFacilityLockForApp: serial %d", serial);
1149 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1150 4, (const char *) facility, (const char *) password,
1151 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId);
1155 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1156 bool lockState, const hidl_string& password,
1157 int32_t serviceClass, const hidl_string& appId) {
1158 RLOGD("setFacilityLockForApp: serial %d", serial);
1159 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1160 5, (const char *) facility, lockState ? "1" : "0", (const char *) password,
1161 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId);
1165 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1166 const hidl_string& oldPassword,
1167 const hidl_string& newPassword) {
1168 RLOGD("setBarringPassword: serial %d", serial);
1169 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1170 2, (const char *) oldPassword, (const char *) newPassword);
1174 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1175 RLOGD("getNetworkSelectionMode: serial %d", serial);
1176 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1180 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1181 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1182 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1186 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1187 const hidl_string& operatorNumeric) {
1188 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1189 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1190 (const char *) operatorNumeric);
1194 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1195 RLOGD("getAvailableNetworks: serial %d", serial);
1196 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1200 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1201 RLOGD("startDtmf: serial %d", serial);
1202 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1207 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1208 RLOGD("stopDtmf: serial %d", serial);
1209 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1213 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1214 RLOGD("getBasebandVersion: serial %d", serial);
1215 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1219 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1220 RLOGD("separateConnection: serial %d", serial);
1221 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1225 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1226 RLOGD("setMute: serial %d", serial);
1227 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1231 Return<void> RadioImpl::getMute(int32_t serial) {
1232 RLOGD("getMute: serial %d", serial);
1233 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1237 Return<void> RadioImpl::getClip(int32_t serial) {
1238 RLOGD("getClip: serial %d", serial);
1239 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1243 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1244 RLOGD("getDataCallList: serial %d", serial);
1245 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1249 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1250 RLOGD("setSuppServiceNotifications: serial %d", serial);
1251 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1252 BOOL_TO_INT(enable));
1256 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1257 RLOGD("writeSmsToSim: serial %d", serial);
1258 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1263 RIL_SMS_WriteArgs args;
1264 args.status = (int) smsWriteArgs.status;
1267 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1271 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1272 memsetAndFreeStrings(1, args.pdu);
1276 s_vendorFunctions->onRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI);
1278 memsetAndFreeStrings(2, args.smsc, args.pdu);
1283 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1284 RLOGD("deleteSmsOnSim: serial %d", serial);
1285 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1289 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1290 RLOGD("setBandMode: serial %d", serial);
1291 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1295 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1296 RLOGD("getAvailableBandModes: serial %d", serial);
1297 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1301 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1302 RLOGD("sendEnvelope: serial %d", serial);
1303 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1304 (const char *) command);
1308 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1309 const hidl_string& commandResponse) {
1310 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1311 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1312 (const char *) commandResponse);
1316 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1317 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1318 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1319 1, BOOL_TO_INT(accept));
1323 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1324 RLOGD("explicitCallTransfer: serial %d", serial);
1325 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1329 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1330 RLOGD("setPreferredNetworkType: serial %d", serial);
1331 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1335 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1336 RLOGD("getPreferredNetworkType: serial %d", serial);
1337 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1341 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1342 RLOGD("getNeighboringCids: serial %d", serial);
1343 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1347 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1348 RLOGD("setLocationUpdates: serial %d", serial);
1349 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1353 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1354 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1355 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1359 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1360 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1361 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1365 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1366 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1367 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1371 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1372 RLOGD("setTTYMode: serial %d", serial);
1373 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1377 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1378 RLOGD("getTTYMode: serial %d", serial);
1379 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1383 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1384 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1385 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1386 1, BOOL_TO_INT(enable));
1390 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1391 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1392 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1396 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1397 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1398 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1399 (const char *) featureCode);
1403 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1405 RLOGD("sendBurstDtmf: serial %d", serial);
1406 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1407 3, (const char *) dtmf, (const char *) (std::to_string(on)).c_str(),
1408 (const char *) (std::to_string(off)).c_str());
1412 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1413 memset(&rcsm, 0, sizeof(rcsm));
1415 rcsm.uTeleserviceID = sms.teleserviceId;
1416 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1417 rcsm.uServicecategory = sms.serviceCategory;
1418 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1419 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1420 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1421 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1423 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1424 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1425 for (int i = 0; i < digitLimit; i++) {
1426 rcsm.sAddress.digits[i] = sms.address.digits[i];
1429 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1430 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1432 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1433 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1434 for (int i = 0; i < digitLimit; i++) {
1435 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1438 rcsm.uBearerDataLen = sms.bearerData.size();
1439 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1440 for (int i = 0; i < digitLimit; i++) {
1441 rcsm.aBearerData[i] = sms.bearerData[i];
1445 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1446 RLOGD("sendCdmaSms: serial %d", serial);
1447 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1452 RIL_CDMA_SMS_Message rcsm;
1453 constructCdmaSms(rcsm, sms);
1455 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI);
1459 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1460 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1461 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1466 RIL_CDMA_SMS_Ack rcsa = {};
1468 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1469 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1471 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI);
1475 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1476 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1477 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1481 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1482 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1484 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1485 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1486 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1491 int num = configInfo.size();
1492 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1493 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1495 for (int i = 0 ; i < num ; i++ ) {
1496 gsmBciPtrs[i] = &gsmBci[i];
1497 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1498 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1499 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1500 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1501 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1504 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, gsmBciPtrs,
1505 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI);
1509 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1510 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1511 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1512 1, BOOL_TO_INT(!activate));
1516 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1517 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1518 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1522 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1523 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1525 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1526 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1527 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1532 int num = configInfo.size();
1533 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1534 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1536 for (int i = 0 ; i < num ; i++ ) {
1537 cdmaBciPtrs[i] = &cdmaBci[i];
1538 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1539 cdmaBci[i].language = configInfo[i].language;
1540 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1543 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, cdmaBciPtrs,
1544 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI);
1548 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1549 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1550 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1551 1, BOOL_TO_INT(!activate));
1555 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1556 RLOGD("getCDMASubscription: serial %d", serial);
1557 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1561 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1562 RLOGD("writeSmsToRuim: serial %d", serial);
1563 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1564 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1569 RIL_CDMA_SMS_WriteArgs rcsw = {};
1570 rcsw.status = (int) cdmaSms.status;
1571 constructCdmaSms(rcsw.message, cdmaSms.message);
1573 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI);
1577 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1578 RLOGD("deleteSmsOnRuim: serial %d", serial);
1579 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1583 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1584 RLOGD("getDeviceIdentity: serial %d", serial);
1585 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1589 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1590 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1591 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1595 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1596 RLOGD("getSmscAddress: serial %d", serial);
1597 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1601 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1602 RLOGD("setSmscAddress: serial %d", serial);
1603 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1604 (const char *) smsc);
1608 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1609 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1610 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1611 BOOL_TO_INT(available));
1615 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1616 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1617 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1621 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1622 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1623 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1627 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1628 RLOGD("requestIsimAuthentication: serial %d", serial);
1629 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1630 (const char *) challenge);
1634 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1635 const hidl_string& ackPdu) {
1636 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1637 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1638 2, success ? "1" : "0", (const char *) ackPdu);
1642 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1643 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1644 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1645 (const char *) contents);
1649 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1650 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1651 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1655 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1656 RLOGD("getCellInfoList: serial %d", serial);
1657 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1661 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1662 RLOGD("setCellInfoListRate: serial %d", serial);
1663 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1667 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1668 bool modemCognitive, bool isRoaming) {
1669 RLOGD("setInitialAttachApn: serial %d", serial);
1670 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1671 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
1676 if (s_vendorFunctions->version <= 14) {
1677 RIL_InitialAttachApn iaa = {};
1679 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1683 const hidl_string &protocol =
1684 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1686 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
1689 iaa.authtype = (int) dataProfileInfo.authType;
1690 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1693 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1697 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1699 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
1701 RIL_InitialAttachApn_v15 iaa = {};
1703 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1706 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
1709 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
1712 iaa.authtype = (int) dataProfileInfo.authType;
1713 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1716 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1719 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
1720 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
1721 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
1722 iaa.mtu = dataProfileInfo.mtu;
1724 // Note that there is no need for memory allocation/free.
1725 iaa.mvnoType = (char *) convertMvnoTypeToString(dataProfileInfo.mvnoType);
1726 if (iaa.mvnoType == NULL) {
1727 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1731 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
1735 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1737 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1738 iaa.password, iaa.mvnoMatchData);
1744 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
1745 RLOGD("getImsRegistrationState: serial %d", serial);
1746 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
1750 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
1751 RIL_IMS_SMS_Message rism = {};
1753 int countStrings = 2;
1754 int dataLen = sizeof(char *) * countStrings;
1756 rism.tech = RADIO_TECH_3GPP;
1757 rism.retry = BOOL_TO_INT(message.retry);
1758 rism.messageRef = message.messageRef;
1760 if (message.gsmMessage.size() != 1) {
1761 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
1762 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1766 pStrings = (char **)calloc(countStrings, sizeof(char *));
1767 if (pStrings == NULL) {
1768 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
1769 requestToString(pRI->pCI->requestNumber));
1770 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1774 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
1776 memset(pStrings, 0, datalen);
1782 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
1783 memsetAndFreeStrings(1, pStrings[0]);
1785 memset(pStrings, 0, datalen);
1791 rism.message.gsmMessage = pStrings;
1792 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
1793 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI);
1795 for (int i = 0 ; i < countStrings ; i++) {
1796 memsetAndFreeStrings(1, pStrings[i]);
1800 memset(pStrings, 0, datalen);
1807 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
1808 RIL_IMS_SMS_Message rism;
1809 RIL_CDMA_SMS_Message rcsm;
1811 if (message.cdmaMessage.size() != 1) {
1812 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
1813 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1817 rism.tech = RADIO_TECH_3GPP2;
1818 rism.retry = BOOL_TO_INT(message.retry);
1819 rism.messageRef = message.messageRef;
1820 rism.message.cdmaMessage = &rcsm;
1822 constructCdmaSms(rcsm, message.cdmaMessage[0]);
1824 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
1825 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI);
1830 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
1831 RLOGD("sendImsSms: serial %d", serial);
1832 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
1837 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
1839 if (RADIO_TECH_3GPP == format) {
1840 dispatchImsGsmSms(message, pRI);
1841 } else if (RADIO_TECH_3GPP2 == format) {
1842 dispatchImsCdmaSms(message, pRI);
1844 RLOGE("sendImsSms: Invalid radio tech %s",
1845 requestToString(pRI->pCI->requestNumber));
1846 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1851 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
1852 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
1853 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
1857 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid) {
1858 RLOGD("iccOpenLogicalChannel: serial %d", serial);
1859 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL,
1860 (const char *) aid);
1864 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
1865 RLOGD("iccCloseLogicalChannel: serial %d", serial);
1866 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
1870 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
1871 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
1872 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
1876 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
1877 RLOGD("nvReadItem: serial %d", serial);
1878 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
1883 RIL_NV_ReadItem nvri;
1884 memset (&nvri, 0, sizeof(nvri));
1885 nvri.itemID = (RIL_NV_Item) itemId;
1887 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI);
1891 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
1892 RLOGD("nvWriteItem: serial %d", serial);
1893 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
1898 RIL_NV_WriteItem nvwi;
1899 memset (&nvwi, 0, sizeof(nvwi));
1901 nvwi.itemID = (RIL_NV_Item) item.itemId;
1903 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
1907 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI);
1909 memsetAndFreeStrings(1, nvwi.value);
1913 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
1914 RLOGD("nvWriteCdmaPrl: serial %d", serial);
1915 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
1919 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
1920 RLOGD("nvResetConfig: serial %d", serial);
1921 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, (int) resetType);
1925 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
1926 RLOGD("setUiccSubscription: serial %d", serial);
1927 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1928 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
1933 RIL_SelectUiccSub rilUiccSub = {};
1935 rilUiccSub.slot = uiccSub.slot;
1936 rilUiccSub.app_index = uiccSub.appIndex;
1937 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
1938 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
1940 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI);
1944 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
1945 RLOGD("setDataAllowed: serial %d", serial);
1946 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
1950 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
1951 RLOGD("getHardwareConfig: serial %d", serial);
1952 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
1956 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
1957 const hidl_string& authData, const hidl_string& aid) {
1958 RLOGD("requestIccSimAuthentication: serial %d", serial);
1959 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
1964 RIL_SimAuthentication pf;
1965 memset (&pf, 0, sizeof(pf));
1967 pf.authContext = authContext;
1970 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
1974 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
1975 memsetAndFreeStrings(1, pf.authData);
1979 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI);
1981 memsetAndFreeStrings(2, pf.authData, pf.aid);
1986 * @param numProfiles number of data profile
1987 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
1988 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
1989 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
1990 * @param numfields number of string-type member in the data profile structure
1991 * @param ... the variadic parameters are pointers to each string-type member
1993 template <typename T>
1994 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
1995 int numfields, ...) {
1997 va_start(args, numfields);
1999 // Iterate through each string-type field that need to be free.
2000 for (int i = 0; i < numfields; i++) {
2001 // Iterate through each data profile and free that specific string-type field.
2002 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2003 char *T::*ptr = va_arg(args, char *T::*);
2004 for (int j = 0; j < numProfiles; j++) {
2005 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2012 memset(dataProfiles, 0, numProfiles * sizeof(T));
2013 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2016 free(dataProfilePtrs);
2019 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2021 RLOGD("setDataProfile: serial %d", serial);
2022 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2027 size_t num = profiles.size();
2028 bool success = false;
2030 if (s_vendorFunctions->version <= 14) {
2032 RIL_DataProfileInfo *dataProfiles =
2033 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2035 if (dataProfiles == NULL) {
2036 RLOGE("Memory allocation failed for request %s",
2037 requestToString(pRI->pCI->requestNumber));
2038 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2042 RIL_DataProfileInfo **dataProfilePtrs =
2043 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2044 if (dataProfilePtrs == NULL) {
2045 RLOGE("Memory allocation failed for request %s",
2046 requestToString(pRI->pCI->requestNumber));
2048 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2052 for (size_t i = 0; i < num; i++) {
2053 dataProfilePtrs[i] = &dataProfiles[i];
2055 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2057 const hidl_string &protocol =
2058 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2060 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2064 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2067 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2073 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2074 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2075 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2079 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2080 dataProfiles[i].authType = (int) profiles[i].authType;
2081 dataProfiles[i].type = (int) profiles[i].type;
2082 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2083 dataProfiles[i].maxConns = profiles[i].maxConns;
2084 dataProfiles[i].waitTime = profiles[i].waitTime;
2085 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2088 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2089 num * sizeof(RIL_DataProfileInfo *), pRI);
2091 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2092 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2093 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2095 RIL_DataProfileInfo_v15 *dataProfiles =
2096 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2098 if (dataProfiles == NULL) {
2099 RLOGE("Memory allocation failed for request %s",
2100 requestToString(pRI->pCI->requestNumber));
2101 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2105 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2106 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2107 if (dataProfilePtrs == NULL) {
2108 RLOGE("Memory allocation failed for request %s",
2109 requestToString(pRI->pCI->requestNumber));
2111 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2115 for (size_t i = 0; i < num; i++) {
2116 dataProfilePtrs[i] = &dataProfiles[i];
2118 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2119 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2123 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2124 profiles[i].roamingProtocol, pRI)) {
2127 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2130 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2135 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2136 profiles[i].mvnoMatchData, pRI)) {
2141 dataProfiles[i].mvnoType = (char *) convertMvnoTypeToString(profiles[i].mvnoType);
2142 if (dataProfiles[i].mvnoType == NULL) {
2143 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2149 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2150 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2151 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2152 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2156 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2157 dataProfiles[i].authType = (int) profiles[i].authType;
2158 dataProfiles[i].type = (int) profiles[i].type;
2159 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2160 dataProfiles[i].maxConns = profiles[i].maxConns;
2161 dataProfiles[i].waitTime = profiles[i].waitTime;
2162 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2163 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2164 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2165 dataProfiles[i].mtu = profiles[i].mtu;
2168 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2169 num * sizeof(RIL_DataProfileInfo_v15 *), pRI);
2171 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2172 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2173 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2174 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2180 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2181 RLOGD("requestShutdown: serial %d", serial);
2182 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2186 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2187 RLOGD("getRadioCapability: serial %d", serial);
2188 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2192 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2193 RLOGD("setRadioCapability: serial %d", serial);
2194 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2199 RIL_RadioCapability rilRc;
2200 memset (&rilRc, 0, sizeof(rilRc));
2202 // TODO : set rilRc.version using HIDL version ?
2203 rilRc.session = rc.session;
2204 rilRc.phase = (int) rc.phase;
2205 rilRc.rat = (int) rc.raf;
2206 rilRc.status = (int) rc.status;
2207 strncpy(rilRc.logicalModemUuid, (const char *) rc.logicalModemUuid, MAX_UUID_LENGTH);
2209 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI);
2214 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2215 RLOGD("startLceService: serial %d", serial);
2216 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2217 BOOL_TO_INT(pullMode));
2221 Return<void> RadioImpl::stopLceService(int32_t serial) {
2222 RLOGD("stopLceService: serial %d", serial);
2223 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2227 Return<void> RadioImpl::pullLceData(int32_t serial) {
2228 RLOGD("pullLceData: serial %d", serial);
2229 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2233 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2234 RLOGD("getModemActivityInfo: serial %d", serial);
2235 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2239 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2240 const CarrierRestrictions& carriers) {
2241 RLOGD("setAllowedCarriers: serial %d", serial);
2242 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2243 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2248 RIL_CarrierRestrictions cr = {};
2249 RIL_Carrier *allowedCarriers = NULL;
2250 RIL_Carrier *excludedCarriers = NULL;
2252 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2253 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2254 if (allowedCarriers == NULL) {
2255 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2256 requestToString(pRI->pCI->requestNumber));
2257 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2260 cr.allowed_carriers = allowedCarriers;
2262 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2263 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2264 if (excludedCarriers == NULL) {
2265 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2266 requestToString(pRI->pCI->requestNumber));
2267 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2269 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2271 free(allowedCarriers);
2274 cr.excluded_carriers = excludedCarriers;
2276 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2277 allowedCarriers[i].mcc = (const char *) carriers.allowedCarriers[i].mcc;
2278 allowedCarriers[i].mnc = (const char *) carriers.allowedCarriers[i].mnc;
2279 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2280 allowedCarriers[i].match_data = (const char *) carriers.allowedCarriers[i].matchData;
2283 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2284 excludedCarriers[i].mcc = (const char *) carriers.excludedCarriers[i].mcc;
2285 excludedCarriers[i].mnc = (const char *) carriers.excludedCarriers[i].mnc;
2286 excludedCarriers[i].match_type =
2287 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2288 excludedCarriers[i].match_data = (const char *) carriers.excludedCarriers[i].matchData;
2291 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI);
2294 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2295 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2297 free(allowedCarriers);
2298 free(excludedCarriers);
2302 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2303 RLOGD("getAllowedCarriers: serial %d", serial);
2304 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2308 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2310 RLOGD("sendDeviceState: serial %d", serial);
2311 if (s_vendorFunctions->version < 15) {
2312 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2313 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2314 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2316 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2317 RIL_REQUEST_SEND_DEVICE_STATE);
2318 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2322 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2323 BOOL_TO_INT(state));
2327 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2328 RLOGD("setIndicationFilter: serial %d", serial);
2329 if (s_vendorFunctions->version < 15) {
2330 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2331 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2332 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2335 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2339 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2340 RLOGD("setSimCardPower: serial %d", serial);
2341 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2345 Return<void> RadioImpl::responseAcknowledgement() {
2346 android::releaseWakeLock();
2350 Return<void> OemHookImpl::setResponseFunctions(
2351 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2352 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2353 RLOGD("OemHookImpl::setResponseFunctions");
2355 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2356 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2359 mOemHookResponse = oemHookResponseParam;
2360 mOemHookIndication = oemHookIndicationParam;
2361 mCounter[mSlotId]++;
2363 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2369 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2370 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2371 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2375 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2376 const hidl_vec<hidl_string>& data) {
2377 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2378 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2382 /***************************************************************************************************
2383 * RESPONSE FUNCTIONS
2384 * Functions above are used for requests going from framework to vendor code. The ones below are
2385 * responses for those requests coming back from the vendor code.
2386 **************************************************************************************************/
2388 void radio::acknowledgeRequest(int slotId, int serial) {
2389 if (radioService[slotId]->mRadioResponse != NULL) {
2390 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2391 radioService[slotId]->checkReturnStatus(retStatus);
2393 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2397 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2399 responseInfo.serial = serial;
2400 switch (responseType) {
2401 case RESPONSE_SOLICITED:
2402 responseInfo.type = RadioResponseType::SOLICITED;
2404 case RESPONSE_SOLICITED_ACK_EXP:
2405 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2408 responseInfo.error = (RadioError) e;
2411 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2412 void *response, size_t responseLen) {
2413 populateResponseInfo(responseInfo, serial, responseType, e);
2416 if (response == NULL || responseLen != sizeof(int)) {
2417 RLOGE("responseInt: Invalid response");
2418 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2420 int *p_int = (int *) response;
2426 int radio::getIccCardStatusResponse(int slotId,
2427 int responseType, int serial, RIL_Errno e,
2428 void *response, size_t responseLen) {
2429 if (radioService[slotId]->mRadioResponse != NULL) {
2430 RadioResponseInfo responseInfo = {};
2431 populateResponseInfo(responseInfo, serial, responseType, e);
2432 CardStatus cardStatus = {};
2433 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2434 RLOGE("getIccCardStatusResponse: Invalid response");
2435 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2437 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2438 cardStatus.cardState = (CardState) p_cur->card_state;
2439 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2440 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2441 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2442 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2444 RIL_AppStatus *rilAppStatus = p_cur->applications;
2445 cardStatus.applications.resize(p_cur->num_applications);
2446 AppStatus *appStatus = cardStatus.applications.data();
2447 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2448 for (int i = 0; i < p_cur->num_applications; i++) {
2449 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2450 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2451 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2452 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2453 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2454 rilAppStatus[i].app_label_ptr);
2455 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2456 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2457 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2461 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2462 getIccCardStatusResponse(responseInfo, cardStatus);
2463 radioService[slotId]->checkReturnStatus(retStatus);
2465 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2471 int radio::supplyIccPinForAppResponse(int slotId,
2472 int responseType, int serial, RIL_Errno e,
2473 void *response, size_t responseLen) {
2474 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
2476 if (radioService[slotId]->mRadioResponse != NULL) {
2477 RadioResponseInfo responseInfo = {};
2478 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2479 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2480 supplyIccPinForAppResponse(responseInfo, ret);
2481 radioService[slotId]->checkReturnStatus(retStatus);
2483 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2490 int radio::supplyIccPukForAppResponse(int slotId,
2491 int responseType, int serial, RIL_Errno e,
2492 void *response, size_t responseLen) {
2493 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
2495 if (radioService[slotId]->mRadioResponse != NULL) {
2496 RadioResponseInfo responseInfo = {};
2497 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2498 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2500 radioService[slotId]->checkReturnStatus(retStatus);
2502 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2509 int radio::supplyIccPin2ForAppResponse(int slotId,
2510 int responseType, int serial, RIL_Errno e,
2511 void *response, size_t responseLen) {
2512 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
2514 if (radioService[slotId]->mRadioResponse != NULL) {
2515 RadioResponseInfo responseInfo = {};
2516 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2517 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2518 supplyIccPin2ForAppResponse(responseInfo, ret);
2519 radioService[slotId]->checkReturnStatus(retStatus);
2521 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2528 int radio::supplyIccPuk2ForAppResponse(int slotId,
2529 int responseType, int serial, RIL_Errno e,
2530 void *response, size_t responseLen) {
2531 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
2533 if (radioService[slotId]->mRadioResponse != NULL) {
2534 RadioResponseInfo responseInfo = {};
2535 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2536 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2537 supplyIccPuk2ForAppResponse(responseInfo, ret);
2538 radioService[slotId]->checkReturnStatus(retStatus);
2540 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2547 int radio::changeIccPinForAppResponse(int slotId,
2548 int responseType, int serial, RIL_Errno e,
2549 void *response, size_t responseLen) {
2550 RLOGD("changeIccPinForAppResponse: serial %d", serial);
2552 if (radioService[slotId]->mRadioResponse != NULL) {
2553 RadioResponseInfo responseInfo = {};
2554 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2555 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2556 changeIccPinForAppResponse(responseInfo, ret);
2557 radioService[slotId]->checkReturnStatus(retStatus);
2559 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2566 int radio::changeIccPin2ForAppResponse(int slotId,
2567 int responseType, int serial, RIL_Errno e,
2568 void *response, size_t responseLen) {
2569 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
2571 if (radioService[slotId]->mRadioResponse != NULL) {
2572 RadioResponseInfo responseInfo = {};
2573 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2574 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2575 changeIccPin2ForAppResponse(responseInfo, ret);
2576 radioService[slotId]->checkReturnStatus(retStatus);
2578 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2585 int radio::supplyNetworkDepersonalizationResponse(int slotId,
2586 int responseType, int serial, RIL_Errno e,
2587 void *response, size_t responseLen) {
2588 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
2590 if (radioService[slotId]->mRadioResponse != NULL) {
2591 RadioResponseInfo responseInfo = {};
2592 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2593 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2594 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2595 radioService[slotId]->checkReturnStatus(retStatus);
2597 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
2604 int radio::getCurrentCallsResponse(int slotId,
2605 int responseType, int serial, RIL_Errno e,
2606 void *response, size_t responseLen) {
2607 RLOGD("getCurrentCallsResponse: serial %d", serial);
2609 if (radioService[slotId]->mRadioResponse != NULL) {
2610 RadioResponseInfo responseInfo = {};
2611 populateResponseInfo(responseInfo, serial, responseType, e);
2613 hidl_vec<Call> calls;
2614 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) {
2615 RLOGE("getCurrentCallsResponse: Invalid response");
2616 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2618 int num = responseLen / sizeof(RIL_Call *);
2621 for (int i = 0 ; i < num ; i++) {
2622 RIL_Call *p_cur = ((RIL_Call **) response)[i];
2623 /* each call info */
2624 calls[i].state = (CallState) p_cur->state;
2625 calls[i].index = p_cur->index;
2626 calls[i].toa = p_cur->toa;
2627 calls[i].isMpty = p_cur->isMpty;
2628 calls[i].isMT = p_cur->isMT;
2629 calls[i].als = p_cur->als;
2630 calls[i].isVoice = p_cur->isVoice;
2631 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
2632 calls[i].number = convertCharPtrToHidlString(p_cur->number);
2633 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
2634 calls[i].name = convertCharPtrToHidlString(p_cur->name);
2635 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
2636 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
2637 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
2638 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
2639 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
2640 // convert uusInfo->uusData to a null-terminated string
2641 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
2642 calls[i].uusInfo[0].uusData = nullTermStr;
2648 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2649 getCurrentCallsResponse(responseInfo, calls);
2650 radioService[slotId]->checkReturnStatus(retStatus);
2652 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2658 int radio::dialResponse(int slotId,
2659 int responseType, int serial, RIL_Errno e, void *response,
2660 size_t responseLen) {
2661 RLOGD("dialResponse: serial %d", serial);
2663 if (radioService[slotId]->mRadioResponse != NULL) {
2664 RadioResponseInfo responseInfo = {};
2665 populateResponseInfo(responseInfo, serial, responseType, e);
2666 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
2667 radioService[slotId]->checkReturnStatus(retStatus);
2669 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2675 int radio::getIMSIForAppResponse(int slotId,
2676 int responseType, int serial, RIL_Errno e, void *response,
2677 size_t responseLen) {
2678 RLOGD("getIMSIForAppResponse: serial %d", serial);
2680 if (radioService[slotId]->mRadioResponse != NULL) {
2681 RadioResponseInfo responseInfo = {};
2682 populateResponseInfo(responseInfo, serial, responseType, e);
2683 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
2684 responseInfo, convertCharPtrToHidlString((char *) response));
2685 radioService[slotId]->checkReturnStatus(retStatus);
2687 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
2694 int radio::hangupConnectionResponse(int slotId,
2695 int responseType, int serial, RIL_Errno e,
2696 void *response, size_t responseLen) {
2697 RLOGD("hangupConnectionResponse: serial %d", serial);
2699 if (radioService[slotId]->mRadioResponse != NULL) {
2700 RadioResponseInfo responseInfo = {};
2701 populateResponseInfo(responseInfo, serial, responseType, e);
2702 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
2704 radioService[slotId]->checkReturnStatus(retStatus);
2706 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
2713 int radio::hangupWaitingOrBackgroundResponse(int slotId,
2714 int responseType, int serial, RIL_Errno e,
2715 void *response, size_t responseLen) {
2716 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
2718 if (radioService[slotId]->mRadioResponse != NULL) {
2719 RadioResponseInfo responseInfo = {};
2720 populateResponseInfo(responseInfo, serial, responseType, e);
2721 Return<void> retStatus =
2722 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
2724 radioService[slotId]->checkReturnStatus(retStatus);
2726 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
2733 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
2734 RIL_Errno e, void *response,
2735 size_t responseLen) {
2736 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
2738 if (radioService[slotId]->mRadioResponse != NULL) {
2739 RadioResponseInfo responseInfo = {};
2740 populateResponseInfo(responseInfo, serial, responseType, e);
2741 Return<void> retStatus =
2742 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
2744 radioService[slotId]->checkReturnStatus(retStatus);
2746 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
2753 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
2754 RIL_Errno e, void *response,
2755 size_t responseLen) {
2756 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
2758 if (radioService[slotId]->mRadioResponse != NULL) {
2759 RadioResponseInfo responseInfo = {};
2760 populateResponseInfo(responseInfo, serial, responseType, e);
2761 Return<void> retStatus =
2762 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
2764 radioService[slotId]->checkReturnStatus(retStatus);
2766 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
2773 int radio::conferenceResponse(int slotId, int responseType,
2774 int serial, RIL_Errno e, void *response, size_t responseLen) {
2775 RLOGD("conferenceResponse: serial %d", serial);
2777 if (radioService[slotId]->mRadioResponse != NULL) {
2778 RadioResponseInfo responseInfo = {};
2779 populateResponseInfo(responseInfo, serial, responseType, e);
2780 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
2782 radioService[slotId]->checkReturnStatus(retStatus);
2784 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
2791 int radio::rejectCallResponse(int slotId, int responseType,
2792 int serial, RIL_Errno e, void *response, size_t responseLen) {
2793 RLOGD("rejectCallResponse: serial %d", serial);
2795 if (radioService[slotId]->mRadioResponse != NULL) {
2796 RadioResponseInfo responseInfo = {};
2797 populateResponseInfo(responseInfo, serial, responseType, e);
2798 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
2800 radioService[slotId]->checkReturnStatus(retStatus);
2802 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
2809 int radio::getLastCallFailCauseResponse(int slotId,
2810 int responseType, int serial, RIL_Errno e, void *response,
2811 size_t responseLen) {
2812 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
2814 if (radioService[slotId]->mRadioResponse != NULL) {
2815 RadioResponseInfo responseInfo = {};
2816 populateResponseInfo(responseInfo, serial, responseType, e);
2818 LastCallFailCauseInfo info = {};
2819 info.vendorCause = hidl_string();
2820 if (response == NULL) {
2821 RLOGE("getCurrentCallsResponse Invalid response: NULL");
2822 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2823 } else if (responseLen == sizeof(int)) {
2824 int *pInt = (int *) response;
2825 info.causeCode = (LastCallFailCause) pInt[0];
2826 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
2827 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
2828 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
2829 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
2831 RLOGE("getCurrentCallsResponse Invalid response: NULL");
2832 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2835 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
2836 responseInfo, info);
2837 radioService[slotId]->checkReturnStatus(retStatus);
2839 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
2846 int radio::getSignalStrengthResponse(int slotId,
2847 int responseType, int serial, RIL_Errno e,
2848 void *response, size_t responseLen) {
2849 RLOGD("getSignalStrengthResponse: serial %d", serial);
2851 if (radioService[slotId]->mRadioResponse != NULL) {
2852 RadioResponseInfo responseInfo = {};
2853 populateResponseInfo(responseInfo, serial, responseType, e);
2854 SignalStrength signalStrength = {};
2855 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
2856 RLOGE("getSignalStrengthResponse: Invalid response");
2857 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2859 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
2862 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
2863 responseInfo, signalStrength);
2864 radioService[slotId]->checkReturnStatus(retStatus);
2866 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
2873 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
2875 return RIL_CELL_INFO_TYPE_NONE;
2878 int radioTech = atoi(rat);
2882 case RADIO_TECH_GPRS:
2883 case RADIO_TECH_EDGE:
2884 case RADIO_TECH_GSM: {
2885 return RIL_CELL_INFO_TYPE_GSM;
2888 case RADIO_TECH_UMTS:
2889 case RADIO_TECH_HSDPA:
2890 case RADIO_TECH_HSUPA:
2891 case RADIO_TECH_HSPA:
2892 case RADIO_TECH_HSPAP: {
2893 return RIL_CELL_INFO_TYPE_WCDMA;
2896 case RADIO_TECH_IS95A:
2897 case RADIO_TECH_IS95B:
2898 case RADIO_TECH_1xRTT:
2899 case RADIO_TECH_EVDO_0:
2900 case RADIO_TECH_EVDO_A:
2901 case RADIO_TECH_EVDO_B:
2902 case RADIO_TECH_EHRPD: {
2903 return RIL_CELL_INFO_TYPE_CDMA;
2906 case RADIO_TECH_LTE:
2907 case RADIO_TECH_LTE_CA: {
2908 return RIL_CELL_INFO_TYPE_LTE;
2911 case RADIO_TECH_TD_SCDMA: {
2912 return RIL_CELL_INFO_TYPE_TD_SCDMA;
2920 return RIL_CELL_INFO_TYPE_NONE;
2924 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
2926 cellIdentity.cellIdentityGsm.resize(0);
2927 cellIdentity.cellIdentityWcdma.resize(0);
2928 cellIdentity.cellIdentityCdma.resize(0);
2929 cellIdentity.cellIdentityTdscdma.resize(0);
2930 cellIdentity.cellIdentityLte.resize(0);
2931 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
2932 switch(rilCellIdentity.cellInfoType) {
2934 case RIL_CELL_INFO_TYPE_GSM: {
2935 cellIdentity.cellIdentityGsm.resize(1);
2936 cellIdentity.cellIdentityGsm[0].mcc =
2937 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
2938 cellIdentity.cellIdentityGsm[0].mnc =
2939 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
2940 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
2941 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
2942 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
2943 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
2947 case RIL_CELL_INFO_TYPE_WCDMA: {
2948 cellIdentity.cellIdentityWcdma.resize(1);
2949 cellIdentity.cellIdentityWcdma[0].mcc =
2950 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
2951 cellIdentity.cellIdentityWcdma[0].mnc =
2952 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
2953 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
2954 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
2955 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
2956 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
2960 case RIL_CELL_INFO_TYPE_CDMA: {
2961 cellIdentity.cellIdentityCdma.resize(1);
2962 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
2963 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
2964 cellIdentity.cellIdentityCdma[0].baseStationId =
2965 rilCellIdentity.cellIdentityCdma.basestationId;
2966 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
2967 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
2971 case RIL_CELL_INFO_TYPE_LTE: {
2972 cellIdentity.cellIdentityLte.resize(1);
2973 cellIdentity.cellIdentityLte[0].mcc =
2974 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
2975 cellIdentity.cellIdentityLte[0].mnc =
2976 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
2977 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
2978 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
2979 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
2980 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
2984 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
2985 cellIdentity.cellIdentityTdscdma.resize(1);
2986 cellIdentity.cellIdentityTdscdma[0].mcc =
2987 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
2988 cellIdentity.cellIdentityTdscdma[0].mnc =
2989 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
2990 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
2991 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
2992 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3002 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3003 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3004 return atoi(response[index]);
3010 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3011 int numStrings, char** response) {
3013 RIL_CellIdentity_v16 rilCellIdentity;
3014 int32_t *tmp = (int32_t*)&rilCellIdentity;
3016 for (size_t i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) {
3020 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3021 switch(rilCellIdentity.cellInfoType) {
3023 case RIL_CELL_INFO_TYPE_GSM: {
3024 rilCellIdentity.cellIdentityGsm.lac =
3025 convertResponseStringEntryToInt(response, 1, numStrings);
3026 rilCellIdentity.cellIdentityGsm.cid =
3027 convertResponseStringEntryToInt(response, 2, numStrings);
3031 case RIL_CELL_INFO_TYPE_WCDMA: {
3032 rilCellIdentity.cellIdentityWcdma.lac =
3033 convertResponseStringEntryToInt(response, 1, numStrings);
3034 rilCellIdentity.cellIdentityWcdma.cid =
3035 convertResponseStringEntryToInt(response, 2, numStrings);
3036 rilCellIdentity.cellIdentityWcdma.psc =
3037 convertResponseStringEntryToInt(response, 14, numStrings);
3041 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3042 rilCellIdentity.cellIdentityTdscdma.lac =
3043 convertResponseStringEntryToInt(response, 1, numStrings);
3044 rilCellIdentity.cellIdentityTdscdma.cid =
3045 convertResponseStringEntryToInt(response, 2, numStrings);
3049 case RIL_CELL_INFO_TYPE_CDMA:{
3050 rilCellIdentity.cellIdentityCdma.basestationId =
3051 convertResponseStringEntryToInt(response, 4, numStrings);
3052 rilCellIdentity.cellIdentityCdma.longitude =
3053 convertResponseStringEntryToInt(response, 5, numStrings);
3054 rilCellIdentity.cellIdentityCdma.latitude =
3055 convertResponseStringEntryToInt(response, 6, numStrings);
3056 rilCellIdentity.cellIdentityCdma.systemId =
3057 convertResponseStringEntryToInt(response, 8, numStrings);
3058 rilCellIdentity.cellIdentityCdma.networkId =
3059 convertResponseStringEntryToInt(response, 9, numStrings);
3063 case RIL_CELL_INFO_TYPE_LTE:{
3064 rilCellIdentity.cellIdentityLte.tac =
3065 convertResponseStringEntryToInt(response, 1, numStrings);
3066 rilCellIdentity.cellIdentityLte.ci =
3067 convertResponseStringEntryToInt(response, 2, numStrings);
3076 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3079 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3080 int numStrings, char** response) {
3082 RIL_CellIdentity_v16 rilCellIdentity;
3083 int32_t *tmp = (int32_t*)&rilCellIdentity;
3085 for (size_t i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) {
3089 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3090 switch(rilCellIdentity.cellInfoType) {
3091 case RIL_CELL_INFO_TYPE_GSM: {
3092 rilCellIdentity.cellIdentityGsm.lac =
3093 convertResponseStringEntryToInt(response, 1, numStrings);
3094 rilCellIdentity.cellIdentityGsm.cid =
3095 convertResponseStringEntryToInt(response, 2, numStrings);
3098 case RIL_CELL_INFO_TYPE_WCDMA: {
3099 rilCellIdentity.cellIdentityWcdma.lac =
3100 convertResponseStringEntryToInt(response, 1, numStrings);
3101 rilCellIdentity.cellIdentityWcdma.cid =
3102 convertResponseStringEntryToInt(response, 2, numStrings);
3105 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3106 rilCellIdentity.cellIdentityTdscdma.lac =
3107 convertResponseStringEntryToInt(response, 1, numStrings);
3108 rilCellIdentity.cellIdentityTdscdma.cid =
3109 convertResponseStringEntryToInt(response, 2, numStrings);
3112 case RIL_CELL_INFO_TYPE_LTE: {
3113 rilCellIdentity.cellIdentityLte.tac =
3114 convertResponseStringEntryToInt(response, 6, numStrings);
3115 rilCellIdentity.cellIdentityLte.pci =
3116 convertResponseStringEntryToInt(response, 7, numStrings);
3117 rilCellIdentity.cellIdentityLte.ci =
3118 convertResponseStringEntryToInt(response, 8, numStrings);
3126 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3129 int radio::getVoiceRegistrationStateResponse(int slotId,
3130 int responseType, int serial, RIL_Errno e,
3131 void *response, size_t responseLen) {
3132 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3134 if (radioService[slotId]->mRadioResponse != NULL) {
3135 RadioResponseInfo responseInfo = {};
3136 populateResponseInfo(responseInfo, serial, responseType, e);
3138 VoiceRegStateResult voiceRegResponse = {};
3139 int numStrings = responseLen / sizeof(char *);
3140 if (response == NULL) {
3141 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3142 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3143 } else if (s_vendorFunctions->version <= 14) {
3144 if (numStrings != 15) {
3145 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3146 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3148 char **resp = (char **) response;
3149 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3150 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3151 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3152 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3153 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3154 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3155 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3156 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3160 RIL_VoiceRegistrationStateResponse *voiceRegState =
3161 (RIL_VoiceRegistrationStateResponse *)response;
3163 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3164 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3165 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3167 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3168 voiceRegResponse.rat = voiceRegState->rat;;
3169 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3170 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3171 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3172 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3173 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3174 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3175 voiceRegState->cellIdentity);
3179 Return<void> retStatus =
3180 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3181 responseInfo, voiceRegResponse);
3182 radioService[slotId]->checkReturnStatus(retStatus);
3184 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3191 int radio::getDataRegistrationStateResponse(int slotId,
3192 int responseType, int serial, RIL_Errno e,
3193 void *response, size_t responseLen) {
3194 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3196 if (radioService[slotId]->mRadioResponse != NULL) {
3197 RadioResponseInfo responseInfo = {};
3198 populateResponseInfo(responseInfo, serial, responseType, e);
3199 DataRegStateResult dataRegResponse = {};
3200 if (response == NULL) {
3201 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3202 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3203 } else if (s_vendorFunctions->version <= 14) {
3204 int numStrings = responseLen / sizeof(char *);
3205 if ((numStrings != 6) && (numStrings != 11)) {
3206 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3207 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3209 char **resp = (char **) response;
3210 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3211 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3212 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3213 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3214 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3218 RIL_DataRegistrationStateResponse *dataRegState =
3219 (RIL_DataRegistrationStateResponse *)response;
3221 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3222 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3223 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3225 dataRegResponse.regState = (RegState) dataRegState->regState;
3226 dataRegResponse.rat = dataRegState->rat;;
3227 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3228 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3229 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3233 Return<void> retStatus =
3234 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3236 radioService[slotId]->checkReturnStatus(retStatus);
3238 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3245 int radio::getOperatorResponse(int slotId,
3246 int responseType, int serial, RIL_Errno e, void *response,
3247 size_t responseLen) {
3248 RLOGD("getOperatorResponse: serial %d", serial);
3250 if (radioService[slotId]->mRadioResponse != NULL) {
3251 RadioResponseInfo responseInfo = {};
3252 populateResponseInfo(responseInfo, serial, responseType, e);
3253 hidl_string longName;
3254 hidl_string shortName;
3255 hidl_string numeric;
3256 int numStrings = responseLen / sizeof(char *);
3257 if (response == NULL || numStrings != 3) {
3258 RLOGE("getOperatorResponse Invalid response: NULL");
3259 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3262 char **resp = (char **) response;
3263 longName = convertCharPtrToHidlString(resp[0]);
3264 shortName = convertCharPtrToHidlString(resp[1]);
3265 numeric = convertCharPtrToHidlString(resp[2]);
3267 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3268 responseInfo, longName, shortName, numeric);
3269 radioService[slotId]->checkReturnStatus(retStatus);
3271 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3278 int radio::setRadioPowerResponse(int slotId,
3279 int responseType, int serial, RIL_Errno e, void *response,
3280 size_t responseLen) {
3281 RLOGD("setRadioPowerResponse: serial %d", serial);
3283 if (radioService[slotId]->mRadioResponse != NULL) {
3284 RadioResponseInfo responseInfo = {};
3285 populateResponseInfo(responseInfo, serial, responseType, e);
3286 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3288 radioService[slotId]->checkReturnStatus(retStatus);
3290 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3297 int radio::sendDtmfResponse(int slotId,
3298 int responseType, int serial, RIL_Errno e, void *response,
3299 size_t responseLen) {
3300 RLOGD("sendDtmfResponse: serial %d", serial);
3302 if (radioService[slotId]->mRadioResponse != NULL) {
3303 RadioResponseInfo responseInfo = {};
3304 populateResponseInfo(responseInfo, serial, responseType, e);
3305 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3307 radioService[slotId]->checkReturnStatus(retStatus);
3309 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3316 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3317 RIL_Errno e, void *response, size_t responseLen) {
3318 populateResponseInfo(responseInfo, serial, responseType, e);
3319 SendSmsResult result = {};
3321 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3322 RLOGE("Invalid response: NULL");
3323 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3324 result.ackPDU = hidl_string();
3326 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3327 result.messageRef = resp->messageRef;
3328 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3329 result.errorCode = resp->errorCode;
3334 int radio::sendSmsResponse(int slotId,
3335 int responseType, int serial, RIL_Errno e, void *response,
3336 size_t responseLen) {
3337 RLOGD("sendSmsResponse: serial %d", serial);
3339 if (radioService[slotId]->mRadioResponse != NULL) {
3340 RadioResponseInfo responseInfo = {};
3341 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3344 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3346 radioService[slotId]->checkReturnStatus(retStatus);
3348 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3354 int radio::sendSMSExpectMoreResponse(int slotId,
3355 int responseType, int serial, RIL_Errno e, void *response,
3356 size_t responseLen) {
3357 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3359 if (radioService[slotId]->mRadioResponse != NULL) {
3360 RadioResponseInfo responseInfo = {};
3361 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3364 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3365 responseInfo, result);
3366 radioService[slotId]->checkReturnStatus(retStatus);
3368 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3374 int radio::setupDataCallResponse(int slotId,
3375 int responseType, int serial, RIL_Errno e, void *response,
3376 size_t responseLen) {
3377 RLOGD("setupDataCallResponse: serial %d", serial);
3379 if (radioService[slotId]->mRadioResponse != NULL) {
3380 RadioResponseInfo responseInfo = {};
3381 populateResponseInfo(responseInfo, serial, responseType, e);
3383 SetupDataCallResult result = {};
3384 if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) {
3385 RLOGE("setupDataCallResponse: Invalid response");
3386 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3387 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3388 result.type = hidl_string();
3389 result.ifname = hidl_string();
3390 result.addresses = hidl_string();
3391 result.dnses = hidl_string();
3392 result.gateways = hidl_string();
3393 result.pcscf = hidl_string();
3395 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3398 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3399 responseInfo, result);
3400 radioService[slotId]->checkReturnStatus(retStatus);
3402 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3408 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3409 RIL_Errno e, void *response, size_t responseLen) {
3410 populateResponseInfo(responseInfo, serial, responseType, e);
3411 IccIoResult result = {};
3413 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3414 RLOGE("Invalid response: NULL");
3415 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3416 result.simResponse = hidl_string();
3418 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3419 result.sw1 = resp->sw1;
3420 result.sw2 = resp->sw2;
3421 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3426 int radio::iccIOForAppResponse(int slotId,
3427 int responseType, int serial, RIL_Errno e, void *response,
3428 size_t responseLen) {
3429 RLOGD("iccIOForAppResponse: serial %d", serial);
3431 if (radioService[slotId]->mRadioResponse != NULL) {
3432 RadioResponseInfo responseInfo = {};
3433 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3436 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3437 responseInfo, result);
3438 radioService[slotId]->checkReturnStatus(retStatus);
3440 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3446 int radio::sendUssdResponse(int slotId,
3447 int responseType, int serial, RIL_Errno e, void *response,
3448 size_t responseLen) {
3449 RLOGD("sendUssdResponse: serial %d", serial);
3451 if (radioService[slotId]->mRadioResponse != NULL) {
3452 RadioResponseInfo responseInfo = {};
3453 populateResponseInfo(responseInfo, serial, responseType, e);
3454 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3456 radioService[slotId]->checkReturnStatus(retStatus);
3458 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3465 int radio::cancelPendingUssdResponse(int slotId,
3466 int responseType, int serial, RIL_Errno e, void *response,
3467 size_t responseLen) {
3468 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3470 if (radioService[slotId]->mRadioResponse != NULL) {
3471 RadioResponseInfo responseInfo = {};
3472 populateResponseInfo(responseInfo, serial, responseType, e);
3473 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3475 radioService[slotId]->checkReturnStatus(retStatus);
3477 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3484 int radio::getClirResponse(int slotId,
3485 int responseType, int serial, RIL_Errno e, void *response,
3486 size_t responseLen) {
3487 RLOGD("getClirResponse: serial %d", serial);
3489 if (radioService[slotId]->mRadioResponse != NULL) {
3490 RadioResponseInfo responseInfo = {};
3491 populateResponseInfo(responseInfo, serial, responseType, e);
3493 int numInts = responseLen / sizeof(int);
3494 if (response == NULL || numInts != 2) {
3495 RLOGE("getClirResponse Invalid response: NULL");
3496 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3498 int *pInt = (int *) response;
3502 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3504 radioService[slotId]->checkReturnStatus(retStatus);
3506 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3512 int radio::setClirResponse(int slotId,
3513 int responseType, int serial, RIL_Errno e, void *response,
3514 size_t responseLen) {
3515 RLOGD("setClirResponse: serial %d", serial);
3517 if (radioService[slotId]->mRadioResponse != NULL) {
3518 RadioResponseInfo responseInfo = {};
3519 populateResponseInfo(responseInfo, serial, responseType, e);
3520 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
3522 radioService[slotId]->checkReturnStatus(retStatus);
3524 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3530 int radio::getCallForwardStatusResponse(int slotId,
3531 int responseType, int serial, RIL_Errno e,
3532 void *response, size_t responseLen) {
3533 RLOGD("getCallForwardStatusResponse: serial %d", serial);
3535 if (radioService[slotId]->mRadioResponse != NULL) {
3536 RadioResponseInfo responseInfo = {};
3537 populateResponseInfo(responseInfo, serial, responseType, e);
3538 hidl_vec<CallForwardInfo> callForwardInfos;
3540 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
3541 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
3542 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3544 int num = responseLen / sizeof(RIL_CallForwardInfo *);
3545 callForwardInfos.resize(num);
3546 for (int i = 0 ; i < num; i++) {
3547 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
3548 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
3549 callForwardInfos[i].reason = resp->reason;
3550 callForwardInfos[i].serviceClass = resp->serviceClass;
3551 callForwardInfos[i].toa = resp->toa;
3552 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
3553 callForwardInfos[i].timeSeconds = resp->timeSeconds;
3557 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
3558 responseInfo, callForwardInfos);
3559 radioService[slotId]->checkReturnStatus(retStatus);
3561 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
3568 int radio::setCallForwardResponse(int slotId,
3569 int responseType, int serial, RIL_Errno e, void *response,
3570 size_t responseLen) {
3571 RLOGD("setCallForwardResponse: serial %d", serial);
3573 if (radioService[slotId]->mRadioResponse != NULL) {
3574 RadioResponseInfo responseInfo = {};
3575 populateResponseInfo(responseInfo, serial, responseType, e);
3576 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
3578 radioService[slotId]->checkReturnStatus(retStatus);
3580 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3586 int radio::getCallWaitingResponse(int slotId,
3587 int responseType, int serial, RIL_Errno e, void *response,
3588 size_t responseLen) {
3589 RLOGD("getCallWaitingResponse: serial %d", serial);
3591 if (radioService[slotId]->mRadioResponse != NULL) {
3592 RadioResponseInfo responseInfo = {};
3593 populateResponseInfo(responseInfo, serial, responseType, e);
3594 bool enable = false;
3595 int serviceClass = -1;
3596 int numInts = responseLen / sizeof(int);
3597 if (response == NULL || numInts != 2) {
3598 RLOGE("getCallWaitingResponse Invalid response: NULL");
3599 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3601 int *pInt = (int *) response;
3602 enable = pInt[0] == 1 ? true : false;
3603 serviceClass = pInt[1];
3605 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
3606 responseInfo, enable, serviceClass);
3607 radioService[slotId]->checkReturnStatus(retStatus);
3609 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3615 int radio::setCallWaitingResponse(int slotId,
3616 int responseType, int serial, RIL_Errno e, void *response,
3617 size_t responseLen) {
3618 RLOGD("setCallWaitingResponse: serial %d", serial);
3620 if (radioService[slotId]->mRadioResponse != NULL) {
3621 RadioResponseInfo responseInfo = {};
3622 populateResponseInfo(responseInfo, serial, responseType, e);
3623 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
3625 radioService[slotId]->checkReturnStatus(retStatus);
3627 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3633 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
3634 int responseType, int serial, RIL_Errno e,
3635 void *response, size_t responseLen) {
3636 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
3638 if (radioService[slotId]->mRadioResponse != NULL) {
3639 RadioResponseInfo responseInfo = {};
3640 populateResponseInfo(responseInfo, serial, responseType, e);
3641 Return<void> retStatus =
3642 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
3644 radioService[slotId]->checkReturnStatus(retStatus);
3646 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
3653 int radio::acceptCallResponse(int slotId,
3654 int responseType, int serial, RIL_Errno e,
3655 void *response, size_t responseLen) {
3656 RLOGD("acceptCallResponse: serial %d", serial);
3658 if (radioService[slotId]->mRadioResponse != NULL) {
3659 RadioResponseInfo responseInfo = {};
3660 populateResponseInfo(responseInfo, serial, responseType, e);
3661 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
3663 radioService[slotId]->checkReturnStatus(retStatus);
3665 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
3672 int radio::deactivateDataCallResponse(int slotId,
3673 int responseType, int serial, RIL_Errno e,
3674 void *response, size_t responseLen) {
3675 RLOGD("deactivateDataCallResponse: serial %d", serial);
3677 if (radioService[slotId]->mRadioResponse != NULL) {
3678 RadioResponseInfo responseInfo = {};
3679 populateResponseInfo(responseInfo, serial, responseType, e);
3680 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
3682 radioService[slotId]->checkReturnStatus(retStatus);
3684 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
3691 int radio::getFacilityLockForAppResponse(int slotId,
3692 int responseType, int serial, RIL_Errno e,
3693 void *response, size_t responseLen) {
3694 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
3696 if (radioService[slotId]->mRadioResponse != NULL) {
3697 RadioResponseInfo responseInfo = {};
3698 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
3699 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3700 getFacilityLockForAppResponse(responseInfo, ret);
3701 radioService[slotId]->checkReturnStatus(retStatus);
3703 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
3710 int radio::setFacilityLockForAppResponse(int slotId,
3711 int responseType, int serial, RIL_Errno e,
3712 void *response, size_t responseLen) {
3713 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
3715 if (radioService[slotId]->mRadioResponse != NULL) {
3716 RadioResponseInfo responseInfo = {};
3717 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
3718 Return<void> retStatus
3719 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
3721 radioService[slotId]->checkReturnStatus(retStatus);
3723 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
3730 int radio::setBarringPasswordResponse(int slotId,
3731 int responseType, int serial, RIL_Errno e,
3732 void *response, size_t responseLen) {
3733 RLOGD("acceptCallResponse: serial %d", serial);
3735 if (radioService[slotId]->mRadioResponse != NULL) {
3736 RadioResponseInfo responseInfo = {};
3737 populateResponseInfo(responseInfo, serial, responseType, e);
3738 Return<void> retStatus
3739 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
3740 radioService[slotId]->checkReturnStatus(retStatus);
3742 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
3749 int radio::getNetworkSelectionModeResponse(int slotId,
3750 int responseType, int serial, RIL_Errno e, void *response,
3751 size_t responseLen) {
3752 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
3754 if (radioService[slotId]->mRadioResponse != NULL) {
3755 RadioResponseInfo responseInfo = {};
3756 populateResponseInfo(responseInfo, serial, responseType, e);
3757 bool manual = false;
3759 if (response == NULL || responseLen != sizeof(int)) {
3760 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
3761 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3763 int *pInt = (int *) response;
3764 manual = pInt[0] == 1 ? true : false;
3766 Return<void> retStatus
3767 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
3770 radioService[slotId]->checkReturnStatus(retStatus);
3772 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
3779 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
3780 RIL_Errno e, void *response,
3781 size_t responseLen) {
3782 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
3784 if (radioService[slotId]->mRadioResponse != NULL) {
3785 RadioResponseInfo responseInfo = {};
3786 populateResponseInfo(responseInfo, serial, responseType, e);
3787 Return<void> retStatus
3788 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
3790 radioService[slotId]->checkReturnStatus(retStatus);
3792 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
3799 int radio::setNetworkSelectionModeManualResponse(int slotId,
3800 int responseType, int serial, RIL_Errno e,
3801 void *response, size_t responseLen) {
3802 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
3804 if (radioService[slotId]->mRadioResponse != NULL) {
3805 RadioResponseInfo responseInfo = {};
3806 populateResponseInfo(responseInfo, serial, responseType, e);
3807 Return<void> retStatus
3808 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
3810 radioService[slotId]->checkReturnStatus(retStatus);
3812 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
3819 int convertOperatorStatusToInt(const char *str) {
3820 if (strncmp("unknown", str, 9) == 0) {
3821 return (int) OperatorStatus::UNKNOWN;
3822 } else if (strncmp("available", str, 9) == 0) {
3823 return (int) OperatorStatus::AVAILABLE;
3824 } else if (strncmp("current", str, 9) == 0) {
3825 return (int) OperatorStatus::CURRENT;
3826 } else if (strncmp("forbidden", str, 9) == 0) {
3827 return (int) OperatorStatus::FORBIDDEN;
3833 int radio::getAvailableNetworksResponse(int slotId,
3834 int responseType, int serial, RIL_Errno e, void *response,
3835 size_t responseLen) {
3836 RLOGD("getAvailableNetworksResponse: serial %d", serial);
3838 if (radioService[slotId]->mRadioResponse != NULL) {
3839 RadioResponseInfo responseInfo = {};
3840 populateResponseInfo(responseInfo, serial, responseType, e);
3841 hidl_vec<OperatorInfo> networks;
3842 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) {
3843 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
3844 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3846 char **resp = (char **) response;
3847 int numStrings = responseLen / sizeof(char *);
3848 networks.resize(numStrings/4);
3849 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
3850 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
3851 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
3852 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
3853 int status = convertOperatorStatusToInt(resp[i + 3]);
3855 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3857 networks[j].status = (OperatorStatus) status;
3861 Return<void> retStatus
3862 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
3864 radioService[slotId]->checkReturnStatus(retStatus);
3866 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
3873 int radio::startDtmfResponse(int slotId,
3874 int responseType, int serial, RIL_Errno e,
3875 void *response, size_t responseLen) {
3876 RLOGD("startDtmfResponse: serial %d", serial);
3878 if (radioService[slotId]->mRadioResponse != NULL) {
3879 RadioResponseInfo responseInfo = {};
3880 populateResponseInfo(responseInfo, serial, responseType, e);
3881 Return<void> retStatus
3882 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
3883 radioService[slotId]->checkReturnStatus(retStatus);
3885 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3891 int radio::stopDtmfResponse(int slotId,
3892 int responseType, int serial, RIL_Errno e,
3893 void *response, size_t responseLen) {
3894 RLOGD("stopDtmfResponse: serial %d", serial);
3896 if (radioService[slotId]->mRadioResponse != NULL) {
3897 RadioResponseInfo responseInfo = {};
3898 populateResponseInfo(responseInfo, serial, responseType, e);
3899 Return<void> retStatus
3900 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
3901 radioService[slotId]->checkReturnStatus(retStatus);
3903 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3909 int radio::getBasebandVersionResponse(int slotId,
3910 int responseType, int serial, RIL_Errno e,
3911 void *response, size_t responseLen) {
3912 RLOGD("getBasebandVersionResponse: serial %d", serial);
3914 if (radioService[slotId]->mRadioResponse != NULL) {
3915 RadioResponseInfo responseInfo = {};
3916 populateResponseInfo(responseInfo, serial, responseType, e);
3917 Return<void> retStatus
3918 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
3919 convertCharPtrToHidlString((char *) response));
3920 radioService[slotId]->checkReturnStatus(retStatus);
3922 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3928 int radio::separateConnectionResponse(int slotId,
3929 int responseType, int serial, RIL_Errno e,
3930 void *response, size_t responseLen) {
3931 RLOGD("separateConnectionResponse: serial %d", serial);
3933 if (radioService[slotId]->mRadioResponse != NULL) {
3934 RadioResponseInfo responseInfo = {};
3935 populateResponseInfo(responseInfo, serial, responseType, e);
3936 Return<void> retStatus
3937 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
3938 radioService[slotId]->checkReturnStatus(retStatus);
3940 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3947 int radio::setMuteResponse(int slotId,
3948 int responseType, int serial, RIL_Errno e,
3949 void *response, size_t responseLen) {
3950 RLOGD("setMuteResponse: serial %d", serial);
3952 if (radioService[slotId]->mRadioResponse != NULL) {
3953 RadioResponseInfo responseInfo = {};
3954 populateResponseInfo(responseInfo, serial, responseType, e);
3955 Return<void> retStatus
3956 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
3957 radioService[slotId]->checkReturnStatus(retStatus);
3959 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3965 int radio::getMuteResponse(int slotId,
3966 int responseType, int serial, RIL_Errno e, void *response,
3967 size_t responseLen) {
3968 RLOGD("getMuteResponse: serial %d", serial);
3970 if (radioService[slotId]->mRadioResponse != NULL) {
3971 RadioResponseInfo responseInfo = {};
3972 populateResponseInfo(responseInfo, serial, responseType, e);
3973 bool enable = false;
3975 if (response == NULL || responseLen != sizeof(int)) {
3976 RLOGE("getMuteResponse Invalid response: NULL");
3977 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3979 int *pInt = (int *) response;
3980 enable = pInt[0] == 1 ? true : false;
3982 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
3984 radioService[slotId]->checkReturnStatus(retStatus);
3986 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3992 int radio::getClipResponse(int slotId,
3993 int responseType, int serial, RIL_Errno e,
3994 void *response, size_t responseLen) {
3995 RLOGD("getClipResponse: serial %d", serial);
3997 if (radioService[slotId]->mRadioResponse != NULL) {
3998 RadioResponseInfo responseInfo = {};
3999 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4000 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4002 radioService[slotId]->checkReturnStatus(retStatus);
4004 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4010 int radio::getDataCallListResponse(int slotId,
4011 int responseType, int serial, RIL_Errno e,
4012 void *response, size_t responseLen) {
4013 RLOGD("getDataCallListResponse: serial %d", serial);
4015 if (radioService[slotId]->mRadioResponse != NULL) {
4016 RadioResponseInfo responseInfo = {};
4017 populateResponseInfo(responseInfo, serial, responseType, e);
4019 hidl_vec<SetupDataCallResult> ret;
4020 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4021 RLOGE("getDataCallListResponse: invalid response");
4022 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4024 convertRilDataCallListToHal(response, responseLen, ret);
4027 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4029 radioService[slotId]->checkReturnStatus(retStatus);
4031 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4037 int radio::setSuppServiceNotificationsResponse(int slotId,
4038 int responseType, int serial, RIL_Errno e,
4039 void *response, size_t responseLen) {
4040 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4042 if (radioService[slotId]->mRadioResponse != NULL) {
4043 RadioResponseInfo responseInfo = {};
4044 populateResponseInfo(responseInfo, serial, responseType, e);
4045 Return<void> retStatus
4046 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4048 radioService[slotId]->checkReturnStatus(retStatus);
4050 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4057 int radio::deleteSmsOnSimResponse(int slotId,
4058 int responseType, int serial, RIL_Errno e,
4059 void *response, size_t responseLen) {
4060 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4062 if (radioService[slotId]->mRadioResponse != NULL) {
4063 RadioResponseInfo responseInfo = {};
4064 populateResponseInfo(responseInfo, serial, responseType, e);
4065 Return<void> retStatus
4066 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4067 radioService[slotId]->checkReturnStatus(retStatus);
4069 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4075 int radio::setBandModeResponse(int slotId,
4076 int responseType, int serial, RIL_Errno e,
4077 void *response, size_t responseLen) {
4078 RLOGD("setBandModeResponse: serial %d", serial);
4080 if (radioService[slotId]->mRadioResponse != NULL) {
4081 RadioResponseInfo responseInfo = {};
4082 populateResponseInfo(responseInfo, serial, responseType, e);
4083 Return<void> retStatus
4084 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4085 radioService[slotId]->checkReturnStatus(retStatus);
4087 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4093 int radio::writeSmsToSimResponse(int slotId,
4094 int responseType, int serial, RIL_Errno e,
4095 void *response, size_t responseLen) {
4096 RLOGD("writeSmsToSimResponse: serial %d", serial);
4098 if (radioService[slotId]->mRadioResponse != NULL) {
4099 RadioResponseInfo responseInfo = {};
4100 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4101 Return<void> retStatus
4102 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4103 radioService[slotId]->checkReturnStatus(retStatus);
4105 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4111 int radio::getAvailableBandModesResponse(int slotId,
4112 int responseType, int serial, RIL_Errno e, void *response,
4113 size_t responseLen) {
4114 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4116 if (radioService[slotId]->mRadioResponse != NULL) {
4117 RadioResponseInfo responseInfo = {};
4118 populateResponseInfo(responseInfo, serial, responseType, e);
4119 hidl_vec<RadioBandMode> modes;
4120 if (response == NULL || responseLen % sizeof(int) != 0) {
4121 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4122 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4124 int *pInt = (int *) response;
4125 int numInts = responseLen / sizeof(int);
4126 modes.resize(numInts);
4127 for (int i = 0; i < numInts; i++) {
4128 modes[i] = (RadioBandMode) pInt[i];
4131 Return<void> retStatus
4132 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4134 radioService[slotId]->checkReturnStatus(retStatus);
4136 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4143 int radio::sendEnvelopeResponse(int slotId,
4144 int responseType, int serial, RIL_Errno e,
4145 void *response, size_t responseLen) {
4146 RLOGD("sendEnvelopeResponse: serial %d", serial);
4148 if (radioService[slotId]->mRadioResponse != NULL) {
4149 RadioResponseInfo responseInfo = {};
4150 populateResponseInfo(responseInfo, serial, responseType, e);
4151 Return<void> retStatus
4152 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4153 convertCharPtrToHidlString((char *) response));
4154 radioService[slotId]->checkReturnStatus(retStatus);
4156 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4162 int radio::sendTerminalResponseToSimResponse(int slotId,
4163 int responseType, int serial, RIL_Errno e,
4164 void *response, size_t responseLen) {
4165 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4167 if (radioService[slotId]->mRadioResponse != NULL) {
4168 RadioResponseInfo responseInfo = {};
4169 populateResponseInfo(responseInfo, serial, responseType, e);
4170 Return<void> retStatus
4171 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4173 radioService[slotId]->checkReturnStatus(retStatus);
4175 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4182 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4183 int responseType, int serial,
4184 RIL_Errno e, void *response,
4185 size_t responseLen) {
4186 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4188 if (radioService[slotId]->mRadioResponse != NULL) {
4189 RadioResponseInfo responseInfo = {};
4190 populateResponseInfo(responseInfo, serial, responseType, e);
4191 Return<void> retStatus
4192 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4194 radioService[slotId]->checkReturnStatus(retStatus);
4196 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4203 int radio::explicitCallTransferResponse(int slotId,
4204 int responseType, int serial, RIL_Errno e,
4205 void *response, size_t responseLen) {
4206 RLOGD("explicitCallTransferResponse: serial %d", serial);
4208 if (radioService[slotId]->mRadioResponse != NULL) {
4209 RadioResponseInfo responseInfo = {};
4210 populateResponseInfo(responseInfo, serial, responseType, e);
4211 Return<void> retStatus
4212 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4213 radioService[slotId]->checkReturnStatus(retStatus);
4215 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4222 int radio::setPreferredNetworkTypeResponse(int slotId,
4223 int responseType, int serial, RIL_Errno e,
4224 void *response, size_t responseLen) {
4225 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4227 if (radioService[slotId]->mRadioResponse != NULL) {
4228 RadioResponseInfo responseInfo = {};
4229 populateResponseInfo(responseInfo, serial, responseType, e);
4230 Return<void> retStatus
4231 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4233 radioService[slotId]->checkReturnStatus(retStatus);
4235 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4243 int radio::getPreferredNetworkTypeResponse(int slotId,
4244 int responseType, int serial, RIL_Errno e,
4245 void *response, size_t responseLen) {
4246 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4248 if (radioService[slotId]->mRadioResponse != NULL) {
4249 RadioResponseInfo responseInfo = {};
4250 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4251 Return<void> retStatus
4252 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4253 responseInfo, (PreferredNetworkType) ret);
4254 radioService[slotId]->checkReturnStatus(retStatus);
4256 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4263 int radio::getNeighboringCidsResponse(int slotId,
4264 int responseType, int serial, RIL_Errno e,
4265 void *response, size_t responseLen) {
4266 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4268 if (radioService[slotId]->mRadioResponse != NULL) {
4269 RadioResponseInfo responseInfo = {};
4270 populateResponseInfo(responseInfo, serial, responseType, e);
4271 hidl_vec<NeighboringCell> cells;
4273 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4274 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4275 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4277 int num = responseLen / sizeof(RIL_NeighboringCell *);
4279 for (int i = 0 ; i < num; i++) {
4280 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4281 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4282 cells[i].rssi = resp->rssi;
4286 Return<void> retStatus
4287 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4289 radioService[slotId]->checkReturnStatus(retStatus);
4291 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4298 int radio::setLocationUpdatesResponse(int slotId,
4299 int responseType, int serial, RIL_Errno e,
4300 void *response, size_t responseLen) {
4301 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4303 if (radioService[slotId]->mRadioResponse != NULL) {
4304 RadioResponseInfo responseInfo = {};
4305 populateResponseInfo(responseInfo, serial, responseType, e);
4306 Return<void> retStatus
4307 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4308 radioService[slotId]->checkReturnStatus(retStatus);
4310 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4317 int radio::setCdmaSubscriptionSourceResponse(int slotId,
4318 int responseType, int serial, RIL_Errno e,
4319 void *response, size_t responseLen) {
4320 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4322 if (radioService[slotId]->mRadioResponse != NULL) {
4323 RadioResponseInfo responseInfo = {};
4324 populateResponseInfo(responseInfo, serial, responseType, e);
4325 Return<void> retStatus
4326 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4328 radioService[slotId]->checkReturnStatus(retStatus);
4330 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4337 int radio::setCdmaRoamingPreferenceResponse(int slotId,
4338 int responseType, int serial, RIL_Errno e,
4339 void *response, size_t responseLen) {
4340 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4342 if (radioService[slotId]->mRadioResponse != NULL) {
4343 RadioResponseInfo responseInfo = {};
4344 populateResponseInfo(responseInfo, serial, responseType, e);
4345 Return<void> retStatus
4346 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4348 radioService[slotId]->checkReturnStatus(retStatus);
4350 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4357 int radio::getCdmaRoamingPreferenceResponse(int slotId,
4358 int responseType, int serial, RIL_Errno e,
4359 void *response, size_t responseLen) {
4360 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4362 if (radioService[slotId]->mRadioResponse != NULL) {
4363 RadioResponseInfo responseInfo = {};
4364 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4365 Return<void> retStatus
4366 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4367 responseInfo, (CdmaRoamingType) ret);
4368 radioService[slotId]->checkReturnStatus(retStatus);
4370 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4377 int radio::setTTYModeResponse(int slotId,
4378 int responseType, int serial, RIL_Errno e,
4379 void *response, size_t responseLen) {
4380 RLOGD("setTTYModeResponse: serial %d", serial);
4382 if (radioService[slotId]->mRadioResponse != NULL) {
4383 RadioResponseInfo responseInfo = {};
4384 populateResponseInfo(responseInfo, serial, responseType, e);
4385 Return<void> retStatus
4386 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4387 radioService[slotId]->checkReturnStatus(retStatus);
4389 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4395 int radio::getTTYModeResponse(int slotId,
4396 int responseType, int serial, RIL_Errno e,
4397 void *response, size_t responseLen) {
4398 RLOGD("getTTYModeResponse: serial %d", serial);
4400 if (radioService[slotId]->mRadioResponse != NULL) {
4401 RadioResponseInfo responseInfo = {};
4402 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4403 Return<void> retStatus
4404 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4406 radioService[slotId]->checkReturnStatus(retStatus);
4408 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4414 int radio::setPreferredVoicePrivacyResponse(int slotId,
4415 int responseType, int serial, RIL_Errno e,
4416 void *response, size_t responseLen) {
4417 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
4419 if (radioService[slotId]->mRadioResponse != NULL) {
4420 RadioResponseInfo responseInfo = {};
4421 populateResponseInfo(responseInfo, serial, responseType, e);
4422 Return<void> retStatus
4423 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4425 radioService[slotId]->checkReturnStatus(retStatus);
4427 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4434 int radio::getPreferredVoicePrivacyResponse(int slotId,
4435 int responseType, int serial, RIL_Errno e,
4436 void *response, size_t responseLen) {
4437 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
4439 if (radioService[slotId]->mRadioResponse != NULL) {
4440 RadioResponseInfo responseInfo = {};
4441 populateResponseInfo(responseInfo, serial, responseType, e);
4442 bool enable = false;
4443 int numInts = responseLen / sizeof(int);
4444 if (response == NULL || numInts != 1) {
4445 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
4446 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4448 int *pInt = (int *) response;
4449 enable = pInt[0] == 1 ? true : false;
4451 Return<void> retStatus
4452 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
4453 responseInfo, enable);
4454 radioService[slotId]->checkReturnStatus(retStatus);
4456 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4463 int radio::sendCDMAFeatureCodeResponse(int slotId,
4464 int responseType, int serial, RIL_Errno e,
4465 void *response, size_t responseLen) {
4466 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
4468 if (radioService[slotId]->mRadioResponse != NULL) {
4469 RadioResponseInfo responseInfo = {};
4470 populateResponseInfo(responseInfo, serial, responseType, e);
4471 Return<void> retStatus
4472 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
4473 radioService[slotId]->checkReturnStatus(retStatus);
4475 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
4482 int radio::sendBurstDtmfResponse(int slotId,
4483 int responseType, int serial, RIL_Errno e,
4484 void *response, size_t responseLen) {
4485 RLOGD("sendBurstDtmfResponse: serial %d", serial);
4487 if (radioService[slotId]->mRadioResponse != NULL) {
4488 RadioResponseInfo responseInfo = {};
4489 populateResponseInfo(responseInfo, serial, responseType, e);
4490 Return<void> retStatus
4491 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
4492 radioService[slotId]->checkReturnStatus(retStatus);
4494 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4500 int radio::sendCdmaSmsResponse(int slotId,
4501 int responseType, int serial, RIL_Errno e, void *response,
4502 size_t responseLen) {
4503 RLOGD("sendCdmaSmsResponse: serial %d", serial);
4505 if (radioService[slotId]->mRadioResponse != NULL) {
4506 RadioResponseInfo responseInfo = {};
4507 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4510 Return<void> retStatus
4511 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
4512 radioService[slotId]->checkReturnStatus(retStatus);
4514 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4520 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
4521 int responseType, int serial, RIL_Errno e,
4522 void *response, size_t responseLen) {
4523 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
4525 if (radioService[slotId]->mRadioResponse != NULL) {
4526 RadioResponseInfo responseInfo = {};
4527 populateResponseInfo(responseInfo, serial, responseType, e);
4528 Return<void> retStatus
4529 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
4531 radioService[slotId]->checkReturnStatus(retStatus);
4533 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
4540 int radio::getGsmBroadcastConfigResponse(int slotId,
4541 int responseType, int serial, RIL_Errno e,
4542 void *response, size_t responseLen) {
4543 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
4545 if (radioService[slotId]->mRadioResponse != NULL) {
4546 RadioResponseInfo responseInfo = {};
4547 populateResponseInfo(responseInfo, serial, responseType, e);
4548 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
4550 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
4551 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
4552 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4554 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
4555 configs.resize(num);
4556 for (int i = 0 ; i < num; i++) {
4557 RIL_GSM_BroadcastSmsConfigInfo *resp =
4558 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
4559 configs[i].fromServiceId = resp->fromServiceId;
4560 configs[i].toServiceId = resp->toServiceId;
4561 configs[i].fromCodeScheme = resp->fromCodeScheme;
4562 configs[i].toCodeScheme = resp->toCodeScheme;
4563 configs[i].selected = resp->selected == 1 ? true : false;
4567 Return<void> retStatus
4568 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
4570 radioService[slotId]->checkReturnStatus(retStatus);
4572 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4579 int radio::setGsmBroadcastConfigResponse(int slotId,
4580 int responseType, int serial, RIL_Errno e,
4581 void *response, size_t responseLen) {
4582 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
4584 if (radioService[slotId]->mRadioResponse != NULL) {
4585 RadioResponseInfo responseInfo = {};
4586 populateResponseInfo(responseInfo, serial, responseType, e);
4587 Return<void> retStatus
4588 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
4589 radioService[slotId]->checkReturnStatus(retStatus);
4591 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4598 int radio::setGsmBroadcastActivationResponse(int slotId,
4599 int responseType, int serial, RIL_Errno e,
4600 void *response, size_t responseLen) {
4601 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
4603 if (radioService[slotId]->mRadioResponse != NULL) {
4604 RadioResponseInfo responseInfo = {};
4605 populateResponseInfo(responseInfo, serial, responseType, e);
4606 Return<void> retStatus
4607 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
4609 radioService[slotId]->checkReturnStatus(retStatus);
4611 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
4618 int radio::getCdmaBroadcastConfigResponse(int slotId,
4619 int responseType, int serial, RIL_Errno e,
4620 void *response, size_t responseLen) {
4621 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
4623 if (radioService[slotId]->mRadioResponse != NULL) {
4624 RadioResponseInfo responseInfo = {};
4625 populateResponseInfo(responseInfo, serial, responseType, e);
4626 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
4628 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
4629 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
4630 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4632 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
4633 configs.resize(num);
4634 for (int i = 0 ; i < num; i++) {
4635 RIL_CDMA_BroadcastSmsConfigInfo *resp =
4636 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
4637 configs[i].serviceCategory = resp->service_category;
4638 configs[i].language = resp->language;
4639 configs[i].selected = resp->selected == 1 ? true : false;
4643 Return<void> retStatus
4644 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
4646 radioService[slotId]->checkReturnStatus(retStatus);
4648 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4655 int radio::setCdmaBroadcastConfigResponse(int slotId,
4656 int responseType, int serial, RIL_Errno e,
4657 void *response, size_t responseLen) {
4658 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
4660 if (radioService[slotId]->mRadioResponse != NULL) {
4661 RadioResponseInfo responseInfo = {};
4662 populateResponseInfo(responseInfo, serial, responseType, e);
4663 Return<void> retStatus
4664 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
4666 radioService[slotId]->checkReturnStatus(retStatus);
4668 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4675 int radio::setCdmaBroadcastActivationResponse(int slotId,
4676 int responseType, int serial, RIL_Errno e,
4677 void *response, size_t responseLen) {
4678 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
4680 if (radioService[slotId]->mRadioResponse != NULL) {
4681 RadioResponseInfo responseInfo = {};
4682 populateResponseInfo(responseInfo, serial, responseType, e);
4683 Return<void> retStatus
4684 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
4686 radioService[slotId]->checkReturnStatus(retStatus);
4688 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
4695 int radio::getCDMASubscriptionResponse(int slotId,
4696 int responseType, int serial, RIL_Errno e, void *response,
4697 size_t responseLen) {
4698 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
4700 if (radioService[slotId]->mRadioResponse != NULL) {
4701 RadioResponseInfo responseInfo = {};
4702 populateResponseInfo(responseInfo, serial, responseType, e);
4704 int numStrings = responseLen / sizeof(char *);
4705 hidl_string emptyString;
4706 if (response == NULL || numStrings != 5) {
4707 RLOGE("getOperatorResponse Invalid response: NULL");
4708 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4709 Return<void> retStatus
4710 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
4711 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
4712 radioService[slotId]->checkReturnStatus(retStatus);
4714 char **resp = (char **) response;
4715 Return<void> retStatus
4716 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
4718 convertCharPtrToHidlString(resp[0]),
4719 convertCharPtrToHidlString(resp[1]),
4720 convertCharPtrToHidlString(resp[2]),
4721 convertCharPtrToHidlString(resp[3]),
4722 convertCharPtrToHidlString(resp[4]));
4723 radioService[slotId]->checkReturnStatus(retStatus);
4726 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
4733 int radio::writeSmsToRuimResponse(int slotId,
4734 int responseType, int serial, RIL_Errno e,
4735 void *response, size_t responseLen) {
4736 RLOGD("writeSmsToRuimResponse: serial %d", serial);
4738 if (radioService[slotId]->mRadioResponse != NULL) {
4739 RadioResponseInfo responseInfo = {};
4740 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4741 Return<void> retStatus
4742 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
4743 radioService[slotId]->checkReturnStatus(retStatus);
4745 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4751 int radio::deleteSmsOnRuimResponse(int slotId,
4752 int responseType, int serial, RIL_Errno e,
4753 void *response, size_t responseLen) {
4754 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
4756 if (radioService[slotId]->mRadioResponse != NULL) {
4757 RadioResponseInfo responseInfo = {};
4758 populateResponseInfo(responseInfo, serial, responseType, e);
4759 Return<void> retStatus
4760 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
4761 radioService[slotId]->checkReturnStatus(retStatus);
4763 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4769 int radio::getDeviceIdentityResponse(int slotId,
4770 int responseType, int serial, RIL_Errno e, void *response,
4771 size_t responseLen) {
4772 RLOGD("getDeviceIdentityResponse: serial %d", serial);
4774 if (radioService[slotId]->mRadioResponse != NULL) {
4775 RadioResponseInfo responseInfo = {};
4776 populateResponseInfo(responseInfo, serial, responseType, e);
4778 int numStrings = responseLen / sizeof(char *);
4779 hidl_string emptyString;
4780 if (response == NULL || numStrings != 4) {
4781 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
4782 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4783 Return<void> retStatus
4784 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
4785 emptyString, emptyString, emptyString, emptyString);
4786 radioService[slotId]->checkReturnStatus(retStatus);
4788 char **resp = (char **) response;
4789 Return<void> retStatus
4790 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
4791 convertCharPtrToHidlString(resp[0]),
4792 convertCharPtrToHidlString(resp[1]),
4793 convertCharPtrToHidlString(resp[2]),
4794 convertCharPtrToHidlString(resp[3]));
4795 radioService[slotId]->checkReturnStatus(retStatus);
4798 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
4805 int radio::exitEmergencyCallbackModeResponse(int slotId,
4806 int responseType, int serial, RIL_Errno e,
4807 void *response, size_t responseLen) {
4808 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
4810 if (radioService[slotId]->mRadioResponse != NULL) {
4811 RadioResponseInfo responseInfo = {};
4812 populateResponseInfo(responseInfo, serial, responseType, e);
4813 Return<void> retStatus
4814 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
4816 radioService[slotId]->checkReturnStatus(retStatus);
4818 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
4825 int radio::getSmscAddressResponse(int slotId,
4826 int responseType, int serial, RIL_Errno e,
4827 void *response, size_t responseLen) {
4828 RLOGD("getSmscAddressResponse: serial %d", serial);
4830 if (radioService[slotId]->mRadioResponse != NULL) {
4831 RadioResponseInfo responseInfo = {};
4832 populateResponseInfo(responseInfo, serial, responseType, e);
4833 Return<void> retStatus
4834 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
4835 convertCharPtrToHidlString((char *) response));
4836 radioService[slotId]->checkReturnStatus(retStatus);
4838 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4844 int radio::setSmscAddressResponse(int slotId,
4845 int responseType, int serial, RIL_Errno e,
4846 void *response, size_t responseLen) {
4847 RLOGD("setSmscAddressResponse: serial %d", serial);
4849 if (radioService[slotId]->mRadioResponse != NULL) {
4850 RadioResponseInfo responseInfo = {};
4851 populateResponseInfo(responseInfo, serial, responseType, e);
4852 Return<void> retStatus
4853 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
4854 radioService[slotId]->checkReturnStatus(retStatus);
4856 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4862 int radio::reportSmsMemoryStatusResponse(int slotId,
4863 int responseType, int serial, RIL_Errno e,
4864 void *response, size_t responseLen) {
4865 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
4867 if (radioService[slotId]->mRadioResponse != NULL) {
4868 RadioResponseInfo responseInfo = {};
4869 populateResponseInfo(responseInfo, serial, responseType, e);
4870 Return<void> retStatus
4871 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
4872 radioService[slotId]->checkReturnStatus(retStatus);
4874 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
4881 int radio::reportStkServiceIsRunningResponse(int slotId,
4882 int responseType, int serial, RIL_Errno e,
4883 void *response, size_t responseLen) {
4884 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
4886 if (radioService[slotId]->mRadioResponse != NULL) {
4887 RadioResponseInfo responseInfo = {};
4888 populateResponseInfo(responseInfo, serial, responseType, e);
4889 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4890 reportStkServiceIsRunningResponse(responseInfo);
4891 radioService[slotId]->checkReturnStatus(retStatus);
4893 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
4900 int radio::getCdmaSubscriptionSourceResponse(int slotId,
4901 int responseType, int serial, RIL_Errno e,
4902 void *response, size_t responseLen) {
4903 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
4905 if (radioService[slotId]->mRadioResponse != NULL) {
4906 RadioResponseInfo responseInfo = {};
4907 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4908 Return<void> retStatus
4909 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
4910 responseInfo, (CdmaSubscriptionSource) ret);
4911 radioService[slotId]->checkReturnStatus(retStatus);
4913 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4920 int radio::requestIsimAuthenticationResponse(int slotId,
4921 int responseType, int serial, RIL_Errno e,
4922 void *response, size_t responseLen) {
4923 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
4925 if (radioService[slotId]->mRadioResponse != NULL) {
4926 RadioResponseInfo responseInfo = {};
4927 populateResponseInfo(responseInfo, serial, responseType, e);
4928 Return<void> retStatus
4929 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
4931 convertCharPtrToHidlString((char *) response));
4932 radioService[slotId]->checkReturnStatus(retStatus);
4934 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
4941 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
4943 int serial, RIL_Errno e, void *response,
4944 size_t responseLen) {
4945 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
4947 if (radioService[slotId]->mRadioResponse != NULL) {
4948 RadioResponseInfo responseInfo = {};
4949 populateResponseInfo(responseInfo, serial, responseType, e);
4950 Return<void> retStatus
4951 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
4953 radioService[slotId]->checkReturnStatus(retStatus);
4955 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
4962 int radio::sendEnvelopeWithStatusResponse(int slotId,
4963 int responseType, int serial, RIL_Errno e, void *response,
4964 size_t responseLen) {
4965 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
4967 if (radioService[slotId]->mRadioResponse != NULL) {
4968 RadioResponseInfo responseInfo = {};
4969 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
4970 response, responseLen);
4972 Return<void> retStatus
4973 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
4975 radioService[slotId]->checkReturnStatus(retStatus);
4977 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
4984 int radio::getVoiceRadioTechnologyResponse(int slotId,
4985 int responseType, int serial, RIL_Errno e,
4986 void *response, size_t responseLen) {
4987 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
4989 if (radioService[slotId]->mRadioResponse != NULL) {
4990 RadioResponseInfo responseInfo = {};
4991 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4992 Return<void> retStatus
4993 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
4994 responseInfo, (RadioTechnology) ret);
4995 radioService[slotId]->checkReturnStatus(retStatus);
4997 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5004 int radio::getCellInfoListResponse(int slotId,
5006 int serial, RIL_Errno e, void *response,
5007 size_t responseLen) {
5008 RLOGD("getCellInfoListResponse: serial %d", serial);
5010 if (radioService[slotId]->mRadioResponse != NULL) {
5011 RadioResponseInfo responseInfo = {};
5012 populateResponseInfo(responseInfo, serial, responseType, e);
5014 hidl_vec<CellInfo> ret;
5015 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5016 RLOGE("getCellInfoListResponse: Invalid response");
5017 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5019 convertRilCellInfoListToHal(response, responseLen, ret);
5022 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5024 radioService[slotId]->checkReturnStatus(retStatus);
5026 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5032 int radio::setCellInfoListRateResponse(int slotId,
5034 int serial, RIL_Errno e, void *response,
5035 size_t responseLen) {
5036 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5038 if (radioService[slotId]->mRadioResponse != NULL) {
5039 RadioResponseInfo responseInfo = {};
5040 populateResponseInfo(responseInfo, serial, responseType, e);
5041 Return<void> retStatus
5042 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5043 radioService[slotId]->checkReturnStatus(retStatus);
5045 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5052 int radio::setInitialAttachApnResponse(int slotId,
5053 int responseType, int serial, RIL_Errno e,
5054 void *response, size_t responseLen) {
5055 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5057 if (radioService[slotId]->mRadioResponse != NULL) {
5058 RadioResponseInfo responseInfo = {};
5059 populateResponseInfo(responseInfo, serial, responseType, e);
5060 Return<void> retStatus
5061 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5062 radioService[slotId]->checkReturnStatus(retStatus);
5064 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5071 int radio::getImsRegistrationStateResponse(int slotId,
5072 int responseType, int serial, RIL_Errno e,
5073 void *response, size_t responseLen) {
5074 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5076 if (radioService[slotId]->mRadioResponse != NULL) {
5077 RadioResponseInfo responseInfo = {};
5078 populateResponseInfo(responseInfo, serial, responseType, e);
5079 bool isRegistered = false;
5081 int numInts = responseLen / sizeof(int);
5082 if (response == NULL || numInts != 2) {
5083 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5084 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5086 int *pInt = (int *) response;
5087 isRegistered = pInt[0] == 1 ? true : false;
5088 ratFamily = pInt[1];
5090 Return<void> retStatus
5091 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5092 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5093 radioService[slotId]->checkReturnStatus(retStatus);
5095 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5102 int radio::sendImsSmsResponse(int slotId,
5103 int responseType, int serial, RIL_Errno e, void *response,
5104 size_t responseLen) {
5105 RLOGD("sendImsSmsResponse: serial %d", serial);
5107 if (radioService[slotId]->mRadioResponse != NULL) {
5108 RadioResponseInfo responseInfo = {};
5109 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5112 Return<void> retStatus
5113 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5114 radioService[slotId]->checkReturnStatus(retStatus);
5116 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5122 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5123 int responseType, int serial, RIL_Errno e,
5124 void *response, size_t responseLen) {
5125 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5127 if (radioService[slotId]->mRadioResponse != NULL) {
5128 RadioResponseInfo responseInfo = {};
5129 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5132 Return<void> retStatus
5133 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5134 responseInfo, result);
5135 radioService[slotId]->checkReturnStatus(retStatus);
5137 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5144 int radio::iccOpenLogicalChannelResponse(int slotId,
5145 int responseType, int serial, RIL_Errno e, void *response,
5146 size_t responseLen) {
5147 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5149 if (radioService[slotId]->mRadioResponse != NULL) {
5150 RadioResponseInfo responseInfo = {};
5151 populateResponseInfo(responseInfo, serial, responseType, e);
5153 hidl_vec<int8_t> selectResponse;
5154 int numInts = responseLen / sizeof(int);
5155 if (response == NULL || responseLen % sizeof(int) != 0) {
5156 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5157 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5159 int *pInt = (int *) response;
5160 channelId = pInt[0];
5161 selectResponse.resize(numInts - 1);
5162 for (int i = 1; i < numInts; i++) {
5163 selectResponse[i - 1] = (int8_t) pInt[i];
5166 Return<void> retStatus
5167 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5168 channelId, selectResponse);
5169 radioService[slotId]->checkReturnStatus(retStatus);
5171 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5178 int radio::iccCloseLogicalChannelResponse(int slotId,
5179 int responseType, int serial, RIL_Errno e,
5180 void *response, size_t responseLen) {
5181 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5183 if (radioService[slotId]->mRadioResponse != NULL) {
5184 RadioResponseInfo responseInfo = {};
5185 populateResponseInfo(responseInfo, serial, responseType, e);
5186 Return<void> retStatus
5187 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5189 radioService[slotId]->checkReturnStatus(retStatus);
5191 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5198 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5199 int responseType, int serial, RIL_Errno e,
5200 void *response, size_t responseLen) {
5201 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5203 if (radioService[slotId]->mRadioResponse != NULL) {
5204 RadioResponseInfo responseInfo = {};
5205 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5208 Return<void> retStatus
5209 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5210 responseInfo, result);
5211 radioService[slotId]->checkReturnStatus(retStatus);
5213 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5220 int radio::nvReadItemResponse(int slotId,
5221 int responseType, int serial, RIL_Errno e,
5222 void *response, size_t responseLen) {
5223 RLOGD("nvReadItemResponse: serial %d", serial);
5225 if (radioService[slotId]->mRadioResponse != NULL) {
5226 RadioResponseInfo responseInfo = {};
5227 populateResponseInfo(responseInfo, serial, responseType, e);
5228 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5230 convertCharPtrToHidlString((char *) response));
5231 radioService[slotId]->checkReturnStatus(retStatus);
5233 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5239 int radio::nvWriteItemResponse(int slotId,
5240 int responseType, int serial, RIL_Errno e,
5241 void *response, size_t responseLen) {
5242 RLOGD("nvWriteItemResponse: serial %d", serial);
5244 if (radioService[slotId]->mRadioResponse != NULL) {
5245 RadioResponseInfo responseInfo = {};
5246 populateResponseInfo(responseInfo, serial, responseType, e);
5247 Return<void> retStatus
5248 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5249 radioService[slotId]->checkReturnStatus(retStatus);
5251 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5257 int radio::nvWriteCdmaPrlResponse(int slotId,
5258 int responseType, int serial, RIL_Errno e,
5259 void *response, size_t responseLen) {
5260 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5262 if (radioService[slotId]->mRadioResponse != NULL) {
5263 RadioResponseInfo responseInfo = {};
5264 populateResponseInfo(responseInfo, serial, responseType, e);
5265 Return<void> retStatus
5266 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5267 radioService[slotId]->checkReturnStatus(retStatus);
5269 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5275 int radio::nvResetConfigResponse(int slotId,
5276 int responseType, int serial, RIL_Errno e,
5277 void *response, size_t responseLen) {
5278 RLOGD("nvResetConfigResponse: serial %d", serial);
5280 if (radioService[slotId]->mRadioResponse != NULL) {
5281 RadioResponseInfo responseInfo = {};
5282 populateResponseInfo(responseInfo, serial, responseType, e);
5283 Return<void> retStatus
5284 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5285 radioService[slotId]->checkReturnStatus(retStatus);
5287 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5293 int radio::setUiccSubscriptionResponse(int slotId,
5294 int responseType, int serial, RIL_Errno e,
5295 void *response, size_t responseLen) {
5296 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5298 if (radioService[slotId]->mRadioResponse != NULL) {
5299 RadioResponseInfo responseInfo = {};
5300 populateResponseInfo(responseInfo, serial, responseType, e);
5301 Return<void> retStatus
5302 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5303 radioService[slotId]->checkReturnStatus(retStatus);
5305 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5312 int radio::setDataAllowedResponse(int slotId,
5313 int responseType, int serial, RIL_Errno e,
5314 void *response, size_t responseLen) {
5315 RLOGD("setDataAllowedResponse: serial %d", serial);
5317 if (radioService[slotId]->mRadioResponse != NULL) {
5318 RadioResponseInfo responseInfo = {};
5319 populateResponseInfo(responseInfo, serial, responseType, e);
5320 Return<void> retStatus
5321 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5322 radioService[slotId]->checkReturnStatus(retStatus);
5324 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5330 int radio::getHardwareConfigResponse(int slotId,
5331 int responseType, int serial, RIL_Errno e,
5332 void *response, size_t responseLen) {
5333 RLOGD("getHardwareConfigResponse: serial %d", serial);
5335 if (radioService[slotId]->mRadioResponse != NULL) {
5336 RadioResponseInfo responseInfo = {};
5337 populateResponseInfo(responseInfo, serial, responseType, e);
5339 hidl_vec<HardwareConfig> result;
5340 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
5341 RLOGE("hardwareConfigChangedInd: invalid response");
5342 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5344 convertRilHardwareConfigListToHal(response, responseLen, result);
5347 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
5348 responseInfo, result);
5349 radioService[slotId]->checkReturnStatus(retStatus);
5351 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5357 int radio::requestIccSimAuthenticationResponse(int slotId,
5358 int responseType, int serial, RIL_Errno e,
5359 void *response, size_t responseLen) {
5360 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
5362 if (radioService[slotId]->mRadioResponse != NULL) {
5363 RadioResponseInfo responseInfo = {};
5364 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5367 Return<void> retStatus
5368 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
5369 responseInfo, result);
5370 radioService[slotId]->checkReturnStatus(retStatus);
5372 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
5379 int radio::setDataProfileResponse(int slotId,
5380 int responseType, int serial, RIL_Errno e,
5381 void *response, size_t responseLen) {
5382 RLOGD("setDataProfileResponse: serial %d", serial);
5384 if (radioService[slotId]->mRadioResponse != NULL) {
5385 RadioResponseInfo responseInfo = {};
5386 populateResponseInfo(responseInfo, serial, responseType, e);
5387 Return<void> retStatus
5388 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
5389 radioService[slotId]->checkReturnStatus(retStatus);
5391 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5397 int radio::requestShutdownResponse(int slotId,
5398 int responseType, int serial, RIL_Errno e,
5399 void *response, size_t responseLen) {
5400 RLOGD("requestShutdownResponse: serial %d", serial);
5402 if (radioService[slotId]->mRadioResponse != NULL) {
5403 RadioResponseInfo responseInfo = {};
5404 populateResponseInfo(responseInfo, serial, responseType, e);
5405 Return<void> retStatus
5406 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
5407 radioService[slotId]->checkReturnStatus(retStatus);
5409 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5415 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
5416 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
5417 populateResponseInfo(responseInfo, serial, responseType, e);
5419 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
5420 RLOGE("responseRadioCapability: Invalid response");
5421 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5422 rc.logicalModemUuid = hidl_string();
5424 convertRilRadioCapabilityToHal(response, responseLen, rc);
5428 int radio::getRadioCapabilityResponse(int slotId,
5429 int responseType, int serial, RIL_Errno e,
5430 void *response, size_t responseLen) {
5431 RLOGD("getRadioCapabilityResponse: serial %d", serial);
5433 if (radioService[slotId]->mRadioResponse != NULL) {
5434 RadioResponseInfo responseInfo = {};
5435 RadioCapability result = {};
5436 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
5438 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
5439 responseInfo, result);
5440 radioService[slotId]->checkReturnStatus(retStatus);
5442 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5448 int radio::setRadioCapabilityResponse(int slotId,
5449 int responseType, int serial, RIL_Errno e,
5450 void *response, size_t responseLen) {
5451 RLOGD("setRadioCapabilityResponse: serial %d", serial);
5453 if (radioService[slotId]->mRadioResponse != NULL) {
5454 RadioResponseInfo responseInfo = {};
5455 RadioCapability result = {};
5456 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
5458 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
5459 responseInfo, result);
5460 radioService[slotId]->checkReturnStatus(retStatus);
5462 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5468 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
5469 RIL_Errno e, void *response, size_t responseLen) {
5470 populateResponseInfo(responseInfo, serial, responseType, e);
5471 LceStatusInfo result = {};
5473 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
5474 RLOGE("Invalid response: NULL");
5475 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5477 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
5478 result.lceStatus = (LceStatus) resp->lce_status;
5479 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
5484 int radio::startLceServiceResponse(int slotId,
5485 int responseType, int serial, RIL_Errno e,
5486 void *response, size_t responseLen) {
5487 RLOGD("startLceServiceResponse: serial %d", serial);
5489 if (radioService[slotId]->mRadioResponse != NULL) {
5490 RadioResponseInfo responseInfo = {};
5491 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
5492 response, responseLen);
5494 Return<void> retStatus
5495 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
5497 radioService[slotId]->checkReturnStatus(retStatus);
5499 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5505 int radio::stopLceServiceResponse(int slotId,
5506 int responseType, int serial, RIL_Errno e,
5507 void *response, size_t responseLen) {
5508 RLOGD("stopLceServiceResponse: serial %d", serial);
5510 if (radioService[slotId]->mRadioResponse != NULL) {
5511 RadioResponseInfo responseInfo = {};
5512 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
5513 response, responseLen);
5515 Return<void> retStatus
5516 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
5518 radioService[slotId]->checkReturnStatus(retStatus);
5520 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5526 int radio::pullLceDataResponse(int slotId,
5527 int responseType, int serial, RIL_Errno e,
5528 void *response, size_t responseLen) {
5529 RLOGD("pullLceDataResponse: serial %d", serial);
5531 if (radioService[slotId]->mRadioResponse != NULL) {
5532 RadioResponseInfo responseInfo = {};
5533 populateResponseInfo(responseInfo, serial, responseType, e);
5535 LceDataInfo result = {};
5536 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
5537 RLOGE("pullLceDataResponse: Invalid response");
5538 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5540 convertRilLceDataInfoToHal(response, responseLen, result);
5543 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
5544 responseInfo, result);
5545 radioService[slotId]->checkReturnStatus(retStatus);
5547 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5553 int radio::getModemActivityInfoResponse(int slotId,
5554 int responseType, int serial, RIL_Errno e,
5555 void *response, size_t responseLen) {
5556 RLOGD("getModemActivityInfoResponse: serial %d", serial);
5558 if (radioService[slotId]->mRadioResponse != NULL) {
5559 RadioResponseInfo responseInfo = {};
5560 populateResponseInfo(responseInfo, serial, responseType, e);
5561 ActivityStatsInfo info;
5562 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
5563 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
5564 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5566 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
5567 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
5568 info.idleModeTimeMs = resp->idle_mode_time_ms;
5569 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
5570 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
5572 info.rxModeTimeMs = resp->rx_mode_time_ms;
5575 Return<void> retStatus
5576 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
5578 radioService[slotId]->checkReturnStatus(retStatus);
5580 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
5587 int radio::setAllowedCarriersResponse(int slotId,
5588 int responseType, int serial, RIL_Errno e,
5589 void *response, size_t responseLen) {
5590 RLOGD("setAllowedCarriersResponse: 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->setAllowedCarriersResponse(responseInfo,
5598 radioService[slotId]->checkReturnStatus(retStatus);
5600 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
5607 int radio::getAllowedCarriersResponse(int slotId,
5608 int responseType, int serial, RIL_Errno e,
5609 void *response, size_t responseLen) {
5610 RLOGD("getAllowedCarriersResponse: serial %d", serial);
5612 if (radioService[slotId]->mRadioResponse != NULL) {
5613 RadioResponseInfo responseInfo = {};
5614 populateResponseInfo(responseInfo, serial, responseType, e);
5615 CarrierRestrictions carrierInfo = {};
5616 bool allAllowed = true;
5617 if (response == NULL || responseLen != sizeof(RIL_CarrierRestrictions)) {
5618 RLOGE("getAllowedCarriersResponse Invalid response: NULL");
5619 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5621 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
5622 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
5626 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
5627 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
5628 RIL_Carrier *carrier = pCr->allowed_carriers + i;
5629 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
5630 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
5631 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
5632 carrierInfo.allowedCarriers[i].matchData =
5633 convertCharPtrToHidlString(carrier->match_data);
5636 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
5637 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
5638 RIL_Carrier *carrier = pCr->excluded_carriers + i;
5639 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
5640 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
5641 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
5642 carrierInfo.excludedCarriers[i].matchData =
5643 convertCharPtrToHidlString(carrier->match_data);
5647 Return<void> retStatus
5648 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
5649 allAllowed, carrierInfo);
5650 radioService[slotId]->checkReturnStatus(retStatus);
5652 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
5659 int radio::sendDeviceStateResponse(int slotId,
5660 int responseType, int serial, RIL_Errno e,
5661 void *response, size_t responselen) {
5662 RLOGD("sendDeviceStateResponse: serial %d", serial);
5664 if (radioService[slotId]->mRadioResponse != NULL) {
5665 RadioResponseInfo responseInfo = {};
5666 populateResponseInfo(responseInfo, serial, responseType, e);
5667 Return<void> retStatus
5668 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
5669 radioService[slotId]->checkReturnStatus(retStatus);
5671 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5677 int radio::setIndicationFilterResponse(int slotId,
5678 int responseType, int serial, RIL_Errno e,
5679 void *response, size_t responselen) {
5680 RLOGD("setIndicationFilterResponse: serial %d", serial);
5682 if (radioService[slotId]->mRadioResponse != NULL) {
5683 RadioResponseInfo responseInfo = {};
5684 populateResponseInfo(responseInfo, serial, responseType, e);
5685 Return<void> retStatus
5686 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
5687 radioService[slotId]->checkReturnStatus(retStatus);
5689 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
5697 int radio::setSimCardPowerResponse(int slotId,
5698 int responseType, int serial, RIL_Errno e,
5699 void *response, size_t responseLen) {
5700 RLOGD("setSimCardPowerResponse: serial %d", serial);
5702 if (radioService[slotId]->mRadioResponse != NULL) {
5703 RadioResponseInfo responseInfo = {};
5704 populateResponseInfo(responseInfo, serial, responseType, e);
5705 Return<void> retStatus
5706 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
5707 radioService[slotId]->checkReturnStatus(retStatus);
5709 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5715 int radio::sendRequestRawResponse(int slotId,
5716 int responseType, int serial, RIL_Errno e,
5717 void *response, size_t responseLen) {
5718 RLOGD("sendRequestRawResponse: serial %d", serial);
5720 if (oemHookService[slotId]->mOemHookResponse != NULL) {
5721 RadioResponseInfo responseInfo = {};
5722 populateResponseInfo(responseInfo, serial, responseType, e);
5723 hidl_vec<uint8_t> data;
5725 if (response == NULL) {
5726 RLOGE("sendRequestRawResponse: Invalid response");
5727 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5729 data.setToExternal((uint8_t *) response, responseLen);
5731 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
5732 sendRequestRawResponse(responseInfo, data);
5733 checkReturnStatus(slotId, retStatus);
5735 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
5742 int radio::sendRequestStringsResponse(int slotId,
5743 int responseType, int serial, RIL_Errno e,
5744 void *response, size_t responseLen) {
5745 RLOGD("sendRequestStringsResponse: serial %d", serial);
5747 if (oemHookService[slotId]->mOemHookResponse != NULL) {
5748 RadioResponseInfo responseInfo = {};
5749 populateResponseInfo(responseInfo, serial, responseType, e);
5750 hidl_vec<hidl_string> data;
5752 if (response == NULL || responseLen % sizeof(char *) != 0) {
5753 RLOGE("sendRequestStringsResponse Invalid response: NULL");
5754 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5756 char **resp = (char **) response;
5757 int numStrings = responseLen / sizeof(char *);
5758 data.resize(numStrings);
5759 for (int i = 0; i < numStrings; i++) {
5760 data[i] = convertCharPtrToHidlString(resp[i]);
5763 Return<void> retStatus
5764 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
5765 responseInfo, data);
5766 checkReturnStatus(slotId, retStatus);
5768 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
5775 // Radio Indication functions
5777 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
5778 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
5779 (RadioIndicationType::UNSOLICITED_ACK_EXP);
5782 int radio::radioStateChangedInd(int slotId,
5783 int indicationType, int token, RIL_Errno e, void *response,
5784 size_t responseLen) {
5785 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5786 RadioState radioState = (RadioState) s_vendorFunctions->onStateRequest();
5787 RLOGD("radioStateChangedInd: radioState %d", radioState);
5788 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
5789 convertIntToRadioIndicationType(indicationType), radioState);
5790 radioService[slotId]->checkReturnStatus(retStatus);
5792 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
5798 int radio::callStateChangedInd(int slotId,
5799 int indicationType, int token, RIL_Errno e, void *response,
5800 size_t responseLen) {
5801 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5802 RLOGD("callStateChangedInd");
5803 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
5804 convertIntToRadioIndicationType(indicationType));
5805 radioService[slotId]->checkReturnStatus(retStatus);
5807 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
5813 int radio::networkStateChangedInd(int slotId,
5814 int indicationType, int token, RIL_Errno e, void *response,
5815 size_t responseLen) {
5816 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5817 RLOGD("networkStateChangedInd");
5818 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
5819 convertIntToRadioIndicationType(indicationType));
5820 radioService[slotId]->checkReturnStatus(retStatus);
5822 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
5829 uint8_t hexCharToInt(uint8_t c) {
5830 if (c >= '0' && c <= '9') return (c - '0');
5831 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
5832 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
5834 return INVALID_HEX_CHAR;
5837 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
5838 if (responseLen % 2 != 0) {
5842 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
5843 if (bytes == NULL) {
5844 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
5847 uint8_t *hexString = (uint8_t *)response;
5849 for (size_t i = 0; i < responseLen; i += 2) {
5850 uint8_t hexChar1 = hexCharToInt(hexString[i]);
5851 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
5853 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
5854 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
5855 hexString[i], hexString[i + 1]);
5859 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
5865 int radio::newSmsInd(int slotId, int indicationType,
5866 int token, RIL_Errno e, void *response, size_t responseLen) {
5867 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5868 if (response == NULL || responseLen == 0) {
5869 RLOGE("newSmsInd: invalid response");
5873 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
5874 if (bytes == NULL) {
5875 RLOGE("newSmsInd: convertHexStringToBytes failed");
5879 hidl_vec<uint8_t> pdu;
5880 pdu.setToExternal(bytes, responseLen/2);
5882 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
5883 convertIntToRadioIndicationType(indicationType), pdu);
5884 radioService[slotId]->checkReturnStatus(retStatus);
5887 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
5893 int radio::newSmsStatusReportInd(int slotId,
5894 int indicationType, int token, RIL_Errno e, void *response,
5895 size_t responseLen) {
5896 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5897 if (response == NULL || responseLen == 0) {
5898 RLOGE("newSmsStatusReportInd: invalid response");
5902 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
5903 if (bytes == NULL) {
5904 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
5908 hidl_vec<uint8_t> pdu;
5909 pdu.setToExternal(bytes, responseLen/2);
5910 RLOGD("newSmsStatusReportInd");
5911 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
5912 convertIntToRadioIndicationType(indicationType), pdu);
5913 radioService[slotId]->checkReturnStatus(retStatus);
5916 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
5922 int radio::newSmsOnSimInd(int slotId, int indicationType,
5923 int token, RIL_Errno e, void *response, size_t responseLen) {
5924 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5925 if (response == NULL || responseLen != sizeof(int)) {
5926 RLOGE("newSmsOnSimInd: invalid response");
5929 int32_t recordNumber = ((int32_t *) response)[0];
5930 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
5931 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
5932 convertIntToRadioIndicationType(indicationType), recordNumber);
5933 radioService[slotId]->checkReturnStatus(retStatus);
5935 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
5941 int radio::onUssdInd(int slotId, int indicationType,
5942 int token, RIL_Errno e, void *response, size_t responseLen) {
5943 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5944 if (response == NULL || responseLen != 2 * sizeof(char *)) {
5945 RLOGE("onUssdInd: invalid response");
5948 char **strings = (char **) response;
5949 char *mode = strings[0];
5950 hidl_string msg = convertCharPtrToHidlString(strings[1]);
5951 UssdModeType modeType = (UssdModeType) atoi(mode);
5952 RLOGD("onUssdInd: mode %s", mode);
5953 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
5954 convertIntToRadioIndicationType(indicationType), modeType, msg);
5955 radioService[slotId]->checkReturnStatus(retStatus);
5957 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
5963 int radio::nitzTimeReceivedInd(int slotId,
5964 int indicationType, int token, RIL_Errno e, void *response,
5965 size_t responseLen) {
5966 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5967 if (response == NULL || responseLen == 0) {
5968 RLOGE("nitzTimeReceivedInd: invalid response");
5971 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
5972 int64_t timeReceived = android::elapsedRealtime();
5973 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
5975 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
5976 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
5977 radioService[slotId]->checkReturnStatus(retStatus);
5979 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
5986 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
5987 SignalStrength& signalStrength) {
5988 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
5990 // Fixup LTE for backwards compatibility
5991 // signalStrength: -1 -> 99
5992 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
5993 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
5995 // rsrp: -1 -> INT_MAX all other negative value to positive.
5997 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
5998 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
5999 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6000 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6002 // rsrq: -1 -> INT_MAX
6003 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6004 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6006 // Not remapping rssnr is already using INT_MAX
6007 // cqi: -1 -> INT_MAX
6008 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6009 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6012 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6013 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6014 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6015 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6016 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6017 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6018 signalStrength.evdo.signalNoiseRatio =
6019 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6020 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6021 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6022 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6023 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6024 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6025 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6026 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6029 int radio::currentSignalStrengthInd(int slotId,
6030 int indicationType, int token, RIL_Errno e,
6031 void *response, size_t responseLen) {
6032 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6033 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
6034 RLOGE("currentSignalStrengthInd: invalid response");
6038 SignalStrength signalStrength = {};
6039 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6041 RLOGD("currentSignalStrengthInd");
6042 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6043 convertIntToRadioIndicationType(indicationType), signalStrength);
6044 radioService[slotId]->checkReturnStatus(retStatus);
6046 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6053 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6054 SetupDataCallResult& dcResult) {
6055 dcResult.status = (DataCallFailCause) dcResponse->status;
6056 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6057 dcResult.cid = dcResponse->cid;
6058 dcResult.active = dcResponse->active;
6059 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6060 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6061 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6062 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6063 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6064 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6065 dcResult.mtu = dcResponse->mtu;
6068 void convertRilDataCallListToHal(void *response, size_t responseLen,
6069 hidl_vec<SetupDataCallResult>& dcResultList) {
6070 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6072 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6073 dcResultList.resize(num);
6074 for (int i = 0; i < num; i++) {
6075 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6079 int radio::dataCallListChangedInd(int slotId,
6080 int indicationType, int token, RIL_Errno e, void *response,
6081 size_t responseLen) {
6082 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6083 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
6084 RLOGE("dataCallListChangedInd: invalid response");
6087 hidl_vec<SetupDataCallResult> dcList;
6088 convertRilDataCallListToHal(response, responseLen, dcList);
6089 RLOGD("dataCallListChangedInd");
6090 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
6091 convertIntToRadioIndicationType(indicationType), dcList);
6092 radioService[slotId]->checkReturnStatus(retStatus);
6094 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6100 int radio::suppSvcNotifyInd(int slotId, int indicationType,
6101 int token, RIL_Errno e, void *response, size_t responseLen) {
6102 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6103 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
6104 RLOGE("suppSvcNotifyInd: invalid response");
6108 SuppSvcNotification suppSvc = {};
6109 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6110 suppSvc.isMT = ssn->notificationType;
6111 suppSvc.code = ssn->code;
6112 suppSvc.index = ssn->index;
6113 suppSvc.type = ssn->type;
6114 suppSvc.number = convertCharPtrToHidlString(ssn->number);
6116 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
6117 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
6118 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
6119 convertIntToRadioIndicationType(indicationType), suppSvc);
6120 radioService[slotId]->checkReturnStatus(retStatus);
6122 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6128 int radio::stkSessionEndInd(int slotId, int indicationType,
6129 int token, RIL_Errno e, void *response, size_t responseLen) {
6130 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6131 RLOGD("stkSessionEndInd");
6132 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
6133 convertIntToRadioIndicationType(indicationType));
6134 radioService[slotId]->checkReturnStatus(retStatus);
6136 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
6142 int radio::stkProactiveCommandInd(int slotId,
6143 int indicationType, int token, RIL_Errno e, void *response,
6144 size_t responseLen) {
6145 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6146 if (response == NULL || responseLen == 0) {
6147 RLOGE("stkProactiveCommandInd: invalid response");
6150 RLOGD("stkProactiveCommandInd");
6151 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
6152 convertIntToRadioIndicationType(indicationType),
6153 convertCharPtrToHidlString((char *) response));
6154 radioService[slotId]->checkReturnStatus(retStatus);
6156 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
6162 int radio::stkEventNotifyInd(int slotId, int indicationType,
6163 int token, RIL_Errno e, void *response, size_t responseLen) {
6164 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6165 if (response == NULL || responseLen == 0) {
6166 RLOGE("stkEventNotifyInd: invalid response");
6169 RLOGD("stkEventNotifyInd");
6170 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
6171 convertIntToRadioIndicationType(indicationType),
6172 convertCharPtrToHidlString((char *) response));
6173 radioService[slotId]->checkReturnStatus(retStatus);
6175 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6181 int radio::stkCallSetupInd(int slotId, int indicationType,
6182 int token, RIL_Errno e, void *response, size_t responseLen) {
6183 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6184 if (response == NULL || responseLen != sizeof(int)) {
6185 RLOGE("stkCallSetupInd: invalid response");
6188 int32_t timeout = ((int32_t *) response)[0];
6189 RLOGD("stkCallSetupInd: timeout %d", timeout);
6190 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
6191 convertIntToRadioIndicationType(indicationType), timeout);
6192 radioService[slotId]->checkReturnStatus(retStatus);
6194 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
6200 int radio::simSmsStorageFullInd(int slotId,
6201 int indicationType, int token, RIL_Errno e, void *response,
6202 size_t responseLen) {
6203 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6204 RLOGD("simSmsStorageFullInd");
6205 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
6206 convertIntToRadioIndicationType(indicationType));
6207 radioService[slotId]->checkReturnStatus(retStatus);
6209 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
6215 int radio::simRefreshInd(int slotId, int indicationType,
6216 int token, RIL_Errno e, void *response, size_t responseLen) {
6217 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6218 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
6219 RLOGE("simRefreshInd: invalid response");
6223 SimRefreshResult refreshResult = {};
6224 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
6225 refreshResult.type =
6226 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
6227 refreshResult.efId = simRefreshResponse->ef_id;
6228 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
6230 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
6231 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
6232 convertIntToRadioIndicationType(indicationType), refreshResult);
6233 radioService[slotId]->checkReturnStatus(retStatus);
6235 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
6241 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
6242 CdmaSignalInfoRecord& record) {
6243 record.isPresent = signalInfoRecord->isPresent;
6244 record.signalType = signalInfoRecord->signalType;
6245 record.alertPitch = signalInfoRecord->alertPitch;
6246 record.signal = signalInfoRecord->signal;
6249 int radio::callRingInd(int slotId, int indicationType,
6250 int token, RIL_Errno e, void *response, size_t responseLen) {
6251 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6253 CdmaSignalInfoRecord record = {};
6254 if (response == NULL || responseLen == 0) {
6258 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
6259 RLOGE("callRingInd: invalid response");
6262 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
6265 RLOGD("callRingInd: isGsm %d", isGsm);
6266 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
6267 convertIntToRadioIndicationType(indicationType), isGsm, record);
6268 radioService[slotId]->checkReturnStatus(retStatus);
6270 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
6276 int radio::simStatusChangedInd(int slotId,
6277 int indicationType, int token, RIL_Errno e, void *response,
6278 size_t responseLen) {
6279 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6280 RLOGD("simStatusChangedInd");
6281 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
6282 convertIntToRadioIndicationType(indicationType));
6283 radioService[slotId]->checkReturnStatus(retStatus);
6285 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6291 int radio::cdmaNewSmsInd(int slotId, int indicationType,
6292 int token, RIL_Errno e, void *response, size_t responseLen) {
6293 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6294 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
6295 RLOGE("cdmaNewSmsInd: invalid response");
6299 CdmaSmsMessage msg = {};
6300 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
6301 msg.teleserviceId = rilMsg->uTeleserviceID;
6302 msg.isServicePresent = rilMsg->bIsServicePresent;
6303 msg.serviceCategory = rilMsg->uServicecategory;
6304 msg.address.digitMode =
6305 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
6306 msg.address.numberMode =
6307 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
6308 msg.address.numberType =
6309 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
6310 msg.address.numberPlan =
6311 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
6313 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
6314 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
6316 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
6317 rilMsg->sSubAddress.subaddressType;
6318 msg.subAddress.odd = rilMsg->sSubAddress.odd;
6320 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
6321 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
6323 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
6324 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
6326 RLOGD("cdmaNewSmsInd");
6327 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
6328 convertIntToRadioIndicationType(indicationType), msg);
6329 radioService[slotId]->checkReturnStatus(retStatus);
6331 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6337 int radio::newBroadcastSmsInd(int slotId,
6338 int indicationType, int token, RIL_Errno e, void *response,
6339 size_t responseLen) {
6340 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6341 if (response == NULL || responseLen == 0) {
6342 RLOGE("newBroadcastSmsInd: invalid response");
6346 hidl_vec<uint8_t> data;
6347 data.setToExternal((uint8_t *) response, responseLen);
6348 RLOGD("newBroadcastSmsInd");
6349 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
6350 convertIntToRadioIndicationType(indicationType), data);
6351 radioService[slotId]->checkReturnStatus(retStatus);
6353 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6359 int radio::cdmaRuimSmsStorageFullInd(int slotId,
6360 int indicationType, int token, RIL_Errno e, void *response,
6361 size_t responseLen) {
6362 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6363 RLOGD("cdmaRuimSmsStorageFullInd");
6364 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
6365 convertIntToRadioIndicationType(indicationType));
6366 radioService[slotId]->checkReturnStatus(retStatus);
6368 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
6375 int radio::restrictedStateChangedInd(int slotId,
6376 int indicationType, int token, RIL_Errno e, void *response,
6377 size_t responseLen) {
6378 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6379 if (response == NULL || responseLen != sizeof(int)) {
6380 RLOGE("restrictedStateChangedInd: invalid response");
6383 int32_t state = ((int32_t *) response)[0];
6384 RLOGD("restrictedStateChangedInd: state %d", state);
6385 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
6386 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
6387 radioService[slotId]->checkReturnStatus(retStatus);
6389 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6396 int radio::enterEmergencyCallbackModeInd(int slotId,
6397 int indicationType, int token, RIL_Errno e, void *response,
6398 size_t responseLen) {
6399 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6400 RLOGD("enterEmergencyCallbackModeInd");
6401 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
6402 convertIntToRadioIndicationType(indicationType));
6403 radioService[slotId]->checkReturnStatus(retStatus);
6405 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
6412 int radio::cdmaCallWaitingInd(int slotId,
6413 int indicationType, int token, RIL_Errno e, void *response,
6414 size_t responseLen) {
6415 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6416 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
6417 RLOGE("cdmaCallWaitingInd: invalid response");
6421 CdmaCallWaiting callWaitingRecord = {};
6422 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
6423 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
6424 callWaitingRecord.numberPresentation =
6425 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
6426 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
6427 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
6428 callWaitingRecord.signalInfoRecord);
6429 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
6430 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
6432 RLOGD("cdmaCallWaitingInd");
6433 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
6434 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
6435 radioService[slotId]->checkReturnStatus(retStatus);
6437 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
6443 int radio::cdmaOtaProvisionStatusInd(int slotId,
6444 int indicationType, int token, RIL_Errno e, void *response,
6445 size_t responseLen) {
6446 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6447 if (response == NULL || responseLen != sizeof(int)) {
6448 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
6451 int32_t status = ((int32_t *) response)[0];
6452 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
6453 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
6454 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
6455 radioService[slotId]->checkReturnStatus(retStatus);
6457 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
6464 int radio::cdmaInfoRecInd(int slotId,
6465 int indicationType, int token, RIL_Errno e, void *response,
6466 size_t responseLen) {
6467 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6468 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
6469 RLOGE("cdmaInfoRecInd: invalid response");
6473 CdmaInformationRecords records = {};
6474 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
6476 char* string8 = NULL;
6477 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
6478 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
6479 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
6480 "additional ones", recordsRil->numberOfInfoRecs,
6481 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
6483 records.infoRec.resize(num);
6484 for (int i = 0 ; i < num ; i++) {
6485 CdmaInformationRecord *record = &records.infoRec[i];
6486 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
6487 record->name = (CdmaInfoRecName) infoRec->name;
6488 // All vectors should be size 0 except one which will be size 1. Set everything to
6489 // size 0 initially.
6490 record->display.resize(0);
6491 record->number.resize(0);
6492 record->signal.resize(0);
6493 record->redir.resize(0);
6494 record->lineCtrl.resize(0);
6495 record->clir.resize(0);
6496 record->audioCtrl.resize(0);
6497 switch (infoRec->name) {
6498 case RIL_CDMA_DISPLAY_INFO_REC:
6499 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
6500 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
6501 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
6502 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
6503 CDMA_ALPHA_INFO_BUFFER_LENGTH);
6506 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
6507 if (string8 == NULL) {
6508 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
6509 "responseCdmaInformationRecords");
6512 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
6513 string8[(int)infoRec->rec.display.alpha_len] = '\0';
6515 record->display.resize(1);
6516 record->display[0].alphaBuf = string8;
6522 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
6523 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
6524 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
6525 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
6526 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
6527 "expected not more than %d", (int) infoRec->rec.number.len,
6528 CDMA_NUMBER_INFO_BUFFER_LENGTH);
6531 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
6532 if (string8 == NULL) {
6533 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
6534 "responseCdmaInformationRecords");
6537 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
6538 string8[(int)infoRec->rec.number.len] = '\0';
6540 record->number.resize(1);
6541 record->number[0].number = string8;
6544 record->number[0].numberType = infoRec->rec.number.number_type;
6545 record->number[0].numberPlan = infoRec->rec.number.number_plan;
6546 record->number[0].pi = infoRec->rec.number.pi;
6547 record->number[0].si = infoRec->rec.number.si;
6551 case RIL_CDMA_SIGNAL_INFO_REC: {
6552 record->signal.resize(1);
6553 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
6554 record->signal[0].signalType = infoRec->rec.signal.signalType;
6555 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
6556 record->signal[0].signal = infoRec->rec.signal.signal;
6560 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
6561 if (infoRec->rec.redir.redirectingNumber.len >
6562 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
6563 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
6564 "expected not more than %d\n",
6565 (int)infoRec->rec.redir.redirectingNumber.len,
6566 CDMA_NUMBER_INFO_BUFFER_LENGTH);
6569 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
6571 if (string8 == NULL) {
6572 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
6573 "responseCdmaInformationRecords");
6576 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
6577 infoRec->rec.redir.redirectingNumber.len);
6578 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
6580 record->redir.resize(1);
6581 record->redir[0].redirectingNumber.number = string8;
6584 record->redir[0].redirectingNumber.numberType =
6585 infoRec->rec.redir.redirectingNumber.number_type;
6586 record->redir[0].redirectingNumber.numberPlan =
6587 infoRec->rec.redir.redirectingNumber.number_plan;
6588 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
6589 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
6590 record->redir[0].redirectingReason =
6591 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
6595 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
6596 record->lineCtrl.resize(1);
6597 record->lineCtrl[0].lineCtrlPolarityIncluded =
6598 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
6599 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
6600 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
6601 record->lineCtrl[0].lineCtrlPowerDenial =
6602 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
6606 case RIL_CDMA_T53_CLIR_INFO_REC: {
6607 record->clir.resize(1);
6608 record->clir[0].cause = infoRec->rec.clir.cause;
6612 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
6613 record->audioCtrl.resize(1);
6614 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
6615 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
6619 case RIL_CDMA_T53_RELEASE_INFO_REC:
6620 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
6624 RLOGE("cdmaInfoRecInd: Incorrect name value");
6629 RLOGD("cdmaInfoRecInd");
6630 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
6631 convertIntToRadioIndicationType(indicationType), records);
6632 radioService[slotId]->checkReturnStatus(retStatus);
6634 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
6640 int radio::indicateRingbackToneInd(int slotId,
6641 int indicationType, int token, RIL_Errno e, void *response,
6642 size_t responseLen) {
6643 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6644 if (response == NULL || responseLen != sizeof(int)) {
6645 RLOGE("indicateRingbackToneInd: invalid response");
6648 bool start = ((int32_t *) response)[0];
6649 RLOGD("indicateRingbackToneInd: start %d", start);
6650 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
6651 convertIntToRadioIndicationType(indicationType), start);
6652 radioService[slotId]->checkReturnStatus(retStatus);
6654 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
6660 int radio::resendIncallMuteInd(int slotId,
6661 int indicationType, int token, RIL_Errno e, void *response,
6662 size_t responseLen) {
6663 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6664 RLOGD("resendIncallMuteInd");
6665 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
6666 convertIntToRadioIndicationType(indicationType));
6667 radioService[slotId]->checkReturnStatus(retStatus);
6669 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
6675 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
6676 int indicationType, int token, RIL_Errno e,
6677 void *response, size_t responseLen) {
6678 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6679 if (response == NULL || responseLen != sizeof(int)) {
6680 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
6683 int32_t cdmaSource = ((int32_t *) response)[0];
6684 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
6685 Return<void> retStatus = radioService[slotId]->mRadioIndication->
6686 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
6687 (CdmaSubscriptionSource) cdmaSource);
6688 radioService[slotId]->checkReturnStatus(retStatus);
6690 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
6697 int radio::cdmaPrlChangedInd(int slotId,
6698 int indicationType, int token, RIL_Errno e, void *response,
6699 size_t responseLen) {
6700 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6701 if (response == NULL || responseLen != sizeof(int)) {
6702 RLOGE("cdmaPrlChangedInd: invalid response");
6705 int32_t version = ((int32_t *) response)[0];
6706 RLOGD("cdmaPrlChangedInd: version %d", version);
6707 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
6708 convertIntToRadioIndicationType(indicationType), version);
6709 radioService[slotId]->checkReturnStatus(retStatus);
6711 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6717 int radio::exitEmergencyCallbackModeInd(int slotId,
6718 int indicationType, int token, RIL_Errno e, void *response,
6719 size_t responseLen) {
6720 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6721 RLOGD("exitEmergencyCallbackModeInd");
6722 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
6723 convertIntToRadioIndicationType(indicationType));
6724 radioService[slotId]->checkReturnStatus(retStatus);
6726 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
6733 int radio::rilConnectedInd(int slotId,
6734 int indicationType, int token, RIL_Errno e, void *response,
6735 size_t responseLen) {
6736 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6737 RLOGD("rilConnectedInd");
6738 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
6739 convertIntToRadioIndicationType(indicationType));
6740 radioService[slotId]->checkReturnStatus(retStatus);
6742 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6748 int radio::voiceRadioTechChangedInd(int slotId,
6749 int indicationType, int token, RIL_Errno e, void *response,
6750 size_t responseLen) {
6751 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6752 if (response == NULL || responseLen != sizeof(int)) {
6753 RLOGE("voiceRadioTechChangedInd: invalid response");
6756 int32_t rat = ((int32_t *) response)[0];
6757 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
6758 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
6759 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
6760 radioService[slotId]->checkReturnStatus(retStatus);
6762 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
6769 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
6770 int num = responseLen / sizeof(RIL_CellInfo_v12);
6771 records.resize(num);
6773 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
6774 for (int i = 0; i < num; i++) {
6775 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
6776 records[i].registered = rillCellInfo->registered;
6777 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
6778 records[i].timeStamp = rillCellInfo->timeStamp;
6779 // All vectors should be size 0 except one which will be size 1. Set everything to
6780 // size 0 initially.
6781 records[i].gsm.resize(0);
6782 records[i].wcdma.resize(0);
6783 records[i].cdma.resize(0);
6784 records[i].lte.resize(0);
6785 records[i].tdscdma.resize(0);
6786 switch(rillCellInfo->cellInfoType) {
6787 case RIL_CELL_INFO_TYPE_GSM: {
6788 records[i].gsm.resize(1);
6789 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
6790 cellInfoGsm->cellIdentityGsm.mcc =
6791 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
6792 cellInfoGsm->cellIdentityGsm.mnc =
6793 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
6794 cellInfoGsm->cellIdentityGsm.lac =
6795 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
6796 cellInfoGsm->cellIdentityGsm.cid =
6797 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
6798 cellInfoGsm->cellIdentityGsm.arfcn =
6799 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
6800 cellInfoGsm->cellIdentityGsm.bsic =
6801 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
6802 cellInfoGsm->signalStrengthGsm.signalStrength =
6803 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
6804 cellInfoGsm->signalStrengthGsm.bitErrorRate =
6805 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
6806 cellInfoGsm->signalStrengthGsm.timingAdvance =
6807 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
6811 case RIL_CELL_INFO_TYPE_WCDMA: {
6812 records[i].wcdma.resize(1);
6813 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
6814 cellInfoWcdma->cellIdentityWcdma.mcc =
6815 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
6816 cellInfoWcdma->cellIdentityWcdma.mnc =
6817 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
6818 cellInfoWcdma->cellIdentityWcdma.lac =
6819 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
6820 cellInfoWcdma->cellIdentityWcdma.cid =
6821 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
6822 cellInfoWcdma->cellIdentityWcdma.psc =
6823 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
6824 cellInfoWcdma->cellIdentityWcdma.uarfcn =
6825 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
6826 cellInfoWcdma->signalStrengthWcdma.signalStrength =
6827 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
6828 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
6829 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
6833 case RIL_CELL_INFO_TYPE_CDMA: {
6834 records[i].cdma.resize(1);
6835 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
6836 cellInfoCdma->cellIdentityCdma.networkId =
6837 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
6838 cellInfoCdma->cellIdentityCdma.systemId =
6839 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
6840 cellInfoCdma->cellIdentityCdma.baseStationId =
6841 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
6842 cellInfoCdma->cellIdentityCdma.longitude =
6843 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
6844 cellInfoCdma->cellIdentityCdma.latitude =
6845 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
6846 cellInfoCdma->signalStrengthCdma.dbm =
6847 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
6848 cellInfoCdma->signalStrengthCdma.ecio =
6849 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
6850 cellInfoCdma->signalStrengthEvdo.dbm =
6851 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
6852 cellInfoCdma->signalStrengthEvdo.ecio =
6853 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
6854 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
6855 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
6859 case RIL_CELL_INFO_TYPE_LTE: {
6860 records[i].lte.resize(1);
6861 CellInfoLte *cellInfoLte = &records[i].lte[0];
6862 cellInfoLte->cellIdentityLte.mcc =
6863 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
6864 cellInfoLte->cellIdentityLte.mnc =
6865 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
6866 cellInfoLte->cellIdentityLte.ci =
6867 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
6868 cellInfoLte->cellIdentityLte.pci =
6869 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
6870 cellInfoLte->cellIdentityLte.tac =
6871 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
6872 cellInfoLte->cellIdentityLte.earfcn =
6873 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
6874 cellInfoLte->signalStrengthLte.signalStrength =
6875 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
6876 cellInfoLte->signalStrengthLte.rsrp =
6877 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
6878 cellInfoLte->signalStrengthLte.rsrq =
6879 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
6880 cellInfoLte->signalStrengthLte.rssnr =
6881 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
6882 cellInfoLte->signalStrengthLte.cqi =
6883 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
6884 cellInfoLte->signalStrengthLte.timingAdvance =
6885 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
6889 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
6890 records[i].tdscdma.resize(1);
6891 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
6892 cellInfoTdscdma->cellIdentityTdscdma.mcc =
6893 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
6894 cellInfoTdscdma->cellIdentityTdscdma.mnc =
6895 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
6896 cellInfoTdscdma->cellIdentityTdscdma.lac =
6897 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
6898 cellInfoTdscdma->cellIdentityTdscdma.cid =
6899 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
6900 cellInfoTdscdma->cellIdentityTdscdma.cpid =
6901 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
6902 cellInfoTdscdma->signalStrengthTdscdma.rscp =
6903 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
6914 int radio::cellInfoListInd(int slotId,
6915 int indicationType, int token, RIL_Errno e, void *response,
6916 size_t responseLen) {
6917 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6918 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
6919 RLOGE("cellInfoListInd: invalid response");
6923 hidl_vec<CellInfo> records;
6924 convertRilCellInfoListToHal(response, responseLen, records);
6926 RLOGD("cellInfoListInd");
6927 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
6928 convertIntToRadioIndicationType(indicationType), records);
6929 radioService[slotId]->checkReturnStatus(retStatus);
6931 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
6937 int radio::imsNetworkStateChangedInd(int slotId,
6938 int indicationType, int token, RIL_Errno e, void *response,
6939 size_t responseLen) {
6940 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6941 RLOGD("imsNetworkStateChangedInd");
6942 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
6943 convertIntToRadioIndicationType(indicationType));
6944 radioService[slotId]->checkReturnStatus(retStatus);
6946 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6953 int radio::subscriptionStatusChangedInd(int slotId,
6954 int indicationType, int token, RIL_Errno e, void *response,
6955 size_t responseLen) {
6956 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6957 if (response == NULL || responseLen != sizeof(int)) {
6958 RLOGE("subscriptionStatusChangedInd: invalid response");
6961 bool activate = ((int32_t *) response)[0];
6962 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
6963 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
6964 convertIntToRadioIndicationType(indicationType), activate);
6965 radioService[slotId]->checkReturnStatus(retStatus);
6967 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
6974 int radio::srvccStateNotifyInd(int slotId,
6975 int indicationType, int token, RIL_Errno e, void *response,
6976 size_t responseLen) {
6977 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6978 if (response == NULL || responseLen != sizeof(int)) {
6979 RLOGE("srvccStateNotifyInd: invalid response");
6982 int32_t state = ((int32_t *) response)[0];
6983 RLOGD("srvccStateNotifyInd: rat %d", state);
6984 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
6985 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
6986 radioService[slotId]->checkReturnStatus(retStatus);
6988 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6994 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
6995 hidl_vec<HardwareConfig>& records) {
6996 int num = responseLen / sizeof(RIL_HardwareConfig);
6997 records.resize(num);
6999 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7000 for (int i = 0; i < num; i++) {
7001 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7002 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7003 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7004 switch (rilHardwareConfig[i].type) {
7005 case RIL_HARDWARE_CONFIG_MODEM: {
7006 records[i].modem.resize(1);
7007 records[i].sim.resize(0);
7008 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7009 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7010 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7011 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7012 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7016 case RIL_HARDWARE_CONFIG_SIM: {
7017 records[i].sim.resize(1);
7018 records[i].modem.resize(0);
7019 records[i].sim[0].modemUuid =
7020 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7027 int radio::hardwareConfigChangedInd(int slotId,
7028 int indicationType, int token, RIL_Errno e, void *response,
7029 size_t responseLen) {
7030 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7031 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7032 RLOGE("hardwareConfigChangedInd: invalid response");
7036 hidl_vec<HardwareConfig> configs;
7037 convertRilHardwareConfigListToHal(response, responseLen, configs);
7039 RLOGD("hardwareConfigChangedInd");
7040 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
7041 convertIntToRadioIndicationType(indicationType), configs);
7042 radioService[slotId]->checkReturnStatus(retStatus);
7044 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
7051 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7052 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7053 rc.session = rilRadioCapability->session;
7054 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7055 rc.raf = rilRadioCapability->rat;
7056 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7057 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
7060 int radio::radioCapabilityIndicationInd(int slotId,
7061 int indicationType, int token, RIL_Errno e, void *response,
7062 size_t responseLen) {
7063 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7064 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
7065 RLOGE("radioCapabilityIndicationInd: invalid response");
7069 RadioCapability rc = {};
7070 convertRilRadioCapabilityToHal(response, responseLen, rc);
7072 RLOGD("radioCapabilityIndicationInd");
7073 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
7074 convertIntToRadioIndicationType(indicationType), rc);
7075 radioService[slotId]->checkReturnStatus(retStatus);
7077 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
7084 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
7085 if ((reqType == SS_INTERROGATION) &&
7086 (serType == SS_CFU ||
7087 serType == SS_CF_BUSY ||
7088 serType == SS_CF_NO_REPLY ||
7089 serType == SS_CF_NOT_REACHABLE ||
7090 serType == SS_CF_ALL ||
7091 serType == SS_CF_ALL_CONDITIONAL)) {
7097 int radio::onSupplementaryServiceIndicationInd(int slotId,
7098 int indicationType, int token, RIL_Errno e,
7099 void *response, size_t responseLen) {
7100 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7101 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
7102 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
7106 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
7107 StkCcUnsolSsResult ss = {};
7108 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
7109 ss.requestType = (SsRequestType) rilSsResponse->requestType;
7110 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
7111 ss.serviceClass = rilSsResponse->serviceClass;
7112 ss.result = (RadioError) rilSsResponse->result;
7114 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
7115 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
7116 rilSsResponse->cfData.numValidIndexes);
7117 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
7118 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
7119 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
7120 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
7123 ss.cfData.resize(1);
7124 ss.ssInfo.resize(0);
7126 /* number of call info's */
7127 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
7129 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
7130 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
7131 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
7133 cfInfo->status = (CallForwardInfoStatus) cf.status;
7134 cfInfo->reason = cf.reason;
7135 cfInfo->serviceClass = cf.serviceClass;
7136 cfInfo->toa = cf.toa;
7137 cfInfo->number = convertCharPtrToHidlString(cf.number);
7138 cfInfo->timeSeconds = cf.timeSeconds;
7139 RLOGD("onSupplementaryServiceIndicationInd: "
7140 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
7141 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
7144 ss.ssInfo.resize(1);
7145 ss.cfData.resize(0);
7148 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
7149 for (int i = 0; i < SS_INFO_MAX; i++) {
7150 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
7151 rilSsResponse->ssInfo[i]);
7152 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
7156 RLOGD("onSupplementaryServiceIndicationInd");
7157 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7158 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
7160 radioService[slotId]->checkReturnStatus(retStatus);
7162 RLOGE("onSupplementaryServiceIndicationInd: "
7163 "radioService[%d]->mRadioIndication == NULL", slotId);
7169 int radio::stkCallControlAlphaNotifyInd(int slotId,
7170 int indicationType, int token, RIL_Errno e, void *response,
7171 size_t responseLen) {
7172 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7173 if (response == NULL || responseLen == 0) {
7174 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
7177 RLOGD("stkCallControlAlphaNotifyInd");
7178 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
7179 convertIntToRadioIndicationType(indicationType),
7180 convertCharPtrToHidlString((char *) response));
7181 radioService[slotId]->checkReturnStatus(retStatus);
7183 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
7190 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
7191 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
7192 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
7193 lce.confidenceLevel = rilLceDataInfo->confidence_level;
7194 lce.lceSuspended = rilLceDataInfo->lce_suspended;
7197 int radio::lceDataInd(int slotId,
7198 int indicationType, int token, RIL_Errno e, void *response,
7199 size_t responseLen) {
7200 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7201 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
7202 RLOGE("lceDataInd: invalid response");
7206 LceDataInfo lce = {};
7207 convertRilLceDataInfoToHal(response, responseLen, lce);
7208 RLOGD("lceDataInd");
7209 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
7210 convertIntToRadioIndicationType(indicationType), lce);
7211 radioService[slotId]->checkReturnStatus(retStatus);
7213 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7219 int radio::pcoDataInd(int slotId,
7220 int indicationType, int token, RIL_Errno e, void *response,
7221 size_t responseLen) {
7222 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7223 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
7224 RLOGE("pcoDataInd: invalid response");
7228 PcoDataInfo pco = {};
7229 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
7230 pco.cid = rilPcoData->cid;
7231 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
7232 pco.pcoId = rilPcoData->pco_id;
7233 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
7235 RLOGD("pcoDataInd");
7236 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
7237 convertIntToRadioIndicationType(indicationType), pco);
7238 radioService[slotId]->checkReturnStatus(retStatus);
7240 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7246 int radio::modemResetInd(int slotId,
7247 int indicationType, int token, RIL_Errno e, void *response,
7248 size_t responseLen) {
7249 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7250 if (response == NULL || responseLen == 0) {
7251 RLOGE("modemResetInd: invalid response");
7254 RLOGD("modemResetInd");
7255 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
7256 convertIntToRadioIndicationType(indicationType),
7257 convertCharPtrToHidlString((char *) response));
7258 radioService[slotId]->checkReturnStatus(retStatus);
7260 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
7266 int radio::oemHookRawInd(int slotId,
7267 int indicationType, int token, RIL_Errno e, void *response,
7268 size_t responseLen) {
7269 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
7270 if (response == NULL || responseLen == 0) {
7271 RLOGE("oemHookRawInd: invalid response");
7275 hidl_vec<uint8_t> data;
7276 data.setToExternal((uint8_t *) response, responseLen);
7277 RLOGD("oemHookRawInd");
7278 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
7279 convertIntToRadioIndicationType(indicationType), data);
7280 checkReturnStatus(slotId, retStatus);
7282 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
7288 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
7289 using namespace android::hardware;
7291 const char *serviceNames[] = {
7292 android::RIL_getRilSocketName()
7293 #if (SIM_COUNT >= 2)
7295 #if (SIM_COUNT >= 3)
7297 #if (SIM_COUNT >= 4)
7304 const char *oemHookServiceNames[] = {
7305 OEM_HOOK_SERVICE_NAME
7306 #if (SIM_COUNT >= 2)
7307 , OEM_HOOK2_SERVICE_NAME
7308 #if (SIM_COUNT >= 3)
7309 , OEM_HOOK3_SERVICE_NAME
7310 #if (SIM_COUNT >= 4)
7311 , OEM_HOOK4_SERVICE_NAME
7317 #if (SIM_COUNT >= 2)
7318 simCount = SIM_COUNT;
7321 configureRpcThreadpool(1, true /* callerWillJoin */);
7322 for (int i = 0; i < simCount; i++) {
7323 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
7324 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
7327 radioService[i] = new RadioImpl;
7328 radioService[i]->mSlotId = i;
7329 oemHookService[i] = new OemHookImpl;
7330 oemHookService[i]->mSlotId = i;
7331 RLOGD("registerService: starting IRadio %s", serviceNames[i]);
7332 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
7333 status = oemHookService[i]->registerAsService(oemHookServiceNames[i]);
7335 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
7339 s_vendorFunctions = callbacks;
7340 s_commands = commands;
7343 void rilc_thread_pool() {
7344 joinRpcThreadpool();
7347 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
7348 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
7350 #if (SIM_COUNT >= 2)
7351 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
7352 #if (SIM_COUNT >= 3)
7353 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
7354 #if (SIM_COUNT >= 4)
7355 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
7360 return radioServiceRwlockPtr;