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::Status;
37 using ::android::hardware::hidl_string;
38 using ::android::hardware::hidl_vec;
39 using ::android::hardware::hidl_array;
40 using ::android::hardware::Void;
41 using android::CommandInfo;
42 using android::RequestInfo;
43 using android::requestToString;
46 #define BOOL_TO_INT(x) (x ? 1 : 0)
47 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
48 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
50 RIL_RadioFunctions *s_vendorFunctions = NULL;
51 static CommandInfo *s_commands;
57 sp<RadioImpl> radioService[SIM_COUNT];
58 sp<OemHookImpl> oemHookService[SIM_COUNT];
59 // counter used for synchronization. It is incremented every time response callbacks are updated.
60 volatile int32_t mCounterRadio[SIM_COUNT];
61 volatile int32_t mCounterOemHook[SIM_COUNT];
63 sp<RadioImpl> radioService[1];
64 sp<OemHookImpl> oemHookService[1];
65 // counter used for synchronization. It is incremented every time response callbacks are updated.
66 volatile int32_t mCounterRadio[1];
67 volatile int32_t mCounterOemHook[1];
70 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
73 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
75 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
77 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
82 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
83 hidl_vec<HardwareConfig>& records);
85 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
87 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
89 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
90 SignalStrength& signalStrength);
92 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
93 SetupDataCallResult& dcResult);
95 void convertRilDataCallListToHal(void *response, size_t responseLen,
96 hidl_vec<SetupDataCallResult>& dcResultList);
98 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
100 struct RadioImpl : public IRadio {
102 sp<IRadioResponse> mRadioResponse;
103 sp<IRadioIndication> mRadioIndication;
105 Return<void> setResponseFunctions(
106 const ::android::sp<IRadioResponse>& radioResponse,
107 const ::android::sp<IRadioIndication>& radioIndication);
109 Return<void> getIccCardStatus(int32_t serial);
111 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
112 const hidl_string& aid);
114 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
115 const hidl_string& pin, const hidl_string& aid);
117 Return<void> supplyIccPin2ForApp(int32_t serial,
118 const hidl_string& pin2,
119 const hidl_string& aid);
121 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
122 const hidl_string& pin2, const hidl_string& aid);
124 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
125 const hidl_string& newPin, const hidl_string& aid);
127 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
128 const hidl_string& newPin2, const hidl_string& aid);
130 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
132 Return<void> getCurrentCalls(int32_t serial);
134 Return<void> dial(int32_t serial, const Dial& dialInfo);
136 Return<void> getImsiForApp(int32_t serial,
137 const ::android::hardware::hidl_string& aid);
139 Return<void> hangup(int32_t serial, int32_t gsmIndex);
141 Return<void> hangupWaitingOrBackground(int32_t serial);
143 Return<void> hangupForegroundResumeBackground(int32_t serial);
145 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
147 Return<void> conference(int32_t serial);
149 Return<void> rejectCall(int32_t serial);
151 Return<void> getLastCallFailCause(int32_t serial);
153 Return<void> getSignalStrength(int32_t serial);
155 Return<void> getVoiceRegistrationState(int32_t serial);
157 Return<void> getDataRegistrationState(int32_t serial);
159 Return<void> getOperator(int32_t serial);
161 Return<void> setRadioPower(int32_t serial, bool on);
163 Return<void> sendDtmf(int32_t serial,
164 const ::android::hardware::hidl_string& s);
166 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
168 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
170 Return<void> setupDataCall(int32_t serial,
171 RadioTechnology radioTechnology,
172 const DataProfileInfo& profileInfo,
177 Return<void> iccIOForApp(int32_t serial,
180 Return<void> sendUssd(int32_t serial,
181 const ::android::hardware::hidl_string& ussd);
183 Return<void> cancelPendingUssd(int32_t serial);
185 Return<void> getClir(int32_t serial);
187 Return<void> setClir(int32_t serial, int32_t status);
189 Return<void> getCallForwardStatus(int32_t serial,
190 const CallForwardInfo& callInfo);
192 Return<void> setCallForward(int32_t serial,
193 const CallForwardInfo& callInfo);
195 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
197 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
199 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
200 bool success, SmsAcknowledgeFailCause cause);
202 Return<void> acceptCall(int32_t serial);
204 Return<void> deactivateDataCall(int32_t serial,
205 int32_t cid, bool reasonRadioShutDown);
207 Return<void> getFacilityLockForApp(int32_t serial,
208 const ::android::hardware::hidl_string& facility,
209 const ::android::hardware::hidl_string& password,
210 int32_t serviceClass,
211 const ::android::hardware::hidl_string& appId);
213 Return<void> setFacilityLockForApp(int32_t serial,
214 const ::android::hardware::hidl_string& facility,
216 const ::android::hardware::hidl_string& password,
217 int32_t serviceClass,
218 const ::android::hardware::hidl_string& appId);
220 Return<void> setBarringPassword(int32_t serial,
221 const ::android::hardware::hidl_string& facility,
222 const ::android::hardware::hidl_string& oldPassword,
223 const ::android::hardware::hidl_string& newPassword);
225 Return<void> getNetworkSelectionMode(int32_t serial);
227 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
229 Return<void> setNetworkSelectionModeManual(int32_t serial,
230 const ::android::hardware::hidl_string& operatorNumeric);
232 Return<void> getAvailableNetworks(int32_t serial);
234 Return<void> startDtmf(int32_t serial,
235 const ::android::hardware::hidl_string& s);
237 Return<void> stopDtmf(int32_t serial);
239 Return<void> getBasebandVersion(int32_t serial);
241 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
243 Return<void> setMute(int32_t serial, bool enable);
245 Return<void> getMute(int32_t serial);
247 Return<void> getClip(int32_t serial);
249 Return<void> getDataCallList(int32_t serial);
251 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
253 Return<void> writeSmsToSim(int32_t serial,
254 const SmsWriteArgs& smsWriteArgs);
256 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
258 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
260 Return<void> getAvailableBandModes(int32_t serial);
262 Return<void> sendEnvelope(int32_t serial,
263 const ::android::hardware::hidl_string& command);
265 Return<void> sendTerminalResponseToSim(int32_t serial,
266 const ::android::hardware::hidl_string& commandResponse);
268 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
270 Return<void> explicitCallTransfer(int32_t serial);
272 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
274 Return<void> getPreferredNetworkType(int32_t serial);
276 Return<void> getNeighboringCids(int32_t serial);
278 Return<void> setLocationUpdates(int32_t serial, bool enable);
280 Return<void> setCdmaSubscriptionSource(int32_t serial,
281 CdmaSubscriptionSource cdmaSub);
283 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
285 Return<void> getCdmaRoamingPreference(int32_t serial);
287 Return<void> setTTYMode(int32_t serial, TtyMode mode);
289 Return<void> getTTYMode(int32_t serial);
291 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
293 Return<void> getPreferredVoicePrivacy(int32_t serial);
295 Return<void> sendCDMAFeatureCode(int32_t serial,
296 const ::android::hardware::hidl_string& featureCode);
298 Return<void> sendBurstDtmf(int32_t serial,
299 const ::android::hardware::hidl_string& dtmf,
303 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
305 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
306 const CdmaSmsAck& smsAck);
308 Return<void> getGsmBroadcastConfig(int32_t serial);
310 Return<void> setGsmBroadcastConfig(int32_t serial,
311 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
313 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
315 Return<void> getCdmaBroadcastConfig(int32_t serial);
317 Return<void> setCdmaBroadcastConfig(int32_t serial,
318 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
320 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
322 Return<void> getCDMASubscription(int32_t serial);
324 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
326 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
328 Return<void> getDeviceIdentity(int32_t serial);
330 Return<void> exitEmergencyCallbackMode(int32_t serial);
332 Return<void> getSmscAddress(int32_t serial);
334 Return<void> setSmscAddress(int32_t serial,
335 const ::android::hardware::hidl_string& smsc);
337 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
339 Return<void> reportStkServiceIsRunning(int32_t serial);
341 Return<void> getCdmaSubscriptionSource(int32_t serial);
343 Return<void> requestIsimAuthentication(int32_t serial,
344 const ::android::hardware::hidl_string& challenge);
346 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
348 const ::android::hardware::hidl_string& ackPdu);
350 Return<void> sendEnvelopeWithStatus(int32_t serial,
351 const ::android::hardware::hidl_string& contents);
353 Return<void> getVoiceRadioTechnology(int32_t serial);
355 Return<void> getCellInfoList(int32_t serial);
357 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
359 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
360 bool modemCognitive, bool isRoaming);
362 Return<void> getImsRegistrationState(int32_t serial);
364 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
366 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
368 Return<void> iccOpenLogicalChannel(int32_t serial,
369 const ::android::hardware::hidl_string& aid);
371 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
373 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
375 Return<void> nvReadItem(int32_t serial, NvItem itemId);
377 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
379 Return<void> nvWriteCdmaPrl(int32_t serial,
380 const ::android::hardware::hidl_vec<uint8_t>& prl);
382 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
384 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
386 Return<void> setDataAllowed(int32_t serial, bool allow);
388 Return<void> getHardwareConfig(int32_t serial);
390 Return<void> requestIccSimAuthentication(int32_t serial,
392 const ::android::hardware::hidl_string& authData,
393 const ::android::hardware::hidl_string& aid);
395 Return<void> setDataProfile(int32_t serial,
396 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
398 Return<void> requestShutdown(int32_t serial);
400 Return<void> getRadioCapability(int32_t serial);
402 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
404 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
406 Return<void> stopLceService(int32_t serial);
408 Return<void> pullLceData(int32_t serial);
410 Return<void> getModemActivityInfo(int32_t serial);
412 Return<void> setAllowedCarriers(int32_t serial,
414 const CarrierRestrictions& carriers);
416 Return<void> getAllowedCarriers(int32_t serial);
418 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
420 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
422 Return<void> setSimCardPower(int32_t serial, bool powerUp);
424 Return<void> responseAcknowledgement();
426 void checkReturnStatus(Return<void>& ret);
429 struct OemHookImpl : public IOemHook {
431 sp<IOemHookResponse> mOemHookResponse;
432 sp<IOemHookIndication> mOemHookIndication;
434 Return<void> setResponseFunctions(
435 const ::android::sp<IOemHookResponse>& oemHookResponse,
436 const ::android::sp<IOemHookIndication>& oemHookIndication);
438 Return<void> sendRequestRaw(int32_t serial,
439 const ::android::hardware::hidl_vec<uint8_t>& data);
441 Return<void> sendRequestStrings(int32_t serial,
442 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
445 void memsetAndFreeStrings(int numPointers, ...) {
447 va_start(ap, numPointers);
448 for (int i = 0; i < numPointers; i++) {
449 char *ptr = va_arg(ap, char *);
452 // TODO: Should pass in the maximum length of the string
461 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
462 pRI->pCI->responseFunction((int) pRI->socket_id,
463 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
467 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
468 * request with error RIL_E_NO_MEMORY.
469 * Returns true on success, and false on failure.
471 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
472 size_t len = src.size();
477 *dest = (char *) calloc(len + 1, sizeof(char));
479 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
480 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
483 strncpy(*dest, src, len + 1);
487 hidl_string convertCharPtrToHidlString(const char *ptr) {
490 // TODO: replace this with strnlen
491 ret.setToExternal(ptr, strlen(ptr));
496 bool dispatchVoid(int serial, int slotId, int request) {
497 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
501 s_vendorFunctions->onRequest(request, NULL, 0, pRI);
505 bool dispatchString(int serial, int slotId, int request, const char * str) {
506 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
512 if (!copyHidlStringToRil(&pString, str, pRI)) {
516 s_vendorFunctions->onRequest(request, pString, sizeof(char *), pRI);
518 memsetAndFreeStrings(1, pString);
522 bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) {
523 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
529 pStrings = (char **)calloc(countStrings, sizeof(char *));
530 if (pStrings == NULL) {
531 RLOGE("Memory allocation failed for request %s", requestToString(request));
532 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
536 va_start(ap, countStrings);
537 for (int i = 0; i < countStrings; i++) {
538 const char* str = va_arg(ap, const char *);
539 if (!copyHidlStringToRil(&pStrings[i], str, pRI)) {
541 for (int j = 0; j < i; j++) {
542 memsetAndFreeStrings(1, pStrings[j]);
550 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
552 if (pStrings != NULL) {
553 for (int i = 0 ; i < countStrings ; i++) {
554 memsetAndFreeStrings(1, pStrings[i]);
558 memset(pStrings, 0, countStrings * sizeof(char *));
565 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
566 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
571 int countStrings = data.size();
573 pStrings = (char **)calloc(countStrings, sizeof(char *));
574 if (pStrings == NULL) {
575 RLOGE("Memory allocation failed for request %s", requestToString(request));
576 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
580 for (int i = 0; i < countStrings; i++) {
581 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
582 for (int j = 0; j < i; j++) {
583 memsetAndFreeStrings(1, pStrings[j]);
590 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
592 if (pStrings != NULL) {
593 for (int i = 0 ; i < countStrings ; i++) {
594 memsetAndFreeStrings(1, pStrings[i]);
598 memset(pStrings, 0, countStrings * sizeof(char *));
605 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
606 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
611 int *pInts = (int *)calloc(countInts, sizeof(int));
614 RLOGE("Memory allocation failed for request %s", requestToString(request));
615 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
619 va_start(ap, countInts);
620 for (int i = 0; i < countInts; i++) {
621 pInts[i] = va_arg(ap, int);
625 s_vendorFunctions->onRequest(request, pInts, countInts * sizeof(int), pRI);
629 memset(pInts, 0, countInts * sizeof(int));
636 bool dispatchCallForwardStatus(int serial, int slotId, int request,
637 const CallForwardInfo& callInfo) {
638 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
643 RIL_CallForwardInfo cf;
644 cf.status = (int) callInfo.status;
645 cf.reason = callInfo.reason;
646 cf.serviceClass = callInfo.serviceClass;
647 cf.toa = callInfo.toa;
648 cf.timeSeconds = callInfo.timeSeconds;
650 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
654 s_vendorFunctions->onRequest(request, &cf, sizeof(cf), pRI);
656 memsetAndFreeStrings(1, cf.number);
661 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
662 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
667 const uint8_t *uData = rawBytes.data();
669 s_vendorFunctions->onRequest(request, (void *) uData, rawBytes.size(), pRI);
674 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
675 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
681 memset (&apdu, 0, sizeof(RIL_SIM_APDU));
683 apdu.sessionid = message.sessionId;
684 apdu.cla = message.cla;
685 apdu.instruction = message.instruction;
686 apdu.p1 = message.p1;
687 apdu.p2 = message.p2;
688 apdu.p3 = message.p3;
690 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
694 s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI);
696 memsetAndFreeStrings(1, apdu.data);
701 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
702 if (ret.isOk() == false) {
703 RLOGE("checkReturnStatus: unable to call response/indication callback");
704 // Remote process hosting the callbacks must be dead. Reset the callback objects;
705 // there's no other recovery to be done here. When the client process is back up, it will
706 // call setResponseFunctions()
708 // Caller should already hold rdlock, release that first
709 // note the current counter to avoid overwriting updates made by another thread before
710 // write lock is acquired.
711 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
712 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
713 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
717 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
720 // make sure the counter value has not changed
721 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
722 if (isRadioService) {
723 radioService[slotId]->mRadioResponse = NULL;
724 radioService[slotId]->mRadioIndication = NULL;
726 oemHookService[slotId]->mOemHookResponse = NULL;
727 oemHookService[slotId]->mOemHookIndication = NULL;
729 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
731 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
732 "got updated on another thread");
736 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
740 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
745 void RadioImpl::checkReturnStatus(Return<void>& ret) {
746 ::checkReturnStatus(mSlotId, ret, true);
749 Return<void> RadioImpl::setResponseFunctions(
750 const ::android::sp<IRadioResponse>& radioResponseParam,
751 const ::android::sp<IRadioIndication>& radioIndicationParam) {
752 RLOGD("setResponseFunctions");
754 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
755 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
758 mRadioResponse = radioResponseParam;
759 mRadioIndication = radioIndicationParam;
760 mCounterRadio[mSlotId]++;
762 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
768 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
769 RLOGD("getIccCardStatus: serial %d", serial);
770 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
774 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
775 const hidl_string& aid) {
776 RLOGD("supplyIccPinForApp: serial %d", serial);
777 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
778 2, (const char *)pin, (const char *)aid);
782 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
783 const hidl_string& pin, const hidl_string& aid) {
784 RLOGD("supplyIccPukForApp: serial %d", serial);
785 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
786 3, (const char *)puk, (const char *)pin, (const char *)aid);
790 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
791 const hidl_string& aid) {
792 RLOGD("supplyIccPin2ForApp: serial %d", serial);
793 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
794 2, (const char *)pin2, (const char *)aid);
798 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
799 const hidl_string& pin2, const hidl_string& aid) {
800 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
801 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
802 3, (const char *)puk2, (const char *)pin2, (const char *)aid);
806 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
807 const hidl_string& newPin, const hidl_string& aid) {
808 RLOGD("changeIccPinForApp: serial %d", serial);
809 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
810 3, (const char *)oldPin, (const char *)newPin, (const char *)aid);
814 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
815 const hidl_string& newPin2, const hidl_string& aid) {
816 RLOGD("changeIccPin2ForApp: serial %d", serial);
817 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
818 3, (const char *)oldPin2, (const char *)newPin2, (const char *)aid);
822 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
823 const hidl_string& netPin) {
824 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
825 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
826 1, (const char *)netPin);
830 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
831 RLOGD("getCurrentCalls: serial %d", serial);
832 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
836 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
837 RLOGD("dial: serial %d", serial);
838 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
843 RIL_UUS_Info uusInfo = {};
844 int32_t sizeOfDial = sizeof(dial);
846 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
849 dial.clir = (int) dialInfo.clir;
851 if (dialInfo.uusInfo.size() != 0) {
852 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
853 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
855 if (dialInfo.uusInfo[0].uusData.size() == 0) {
856 uusInfo.uusData = NULL;
857 uusInfo.uusLength = 0;
859 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
860 memsetAndFreeStrings(1, dial.address);
863 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
866 dial.uusInfo = &uusInfo;
869 s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI);
871 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
876 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
877 RLOGD("getImsiForApp: serial %d", serial);
878 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
879 1, (const char *) aid);
883 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
884 RLOGD("hangup: serial %d", serial);
885 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
889 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
890 RLOGD("hangupWaitingOrBackground: serial %d", serial);
891 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
895 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
896 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
897 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
901 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
902 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
903 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
907 Return<void> RadioImpl::conference(int32_t serial) {
908 RLOGD("conference: serial %d", serial);
909 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
913 Return<void> RadioImpl::rejectCall(int32_t serial) {
914 RLOGD("rejectCall: serial %d", serial);
915 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
919 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
920 RLOGD("getLastCallFailCause: serial %d", serial);
921 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
925 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
926 RLOGD("getSignalStrength: serial %d", serial);
927 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
931 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
932 RLOGD("getVoiceRegistrationState: serial %d", serial);
933 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
937 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
938 RLOGD("getDataRegistrationState: serial %d", serial);
939 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
943 Return<void> RadioImpl::getOperator(int32_t serial) {
944 RLOGD("getOperator: serial %d", serial);
945 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
949 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
950 RLOGD("setRadioPower: serial %d on %d", serial, on);
951 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
955 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
956 RLOGD("sendDtmf: serial %d", serial);
957 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, (const char *) s);
961 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
962 RLOGD("sendSms: serial %d", serial);
963 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
964 2, (const char *) message.smscPdu, (const char *) message.pdu);
968 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
969 RLOGD("sendSMSExpectMore: serial %d", serial);
970 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
971 2, (const char *) message.smscPdu, (const char *) message.pdu);
975 const char *convertMvnoTypeToString(MvnoType type) {
977 case MvnoType::IMSI: return "imsi";
978 case MvnoType::GID: return "gid";
979 case MvnoType::SPN: return "spn";
980 default: return NULL;
984 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
985 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
986 bool roamingAllowed, bool isRoaming) {
988 RLOGD("setupDataCall: serial %d", serial);
990 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
991 const hidl_string &protocol =
992 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
993 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
994 std::to_string((int) radioTechnology + 2).c_str(),
995 std::to_string((int) dataProfileInfo.profileId).c_str(),
996 dataProfileInfo.apn.c_str(),
997 dataProfileInfo.user.c_str(),
998 dataProfileInfo.password.c_str(),
999 std::to_string((int) dataProfileInfo.authType).c_str(),
1001 } else if (s_vendorFunctions->version >= 15) {
1002 const char *mvnoTypeStr = convertMvnoTypeToString(dataProfileInfo.mvnoType);
1003 if (mvnoTypeStr == NULL) {
1004 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1005 RIL_REQUEST_SETUP_DATA_CALL);
1007 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1011 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1012 std::to_string((int) radioTechnology + 2).c_str(),
1013 std::to_string((int) dataProfileInfo.profileId).c_str(),
1014 dataProfileInfo.apn.c_str(),
1015 dataProfileInfo.user.c_str(),
1016 dataProfileInfo.password.c_str(),
1017 std::to_string((int) dataProfileInfo.authType).c_str(),
1018 dataProfileInfo.protocol.c_str(),
1019 dataProfileInfo.roamingProtocol.c_str(),
1020 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1021 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1022 BOOL_TO_INT(modemCognitive),
1023 std::to_string(dataProfileInfo.mtu).c_str(),
1025 dataProfileInfo.mvnoMatchData.c_str(),
1026 BOOL_TO_INT(roamingAllowed));
1028 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1029 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1030 RIL_REQUEST_SETUP_DATA_CALL);
1032 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1038 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1039 RLOGD("iccIOForApp: serial %d", serial);
1040 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1045 RIL_SIM_IO_v6 rilIccIo;
1046 rilIccIo.command = iccIo.command;
1047 rilIccIo.fileid = iccIo.fileId;
1048 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1052 rilIccIo.p1 = iccIo.p1;
1053 rilIccIo.p2 = iccIo.p2;
1054 rilIccIo.p3 = iccIo.p3;
1056 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1057 memsetAndFreeStrings(1, rilIccIo.path);
1061 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1062 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1066 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1067 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1071 s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI);
1073 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1078 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1079 RLOGD("sendUssd: serial %d", serial);
1080 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, (const char *) ussd);
1084 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1085 RLOGD("cancelPendingUssd: serial %d", serial);
1086 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1090 Return<void> RadioImpl::getClir(int32_t serial) {
1091 RLOGD("getClir: serial %d", serial);
1092 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1096 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1097 RLOGD("setClir: serial %d", serial);
1098 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1102 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1103 RLOGD("getCallForwardStatus: serial %d", serial);
1104 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1109 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1110 RLOGD("setCallForward: serial %d", serial);
1111 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1116 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1117 RLOGD("getCallWaiting: serial %d", serial);
1118 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1122 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1123 RLOGD("setCallWaiting: serial %d", serial);
1124 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1129 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1130 bool success, SmsAcknowledgeFailCause cause) {
1131 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1132 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1137 Return<void> RadioImpl::acceptCall(int32_t serial) {
1138 RLOGD("acceptCall: serial %d", serial);
1139 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1143 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1144 int32_t cid, bool reasonRadioShutDown) {
1145 RLOGD("deactivateDataCall: serial %d", serial);
1146 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1147 2, (const char *) (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1151 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1152 const hidl_string& password, int32_t serviceClass,
1153 const hidl_string& appId) {
1154 RLOGD("getFacilityLockForApp: serial %d", serial);
1155 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1156 4, (const char *) facility, (const char *) password,
1157 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId);
1161 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1162 bool lockState, const hidl_string& password,
1163 int32_t serviceClass, const hidl_string& appId) {
1164 RLOGD("setFacilityLockForApp: serial %d", serial);
1165 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1166 5, (const char *) facility, lockState ? "1" : "0", (const char *) password,
1167 (const char *) (std::to_string(serviceClass)).c_str(), (const char *) appId);
1171 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1172 const hidl_string& oldPassword,
1173 const hidl_string& newPassword) {
1174 RLOGD("setBarringPassword: serial %d", serial);
1175 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1176 2, (const char *) oldPassword, (const char *) newPassword);
1180 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1181 RLOGD("getNetworkSelectionMode: serial %d", serial);
1182 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1186 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1187 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1188 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1192 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1193 const hidl_string& operatorNumeric) {
1194 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1195 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1196 (const char *) operatorNumeric);
1200 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1201 RLOGD("getAvailableNetworks: serial %d", serial);
1202 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1206 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1207 RLOGD("startDtmf: serial %d", serial);
1208 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1213 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1214 RLOGD("stopDtmf: serial %d", serial);
1215 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1219 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1220 RLOGD("getBasebandVersion: serial %d", serial);
1221 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1225 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1226 RLOGD("separateConnection: serial %d", serial);
1227 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1231 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1232 RLOGD("setMute: serial %d", serial);
1233 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1237 Return<void> RadioImpl::getMute(int32_t serial) {
1238 RLOGD("getMute: serial %d", serial);
1239 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1243 Return<void> RadioImpl::getClip(int32_t serial) {
1244 RLOGD("getClip: serial %d", serial);
1245 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1249 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1250 RLOGD("getDataCallList: serial %d", serial);
1251 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1255 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1256 RLOGD("setSuppServiceNotifications: serial %d", serial);
1257 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1258 BOOL_TO_INT(enable));
1262 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1263 RLOGD("writeSmsToSim: serial %d", serial);
1264 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1269 RIL_SMS_WriteArgs args;
1270 args.status = (int) smsWriteArgs.status;
1273 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1277 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1278 memsetAndFreeStrings(1, args.pdu);
1282 s_vendorFunctions->onRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI);
1284 memsetAndFreeStrings(2, args.smsc, args.pdu);
1289 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1290 RLOGD("deleteSmsOnSim: serial %d", serial);
1291 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1295 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1296 RLOGD("setBandMode: serial %d", serial);
1297 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1301 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1302 RLOGD("getAvailableBandModes: serial %d", serial);
1303 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1307 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1308 RLOGD("sendEnvelope: serial %d", serial);
1309 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1310 (const char *) command);
1314 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1315 const hidl_string& commandResponse) {
1316 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1317 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1318 (const char *) commandResponse);
1322 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1323 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1324 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1325 1, BOOL_TO_INT(accept));
1329 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1330 RLOGD("explicitCallTransfer: serial %d", serial);
1331 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1335 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1336 RLOGD("setPreferredNetworkType: serial %d", serial);
1337 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1341 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1342 RLOGD("getPreferredNetworkType: serial %d", serial);
1343 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1347 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1348 RLOGD("getNeighboringCids: serial %d", serial);
1349 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1353 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1354 RLOGD("setLocationUpdates: serial %d", serial);
1355 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1359 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1360 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1361 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1365 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1366 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1367 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1371 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1372 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1373 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1377 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1378 RLOGD("setTTYMode: serial %d", serial);
1379 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1383 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1384 RLOGD("getTTYMode: serial %d", serial);
1385 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1389 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1390 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1391 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1392 1, BOOL_TO_INT(enable));
1396 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1397 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1398 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1402 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1403 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1404 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1405 (const char *) featureCode);
1409 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1411 RLOGD("sendBurstDtmf: serial %d", serial);
1412 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1413 3, (const char *) dtmf, (const char *) (std::to_string(on)).c_str(),
1414 (const char *) (std::to_string(off)).c_str());
1418 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1419 memset(&rcsm, 0, sizeof(rcsm));
1421 rcsm.uTeleserviceID = sms.teleserviceId;
1422 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1423 rcsm.uServicecategory = sms.serviceCategory;
1424 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1425 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1426 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1427 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1429 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1430 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1431 for (int i = 0; i < digitLimit; i++) {
1432 rcsm.sAddress.digits[i] = sms.address.digits[i];
1435 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1436 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1438 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1439 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1440 for (int i = 0; i < digitLimit; i++) {
1441 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1444 rcsm.uBearerDataLen = sms.bearerData.size();
1445 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1446 for (int i = 0; i < digitLimit; i++) {
1447 rcsm.aBearerData[i] = sms.bearerData[i];
1451 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1452 RLOGD("sendCdmaSms: serial %d", serial);
1453 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1458 RIL_CDMA_SMS_Message rcsm;
1459 constructCdmaSms(rcsm, sms);
1461 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI);
1465 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1466 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1467 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1472 RIL_CDMA_SMS_Ack rcsa = {};
1474 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1475 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1477 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI);
1481 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1482 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1483 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1487 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1488 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1490 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1491 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1492 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1497 int num = configInfo.size();
1498 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1499 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1501 for (int i = 0 ; i < num ; i++ ) {
1502 gsmBciPtrs[i] = &gsmBci[i];
1503 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1504 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1505 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1506 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1507 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1510 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, gsmBciPtrs,
1511 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI);
1515 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1516 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1517 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1518 1, BOOL_TO_INT(!activate));
1522 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1523 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1524 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1528 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1529 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1531 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1532 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1533 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1538 int num = configInfo.size();
1539 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1540 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1542 for (int i = 0 ; i < num ; i++ ) {
1543 cdmaBciPtrs[i] = &cdmaBci[i];
1544 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1545 cdmaBci[i].language = configInfo[i].language;
1546 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1549 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, cdmaBciPtrs,
1550 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI);
1554 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1555 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1556 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1557 1, BOOL_TO_INT(!activate));
1561 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1562 RLOGD("getCDMASubscription: serial %d", serial);
1563 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1567 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1568 RLOGD("writeSmsToRuim: serial %d", serial);
1569 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1570 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1575 RIL_CDMA_SMS_WriteArgs rcsw = {};
1576 rcsw.status = (int) cdmaSms.status;
1577 constructCdmaSms(rcsw.message, cdmaSms.message);
1579 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI);
1583 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1584 RLOGD("deleteSmsOnRuim: serial %d", serial);
1585 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1589 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1590 RLOGD("getDeviceIdentity: serial %d", serial);
1591 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1595 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1596 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1597 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1601 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1602 RLOGD("getSmscAddress: serial %d", serial);
1603 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1607 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1608 RLOGD("setSmscAddress: serial %d", serial);
1609 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1610 (const char *) smsc);
1614 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1615 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1616 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1617 BOOL_TO_INT(available));
1621 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1622 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1623 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1627 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1628 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1629 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1633 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1634 RLOGD("requestIsimAuthentication: serial %d", serial);
1635 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1636 (const char *) challenge);
1640 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1641 const hidl_string& ackPdu) {
1642 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1643 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1644 2, success ? "1" : "0", (const char *) ackPdu);
1648 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1649 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1650 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1651 (const char *) contents);
1655 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1656 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1657 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1661 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1662 RLOGD("getCellInfoList: serial %d", serial);
1663 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1667 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1668 RLOGD("setCellInfoListRate: serial %d", serial);
1669 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1673 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1674 bool modemCognitive, bool isRoaming) {
1675 RLOGD("setInitialAttachApn: serial %d", serial);
1676 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1677 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
1682 if (s_vendorFunctions->version <= 14) {
1683 RIL_InitialAttachApn iaa = {};
1685 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1689 const hidl_string &protocol =
1690 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1692 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
1695 iaa.authtype = (int) dataProfileInfo.authType;
1696 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1699 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1703 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1705 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
1707 RIL_InitialAttachApn_v15 iaa = {};
1709 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1712 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
1715 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
1718 iaa.authtype = (int) dataProfileInfo.authType;
1719 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1722 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1725 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
1726 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
1727 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
1728 iaa.mtu = dataProfileInfo.mtu;
1730 // Note that there is no need for memory allocation/free.
1731 iaa.mvnoType = (char *) convertMvnoTypeToString(dataProfileInfo.mvnoType);
1732 if (iaa.mvnoType == NULL) {
1733 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1737 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
1741 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1743 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1744 iaa.password, iaa.mvnoMatchData);
1750 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
1751 RLOGD("getImsRegistrationState: serial %d", serial);
1752 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
1756 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
1757 RIL_IMS_SMS_Message rism = {};
1759 int countStrings = 2;
1760 int dataLen = sizeof(char *) * countStrings;
1762 rism.tech = RADIO_TECH_3GPP;
1763 rism.retry = BOOL_TO_INT(message.retry);
1764 rism.messageRef = message.messageRef;
1766 if (message.gsmMessage.size() != 1) {
1767 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
1768 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1772 pStrings = (char **)calloc(countStrings, sizeof(char *));
1773 if (pStrings == NULL) {
1774 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
1775 requestToString(pRI->pCI->requestNumber));
1776 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1780 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
1782 memset(pStrings, 0, datalen);
1788 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
1789 memsetAndFreeStrings(1, pStrings[0]);
1791 memset(pStrings, 0, datalen);
1797 rism.message.gsmMessage = pStrings;
1798 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
1799 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI);
1801 for (int i = 0 ; i < countStrings ; i++) {
1802 memsetAndFreeStrings(1, pStrings[i]);
1806 memset(pStrings, 0, datalen);
1813 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
1814 RIL_IMS_SMS_Message rism;
1815 RIL_CDMA_SMS_Message rcsm;
1817 if (message.cdmaMessage.size() != 1) {
1818 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
1819 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1823 rism.tech = RADIO_TECH_3GPP2;
1824 rism.retry = BOOL_TO_INT(message.retry);
1825 rism.messageRef = message.messageRef;
1826 rism.message.cdmaMessage = &rcsm;
1828 constructCdmaSms(rcsm, message.cdmaMessage[0]);
1830 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
1831 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI);
1836 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
1837 RLOGD("sendImsSms: serial %d", serial);
1838 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
1843 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
1845 if (RADIO_TECH_3GPP == format) {
1846 dispatchImsGsmSms(message, pRI);
1847 } else if (RADIO_TECH_3GPP2 == format) {
1848 dispatchImsCdmaSms(message, pRI);
1850 RLOGE("sendImsSms: Invalid radio tech %s",
1851 requestToString(pRI->pCI->requestNumber));
1852 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1857 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
1858 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
1859 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
1863 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid) {
1864 RLOGD("iccOpenLogicalChannel: serial %d", serial);
1865 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL,
1866 (const char *) aid);
1870 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
1871 RLOGD("iccCloseLogicalChannel: serial %d", serial);
1872 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
1876 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
1877 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
1878 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
1882 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
1883 RLOGD("nvReadItem: serial %d", serial);
1884 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
1889 RIL_NV_ReadItem nvri;
1890 memset (&nvri, 0, sizeof(nvri));
1891 nvri.itemID = (RIL_NV_Item) itemId;
1893 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI);
1897 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
1898 RLOGD("nvWriteItem: serial %d", serial);
1899 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
1904 RIL_NV_WriteItem nvwi;
1905 memset (&nvwi, 0, sizeof(nvwi));
1907 nvwi.itemID = (RIL_NV_Item) item.itemId;
1909 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
1913 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI);
1915 memsetAndFreeStrings(1, nvwi.value);
1919 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
1920 RLOGD("nvWriteCdmaPrl: serial %d", serial);
1921 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
1925 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
1926 RLOGD("nvResetConfig: serial %d", serial);
1927 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, (int) resetType);
1931 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
1932 RLOGD("setUiccSubscription: serial %d", serial);
1933 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1934 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
1939 RIL_SelectUiccSub rilUiccSub = {};
1941 rilUiccSub.slot = uiccSub.slot;
1942 rilUiccSub.app_index = uiccSub.appIndex;
1943 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
1944 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
1946 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI);
1950 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
1951 RLOGD("setDataAllowed: serial %d", serial);
1952 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
1956 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
1957 RLOGD("getHardwareConfig: serial %d", serial);
1958 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
1962 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
1963 const hidl_string& authData, const hidl_string& aid) {
1964 RLOGD("requestIccSimAuthentication: serial %d", serial);
1965 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
1970 RIL_SimAuthentication pf;
1971 memset (&pf, 0, sizeof(pf));
1973 pf.authContext = authContext;
1976 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
1980 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
1981 memsetAndFreeStrings(1, pf.authData);
1985 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI);
1987 memsetAndFreeStrings(2, pf.authData, pf.aid);
1992 * @param numProfiles number of data profile
1993 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
1994 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
1995 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
1996 * @param numfields number of string-type member in the data profile structure
1997 * @param ... the variadic parameters are pointers to each string-type member
1999 template <typename T>
2000 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2001 int numfields, ...) {
2003 va_start(args, numfields);
2005 // Iterate through each string-type field that need to be free.
2006 for (int i = 0; i < numfields; i++) {
2007 // Iterate through each data profile and free that specific string-type field.
2008 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2009 char *T::*ptr = va_arg(args, char *T::*);
2010 for (int j = 0; j < numProfiles; j++) {
2011 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2018 memset(dataProfiles, 0, numProfiles * sizeof(T));
2019 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2022 free(dataProfilePtrs);
2025 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2027 RLOGD("setDataProfile: serial %d", serial);
2028 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2033 size_t num = profiles.size();
2034 bool success = false;
2036 if (s_vendorFunctions->version <= 14) {
2038 RIL_DataProfileInfo *dataProfiles =
2039 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2041 if (dataProfiles == NULL) {
2042 RLOGE("Memory allocation failed for request %s",
2043 requestToString(pRI->pCI->requestNumber));
2044 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2048 RIL_DataProfileInfo **dataProfilePtrs =
2049 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2050 if (dataProfilePtrs == NULL) {
2051 RLOGE("Memory allocation failed for request %s",
2052 requestToString(pRI->pCI->requestNumber));
2054 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2058 for (size_t i = 0; i < num; i++) {
2059 dataProfilePtrs[i] = &dataProfiles[i];
2061 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2063 const hidl_string &protocol =
2064 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2066 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2070 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2073 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2079 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2080 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2081 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2085 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2086 dataProfiles[i].authType = (int) profiles[i].authType;
2087 dataProfiles[i].type = (int) profiles[i].type;
2088 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2089 dataProfiles[i].maxConns = profiles[i].maxConns;
2090 dataProfiles[i].waitTime = profiles[i].waitTime;
2091 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2094 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2095 num * sizeof(RIL_DataProfileInfo *), pRI);
2097 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2098 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2099 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2101 RIL_DataProfileInfo_v15 *dataProfiles =
2102 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2104 if (dataProfiles == NULL) {
2105 RLOGE("Memory allocation failed for request %s",
2106 requestToString(pRI->pCI->requestNumber));
2107 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2111 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2112 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2113 if (dataProfilePtrs == NULL) {
2114 RLOGE("Memory allocation failed for request %s",
2115 requestToString(pRI->pCI->requestNumber));
2117 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2121 for (size_t i = 0; i < num; i++) {
2122 dataProfilePtrs[i] = &dataProfiles[i];
2124 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2125 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2129 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2130 profiles[i].roamingProtocol, pRI)) {
2133 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2136 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2141 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2142 profiles[i].mvnoMatchData, pRI)) {
2147 dataProfiles[i].mvnoType = (char *) convertMvnoTypeToString(profiles[i].mvnoType);
2148 if (dataProfiles[i].mvnoType == NULL) {
2149 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2155 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2156 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2157 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2158 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2162 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2163 dataProfiles[i].authType = (int) profiles[i].authType;
2164 dataProfiles[i].type = (int) profiles[i].type;
2165 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2166 dataProfiles[i].maxConns = profiles[i].maxConns;
2167 dataProfiles[i].waitTime = profiles[i].waitTime;
2168 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2169 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2170 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2171 dataProfiles[i].mtu = profiles[i].mtu;
2174 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2175 num * sizeof(RIL_DataProfileInfo_v15 *), pRI);
2177 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2178 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2179 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2180 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2186 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2187 RLOGD("requestShutdown: serial %d", serial);
2188 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2192 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2193 RLOGD("getRadioCapability: serial %d", serial);
2194 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2198 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2199 RLOGD("setRadioCapability: serial %d", serial);
2200 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2205 RIL_RadioCapability rilRc;
2206 memset (&rilRc, 0, sizeof(rilRc));
2208 // TODO : set rilRc.version using HIDL version ?
2209 rilRc.session = rc.session;
2210 rilRc.phase = (int) rc.phase;
2211 rilRc.rat = (int) rc.raf;
2212 rilRc.status = (int) rc.status;
2213 strncpy(rilRc.logicalModemUuid, (const char *) rc.logicalModemUuid, MAX_UUID_LENGTH);
2215 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI);
2220 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2221 RLOGD("startLceService: serial %d", serial);
2222 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2223 BOOL_TO_INT(pullMode));
2227 Return<void> RadioImpl::stopLceService(int32_t serial) {
2228 RLOGD("stopLceService: serial %d", serial);
2229 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2233 Return<void> RadioImpl::pullLceData(int32_t serial) {
2234 RLOGD("pullLceData: serial %d", serial);
2235 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2239 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2240 RLOGD("getModemActivityInfo: serial %d", serial);
2241 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2245 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2246 const CarrierRestrictions& carriers) {
2247 RLOGD("setAllowedCarriers: serial %d", serial);
2248 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2249 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2254 RIL_CarrierRestrictions cr = {};
2255 RIL_Carrier *allowedCarriers = NULL;
2256 RIL_Carrier *excludedCarriers = NULL;
2258 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2259 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2260 if (allowedCarriers == NULL) {
2261 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2262 requestToString(pRI->pCI->requestNumber));
2263 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2266 cr.allowed_carriers = allowedCarriers;
2268 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2269 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2270 if (excludedCarriers == NULL) {
2271 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2272 requestToString(pRI->pCI->requestNumber));
2273 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2275 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2277 free(allowedCarriers);
2280 cr.excluded_carriers = excludedCarriers;
2282 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2283 allowedCarriers[i].mcc = (const char *) carriers.allowedCarriers[i].mcc;
2284 allowedCarriers[i].mnc = (const char *) carriers.allowedCarriers[i].mnc;
2285 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2286 allowedCarriers[i].match_data = (const char *) carriers.allowedCarriers[i].matchData;
2289 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2290 excludedCarriers[i].mcc = (const char *) carriers.excludedCarriers[i].mcc;
2291 excludedCarriers[i].mnc = (const char *) carriers.excludedCarriers[i].mnc;
2292 excludedCarriers[i].match_type =
2293 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2294 excludedCarriers[i].match_data = (const char *) carriers.excludedCarriers[i].matchData;
2297 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI);
2300 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2301 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2303 free(allowedCarriers);
2304 free(excludedCarriers);
2308 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2309 RLOGD("getAllowedCarriers: serial %d", serial);
2310 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2314 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2316 RLOGD("sendDeviceState: serial %d", serial);
2317 if (s_vendorFunctions->version < 15) {
2318 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2319 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2320 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2322 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2323 RIL_REQUEST_SEND_DEVICE_STATE);
2324 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2328 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2329 BOOL_TO_INT(state));
2333 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2334 RLOGD("setIndicationFilter: serial %d", serial);
2335 if (s_vendorFunctions->version < 15) {
2336 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2337 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2338 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2341 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2345 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2346 RLOGD("setSimCardPower: serial %d", serial);
2347 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2351 Return<void> RadioImpl::responseAcknowledgement() {
2352 android::releaseWakeLock();
2356 Return<void> OemHookImpl::setResponseFunctions(
2357 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2358 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2359 RLOGD("OemHookImpl::setResponseFunctions");
2361 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2362 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2365 mOemHookResponse = oemHookResponseParam;
2366 mOemHookIndication = oemHookIndicationParam;
2367 mCounterOemHook[mSlotId]++;
2369 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2375 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2376 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2377 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2381 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2382 const hidl_vec<hidl_string>& data) {
2383 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2384 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2388 /***************************************************************************************************
2389 * RESPONSE FUNCTIONS
2390 * Functions above are used for requests going from framework to vendor code. The ones below are
2391 * responses for those requests coming back from the vendor code.
2392 **************************************************************************************************/
2394 void radio::acknowledgeRequest(int slotId, int serial) {
2395 if (radioService[slotId]->mRadioResponse != NULL) {
2396 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2397 radioService[slotId]->checkReturnStatus(retStatus);
2399 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2403 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2405 responseInfo.serial = serial;
2406 switch (responseType) {
2407 case RESPONSE_SOLICITED:
2408 responseInfo.type = RadioResponseType::SOLICITED;
2410 case RESPONSE_SOLICITED_ACK_EXP:
2411 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2414 responseInfo.error = (RadioError) e;
2417 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2418 void *response, size_t responseLen) {
2419 populateResponseInfo(responseInfo, serial, responseType, e);
2422 if (response == NULL || responseLen != sizeof(int)) {
2423 RLOGE("responseInt: Invalid response");
2424 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2426 int *p_int = (int *) response;
2432 int radio::getIccCardStatusResponse(int slotId,
2433 int responseType, int serial, RIL_Errno e,
2434 void *response, size_t responseLen) {
2435 if (radioService[slotId]->mRadioResponse != NULL) {
2436 RadioResponseInfo responseInfo = {};
2437 populateResponseInfo(responseInfo, serial, responseType, e);
2438 CardStatus cardStatus = {};
2439 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2440 RLOGE("getIccCardStatusResponse: Invalid response");
2441 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2443 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2444 cardStatus.cardState = (CardState) p_cur->card_state;
2445 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2446 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2447 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2448 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2450 RIL_AppStatus *rilAppStatus = p_cur->applications;
2451 cardStatus.applications.resize(p_cur->num_applications);
2452 AppStatus *appStatus = cardStatus.applications.data();
2453 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2454 for (int i = 0; i < p_cur->num_applications; i++) {
2455 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2456 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2457 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2458 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2459 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2460 rilAppStatus[i].app_label_ptr);
2461 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2462 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2463 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2467 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2468 getIccCardStatusResponse(responseInfo, cardStatus);
2469 radioService[slotId]->checkReturnStatus(retStatus);
2471 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2477 int radio::supplyIccPinForAppResponse(int slotId,
2478 int responseType, int serial, RIL_Errno e,
2479 void *response, size_t responseLen) {
2480 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
2482 if (radioService[slotId]->mRadioResponse != NULL) {
2483 RadioResponseInfo responseInfo = {};
2484 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2485 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2486 supplyIccPinForAppResponse(responseInfo, ret);
2487 radioService[slotId]->checkReturnStatus(retStatus);
2489 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2496 int radio::supplyIccPukForAppResponse(int slotId,
2497 int responseType, int serial, RIL_Errno e,
2498 void *response, size_t responseLen) {
2499 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
2501 if (radioService[slotId]->mRadioResponse != NULL) {
2502 RadioResponseInfo responseInfo = {};
2503 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2504 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2506 radioService[slotId]->checkReturnStatus(retStatus);
2508 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2515 int radio::supplyIccPin2ForAppResponse(int slotId,
2516 int responseType, int serial, RIL_Errno e,
2517 void *response, size_t responseLen) {
2518 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
2520 if (radioService[slotId]->mRadioResponse != NULL) {
2521 RadioResponseInfo responseInfo = {};
2522 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2523 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2524 supplyIccPin2ForAppResponse(responseInfo, ret);
2525 radioService[slotId]->checkReturnStatus(retStatus);
2527 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2534 int radio::supplyIccPuk2ForAppResponse(int slotId,
2535 int responseType, int serial, RIL_Errno e,
2536 void *response, size_t responseLen) {
2537 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
2539 if (radioService[slotId]->mRadioResponse != NULL) {
2540 RadioResponseInfo responseInfo = {};
2541 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2542 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2543 supplyIccPuk2ForAppResponse(responseInfo, ret);
2544 radioService[slotId]->checkReturnStatus(retStatus);
2546 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2553 int radio::changeIccPinForAppResponse(int slotId,
2554 int responseType, int serial, RIL_Errno e,
2555 void *response, size_t responseLen) {
2556 RLOGD("changeIccPinForAppResponse: serial %d", serial);
2558 if (radioService[slotId]->mRadioResponse != NULL) {
2559 RadioResponseInfo responseInfo = {};
2560 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2561 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2562 changeIccPinForAppResponse(responseInfo, ret);
2563 radioService[slotId]->checkReturnStatus(retStatus);
2565 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2572 int radio::changeIccPin2ForAppResponse(int slotId,
2573 int responseType, int serial, RIL_Errno e,
2574 void *response, size_t responseLen) {
2575 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
2577 if (radioService[slotId]->mRadioResponse != NULL) {
2578 RadioResponseInfo responseInfo = {};
2579 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2580 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2581 changeIccPin2ForAppResponse(responseInfo, ret);
2582 radioService[slotId]->checkReturnStatus(retStatus);
2584 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2591 int radio::supplyNetworkDepersonalizationResponse(int slotId,
2592 int responseType, int serial, RIL_Errno e,
2593 void *response, size_t responseLen) {
2594 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
2596 if (radioService[slotId]->mRadioResponse != NULL) {
2597 RadioResponseInfo responseInfo = {};
2598 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
2599 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2600 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2601 radioService[slotId]->checkReturnStatus(retStatus);
2603 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
2610 int radio::getCurrentCallsResponse(int slotId,
2611 int responseType, int serial, RIL_Errno e,
2612 void *response, size_t responseLen) {
2613 RLOGD("getCurrentCallsResponse: serial %d", serial);
2615 if (radioService[slotId]->mRadioResponse != NULL) {
2616 RadioResponseInfo responseInfo = {};
2617 populateResponseInfo(responseInfo, serial, responseType, e);
2619 hidl_vec<Call> calls;
2620 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) {
2621 RLOGE("getCurrentCallsResponse: Invalid response");
2622 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2624 int num = responseLen / sizeof(RIL_Call *);
2627 for (int i = 0 ; i < num ; i++) {
2628 RIL_Call *p_cur = ((RIL_Call **) response)[i];
2629 /* each call info */
2630 calls[i].state = (CallState) p_cur->state;
2631 calls[i].index = p_cur->index;
2632 calls[i].toa = p_cur->toa;
2633 calls[i].isMpty = p_cur->isMpty;
2634 calls[i].isMT = p_cur->isMT;
2635 calls[i].als = p_cur->als;
2636 calls[i].isVoice = p_cur->isVoice;
2637 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
2638 calls[i].number = convertCharPtrToHidlString(p_cur->number);
2639 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
2640 calls[i].name = convertCharPtrToHidlString(p_cur->name);
2641 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
2642 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
2643 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
2644 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
2645 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
2646 // convert uusInfo->uusData to a null-terminated string
2647 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
2648 calls[i].uusInfo[0].uusData = nullTermStr;
2654 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2655 getCurrentCallsResponse(responseInfo, calls);
2656 radioService[slotId]->checkReturnStatus(retStatus);
2658 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2664 int radio::dialResponse(int slotId,
2665 int responseType, int serial, RIL_Errno e, void *response,
2666 size_t responseLen) {
2667 RLOGD("dialResponse: serial %d", serial);
2669 if (radioService[slotId]->mRadioResponse != NULL) {
2670 RadioResponseInfo responseInfo = {};
2671 populateResponseInfo(responseInfo, serial, responseType, e);
2672 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
2673 radioService[slotId]->checkReturnStatus(retStatus);
2675 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2681 int radio::getIMSIForAppResponse(int slotId,
2682 int responseType, int serial, RIL_Errno e, void *response,
2683 size_t responseLen) {
2684 RLOGD("getIMSIForAppResponse: serial %d", serial);
2686 if (radioService[slotId]->mRadioResponse != NULL) {
2687 RadioResponseInfo responseInfo = {};
2688 populateResponseInfo(responseInfo, serial, responseType, e);
2689 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
2690 responseInfo, convertCharPtrToHidlString((char *) response));
2691 radioService[slotId]->checkReturnStatus(retStatus);
2693 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
2700 int radio::hangupConnectionResponse(int slotId,
2701 int responseType, int serial, RIL_Errno e,
2702 void *response, size_t responseLen) {
2703 RLOGD("hangupConnectionResponse: serial %d", serial);
2705 if (radioService[slotId]->mRadioResponse != NULL) {
2706 RadioResponseInfo responseInfo = {};
2707 populateResponseInfo(responseInfo, serial, responseType, e);
2708 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
2710 radioService[slotId]->checkReturnStatus(retStatus);
2712 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
2719 int radio::hangupWaitingOrBackgroundResponse(int slotId,
2720 int responseType, int serial, RIL_Errno e,
2721 void *response, size_t responseLen) {
2722 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
2724 if (radioService[slotId]->mRadioResponse != NULL) {
2725 RadioResponseInfo responseInfo = {};
2726 populateResponseInfo(responseInfo, serial, responseType, e);
2727 Return<void> retStatus =
2728 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
2730 radioService[slotId]->checkReturnStatus(retStatus);
2732 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
2739 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
2740 RIL_Errno e, void *response,
2741 size_t responseLen) {
2742 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
2744 if (radioService[slotId]->mRadioResponse != NULL) {
2745 RadioResponseInfo responseInfo = {};
2746 populateResponseInfo(responseInfo, serial, responseType, e);
2747 Return<void> retStatus =
2748 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
2750 radioService[slotId]->checkReturnStatus(retStatus);
2752 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
2759 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
2760 RIL_Errno e, void *response,
2761 size_t responseLen) {
2762 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
2764 if (radioService[slotId]->mRadioResponse != NULL) {
2765 RadioResponseInfo responseInfo = {};
2766 populateResponseInfo(responseInfo, serial, responseType, e);
2767 Return<void> retStatus =
2768 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
2770 radioService[slotId]->checkReturnStatus(retStatus);
2772 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
2779 int radio::conferenceResponse(int slotId, int responseType,
2780 int serial, RIL_Errno e, void *response, size_t responseLen) {
2781 RLOGD("conferenceResponse: serial %d", serial);
2783 if (radioService[slotId]->mRadioResponse != NULL) {
2784 RadioResponseInfo responseInfo = {};
2785 populateResponseInfo(responseInfo, serial, responseType, e);
2786 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
2788 radioService[slotId]->checkReturnStatus(retStatus);
2790 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
2797 int radio::rejectCallResponse(int slotId, int responseType,
2798 int serial, RIL_Errno e, void *response, size_t responseLen) {
2799 RLOGD("rejectCallResponse: serial %d", serial);
2801 if (radioService[slotId]->mRadioResponse != NULL) {
2802 RadioResponseInfo responseInfo = {};
2803 populateResponseInfo(responseInfo, serial, responseType, e);
2804 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
2806 radioService[slotId]->checkReturnStatus(retStatus);
2808 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
2815 int radio::getLastCallFailCauseResponse(int slotId,
2816 int responseType, int serial, RIL_Errno e, void *response,
2817 size_t responseLen) {
2818 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
2820 if (radioService[slotId]->mRadioResponse != NULL) {
2821 RadioResponseInfo responseInfo = {};
2822 populateResponseInfo(responseInfo, serial, responseType, e);
2824 LastCallFailCauseInfo info = {};
2825 info.vendorCause = hidl_string();
2826 if (response == NULL) {
2827 RLOGE("getCurrentCallsResponse Invalid response: NULL");
2828 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2829 } else if (responseLen == sizeof(int)) {
2830 int *pInt = (int *) response;
2831 info.causeCode = (LastCallFailCause) pInt[0];
2832 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
2833 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
2834 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
2835 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
2837 RLOGE("getCurrentCallsResponse Invalid response: NULL");
2838 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2841 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
2842 responseInfo, info);
2843 radioService[slotId]->checkReturnStatus(retStatus);
2845 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
2852 int radio::getSignalStrengthResponse(int slotId,
2853 int responseType, int serial, RIL_Errno e,
2854 void *response, size_t responseLen) {
2855 RLOGD("getSignalStrengthResponse: serial %d", serial);
2857 if (radioService[slotId]->mRadioResponse != NULL) {
2858 RadioResponseInfo responseInfo = {};
2859 populateResponseInfo(responseInfo, serial, responseType, e);
2860 SignalStrength signalStrength = {};
2861 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
2862 RLOGE("getSignalStrengthResponse: Invalid response");
2863 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2865 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
2868 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
2869 responseInfo, signalStrength);
2870 radioService[slotId]->checkReturnStatus(retStatus);
2872 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
2879 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
2881 return RIL_CELL_INFO_TYPE_NONE;
2884 int radioTech = atoi(rat);
2888 case RADIO_TECH_GPRS:
2889 case RADIO_TECH_EDGE:
2890 case RADIO_TECH_GSM: {
2891 return RIL_CELL_INFO_TYPE_GSM;
2894 case RADIO_TECH_UMTS:
2895 case RADIO_TECH_HSDPA:
2896 case RADIO_TECH_HSUPA:
2897 case RADIO_TECH_HSPA:
2898 case RADIO_TECH_HSPAP: {
2899 return RIL_CELL_INFO_TYPE_WCDMA;
2902 case RADIO_TECH_IS95A:
2903 case RADIO_TECH_IS95B:
2904 case RADIO_TECH_1xRTT:
2905 case RADIO_TECH_EVDO_0:
2906 case RADIO_TECH_EVDO_A:
2907 case RADIO_TECH_EVDO_B:
2908 case RADIO_TECH_EHRPD: {
2909 return RIL_CELL_INFO_TYPE_CDMA;
2912 case RADIO_TECH_LTE:
2913 case RADIO_TECH_LTE_CA: {
2914 return RIL_CELL_INFO_TYPE_LTE;
2917 case RADIO_TECH_TD_SCDMA: {
2918 return RIL_CELL_INFO_TYPE_TD_SCDMA;
2926 return RIL_CELL_INFO_TYPE_NONE;
2930 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
2932 cellIdentity.cellIdentityGsm.resize(0);
2933 cellIdentity.cellIdentityWcdma.resize(0);
2934 cellIdentity.cellIdentityCdma.resize(0);
2935 cellIdentity.cellIdentityTdscdma.resize(0);
2936 cellIdentity.cellIdentityLte.resize(0);
2937 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
2938 switch(rilCellIdentity.cellInfoType) {
2940 case RIL_CELL_INFO_TYPE_GSM: {
2941 cellIdentity.cellIdentityGsm.resize(1);
2942 cellIdentity.cellIdentityGsm[0].mcc =
2943 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
2944 cellIdentity.cellIdentityGsm[0].mnc =
2945 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
2946 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
2947 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
2948 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
2949 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
2953 case RIL_CELL_INFO_TYPE_WCDMA: {
2954 cellIdentity.cellIdentityWcdma.resize(1);
2955 cellIdentity.cellIdentityWcdma[0].mcc =
2956 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
2957 cellIdentity.cellIdentityWcdma[0].mnc =
2958 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
2959 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
2960 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
2961 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
2962 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
2966 case RIL_CELL_INFO_TYPE_CDMA: {
2967 cellIdentity.cellIdentityCdma.resize(1);
2968 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
2969 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
2970 cellIdentity.cellIdentityCdma[0].baseStationId =
2971 rilCellIdentity.cellIdentityCdma.basestationId;
2972 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
2973 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
2977 case RIL_CELL_INFO_TYPE_LTE: {
2978 cellIdentity.cellIdentityLte.resize(1);
2979 cellIdentity.cellIdentityLte[0].mcc =
2980 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
2981 cellIdentity.cellIdentityLte[0].mnc =
2982 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
2983 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
2984 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
2985 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
2986 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
2990 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
2991 cellIdentity.cellIdentityTdscdma.resize(1);
2992 cellIdentity.cellIdentityTdscdma[0].mcc =
2993 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
2994 cellIdentity.cellIdentityTdscdma[0].mnc =
2995 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
2996 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
2997 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
2998 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3008 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3009 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3010 return atoi(response[index]);
3016 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3017 int numStrings, char** response) {
3019 RIL_CellIdentity_v16 rilCellIdentity;
3020 int32_t *tmp = (int32_t*)&rilCellIdentity;
3022 for (size_t i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) {
3026 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3027 switch(rilCellIdentity.cellInfoType) {
3029 case RIL_CELL_INFO_TYPE_GSM: {
3030 rilCellIdentity.cellIdentityGsm.lac =
3031 convertResponseStringEntryToInt(response, 1, numStrings);
3032 rilCellIdentity.cellIdentityGsm.cid =
3033 convertResponseStringEntryToInt(response, 2, numStrings);
3037 case RIL_CELL_INFO_TYPE_WCDMA: {
3038 rilCellIdentity.cellIdentityWcdma.lac =
3039 convertResponseStringEntryToInt(response, 1, numStrings);
3040 rilCellIdentity.cellIdentityWcdma.cid =
3041 convertResponseStringEntryToInt(response, 2, numStrings);
3042 rilCellIdentity.cellIdentityWcdma.psc =
3043 convertResponseStringEntryToInt(response, 14, numStrings);
3047 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3048 rilCellIdentity.cellIdentityTdscdma.lac =
3049 convertResponseStringEntryToInt(response, 1, numStrings);
3050 rilCellIdentity.cellIdentityTdscdma.cid =
3051 convertResponseStringEntryToInt(response, 2, numStrings);
3055 case RIL_CELL_INFO_TYPE_CDMA:{
3056 rilCellIdentity.cellIdentityCdma.basestationId =
3057 convertResponseStringEntryToInt(response, 4, numStrings);
3058 rilCellIdentity.cellIdentityCdma.longitude =
3059 convertResponseStringEntryToInt(response, 5, numStrings);
3060 rilCellIdentity.cellIdentityCdma.latitude =
3061 convertResponseStringEntryToInt(response, 6, numStrings);
3062 rilCellIdentity.cellIdentityCdma.systemId =
3063 convertResponseStringEntryToInt(response, 8, numStrings);
3064 rilCellIdentity.cellIdentityCdma.networkId =
3065 convertResponseStringEntryToInt(response, 9, numStrings);
3069 case RIL_CELL_INFO_TYPE_LTE:{
3070 rilCellIdentity.cellIdentityLte.tac =
3071 convertResponseStringEntryToInt(response, 1, numStrings);
3072 rilCellIdentity.cellIdentityLte.ci =
3073 convertResponseStringEntryToInt(response, 2, numStrings);
3082 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3085 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3086 int numStrings, char** response) {
3088 RIL_CellIdentity_v16 rilCellIdentity;
3089 int32_t *tmp = (int32_t*)&rilCellIdentity;
3091 for (size_t i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) {
3095 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3096 switch(rilCellIdentity.cellInfoType) {
3097 case RIL_CELL_INFO_TYPE_GSM: {
3098 rilCellIdentity.cellIdentityGsm.lac =
3099 convertResponseStringEntryToInt(response, 1, numStrings);
3100 rilCellIdentity.cellIdentityGsm.cid =
3101 convertResponseStringEntryToInt(response, 2, numStrings);
3104 case RIL_CELL_INFO_TYPE_WCDMA: {
3105 rilCellIdentity.cellIdentityWcdma.lac =
3106 convertResponseStringEntryToInt(response, 1, numStrings);
3107 rilCellIdentity.cellIdentityWcdma.cid =
3108 convertResponseStringEntryToInt(response, 2, numStrings);
3111 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3112 rilCellIdentity.cellIdentityTdscdma.lac =
3113 convertResponseStringEntryToInt(response, 1, numStrings);
3114 rilCellIdentity.cellIdentityTdscdma.cid =
3115 convertResponseStringEntryToInt(response, 2, numStrings);
3118 case RIL_CELL_INFO_TYPE_LTE: {
3119 rilCellIdentity.cellIdentityLte.tac =
3120 convertResponseStringEntryToInt(response, 6, numStrings);
3121 rilCellIdentity.cellIdentityLte.pci =
3122 convertResponseStringEntryToInt(response, 7, numStrings);
3123 rilCellIdentity.cellIdentityLte.ci =
3124 convertResponseStringEntryToInt(response, 8, numStrings);
3132 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3135 int radio::getVoiceRegistrationStateResponse(int slotId,
3136 int responseType, int serial, RIL_Errno e,
3137 void *response, size_t responseLen) {
3138 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3140 if (radioService[slotId]->mRadioResponse != NULL) {
3141 RadioResponseInfo responseInfo = {};
3142 populateResponseInfo(responseInfo, serial, responseType, e);
3144 VoiceRegStateResult voiceRegResponse = {};
3145 int numStrings = responseLen / sizeof(char *);
3146 if (response == NULL) {
3147 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3148 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3149 } else if (s_vendorFunctions->version <= 14) {
3150 if (numStrings != 15) {
3151 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3152 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3154 char **resp = (char **) response;
3155 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3156 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3157 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3158 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3159 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3160 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3161 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3162 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3166 RIL_VoiceRegistrationStateResponse *voiceRegState =
3167 (RIL_VoiceRegistrationStateResponse *)response;
3169 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3170 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3171 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3173 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3174 voiceRegResponse.rat = voiceRegState->rat;;
3175 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3176 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3177 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3178 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3179 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3180 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3181 voiceRegState->cellIdentity);
3185 Return<void> retStatus =
3186 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3187 responseInfo, voiceRegResponse);
3188 radioService[slotId]->checkReturnStatus(retStatus);
3190 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3197 int radio::getDataRegistrationStateResponse(int slotId,
3198 int responseType, int serial, RIL_Errno e,
3199 void *response, size_t responseLen) {
3200 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3202 if (radioService[slotId]->mRadioResponse != NULL) {
3203 RadioResponseInfo responseInfo = {};
3204 populateResponseInfo(responseInfo, serial, responseType, e);
3205 DataRegStateResult dataRegResponse = {};
3206 if (response == NULL) {
3207 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3208 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3209 } else if (s_vendorFunctions->version <= 14) {
3210 int numStrings = responseLen / sizeof(char *);
3211 if ((numStrings != 6) && (numStrings != 11)) {
3212 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3213 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3215 char **resp = (char **) response;
3216 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3217 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3218 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3219 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3220 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3224 RIL_DataRegistrationStateResponse *dataRegState =
3225 (RIL_DataRegistrationStateResponse *)response;
3227 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3228 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3229 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3231 dataRegResponse.regState = (RegState) dataRegState->regState;
3232 dataRegResponse.rat = dataRegState->rat;;
3233 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3234 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3235 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3239 Return<void> retStatus =
3240 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3242 radioService[slotId]->checkReturnStatus(retStatus);
3244 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3251 int radio::getOperatorResponse(int slotId,
3252 int responseType, int serial, RIL_Errno e, void *response,
3253 size_t responseLen) {
3254 RLOGD("getOperatorResponse: serial %d", serial);
3256 if (radioService[slotId]->mRadioResponse != NULL) {
3257 RadioResponseInfo responseInfo = {};
3258 populateResponseInfo(responseInfo, serial, responseType, e);
3259 hidl_string longName;
3260 hidl_string shortName;
3261 hidl_string numeric;
3262 int numStrings = responseLen / sizeof(char *);
3263 if (response == NULL || numStrings != 3) {
3264 RLOGE("getOperatorResponse Invalid response: NULL");
3265 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3268 char **resp = (char **) response;
3269 longName = convertCharPtrToHidlString(resp[0]);
3270 shortName = convertCharPtrToHidlString(resp[1]);
3271 numeric = convertCharPtrToHidlString(resp[2]);
3273 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3274 responseInfo, longName, shortName, numeric);
3275 radioService[slotId]->checkReturnStatus(retStatus);
3277 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3284 int radio::setRadioPowerResponse(int slotId,
3285 int responseType, int serial, RIL_Errno e, void *response,
3286 size_t responseLen) {
3287 RLOGD("setRadioPowerResponse: serial %d", serial);
3289 if (radioService[slotId]->mRadioResponse != NULL) {
3290 RadioResponseInfo responseInfo = {};
3291 populateResponseInfo(responseInfo, serial, responseType, e);
3292 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3294 radioService[slotId]->checkReturnStatus(retStatus);
3296 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3303 int radio::sendDtmfResponse(int slotId,
3304 int responseType, int serial, RIL_Errno e, void *response,
3305 size_t responseLen) {
3306 RLOGD("sendDtmfResponse: serial %d", serial);
3308 if (radioService[slotId]->mRadioResponse != NULL) {
3309 RadioResponseInfo responseInfo = {};
3310 populateResponseInfo(responseInfo, serial, responseType, e);
3311 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3313 radioService[slotId]->checkReturnStatus(retStatus);
3315 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3322 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3323 RIL_Errno e, void *response, size_t responseLen) {
3324 populateResponseInfo(responseInfo, serial, responseType, e);
3325 SendSmsResult result = {};
3327 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3328 RLOGE("Invalid response: NULL");
3329 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3330 result.ackPDU = hidl_string();
3332 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3333 result.messageRef = resp->messageRef;
3334 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3335 result.errorCode = resp->errorCode;
3340 int radio::sendSmsResponse(int slotId,
3341 int responseType, int serial, RIL_Errno e, void *response,
3342 size_t responseLen) {
3343 RLOGD("sendSmsResponse: serial %d", serial);
3345 if (radioService[slotId]->mRadioResponse != NULL) {
3346 RadioResponseInfo responseInfo = {};
3347 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3350 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3352 radioService[slotId]->checkReturnStatus(retStatus);
3354 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3360 int radio::sendSMSExpectMoreResponse(int slotId,
3361 int responseType, int serial, RIL_Errno e, void *response,
3362 size_t responseLen) {
3363 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3365 if (radioService[slotId]->mRadioResponse != NULL) {
3366 RadioResponseInfo responseInfo = {};
3367 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3370 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3371 responseInfo, result);
3372 radioService[slotId]->checkReturnStatus(retStatus);
3374 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3380 int radio::setupDataCallResponse(int slotId,
3381 int responseType, int serial, RIL_Errno e, void *response,
3382 size_t responseLen) {
3383 RLOGD("setupDataCallResponse: serial %d", serial);
3385 if (radioService[slotId]->mRadioResponse != NULL) {
3386 RadioResponseInfo responseInfo = {};
3387 populateResponseInfo(responseInfo, serial, responseType, e);
3389 SetupDataCallResult result = {};
3390 if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) {
3391 RLOGE("setupDataCallResponse: Invalid response");
3392 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3393 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3394 result.type = hidl_string();
3395 result.ifname = hidl_string();
3396 result.addresses = hidl_string();
3397 result.dnses = hidl_string();
3398 result.gateways = hidl_string();
3399 result.pcscf = hidl_string();
3401 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3404 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3405 responseInfo, result);
3406 radioService[slotId]->checkReturnStatus(retStatus);
3408 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3414 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3415 RIL_Errno e, void *response, size_t responseLen) {
3416 populateResponseInfo(responseInfo, serial, responseType, e);
3417 IccIoResult result = {};
3419 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3420 RLOGE("Invalid response: NULL");
3421 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3422 result.simResponse = hidl_string();
3424 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3425 result.sw1 = resp->sw1;
3426 result.sw2 = resp->sw2;
3427 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3432 int radio::iccIOForAppResponse(int slotId,
3433 int responseType, int serial, RIL_Errno e, void *response,
3434 size_t responseLen) {
3435 RLOGD("iccIOForAppResponse: serial %d", serial);
3437 if (radioService[slotId]->mRadioResponse != NULL) {
3438 RadioResponseInfo responseInfo = {};
3439 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3442 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3443 responseInfo, result);
3444 radioService[slotId]->checkReturnStatus(retStatus);
3446 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3452 int radio::sendUssdResponse(int slotId,
3453 int responseType, int serial, RIL_Errno e, void *response,
3454 size_t responseLen) {
3455 RLOGD("sendUssdResponse: serial %d", serial);
3457 if (radioService[slotId]->mRadioResponse != NULL) {
3458 RadioResponseInfo responseInfo = {};
3459 populateResponseInfo(responseInfo, serial, responseType, e);
3460 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3462 radioService[slotId]->checkReturnStatus(retStatus);
3464 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3471 int radio::cancelPendingUssdResponse(int slotId,
3472 int responseType, int serial, RIL_Errno e, void *response,
3473 size_t responseLen) {
3474 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3476 if (radioService[slotId]->mRadioResponse != NULL) {
3477 RadioResponseInfo responseInfo = {};
3478 populateResponseInfo(responseInfo, serial, responseType, e);
3479 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3481 radioService[slotId]->checkReturnStatus(retStatus);
3483 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3490 int radio::getClirResponse(int slotId,
3491 int responseType, int serial, RIL_Errno e, void *response,
3492 size_t responseLen) {
3493 RLOGD("getClirResponse: serial %d", serial);
3495 if (radioService[slotId]->mRadioResponse != NULL) {
3496 RadioResponseInfo responseInfo = {};
3497 populateResponseInfo(responseInfo, serial, responseType, e);
3499 int numInts = responseLen / sizeof(int);
3500 if (response == NULL || numInts != 2) {
3501 RLOGE("getClirResponse Invalid response: NULL");
3502 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3504 int *pInt = (int *) response;
3508 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3510 radioService[slotId]->checkReturnStatus(retStatus);
3512 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3518 int radio::setClirResponse(int slotId,
3519 int responseType, int serial, RIL_Errno e, void *response,
3520 size_t responseLen) {
3521 RLOGD("setClirResponse: serial %d", serial);
3523 if (radioService[slotId]->mRadioResponse != NULL) {
3524 RadioResponseInfo responseInfo = {};
3525 populateResponseInfo(responseInfo, serial, responseType, e);
3526 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
3528 radioService[slotId]->checkReturnStatus(retStatus);
3530 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3536 int radio::getCallForwardStatusResponse(int slotId,
3537 int responseType, int serial, RIL_Errno e,
3538 void *response, size_t responseLen) {
3539 RLOGD("getCallForwardStatusResponse: serial %d", serial);
3541 if (radioService[slotId]->mRadioResponse != NULL) {
3542 RadioResponseInfo responseInfo = {};
3543 populateResponseInfo(responseInfo, serial, responseType, e);
3544 hidl_vec<CallForwardInfo> callForwardInfos;
3546 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
3547 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
3548 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3550 int num = responseLen / sizeof(RIL_CallForwardInfo *);
3551 callForwardInfos.resize(num);
3552 for (int i = 0 ; i < num; i++) {
3553 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
3554 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
3555 callForwardInfos[i].reason = resp->reason;
3556 callForwardInfos[i].serviceClass = resp->serviceClass;
3557 callForwardInfos[i].toa = resp->toa;
3558 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
3559 callForwardInfos[i].timeSeconds = resp->timeSeconds;
3563 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
3564 responseInfo, callForwardInfos);
3565 radioService[slotId]->checkReturnStatus(retStatus);
3567 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
3574 int radio::setCallForwardResponse(int slotId,
3575 int responseType, int serial, RIL_Errno e, void *response,
3576 size_t responseLen) {
3577 RLOGD("setCallForwardResponse: serial %d", serial);
3579 if (radioService[slotId]->mRadioResponse != NULL) {
3580 RadioResponseInfo responseInfo = {};
3581 populateResponseInfo(responseInfo, serial, responseType, e);
3582 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
3584 radioService[slotId]->checkReturnStatus(retStatus);
3586 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3592 int radio::getCallWaitingResponse(int slotId,
3593 int responseType, int serial, RIL_Errno e, void *response,
3594 size_t responseLen) {
3595 RLOGD("getCallWaitingResponse: serial %d", serial);
3597 if (radioService[slotId]->mRadioResponse != NULL) {
3598 RadioResponseInfo responseInfo = {};
3599 populateResponseInfo(responseInfo, serial, responseType, e);
3600 bool enable = false;
3601 int serviceClass = -1;
3602 int numInts = responseLen / sizeof(int);
3603 if (response == NULL || numInts != 2) {
3604 RLOGE("getCallWaitingResponse Invalid response: NULL");
3605 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3607 int *pInt = (int *) response;
3608 enable = pInt[0] == 1 ? true : false;
3609 serviceClass = pInt[1];
3611 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
3612 responseInfo, enable, serviceClass);
3613 radioService[slotId]->checkReturnStatus(retStatus);
3615 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3621 int radio::setCallWaitingResponse(int slotId,
3622 int responseType, int serial, RIL_Errno e, void *response,
3623 size_t responseLen) {
3624 RLOGD("setCallWaitingResponse: serial %d", serial);
3626 if (radioService[slotId]->mRadioResponse != NULL) {
3627 RadioResponseInfo responseInfo = {};
3628 populateResponseInfo(responseInfo, serial, responseType, e);
3629 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
3631 radioService[slotId]->checkReturnStatus(retStatus);
3633 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3639 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
3640 int responseType, int serial, RIL_Errno e,
3641 void *response, size_t responseLen) {
3642 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
3644 if (radioService[slotId]->mRadioResponse != NULL) {
3645 RadioResponseInfo responseInfo = {};
3646 populateResponseInfo(responseInfo, serial, responseType, e);
3647 Return<void> retStatus =
3648 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
3650 radioService[slotId]->checkReturnStatus(retStatus);
3652 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
3659 int radio::acceptCallResponse(int slotId,
3660 int responseType, int serial, RIL_Errno e,
3661 void *response, size_t responseLen) {
3662 RLOGD("acceptCallResponse: serial %d", serial);
3664 if (radioService[slotId]->mRadioResponse != NULL) {
3665 RadioResponseInfo responseInfo = {};
3666 populateResponseInfo(responseInfo, serial, responseType, e);
3667 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
3669 radioService[slotId]->checkReturnStatus(retStatus);
3671 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
3678 int radio::deactivateDataCallResponse(int slotId,
3679 int responseType, int serial, RIL_Errno e,
3680 void *response, size_t responseLen) {
3681 RLOGD("deactivateDataCallResponse: serial %d", serial);
3683 if (radioService[slotId]->mRadioResponse != NULL) {
3684 RadioResponseInfo responseInfo = {};
3685 populateResponseInfo(responseInfo, serial, responseType, e);
3686 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
3688 radioService[slotId]->checkReturnStatus(retStatus);
3690 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
3697 int radio::getFacilityLockForAppResponse(int slotId,
3698 int responseType, int serial, RIL_Errno e,
3699 void *response, size_t responseLen) {
3700 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
3702 if (radioService[slotId]->mRadioResponse != NULL) {
3703 RadioResponseInfo responseInfo = {};
3704 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
3705 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3706 getFacilityLockForAppResponse(responseInfo, ret);
3707 radioService[slotId]->checkReturnStatus(retStatus);
3709 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
3716 int radio::setFacilityLockForAppResponse(int slotId,
3717 int responseType, int serial, RIL_Errno e,
3718 void *response, size_t responseLen) {
3719 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
3721 if (radioService[slotId]->mRadioResponse != NULL) {
3722 RadioResponseInfo responseInfo = {};
3723 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
3724 Return<void> retStatus
3725 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
3727 radioService[slotId]->checkReturnStatus(retStatus);
3729 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
3736 int radio::setBarringPasswordResponse(int slotId,
3737 int responseType, int serial, RIL_Errno e,
3738 void *response, size_t responseLen) {
3739 RLOGD("acceptCallResponse: serial %d", serial);
3741 if (radioService[slotId]->mRadioResponse != NULL) {
3742 RadioResponseInfo responseInfo = {};
3743 populateResponseInfo(responseInfo, serial, responseType, e);
3744 Return<void> retStatus
3745 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
3746 radioService[slotId]->checkReturnStatus(retStatus);
3748 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
3755 int radio::getNetworkSelectionModeResponse(int slotId,
3756 int responseType, int serial, RIL_Errno e, void *response,
3757 size_t responseLen) {
3758 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
3760 if (radioService[slotId]->mRadioResponse != NULL) {
3761 RadioResponseInfo responseInfo = {};
3762 populateResponseInfo(responseInfo, serial, responseType, e);
3763 bool manual = false;
3765 if (response == NULL || responseLen != sizeof(int)) {
3766 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
3767 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3769 int *pInt = (int *) response;
3770 manual = pInt[0] == 1 ? true : false;
3772 Return<void> retStatus
3773 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
3776 radioService[slotId]->checkReturnStatus(retStatus);
3778 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
3785 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
3786 RIL_Errno e, void *response,
3787 size_t responseLen) {
3788 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
3790 if (radioService[slotId]->mRadioResponse != NULL) {
3791 RadioResponseInfo responseInfo = {};
3792 populateResponseInfo(responseInfo, serial, responseType, e);
3793 Return<void> retStatus
3794 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
3796 radioService[slotId]->checkReturnStatus(retStatus);
3798 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
3805 int radio::setNetworkSelectionModeManualResponse(int slotId,
3806 int responseType, int serial, RIL_Errno e,
3807 void *response, size_t responseLen) {
3808 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
3810 if (radioService[slotId]->mRadioResponse != NULL) {
3811 RadioResponseInfo responseInfo = {};
3812 populateResponseInfo(responseInfo, serial, responseType, e);
3813 Return<void> retStatus
3814 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
3816 radioService[slotId]->checkReturnStatus(retStatus);
3818 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
3825 int convertOperatorStatusToInt(const char *str) {
3826 if (strncmp("unknown", str, 9) == 0) {
3827 return (int) OperatorStatus::UNKNOWN;
3828 } else if (strncmp("available", str, 9) == 0) {
3829 return (int) OperatorStatus::AVAILABLE;
3830 } else if (strncmp("current", str, 9) == 0) {
3831 return (int) OperatorStatus::CURRENT;
3832 } else if (strncmp("forbidden", str, 9) == 0) {
3833 return (int) OperatorStatus::FORBIDDEN;
3839 int radio::getAvailableNetworksResponse(int slotId,
3840 int responseType, int serial, RIL_Errno e, void *response,
3841 size_t responseLen) {
3842 RLOGD("getAvailableNetworksResponse: serial %d", serial);
3844 if (radioService[slotId]->mRadioResponse != NULL) {
3845 RadioResponseInfo responseInfo = {};
3846 populateResponseInfo(responseInfo, serial, responseType, e);
3847 hidl_vec<OperatorInfo> networks;
3848 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) {
3849 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
3850 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3852 char **resp = (char **) response;
3853 int numStrings = responseLen / sizeof(char *);
3854 networks.resize(numStrings/4);
3855 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
3856 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
3857 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
3858 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
3859 int status = convertOperatorStatusToInt(resp[i + 3]);
3861 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3863 networks[j].status = (OperatorStatus) status;
3867 Return<void> retStatus
3868 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
3870 radioService[slotId]->checkReturnStatus(retStatus);
3872 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
3879 int radio::startDtmfResponse(int slotId,
3880 int responseType, int serial, RIL_Errno e,
3881 void *response, size_t responseLen) {
3882 RLOGD("startDtmfResponse: serial %d", serial);
3884 if (radioService[slotId]->mRadioResponse != NULL) {
3885 RadioResponseInfo responseInfo = {};
3886 populateResponseInfo(responseInfo, serial, responseType, e);
3887 Return<void> retStatus
3888 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
3889 radioService[slotId]->checkReturnStatus(retStatus);
3891 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3897 int radio::stopDtmfResponse(int slotId,
3898 int responseType, int serial, RIL_Errno e,
3899 void *response, size_t responseLen) {
3900 RLOGD("stopDtmfResponse: serial %d", serial);
3902 if (radioService[slotId]->mRadioResponse != NULL) {
3903 RadioResponseInfo responseInfo = {};
3904 populateResponseInfo(responseInfo, serial, responseType, e);
3905 Return<void> retStatus
3906 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
3907 radioService[slotId]->checkReturnStatus(retStatus);
3909 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3915 int radio::getBasebandVersionResponse(int slotId,
3916 int responseType, int serial, RIL_Errno e,
3917 void *response, size_t responseLen) {
3918 RLOGD("getBasebandVersionResponse: serial %d", serial);
3920 if (radioService[slotId]->mRadioResponse != NULL) {
3921 RadioResponseInfo responseInfo = {};
3922 populateResponseInfo(responseInfo, serial, responseType, e);
3923 Return<void> retStatus
3924 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
3925 convertCharPtrToHidlString((char *) response));
3926 radioService[slotId]->checkReturnStatus(retStatus);
3928 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3934 int radio::separateConnectionResponse(int slotId,
3935 int responseType, int serial, RIL_Errno e,
3936 void *response, size_t responseLen) {
3937 RLOGD("separateConnectionResponse: serial %d", serial);
3939 if (radioService[slotId]->mRadioResponse != NULL) {
3940 RadioResponseInfo responseInfo = {};
3941 populateResponseInfo(responseInfo, serial, responseType, e);
3942 Return<void> retStatus
3943 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
3944 radioService[slotId]->checkReturnStatus(retStatus);
3946 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3953 int radio::setMuteResponse(int slotId,
3954 int responseType, int serial, RIL_Errno e,
3955 void *response, size_t responseLen) {
3956 RLOGD("setMuteResponse: serial %d", serial);
3958 if (radioService[slotId]->mRadioResponse != NULL) {
3959 RadioResponseInfo responseInfo = {};
3960 populateResponseInfo(responseInfo, serial, responseType, e);
3961 Return<void> retStatus
3962 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
3963 radioService[slotId]->checkReturnStatus(retStatus);
3965 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3971 int radio::getMuteResponse(int slotId,
3972 int responseType, int serial, RIL_Errno e, void *response,
3973 size_t responseLen) {
3974 RLOGD("getMuteResponse: serial %d", serial);
3976 if (radioService[slotId]->mRadioResponse != NULL) {
3977 RadioResponseInfo responseInfo = {};
3978 populateResponseInfo(responseInfo, serial, responseType, e);
3979 bool enable = false;
3981 if (response == NULL || responseLen != sizeof(int)) {
3982 RLOGE("getMuteResponse Invalid response: NULL");
3983 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3985 int *pInt = (int *) response;
3986 enable = pInt[0] == 1 ? true : false;
3988 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
3990 radioService[slotId]->checkReturnStatus(retStatus);
3992 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3998 int radio::getClipResponse(int slotId,
3999 int responseType, int serial, RIL_Errno e,
4000 void *response, size_t responseLen) {
4001 RLOGD("getClipResponse: serial %d", serial);
4003 if (radioService[slotId]->mRadioResponse != NULL) {
4004 RadioResponseInfo responseInfo = {};
4005 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4006 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4008 radioService[slotId]->checkReturnStatus(retStatus);
4010 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4016 int radio::getDataCallListResponse(int slotId,
4017 int responseType, int serial, RIL_Errno e,
4018 void *response, size_t responseLen) {
4019 RLOGD("getDataCallListResponse: serial %d", serial);
4021 if (radioService[slotId]->mRadioResponse != NULL) {
4022 RadioResponseInfo responseInfo = {};
4023 populateResponseInfo(responseInfo, serial, responseType, e);
4025 hidl_vec<SetupDataCallResult> ret;
4026 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4027 RLOGE("getDataCallListResponse: invalid response");
4028 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4030 convertRilDataCallListToHal(response, responseLen, ret);
4033 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4035 radioService[slotId]->checkReturnStatus(retStatus);
4037 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4043 int radio::setSuppServiceNotificationsResponse(int slotId,
4044 int responseType, int serial, RIL_Errno e,
4045 void *response, size_t responseLen) {
4046 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4048 if (radioService[slotId]->mRadioResponse != NULL) {
4049 RadioResponseInfo responseInfo = {};
4050 populateResponseInfo(responseInfo, serial, responseType, e);
4051 Return<void> retStatus
4052 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4054 radioService[slotId]->checkReturnStatus(retStatus);
4056 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4063 int radio::deleteSmsOnSimResponse(int slotId,
4064 int responseType, int serial, RIL_Errno e,
4065 void *response, size_t responseLen) {
4066 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4068 if (radioService[slotId]->mRadioResponse != NULL) {
4069 RadioResponseInfo responseInfo = {};
4070 populateResponseInfo(responseInfo, serial, responseType, e);
4071 Return<void> retStatus
4072 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4073 radioService[slotId]->checkReturnStatus(retStatus);
4075 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4081 int radio::setBandModeResponse(int slotId,
4082 int responseType, int serial, RIL_Errno e,
4083 void *response, size_t responseLen) {
4084 RLOGD("setBandModeResponse: serial %d", serial);
4086 if (radioService[slotId]->mRadioResponse != NULL) {
4087 RadioResponseInfo responseInfo = {};
4088 populateResponseInfo(responseInfo, serial, responseType, e);
4089 Return<void> retStatus
4090 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4091 radioService[slotId]->checkReturnStatus(retStatus);
4093 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4099 int radio::writeSmsToSimResponse(int slotId,
4100 int responseType, int serial, RIL_Errno e,
4101 void *response, size_t responseLen) {
4102 RLOGD("writeSmsToSimResponse: serial %d", serial);
4104 if (radioService[slotId]->mRadioResponse != NULL) {
4105 RadioResponseInfo responseInfo = {};
4106 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4107 Return<void> retStatus
4108 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4109 radioService[slotId]->checkReturnStatus(retStatus);
4111 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4117 int radio::getAvailableBandModesResponse(int slotId,
4118 int responseType, int serial, RIL_Errno e, void *response,
4119 size_t responseLen) {
4120 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4122 if (radioService[slotId]->mRadioResponse != NULL) {
4123 RadioResponseInfo responseInfo = {};
4124 populateResponseInfo(responseInfo, serial, responseType, e);
4125 hidl_vec<RadioBandMode> modes;
4126 if (response == NULL || responseLen % sizeof(int) != 0) {
4127 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4128 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4130 int *pInt = (int *) response;
4131 int numInts = responseLen / sizeof(int);
4132 modes.resize(numInts);
4133 for (int i = 0; i < numInts; i++) {
4134 modes[i] = (RadioBandMode) pInt[i];
4137 Return<void> retStatus
4138 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4140 radioService[slotId]->checkReturnStatus(retStatus);
4142 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4149 int radio::sendEnvelopeResponse(int slotId,
4150 int responseType, int serial, RIL_Errno e,
4151 void *response, size_t responseLen) {
4152 RLOGD("sendEnvelopeResponse: serial %d", serial);
4154 if (radioService[slotId]->mRadioResponse != NULL) {
4155 RadioResponseInfo responseInfo = {};
4156 populateResponseInfo(responseInfo, serial, responseType, e);
4157 Return<void> retStatus
4158 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4159 convertCharPtrToHidlString((char *) response));
4160 radioService[slotId]->checkReturnStatus(retStatus);
4162 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4168 int radio::sendTerminalResponseToSimResponse(int slotId,
4169 int responseType, int serial, RIL_Errno e,
4170 void *response, size_t responseLen) {
4171 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4173 if (radioService[slotId]->mRadioResponse != NULL) {
4174 RadioResponseInfo responseInfo = {};
4175 populateResponseInfo(responseInfo, serial, responseType, e);
4176 Return<void> retStatus
4177 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4179 radioService[slotId]->checkReturnStatus(retStatus);
4181 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4188 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4189 int responseType, int serial,
4190 RIL_Errno e, void *response,
4191 size_t responseLen) {
4192 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4194 if (radioService[slotId]->mRadioResponse != NULL) {
4195 RadioResponseInfo responseInfo = {};
4196 populateResponseInfo(responseInfo, serial, responseType, e);
4197 Return<void> retStatus
4198 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4200 radioService[slotId]->checkReturnStatus(retStatus);
4202 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4209 int radio::explicitCallTransferResponse(int slotId,
4210 int responseType, int serial, RIL_Errno e,
4211 void *response, size_t responseLen) {
4212 RLOGD("explicitCallTransferResponse: serial %d", serial);
4214 if (radioService[slotId]->mRadioResponse != NULL) {
4215 RadioResponseInfo responseInfo = {};
4216 populateResponseInfo(responseInfo, serial, responseType, e);
4217 Return<void> retStatus
4218 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4219 radioService[slotId]->checkReturnStatus(retStatus);
4221 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4228 int radio::setPreferredNetworkTypeResponse(int slotId,
4229 int responseType, int serial, RIL_Errno e,
4230 void *response, size_t responseLen) {
4231 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4233 if (radioService[slotId]->mRadioResponse != NULL) {
4234 RadioResponseInfo responseInfo = {};
4235 populateResponseInfo(responseInfo, serial, responseType, e);
4236 Return<void> retStatus
4237 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4239 radioService[slotId]->checkReturnStatus(retStatus);
4241 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4249 int radio::getPreferredNetworkTypeResponse(int slotId,
4250 int responseType, int serial, RIL_Errno e,
4251 void *response, size_t responseLen) {
4252 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4254 if (radioService[slotId]->mRadioResponse != NULL) {
4255 RadioResponseInfo responseInfo = {};
4256 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4257 Return<void> retStatus
4258 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4259 responseInfo, (PreferredNetworkType) ret);
4260 radioService[slotId]->checkReturnStatus(retStatus);
4262 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4269 int radio::getNeighboringCidsResponse(int slotId,
4270 int responseType, int serial, RIL_Errno e,
4271 void *response, size_t responseLen) {
4272 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4274 if (radioService[slotId]->mRadioResponse != NULL) {
4275 RadioResponseInfo responseInfo = {};
4276 populateResponseInfo(responseInfo, serial, responseType, e);
4277 hidl_vec<NeighboringCell> cells;
4279 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4280 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4281 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4283 int num = responseLen / sizeof(RIL_NeighboringCell *);
4285 for (int i = 0 ; i < num; i++) {
4286 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4287 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4288 cells[i].rssi = resp->rssi;
4292 Return<void> retStatus
4293 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4295 radioService[slotId]->checkReturnStatus(retStatus);
4297 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4304 int radio::setLocationUpdatesResponse(int slotId,
4305 int responseType, int serial, RIL_Errno e,
4306 void *response, size_t responseLen) {
4307 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4309 if (radioService[slotId]->mRadioResponse != NULL) {
4310 RadioResponseInfo responseInfo = {};
4311 populateResponseInfo(responseInfo, serial, responseType, e);
4312 Return<void> retStatus
4313 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4314 radioService[slotId]->checkReturnStatus(retStatus);
4316 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4323 int radio::setCdmaSubscriptionSourceResponse(int slotId,
4324 int responseType, int serial, RIL_Errno e,
4325 void *response, size_t responseLen) {
4326 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4328 if (radioService[slotId]->mRadioResponse != NULL) {
4329 RadioResponseInfo responseInfo = {};
4330 populateResponseInfo(responseInfo, serial, responseType, e);
4331 Return<void> retStatus
4332 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4334 radioService[slotId]->checkReturnStatus(retStatus);
4336 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4343 int radio::setCdmaRoamingPreferenceResponse(int slotId,
4344 int responseType, int serial, RIL_Errno e,
4345 void *response, size_t responseLen) {
4346 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4348 if (radioService[slotId]->mRadioResponse != NULL) {
4349 RadioResponseInfo responseInfo = {};
4350 populateResponseInfo(responseInfo, serial, responseType, e);
4351 Return<void> retStatus
4352 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4354 radioService[slotId]->checkReturnStatus(retStatus);
4356 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4363 int radio::getCdmaRoamingPreferenceResponse(int slotId,
4364 int responseType, int serial, RIL_Errno e,
4365 void *response, size_t responseLen) {
4366 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4368 if (radioService[slotId]->mRadioResponse != NULL) {
4369 RadioResponseInfo responseInfo = {};
4370 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4371 Return<void> retStatus
4372 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4373 responseInfo, (CdmaRoamingType) ret);
4374 radioService[slotId]->checkReturnStatus(retStatus);
4376 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4383 int radio::setTTYModeResponse(int slotId,
4384 int responseType, int serial, RIL_Errno e,
4385 void *response, size_t responseLen) {
4386 RLOGD("setTTYModeResponse: serial %d", serial);
4388 if (radioService[slotId]->mRadioResponse != NULL) {
4389 RadioResponseInfo responseInfo = {};
4390 populateResponseInfo(responseInfo, serial, responseType, e);
4391 Return<void> retStatus
4392 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4393 radioService[slotId]->checkReturnStatus(retStatus);
4395 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4401 int radio::getTTYModeResponse(int slotId,
4402 int responseType, int serial, RIL_Errno e,
4403 void *response, size_t responseLen) {
4404 RLOGD("getTTYModeResponse: serial %d", serial);
4406 if (radioService[slotId]->mRadioResponse != NULL) {
4407 RadioResponseInfo responseInfo = {};
4408 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4409 Return<void> retStatus
4410 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4412 radioService[slotId]->checkReturnStatus(retStatus);
4414 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4420 int radio::setPreferredVoicePrivacyResponse(int slotId,
4421 int responseType, int serial, RIL_Errno e,
4422 void *response, size_t responseLen) {
4423 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
4425 if (radioService[slotId]->mRadioResponse != NULL) {
4426 RadioResponseInfo responseInfo = {};
4427 populateResponseInfo(responseInfo, serial, responseType, e);
4428 Return<void> retStatus
4429 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4431 radioService[slotId]->checkReturnStatus(retStatus);
4433 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4440 int radio::getPreferredVoicePrivacyResponse(int slotId,
4441 int responseType, int serial, RIL_Errno e,
4442 void *response, size_t responseLen) {
4443 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
4445 if (radioService[slotId]->mRadioResponse != NULL) {
4446 RadioResponseInfo responseInfo = {};
4447 populateResponseInfo(responseInfo, serial, responseType, e);
4448 bool enable = false;
4449 int numInts = responseLen / sizeof(int);
4450 if (response == NULL || numInts != 1) {
4451 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
4452 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4454 int *pInt = (int *) response;
4455 enable = pInt[0] == 1 ? true : false;
4457 Return<void> retStatus
4458 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
4459 responseInfo, enable);
4460 radioService[slotId]->checkReturnStatus(retStatus);
4462 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4469 int radio::sendCDMAFeatureCodeResponse(int slotId,
4470 int responseType, int serial, RIL_Errno e,
4471 void *response, size_t responseLen) {
4472 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
4474 if (radioService[slotId]->mRadioResponse != NULL) {
4475 RadioResponseInfo responseInfo = {};
4476 populateResponseInfo(responseInfo, serial, responseType, e);
4477 Return<void> retStatus
4478 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
4479 radioService[slotId]->checkReturnStatus(retStatus);
4481 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
4488 int radio::sendBurstDtmfResponse(int slotId,
4489 int responseType, int serial, RIL_Errno e,
4490 void *response, size_t responseLen) {
4491 RLOGD("sendBurstDtmfResponse: serial %d", serial);
4493 if (radioService[slotId]->mRadioResponse != NULL) {
4494 RadioResponseInfo responseInfo = {};
4495 populateResponseInfo(responseInfo, serial, responseType, e);
4496 Return<void> retStatus
4497 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
4498 radioService[slotId]->checkReturnStatus(retStatus);
4500 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4506 int radio::sendCdmaSmsResponse(int slotId,
4507 int responseType, int serial, RIL_Errno e, void *response,
4508 size_t responseLen) {
4509 RLOGD("sendCdmaSmsResponse: serial %d", serial);
4511 if (radioService[slotId]->mRadioResponse != NULL) {
4512 RadioResponseInfo responseInfo = {};
4513 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4516 Return<void> retStatus
4517 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
4518 radioService[slotId]->checkReturnStatus(retStatus);
4520 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4526 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
4527 int responseType, int serial, RIL_Errno e,
4528 void *response, size_t responseLen) {
4529 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
4531 if (radioService[slotId]->mRadioResponse != NULL) {
4532 RadioResponseInfo responseInfo = {};
4533 populateResponseInfo(responseInfo, serial, responseType, e);
4534 Return<void> retStatus
4535 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
4537 radioService[slotId]->checkReturnStatus(retStatus);
4539 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
4546 int radio::getGsmBroadcastConfigResponse(int slotId,
4547 int responseType, int serial, RIL_Errno e,
4548 void *response, size_t responseLen) {
4549 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
4551 if (radioService[slotId]->mRadioResponse != NULL) {
4552 RadioResponseInfo responseInfo = {};
4553 populateResponseInfo(responseInfo, serial, responseType, e);
4554 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
4556 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
4557 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
4558 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4560 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
4561 configs.resize(num);
4562 for (int i = 0 ; i < num; i++) {
4563 RIL_GSM_BroadcastSmsConfigInfo *resp =
4564 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
4565 configs[i].fromServiceId = resp->fromServiceId;
4566 configs[i].toServiceId = resp->toServiceId;
4567 configs[i].fromCodeScheme = resp->fromCodeScheme;
4568 configs[i].toCodeScheme = resp->toCodeScheme;
4569 configs[i].selected = resp->selected == 1 ? true : false;
4573 Return<void> retStatus
4574 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
4576 radioService[slotId]->checkReturnStatus(retStatus);
4578 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4585 int radio::setGsmBroadcastConfigResponse(int slotId,
4586 int responseType, int serial, RIL_Errno e,
4587 void *response, size_t responseLen) {
4588 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
4590 if (radioService[slotId]->mRadioResponse != NULL) {
4591 RadioResponseInfo responseInfo = {};
4592 populateResponseInfo(responseInfo, serial, responseType, e);
4593 Return<void> retStatus
4594 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
4595 radioService[slotId]->checkReturnStatus(retStatus);
4597 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4604 int radio::setGsmBroadcastActivationResponse(int slotId,
4605 int responseType, int serial, RIL_Errno e,
4606 void *response, size_t responseLen) {
4607 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
4609 if (radioService[slotId]->mRadioResponse != NULL) {
4610 RadioResponseInfo responseInfo = {};
4611 populateResponseInfo(responseInfo, serial, responseType, e);
4612 Return<void> retStatus
4613 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
4615 radioService[slotId]->checkReturnStatus(retStatus);
4617 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
4624 int radio::getCdmaBroadcastConfigResponse(int slotId,
4625 int responseType, int serial, RIL_Errno e,
4626 void *response, size_t responseLen) {
4627 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
4629 if (radioService[slotId]->mRadioResponse != NULL) {
4630 RadioResponseInfo responseInfo = {};
4631 populateResponseInfo(responseInfo, serial, responseType, e);
4632 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
4634 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
4635 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
4636 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4638 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
4639 configs.resize(num);
4640 for (int i = 0 ; i < num; i++) {
4641 RIL_CDMA_BroadcastSmsConfigInfo *resp =
4642 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
4643 configs[i].serviceCategory = resp->service_category;
4644 configs[i].language = resp->language;
4645 configs[i].selected = resp->selected == 1 ? true : false;
4649 Return<void> retStatus
4650 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
4652 radioService[slotId]->checkReturnStatus(retStatus);
4654 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4661 int radio::setCdmaBroadcastConfigResponse(int slotId,
4662 int responseType, int serial, RIL_Errno e,
4663 void *response, size_t responseLen) {
4664 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
4666 if (radioService[slotId]->mRadioResponse != NULL) {
4667 RadioResponseInfo responseInfo = {};
4668 populateResponseInfo(responseInfo, serial, responseType, e);
4669 Return<void> retStatus
4670 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
4672 radioService[slotId]->checkReturnStatus(retStatus);
4674 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
4681 int radio::setCdmaBroadcastActivationResponse(int slotId,
4682 int responseType, int serial, RIL_Errno e,
4683 void *response, size_t responseLen) {
4684 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
4686 if (radioService[slotId]->mRadioResponse != NULL) {
4687 RadioResponseInfo responseInfo = {};
4688 populateResponseInfo(responseInfo, serial, responseType, e);
4689 Return<void> retStatus
4690 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
4692 radioService[slotId]->checkReturnStatus(retStatus);
4694 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
4701 int radio::getCDMASubscriptionResponse(int slotId,
4702 int responseType, int serial, RIL_Errno e, void *response,
4703 size_t responseLen) {
4704 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
4706 if (radioService[slotId]->mRadioResponse != NULL) {
4707 RadioResponseInfo responseInfo = {};
4708 populateResponseInfo(responseInfo, serial, responseType, e);
4710 int numStrings = responseLen / sizeof(char *);
4711 hidl_string emptyString;
4712 if (response == NULL || numStrings != 5) {
4713 RLOGE("getOperatorResponse Invalid response: NULL");
4714 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4715 Return<void> retStatus
4716 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
4717 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
4718 radioService[slotId]->checkReturnStatus(retStatus);
4720 char **resp = (char **) response;
4721 Return<void> retStatus
4722 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
4724 convertCharPtrToHidlString(resp[0]),
4725 convertCharPtrToHidlString(resp[1]),
4726 convertCharPtrToHidlString(resp[2]),
4727 convertCharPtrToHidlString(resp[3]),
4728 convertCharPtrToHidlString(resp[4]));
4729 radioService[slotId]->checkReturnStatus(retStatus);
4732 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
4739 int radio::writeSmsToRuimResponse(int slotId,
4740 int responseType, int serial, RIL_Errno e,
4741 void *response, size_t responseLen) {
4742 RLOGD("writeSmsToRuimResponse: serial %d", serial);
4744 if (radioService[slotId]->mRadioResponse != NULL) {
4745 RadioResponseInfo responseInfo = {};
4746 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4747 Return<void> retStatus
4748 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
4749 radioService[slotId]->checkReturnStatus(retStatus);
4751 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4757 int radio::deleteSmsOnRuimResponse(int slotId,
4758 int responseType, int serial, RIL_Errno e,
4759 void *response, size_t responseLen) {
4760 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
4762 if (radioService[slotId]->mRadioResponse != NULL) {
4763 RadioResponseInfo responseInfo = {};
4764 populateResponseInfo(responseInfo, serial, responseType, e);
4765 Return<void> retStatus
4766 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
4767 radioService[slotId]->checkReturnStatus(retStatus);
4769 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4775 int radio::getDeviceIdentityResponse(int slotId,
4776 int responseType, int serial, RIL_Errno e, void *response,
4777 size_t responseLen) {
4778 RLOGD("getDeviceIdentityResponse: serial %d", serial);
4780 if (radioService[slotId]->mRadioResponse != NULL) {
4781 RadioResponseInfo responseInfo = {};
4782 populateResponseInfo(responseInfo, serial, responseType, e);
4784 int numStrings = responseLen / sizeof(char *);
4785 hidl_string emptyString;
4786 if (response == NULL || numStrings != 4) {
4787 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
4788 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4789 Return<void> retStatus
4790 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
4791 emptyString, emptyString, emptyString, emptyString);
4792 radioService[slotId]->checkReturnStatus(retStatus);
4794 char **resp = (char **) response;
4795 Return<void> retStatus
4796 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
4797 convertCharPtrToHidlString(resp[0]),
4798 convertCharPtrToHidlString(resp[1]),
4799 convertCharPtrToHidlString(resp[2]),
4800 convertCharPtrToHidlString(resp[3]));
4801 radioService[slotId]->checkReturnStatus(retStatus);
4804 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
4811 int radio::exitEmergencyCallbackModeResponse(int slotId,
4812 int responseType, int serial, RIL_Errno e,
4813 void *response, size_t responseLen) {
4814 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
4816 if (radioService[slotId]->mRadioResponse != NULL) {
4817 RadioResponseInfo responseInfo = {};
4818 populateResponseInfo(responseInfo, serial, responseType, e);
4819 Return<void> retStatus
4820 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
4822 radioService[slotId]->checkReturnStatus(retStatus);
4824 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
4831 int radio::getSmscAddressResponse(int slotId,
4832 int responseType, int serial, RIL_Errno e,
4833 void *response, size_t responseLen) {
4834 RLOGD("getSmscAddressResponse: serial %d", serial);
4836 if (radioService[slotId]->mRadioResponse != NULL) {
4837 RadioResponseInfo responseInfo = {};
4838 populateResponseInfo(responseInfo, serial, responseType, e);
4839 Return<void> retStatus
4840 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
4841 convertCharPtrToHidlString((char *) response));
4842 radioService[slotId]->checkReturnStatus(retStatus);
4844 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4850 int radio::setSmscAddressResponse(int slotId,
4851 int responseType, int serial, RIL_Errno e,
4852 void *response, size_t responseLen) {
4853 RLOGD("setSmscAddressResponse: serial %d", serial);
4855 if (radioService[slotId]->mRadioResponse != NULL) {
4856 RadioResponseInfo responseInfo = {};
4857 populateResponseInfo(responseInfo, serial, responseType, e);
4858 Return<void> retStatus
4859 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
4860 radioService[slotId]->checkReturnStatus(retStatus);
4862 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4868 int radio::reportSmsMemoryStatusResponse(int slotId,
4869 int responseType, int serial, RIL_Errno e,
4870 void *response, size_t responseLen) {
4871 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
4873 if (radioService[slotId]->mRadioResponse != NULL) {
4874 RadioResponseInfo responseInfo = {};
4875 populateResponseInfo(responseInfo, serial, responseType, e);
4876 Return<void> retStatus
4877 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
4878 radioService[slotId]->checkReturnStatus(retStatus);
4880 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
4887 int radio::reportStkServiceIsRunningResponse(int slotId,
4888 int responseType, int serial, RIL_Errno e,
4889 void *response, size_t responseLen) {
4890 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
4892 if (radioService[slotId]->mRadioResponse != NULL) {
4893 RadioResponseInfo responseInfo = {};
4894 populateResponseInfo(responseInfo, serial, responseType, e);
4895 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4896 reportStkServiceIsRunningResponse(responseInfo);
4897 radioService[slotId]->checkReturnStatus(retStatus);
4899 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
4906 int radio::getCdmaSubscriptionSourceResponse(int slotId,
4907 int responseType, int serial, RIL_Errno e,
4908 void *response, size_t responseLen) {
4909 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
4911 if (radioService[slotId]->mRadioResponse != NULL) {
4912 RadioResponseInfo responseInfo = {};
4913 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4914 Return<void> retStatus
4915 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
4916 responseInfo, (CdmaSubscriptionSource) ret);
4917 radioService[slotId]->checkReturnStatus(retStatus);
4919 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4926 int radio::requestIsimAuthenticationResponse(int slotId,
4927 int responseType, int serial, RIL_Errno e,
4928 void *response, size_t responseLen) {
4929 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
4931 if (radioService[slotId]->mRadioResponse != NULL) {
4932 RadioResponseInfo responseInfo = {};
4933 populateResponseInfo(responseInfo, serial, responseType, e);
4934 Return<void> retStatus
4935 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
4937 convertCharPtrToHidlString((char *) response));
4938 radioService[slotId]->checkReturnStatus(retStatus);
4940 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
4947 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
4949 int serial, RIL_Errno e, void *response,
4950 size_t responseLen) {
4951 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
4953 if (radioService[slotId]->mRadioResponse != NULL) {
4954 RadioResponseInfo responseInfo = {};
4955 populateResponseInfo(responseInfo, serial, responseType, e);
4956 Return<void> retStatus
4957 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
4959 radioService[slotId]->checkReturnStatus(retStatus);
4961 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
4968 int radio::sendEnvelopeWithStatusResponse(int slotId,
4969 int responseType, int serial, RIL_Errno e, void *response,
4970 size_t responseLen) {
4971 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
4973 if (radioService[slotId]->mRadioResponse != NULL) {
4974 RadioResponseInfo responseInfo = {};
4975 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
4976 response, responseLen);
4978 Return<void> retStatus
4979 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
4981 radioService[slotId]->checkReturnStatus(retStatus);
4983 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
4990 int radio::getVoiceRadioTechnologyResponse(int slotId,
4991 int responseType, int serial, RIL_Errno e,
4992 void *response, size_t responseLen) {
4993 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
4995 if (radioService[slotId]->mRadioResponse != NULL) {
4996 RadioResponseInfo responseInfo = {};
4997 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4998 Return<void> retStatus
4999 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5000 responseInfo, (RadioTechnology) ret);
5001 radioService[slotId]->checkReturnStatus(retStatus);
5003 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5010 int radio::getCellInfoListResponse(int slotId,
5012 int serial, RIL_Errno e, void *response,
5013 size_t responseLen) {
5014 RLOGD("getCellInfoListResponse: serial %d", serial);
5016 if (radioService[slotId]->mRadioResponse != NULL) {
5017 RadioResponseInfo responseInfo = {};
5018 populateResponseInfo(responseInfo, serial, responseType, e);
5020 hidl_vec<CellInfo> ret;
5021 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5022 RLOGE("getCellInfoListResponse: Invalid response");
5023 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5025 convertRilCellInfoListToHal(response, responseLen, ret);
5028 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5030 radioService[slotId]->checkReturnStatus(retStatus);
5032 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5038 int radio::setCellInfoListRateResponse(int slotId,
5040 int serial, RIL_Errno e, void *response,
5041 size_t responseLen) {
5042 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5044 if (radioService[slotId]->mRadioResponse != NULL) {
5045 RadioResponseInfo responseInfo = {};
5046 populateResponseInfo(responseInfo, serial, responseType, e);
5047 Return<void> retStatus
5048 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5049 radioService[slotId]->checkReturnStatus(retStatus);
5051 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5058 int radio::setInitialAttachApnResponse(int slotId,
5059 int responseType, int serial, RIL_Errno e,
5060 void *response, size_t responseLen) {
5061 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5063 if (radioService[slotId]->mRadioResponse != NULL) {
5064 RadioResponseInfo responseInfo = {};
5065 populateResponseInfo(responseInfo, serial, responseType, e);
5066 Return<void> retStatus
5067 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5068 radioService[slotId]->checkReturnStatus(retStatus);
5070 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5077 int radio::getImsRegistrationStateResponse(int slotId,
5078 int responseType, int serial, RIL_Errno e,
5079 void *response, size_t responseLen) {
5080 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5082 if (radioService[slotId]->mRadioResponse != NULL) {
5083 RadioResponseInfo responseInfo = {};
5084 populateResponseInfo(responseInfo, serial, responseType, e);
5085 bool isRegistered = false;
5087 int numInts = responseLen / sizeof(int);
5088 if (response == NULL || numInts != 2) {
5089 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5090 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5092 int *pInt = (int *) response;
5093 isRegistered = pInt[0] == 1 ? true : false;
5094 ratFamily = pInt[1];
5096 Return<void> retStatus
5097 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5098 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5099 radioService[slotId]->checkReturnStatus(retStatus);
5101 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5108 int radio::sendImsSmsResponse(int slotId,
5109 int responseType, int serial, RIL_Errno e, void *response,
5110 size_t responseLen) {
5111 RLOGD("sendImsSmsResponse: serial %d", serial);
5113 if (radioService[slotId]->mRadioResponse != NULL) {
5114 RadioResponseInfo responseInfo = {};
5115 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5118 Return<void> retStatus
5119 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5120 radioService[slotId]->checkReturnStatus(retStatus);
5122 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5128 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5129 int responseType, int serial, RIL_Errno e,
5130 void *response, size_t responseLen) {
5131 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5133 if (radioService[slotId]->mRadioResponse != NULL) {
5134 RadioResponseInfo responseInfo = {};
5135 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5138 Return<void> retStatus
5139 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5140 responseInfo, result);
5141 radioService[slotId]->checkReturnStatus(retStatus);
5143 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5150 int radio::iccOpenLogicalChannelResponse(int slotId,
5151 int responseType, int serial, RIL_Errno e, void *response,
5152 size_t responseLen) {
5153 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5155 if (radioService[slotId]->mRadioResponse != NULL) {
5156 RadioResponseInfo responseInfo = {};
5157 populateResponseInfo(responseInfo, serial, responseType, e);
5159 hidl_vec<int8_t> selectResponse;
5160 int numInts = responseLen / sizeof(int);
5161 if (response == NULL || responseLen % sizeof(int) != 0) {
5162 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5163 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5165 int *pInt = (int *) response;
5166 channelId = pInt[0];
5167 selectResponse.resize(numInts - 1);
5168 for (int i = 1; i < numInts; i++) {
5169 selectResponse[i - 1] = (int8_t) pInt[i];
5172 Return<void> retStatus
5173 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5174 channelId, selectResponse);
5175 radioService[slotId]->checkReturnStatus(retStatus);
5177 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5184 int radio::iccCloseLogicalChannelResponse(int slotId,
5185 int responseType, int serial, RIL_Errno e,
5186 void *response, size_t responseLen) {
5187 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5189 if (radioService[slotId]->mRadioResponse != NULL) {
5190 RadioResponseInfo responseInfo = {};
5191 populateResponseInfo(responseInfo, serial, responseType, e);
5192 Return<void> retStatus
5193 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5195 radioService[slotId]->checkReturnStatus(retStatus);
5197 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5204 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5205 int responseType, int serial, RIL_Errno e,
5206 void *response, size_t responseLen) {
5207 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5209 if (radioService[slotId]->mRadioResponse != NULL) {
5210 RadioResponseInfo responseInfo = {};
5211 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5214 Return<void> retStatus
5215 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5216 responseInfo, result);
5217 radioService[slotId]->checkReturnStatus(retStatus);
5219 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5226 int radio::nvReadItemResponse(int slotId,
5227 int responseType, int serial, RIL_Errno e,
5228 void *response, size_t responseLen) {
5229 RLOGD("nvReadItemResponse: serial %d", serial);
5231 if (radioService[slotId]->mRadioResponse != NULL) {
5232 RadioResponseInfo responseInfo = {};
5233 populateResponseInfo(responseInfo, serial, responseType, e);
5234 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5236 convertCharPtrToHidlString((char *) response));
5237 radioService[slotId]->checkReturnStatus(retStatus);
5239 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5245 int radio::nvWriteItemResponse(int slotId,
5246 int responseType, int serial, RIL_Errno e,
5247 void *response, size_t responseLen) {
5248 RLOGD("nvWriteItemResponse: serial %d", serial);
5250 if (radioService[slotId]->mRadioResponse != NULL) {
5251 RadioResponseInfo responseInfo = {};
5252 populateResponseInfo(responseInfo, serial, responseType, e);
5253 Return<void> retStatus
5254 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5255 radioService[slotId]->checkReturnStatus(retStatus);
5257 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5263 int radio::nvWriteCdmaPrlResponse(int slotId,
5264 int responseType, int serial, RIL_Errno e,
5265 void *response, size_t responseLen) {
5266 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5268 if (radioService[slotId]->mRadioResponse != NULL) {
5269 RadioResponseInfo responseInfo = {};
5270 populateResponseInfo(responseInfo, serial, responseType, e);
5271 Return<void> retStatus
5272 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5273 radioService[slotId]->checkReturnStatus(retStatus);
5275 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5281 int radio::nvResetConfigResponse(int slotId,
5282 int responseType, int serial, RIL_Errno e,
5283 void *response, size_t responseLen) {
5284 RLOGD("nvResetConfigResponse: serial %d", serial);
5286 if (radioService[slotId]->mRadioResponse != NULL) {
5287 RadioResponseInfo responseInfo = {};
5288 populateResponseInfo(responseInfo, serial, responseType, e);
5289 Return<void> retStatus
5290 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5291 radioService[slotId]->checkReturnStatus(retStatus);
5293 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5299 int radio::setUiccSubscriptionResponse(int slotId,
5300 int responseType, int serial, RIL_Errno e,
5301 void *response, size_t responseLen) {
5302 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5304 if (radioService[slotId]->mRadioResponse != NULL) {
5305 RadioResponseInfo responseInfo = {};
5306 populateResponseInfo(responseInfo, serial, responseType, e);
5307 Return<void> retStatus
5308 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5309 radioService[slotId]->checkReturnStatus(retStatus);
5311 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5318 int radio::setDataAllowedResponse(int slotId,
5319 int responseType, int serial, RIL_Errno e,
5320 void *response, size_t responseLen) {
5321 RLOGD("setDataAllowedResponse: serial %d", serial);
5323 if (radioService[slotId]->mRadioResponse != NULL) {
5324 RadioResponseInfo responseInfo = {};
5325 populateResponseInfo(responseInfo, serial, responseType, e);
5326 Return<void> retStatus
5327 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5328 radioService[slotId]->checkReturnStatus(retStatus);
5330 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5336 int radio::getHardwareConfigResponse(int slotId,
5337 int responseType, int serial, RIL_Errno e,
5338 void *response, size_t responseLen) {
5339 RLOGD("getHardwareConfigResponse: serial %d", serial);
5341 if (radioService[slotId]->mRadioResponse != NULL) {
5342 RadioResponseInfo responseInfo = {};
5343 populateResponseInfo(responseInfo, serial, responseType, e);
5345 hidl_vec<HardwareConfig> result;
5346 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
5347 RLOGE("hardwareConfigChangedInd: invalid response");
5348 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5350 convertRilHardwareConfigListToHal(response, responseLen, result);
5353 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
5354 responseInfo, result);
5355 radioService[slotId]->checkReturnStatus(retStatus);
5357 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5363 int radio::requestIccSimAuthenticationResponse(int slotId,
5364 int responseType, int serial, RIL_Errno e,
5365 void *response, size_t responseLen) {
5366 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
5368 if (radioService[slotId]->mRadioResponse != NULL) {
5369 RadioResponseInfo responseInfo = {};
5370 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5373 Return<void> retStatus
5374 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
5375 responseInfo, result);
5376 radioService[slotId]->checkReturnStatus(retStatus);
5378 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
5385 int radio::setDataProfileResponse(int slotId,
5386 int responseType, int serial, RIL_Errno e,
5387 void *response, size_t responseLen) {
5388 RLOGD("setDataProfileResponse: serial %d", serial);
5390 if (radioService[slotId]->mRadioResponse != NULL) {
5391 RadioResponseInfo responseInfo = {};
5392 populateResponseInfo(responseInfo, serial, responseType, e);
5393 Return<void> retStatus
5394 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
5395 radioService[slotId]->checkReturnStatus(retStatus);
5397 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5403 int radio::requestShutdownResponse(int slotId,
5404 int responseType, int serial, RIL_Errno e,
5405 void *response, size_t responseLen) {
5406 RLOGD("requestShutdownResponse: serial %d", serial);
5408 if (radioService[slotId]->mRadioResponse != NULL) {
5409 RadioResponseInfo responseInfo = {};
5410 populateResponseInfo(responseInfo, serial, responseType, e);
5411 Return<void> retStatus
5412 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
5413 radioService[slotId]->checkReturnStatus(retStatus);
5415 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5421 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
5422 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
5423 populateResponseInfo(responseInfo, serial, responseType, e);
5425 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
5426 RLOGE("responseRadioCapability: Invalid response");
5427 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5428 rc.logicalModemUuid = hidl_string();
5430 convertRilRadioCapabilityToHal(response, responseLen, rc);
5434 int radio::getRadioCapabilityResponse(int slotId,
5435 int responseType, int serial, RIL_Errno e,
5436 void *response, size_t responseLen) {
5437 RLOGD("getRadioCapabilityResponse: serial %d", serial);
5439 if (radioService[slotId]->mRadioResponse != NULL) {
5440 RadioResponseInfo responseInfo = {};
5441 RadioCapability result = {};
5442 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
5444 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
5445 responseInfo, result);
5446 radioService[slotId]->checkReturnStatus(retStatus);
5448 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5454 int radio::setRadioCapabilityResponse(int slotId,
5455 int responseType, int serial, RIL_Errno e,
5456 void *response, size_t responseLen) {
5457 RLOGD("setRadioCapabilityResponse: serial %d", serial);
5459 if (radioService[slotId]->mRadioResponse != NULL) {
5460 RadioResponseInfo responseInfo = {};
5461 RadioCapability result = {};
5462 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
5464 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
5465 responseInfo, result);
5466 radioService[slotId]->checkReturnStatus(retStatus);
5468 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5474 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
5475 RIL_Errno e, void *response, size_t responseLen) {
5476 populateResponseInfo(responseInfo, serial, responseType, e);
5477 LceStatusInfo result = {};
5479 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
5480 RLOGE("Invalid response: NULL");
5481 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5483 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
5484 result.lceStatus = (LceStatus) resp->lce_status;
5485 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
5490 int radio::startLceServiceResponse(int slotId,
5491 int responseType, int serial, RIL_Errno e,
5492 void *response, size_t responseLen) {
5493 RLOGD("startLceServiceResponse: serial %d", serial);
5495 if (radioService[slotId]->mRadioResponse != NULL) {
5496 RadioResponseInfo responseInfo = {};
5497 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
5498 response, responseLen);
5500 Return<void> retStatus
5501 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
5503 radioService[slotId]->checkReturnStatus(retStatus);
5505 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5511 int radio::stopLceServiceResponse(int slotId,
5512 int responseType, int serial, RIL_Errno e,
5513 void *response, size_t responseLen) {
5514 RLOGD("stopLceServiceResponse: serial %d", serial);
5516 if (radioService[slotId]->mRadioResponse != NULL) {
5517 RadioResponseInfo responseInfo = {};
5518 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
5519 response, responseLen);
5521 Return<void> retStatus
5522 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
5524 radioService[slotId]->checkReturnStatus(retStatus);
5526 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5532 int radio::pullLceDataResponse(int slotId,
5533 int responseType, int serial, RIL_Errno e,
5534 void *response, size_t responseLen) {
5535 RLOGD("pullLceDataResponse: serial %d", serial);
5537 if (radioService[slotId]->mRadioResponse != NULL) {
5538 RadioResponseInfo responseInfo = {};
5539 populateResponseInfo(responseInfo, serial, responseType, e);
5541 LceDataInfo result = {};
5542 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
5543 RLOGE("pullLceDataResponse: Invalid response");
5544 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5546 convertRilLceDataInfoToHal(response, responseLen, result);
5549 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
5550 responseInfo, result);
5551 radioService[slotId]->checkReturnStatus(retStatus);
5553 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5559 int radio::getModemActivityInfoResponse(int slotId,
5560 int responseType, int serial, RIL_Errno e,
5561 void *response, size_t responseLen) {
5562 RLOGD("getModemActivityInfoResponse: serial %d", serial);
5564 if (radioService[slotId]->mRadioResponse != NULL) {
5565 RadioResponseInfo responseInfo = {};
5566 populateResponseInfo(responseInfo, serial, responseType, e);
5567 ActivityStatsInfo info;
5568 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
5569 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
5570 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5572 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
5573 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
5574 info.idleModeTimeMs = resp->idle_mode_time_ms;
5575 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
5576 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
5578 info.rxModeTimeMs = resp->rx_mode_time_ms;
5581 Return<void> retStatus
5582 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
5584 radioService[slotId]->checkReturnStatus(retStatus);
5586 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
5593 int radio::setAllowedCarriersResponse(int slotId,
5594 int responseType, int serial, RIL_Errno e,
5595 void *response, size_t responseLen) {
5596 RLOGD("setAllowedCarriersResponse: serial %d", serial);
5598 if (radioService[slotId]->mRadioResponse != NULL) {
5599 RadioResponseInfo responseInfo = {};
5600 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5601 Return<void> retStatus
5602 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
5604 radioService[slotId]->checkReturnStatus(retStatus);
5606 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
5613 int radio::getAllowedCarriersResponse(int slotId,
5614 int responseType, int serial, RIL_Errno e,
5615 void *response, size_t responseLen) {
5616 RLOGD("getAllowedCarriersResponse: serial %d", serial);
5618 if (radioService[slotId]->mRadioResponse != NULL) {
5619 RadioResponseInfo responseInfo = {};
5620 populateResponseInfo(responseInfo, serial, responseType, e);
5621 CarrierRestrictions carrierInfo = {};
5622 bool allAllowed = true;
5623 if (response == NULL || responseLen != sizeof(RIL_CarrierRestrictions)) {
5624 RLOGE("getAllowedCarriersResponse Invalid response: NULL");
5625 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5627 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
5628 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
5632 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
5633 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
5634 RIL_Carrier *carrier = pCr->allowed_carriers + i;
5635 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
5636 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
5637 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
5638 carrierInfo.allowedCarriers[i].matchData =
5639 convertCharPtrToHidlString(carrier->match_data);
5642 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
5643 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
5644 RIL_Carrier *carrier = pCr->excluded_carriers + i;
5645 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
5646 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
5647 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
5648 carrierInfo.excludedCarriers[i].matchData =
5649 convertCharPtrToHidlString(carrier->match_data);
5653 Return<void> retStatus
5654 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
5655 allAllowed, carrierInfo);
5656 radioService[slotId]->checkReturnStatus(retStatus);
5658 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
5665 int radio::sendDeviceStateResponse(int slotId,
5666 int responseType, int serial, RIL_Errno e,
5667 void *response, size_t responselen) {
5668 RLOGD("sendDeviceStateResponse: serial %d", serial);
5670 if (radioService[slotId]->mRadioResponse != NULL) {
5671 RadioResponseInfo responseInfo = {};
5672 populateResponseInfo(responseInfo, serial, responseType, e);
5673 Return<void> retStatus
5674 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
5675 radioService[slotId]->checkReturnStatus(retStatus);
5677 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5683 int radio::setIndicationFilterResponse(int slotId,
5684 int responseType, int serial, RIL_Errno e,
5685 void *response, size_t responselen) {
5686 RLOGD("setIndicationFilterResponse: serial %d", serial);
5688 if (radioService[slotId]->mRadioResponse != NULL) {
5689 RadioResponseInfo responseInfo = {};
5690 populateResponseInfo(responseInfo, serial, responseType, e);
5691 Return<void> retStatus
5692 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
5693 radioService[slotId]->checkReturnStatus(retStatus);
5695 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
5703 int radio::setSimCardPowerResponse(int slotId,
5704 int responseType, int serial, RIL_Errno e,
5705 void *response, size_t responseLen) {
5706 RLOGD("setSimCardPowerResponse: serial %d", serial);
5708 if (radioService[slotId]->mRadioResponse != NULL) {
5709 RadioResponseInfo responseInfo = {};
5710 populateResponseInfo(responseInfo, serial, responseType, e);
5711 Return<void> retStatus
5712 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
5713 radioService[slotId]->checkReturnStatus(retStatus);
5715 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5721 int radio::sendRequestRawResponse(int slotId,
5722 int responseType, int serial, RIL_Errno e,
5723 void *response, size_t responseLen) {
5724 RLOGD("sendRequestRawResponse: serial %d", serial);
5726 if (oemHookService[slotId]->mOemHookResponse != NULL) {
5727 RadioResponseInfo responseInfo = {};
5728 populateResponseInfo(responseInfo, serial, responseType, e);
5729 hidl_vec<uint8_t> data;
5731 if (response == NULL) {
5732 RLOGE("sendRequestRawResponse: Invalid response");
5733 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5735 data.setToExternal((uint8_t *) response, responseLen);
5737 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
5738 sendRequestRawResponse(responseInfo, data);
5739 checkReturnStatus(slotId, retStatus, false);
5741 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
5748 int radio::sendRequestStringsResponse(int slotId,
5749 int responseType, int serial, RIL_Errno e,
5750 void *response, size_t responseLen) {
5751 RLOGD("sendRequestStringsResponse: serial %d", serial);
5753 if (oemHookService[slotId]->mOemHookResponse != NULL) {
5754 RadioResponseInfo responseInfo = {};
5755 populateResponseInfo(responseInfo, serial, responseType, e);
5756 hidl_vec<hidl_string> data;
5758 if (response == NULL || responseLen % sizeof(char *) != 0) {
5759 RLOGE("sendRequestStringsResponse Invalid response: NULL");
5760 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5762 char **resp = (char **) response;
5763 int numStrings = responseLen / sizeof(char *);
5764 data.resize(numStrings);
5765 for (int i = 0; i < numStrings; i++) {
5766 data[i] = convertCharPtrToHidlString(resp[i]);
5769 Return<void> retStatus
5770 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
5771 responseInfo, data);
5772 checkReturnStatus(slotId, retStatus, false);
5774 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
5781 // Radio Indication functions
5783 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
5784 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
5785 (RadioIndicationType::UNSOLICITED_ACK_EXP);
5788 int radio::radioStateChangedInd(int slotId,
5789 int indicationType, int token, RIL_Errno e, void *response,
5790 size_t responseLen) {
5791 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5792 RadioState radioState = (RadioState) s_vendorFunctions->onStateRequest();
5793 RLOGD("radioStateChangedInd: radioState %d", radioState);
5794 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
5795 convertIntToRadioIndicationType(indicationType), radioState);
5796 radioService[slotId]->checkReturnStatus(retStatus);
5798 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
5804 int radio::callStateChangedInd(int slotId,
5805 int indicationType, int token, RIL_Errno e, void *response,
5806 size_t responseLen) {
5807 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5808 RLOGD("callStateChangedInd");
5809 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
5810 convertIntToRadioIndicationType(indicationType));
5811 radioService[slotId]->checkReturnStatus(retStatus);
5813 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
5819 int radio::networkStateChangedInd(int slotId,
5820 int indicationType, int token, RIL_Errno e, void *response,
5821 size_t responseLen) {
5822 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5823 RLOGD("networkStateChangedInd");
5824 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
5825 convertIntToRadioIndicationType(indicationType));
5826 radioService[slotId]->checkReturnStatus(retStatus);
5828 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
5835 uint8_t hexCharToInt(uint8_t c) {
5836 if (c >= '0' && c <= '9') return (c - '0');
5837 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
5838 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
5840 return INVALID_HEX_CHAR;
5843 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
5844 if (responseLen % 2 != 0) {
5848 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
5849 if (bytes == NULL) {
5850 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
5853 uint8_t *hexString = (uint8_t *)response;
5855 for (size_t i = 0; i < responseLen; i += 2) {
5856 uint8_t hexChar1 = hexCharToInt(hexString[i]);
5857 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
5859 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
5860 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
5861 hexString[i], hexString[i + 1]);
5865 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
5871 int radio::newSmsInd(int slotId, int indicationType,
5872 int token, RIL_Errno e, void *response, size_t responseLen) {
5873 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5874 if (response == NULL || responseLen == 0) {
5875 RLOGE("newSmsInd: invalid response");
5879 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
5880 if (bytes == NULL) {
5881 RLOGE("newSmsInd: convertHexStringToBytes failed");
5885 hidl_vec<uint8_t> pdu;
5886 pdu.setToExternal(bytes, responseLen/2);
5888 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
5889 convertIntToRadioIndicationType(indicationType), pdu);
5890 radioService[slotId]->checkReturnStatus(retStatus);
5893 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
5899 int radio::newSmsStatusReportInd(int slotId,
5900 int indicationType, int token, RIL_Errno e, void *response,
5901 size_t responseLen) {
5902 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5903 if (response == NULL || responseLen == 0) {
5904 RLOGE("newSmsStatusReportInd: invalid response");
5908 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
5909 if (bytes == NULL) {
5910 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
5914 hidl_vec<uint8_t> pdu;
5915 pdu.setToExternal(bytes, responseLen/2);
5916 RLOGD("newSmsStatusReportInd");
5917 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
5918 convertIntToRadioIndicationType(indicationType), pdu);
5919 radioService[slotId]->checkReturnStatus(retStatus);
5922 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
5928 int radio::newSmsOnSimInd(int slotId, int indicationType,
5929 int token, RIL_Errno e, void *response, size_t responseLen) {
5930 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5931 if (response == NULL || responseLen != sizeof(int)) {
5932 RLOGE("newSmsOnSimInd: invalid response");
5935 int32_t recordNumber = ((int32_t *) response)[0];
5936 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
5937 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
5938 convertIntToRadioIndicationType(indicationType), recordNumber);
5939 radioService[slotId]->checkReturnStatus(retStatus);
5941 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
5947 int radio::onUssdInd(int slotId, int indicationType,
5948 int token, RIL_Errno e, void *response, size_t responseLen) {
5949 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5950 if (response == NULL || responseLen != 2 * sizeof(char *)) {
5951 RLOGE("onUssdInd: invalid response");
5954 char **strings = (char **) response;
5955 char *mode = strings[0];
5956 hidl_string msg = convertCharPtrToHidlString(strings[1]);
5957 UssdModeType modeType = (UssdModeType) atoi(mode);
5958 RLOGD("onUssdInd: mode %s", mode);
5959 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
5960 convertIntToRadioIndicationType(indicationType), modeType, msg);
5961 radioService[slotId]->checkReturnStatus(retStatus);
5963 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
5969 int radio::nitzTimeReceivedInd(int slotId,
5970 int indicationType, int token, RIL_Errno e, void *response,
5971 size_t responseLen) {
5972 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
5973 if (response == NULL || responseLen == 0) {
5974 RLOGE("nitzTimeReceivedInd: invalid response");
5977 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
5978 int64_t timeReceived = android::elapsedRealtime();
5979 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
5981 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
5982 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
5983 radioService[slotId]->checkReturnStatus(retStatus);
5985 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
5992 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
5993 SignalStrength& signalStrength) {
5994 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
5996 // Fixup LTE for backwards compatibility
5997 // signalStrength: -1 -> 99
5998 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
5999 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6001 // rsrp: -1 -> INT_MAX all other negative value to positive.
6003 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6004 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6005 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6006 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6008 // rsrq: -1 -> INT_MAX
6009 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6010 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6012 // Not remapping rssnr is already using INT_MAX
6013 // cqi: -1 -> INT_MAX
6014 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6015 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6018 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6019 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6020 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6021 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6022 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6023 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6024 signalStrength.evdo.signalNoiseRatio =
6025 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6026 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6027 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6028 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6029 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6030 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6031 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6032 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6035 int radio::currentSignalStrengthInd(int slotId,
6036 int indicationType, int token, RIL_Errno e,
6037 void *response, size_t responseLen) {
6038 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6039 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
6040 RLOGE("currentSignalStrengthInd: invalid response");
6044 SignalStrength signalStrength = {};
6045 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6047 RLOGD("currentSignalStrengthInd");
6048 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6049 convertIntToRadioIndicationType(indicationType), signalStrength);
6050 radioService[slotId]->checkReturnStatus(retStatus);
6052 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6059 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6060 SetupDataCallResult& dcResult) {
6061 dcResult.status = (DataCallFailCause) dcResponse->status;
6062 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6063 dcResult.cid = dcResponse->cid;
6064 dcResult.active = dcResponse->active;
6065 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6066 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6067 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6068 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6069 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6070 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6071 dcResult.mtu = dcResponse->mtu;
6074 void convertRilDataCallListToHal(void *response, size_t responseLen,
6075 hidl_vec<SetupDataCallResult>& dcResultList) {
6076 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6078 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6079 dcResultList.resize(num);
6080 for (int i = 0; i < num; i++) {
6081 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6085 int radio::dataCallListChangedInd(int slotId,
6086 int indicationType, int token, RIL_Errno e, void *response,
6087 size_t responseLen) {
6088 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6089 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
6090 RLOGE("dataCallListChangedInd: invalid response");
6093 hidl_vec<SetupDataCallResult> dcList;
6094 convertRilDataCallListToHal(response, responseLen, dcList);
6095 RLOGD("dataCallListChangedInd");
6096 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
6097 convertIntToRadioIndicationType(indicationType), dcList);
6098 radioService[slotId]->checkReturnStatus(retStatus);
6100 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6106 int radio::suppSvcNotifyInd(int slotId, int indicationType,
6107 int token, RIL_Errno e, void *response, size_t responseLen) {
6108 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6109 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
6110 RLOGE("suppSvcNotifyInd: invalid response");
6114 SuppSvcNotification suppSvc = {};
6115 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6116 suppSvc.isMT = ssn->notificationType;
6117 suppSvc.code = ssn->code;
6118 suppSvc.index = ssn->index;
6119 suppSvc.type = ssn->type;
6120 suppSvc.number = convertCharPtrToHidlString(ssn->number);
6122 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
6123 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
6124 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
6125 convertIntToRadioIndicationType(indicationType), suppSvc);
6126 radioService[slotId]->checkReturnStatus(retStatus);
6128 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6134 int radio::stkSessionEndInd(int slotId, int indicationType,
6135 int token, RIL_Errno e, void *response, size_t responseLen) {
6136 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6137 RLOGD("stkSessionEndInd");
6138 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
6139 convertIntToRadioIndicationType(indicationType));
6140 radioService[slotId]->checkReturnStatus(retStatus);
6142 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
6148 int radio::stkProactiveCommandInd(int slotId,
6149 int indicationType, int token, RIL_Errno e, void *response,
6150 size_t responseLen) {
6151 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6152 if (response == NULL || responseLen == 0) {
6153 RLOGE("stkProactiveCommandInd: invalid response");
6156 RLOGD("stkProactiveCommandInd");
6157 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
6158 convertIntToRadioIndicationType(indicationType),
6159 convertCharPtrToHidlString((char *) response));
6160 radioService[slotId]->checkReturnStatus(retStatus);
6162 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
6168 int radio::stkEventNotifyInd(int slotId, int indicationType,
6169 int token, RIL_Errno e, void *response, size_t responseLen) {
6170 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6171 if (response == NULL || responseLen == 0) {
6172 RLOGE("stkEventNotifyInd: invalid response");
6175 RLOGD("stkEventNotifyInd");
6176 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
6177 convertIntToRadioIndicationType(indicationType),
6178 convertCharPtrToHidlString((char *) response));
6179 radioService[slotId]->checkReturnStatus(retStatus);
6181 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6187 int radio::stkCallSetupInd(int slotId, int indicationType,
6188 int token, RIL_Errno e, void *response, size_t responseLen) {
6189 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6190 if (response == NULL || responseLen != sizeof(int)) {
6191 RLOGE("stkCallSetupInd: invalid response");
6194 int32_t timeout = ((int32_t *) response)[0];
6195 RLOGD("stkCallSetupInd: timeout %d", timeout);
6196 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
6197 convertIntToRadioIndicationType(indicationType), timeout);
6198 radioService[slotId]->checkReturnStatus(retStatus);
6200 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
6206 int radio::simSmsStorageFullInd(int slotId,
6207 int indicationType, int token, RIL_Errno e, void *response,
6208 size_t responseLen) {
6209 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6210 RLOGD("simSmsStorageFullInd");
6211 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
6212 convertIntToRadioIndicationType(indicationType));
6213 radioService[slotId]->checkReturnStatus(retStatus);
6215 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
6221 int radio::simRefreshInd(int slotId, int indicationType,
6222 int token, RIL_Errno e, void *response, size_t responseLen) {
6223 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6224 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
6225 RLOGE("simRefreshInd: invalid response");
6229 SimRefreshResult refreshResult = {};
6230 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
6231 refreshResult.type =
6232 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
6233 refreshResult.efId = simRefreshResponse->ef_id;
6234 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
6236 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
6237 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
6238 convertIntToRadioIndicationType(indicationType), refreshResult);
6239 radioService[slotId]->checkReturnStatus(retStatus);
6241 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
6247 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
6248 CdmaSignalInfoRecord& record) {
6249 record.isPresent = signalInfoRecord->isPresent;
6250 record.signalType = signalInfoRecord->signalType;
6251 record.alertPitch = signalInfoRecord->alertPitch;
6252 record.signal = signalInfoRecord->signal;
6255 int radio::callRingInd(int slotId, int indicationType,
6256 int token, RIL_Errno e, void *response, size_t responseLen) {
6257 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6259 CdmaSignalInfoRecord record = {};
6260 if (response == NULL || responseLen == 0) {
6264 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
6265 RLOGE("callRingInd: invalid response");
6268 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
6271 RLOGD("callRingInd: isGsm %d", isGsm);
6272 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
6273 convertIntToRadioIndicationType(indicationType), isGsm, record);
6274 radioService[slotId]->checkReturnStatus(retStatus);
6276 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
6282 int radio::simStatusChangedInd(int slotId,
6283 int indicationType, int token, RIL_Errno e, void *response,
6284 size_t responseLen) {
6285 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6286 RLOGD("simStatusChangedInd");
6287 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
6288 convertIntToRadioIndicationType(indicationType));
6289 radioService[slotId]->checkReturnStatus(retStatus);
6291 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6297 int radio::cdmaNewSmsInd(int slotId, int indicationType,
6298 int token, RIL_Errno e, void *response, size_t responseLen) {
6299 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6300 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
6301 RLOGE("cdmaNewSmsInd: invalid response");
6305 CdmaSmsMessage msg = {};
6306 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
6307 msg.teleserviceId = rilMsg->uTeleserviceID;
6308 msg.isServicePresent = rilMsg->bIsServicePresent;
6309 msg.serviceCategory = rilMsg->uServicecategory;
6310 msg.address.digitMode =
6311 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
6312 msg.address.numberMode =
6313 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
6314 msg.address.numberType =
6315 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
6316 msg.address.numberPlan =
6317 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
6319 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
6320 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
6322 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
6323 rilMsg->sSubAddress.subaddressType;
6324 msg.subAddress.odd = rilMsg->sSubAddress.odd;
6326 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
6327 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
6329 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
6330 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
6332 RLOGD("cdmaNewSmsInd");
6333 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
6334 convertIntToRadioIndicationType(indicationType), msg);
6335 radioService[slotId]->checkReturnStatus(retStatus);
6337 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6343 int radio::newBroadcastSmsInd(int slotId,
6344 int indicationType, int token, RIL_Errno e, void *response,
6345 size_t responseLen) {
6346 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6347 if (response == NULL || responseLen == 0) {
6348 RLOGE("newBroadcastSmsInd: invalid response");
6352 hidl_vec<uint8_t> data;
6353 data.setToExternal((uint8_t *) response, responseLen);
6354 RLOGD("newBroadcastSmsInd");
6355 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
6356 convertIntToRadioIndicationType(indicationType), data);
6357 radioService[slotId]->checkReturnStatus(retStatus);
6359 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6365 int radio::cdmaRuimSmsStorageFullInd(int slotId,
6366 int indicationType, int token, RIL_Errno e, void *response,
6367 size_t responseLen) {
6368 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6369 RLOGD("cdmaRuimSmsStorageFullInd");
6370 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
6371 convertIntToRadioIndicationType(indicationType));
6372 radioService[slotId]->checkReturnStatus(retStatus);
6374 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
6381 int radio::restrictedStateChangedInd(int slotId,
6382 int indicationType, int token, RIL_Errno e, void *response,
6383 size_t responseLen) {
6384 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6385 if (response == NULL || responseLen != sizeof(int)) {
6386 RLOGE("restrictedStateChangedInd: invalid response");
6389 int32_t state = ((int32_t *) response)[0];
6390 RLOGD("restrictedStateChangedInd: state %d", state);
6391 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
6392 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
6393 radioService[slotId]->checkReturnStatus(retStatus);
6395 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6402 int radio::enterEmergencyCallbackModeInd(int slotId,
6403 int indicationType, int token, RIL_Errno e, void *response,
6404 size_t responseLen) {
6405 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6406 RLOGD("enterEmergencyCallbackModeInd");
6407 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
6408 convertIntToRadioIndicationType(indicationType));
6409 radioService[slotId]->checkReturnStatus(retStatus);
6411 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
6418 int radio::cdmaCallWaitingInd(int slotId,
6419 int indicationType, int token, RIL_Errno e, void *response,
6420 size_t responseLen) {
6421 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6422 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
6423 RLOGE("cdmaCallWaitingInd: invalid response");
6427 CdmaCallWaiting callWaitingRecord = {};
6428 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
6429 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
6430 callWaitingRecord.numberPresentation =
6431 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
6432 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
6433 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
6434 callWaitingRecord.signalInfoRecord);
6435 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
6436 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
6438 RLOGD("cdmaCallWaitingInd");
6439 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
6440 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
6441 radioService[slotId]->checkReturnStatus(retStatus);
6443 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
6449 int radio::cdmaOtaProvisionStatusInd(int slotId,
6450 int indicationType, int token, RIL_Errno e, void *response,
6451 size_t responseLen) {
6452 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6453 if (response == NULL || responseLen != sizeof(int)) {
6454 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
6457 int32_t status = ((int32_t *) response)[0];
6458 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
6459 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
6460 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
6461 radioService[slotId]->checkReturnStatus(retStatus);
6463 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
6470 int radio::cdmaInfoRecInd(int slotId,
6471 int indicationType, int token, RIL_Errno e, void *response,
6472 size_t responseLen) {
6473 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6474 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
6475 RLOGE("cdmaInfoRecInd: invalid response");
6479 CdmaInformationRecords records = {};
6480 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
6482 char* string8 = NULL;
6483 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
6484 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
6485 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
6486 "additional ones", recordsRil->numberOfInfoRecs,
6487 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
6489 records.infoRec.resize(num);
6490 for (int i = 0 ; i < num ; i++) {
6491 CdmaInformationRecord *record = &records.infoRec[i];
6492 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
6493 record->name = (CdmaInfoRecName) infoRec->name;
6494 // All vectors should be size 0 except one which will be size 1. Set everything to
6495 // size 0 initially.
6496 record->display.resize(0);
6497 record->number.resize(0);
6498 record->signal.resize(0);
6499 record->redir.resize(0);
6500 record->lineCtrl.resize(0);
6501 record->clir.resize(0);
6502 record->audioCtrl.resize(0);
6503 switch (infoRec->name) {
6504 case RIL_CDMA_DISPLAY_INFO_REC:
6505 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
6506 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
6507 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
6508 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
6509 CDMA_ALPHA_INFO_BUFFER_LENGTH);
6512 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
6513 if (string8 == NULL) {
6514 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
6515 "responseCdmaInformationRecords");
6518 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
6519 string8[(int)infoRec->rec.display.alpha_len] = '\0';
6521 record->display.resize(1);
6522 record->display[0].alphaBuf = string8;
6528 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
6529 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
6530 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
6531 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
6532 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
6533 "expected not more than %d", (int) infoRec->rec.number.len,
6534 CDMA_NUMBER_INFO_BUFFER_LENGTH);
6537 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
6538 if (string8 == NULL) {
6539 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
6540 "responseCdmaInformationRecords");
6543 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
6544 string8[(int)infoRec->rec.number.len] = '\0';
6546 record->number.resize(1);
6547 record->number[0].number = string8;
6550 record->number[0].numberType = infoRec->rec.number.number_type;
6551 record->number[0].numberPlan = infoRec->rec.number.number_plan;
6552 record->number[0].pi = infoRec->rec.number.pi;
6553 record->number[0].si = infoRec->rec.number.si;
6557 case RIL_CDMA_SIGNAL_INFO_REC: {
6558 record->signal.resize(1);
6559 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
6560 record->signal[0].signalType = infoRec->rec.signal.signalType;
6561 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
6562 record->signal[0].signal = infoRec->rec.signal.signal;
6566 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
6567 if (infoRec->rec.redir.redirectingNumber.len >
6568 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
6569 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
6570 "expected not more than %d\n",
6571 (int)infoRec->rec.redir.redirectingNumber.len,
6572 CDMA_NUMBER_INFO_BUFFER_LENGTH);
6575 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
6577 if (string8 == NULL) {
6578 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
6579 "responseCdmaInformationRecords");
6582 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
6583 infoRec->rec.redir.redirectingNumber.len);
6584 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
6586 record->redir.resize(1);
6587 record->redir[0].redirectingNumber.number = string8;
6590 record->redir[0].redirectingNumber.numberType =
6591 infoRec->rec.redir.redirectingNumber.number_type;
6592 record->redir[0].redirectingNumber.numberPlan =
6593 infoRec->rec.redir.redirectingNumber.number_plan;
6594 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
6595 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
6596 record->redir[0].redirectingReason =
6597 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
6601 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
6602 record->lineCtrl.resize(1);
6603 record->lineCtrl[0].lineCtrlPolarityIncluded =
6604 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
6605 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
6606 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
6607 record->lineCtrl[0].lineCtrlPowerDenial =
6608 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
6612 case RIL_CDMA_T53_CLIR_INFO_REC: {
6613 record->clir.resize(1);
6614 record->clir[0].cause = infoRec->rec.clir.cause;
6618 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
6619 record->audioCtrl.resize(1);
6620 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
6621 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
6625 case RIL_CDMA_T53_RELEASE_INFO_REC:
6626 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
6630 RLOGE("cdmaInfoRecInd: Incorrect name value");
6635 RLOGD("cdmaInfoRecInd");
6636 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
6637 convertIntToRadioIndicationType(indicationType), records);
6638 radioService[slotId]->checkReturnStatus(retStatus);
6640 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
6646 int radio::indicateRingbackToneInd(int slotId,
6647 int indicationType, int token, RIL_Errno e, void *response,
6648 size_t responseLen) {
6649 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6650 if (response == NULL || responseLen != sizeof(int)) {
6651 RLOGE("indicateRingbackToneInd: invalid response");
6654 bool start = ((int32_t *) response)[0];
6655 RLOGD("indicateRingbackToneInd: start %d", start);
6656 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
6657 convertIntToRadioIndicationType(indicationType), start);
6658 radioService[slotId]->checkReturnStatus(retStatus);
6660 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
6666 int radio::resendIncallMuteInd(int slotId,
6667 int indicationType, int token, RIL_Errno e, void *response,
6668 size_t responseLen) {
6669 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6670 RLOGD("resendIncallMuteInd");
6671 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
6672 convertIntToRadioIndicationType(indicationType));
6673 radioService[slotId]->checkReturnStatus(retStatus);
6675 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
6681 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
6682 int indicationType, int token, RIL_Errno e,
6683 void *response, size_t responseLen) {
6684 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6685 if (response == NULL || responseLen != sizeof(int)) {
6686 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
6689 int32_t cdmaSource = ((int32_t *) response)[0];
6690 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
6691 Return<void> retStatus = radioService[slotId]->mRadioIndication->
6692 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
6693 (CdmaSubscriptionSource) cdmaSource);
6694 radioService[slotId]->checkReturnStatus(retStatus);
6696 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
6703 int radio::cdmaPrlChangedInd(int slotId,
6704 int indicationType, int token, RIL_Errno e, void *response,
6705 size_t responseLen) {
6706 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6707 if (response == NULL || responseLen != sizeof(int)) {
6708 RLOGE("cdmaPrlChangedInd: invalid response");
6711 int32_t version = ((int32_t *) response)[0];
6712 RLOGD("cdmaPrlChangedInd: version %d", version);
6713 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
6714 convertIntToRadioIndicationType(indicationType), version);
6715 radioService[slotId]->checkReturnStatus(retStatus);
6717 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6723 int radio::exitEmergencyCallbackModeInd(int slotId,
6724 int indicationType, int token, RIL_Errno e, void *response,
6725 size_t responseLen) {
6726 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6727 RLOGD("exitEmergencyCallbackModeInd");
6728 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
6729 convertIntToRadioIndicationType(indicationType));
6730 radioService[slotId]->checkReturnStatus(retStatus);
6732 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
6739 int radio::rilConnectedInd(int slotId,
6740 int indicationType, int token, RIL_Errno e, void *response,
6741 size_t responseLen) {
6742 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6743 RLOGD("rilConnectedInd");
6744 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
6745 convertIntToRadioIndicationType(indicationType));
6746 radioService[slotId]->checkReturnStatus(retStatus);
6748 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6754 int radio::voiceRadioTechChangedInd(int slotId,
6755 int indicationType, int token, RIL_Errno e, void *response,
6756 size_t responseLen) {
6757 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6758 if (response == NULL || responseLen != sizeof(int)) {
6759 RLOGE("voiceRadioTechChangedInd: invalid response");
6762 int32_t rat = ((int32_t *) response)[0];
6763 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
6764 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
6765 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
6766 radioService[slotId]->checkReturnStatus(retStatus);
6768 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
6775 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
6776 int num = responseLen / sizeof(RIL_CellInfo_v12);
6777 records.resize(num);
6779 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
6780 for (int i = 0; i < num; i++) {
6781 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
6782 records[i].registered = rillCellInfo->registered;
6783 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
6784 records[i].timeStamp = rillCellInfo->timeStamp;
6785 // All vectors should be size 0 except one which will be size 1. Set everything to
6786 // size 0 initially.
6787 records[i].gsm.resize(0);
6788 records[i].wcdma.resize(0);
6789 records[i].cdma.resize(0);
6790 records[i].lte.resize(0);
6791 records[i].tdscdma.resize(0);
6792 switch(rillCellInfo->cellInfoType) {
6793 case RIL_CELL_INFO_TYPE_GSM: {
6794 records[i].gsm.resize(1);
6795 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
6796 cellInfoGsm->cellIdentityGsm.mcc =
6797 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
6798 cellInfoGsm->cellIdentityGsm.mnc =
6799 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
6800 cellInfoGsm->cellIdentityGsm.lac =
6801 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
6802 cellInfoGsm->cellIdentityGsm.cid =
6803 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
6804 cellInfoGsm->cellIdentityGsm.arfcn =
6805 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
6806 cellInfoGsm->cellIdentityGsm.bsic =
6807 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
6808 cellInfoGsm->signalStrengthGsm.signalStrength =
6809 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
6810 cellInfoGsm->signalStrengthGsm.bitErrorRate =
6811 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
6812 cellInfoGsm->signalStrengthGsm.timingAdvance =
6813 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
6817 case RIL_CELL_INFO_TYPE_WCDMA: {
6818 records[i].wcdma.resize(1);
6819 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
6820 cellInfoWcdma->cellIdentityWcdma.mcc =
6821 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
6822 cellInfoWcdma->cellIdentityWcdma.mnc =
6823 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
6824 cellInfoWcdma->cellIdentityWcdma.lac =
6825 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
6826 cellInfoWcdma->cellIdentityWcdma.cid =
6827 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
6828 cellInfoWcdma->cellIdentityWcdma.psc =
6829 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
6830 cellInfoWcdma->cellIdentityWcdma.uarfcn =
6831 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
6832 cellInfoWcdma->signalStrengthWcdma.signalStrength =
6833 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
6834 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
6835 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
6839 case RIL_CELL_INFO_TYPE_CDMA: {
6840 records[i].cdma.resize(1);
6841 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
6842 cellInfoCdma->cellIdentityCdma.networkId =
6843 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
6844 cellInfoCdma->cellIdentityCdma.systemId =
6845 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
6846 cellInfoCdma->cellIdentityCdma.baseStationId =
6847 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
6848 cellInfoCdma->cellIdentityCdma.longitude =
6849 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
6850 cellInfoCdma->cellIdentityCdma.latitude =
6851 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
6852 cellInfoCdma->signalStrengthCdma.dbm =
6853 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
6854 cellInfoCdma->signalStrengthCdma.ecio =
6855 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
6856 cellInfoCdma->signalStrengthEvdo.dbm =
6857 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
6858 cellInfoCdma->signalStrengthEvdo.ecio =
6859 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
6860 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
6861 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
6865 case RIL_CELL_INFO_TYPE_LTE: {
6866 records[i].lte.resize(1);
6867 CellInfoLte *cellInfoLte = &records[i].lte[0];
6868 cellInfoLte->cellIdentityLte.mcc =
6869 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
6870 cellInfoLte->cellIdentityLte.mnc =
6871 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
6872 cellInfoLte->cellIdentityLte.ci =
6873 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
6874 cellInfoLte->cellIdentityLte.pci =
6875 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
6876 cellInfoLte->cellIdentityLte.tac =
6877 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
6878 cellInfoLte->cellIdentityLte.earfcn =
6879 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
6880 cellInfoLte->signalStrengthLte.signalStrength =
6881 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
6882 cellInfoLte->signalStrengthLte.rsrp =
6883 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
6884 cellInfoLte->signalStrengthLte.rsrq =
6885 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
6886 cellInfoLte->signalStrengthLte.rssnr =
6887 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
6888 cellInfoLte->signalStrengthLte.cqi =
6889 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
6890 cellInfoLte->signalStrengthLte.timingAdvance =
6891 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
6895 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
6896 records[i].tdscdma.resize(1);
6897 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
6898 cellInfoTdscdma->cellIdentityTdscdma.mcc =
6899 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
6900 cellInfoTdscdma->cellIdentityTdscdma.mnc =
6901 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
6902 cellInfoTdscdma->cellIdentityTdscdma.lac =
6903 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
6904 cellInfoTdscdma->cellIdentityTdscdma.cid =
6905 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
6906 cellInfoTdscdma->cellIdentityTdscdma.cpid =
6907 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
6908 cellInfoTdscdma->signalStrengthTdscdma.rscp =
6909 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
6920 int radio::cellInfoListInd(int slotId,
6921 int indicationType, int token, RIL_Errno e, void *response,
6922 size_t responseLen) {
6923 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6924 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
6925 RLOGE("cellInfoListInd: invalid response");
6929 hidl_vec<CellInfo> records;
6930 convertRilCellInfoListToHal(response, responseLen, records);
6932 RLOGD("cellInfoListInd");
6933 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
6934 convertIntToRadioIndicationType(indicationType), records);
6935 radioService[slotId]->checkReturnStatus(retStatus);
6937 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
6943 int radio::imsNetworkStateChangedInd(int slotId,
6944 int indicationType, int token, RIL_Errno e, void *response,
6945 size_t responseLen) {
6946 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6947 RLOGD("imsNetworkStateChangedInd");
6948 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
6949 convertIntToRadioIndicationType(indicationType));
6950 radioService[slotId]->checkReturnStatus(retStatus);
6952 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6959 int radio::subscriptionStatusChangedInd(int slotId,
6960 int indicationType, int token, RIL_Errno e, void *response,
6961 size_t responseLen) {
6962 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6963 if (response == NULL || responseLen != sizeof(int)) {
6964 RLOGE("subscriptionStatusChangedInd: invalid response");
6967 bool activate = ((int32_t *) response)[0];
6968 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
6969 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
6970 convertIntToRadioIndicationType(indicationType), activate);
6971 radioService[slotId]->checkReturnStatus(retStatus);
6973 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
6980 int radio::srvccStateNotifyInd(int slotId,
6981 int indicationType, int token, RIL_Errno e, void *response,
6982 size_t responseLen) {
6983 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6984 if (response == NULL || responseLen != sizeof(int)) {
6985 RLOGE("srvccStateNotifyInd: invalid response");
6988 int32_t state = ((int32_t *) response)[0];
6989 RLOGD("srvccStateNotifyInd: rat %d", state);
6990 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
6991 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
6992 radioService[slotId]->checkReturnStatus(retStatus);
6994 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7000 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7001 hidl_vec<HardwareConfig>& records) {
7002 int num = responseLen / sizeof(RIL_HardwareConfig);
7003 records.resize(num);
7005 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7006 for (int i = 0; i < num; i++) {
7007 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7008 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7009 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7010 switch (rilHardwareConfig[i].type) {
7011 case RIL_HARDWARE_CONFIG_MODEM: {
7012 records[i].modem.resize(1);
7013 records[i].sim.resize(0);
7014 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7015 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7016 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7017 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7018 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7022 case RIL_HARDWARE_CONFIG_SIM: {
7023 records[i].sim.resize(1);
7024 records[i].modem.resize(0);
7025 records[i].sim[0].modemUuid =
7026 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7033 int radio::hardwareConfigChangedInd(int slotId,
7034 int indicationType, int token, RIL_Errno e, void *response,
7035 size_t responseLen) {
7036 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7037 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7038 RLOGE("hardwareConfigChangedInd: invalid response");
7042 hidl_vec<HardwareConfig> configs;
7043 convertRilHardwareConfigListToHal(response, responseLen, configs);
7045 RLOGD("hardwareConfigChangedInd");
7046 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
7047 convertIntToRadioIndicationType(indicationType), configs);
7048 radioService[slotId]->checkReturnStatus(retStatus);
7050 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
7057 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7058 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7059 rc.session = rilRadioCapability->session;
7060 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7061 rc.raf = rilRadioCapability->rat;
7062 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7063 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
7066 int radio::radioCapabilityIndicationInd(int slotId,
7067 int indicationType, int token, RIL_Errno e, void *response,
7068 size_t responseLen) {
7069 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7070 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
7071 RLOGE("radioCapabilityIndicationInd: invalid response");
7075 RadioCapability rc = {};
7076 convertRilRadioCapabilityToHal(response, responseLen, rc);
7078 RLOGD("radioCapabilityIndicationInd");
7079 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
7080 convertIntToRadioIndicationType(indicationType), rc);
7081 radioService[slotId]->checkReturnStatus(retStatus);
7083 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
7090 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
7091 if ((reqType == SS_INTERROGATION) &&
7092 (serType == SS_CFU ||
7093 serType == SS_CF_BUSY ||
7094 serType == SS_CF_NO_REPLY ||
7095 serType == SS_CF_NOT_REACHABLE ||
7096 serType == SS_CF_ALL ||
7097 serType == SS_CF_ALL_CONDITIONAL)) {
7103 int radio::onSupplementaryServiceIndicationInd(int slotId,
7104 int indicationType, int token, RIL_Errno e,
7105 void *response, size_t responseLen) {
7106 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7107 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
7108 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
7112 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
7113 StkCcUnsolSsResult ss = {};
7114 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
7115 ss.requestType = (SsRequestType) rilSsResponse->requestType;
7116 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
7117 ss.serviceClass = rilSsResponse->serviceClass;
7118 ss.result = (RadioError) rilSsResponse->result;
7120 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
7121 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
7122 rilSsResponse->cfData.numValidIndexes);
7123 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
7124 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
7125 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
7126 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
7129 ss.cfData.resize(1);
7130 ss.ssInfo.resize(0);
7132 /* number of call info's */
7133 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
7135 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
7136 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
7137 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
7139 cfInfo->status = (CallForwardInfoStatus) cf.status;
7140 cfInfo->reason = cf.reason;
7141 cfInfo->serviceClass = cf.serviceClass;
7142 cfInfo->toa = cf.toa;
7143 cfInfo->number = convertCharPtrToHidlString(cf.number);
7144 cfInfo->timeSeconds = cf.timeSeconds;
7145 RLOGD("onSupplementaryServiceIndicationInd: "
7146 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
7147 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
7150 ss.ssInfo.resize(1);
7151 ss.cfData.resize(0);
7154 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
7155 for (int i = 0; i < SS_INFO_MAX; i++) {
7156 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
7157 rilSsResponse->ssInfo[i]);
7158 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
7162 RLOGD("onSupplementaryServiceIndicationInd");
7163 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7164 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
7166 radioService[slotId]->checkReturnStatus(retStatus);
7168 RLOGE("onSupplementaryServiceIndicationInd: "
7169 "radioService[%d]->mRadioIndication == NULL", slotId);
7175 int radio::stkCallControlAlphaNotifyInd(int slotId,
7176 int indicationType, int token, RIL_Errno e, void *response,
7177 size_t responseLen) {
7178 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7179 if (response == NULL || responseLen == 0) {
7180 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
7183 RLOGD("stkCallControlAlphaNotifyInd");
7184 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
7185 convertIntToRadioIndicationType(indicationType),
7186 convertCharPtrToHidlString((char *) response));
7187 radioService[slotId]->checkReturnStatus(retStatus);
7189 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
7196 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
7197 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
7198 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
7199 lce.confidenceLevel = rilLceDataInfo->confidence_level;
7200 lce.lceSuspended = rilLceDataInfo->lce_suspended;
7203 int radio::lceDataInd(int slotId,
7204 int indicationType, int token, RIL_Errno e, void *response,
7205 size_t responseLen) {
7206 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7207 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
7208 RLOGE("lceDataInd: invalid response");
7212 LceDataInfo lce = {};
7213 convertRilLceDataInfoToHal(response, responseLen, lce);
7214 RLOGD("lceDataInd");
7215 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
7216 convertIntToRadioIndicationType(indicationType), lce);
7217 radioService[slotId]->checkReturnStatus(retStatus);
7219 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7225 int radio::pcoDataInd(int slotId,
7226 int indicationType, int token, RIL_Errno e, void *response,
7227 size_t responseLen) {
7228 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7229 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
7230 RLOGE("pcoDataInd: invalid response");
7234 PcoDataInfo pco = {};
7235 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
7236 pco.cid = rilPcoData->cid;
7237 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
7238 pco.pcoId = rilPcoData->pco_id;
7239 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
7241 RLOGD("pcoDataInd");
7242 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
7243 convertIntToRadioIndicationType(indicationType), pco);
7244 radioService[slotId]->checkReturnStatus(retStatus);
7246 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7252 int radio::modemResetInd(int slotId,
7253 int indicationType, int token, RIL_Errno e, void *response,
7254 size_t responseLen) {
7255 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7256 if (response == NULL || responseLen == 0) {
7257 RLOGE("modemResetInd: invalid response");
7260 RLOGD("modemResetInd");
7261 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
7262 convertIntToRadioIndicationType(indicationType),
7263 convertCharPtrToHidlString((char *) response));
7264 radioService[slotId]->checkReturnStatus(retStatus);
7266 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
7272 int radio::oemHookRawInd(int slotId,
7273 int indicationType, int token, RIL_Errno e, void *response,
7274 size_t responseLen) {
7275 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
7276 if (response == NULL || responseLen == 0) {
7277 RLOGE("oemHookRawInd: invalid response");
7281 hidl_vec<uint8_t> data;
7282 data.setToExternal((uint8_t *) response, responseLen);
7283 RLOGD("oemHookRawInd");
7284 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
7285 convertIntToRadioIndicationType(indicationType), data);
7286 checkReturnStatus(slotId, retStatus, false);
7288 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
7294 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
7295 using namespace android::hardware;
7297 const char *serviceNames[] = {
7298 android::RIL_getRilSocketName()
7299 #if (SIM_COUNT >= 2)
7301 #if (SIM_COUNT >= 3)
7303 #if (SIM_COUNT >= 4)
7310 const char *oemHookServiceNames[] = {
7311 OEM_HOOK_SERVICE_NAME
7312 #if (SIM_COUNT >= 2)
7313 , OEM_HOOK2_SERVICE_NAME
7314 #if (SIM_COUNT >= 3)
7315 , OEM_HOOK3_SERVICE_NAME
7316 #if (SIM_COUNT >= 4)
7317 , OEM_HOOK4_SERVICE_NAME
7323 #if (SIM_COUNT >= 2)
7324 simCount = SIM_COUNT;
7327 configureRpcThreadpool(1, true /* callerWillJoin */);
7328 for (int i = 0; i < simCount; i++) {
7329 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
7330 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
7333 radioService[i] = new RadioImpl;
7334 radioService[i]->mSlotId = i;
7335 oemHookService[i] = new OemHookImpl;
7336 oemHookService[i]->mSlotId = i;
7337 RLOGD("registerService: starting IRadio %s", serviceNames[i]);
7338 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
7339 status = oemHookService[i]->registerAsService(oemHookServiceNames[i]);
7341 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
7345 s_vendorFunctions = callbacks;
7346 s_commands = commands;
7349 void rilc_thread_pool() {
7350 joinRpcThreadpool();
7353 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
7354 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
7356 #if (SIM_COUNT >= 2)
7357 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
7358 #if (SIM_COUNT >= 3)
7359 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
7360 #if (SIM_COUNT >= 4)
7361 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
7366 return radioServiceRwlockPtr;