2 * Copyright (c) 2016 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #define LOG_TAG "RILC"
19 #include <android/hardware/radio/1.0/IRadio.h>
20 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
22 #include <hwbinder/IPCThreadState.h>
23 #include <hwbinder/ProcessState.h>
24 #include <ril_service.h>
25 #include <hidl/HidlTransportSupport.h>
26 #include <utils/SystemClock.h>
29 #define INVALID_HEX_CHAR 16
31 // Enable verbose logging
34 using namespace android::hardware::radio::V1_0;
35 using namespace android::hardware::radio::deprecated::V1_0;
36 using ::android::hardware::configureRpcThreadpool;
37 using ::android::hardware::joinRpcThreadpool;
38 using ::android::hardware::Return;
39 using ::android::hardware::hidl_string;
40 using ::android::hardware::hidl_vec;
41 using ::android::hardware::hidl_array;
42 using ::android::hardware::Void;
43 using android::CommandInfo;
44 using android::RequestInfo;
45 using android::requestToString;
48 #define BOOL_TO_INT(x) (x ? 1 : 0)
49 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
50 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
52 RIL_RadioFunctions *s_vendorFunctions = NULL;
53 static CommandInfo *s_commands;
59 sp<RadioImpl> radioService[SIM_COUNT];
60 sp<OemHookImpl> oemHookService[SIM_COUNT];
61 // counter used for synchronization. It is incremented every time response callbacks are updated.
62 volatile int32_t mCounterRadio[SIM_COUNT];
63 volatile int32_t mCounterOemHook[SIM_COUNT];
65 sp<RadioImpl> radioService[1];
66 sp<OemHookImpl> oemHookService[1];
67 // counter used for synchronization. It is incremented every time response callbacks are updated.
68 volatile int32_t mCounterRadio[1];
69 volatile int32_t mCounterOemHook[1];
72 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
75 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
77 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
79 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
84 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
85 hidl_vec<HardwareConfig>& records);
87 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
89 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
91 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
92 SignalStrength& signalStrength);
94 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
95 SetupDataCallResult& dcResult);
97 void convertRilDataCallListToHal(void *response, size_t responseLen,
98 hidl_vec<SetupDataCallResult>& dcResultList);
100 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
102 struct RadioImpl : public IRadio {
104 sp<IRadioResponse> mRadioResponse;
105 sp<IRadioIndication> mRadioIndication;
107 Return<void> setResponseFunctions(
108 const ::android::sp<IRadioResponse>& radioResponse,
109 const ::android::sp<IRadioIndication>& radioIndication);
111 Return<void> getIccCardStatus(int32_t serial);
113 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
114 const hidl_string& aid);
116 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
117 const hidl_string& pin, const hidl_string& aid);
119 Return<void> supplyIccPin2ForApp(int32_t serial,
120 const hidl_string& pin2,
121 const hidl_string& aid);
123 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
124 const hidl_string& pin2, const hidl_string& aid);
126 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
127 const hidl_string& newPin, const hidl_string& aid);
129 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
130 const hidl_string& newPin2, const hidl_string& aid);
132 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
134 Return<void> getCurrentCalls(int32_t serial);
136 Return<void> dial(int32_t serial, const Dial& dialInfo);
138 Return<void> getImsiForApp(int32_t serial,
139 const ::android::hardware::hidl_string& aid);
141 Return<void> hangup(int32_t serial, int32_t gsmIndex);
143 Return<void> hangupWaitingOrBackground(int32_t serial);
145 Return<void> hangupForegroundResumeBackground(int32_t serial);
147 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
149 Return<void> conference(int32_t serial);
151 Return<void> rejectCall(int32_t serial);
153 Return<void> getLastCallFailCause(int32_t serial);
155 Return<void> getSignalStrength(int32_t serial);
157 Return<void> getVoiceRegistrationState(int32_t serial);
159 Return<void> getDataRegistrationState(int32_t serial);
161 Return<void> getOperator(int32_t serial);
163 Return<void> setRadioPower(int32_t serial, bool on);
165 Return<void> sendDtmf(int32_t serial,
166 const ::android::hardware::hidl_string& s);
168 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
170 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
172 Return<void> setupDataCall(int32_t serial,
173 RadioTechnology radioTechnology,
174 const DataProfileInfo& profileInfo,
179 Return<void> iccIOForApp(int32_t serial,
182 Return<void> sendUssd(int32_t serial,
183 const ::android::hardware::hidl_string& ussd);
185 Return<void> cancelPendingUssd(int32_t serial);
187 Return<void> getClir(int32_t serial);
189 Return<void> setClir(int32_t serial, int32_t status);
191 Return<void> getCallForwardStatus(int32_t serial,
192 const CallForwardInfo& callInfo);
194 Return<void> setCallForward(int32_t serial,
195 const CallForwardInfo& callInfo);
197 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
199 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
201 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
202 bool success, SmsAcknowledgeFailCause cause);
204 Return<void> acceptCall(int32_t serial);
206 Return<void> deactivateDataCall(int32_t serial,
207 int32_t cid, bool reasonRadioShutDown);
209 Return<void> getFacilityLockForApp(int32_t serial,
210 const ::android::hardware::hidl_string& facility,
211 const ::android::hardware::hidl_string& password,
212 int32_t serviceClass,
213 const ::android::hardware::hidl_string& appId);
215 Return<void> setFacilityLockForApp(int32_t serial,
216 const ::android::hardware::hidl_string& facility,
218 const ::android::hardware::hidl_string& password,
219 int32_t serviceClass,
220 const ::android::hardware::hidl_string& appId);
222 Return<void> setBarringPassword(int32_t serial,
223 const ::android::hardware::hidl_string& facility,
224 const ::android::hardware::hidl_string& oldPassword,
225 const ::android::hardware::hidl_string& newPassword);
227 Return<void> getNetworkSelectionMode(int32_t serial);
229 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
231 Return<void> setNetworkSelectionModeManual(int32_t serial,
232 const ::android::hardware::hidl_string& operatorNumeric);
234 Return<void> getAvailableNetworks(int32_t serial);
236 Return<void> startDtmf(int32_t serial,
237 const ::android::hardware::hidl_string& s);
239 Return<void> stopDtmf(int32_t serial);
241 Return<void> getBasebandVersion(int32_t serial);
243 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
245 Return<void> setMute(int32_t serial, bool enable);
247 Return<void> getMute(int32_t serial);
249 Return<void> getClip(int32_t serial);
251 Return<void> getDataCallList(int32_t serial);
253 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
255 Return<void> writeSmsToSim(int32_t serial,
256 const SmsWriteArgs& smsWriteArgs);
258 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
260 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
262 Return<void> getAvailableBandModes(int32_t serial);
264 Return<void> sendEnvelope(int32_t serial,
265 const ::android::hardware::hidl_string& command);
267 Return<void> sendTerminalResponseToSim(int32_t serial,
268 const ::android::hardware::hidl_string& commandResponse);
270 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
272 Return<void> explicitCallTransfer(int32_t serial);
274 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
276 Return<void> getPreferredNetworkType(int32_t serial);
278 Return<void> getNeighboringCids(int32_t serial);
280 Return<void> setLocationUpdates(int32_t serial, bool enable);
282 Return<void> setCdmaSubscriptionSource(int32_t serial,
283 CdmaSubscriptionSource cdmaSub);
285 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
287 Return<void> getCdmaRoamingPreference(int32_t serial);
289 Return<void> setTTYMode(int32_t serial, TtyMode mode);
291 Return<void> getTTYMode(int32_t serial);
293 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
295 Return<void> getPreferredVoicePrivacy(int32_t serial);
297 Return<void> sendCDMAFeatureCode(int32_t serial,
298 const ::android::hardware::hidl_string& featureCode);
300 Return<void> sendBurstDtmf(int32_t serial,
301 const ::android::hardware::hidl_string& dtmf,
305 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
307 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
308 const CdmaSmsAck& smsAck);
310 Return<void> getGsmBroadcastConfig(int32_t serial);
312 Return<void> setGsmBroadcastConfig(int32_t serial,
313 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
315 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
317 Return<void> getCdmaBroadcastConfig(int32_t serial);
319 Return<void> setCdmaBroadcastConfig(int32_t serial,
320 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
322 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
324 Return<void> getCDMASubscription(int32_t serial);
326 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
328 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
330 Return<void> getDeviceIdentity(int32_t serial);
332 Return<void> exitEmergencyCallbackMode(int32_t serial);
334 Return<void> getSmscAddress(int32_t serial);
336 Return<void> setSmscAddress(int32_t serial,
337 const ::android::hardware::hidl_string& smsc);
339 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
341 Return<void> reportStkServiceIsRunning(int32_t serial);
343 Return<void> getCdmaSubscriptionSource(int32_t serial);
345 Return<void> requestIsimAuthentication(int32_t serial,
346 const ::android::hardware::hidl_string& challenge);
348 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
350 const ::android::hardware::hidl_string& ackPdu);
352 Return<void> sendEnvelopeWithStatus(int32_t serial,
353 const ::android::hardware::hidl_string& contents);
355 Return<void> getVoiceRadioTechnology(int32_t serial);
357 Return<void> getCellInfoList(int32_t serial);
359 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
361 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
362 bool modemCognitive, bool isRoaming);
364 Return<void> getImsRegistrationState(int32_t serial);
366 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
368 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
370 Return<void> iccOpenLogicalChannel(int32_t serial,
371 const ::android::hardware::hidl_string& aid, int32_t p2);
373 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
375 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
377 Return<void> nvReadItem(int32_t serial, NvItem itemId);
379 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
381 Return<void> nvWriteCdmaPrl(int32_t serial,
382 const ::android::hardware::hidl_vec<uint8_t>& prl);
384 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
386 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
388 Return<void> setDataAllowed(int32_t serial, bool allow);
390 Return<void> getHardwareConfig(int32_t serial);
392 Return<void> requestIccSimAuthentication(int32_t serial,
394 const ::android::hardware::hidl_string& authData,
395 const ::android::hardware::hidl_string& aid);
397 Return<void> setDataProfile(int32_t serial,
398 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
400 Return<void> requestShutdown(int32_t serial);
402 Return<void> getRadioCapability(int32_t serial);
404 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
406 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
408 Return<void> stopLceService(int32_t serial);
410 Return<void> pullLceData(int32_t serial);
412 Return<void> getModemActivityInfo(int32_t serial);
414 Return<void> setAllowedCarriers(int32_t serial,
416 const CarrierRestrictions& carriers);
418 Return<void> getAllowedCarriers(int32_t serial);
420 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
422 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
424 Return<void> setSimCardPower(int32_t serial, bool powerUp);
426 Return<void> responseAcknowledgement();
428 void checkReturnStatus(Return<void>& ret);
431 struct OemHookImpl : public IOemHook {
433 sp<IOemHookResponse> mOemHookResponse;
434 sp<IOemHookIndication> mOemHookIndication;
436 Return<void> setResponseFunctions(
437 const ::android::sp<IOemHookResponse>& oemHookResponse,
438 const ::android::sp<IOemHookIndication>& oemHookIndication);
440 Return<void> sendRequestRaw(int32_t serial,
441 const ::android::hardware::hidl_vec<uint8_t>& data);
443 Return<void> sendRequestStrings(int32_t serial,
444 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
447 void memsetAndFreeStrings(int numPointers, ...) {
449 va_start(ap, numPointers);
450 for (int i = 0; i < numPointers; i++) {
451 char *ptr = va_arg(ap, char *);
454 #define MAX_STRING_LENGTH 4096
455 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
463 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
464 pRI->pCI->responseFunction((int) pRI->socket_id,
465 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
469 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
470 * request with error RIL_E_NO_MEMORY.
471 * Returns true on success, and false on failure.
473 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
474 size_t len = src.size();
479 *dest = (char *) calloc(len + 1, sizeof(char));
481 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
482 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
485 strncpy(*dest, src.c_str(), len + 1);
489 hidl_string convertCharPtrToHidlString(const char *ptr) {
492 // TODO: replace this with strnlen
493 ret.setToExternal(ptr, strlen(ptr));
498 bool dispatchVoid(int serial, int slotId, int request) {
499 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
503 s_vendorFunctions->onRequest(request, NULL, 0, pRI);
507 bool dispatchString(int serial, int slotId, int request, const char * str) {
508 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
514 if (!copyHidlStringToRil(&pString, str, pRI)) {
518 s_vendorFunctions->onRequest(request, pString, sizeof(char *), pRI);
520 memsetAndFreeStrings(1, pString);
524 bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) {
525 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
531 pStrings = (char **)calloc(countStrings, sizeof(char *));
532 if (pStrings == NULL) {
533 RLOGE("Memory allocation failed for request %s", requestToString(request));
534 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
538 va_start(ap, countStrings);
539 for (int i = 0; i < countStrings; i++) {
540 const char* str = va_arg(ap, const char *);
541 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI)) {
543 for (int j = 0; j < i; j++) {
544 memsetAndFreeStrings(1, pStrings[j]);
552 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
554 if (pStrings != NULL) {
555 for (int i = 0 ; i < countStrings ; i++) {
556 memsetAndFreeStrings(1, pStrings[i]);
560 memset(pStrings, 0, countStrings * sizeof(char *));
567 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
568 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
573 int countStrings = data.size();
575 pStrings = (char **)calloc(countStrings, sizeof(char *));
576 if (pStrings == NULL) {
577 RLOGE("Memory allocation failed for request %s", requestToString(request));
578 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
582 for (int i = 0; i < countStrings; i++) {
583 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
584 for (int j = 0; j < i; j++) {
585 memsetAndFreeStrings(1, pStrings[j]);
592 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
594 if (pStrings != NULL) {
595 for (int i = 0 ; i < countStrings ; i++) {
596 memsetAndFreeStrings(1, pStrings[i]);
600 memset(pStrings, 0, countStrings * sizeof(char *));
607 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
608 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
613 int *pInts = (int *)calloc(countInts, sizeof(int));
616 RLOGE("Memory allocation failed for request %s", requestToString(request));
617 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
621 va_start(ap, countInts);
622 for (int i = 0; i < countInts; i++) {
623 pInts[i] = va_arg(ap, int);
627 s_vendorFunctions->onRequest(request, pInts, countInts * sizeof(int), pRI);
631 memset(pInts, 0, countInts * sizeof(int));
638 bool dispatchCallForwardStatus(int serial, int slotId, int request,
639 const CallForwardInfo& callInfo) {
640 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
645 RIL_CallForwardInfo cf;
646 cf.status = (int) callInfo.status;
647 cf.reason = callInfo.reason;
648 cf.serviceClass = callInfo.serviceClass;
649 cf.toa = callInfo.toa;
650 cf.timeSeconds = callInfo.timeSeconds;
652 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
656 s_vendorFunctions->onRequest(request, &cf, sizeof(cf), pRI);
658 memsetAndFreeStrings(1, cf.number);
663 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
664 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
669 const uint8_t *uData = rawBytes.data();
671 s_vendorFunctions->onRequest(request, (void *) uData, rawBytes.size(), pRI);
676 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
677 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
682 RIL_SIM_APDU apdu = {};
684 apdu.sessionid = message.sessionId;
685 apdu.cla = message.cla;
686 apdu.instruction = message.instruction;
687 apdu.p1 = message.p1;
688 apdu.p2 = message.p2;
689 apdu.p3 = message.p3;
691 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
695 s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI);
697 memsetAndFreeStrings(1, apdu.data);
702 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
703 if (ret.isOk() == false) {
704 RLOGE("checkReturnStatus: unable to call response/indication callback");
705 // Remote process hosting the callbacks must be dead. Reset the callback objects;
706 // there's no other recovery to be done here. When the client process is back up, it will
707 // call setResponseFunctions()
709 // Caller should already hold rdlock, release that first
710 // note the current counter to avoid overwriting updates made by another thread before
711 // write lock is acquired.
712 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
713 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
714 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
718 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
721 // make sure the counter value has not changed
722 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
723 if (isRadioService) {
724 radioService[slotId]->mRadioResponse = NULL;
725 radioService[slotId]->mRadioIndication = NULL;
727 oemHookService[slotId]->mOemHookResponse = NULL;
728 oemHookService[slotId]->mOemHookIndication = NULL;
730 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
732 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
733 "got updated on another thread");
737 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
741 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
746 void RadioImpl::checkReturnStatus(Return<void>& ret) {
747 ::checkReturnStatus(mSlotId, ret, true);
750 Return<void> RadioImpl::setResponseFunctions(
751 const ::android::sp<IRadioResponse>& radioResponseParam,
752 const ::android::sp<IRadioIndication>& radioIndicationParam) {
753 RLOGD("setResponseFunctions");
755 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
756 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
759 mRadioResponse = radioResponseParam;
760 mRadioIndication = radioIndicationParam;
761 mCounterRadio[mSlotId]++;
763 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
766 // client is connected. Send initial indications.
767 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
772 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
774 RLOGD("getIccCardStatus: serial %d", serial);
776 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
780 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
781 const hidl_string& aid) {
783 RLOGD("supplyIccPinForApp: serial %d", serial);
785 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
786 2, pin.c_str(), aid.c_str());
790 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
791 const hidl_string& pin, const hidl_string& aid) {
793 RLOGD("supplyIccPukForApp: serial %d", serial);
795 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
796 3, puk.c_str(), pin.c_str(), aid.c_str());
800 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
801 const hidl_string& aid) {
803 RLOGD("supplyIccPin2ForApp: serial %d", serial);
805 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
806 2, pin2.c_str(), aid.c_str());
810 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
811 const hidl_string& pin2, const hidl_string& aid) {
813 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
815 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
816 3, puk2.c_str(), pin2.c_str(), aid.c_str());
820 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
821 const hidl_string& newPin, const hidl_string& aid) {
823 RLOGD("changeIccPinForApp: serial %d", serial);
825 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
826 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
830 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
831 const hidl_string& newPin2, const hidl_string& aid) {
833 RLOGD("changeIccPin2ForApp: serial %d", serial);
835 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
836 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
840 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
841 const hidl_string& netPin) {
843 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
845 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
850 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
852 RLOGD("getCurrentCalls: serial %d", serial);
854 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
858 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
860 RLOGD("dial: serial %d", serial);
862 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
867 RIL_UUS_Info uusInfo = {};
868 int32_t sizeOfDial = sizeof(dial);
870 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
873 dial.clir = (int) dialInfo.clir;
875 if (dialInfo.uusInfo.size() != 0) {
876 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
877 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
879 if (dialInfo.uusInfo[0].uusData.size() == 0) {
880 uusInfo.uusData = NULL;
881 uusInfo.uusLength = 0;
883 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
884 memsetAndFreeStrings(1, dial.address);
887 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
890 dial.uusInfo = &uusInfo;
893 s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI);
895 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
900 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
902 RLOGD("getImsiForApp: serial %d", serial);
904 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
909 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
911 RLOGD("hangup: serial %d", serial);
913 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
917 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
919 RLOGD("hangupWaitingOrBackground: serial %d", serial);
921 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
925 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
927 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
929 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
933 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
935 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
937 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
941 Return<void> RadioImpl::conference(int32_t serial) {
943 RLOGD("conference: serial %d", serial);
945 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
949 Return<void> RadioImpl::rejectCall(int32_t serial) {
951 RLOGD("rejectCall: serial %d", serial);
953 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
957 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
959 RLOGD("getLastCallFailCause: serial %d", serial);
961 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
965 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
967 RLOGD("getSignalStrength: serial %d", serial);
969 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
973 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
975 RLOGD("getVoiceRegistrationState: serial %d", serial);
977 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
981 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
983 RLOGD("getDataRegistrationState: serial %d", serial);
985 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
989 Return<void> RadioImpl::getOperator(int32_t serial) {
991 RLOGD("getOperator: serial %d", serial);
993 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
997 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
998 RLOGD("setRadioPower: serial %d on %d", serial, on);
999 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1003 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1005 RLOGD("sendDtmf: serial %d", serial);
1007 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1011 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1013 RLOGD("sendSms: serial %d", serial);
1015 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
1016 2, message.smscPdu.c_str(), message.pdu.c_str());
1020 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1022 RLOGD("sendSMSExpectMore: serial %d", serial);
1024 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
1025 2, message.smscPdu.c_str(), message.pdu.c_str());
1029 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1031 case MvnoType::IMSI:
1032 str = (char *)"imsi";
1035 str = (char *)"gid";
1038 str = (char *)"spn";
1040 case MvnoType::NONE:
1047 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1048 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1049 bool roamingAllowed, bool isRoaming) {
1052 RLOGD("setupDataCall: serial %d", serial);
1055 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1056 const hidl_string &protocol =
1057 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1058 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
1059 std::to_string((int) radioTechnology + 2).c_str(),
1060 std::to_string((int) dataProfileInfo.profileId).c_str(),
1061 dataProfileInfo.apn.c_str(),
1062 dataProfileInfo.user.c_str(),
1063 dataProfileInfo.password.c_str(),
1064 std::to_string((int) dataProfileInfo.authType).c_str(),
1066 } else if (s_vendorFunctions->version >= 15) {
1067 char *mvnoTypeStr = NULL;
1068 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1069 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1070 RIL_REQUEST_SETUP_DATA_CALL);
1072 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1076 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1077 std::to_string((int) radioTechnology + 2).c_str(),
1078 std::to_string((int) dataProfileInfo.profileId).c_str(),
1079 dataProfileInfo.apn.c_str(),
1080 dataProfileInfo.user.c_str(),
1081 dataProfileInfo.password.c_str(),
1082 std::to_string((int) dataProfileInfo.authType).c_str(),
1083 dataProfileInfo.protocol.c_str(),
1084 dataProfileInfo.roamingProtocol.c_str(),
1085 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1086 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1087 modemCognitive ? "1" : "0",
1088 std::to_string(dataProfileInfo.mtu).c_str(),
1090 dataProfileInfo.mvnoMatchData.c_str(),
1091 roamingAllowed ? "1" : "0");
1093 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1094 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1095 RIL_REQUEST_SETUP_DATA_CALL);
1097 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1103 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1105 RLOGD("iccIOForApp: serial %d", serial);
1107 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1112 RIL_SIM_IO_v6 rilIccIo = {};
1113 rilIccIo.command = iccIo.command;
1114 rilIccIo.fileid = iccIo.fileId;
1115 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1119 rilIccIo.p1 = iccIo.p1;
1120 rilIccIo.p2 = iccIo.p2;
1121 rilIccIo.p3 = iccIo.p3;
1123 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1124 memsetAndFreeStrings(1, rilIccIo.path);
1128 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1129 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1133 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1134 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1138 s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI);
1140 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1145 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1147 RLOGD("sendUssd: serial %d", serial);
1149 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1153 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1155 RLOGD("cancelPendingUssd: serial %d", serial);
1157 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1161 Return<void> RadioImpl::getClir(int32_t serial) {
1163 RLOGD("getClir: serial %d", serial);
1165 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1169 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1171 RLOGD("setClir: serial %d", serial);
1173 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1177 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1179 RLOGD("getCallForwardStatus: serial %d", serial);
1181 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1186 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1188 RLOGD("setCallForward: serial %d", serial);
1190 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1195 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1197 RLOGD("getCallWaiting: serial %d", serial);
1199 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1203 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1205 RLOGD("setCallWaiting: serial %d", serial);
1207 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1212 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1213 bool success, SmsAcknowledgeFailCause cause) {
1215 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1217 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1222 Return<void> RadioImpl::acceptCall(int32_t serial) {
1224 RLOGD("acceptCall: serial %d", serial);
1226 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1230 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1231 int32_t cid, bool reasonRadioShutDown) {
1233 RLOGD("deactivateDataCall: serial %d", serial);
1235 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1236 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1240 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1241 const hidl_string& password, int32_t serviceClass,
1242 const hidl_string& appId) {
1244 RLOGD("getFacilityLockForApp: serial %d", serial);
1246 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1247 4, facility.c_str(), password.c_str(),
1248 (std::to_string(serviceClass)).c_str(), appId.c_str());
1252 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1253 bool lockState, const hidl_string& password,
1254 int32_t serviceClass, const hidl_string& appId) {
1256 RLOGD("setFacilityLockForApp: serial %d", serial);
1258 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1259 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1260 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1264 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1265 const hidl_string& oldPassword,
1266 const hidl_string& newPassword) {
1268 RLOGD("setBarringPassword: serial %d", serial);
1270 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1271 2, oldPassword.c_str(), newPassword.c_str());
1275 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1277 RLOGD("getNetworkSelectionMode: serial %d", serial);
1279 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1283 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1285 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1287 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1291 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1292 const hidl_string& operatorNumeric) {
1294 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1296 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1297 operatorNumeric.c_str());
1301 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1303 RLOGD("getAvailableNetworks: serial %d", serial);
1305 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1309 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1311 RLOGD("startDtmf: serial %d", serial);
1313 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1318 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1320 RLOGD("stopDtmf: serial %d", serial);
1322 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1326 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1328 RLOGD("getBasebandVersion: serial %d", serial);
1330 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1334 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1336 RLOGD("separateConnection: serial %d", serial);
1338 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1342 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1344 RLOGD("setMute: serial %d", serial);
1346 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1350 Return<void> RadioImpl::getMute(int32_t serial) {
1352 RLOGD("getMute: serial %d", serial);
1354 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1358 Return<void> RadioImpl::getClip(int32_t serial) {
1360 RLOGD("getClip: serial %d", serial);
1362 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1366 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1368 RLOGD("getDataCallList: serial %d", serial);
1370 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1374 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1376 RLOGD("setSuppServiceNotifications: serial %d", serial);
1378 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1379 BOOL_TO_INT(enable));
1383 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1385 RLOGD("writeSmsToSim: serial %d", serial);
1387 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1392 RIL_SMS_WriteArgs args;
1393 args.status = (int) smsWriteArgs.status;
1396 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1400 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1401 memsetAndFreeStrings(1, args.pdu);
1405 s_vendorFunctions->onRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI);
1407 memsetAndFreeStrings(2, args.smsc, args.pdu);
1412 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1414 RLOGD("deleteSmsOnSim: serial %d", serial);
1416 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1420 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1422 RLOGD("setBandMode: serial %d", serial);
1424 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1428 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1430 RLOGD("getAvailableBandModes: serial %d", serial);
1432 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1436 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1438 RLOGD("sendEnvelope: serial %d", serial);
1440 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1445 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1446 const hidl_string& commandResponse) {
1448 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1450 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1451 commandResponse.c_str());
1455 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1457 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1459 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1460 1, BOOL_TO_INT(accept));
1464 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1466 RLOGD("explicitCallTransfer: serial %d", serial);
1468 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1472 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1474 RLOGD("setPreferredNetworkType: serial %d", serial);
1476 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1480 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1482 RLOGD("getPreferredNetworkType: serial %d", serial);
1484 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1488 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1490 RLOGD("getNeighboringCids: serial %d", serial);
1492 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1496 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1498 RLOGD("setLocationUpdates: serial %d", serial);
1500 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1504 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1506 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1508 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1512 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1514 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1516 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1520 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1522 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1524 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1528 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1530 RLOGD("setTTYMode: serial %d", serial);
1532 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1536 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1538 RLOGD("getTTYMode: serial %d", serial);
1540 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1544 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1546 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1548 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1549 1, BOOL_TO_INT(enable));
1553 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1555 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1557 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1561 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1563 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1565 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1566 featureCode.c_str());
1570 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1573 RLOGD("sendBurstDtmf: serial %d", serial);
1575 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1576 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1577 (std::to_string(off)).c_str());
1581 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1582 rcsm.uTeleserviceID = sms.teleserviceId;
1583 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1584 rcsm.uServicecategory = sms.serviceCategory;
1585 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1586 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1587 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1588 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1590 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1591 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1592 for (int i = 0; i < digitLimit; i++) {
1593 rcsm.sAddress.digits[i] = sms.address.digits[i];
1596 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1597 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1599 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1600 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1601 for (int i = 0; i < digitLimit; i++) {
1602 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1605 rcsm.uBearerDataLen = sms.bearerData.size();
1606 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1607 for (int i = 0; i < digitLimit; i++) {
1608 rcsm.aBearerData[i] = sms.bearerData[i];
1612 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1614 RLOGD("sendCdmaSms: serial %d", serial);
1616 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1621 RIL_CDMA_SMS_Message rcsm = {};
1622 constructCdmaSms(rcsm, sms);
1624 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI);
1628 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1630 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1632 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1637 RIL_CDMA_SMS_Ack rcsa = {};
1639 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1640 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1642 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI);
1646 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1648 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1650 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1654 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1655 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1658 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1660 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1661 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1666 int num = configInfo.size();
1667 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1668 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1670 for (int i = 0 ; i < num ; i++ ) {
1671 gsmBciPtrs[i] = &gsmBci[i];
1672 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1673 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1674 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1675 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1676 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1679 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, gsmBciPtrs,
1680 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI);
1684 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1686 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1688 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1689 1, BOOL_TO_INT(!activate));
1693 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1695 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1697 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1701 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1702 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1705 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1707 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1708 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1713 int num = configInfo.size();
1714 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1715 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1717 for (int i = 0 ; i < num ; i++ ) {
1718 cdmaBciPtrs[i] = &cdmaBci[i];
1719 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1720 cdmaBci[i].language = configInfo[i].language;
1721 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1724 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, cdmaBciPtrs,
1725 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI);
1729 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1731 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1733 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1734 1, BOOL_TO_INT(!activate));
1738 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1740 RLOGD("getCDMASubscription: serial %d", serial);
1742 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1746 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1748 RLOGD("writeSmsToRuim: serial %d", serial);
1750 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1751 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1756 RIL_CDMA_SMS_WriteArgs rcsw = {};
1757 rcsw.status = (int) cdmaSms.status;
1758 constructCdmaSms(rcsw.message, cdmaSms.message);
1760 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI);
1764 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1766 RLOGD("deleteSmsOnRuim: serial %d", serial);
1768 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1772 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1774 RLOGD("getDeviceIdentity: serial %d", serial);
1776 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1780 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1782 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1784 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1788 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1790 RLOGD("getSmscAddress: serial %d", serial);
1792 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1796 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1798 RLOGD("setSmscAddress: serial %d", serial);
1800 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1805 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1807 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1809 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1810 BOOL_TO_INT(available));
1814 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1816 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1818 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1822 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1824 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1826 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1830 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1832 RLOGD("requestIsimAuthentication: serial %d", serial);
1834 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1839 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1840 const hidl_string& ackPdu) {
1842 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1844 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1845 2, success ? "1" : "0", ackPdu.c_str());
1849 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1851 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1853 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1858 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1860 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1862 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1866 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1868 RLOGD("getCellInfoList: serial %d", serial);
1870 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1874 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1876 RLOGD("setCellInfoListRate: serial %d", serial);
1878 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1882 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1883 bool modemCognitive, bool isRoaming) {
1885 RLOGD("setInitialAttachApn: serial %d", serial);
1887 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1888 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
1893 if (s_vendorFunctions->version <= 14) {
1894 RIL_InitialAttachApn iaa = {};
1896 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1900 const hidl_string &protocol =
1901 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1903 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
1904 memsetAndFreeStrings(1, iaa.apn);
1907 iaa.authtype = (int) dataProfileInfo.authType;
1908 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1909 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
1912 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1913 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
1917 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1919 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
1921 RIL_InitialAttachApn_v15 iaa = {};
1923 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1926 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
1927 memsetAndFreeStrings(1, iaa.apn);
1930 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
1931 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
1934 iaa.authtype = (int) dataProfileInfo.authType;
1935 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1936 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
1939 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1940 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
1943 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
1944 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
1945 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
1946 iaa.mtu = dataProfileInfo.mtu;
1948 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
1949 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1950 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1955 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
1956 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1961 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1963 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1964 iaa.password, iaa.mvnoMatchData);
1970 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
1972 RLOGD("getImsRegistrationState: serial %d", serial);
1974 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
1978 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
1979 RIL_IMS_SMS_Message rism = {};
1981 int countStrings = 2;
1982 int dataLen = sizeof(char *) * countStrings;
1984 rism.tech = RADIO_TECH_3GPP;
1985 rism.retry = BOOL_TO_INT(message.retry);
1986 rism.messageRef = message.messageRef;
1988 if (message.gsmMessage.size() != 1) {
1989 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
1990 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1994 pStrings = (char **)calloc(countStrings, sizeof(char *));
1995 if (pStrings == NULL) {
1996 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
1997 requestToString(pRI->pCI->requestNumber));
1998 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2002 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2004 memset(pStrings, 0, dataLen);
2010 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2011 memsetAndFreeStrings(1, pStrings[0]);
2013 memset(pStrings, 0, dataLen);
2019 rism.message.gsmMessage = pStrings;
2020 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2021 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI);
2023 for (int i = 0 ; i < countStrings ; i++) {
2024 memsetAndFreeStrings(1, pStrings[i]);
2028 memset(pStrings, 0, dataLen);
2035 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2036 RIL_IMS_SMS_Message rism = {};
2037 RIL_CDMA_SMS_Message rcsm = {};
2039 if (message.cdmaMessage.size() != 1) {
2040 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2041 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2045 rism.tech = RADIO_TECH_3GPP2;
2046 rism.retry = BOOL_TO_INT(message.retry);
2047 rism.messageRef = message.messageRef;
2048 rism.message.cdmaMessage = &rcsm;
2050 constructCdmaSms(rcsm, message.cdmaMessage[0]);
2052 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2053 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI);
2058 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2060 RLOGD("sendImsSms: serial %d", serial);
2062 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2067 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2069 if (RADIO_TECH_3GPP == format) {
2070 dispatchImsGsmSms(message, pRI);
2071 } else if (RADIO_TECH_3GPP2 == format) {
2072 dispatchImsCdmaSms(message, pRI);
2074 RLOGE("sendImsSms: Invalid radio tech %s",
2075 requestToString(pRI->pCI->requestNumber));
2076 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2081 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2083 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2085 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2089 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2091 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2093 if (s_vendorFunctions->version < 15) {
2094 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2096 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2101 RIL_OpenChannelParams params = {};
2105 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2109 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI);
2111 memsetAndFreeStrings(1, params.aidPtr);
2116 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2118 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2120 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2124 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2126 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2128 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2132 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2134 RLOGD("nvReadItem: serial %d", serial);
2136 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2141 RIL_NV_ReadItem nvri = {};
2142 nvri.itemID = (RIL_NV_Item) itemId;
2144 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI);
2148 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2150 RLOGD("nvWriteItem: serial %d", serial);
2152 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2157 RIL_NV_WriteItem nvwi = {};
2159 nvwi.itemID = (RIL_NV_Item) item.itemId;
2161 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2165 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI);
2167 memsetAndFreeStrings(1, nvwi.value);
2171 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2173 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2175 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2179 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2181 RLOGD("nvResetConfig: serial %d", serial);
2183 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, (int) resetType);
2187 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2189 RLOGD("setUiccSubscription: serial %d", serial);
2191 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2192 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2197 RIL_SelectUiccSub rilUiccSub = {};
2199 rilUiccSub.slot = uiccSub.slot;
2200 rilUiccSub.app_index = uiccSub.appIndex;
2201 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2202 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2204 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI);
2208 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2210 RLOGD("setDataAllowed: serial %d", serial);
2212 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2216 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2218 RLOGD("getHardwareConfig: serial %d", serial);
2220 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2224 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2225 const hidl_string& authData, const hidl_string& aid) {
2227 RLOGD("requestIccSimAuthentication: serial %d", serial);
2229 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2234 RIL_SimAuthentication pf = {};
2236 pf.authContext = authContext;
2239 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2243 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2244 memsetAndFreeStrings(1, pf.authData);
2248 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI);
2250 memsetAndFreeStrings(2, pf.authData, pf.aid);
2255 * @param numProfiles number of data profile
2256 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2257 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2258 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2259 * @param numfields number of string-type member in the data profile structure
2260 * @param ... the variadic parameters are pointers to each string-type member
2262 template <typename T>
2263 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2264 int numfields, ...) {
2266 va_start(args, numfields);
2268 // Iterate through each string-type field that need to be free.
2269 for (int i = 0; i < numfields; i++) {
2270 // Iterate through each data profile and free that specific string-type field.
2271 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2272 char *T::*ptr = va_arg(args, char *T::*);
2273 for (int j = 0; j < numProfiles; j++) {
2274 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2281 memset(dataProfiles, 0, numProfiles * sizeof(T));
2282 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2285 free(dataProfilePtrs);
2288 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2291 RLOGD("setDataProfile: serial %d", serial);
2293 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2298 size_t num = profiles.size();
2299 bool success = false;
2301 if (s_vendorFunctions->version <= 14) {
2303 RIL_DataProfileInfo *dataProfiles =
2304 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2306 if (dataProfiles == NULL) {
2307 RLOGE("Memory allocation failed for request %s",
2308 requestToString(pRI->pCI->requestNumber));
2309 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2313 RIL_DataProfileInfo **dataProfilePtrs =
2314 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2315 if (dataProfilePtrs == NULL) {
2316 RLOGE("Memory allocation failed for request %s",
2317 requestToString(pRI->pCI->requestNumber));
2319 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2323 for (size_t i = 0; i < num; i++) {
2324 dataProfilePtrs[i] = &dataProfiles[i];
2326 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2328 const hidl_string &protocol =
2329 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2331 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2335 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2338 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2344 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2345 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2346 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2350 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2351 dataProfiles[i].authType = (int) profiles[i].authType;
2352 dataProfiles[i].type = (int) profiles[i].type;
2353 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2354 dataProfiles[i].maxConns = profiles[i].maxConns;
2355 dataProfiles[i].waitTime = profiles[i].waitTime;
2356 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2359 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2360 num * sizeof(RIL_DataProfileInfo *), pRI);
2362 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2363 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2364 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2366 RIL_DataProfileInfo_v15 *dataProfiles =
2367 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2369 if (dataProfiles == NULL) {
2370 RLOGE("Memory allocation failed for request %s",
2371 requestToString(pRI->pCI->requestNumber));
2372 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2376 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2377 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2378 if (dataProfilePtrs == NULL) {
2379 RLOGE("Memory allocation failed for request %s",
2380 requestToString(pRI->pCI->requestNumber));
2382 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2386 for (size_t i = 0; i < num; i++) {
2387 dataProfilePtrs[i] = &dataProfiles[i];
2389 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2390 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2394 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2395 profiles[i].roamingProtocol, pRI)) {
2398 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2401 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2406 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2407 profiles[i].mvnoMatchData, pRI)) {
2411 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2412 dataProfiles[i].mvnoType)) {
2413 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2418 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2419 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2420 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2421 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2425 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2426 dataProfiles[i].authType = (int) profiles[i].authType;
2427 dataProfiles[i].type = (int) profiles[i].type;
2428 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2429 dataProfiles[i].maxConns = profiles[i].maxConns;
2430 dataProfiles[i].waitTime = profiles[i].waitTime;
2431 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2432 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2433 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2434 dataProfiles[i].mtu = profiles[i].mtu;
2437 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2438 num * sizeof(RIL_DataProfileInfo_v15 *), pRI);
2440 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2441 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2442 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2443 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2449 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2451 RLOGD("requestShutdown: serial %d", serial);
2453 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2457 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2459 RLOGD("getRadioCapability: serial %d", serial);
2461 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2465 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2467 RLOGD("setRadioCapability: serial %d", serial);
2469 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2474 RIL_RadioCapability rilRc = {};
2476 // TODO : set rilRc.version using HIDL version ?
2477 rilRc.session = rc.session;
2478 rilRc.phase = (int) rc.phase;
2479 rilRc.rat = (int) rc.raf;
2480 rilRc.status = (int) rc.status;
2481 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2483 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI);
2488 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2490 RLOGD("startLceService: serial %d", serial);
2492 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2493 BOOL_TO_INT(pullMode));
2497 Return<void> RadioImpl::stopLceService(int32_t serial) {
2499 RLOGD("stopLceService: serial %d", serial);
2501 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2505 Return<void> RadioImpl::pullLceData(int32_t serial) {
2507 RLOGD("pullLceData: serial %d", serial);
2509 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2513 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2515 RLOGD("getModemActivityInfo: serial %d", serial);
2517 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2521 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2522 const CarrierRestrictions& carriers) {
2524 RLOGD("setAllowedCarriers: serial %d", serial);
2526 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2527 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2532 RIL_CarrierRestrictions cr = {};
2533 RIL_Carrier *allowedCarriers = NULL;
2534 RIL_Carrier *excludedCarriers = NULL;
2536 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2537 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2538 if (allowedCarriers == NULL) {
2539 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2540 requestToString(pRI->pCI->requestNumber));
2541 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2544 cr.allowed_carriers = allowedCarriers;
2546 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2547 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2548 if (excludedCarriers == NULL) {
2549 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2550 requestToString(pRI->pCI->requestNumber));
2551 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2553 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2555 free(allowedCarriers);
2558 cr.excluded_carriers = excludedCarriers;
2560 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2561 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2562 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2563 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2564 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2567 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2568 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2569 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2570 excludedCarriers[i].match_type =
2571 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2572 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2575 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI);
2578 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2579 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2581 free(allowedCarriers);
2582 free(excludedCarriers);
2586 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2588 RLOGD("getAllowedCarriers: serial %d", serial);
2590 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2594 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2597 RLOGD("sendDeviceState: serial %d", serial);
2599 if (s_vendorFunctions->version < 15) {
2600 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2601 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2602 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2604 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2605 RIL_REQUEST_SEND_DEVICE_STATE);
2606 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2610 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2611 BOOL_TO_INT(state));
2615 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2617 RLOGD("setIndicationFilter: serial %d", serial);
2619 if (s_vendorFunctions->version < 15) {
2620 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2621 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2622 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2625 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2629 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2631 RLOGD("setSimCardPower: serial %d", serial);
2633 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2637 Return<void> RadioImpl::responseAcknowledgement() {
2638 android::releaseWakeLock();
2642 Return<void> OemHookImpl::setResponseFunctions(
2643 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2644 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2646 RLOGD("OemHookImpl::setResponseFunctions");
2649 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2650 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2653 mOemHookResponse = oemHookResponseParam;
2654 mOemHookIndication = oemHookIndicationParam;
2655 mCounterOemHook[mSlotId]++;
2657 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2663 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2665 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2667 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2671 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2672 const hidl_vec<hidl_string>& data) {
2674 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2676 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2680 /***************************************************************************************************
2681 * RESPONSE FUNCTIONS
2682 * Functions above are used for requests going from framework to vendor code. The ones below are
2683 * responses for those requests coming back from the vendor code.
2684 **************************************************************************************************/
2686 void radio::acknowledgeRequest(int slotId, int serial) {
2687 if (radioService[slotId]->mRadioResponse != NULL) {
2688 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2689 radioService[slotId]->checkReturnStatus(retStatus);
2691 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2695 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2697 responseInfo.serial = serial;
2698 switch (responseType) {
2699 case RESPONSE_SOLICITED:
2700 responseInfo.type = RadioResponseType::SOLICITED;
2702 case RESPONSE_SOLICITED_ACK_EXP:
2703 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2706 responseInfo.error = (RadioError) e;
2709 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2710 void *response, size_t responseLen) {
2711 populateResponseInfo(responseInfo, serial, responseType, e);
2714 if (response == NULL && responseLen == 0) {
2715 // Earlier RILs did not send a response for some cases although the interface
2716 // expected an integer as response. Do not return error if response is empty. Instead
2717 // Return -1 in those cases to maintain backward compatibility.
2718 } else if (response == NULL || responseLen != sizeof(int)) {
2719 RLOGE("responseIntOrEmpty: Invalid response");
2720 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2722 int *p_int = (int *) response;
2728 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2729 void *response, size_t responseLen) {
2730 populateResponseInfo(responseInfo, serial, responseType, e);
2733 if (response == NULL || responseLen != sizeof(int)) {
2734 RLOGE("responseInt: Invalid response");
2735 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2737 int *p_int = (int *) response;
2743 int radio::getIccCardStatusResponse(int slotId,
2744 int responseType, int serial, RIL_Errno e,
2745 void *response, size_t responseLen) {
2746 if (radioService[slotId]->mRadioResponse != NULL) {
2747 RadioResponseInfo responseInfo = {};
2748 populateResponseInfo(responseInfo, serial, responseType, e);
2749 CardStatus cardStatus = {};
2750 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2751 RLOGE("getIccCardStatusResponse: Invalid response");
2752 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2754 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2755 cardStatus.cardState = (CardState) p_cur->card_state;
2756 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2757 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2758 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2759 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2761 RIL_AppStatus *rilAppStatus = p_cur->applications;
2762 cardStatus.applications.resize(p_cur->num_applications);
2763 AppStatus *appStatus = cardStatus.applications.data();
2765 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2767 for (int i = 0; i < p_cur->num_applications; i++) {
2768 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2769 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2770 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2771 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2772 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2773 rilAppStatus[i].app_label_ptr);
2774 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2775 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2776 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2780 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2781 getIccCardStatusResponse(responseInfo, cardStatus);
2782 radioService[slotId]->checkReturnStatus(retStatus);
2784 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2790 int radio::supplyIccPinForAppResponse(int slotId,
2791 int responseType, int serial, RIL_Errno e,
2792 void *response, size_t responseLen) {
2794 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
2797 if (radioService[slotId]->mRadioResponse != NULL) {
2798 RadioResponseInfo responseInfo = {};
2799 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2800 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2801 supplyIccPinForAppResponse(responseInfo, ret);
2802 radioService[slotId]->checkReturnStatus(retStatus);
2804 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2811 int radio::supplyIccPukForAppResponse(int slotId,
2812 int responseType, int serial, RIL_Errno e,
2813 void *response, size_t responseLen) {
2815 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
2818 if (radioService[slotId]->mRadioResponse != NULL) {
2819 RadioResponseInfo responseInfo = {};
2820 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2821 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2823 radioService[slotId]->checkReturnStatus(retStatus);
2825 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2832 int radio::supplyIccPin2ForAppResponse(int slotId,
2833 int responseType, int serial, RIL_Errno e,
2834 void *response, size_t responseLen) {
2836 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
2839 if (radioService[slotId]->mRadioResponse != NULL) {
2840 RadioResponseInfo responseInfo = {};
2841 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2842 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2843 supplyIccPin2ForAppResponse(responseInfo, ret);
2844 radioService[slotId]->checkReturnStatus(retStatus);
2846 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2853 int radio::supplyIccPuk2ForAppResponse(int slotId,
2854 int responseType, int serial, RIL_Errno e,
2855 void *response, size_t responseLen) {
2857 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
2860 if (radioService[slotId]->mRadioResponse != NULL) {
2861 RadioResponseInfo responseInfo = {};
2862 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2863 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2864 supplyIccPuk2ForAppResponse(responseInfo, ret);
2865 radioService[slotId]->checkReturnStatus(retStatus);
2867 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2874 int radio::changeIccPinForAppResponse(int slotId,
2875 int responseType, int serial, RIL_Errno e,
2876 void *response, size_t responseLen) {
2878 RLOGD("changeIccPinForAppResponse: serial %d", serial);
2881 if (radioService[slotId]->mRadioResponse != NULL) {
2882 RadioResponseInfo responseInfo = {};
2883 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2884 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2885 changeIccPinForAppResponse(responseInfo, ret);
2886 radioService[slotId]->checkReturnStatus(retStatus);
2888 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2895 int radio::changeIccPin2ForAppResponse(int slotId,
2896 int responseType, int serial, RIL_Errno e,
2897 void *response, size_t responseLen) {
2899 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
2902 if (radioService[slotId]->mRadioResponse != NULL) {
2903 RadioResponseInfo responseInfo = {};
2904 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2905 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2906 changeIccPin2ForAppResponse(responseInfo, ret);
2907 radioService[slotId]->checkReturnStatus(retStatus);
2909 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2916 int radio::supplyNetworkDepersonalizationResponse(int slotId,
2917 int responseType, int serial, RIL_Errno e,
2918 void *response, size_t responseLen) {
2920 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
2923 if (radioService[slotId]->mRadioResponse != NULL) {
2924 RadioResponseInfo responseInfo = {};
2925 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2926 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2927 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2928 radioService[slotId]->checkReturnStatus(retStatus);
2930 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
2937 int radio::getCurrentCallsResponse(int slotId,
2938 int responseType, int serial, RIL_Errno e,
2939 void *response, size_t responseLen) {
2941 RLOGD("getCurrentCallsResponse: serial %d", serial);
2944 if (radioService[slotId]->mRadioResponse != NULL) {
2945 RadioResponseInfo responseInfo = {};
2946 populateResponseInfo(responseInfo, serial, responseType, e);
2948 hidl_vec<Call> calls;
2949 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) {
2950 RLOGE("getCurrentCallsResponse: Invalid response");
2951 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2953 int num = responseLen / sizeof(RIL_Call *);
2956 for (int i = 0 ; i < num ; i++) {
2957 RIL_Call *p_cur = ((RIL_Call **) response)[i];
2958 /* each call info */
2959 calls[i].state = (CallState) p_cur->state;
2960 calls[i].index = p_cur->index;
2961 calls[i].toa = p_cur->toa;
2962 calls[i].isMpty = p_cur->isMpty;
2963 calls[i].isMT = p_cur->isMT;
2964 calls[i].als = p_cur->als;
2965 calls[i].isVoice = p_cur->isVoice;
2966 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
2967 calls[i].number = convertCharPtrToHidlString(p_cur->number);
2968 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
2969 calls[i].name = convertCharPtrToHidlString(p_cur->name);
2970 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
2971 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
2972 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
2973 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
2974 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
2975 // convert uusInfo->uusData to a null-terminated string
2976 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
2977 calls[i].uusInfo[0].uusData = nullTermStr;
2983 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2984 getCurrentCallsResponse(responseInfo, calls);
2985 radioService[slotId]->checkReturnStatus(retStatus);
2987 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2993 int radio::dialResponse(int slotId,
2994 int responseType, int serial, RIL_Errno e, void *response,
2995 size_t responseLen) {
2997 RLOGD("dialResponse: serial %d", serial);
3000 if (radioService[slotId]->mRadioResponse != NULL) {
3001 RadioResponseInfo responseInfo = {};
3002 populateResponseInfo(responseInfo, serial, responseType, e);
3003 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3004 radioService[slotId]->checkReturnStatus(retStatus);
3006 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3012 int radio::getIMSIForAppResponse(int slotId,
3013 int responseType, int serial, RIL_Errno e, void *response,
3014 size_t responseLen) {
3016 RLOGD("getIMSIForAppResponse: serial %d", serial);
3019 if (radioService[slotId]->mRadioResponse != NULL) {
3020 RadioResponseInfo responseInfo = {};
3021 populateResponseInfo(responseInfo, serial, responseType, e);
3022 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3023 responseInfo, convertCharPtrToHidlString((char *) response));
3024 radioService[slotId]->checkReturnStatus(retStatus);
3026 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3033 int radio::hangupConnectionResponse(int slotId,
3034 int responseType, int serial, RIL_Errno e,
3035 void *response, size_t responseLen) {
3037 RLOGD("hangupConnectionResponse: serial %d", serial);
3040 if (radioService[slotId]->mRadioResponse != NULL) {
3041 RadioResponseInfo responseInfo = {};
3042 populateResponseInfo(responseInfo, serial, responseType, e);
3043 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3045 radioService[slotId]->checkReturnStatus(retStatus);
3047 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3054 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3055 int responseType, int serial, RIL_Errno e,
3056 void *response, size_t responseLen) {
3058 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3061 if (radioService[slotId]->mRadioResponse != NULL) {
3062 RadioResponseInfo responseInfo = {};
3063 populateResponseInfo(responseInfo, serial, responseType, e);
3064 Return<void> retStatus =
3065 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3067 radioService[slotId]->checkReturnStatus(retStatus);
3069 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3076 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3077 RIL_Errno e, void *response,
3078 size_t responseLen) {
3080 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3083 if (radioService[slotId]->mRadioResponse != NULL) {
3084 RadioResponseInfo responseInfo = {};
3085 populateResponseInfo(responseInfo, serial, responseType, e);
3086 Return<void> retStatus =
3087 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3089 radioService[slotId]->checkReturnStatus(retStatus);
3091 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3098 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3099 RIL_Errno e, void *response,
3100 size_t responseLen) {
3102 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3105 if (radioService[slotId]->mRadioResponse != NULL) {
3106 RadioResponseInfo responseInfo = {};
3107 populateResponseInfo(responseInfo, serial, responseType, e);
3108 Return<void> retStatus =
3109 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3111 radioService[slotId]->checkReturnStatus(retStatus);
3113 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3120 int radio::conferenceResponse(int slotId, int responseType,
3121 int serial, RIL_Errno e, void *response, size_t responseLen) {
3123 RLOGD("conferenceResponse: serial %d", serial);
3126 if (radioService[slotId]->mRadioResponse != NULL) {
3127 RadioResponseInfo responseInfo = {};
3128 populateResponseInfo(responseInfo, serial, responseType, e);
3129 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3131 radioService[slotId]->checkReturnStatus(retStatus);
3133 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3140 int radio::rejectCallResponse(int slotId, int responseType,
3141 int serial, RIL_Errno e, void *response, size_t responseLen) {
3143 RLOGD("rejectCallResponse: serial %d", serial);
3146 if (radioService[slotId]->mRadioResponse != NULL) {
3147 RadioResponseInfo responseInfo = {};
3148 populateResponseInfo(responseInfo, serial, responseType, e);
3149 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3151 radioService[slotId]->checkReturnStatus(retStatus);
3153 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3160 int radio::getLastCallFailCauseResponse(int slotId,
3161 int responseType, int serial, RIL_Errno e, void *response,
3162 size_t responseLen) {
3164 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3167 if (radioService[slotId]->mRadioResponse != NULL) {
3168 RadioResponseInfo responseInfo = {};
3169 populateResponseInfo(responseInfo, serial, responseType, e);
3171 LastCallFailCauseInfo info = {};
3172 info.vendorCause = hidl_string();
3173 if (response == NULL) {
3174 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3175 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3176 } else if (responseLen == sizeof(int)) {
3177 int *pInt = (int *) response;
3178 info.causeCode = (LastCallFailCause) pInt[0];
3179 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3180 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3181 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3182 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3184 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3185 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3188 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3189 responseInfo, info);
3190 radioService[slotId]->checkReturnStatus(retStatus);
3192 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3199 int radio::getSignalStrengthResponse(int slotId,
3200 int responseType, int serial, RIL_Errno e,
3201 void *response, size_t responseLen) {
3203 RLOGD("getSignalStrengthResponse: serial %d", serial);
3206 if (radioService[slotId]->mRadioResponse != NULL) {
3207 RadioResponseInfo responseInfo = {};
3208 populateResponseInfo(responseInfo, serial, responseType, e);
3209 SignalStrength signalStrength = {};
3210 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3211 RLOGE("getSignalStrengthResponse: Invalid response");
3212 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3214 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3217 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3218 responseInfo, signalStrength);
3219 radioService[slotId]->checkReturnStatus(retStatus);
3221 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3228 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3230 return RIL_CELL_INFO_TYPE_NONE;
3233 int radioTech = atoi(rat);
3237 case RADIO_TECH_GPRS:
3238 case RADIO_TECH_EDGE:
3239 case RADIO_TECH_GSM: {
3240 return RIL_CELL_INFO_TYPE_GSM;
3243 case RADIO_TECH_UMTS:
3244 case RADIO_TECH_HSDPA:
3245 case RADIO_TECH_HSUPA:
3246 case RADIO_TECH_HSPA:
3247 case RADIO_TECH_HSPAP: {
3248 return RIL_CELL_INFO_TYPE_WCDMA;
3251 case RADIO_TECH_IS95A:
3252 case RADIO_TECH_IS95B:
3253 case RADIO_TECH_1xRTT:
3254 case RADIO_TECH_EVDO_0:
3255 case RADIO_TECH_EVDO_A:
3256 case RADIO_TECH_EVDO_B:
3257 case RADIO_TECH_EHRPD: {
3258 return RIL_CELL_INFO_TYPE_CDMA;
3261 case RADIO_TECH_LTE:
3262 case RADIO_TECH_LTE_CA: {
3263 return RIL_CELL_INFO_TYPE_LTE;
3266 case RADIO_TECH_TD_SCDMA: {
3267 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3275 return RIL_CELL_INFO_TYPE_NONE;
3279 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3281 cellIdentity.cellIdentityGsm.resize(0);
3282 cellIdentity.cellIdentityWcdma.resize(0);
3283 cellIdentity.cellIdentityCdma.resize(0);
3284 cellIdentity.cellIdentityTdscdma.resize(0);
3285 cellIdentity.cellIdentityLte.resize(0);
3286 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3287 switch(rilCellIdentity.cellInfoType) {
3289 case RIL_CELL_INFO_TYPE_GSM: {
3290 cellIdentity.cellIdentityGsm.resize(1);
3291 cellIdentity.cellIdentityGsm[0].mcc =
3292 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3293 cellIdentity.cellIdentityGsm[0].mnc =
3294 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3295 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3296 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3297 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3298 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3302 case RIL_CELL_INFO_TYPE_WCDMA: {
3303 cellIdentity.cellIdentityWcdma.resize(1);
3304 cellIdentity.cellIdentityWcdma[0].mcc =
3305 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3306 cellIdentity.cellIdentityWcdma[0].mnc =
3307 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3308 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3309 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3310 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3311 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3315 case RIL_CELL_INFO_TYPE_CDMA: {
3316 cellIdentity.cellIdentityCdma.resize(1);
3317 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3318 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3319 cellIdentity.cellIdentityCdma[0].baseStationId =
3320 rilCellIdentity.cellIdentityCdma.basestationId;
3321 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3322 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3326 case RIL_CELL_INFO_TYPE_LTE: {
3327 cellIdentity.cellIdentityLte.resize(1);
3328 cellIdentity.cellIdentityLte[0].mcc =
3329 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3330 cellIdentity.cellIdentityLte[0].mnc =
3331 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3332 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3333 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3334 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3335 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3339 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3340 cellIdentity.cellIdentityTdscdma.resize(1);
3341 cellIdentity.cellIdentityTdscdma[0].mcc =
3342 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3343 cellIdentity.cellIdentityTdscdma[0].mnc =
3344 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3345 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3346 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3347 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3357 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3358 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3359 return atoi(response[index]);
3365 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3366 int numStrings, char** response) {
3368 RIL_CellIdentity_v16 rilCellIdentity;
3369 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3371 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3372 switch(rilCellIdentity.cellInfoType) {
3374 case RIL_CELL_INFO_TYPE_GSM: {
3375 rilCellIdentity.cellIdentityGsm.lac =
3376 convertResponseStringEntryToInt(response, 1, numStrings);
3377 rilCellIdentity.cellIdentityGsm.cid =
3378 convertResponseStringEntryToInt(response, 2, numStrings);
3382 case RIL_CELL_INFO_TYPE_WCDMA: {
3383 rilCellIdentity.cellIdentityWcdma.lac =
3384 convertResponseStringEntryToInt(response, 1, numStrings);
3385 rilCellIdentity.cellIdentityWcdma.cid =
3386 convertResponseStringEntryToInt(response, 2, numStrings);
3387 rilCellIdentity.cellIdentityWcdma.psc =
3388 convertResponseStringEntryToInt(response, 14, numStrings);
3392 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3393 rilCellIdentity.cellIdentityTdscdma.lac =
3394 convertResponseStringEntryToInt(response, 1, numStrings);
3395 rilCellIdentity.cellIdentityTdscdma.cid =
3396 convertResponseStringEntryToInt(response, 2, numStrings);
3400 case RIL_CELL_INFO_TYPE_CDMA:{
3401 rilCellIdentity.cellIdentityCdma.basestationId =
3402 convertResponseStringEntryToInt(response, 4, numStrings);
3403 rilCellIdentity.cellIdentityCdma.longitude =
3404 convertResponseStringEntryToInt(response, 5, numStrings);
3405 rilCellIdentity.cellIdentityCdma.latitude =
3406 convertResponseStringEntryToInt(response, 6, numStrings);
3407 rilCellIdentity.cellIdentityCdma.systemId =
3408 convertResponseStringEntryToInt(response, 8, numStrings);
3409 rilCellIdentity.cellIdentityCdma.networkId =
3410 convertResponseStringEntryToInt(response, 9, numStrings);
3414 case RIL_CELL_INFO_TYPE_LTE:{
3415 rilCellIdentity.cellIdentityLte.tac =
3416 convertResponseStringEntryToInt(response, 1, numStrings);
3417 rilCellIdentity.cellIdentityLte.ci =
3418 convertResponseStringEntryToInt(response, 2, numStrings);
3427 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3430 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3431 int numStrings, char** response) {
3433 RIL_CellIdentity_v16 rilCellIdentity;
3434 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3436 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3437 switch(rilCellIdentity.cellInfoType) {
3438 case RIL_CELL_INFO_TYPE_GSM: {
3439 rilCellIdentity.cellIdentityGsm.lac =
3440 convertResponseStringEntryToInt(response, 1, numStrings);
3441 rilCellIdentity.cellIdentityGsm.cid =
3442 convertResponseStringEntryToInt(response, 2, numStrings);
3445 case RIL_CELL_INFO_TYPE_WCDMA: {
3446 rilCellIdentity.cellIdentityWcdma.lac =
3447 convertResponseStringEntryToInt(response, 1, numStrings);
3448 rilCellIdentity.cellIdentityWcdma.cid =
3449 convertResponseStringEntryToInt(response, 2, numStrings);
3452 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3453 rilCellIdentity.cellIdentityTdscdma.lac =
3454 convertResponseStringEntryToInt(response, 1, numStrings);
3455 rilCellIdentity.cellIdentityTdscdma.cid =
3456 convertResponseStringEntryToInt(response, 2, numStrings);
3459 case RIL_CELL_INFO_TYPE_LTE: {
3460 rilCellIdentity.cellIdentityLte.tac =
3461 convertResponseStringEntryToInt(response, 6, numStrings);
3462 rilCellIdentity.cellIdentityLte.pci =
3463 convertResponseStringEntryToInt(response, 7, numStrings);
3464 rilCellIdentity.cellIdentityLte.ci =
3465 convertResponseStringEntryToInt(response, 8, numStrings);
3473 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3476 int radio::getVoiceRegistrationStateResponse(int slotId,
3477 int responseType, int serial, RIL_Errno e,
3478 void *response, size_t responseLen) {
3480 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3483 if (radioService[slotId]->mRadioResponse != NULL) {
3484 RadioResponseInfo responseInfo = {};
3485 populateResponseInfo(responseInfo, serial, responseType, e);
3487 VoiceRegStateResult voiceRegResponse = {};
3488 int numStrings = responseLen / sizeof(char *);
3489 if (response == NULL) {
3490 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3491 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3492 } else if (s_vendorFunctions->version <= 14) {
3493 if (numStrings != 15) {
3494 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3495 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3497 char **resp = (char **) response;
3498 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3499 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3500 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3501 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3502 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3503 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3504 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3505 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3509 RIL_VoiceRegistrationStateResponse *voiceRegState =
3510 (RIL_VoiceRegistrationStateResponse *)response;
3512 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3513 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3514 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3516 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3517 voiceRegResponse.rat = voiceRegState->rat;;
3518 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3519 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3520 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3521 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3522 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3523 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3524 voiceRegState->cellIdentity);
3528 Return<void> retStatus =
3529 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3530 responseInfo, voiceRegResponse);
3531 radioService[slotId]->checkReturnStatus(retStatus);
3533 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3540 int radio::getDataRegistrationStateResponse(int slotId,
3541 int responseType, int serial, RIL_Errno e,
3542 void *response, size_t responseLen) {
3544 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3547 if (radioService[slotId]->mRadioResponse != NULL) {
3548 RadioResponseInfo responseInfo = {};
3549 populateResponseInfo(responseInfo, serial, responseType, e);
3550 DataRegStateResult dataRegResponse = {};
3551 if (response == NULL) {
3552 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3553 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3554 } else if (s_vendorFunctions->version <= 14) {
3555 int numStrings = responseLen / sizeof(char *);
3556 if ((numStrings != 6) && (numStrings != 11)) {
3557 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3558 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3560 char **resp = (char **) response;
3561 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3562 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3563 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3564 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3565 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3569 RIL_DataRegistrationStateResponse *dataRegState =
3570 (RIL_DataRegistrationStateResponse *)response;
3572 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3573 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3574 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3576 dataRegResponse.regState = (RegState) dataRegState->regState;
3577 dataRegResponse.rat = dataRegState->rat;;
3578 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3579 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3580 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3584 Return<void> retStatus =
3585 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3587 radioService[slotId]->checkReturnStatus(retStatus);
3589 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3596 int radio::getOperatorResponse(int slotId,
3597 int responseType, int serial, RIL_Errno e, void *response,
3598 size_t responseLen) {
3600 RLOGD("getOperatorResponse: serial %d", serial);
3603 if (radioService[slotId]->mRadioResponse != NULL) {
3604 RadioResponseInfo responseInfo = {};
3605 populateResponseInfo(responseInfo, serial, responseType, e);
3606 hidl_string longName;
3607 hidl_string shortName;
3608 hidl_string numeric;
3609 int numStrings = responseLen / sizeof(char *);
3610 if (response == NULL || numStrings != 3) {
3611 RLOGE("getOperatorResponse Invalid response: NULL");
3612 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3615 char **resp = (char **) response;
3616 longName = convertCharPtrToHidlString(resp[0]);
3617 shortName = convertCharPtrToHidlString(resp[1]);
3618 numeric = convertCharPtrToHidlString(resp[2]);
3620 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3621 responseInfo, longName, shortName, numeric);
3622 radioService[slotId]->checkReturnStatus(retStatus);
3624 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3631 int radio::setRadioPowerResponse(int slotId,
3632 int responseType, int serial, RIL_Errno e, void *response,
3633 size_t responseLen) {
3634 RLOGD("setRadioPowerResponse: serial %d", serial);
3636 if (radioService[slotId]->mRadioResponse != NULL) {
3637 RadioResponseInfo responseInfo = {};
3638 populateResponseInfo(responseInfo, serial, responseType, e);
3639 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3641 radioService[slotId]->checkReturnStatus(retStatus);
3643 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3650 int radio::sendDtmfResponse(int slotId,
3651 int responseType, int serial, RIL_Errno e, void *response,
3652 size_t responseLen) {
3654 RLOGD("sendDtmfResponse: serial %d", serial);
3657 if (radioService[slotId]->mRadioResponse != NULL) {
3658 RadioResponseInfo responseInfo = {};
3659 populateResponseInfo(responseInfo, serial, responseType, e);
3660 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3662 radioService[slotId]->checkReturnStatus(retStatus);
3664 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3671 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3672 RIL_Errno e, void *response, size_t responseLen) {
3673 populateResponseInfo(responseInfo, serial, responseType, e);
3674 SendSmsResult result = {};
3676 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3677 RLOGE("Invalid response: NULL");
3678 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3679 result.ackPDU = hidl_string();
3681 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3682 result.messageRef = resp->messageRef;
3683 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3684 result.errorCode = resp->errorCode;
3689 int radio::sendSmsResponse(int slotId,
3690 int responseType, int serial, RIL_Errno e, void *response,
3691 size_t responseLen) {
3693 RLOGD("sendSmsResponse: serial %d", serial);
3696 if (radioService[slotId]->mRadioResponse != NULL) {
3697 RadioResponseInfo responseInfo = {};
3698 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3701 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3703 radioService[slotId]->checkReturnStatus(retStatus);
3705 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3711 int radio::sendSMSExpectMoreResponse(int slotId,
3712 int responseType, int serial, RIL_Errno e, void *response,
3713 size_t responseLen) {
3715 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3718 if (radioService[slotId]->mRadioResponse != NULL) {
3719 RadioResponseInfo responseInfo = {};
3720 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3723 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3724 responseInfo, result);
3725 radioService[slotId]->checkReturnStatus(retStatus);
3727 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3733 int radio::setupDataCallResponse(int slotId,
3734 int responseType, int serial, RIL_Errno e, void *response,
3735 size_t responseLen) {
3737 RLOGD("setupDataCallResponse: serial %d", serial);
3740 if (radioService[slotId]->mRadioResponse != NULL) {
3741 RadioResponseInfo responseInfo = {};
3742 populateResponseInfo(responseInfo, serial, responseType, e);
3744 SetupDataCallResult result = {};
3745 if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) {
3746 RLOGE("setupDataCallResponse: Invalid response");
3747 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3748 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3749 result.type = hidl_string();
3750 result.ifname = hidl_string();
3751 result.addresses = hidl_string();
3752 result.dnses = hidl_string();
3753 result.gateways = hidl_string();
3754 result.pcscf = hidl_string();
3756 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3759 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3760 responseInfo, result);
3761 radioService[slotId]->checkReturnStatus(retStatus);
3763 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3769 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3770 RIL_Errno e, void *response, size_t responseLen) {
3771 populateResponseInfo(responseInfo, serial, responseType, e);
3772 IccIoResult result = {};
3774 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3775 RLOGE("Invalid response: NULL");
3776 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3777 result.simResponse = hidl_string();
3779 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3780 result.sw1 = resp->sw1;
3781 result.sw2 = resp->sw2;
3782 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3787 int radio::iccIOForAppResponse(int slotId,
3788 int responseType, int serial, RIL_Errno e, void *response,
3789 size_t responseLen) {
3791 RLOGD("iccIOForAppResponse: serial %d", serial);
3794 if (radioService[slotId]->mRadioResponse != NULL) {
3795 RadioResponseInfo responseInfo = {};
3796 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3799 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3800 responseInfo, result);
3801 radioService[slotId]->checkReturnStatus(retStatus);
3803 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3809 int radio::sendUssdResponse(int slotId,
3810 int responseType, int serial, RIL_Errno e, void *response,
3811 size_t responseLen) {
3813 RLOGD("sendUssdResponse: serial %d", serial);
3816 if (radioService[slotId]->mRadioResponse != NULL) {
3817 RadioResponseInfo responseInfo = {};
3818 populateResponseInfo(responseInfo, serial, responseType, e);
3819 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3821 radioService[slotId]->checkReturnStatus(retStatus);
3823 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3830 int radio::cancelPendingUssdResponse(int slotId,
3831 int responseType, int serial, RIL_Errno e, void *response,
3832 size_t responseLen) {
3834 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3837 if (radioService[slotId]->mRadioResponse != NULL) {
3838 RadioResponseInfo responseInfo = {};
3839 populateResponseInfo(responseInfo, serial, responseType, e);
3840 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3842 radioService[slotId]->checkReturnStatus(retStatus);
3844 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3851 int radio::getClirResponse(int slotId,
3852 int responseType, int serial, RIL_Errno e, void *response,
3853 size_t responseLen) {
3855 RLOGD("getClirResponse: serial %d", serial);
3858 if (radioService[slotId]->mRadioResponse != NULL) {
3859 RadioResponseInfo responseInfo = {};
3860 populateResponseInfo(responseInfo, serial, responseType, e);
3862 int numInts = responseLen / sizeof(int);
3863 if (response == NULL || numInts != 2) {
3864 RLOGE("getClirResponse Invalid response: NULL");
3865 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3867 int *pInt = (int *) response;
3871 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3873 radioService[slotId]->checkReturnStatus(retStatus);
3875 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3881 int radio::setClirResponse(int slotId,
3882 int responseType, int serial, RIL_Errno e, void *response,
3883 size_t responseLen) {
3885 RLOGD("setClirResponse: serial %d", serial);
3888 if (radioService[slotId]->mRadioResponse != NULL) {
3889 RadioResponseInfo responseInfo = {};
3890 populateResponseInfo(responseInfo, serial, responseType, e);
3891 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
3893 radioService[slotId]->checkReturnStatus(retStatus);
3895 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3901 int radio::getCallForwardStatusResponse(int slotId,
3902 int responseType, int serial, RIL_Errno e,
3903 void *response, size_t responseLen) {
3905 RLOGD("getCallForwardStatusResponse: serial %d", serial);
3908 if (radioService[slotId]->mRadioResponse != NULL) {
3909 RadioResponseInfo responseInfo = {};
3910 populateResponseInfo(responseInfo, serial, responseType, e);
3911 hidl_vec<CallForwardInfo> callForwardInfos;
3913 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
3914 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
3915 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3917 int num = responseLen / sizeof(RIL_CallForwardInfo *);
3918 callForwardInfos.resize(num);
3919 for (int i = 0 ; i < num; i++) {
3920 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
3921 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
3922 callForwardInfos[i].reason = resp->reason;
3923 callForwardInfos[i].serviceClass = resp->serviceClass;
3924 callForwardInfos[i].toa = resp->toa;
3925 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
3926 callForwardInfos[i].timeSeconds = resp->timeSeconds;
3930 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
3931 responseInfo, callForwardInfos);
3932 radioService[slotId]->checkReturnStatus(retStatus);
3934 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
3941 int radio::setCallForwardResponse(int slotId,
3942 int responseType, int serial, RIL_Errno e, void *response,
3943 size_t responseLen) {
3945 RLOGD("setCallForwardResponse: serial %d", serial);
3948 if (radioService[slotId]->mRadioResponse != NULL) {
3949 RadioResponseInfo responseInfo = {};
3950 populateResponseInfo(responseInfo, serial, responseType, e);
3951 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
3953 radioService[slotId]->checkReturnStatus(retStatus);
3955 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3961 int radio::getCallWaitingResponse(int slotId,
3962 int responseType, int serial, RIL_Errno e, void *response,
3963 size_t responseLen) {
3965 RLOGD("getCallWaitingResponse: serial %d", serial);
3968 if (radioService[slotId]->mRadioResponse != NULL) {
3969 RadioResponseInfo responseInfo = {};
3970 populateResponseInfo(responseInfo, serial, responseType, e);
3971 bool enable = false;
3972 int serviceClass = -1;
3973 int numInts = responseLen / sizeof(int);
3974 if (response == NULL || numInts != 2) {
3975 RLOGE("getCallWaitingResponse Invalid response: NULL");
3976 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3978 int *pInt = (int *) response;
3979 enable = pInt[0] == 1 ? true : false;
3980 serviceClass = pInt[1];
3982 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
3983 responseInfo, enable, serviceClass);
3984 radioService[slotId]->checkReturnStatus(retStatus);
3986 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3992 int radio::setCallWaitingResponse(int slotId,
3993 int responseType, int serial, RIL_Errno e, void *response,
3994 size_t responseLen) {
3996 RLOGD("setCallWaitingResponse: serial %d", serial);
3999 if (radioService[slotId]->mRadioResponse != NULL) {
4000 RadioResponseInfo responseInfo = {};
4001 populateResponseInfo(responseInfo, serial, responseType, e);
4002 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4004 radioService[slotId]->checkReturnStatus(retStatus);
4006 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4012 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4013 int responseType, int serial, RIL_Errno e,
4014 void *response, size_t responseLen) {
4016 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4019 if (radioService[slotId]->mRadioResponse != NULL) {
4020 RadioResponseInfo responseInfo = {};
4021 populateResponseInfo(responseInfo, serial, responseType, e);
4022 Return<void> retStatus =
4023 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4025 radioService[slotId]->checkReturnStatus(retStatus);
4027 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4034 int radio::acceptCallResponse(int slotId,
4035 int responseType, int serial, RIL_Errno e,
4036 void *response, size_t responseLen) {
4038 RLOGD("acceptCallResponse: serial %d", serial);
4041 if (radioService[slotId]->mRadioResponse != NULL) {
4042 RadioResponseInfo responseInfo = {};
4043 populateResponseInfo(responseInfo, serial, responseType, e);
4044 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4046 radioService[slotId]->checkReturnStatus(retStatus);
4048 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4055 int radio::deactivateDataCallResponse(int slotId,
4056 int responseType, int serial, RIL_Errno e,
4057 void *response, size_t responseLen) {
4059 RLOGD("deactivateDataCallResponse: serial %d", serial);
4062 if (radioService[slotId]->mRadioResponse != NULL) {
4063 RadioResponseInfo responseInfo = {};
4064 populateResponseInfo(responseInfo, serial, responseType, e);
4065 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4067 radioService[slotId]->checkReturnStatus(retStatus);
4069 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4076 int radio::getFacilityLockForAppResponse(int slotId,
4077 int responseType, int serial, RIL_Errno e,
4078 void *response, size_t responseLen) {
4080 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4083 if (radioService[slotId]->mRadioResponse != NULL) {
4084 RadioResponseInfo responseInfo = {};
4085 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4086 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4087 getFacilityLockForAppResponse(responseInfo, ret);
4088 radioService[slotId]->checkReturnStatus(retStatus);
4090 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4097 int radio::setFacilityLockForAppResponse(int slotId,
4098 int responseType, int serial, RIL_Errno e,
4099 void *response, size_t responseLen) {
4101 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4104 if (radioService[slotId]->mRadioResponse != NULL) {
4105 RadioResponseInfo responseInfo = {};
4106 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4107 Return<void> retStatus
4108 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4110 radioService[slotId]->checkReturnStatus(retStatus);
4112 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4119 int radio::setBarringPasswordResponse(int slotId,
4120 int responseType, int serial, RIL_Errno e,
4121 void *response, size_t responseLen) {
4123 RLOGD("acceptCallResponse: serial %d", serial);
4126 if (radioService[slotId]->mRadioResponse != NULL) {
4127 RadioResponseInfo responseInfo = {};
4128 populateResponseInfo(responseInfo, serial, responseType, e);
4129 Return<void> retStatus
4130 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4131 radioService[slotId]->checkReturnStatus(retStatus);
4133 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4140 int radio::getNetworkSelectionModeResponse(int slotId,
4141 int responseType, int serial, RIL_Errno e, void *response,
4142 size_t responseLen) {
4144 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4147 if (radioService[slotId]->mRadioResponse != NULL) {
4148 RadioResponseInfo responseInfo = {};
4149 populateResponseInfo(responseInfo, serial, responseType, e);
4150 bool manual = false;
4152 if (response == NULL || responseLen != sizeof(int)) {
4153 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4154 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4156 int *pInt = (int *) response;
4157 manual = pInt[0] == 1 ? true : false;
4159 Return<void> retStatus
4160 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4163 radioService[slotId]->checkReturnStatus(retStatus);
4165 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4172 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4173 RIL_Errno e, void *response,
4174 size_t responseLen) {
4176 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4179 if (radioService[slotId]->mRadioResponse != NULL) {
4180 RadioResponseInfo responseInfo = {};
4181 populateResponseInfo(responseInfo, serial, responseType, e);
4182 Return<void> retStatus
4183 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4185 radioService[slotId]->checkReturnStatus(retStatus);
4187 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4194 int radio::setNetworkSelectionModeManualResponse(int slotId,
4195 int responseType, int serial, RIL_Errno e,
4196 void *response, size_t responseLen) {
4198 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4201 if (radioService[slotId]->mRadioResponse != NULL) {
4202 RadioResponseInfo responseInfo = {};
4203 populateResponseInfo(responseInfo, serial, responseType, e);
4204 Return<void> retStatus
4205 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4207 radioService[slotId]->checkReturnStatus(retStatus);
4209 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4216 int convertOperatorStatusToInt(const char *str) {
4217 if (strncmp("unknown", str, 9) == 0) {
4218 return (int) OperatorStatus::UNKNOWN;
4219 } else if (strncmp("available", str, 9) == 0) {
4220 return (int) OperatorStatus::AVAILABLE;
4221 } else if (strncmp("current", str, 9) == 0) {
4222 return (int) OperatorStatus::CURRENT;
4223 } else if (strncmp("forbidden", str, 9) == 0) {
4224 return (int) OperatorStatus::FORBIDDEN;
4230 int radio::getAvailableNetworksResponse(int slotId,
4231 int responseType, int serial, RIL_Errno e, void *response,
4232 size_t responseLen) {
4234 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4237 if (radioService[slotId]->mRadioResponse != NULL) {
4238 RadioResponseInfo responseInfo = {};
4239 populateResponseInfo(responseInfo, serial, responseType, e);
4240 hidl_vec<OperatorInfo> networks;
4241 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) {
4242 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4243 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4245 char **resp = (char **) response;
4246 int numStrings = responseLen / sizeof(char *);
4247 networks.resize(numStrings/4);
4248 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4249 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4250 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4251 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4252 int status = convertOperatorStatusToInt(resp[i + 3]);
4254 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4256 networks[j].status = (OperatorStatus) status;
4260 Return<void> retStatus
4261 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4263 radioService[slotId]->checkReturnStatus(retStatus);
4265 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4272 int radio::startDtmfResponse(int slotId,
4273 int responseType, int serial, RIL_Errno e,
4274 void *response, size_t responseLen) {
4276 RLOGD("startDtmfResponse: serial %d", serial);
4279 if (radioService[slotId]->mRadioResponse != NULL) {
4280 RadioResponseInfo responseInfo = {};
4281 populateResponseInfo(responseInfo, serial, responseType, e);
4282 Return<void> retStatus
4283 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4284 radioService[slotId]->checkReturnStatus(retStatus);
4286 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4292 int radio::stopDtmfResponse(int slotId,
4293 int responseType, int serial, RIL_Errno e,
4294 void *response, size_t responseLen) {
4296 RLOGD("stopDtmfResponse: serial %d", serial);
4299 if (radioService[slotId]->mRadioResponse != NULL) {
4300 RadioResponseInfo responseInfo = {};
4301 populateResponseInfo(responseInfo, serial, responseType, e);
4302 Return<void> retStatus
4303 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4304 radioService[slotId]->checkReturnStatus(retStatus);
4306 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4312 int radio::getBasebandVersionResponse(int slotId,
4313 int responseType, int serial, RIL_Errno e,
4314 void *response, size_t responseLen) {
4316 RLOGD("getBasebandVersionResponse: serial %d", serial);
4319 if (radioService[slotId]->mRadioResponse != NULL) {
4320 RadioResponseInfo responseInfo = {};
4321 populateResponseInfo(responseInfo, serial, responseType, e);
4322 Return<void> retStatus
4323 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4324 convertCharPtrToHidlString((char *) response));
4325 radioService[slotId]->checkReturnStatus(retStatus);
4327 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4333 int radio::separateConnectionResponse(int slotId,
4334 int responseType, int serial, RIL_Errno e,
4335 void *response, size_t responseLen) {
4337 RLOGD("separateConnectionResponse: serial %d", serial);
4340 if (radioService[slotId]->mRadioResponse != NULL) {
4341 RadioResponseInfo responseInfo = {};
4342 populateResponseInfo(responseInfo, serial, responseType, e);
4343 Return<void> retStatus
4344 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4345 radioService[slotId]->checkReturnStatus(retStatus);
4347 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4354 int radio::setMuteResponse(int slotId,
4355 int responseType, int serial, RIL_Errno e,
4356 void *response, size_t responseLen) {
4358 RLOGD("setMuteResponse: serial %d", serial);
4361 if (radioService[slotId]->mRadioResponse != NULL) {
4362 RadioResponseInfo responseInfo = {};
4363 populateResponseInfo(responseInfo, serial, responseType, e);
4364 Return<void> retStatus
4365 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4366 radioService[slotId]->checkReturnStatus(retStatus);
4368 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4374 int radio::getMuteResponse(int slotId,
4375 int responseType, int serial, RIL_Errno e, void *response,
4376 size_t responseLen) {
4378 RLOGD("getMuteResponse: serial %d", serial);
4381 if (radioService[slotId]->mRadioResponse != NULL) {
4382 RadioResponseInfo responseInfo = {};
4383 populateResponseInfo(responseInfo, serial, responseType, e);
4384 bool enable = false;
4386 if (response == NULL || responseLen != sizeof(int)) {
4387 RLOGE("getMuteResponse Invalid response: NULL");
4388 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4390 int *pInt = (int *) response;
4391 enable = pInt[0] == 1 ? true : false;
4393 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4395 radioService[slotId]->checkReturnStatus(retStatus);
4397 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4403 int radio::getClipResponse(int slotId,
4404 int responseType, int serial, RIL_Errno e,
4405 void *response, size_t responseLen) {
4407 RLOGD("getClipResponse: serial %d", serial);
4410 if (radioService[slotId]->mRadioResponse != NULL) {
4411 RadioResponseInfo responseInfo = {};
4412 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4413 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4415 radioService[slotId]->checkReturnStatus(retStatus);
4417 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4423 int radio::getDataCallListResponse(int slotId,
4424 int responseType, int serial, RIL_Errno e,
4425 void *response, size_t responseLen) {
4427 RLOGD("getDataCallListResponse: serial %d", serial);
4430 if (radioService[slotId]->mRadioResponse != NULL) {
4431 RadioResponseInfo responseInfo = {};
4432 populateResponseInfo(responseInfo, serial, responseType, e);
4434 hidl_vec<SetupDataCallResult> ret;
4435 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4436 RLOGE("getDataCallListResponse: invalid response");
4437 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4439 convertRilDataCallListToHal(response, responseLen, ret);
4442 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4444 radioService[slotId]->checkReturnStatus(retStatus);
4446 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4452 int radio::setSuppServiceNotificationsResponse(int slotId,
4453 int responseType, int serial, RIL_Errno e,
4454 void *response, size_t responseLen) {
4456 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4459 if (radioService[slotId]->mRadioResponse != NULL) {
4460 RadioResponseInfo responseInfo = {};
4461 populateResponseInfo(responseInfo, serial, responseType, e);
4462 Return<void> retStatus
4463 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4465 radioService[slotId]->checkReturnStatus(retStatus);
4467 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4474 int radio::deleteSmsOnSimResponse(int slotId,
4475 int responseType, int serial, RIL_Errno e,
4476 void *response, size_t responseLen) {
4478 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4481 if (radioService[slotId]->mRadioResponse != NULL) {
4482 RadioResponseInfo responseInfo = {};
4483 populateResponseInfo(responseInfo, serial, responseType, e);
4484 Return<void> retStatus
4485 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4486 radioService[slotId]->checkReturnStatus(retStatus);
4488 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4494 int radio::setBandModeResponse(int slotId,
4495 int responseType, int serial, RIL_Errno e,
4496 void *response, size_t responseLen) {
4498 RLOGD("setBandModeResponse: serial %d", serial);
4501 if (radioService[slotId]->mRadioResponse != NULL) {
4502 RadioResponseInfo responseInfo = {};
4503 populateResponseInfo(responseInfo, serial, responseType, e);
4504 Return<void> retStatus
4505 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4506 radioService[slotId]->checkReturnStatus(retStatus);
4508 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4514 int radio::writeSmsToSimResponse(int slotId,
4515 int responseType, int serial, RIL_Errno e,
4516 void *response, size_t responseLen) {
4518 RLOGD("writeSmsToSimResponse: serial %d", serial);
4521 if (radioService[slotId]->mRadioResponse != NULL) {
4522 RadioResponseInfo responseInfo = {};
4523 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4524 Return<void> retStatus
4525 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4526 radioService[slotId]->checkReturnStatus(retStatus);
4528 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4534 int radio::getAvailableBandModesResponse(int slotId,
4535 int responseType, int serial, RIL_Errno e, void *response,
4536 size_t responseLen) {
4538 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4541 if (radioService[slotId]->mRadioResponse != NULL) {
4542 RadioResponseInfo responseInfo = {};
4543 populateResponseInfo(responseInfo, serial, responseType, e);
4544 hidl_vec<RadioBandMode> modes;
4545 if (response == NULL || responseLen % sizeof(int) != 0) {
4546 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4547 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4549 int *pInt = (int *) response;
4550 int numInts = responseLen / sizeof(int);
4551 modes.resize(numInts);
4552 for (int i = 0; i < numInts; i++) {
4553 modes[i] = (RadioBandMode) pInt[i];
4556 Return<void> retStatus
4557 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4559 radioService[slotId]->checkReturnStatus(retStatus);
4561 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4568 int radio::sendEnvelopeResponse(int slotId,
4569 int responseType, int serial, RIL_Errno e,
4570 void *response, size_t responseLen) {
4572 RLOGD("sendEnvelopeResponse: serial %d", serial);
4575 if (radioService[slotId]->mRadioResponse != NULL) {
4576 RadioResponseInfo responseInfo = {};
4577 populateResponseInfo(responseInfo, serial, responseType, e);
4578 Return<void> retStatus
4579 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4580 convertCharPtrToHidlString((char *) response));
4581 radioService[slotId]->checkReturnStatus(retStatus);
4583 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4589 int radio::sendTerminalResponseToSimResponse(int slotId,
4590 int responseType, int serial, RIL_Errno e,
4591 void *response, size_t responseLen) {
4593 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4596 if (radioService[slotId]->mRadioResponse != NULL) {
4597 RadioResponseInfo responseInfo = {};
4598 populateResponseInfo(responseInfo, serial, responseType, e);
4599 Return<void> retStatus
4600 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4602 radioService[slotId]->checkReturnStatus(retStatus);
4604 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4611 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4612 int responseType, int serial,
4613 RIL_Errno e, void *response,
4614 size_t responseLen) {
4616 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4619 if (radioService[slotId]->mRadioResponse != NULL) {
4620 RadioResponseInfo responseInfo = {};
4621 populateResponseInfo(responseInfo, serial, responseType, e);
4622 Return<void> retStatus
4623 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4625 radioService[slotId]->checkReturnStatus(retStatus);
4627 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4634 int radio::explicitCallTransferResponse(int slotId,
4635 int responseType, int serial, RIL_Errno e,
4636 void *response, size_t responseLen) {
4638 RLOGD("explicitCallTransferResponse: serial %d", serial);
4641 if (radioService[slotId]->mRadioResponse != NULL) {
4642 RadioResponseInfo responseInfo = {};
4643 populateResponseInfo(responseInfo, serial, responseType, e);
4644 Return<void> retStatus
4645 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4646 radioService[slotId]->checkReturnStatus(retStatus);
4648 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4655 int radio::setPreferredNetworkTypeResponse(int slotId,
4656 int responseType, int serial, RIL_Errno e,
4657 void *response, size_t responseLen) {
4659 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4662 if (radioService[slotId]->mRadioResponse != NULL) {
4663 RadioResponseInfo responseInfo = {};
4664 populateResponseInfo(responseInfo, serial, responseType, e);
4665 Return<void> retStatus
4666 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4668 radioService[slotId]->checkReturnStatus(retStatus);
4670 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4678 int radio::getPreferredNetworkTypeResponse(int slotId,
4679 int responseType, int serial, RIL_Errno e,
4680 void *response, size_t responseLen) {
4682 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4685 if (radioService[slotId]->mRadioResponse != NULL) {
4686 RadioResponseInfo responseInfo = {};
4687 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4688 Return<void> retStatus
4689 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4690 responseInfo, (PreferredNetworkType) ret);
4691 radioService[slotId]->checkReturnStatus(retStatus);
4693 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4700 int radio::getNeighboringCidsResponse(int slotId,
4701 int responseType, int serial, RIL_Errno e,
4702 void *response, size_t responseLen) {
4704 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4707 if (radioService[slotId]->mRadioResponse != NULL) {
4708 RadioResponseInfo responseInfo = {};
4709 populateResponseInfo(responseInfo, serial, responseType, e);
4710 hidl_vec<NeighboringCell> cells;
4712 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4713 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4714 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4716 int num = responseLen / sizeof(RIL_NeighboringCell *);
4718 for (int i = 0 ; i < num; i++) {
4719 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4720 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4721 cells[i].rssi = resp->rssi;
4725 Return<void> retStatus
4726 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4728 radioService[slotId]->checkReturnStatus(retStatus);
4730 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4737 int radio::setLocationUpdatesResponse(int slotId,
4738 int responseType, int serial, RIL_Errno e,
4739 void *response, size_t responseLen) {
4741 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4744 if (radioService[slotId]->mRadioResponse != NULL) {
4745 RadioResponseInfo responseInfo = {};
4746 populateResponseInfo(responseInfo, serial, responseType, e);
4747 Return<void> retStatus
4748 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4749 radioService[slotId]->checkReturnStatus(retStatus);
4751 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4758 int radio::setCdmaSubscriptionSourceResponse(int slotId,
4759 int responseType, int serial, RIL_Errno e,
4760 void *response, size_t responseLen) {
4762 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4765 if (radioService[slotId]->mRadioResponse != NULL) {
4766 RadioResponseInfo responseInfo = {};
4767 populateResponseInfo(responseInfo, serial, responseType, e);
4768 Return<void> retStatus
4769 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4771 radioService[slotId]->checkReturnStatus(retStatus);
4773 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4780 int radio::setCdmaRoamingPreferenceResponse(int slotId,
4781 int responseType, int serial, RIL_Errno e,
4782 void *response, size_t responseLen) {
4784 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4787 if (radioService[slotId]->mRadioResponse != NULL) {
4788 RadioResponseInfo responseInfo = {};
4789 populateResponseInfo(responseInfo, serial, responseType, e);
4790 Return<void> retStatus
4791 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4793 radioService[slotId]->checkReturnStatus(retStatus);
4795 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4802 int radio::getCdmaRoamingPreferenceResponse(int slotId,
4803 int responseType, int serial, RIL_Errno e,
4804 void *response, size_t responseLen) {
4806 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4809 if (radioService[slotId]->mRadioResponse != NULL) {
4810 RadioResponseInfo responseInfo = {};
4811 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4812 Return<void> retStatus
4813 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4814 responseInfo, (CdmaRoamingType) ret);
4815 radioService[slotId]->checkReturnStatus(retStatus);
4817 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4824 int radio::setTTYModeResponse(int slotId,
4825 int responseType, int serial, RIL_Errno e,
4826 void *response, size_t responseLen) {
4828 RLOGD("setTTYModeResponse: serial %d", serial);
4831 if (radioService[slotId]->mRadioResponse != NULL) {
4832 RadioResponseInfo responseInfo = {};
4833 populateResponseInfo(responseInfo, serial, responseType, e);
4834 Return<void> retStatus
4835 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4836 radioService[slotId]->checkReturnStatus(retStatus);
4838 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4844 int radio::getTTYModeResponse(int slotId,
4845 int responseType, int serial, RIL_Errno e,
4846 void *response, size_t responseLen) {
4848 RLOGD("getTTYModeResponse: serial %d", serial);
4851 if (radioService[slotId]->mRadioResponse != NULL) {
4852 RadioResponseInfo responseInfo = {};
4853 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4854 Return<void> retStatus
4855 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4857 radioService[slotId]->checkReturnStatus(retStatus);
4859 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4865 int radio::setPreferredVoicePrivacyResponse(int slotId,
4866 int responseType, int serial, RIL_Errno e,
4867 void *response, size_t responseLen) {
4869 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
4872 if (radioService[slotId]->mRadioResponse != NULL) {
4873 RadioResponseInfo responseInfo = {};
4874 populateResponseInfo(responseInfo, serial, responseType, e);
4875 Return<void> retStatus
4876 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4878 radioService[slotId]->checkReturnStatus(retStatus);
4880 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4887 int radio::getPreferredVoicePrivacyResponse(int slotId,
4888 int responseType, int serial, RIL_Errno e,
4889 void *response, size_t responseLen) {
4891 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
4894 if (radioService[slotId]->mRadioResponse != NULL) {
4895 RadioResponseInfo responseInfo = {};
4896 populateResponseInfo(responseInfo, serial, responseType, e);
4897 bool enable = false;
4898 int numInts = responseLen / sizeof(int);
4899 if (response == NULL || numInts != 1) {
4900 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
4901 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4903 int *pInt = (int *) response;
4904 enable = pInt[0] == 1 ? true : false;
4906 Return<void> retStatus
4907 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
4908 responseInfo, enable);
4909 radioService[slotId]->checkReturnStatus(retStatus);
4911 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4918 int radio::sendCDMAFeatureCodeResponse(int slotId,
4919 int responseType, int serial, RIL_Errno e,
4920 void *response, size_t responseLen) {
4922 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
4925 if (radioService[slotId]->mRadioResponse != NULL) {
4926 RadioResponseInfo responseInfo = {};
4927 populateResponseInfo(responseInfo, serial, responseType, e);
4928 Return<void> retStatus
4929 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
4930 radioService[slotId]->checkReturnStatus(retStatus);
4932 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
4939 int radio::sendBurstDtmfResponse(int slotId,
4940 int responseType, int serial, RIL_Errno e,
4941 void *response, size_t responseLen) {
4943 RLOGD("sendBurstDtmfResponse: serial %d", serial);
4946 if (radioService[slotId]->mRadioResponse != NULL) {
4947 RadioResponseInfo responseInfo = {};
4948 populateResponseInfo(responseInfo, serial, responseType, e);
4949 Return<void> retStatus
4950 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
4951 radioService[slotId]->checkReturnStatus(retStatus);
4953 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4959 int radio::sendCdmaSmsResponse(int slotId,
4960 int responseType, int serial, RIL_Errno e, void *response,
4961 size_t responseLen) {
4963 RLOGD("sendCdmaSmsResponse: serial %d", serial);
4966 if (radioService[slotId]->mRadioResponse != NULL) {
4967 RadioResponseInfo responseInfo = {};
4968 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4971 Return<void> retStatus
4972 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
4973 radioService[slotId]->checkReturnStatus(retStatus);
4975 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4981 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
4982 int responseType, int serial, RIL_Errno e,
4983 void *response, size_t responseLen) {
4985 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
4988 if (radioService[slotId]->mRadioResponse != NULL) {
4989 RadioResponseInfo responseInfo = {};
4990 populateResponseInfo(responseInfo, serial, responseType, e);
4991 Return<void> retStatus
4992 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
4994 radioService[slotId]->checkReturnStatus(retStatus);
4996 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5003 int radio::getGsmBroadcastConfigResponse(int slotId,
5004 int responseType, int serial, RIL_Errno e,
5005 void *response, size_t responseLen) {
5007 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5010 if (radioService[slotId]->mRadioResponse != NULL) {
5011 RadioResponseInfo responseInfo = {};
5012 populateResponseInfo(responseInfo, serial, responseType, e);
5013 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5015 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5016 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5017 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5019 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5020 configs.resize(num);
5021 for (int i = 0 ; i < num; i++) {
5022 RIL_GSM_BroadcastSmsConfigInfo *resp =
5023 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5024 configs[i].fromServiceId = resp->fromServiceId;
5025 configs[i].toServiceId = resp->toServiceId;
5026 configs[i].fromCodeScheme = resp->fromCodeScheme;
5027 configs[i].toCodeScheme = resp->toCodeScheme;
5028 configs[i].selected = resp->selected == 1 ? true : false;
5032 Return<void> retStatus
5033 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5035 radioService[slotId]->checkReturnStatus(retStatus);
5037 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5044 int radio::setGsmBroadcastConfigResponse(int slotId,
5045 int responseType, int serial, RIL_Errno e,
5046 void *response, size_t responseLen) {
5048 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5051 if (radioService[slotId]->mRadioResponse != NULL) {
5052 RadioResponseInfo responseInfo = {};
5053 populateResponseInfo(responseInfo, serial, responseType, e);
5054 Return<void> retStatus
5055 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5056 radioService[slotId]->checkReturnStatus(retStatus);
5058 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5065 int radio::setGsmBroadcastActivationResponse(int slotId,
5066 int responseType, int serial, RIL_Errno e,
5067 void *response, size_t responseLen) {
5069 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5072 if (radioService[slotId]->mRadioResponse != NULL) {
5073 RadioResponseInfo responseInfo = {};
5074 populateResponseInfo(responseInfo, serial, responseType, e);
5075 Return<void> retStatus
5076 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5078 radioService[slotId]->checkReturnStatus(retStatus);
5080 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5087 int radio::getCdmaBroadcastConfigResponse(int slotId,
5088 int responseType, int serial, RIL_Errno e,
5089 void *response, size_t responseLen) {
5091 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5094 if (radioService[slotId]->mRadioResponse != NULL) {
5095 RadioResponseInfo responseInfo = {};
5096 populateResponseInfo(responseInfo, serial, responseType, e);
5097 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5099 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5100 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5101 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5103 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5104 configs.resize(num);
5105 for (int i = 0 ; i < num; i++) {
5106 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5107 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5108 configs[i].serviceCategory = resp->service_category;
5109 configs[i].language = resp->language;
5110 configs[i].selected = resp->selected == 1 ? true : false;
5114 Return<void> retStatus
5115 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5117 radioService[slotId]->checkReturnStatus(retStatus);
5119 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5126 int radio::setCdmaBroadcastConfigResponse(int slotId,
5127 int responseType, int serial, RIL_Errno e,
5128 void *response, size_t responseLen) {
5130 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5133 if (radioService[slotId]->mRadioResponse != NULL) {
5134 RadioResponseInfo responseInfo = {};
5135 populateResponseInfo(responseInfo, serial, responseType, e);
5136 Return<void> retStatus
5137 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5139 radioService[slotId]->checkReturnStatus(retStatus);
5141 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5148 int radio::setCdmaBroadcastActivationResponse(int slotId,
5149 int responseType, int serial, RIL_Errno e,
5150 void *response, size_t responseLen) {
5152 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5155 if (radioService[slotId]->mRadioResponse != NULL) {
5156 RadioResponseInfo responseInfo = {};
5157 populateResponseInfo(responseInfo, serial, responseType, e);
5158 Return<void> retStatus
5159 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5161 radioService[slotId]->checkReturnStatus(retStatus);
5163 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5170 int radio::getCDMASubscriptionResponse(int slotId,
5171 int responseType, int serial, RIL_Errno e, void *response,
5172 size_t responseLen) {
5174 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5177 if (radioService[slotId]->mRadioResponse != NULL) {
5178 RadioResponseInfo responseInfo = {};
5179 populateResponseInfo(responseInfo, serial, responseType, e);
5181 int numStrings = responseLen / sizeof(char *);
5182 hidl_string emptyString;
5183 if (response == NULL || numStrings != 5) {
5184 RLOGE("getOperatorResponse Invalid response: NULL");
5185 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5186 Return<void> retStatus
5187 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5188 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5189 radioService[slotId]->checkReturnStatus(retStatus);
5191 char **resp = (char **) response;
5192 Return<void> retStatus
5193 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5195 convertCharPtrToHidlString(resp[0]),
5196 convertCharPtrToHidlString(resp[1]),
5197 convertCharPtrToHidlString(resp[2]),
5198 convertCharPtrToHidlString(resp[3]),
5199 convertCharPtrToHidlString(resp[4]));
5200 radioService[slotId]->checkReturnStatus(retStatus);
5203 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5210 int radio::writeSmsToRuimResponse(int slotId,
5211 int responseType, int serial, RIL_Errno e,
5212 void *response, size_t responseLen) {
5214 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5217 if (radioService[slotId]->mRadioResponse != NULL) {
5218 RadioResponseInfo responseInfo = {};
5219 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5220 Return<void> retStatus
5221 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5222 radioService[slotId]->checkReturnStatus(retStatus);
5224 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5230 int radio::deleteSmsOnRuimResponse(int slotId,
5231 int responseType, int serial, RIL_Errno e,
5232 void *response, size_t responseLen) {
5234 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5237 if (radioService[slotId]->mRadioResponse != NULL) {
5238 RadioResponseInfo responseInfo = {};
5239 populateResponseInfo(responseInfo, serial, responseType, e);
5240 Return<void> retStatus
5241 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5242 radioService[slotId]->checkReturnStatus(retStatus);
5244 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5250 int radio::getDeviceIdentityResponse(int slotId,
5251 int responseType, int serial, RIL_Errno e, void *response,
5252 size_t responseLen) {
5254 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5257 if (radioService[slotId]->mRadioResponse != NULL) {
5258 RadioResponseInfo responseInfo = {};
5259 populateResponseInfo(responseInfo, serial, responseType, e);
5261 int numStrings = responseLen / sizeof(char *);
5262 hidl_string emptyString;
5263 if (response == NULL || numStrings != 4) {
5264 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5265 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5266 Return<void> retStatus
5267 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5268 emptyString, emptyString, emptyString, emptyString);
5269 radioService[slotId]->checkReturnStatus(retStatus);
5271 char **resp = (char **) response;
5272 Return<void> retStatus
5273 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5274 convertCharPtrToHidlString(resp[0]),
5275 convertCharPtrToHidlString(resp[1]),
5276 convertCharPtrToHidlString(resp[2]),
5277 convertCharPtrToHidlString(resp[3]));
5278 radioService[slotId]->checkReturnStatus(retStatus);
5281 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5288 int radio::exitEmergencyCallbackModeResponse(int slotId,
5289 int responseType, int serial, RIL_Errno e,
5290 void *response, size_t responseLen) {
5292 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5295 if (radioService[slotId]->mRadioResponse != NULL) {
5296 RadioResponseInfo responseInfo = {};
5297 populateResponseInfo(responseInfo, serial, responseType, e);
5298 Return<void> retStatus
5299 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5301 radioService[slotId]->checkReturnStatus(retStatus);
5303 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5310 int radio::getSmscAddressResponse(int slotId,
5311 int responseType, int serial, RIL_Errno e,
5312 void *response, size_t responseLen) {
5314 RLOGD("getSmscAddressResponse: serial %d", serial);
5317 if (radioService[slotId]->mRadioResponse != NULL) {
5318 RadioResponseInfo responseInfo = {};
5319 populateResponseInfo(responseInfo, serial, responseType, e);
5320 Return<void> retStatus
5321 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5322 convertCharPtrToHidlString((char *) response));
5323 radioService[slotId]->checkReturnStatus(retStatus);
5325 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5331 int radio::setSmscAddressResponse(int slotId,
5332 int responseType, int serial, RIL_Errno e,
5333 void *response, size_t responseLen) {
5335 RLOGD("setSmscAddressResponse: serial %d", serial);
5338 if (radioService[slotId]->mRadioResponse != NULL) {
5339 RadioResponseInfo responseInfo = {};
5340 populateResponseInfo(responseInfo, serial, responseType, e);
5341 Return<void> retStatus
5342 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5343 radioService[slotId]->checkReturnStatus(retStatus);
5345 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5351 int radio::reportSmsMemoryStatusResponse(int slotId,
5352 int responseType, int serial, RIL_Errno e,
5353 void *response, size_t responseLen) {
5355 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5358 if (radioService[slotId]->mRadioResponse != NULL) {
5359 RadioResponseInfo responseInfo = {};
5360 populateResponseInfo(responseInfo, serial, responseType, e);
5361 Return<void> retStatus
5362 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5363 radioService[slotId]->checkReturnStatus(retStatus);
5365 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5372 int radio::reportStkServiceIsRunningResponse(int slotId,
5373 int responseType, int serial, RIL_Errno e,
5374 void *response, size_t responseLen) {
5376 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5379 if (radioService[slotId]->mRadioResponse != NULL) {
5380 RadioResponseInfo responseInfo = {};
5381 populateResponseInfo(responseInfo, serial, responseType, e);
5382 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5383 reportStkServiceIsRunningResponse(responseInfo);
5384 radioService[slotId]->checkReturnStatus(retStatus);
5386 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5393 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5394 int responseType, int serial, RIL_Errno e,
5395 void *response, size_t responseLen) {
5397 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5400 if (radioService[slotId]->mRadioResponse != NULL) {
5401 RadioResponseInfo responseInfo = {};
5402 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5403 Return<void> retStatus
5404 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5405 responseInfo, (CdmaSubscriptionSource) ret);
5406 radioService[slotId]->checkReturnStatus(retStatus);
5408 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5415 int radio::requestIsimAuthenticationResponse(int slotId,
5416 int responseType, int serial, RIL_Errno e,
5417 void *response, size_t responseLen) {
5419 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5422 if (radioService[slotId]->mRadioResponse != NULL) {
5423 RadioResponseInfo responseInfo = {};
5424 populateResponseInfo(responseInfo, serial, responseType, e);
5425 Return<void> retStatus
5426 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5428 convertCharPtrToHidlString((char *) response));
5429 radioService[slotId]->checkReturnStatus(retStatus);
5431 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5438 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5440 int serial, RIL_Errno e, void *response,
5441 size_t responseLen) {
5443 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5446 if (radioService[slotId]->mRadioResponse != NULL) {
5447 RadioResponseInfo responseInfo = {};
5448 populateResponseInfo(responseInfo, serial, responseType, e);
5449 Return<void> retStatus
5450 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5452 radioService[slotId]->checkReturnStatus(retStatus);
5454 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5461 int radio::sendEnvelopeWithStatusResponse(int slotId,
5462 int responseType, int serial, RIL_Errno e, void *response,
5463 size_t responseLen) {
5465 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5468 if (radioService[slotId]->mRadioResponse != NULL) {
5469 RadioResponseInfo responseInfo = {};
5470 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5471 response, responseLen);
5473 Return<void> retStatus
5474 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5476 radioService[slotId]->checkReturnStatus(retStatus);
5478 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5485 int radio::getVoiceRadioTechnologyResponse(int slotId,
5486 int responseType, int serial, RIL_Errno e,
5487 void *response, size_t responseLen) {
5489 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5492 if (radioService[slotId]->mRadioResponse != NULL) {
5493 RadioResponseInfo responseInfo = {};
5494 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5495 Return<void> retStatus
5496 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5497 responseInfo, (RadioTechnology) ret);
5498 radioService[slotId]->checkReturnStatus(retStatus);
5500 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5507 int radio::getCellInfoListResponse(int slotId,
5509 int serial, RIL_Errno e, void *response,
5510 size_t responseLen) {
5512 RLOGD("getCellInfoListResponse: serial %d", serial);
5515 if (radioService[slotId]->mRadioResponse != NULL) {
5516 RadioResponseInfo responseInfo = {};
5517 populateResponseInfo(responseInfo, serial, responseType, e);
5519 hidl_vec<CellInfo> ret;
5520 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5521 RLOGE("getCellInfoListResponse: Invalid response");
5522 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5524 convertRilCellInfoListToHal(response, responseLen, ret);
5527 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5529 radioService[slotId]->checkReturnStatus(retStatus);
5531 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5537 int radio::setCellInfoListRateResponse(int slotId,
5539 int serial, RIL_Errno e, void *response,
5540 size_t responseLen) {
5542 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5545 if (radioService[slotId]->mRadioResponse != NULL) {
5546 RadioResponseInfo responseInfo = {};
5547 populateResponseInfo(responseInfo, serial, responseType, e);
5548 Return<void> retStatus
5549 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5550 radioService[slotId]->checkReturnStatus(retStatus);
5552 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5559 int radio::setInitialAttachApnResponse(int slotId,
5560 int responseType, int serial, RIL_Errno e,
5561 void *response, size_t responseLen) {
5563 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5566 if (radioService[slotId]->mRadioResponse != NULL) {
5567 RadioResponseInfo responseInfo = {};
5568 populateResponseInfo(responseInfo, serial, responseType, e);
5569 Return<void> retStatus
5570 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5571 radioService[slotId]->checkReturnStatus(retStatus);
5573 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5580 int radio::getImsRegistrationStateResponse(int slotId,
5581 int responseType, int serial, RIL_Errno e,
5582 void *response, size_t responseLen) {
5584 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5587 if (radioService[slotId]->mRadioResponse != NULL) {
5588 RadioResponseInfo responseInfo = {};
5589 populateResponseInfo(responseInfo, serial, responseType, e);
5590 bool isRegistered = false;
5592 int numInts = responseLen / sizeof(int);
5593 if (response == NULL || numInts != 2) {
5594 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5595 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5597 int *pInt = (int *) response;
5598 isRegistered = pInt[0] == 1 ? true : false;
5599 ratFamily = pInt[1];
5601 Return<void> retStatus
5602 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5603 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5604 radioService[slotId]->checkReturnStatus(retStatus);
5606 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5613 int radio::sendImsSmsResponse(int slotId,
5614 int responseType, int serial, RIL_Errno e, void *response,
5615 size_t responseLen) {
5617 RLOGD("sendImsSmsResponse: serial %d", serial);
5620 if (radioService[slotId]->mRadioResponse != NULL) {
5621 RadioResponseInfo responseInfo = {};
5622 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5625 Return<void> retStatus
5626 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5627 radioService[slotId]->checkReturnStatus(retStatus);
5629 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5635 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5636 int responseType, int serial, RIL_Errno e,
5637 void *response, size_t responseLen) {
5639 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5642 if (radioService[slotId]->mRadioResponse != NULL) {
5643 RadioResponseInfo responseInfo = {};
5644 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5647 Return<void> retStatus
5648 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5649 responseInfo, result);
5650 radioService[slotId]->checkReturnStatus(retStatus);
5652 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5659 int radio::iccOpenLogicalChannelResponse(int slotId,
5660 int responseType, int serial, RIL_Errno e, void *response,
5661 size_t responseLen) {
5663 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5666 if (radioService[slotId]->mRadioResponse != NULL) {
5667 RadioResponseInfo responseInfo = {};
5668 populateResponseInfo(responseInfo, serial, responseType, e);
5670 hidl_vec<int8_t> selectResponse;
5671 int numInts = responseLen / sizeof(int);
5672 if (response == NULL || responseLen % sizeof(int) != 0) {
5673 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5674 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5676 int *pInt = (int *) response;
5677 channelId = pInt[0];
5678 selectResponse.resize(numInts - 1);
5679 for (int i = 1; i < numInts; i++) {
5680 selectResponse[i - 1] = (int8_t) pInt[i];
5683 Return<void> retStatus
5684 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5685 channelId, selectResponse);
5686 radioService[slotId]->checkReturnStatus(retStatus);
5688 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5695 int radio::iccCloseLogicalChannelResponse(int slotId,
5696 int responseType, int serial, RIL_Errno e,
5697 void *response, size_t responseLen) {
5699 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5702 if (radioService[slotId]->mRadioResponse != NULL) {
5703 RadioResponseInfo responseInfo = {};
5704 populateResponseInfo(responseInfo, serial, responseType, e);
5705 Return<void> retStatus
5706 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5708 radioService[slotId]->checkReturnStatus(retStatus);
5710 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5717 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5718 int responseType, int serial, RIL_Errno e,
5719 void *response, size_t responseLen) {
5721 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5724 if (radioService[slotId]->mRadioResponse != NULL) {
5725 RadioResponseInfo responseInfo = {};
5726 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5729 Return<void> retStatus
5730 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5731 responseInfo, result);
5732 radioService[slotId]->checkReturnStatus(retStatus);
5734 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5741 int radio::nvReadItemResponse(int slotId,
5742 int responseType, int serial, RIL_Errno e,
5743 void *response, size_t responseLen) {
5745 RLOGD("nvReadItemResponse: serial %d", serial);
5748 if (radioService[slotId]->mRadioResponse != NULL) {
5749 RadioResponseInfo responseInfo = {};
5750 populateResponseInfo(responseInfo, serial, responseType, e);
5751 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5753 convertCharPtrToHidlString((char *) response));
5754 radioService[slotId]->checkReturnStatus(retStatus);
5756 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5762 int radio::nvWriteItemResponse(int slotId,
5763 int responseType, int serial, RIL_Errno e,
5764 void *response, size_t responseLen) {
5766 RLOGD("nvWriteItemResponse: serial %d", serial);
5769 if (radioService[slotId]->mRadioResponse != NULL) {
5770 RadioResponseInfo responseInfo = {};
5771 populateResponseInfo(responseInfo, serial, responseType, e);
5772 Return<void> retStatus
5773 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5774 radioService[slotId]->checkReturnStatus(retStatus);
5776 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5782 int radio::nvWriteCdmaPrlResponse(int slotId,
5783 int responseType, int serial, RIL_Errno e,
5784 void *response, size_t responseLen) {
5786 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5789 if (radioService[slotId]->mRadioResponse != NULL) {
5790 RadioResponseInfo responseInfo = {};
5791 populateResponseInfo(responseInfo, serial, responseType, e);
5792 Return<void> retStatus
5793 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5794 radioService[slotId]->checkReturnStatus(retStatus);
5796 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5802 int radio::nvResetConfigResponse(int slotId,
5803 int responseType, int serial, RIL_Errno e,
5804 void *response, size_t responseLen) {
5806 RLOGD("nvResetConfigResponse: serial %d", serial);
5809 if (radioService[slotId]->mRadioResponse != NULL) {
5810 RadioResponseInfo responseInfo = {};
5811 populateResponseInfo(responseInfo, serial, responseType, e);
5812 Return<void> retStatus
5813 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5814 radioService[slotId]->checkReturnStatus(retStatus);
5816 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5822 int radio::setUiccSubscriptionResponse(int slotId,
5823 int responseType, int serial, RIL_Errno e,
5824 void *response, size_t responseLen) {
5826 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5829 if (radioService[slotId]->mRadioResponse != NULL) {
5830 RadioResponseInfo responseInfo = {};
5831 populateResponseInfo(responseInfo, serial, responseType, e);
5832 Return<void> retStatus
5833 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5834 radioService[slotId]->checkReturnStatus(retStatus);
5836 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5843 int radio::setDataAllowedResponse(int slotId,
5844 int responseType, int serial, RIL_Errno e,
5845 void *response, size_t responseLen) {
5847 RLOGD("setDataAllowedResponse: serial %d", serial);
5850 if (radioService[slotId]->mRadioResponse != NULL) {
5851 RadioResponseInfo responseInfo = {};
5852 populateResponseInfo(responseInfo, serial, responseType, e);
5853 Return<void> retStatus
5854 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5855 radioService[slotId]->checkReturnStatus(retStatus);
5857 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5863 int radio::getHardwareConfigResponse(int slotId,
5864 int responseType, int serial, RIL_Errno e,
5865 void *response, size_t responseLen) {
5867 RLOGD("getHardwareConfigResponse: serial %d", serial);
5870 if (radioService[slotId]->mRadioResponse != NULL) {
5871 RadioResponseInfo responseInfo = {};
5872 populateResponseInfo(responseInfo, serial, responseType, e);
5874 hidl_vec<HardwareConfig> result;
5875 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
5876 RLOGE("hardwareConfigChangedInd: invalid response");
5877 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5879 convertRilHardwareConfigListToHal(response, responseLen, result);
5882 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
5883 responseInfo, result);
5884 radioService[slotId]->checkReturnStatus(retStatus);
5886 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5892 int radio::requestIccSimAuthenticationResponse(int slotId,
5893 int responseType, int serial, RIL_Errno e,
5894 void *response, size_t responseLen) {
5896 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
5899 if (radioService[slotId]->mRadioResponse != NULL) {
5900 RadioResponseInfo responseInfo = {};
5901 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5904 Return<void> retStatus
5905 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
5906 responseInfo, result);
5907 radioService[slotId]->checkReturnStatus(retStatus);
5909 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
5916 int radio::setDataProfileResponse(int slotId,
5917 int responseType, int serial, RIL_Errno e,
5918 void *response, size_t responseLen) {
5920 RLOGD("setDataProfileResponse: serial %d", serial);
5923 if (radioService[slotId]->mRadioResponse != NULL) {
5924 RadioResponseInfo responseInfo = {};
5925 populateResponseInfo(responseInfo, serial, responseType, e);
5926 Return<void> retStatus
5927 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
5928 radioService[slotId]->checkReturnStatus(retStatus);
5930 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5936 int radio::requestShutdownResponse(int slotId,
5937 int responseType, int serial, RIL_Errno e,
5938 void *response, size_t responseLen) {
5940 RLOGD("requestShutdownResponse: serial %d", serial);
5943 if (radioService[slotId]->mRadioResponse != NULL) {
5944 RadioResponseInfo responseInfo = {};
5945 populateResponseInfo(responseInfo, serial, responseType, e);
5946 Return<void> retStatus
5947 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
5948 radioService[slotId]->checkReturnStatus(retStatus);
5950 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5956 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
5957 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
5958 populateResponseInfo(responseInfo, serial, responseType, e);
5960 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
5961 RLOGE("responseRadioCapability: Invalid response");
5962 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5963 rc.logicalModemUuid = hidl_string();
5965 convertRilRadioCapabilityToHal(response, responseLen, rc);
5969 int radio::getRadioCapabilityResponse(int slotId,
5970 int responseType, int serial, RIL_Errno e,
5971 void *response, size_t responseLen) {
5973 RLOGD("getRadioCapabilityResponse: serial %d", serial);
5976 if (radioService[slotId]->mRadioResponse != NULL) {
5977 RadioResponseInfo responseInfo = {};
5978 RadioCapability result = {};
5979 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
5981 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
5982 responseInfo, result);
5983 radioService[slotId]->checkReturnStatus(retStatus);
5985 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5991 int radio::setRadioCapabilityResponse(int slotId,
5992 int responseType, int serial, RIL_Errno e,
5993 void *response, size_t responseLen) {
5995 RLOGD("setRadioCapabilityResponse: serial %d", serial);
5998 if (radioService[slotId]->mRadioResponse != NULL) {
5999 RadioResponseInfo responseInfo = {};
6000 RadioCapability result = {};
6001 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6003 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6004 responseInfo, result);
6005 radioService[slotId]->checkReturnStatus(retStatus);
6007 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6013 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6014 RIL_Errno e, void *response, size_t responseLen) {
6015 populateResponseInfo(responseInfo, serial, responseType, e);
6016 LceStatusInfo result = {};
6018 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6019 RLOGE("Invalid response: NULL");
6020 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6022 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6023 result.lceStatus = (LceStatus) resp->lce_status;
6024 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6029 int radio::startLceServiceResponse(int slotId,
6030 int responseType, int serial, RIL_Errno e,
6031 void *response, size_t responseLen) {
6033 RLOGD("startLceServiceResponse: serial %d", serial);
6036 if (radioService[slotId]->mRadioResponse != NULL) {
6037 RadioResponseInfo responseInfo = {};
6038 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6039 response, responseLen);
6041 Return<void> retStatus
6042 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6044 radioService[slotId]->checkReturnStatus(retStatus);
6046 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6052 int radio::stopLceServiceResponse(int slotId,
6053 int responseType, int serial, RIL_Errno e,
6054 void *response, size_t responseLen) {
6056 RLOGD("stopLceServiceResponse: serial %d", serial);
6059 if (radioService[slotId]->mRadioResponse != NULL) {
6060 RadioResponseInfo responseInfo = {};
6061 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6062 response, responseLen);
6064 Return<void> retStatus
6065 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6067 radioService[slotId]->checkReturnStatus(retStatus);
6069 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6075 int radio::pullLceDataResponse(int slotId,
6076 int responseType, int serial, RIL_Errno e,
6077 void *response, size_t responseLen) {
6079 RLOGD("pullLceDataResponse: serial %d", serial);
6082 if (radioService[slotId]->mRadioResponse != NULL) {
6083 RadioResponseInfo responseInfo = {};
6084 populateResponseInfo(responseInfo, serial, responseType, e);
6086 LceDataInfo result = {};
6087 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6088 RLOGE("pullLceDataResponse: Invalid response");
6089 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6091 convertRilLceDataInfoToHal(response, responseLen, result);
6094 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6095 responseInfo, result);
6096 radioService[slotId]->checkReturnStatus(retStatus);
6098 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6104 int radio::getModemActivityInfoResponse(int slotId,
6105 int responseType, int serial, RIL_Errno e,
6106 void *response, size_t responseLen) {
6108 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6111 if (radioService[slotId]->mRadioResponse != NULL) {
6112 RadioResponseInfo responseInfo = {};
6113 populateResponseInfo(responseInfo, serial, responseType, e);
6114 ActivityStatsInfo info;
6115 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6116 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6117 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6119 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6120 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6121 info.idleModeTimeMs = resp->idle_mode_time_ms;
6122 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6123 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6125 info.rxModeTimeMs = resp->rx_mode_time_ms;
6128 Return<void> retStatus
6129 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6131 radioService[slotId]->checkReturnStatus(retStatus);
6133 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6140 int radio::setAllowedCarriersResponse(int slotId,
6141 int responseType, int serial, RIL_Errno e,
6142 void *response, size_t responseLen) {
6144 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6147 if (radioService[slotId]->mRadioResponse != NULL) {
6148 RadioResponseInfo responseInfo = {};
6149 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6150 Return<void> retStatus
6151 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6153 radioService[slotId]->checkReturnStatus(retStatus);
6155 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6162 int radio::getAllowedCarriersResponse(int slotId,
6163 int responseType, int serial, RIL_Errno e,
6164 void *response, size_t responseLen) {
6166 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6169 if (radioService[slotId]->mRadioResponse != NULL) {
6170 RadioResponseInfo responseInfo = {};
6171 populateResponseInfo(responseInfo, serial, responseType, e);
6172 CarrierRestrictions carrierInfo = {};
6173 bool allAllowed = true;
6174 if (response == NULL || responseLen != sizeof(RIL_CarrierRestrictions)) {
6175 RLOGE("getAllowedCarriersResponse Invalid response: NULL");
6176 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6178 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6179 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6183 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6184 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6185 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6186 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6187 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6188 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6189 carrierInfo.allowedCarriers[i].matchData =
6190 convertCharPtrToHidlString(carrier->match_data);
6193 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6194 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6195 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6196 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6197 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6198 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6199 carrierInfo.excludedCarriers[i].matchData =
6200 convertCharPtrToHidlString(carrier->match_data);
6204 Return<void> retStatus
6205 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6206 allAllowed, carrierInfo);
6207 radioService[slotId]->checkReturnStatus(retStatus);
6209 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6216 int radio::sendDeviceStateResponse(int slotId,
6217 int responseType, int serial, RIL_Errno e,
6218 void *response, size_t responselen) {
6220 RLOGD("sendDeviceStateResponse: serial %d", serial);
6223 if (radioService[slotId]->mRadioResponse != NULL) {
6224 RadioResponseInfo responseInfo = {};
6225 populateResponseInfo(responseInfo, serial, responseType, e);
6226 Return<void> retStatus
6227 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6228 radioService[slotId]->checkReturnStatus(retStatus);
6230 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6236 int radio::setIndicationFilterResponse(int slotId,
6237 int responseType, int serial, RIL_Errno e,
6238 void *response, size_t responselen) {
6240 RLOGD("setIndicationFilterResponse: serial %d", serial);
6243 if (radioService[slotId]->mRadioResponse != NULL) {
6244 RadioResponseInfo responseInfo = {};
6245 populateResponseInfo(responseInfo, serial, responseType, e);
6246 Return<void> retStatus
6247 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6248 radioService[slotId]->checkReturnStatus(retStatus);
6250 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6258 int radio::setSimCardPowerResponse(int slotId,
6259 int responseType, int serial, RIL_Errno e,
6260 void *response, size_t responseLen) {
6262 RLOGD("setSimCardPowerResponse: serial %d", serial);
6265 if (radioService[slotId]->mRadioResponse != NULL) {
6266 RadioResponseInfo responseInfo = {};
6267 populateResponseInfo(responseInfo, serial, responseType, e);
6268 Return<void> retStatus
6269 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6270 radioService[slotId]->checkReturnStatus(retStatus);
6272 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6278 int radio::sendRequestRawResponse(int slotId,
6279 int responseType, int serial, RIL_Errno e,
6280 void *response, size_t responseLen) {
6282 RLOGD("sendRequestRawResponse: serial %d", serial);
6285 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6286 RadioResponseInfo responseInfo = {};
6287 populateResponseInfo(responseInfo, serial, responseType, e);
6288 hidl_vec<uint8_t> data;
6290 if (response == NULL) {
6291 RLOGE("sendRequestRawResponse: Invalid response");
6292 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6294 data.setToExternal((uint8_t *) response, responseLen);
6296 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6297 sendRequestRawResponse(responseInfo, data);
6298 checkReturnStatus(slotId, retStatus, false);
6300 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6307 int radio::sendRequestStringsResponse(int slotId,
6308 int responseType, int serial, RIL_Errno e,
6309 void *response, size_t responseLen) {
6311 RLOGD("sendRequestStringsResponse: serial %d", serial);
6314 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6315 RadioResponseInfo responseInfo = {};
6316 populateResponseInfo(responseInfo, serial, responseType, e);
6317 hidl_vec<hidl_string> data;
6319 if (response == NULL || responseLen % sizeof(char *) != 0) {
6320 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6321 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6323 char **resp = (char **) response;
6324 int numStrings = responseLen / sizeof(char *);
6325 data.resize(numStrings);
6326 for (int i = 0; i < numStrings; i++) {
6327 data[i] = convertCharPtrToHidlString(resp[i]);
6330 Return<void> retStatus
6331 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6332 responseInfo, data);
6333 checkReturnStatus(slotId, retStatus, false);
6335 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6342 // Radio Indication functions
6344 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6345 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6346 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6349 int radio::radioStateChangedInd(int slotId,
6350 int indicationType, int token, RIL_Errno e, void *response,
6351 size_t responseLen) {
6352 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6353 RadioState radioState = (RadioState) s_vendorFunctions->onStateRequest();
6354 RLOGD("radioStateChangedInd: radioState %d", radioState);
6355 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6356 convertIntToRadioIndicationType(indicationType), radioState);
6357 radioService[slotId]->checkReturnStatus(retStatus);
6359 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6365 int radio::callStateChangedInd(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) {
6370 RLOGD("callStateChangedInd");
6372 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6373 convertIntToRadioIndicationType(indicationType));
6374 radioService[slotId]->checkReturnStatus(retStatus);
6376 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6382 int radio::networkStateChangedInd(int slotId,
6383 int indicationType, int token, RIL_Errno e, void *response,
6384 size_t responseLen) {
6385 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6387 RLOGD("networkStateChangedInd");
6389 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6390 convertIntToRadioIndicationType(indicationType));
6391 radioService[slotId]->checkReturnStatus(retStatus);
6393 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6400 uint8_t hexCharToInt(uint8_t c) {
6401 if (c >= '0' && c <= '9') return (c - '0');
6402 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6403 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6405 return INVALID_HEX_CHAR;
6408 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6409 if (responseLen % 2 != 0) {
6413 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6414 if (bytes == NULL) {
6415 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6418 uint8_t *hexString = (uint8_t *)response;
6420 for (size_t i = 0; i < responseLen; i += 2) {
6421 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6422 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6424 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6425 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6426 hexString[i], hexString[i + 1]);
6430 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6436 int radio::newSmsInd(int slotId, int indicationType,
6437 int token, RIL_Errno e, void *response, size_t responseLen) {
6438 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6439 if (response == NULL || responseLen == 0) {
6440 RLOGE("newSmsInd: invalid response");
6444 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6445 if (bytes == NULL) {
6446 RLOGE("newSmsInd: convertHexStringToBytes failed");
6450 hidl_vec<uint8_t> pdu;
6451 pdu.setToExternal(bytes, responseLen/2);
6455 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6456 convertIntToRadioIndicationType(indicationType), pdu);
6457 radioService[slotId]->checkReturnStatus(retStatus);
6460 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6466 int radio::newSmsStatusReportInd(int slotId,
6467 int indicationType, int token, RIL_Errno e, void *response,
6468 size_t responseLen) {
6469 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6470 if (response == NULL || responseLen == 0) {
6471 RLOGE("newSmsStatusReportInd: invalid response");
6475 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6476 if (bytes == NULL) {
6477 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6481 hidl_vec<uint8_t> pdu;
6482 pdu.setToExternal(bytes, responseLen/2);
6484 RLOGD("newSmsStatusReportInd");
6486 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6487 convertIntToRadioIndicationType(indicationType), pdu);
6488 radioService[slotId]->checkReturnStatus(retStatus);
6491 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6497 int radio::newSmsOnSimInd(int slotId, int indicationType,
6498 int token, RIL_Errno e, void *response, size_t responseLen) {
6499 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6500 if (response == NULL || responseLen != sizeof(int)) {
6501 RLOGE("newSmsOnSimInd: invalid response");
6504 int32_t recordNumber = ((int32_t *) response)[0];
6506 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6508 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6509 convertIntToRadioIndicationType(indicationType), recordNumber);
6510 radioService[slotId]->checkReturnStatus(retStatus);
6512 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6518 int radio::onUssdInd(int slotId, int indicationType,
6519 int token, RIL_Errno e, void *response, size_t responseLen) {
6520 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6521 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6522 RLOGE("onUssdInd: invalid response");
6525 char **strings = (char **) response;
6526 char *mode = strings[0];
6527 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6528 UssdModeType modeType = (UssdModeType) atoi(mode);
6530 RLOGD("onUssdInd: mode %s", mode);
6532 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6533 convertIntToRadioIndicationType(indicationType), modeType, msg);
6534 radioService[slotId]->checkReturnStatus(retStatus);
6536 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6542 int radio::nitzTimeReceivedInd(int slotId,
6543 int indicationType, int token, RIL_Errno e, void *response,
6544 size_t responseLen) {
6545 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6546 if (response == NULL || responseLen == 0) {
6547 RLOGE("nitzTimeReceivedInd: invalid response");
6550 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6551 int64_t timeReceived = android::elapsedRealtime();
6553 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6556 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6557 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6558 radioService[slotId]->checkReturnStatus(retStatus);
6560 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6567 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6568 SignalStrength& signalStrength) {
6569 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6571 // Fixup LTE for backwards compatibility
6572 // signalStrength: -1 -> 99
6573 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6574 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6576 // rsrp: -1 -> INT_MAX all other negative value to positive.
6578 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6579 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6580 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6581 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6583 // rsrq: -1 -> INT_MAX
6584 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6585 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6587 // Not remapping rssnr is already using INT_MAX
6588 // cqi: -1 -> INT_MAX
6589 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6590 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6593 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6594 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6595 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6596 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6597 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6598 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6599 signalStrength.evdo.signalNoiseRatio =
6600 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6601 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6602 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6603 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6604 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6605 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6606 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6607 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6610 int radio::currentSignalStrengthInd(int slotId,
6611 int indicationType, int token, RIL_Errno e,
6612 void *response, size_t responseLen) {
6613 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6614 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
6615 RLOGE("currentSignalStrengthInd: invalid response");
6619 SignalStrength signalStrength = {};
6620 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6623 RLOGD("currentSignalStrengthInd");
6625 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6626 convertIntToRadioIndicationType(indicationType), signalStrength);
6627 radioService[slotId]->checkReturnStatus(retStatus);
6629 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6636 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6637 SetupDataCallResult& dcResult) {
6638 dcResult.status = (DataCallFailCause) dcResponse->status;
6639 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6640 dcResult.cid = dcResponse->cid;
6641 dcResult.active = dcResponse->active;
6642 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6643 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6644 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6645 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6646 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6647 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6648 dcResult.mtu = dcResponse->mtu;
6651 void convertRilDataCallListToHal(void *response, size_t responseLen,
6652 hidl_vec<SetupDataCallResult>& dcResultList) {
6653 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6655 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6656 dcResultList.resize(num);
6657 for (int i = 0; i < num; i++) {
6658 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6662 int radio::dataCallListChangedInd(int slotId,
6663 int indicationType, int token, RIL_Errno e, void *response,
6664 size_t responseLen) {
6665 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6666 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
6667 RLOGE("dataCallListChangedInd: invalid response");
6670 hidl_vec<SetupDataCallResult> dcList;
6671 convertRilDataCallListToHal(response, responseLen, dcList);
6673 RLOGD("dataCallListChangedInd");
6675 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
6676 convertIntToRadioIndicationType(indicationType), dcList);
6677 radioService[slotId]->checkReturnStatus(retStatus);
6679 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6685 int radio::suppSvcNotifyInd(int slotId, int indicationType,
6686 int token, RIL_Errno e, void *response, size_t responseLen) {
6687 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6688 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
6689 RLOGE("suppSvcNotifyInd: invalid response");
6693 SuppSvcNotification suppSvc = {};
6694 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6695 suppSvc.isMT = ssn->notificationType;
6696 suppSvc.code = ssn->code;
6697 suppSvc.index = ssn->index;
6698 suppSvc.type = ssn->type;
6699 suppSvc.number = convertCharPtrToHidlString(ssn->number);
6702 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
6703 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
6705 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
6706 convertIntToRadioIndicationType(indicationType), suppSvc);
6707 radioService[slotId]->checkReturnStatus(retStatus);
6709 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6715 int radio::stkSessionEndInd(int slotId, int indicationType,
6716 int token, RIL_Errno e, void *response, size_t responseLen) {
6717 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6719 RLOGD("stkSessionEndInd");
6721 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
6722 convertIntToRadioIndicationType(indicationType));
6723 radioService[slotId]->checkReturnStatus(retStatus);
6725 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
6731 int radio::stkProactiveCommandInd(int slotId,
6732 int indicationType, int token, RIL_Errno e, void *response,
6733 size_t responseLen) {
6734 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6735 if (response == NULL || responseLen == 0) {
6736 RLOGE("stkProactiveCommandInd: invalid response");
6740 RLOGD("stkProactiveCommandInd");
6742 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
6743 convertIntToRadioIndicationType(indicationType),
6744 convertCharPtrToHidlString((char *) response));
6745 radioService[slotId]->checkReturnStatus(retStatus);
6747 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
6753 int radio::stkEventNotifyInd(int slotId, int indicationType,
6754 int token, RIL_Errno e, void *response, size_t responseLen) {
6755 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6756 if (response == NULL || responseLen == 0) {
6757 RLOGE("stkEventNotifyInd: invalid response");
6761 RLOGD("stkEventNotifyInd");
6763 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
6764 convertIntToRadioIndicationType(indicationType),
6765 convertCharPtrToHidlString((char *) response));
6766 radioService[slotId]->checkReturnStatus(retStatus);
6768 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6774 int radio::stkCallSetupInd(int slotId, int indicationType,
6775 int token, RIL_Errno e, void *response, size_t responseLen) {
6776 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6777 if (response == NULL || responseLen != sizeof(int)) {
6778 RLOGE("stkCallSetupInd: invalid response");
6781 int32_t timeout = ((int32_t *) response)[0];
6783 RLOGD("stkCallSetupInd: timeout %d", timeout);
6785 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
6786 convertIntToRadioIndicationType(indicationType), timeout);
6787 radioService[slotId]->checkReturnStatus(retStatus);
6789 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
6795 int radio::simSmsStorageFullInd(int slotId,
6796 int indicationType, int token, RIL_Errno e, void *response,
6797 size_t responseLen) {
6798 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6800 RLOGD("simSmsStorageFullInd");
6802 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
6803 convertIntToRadioIndicationType(indicationType));
6804 radioService[slotId]->checkReturnStatus(retStatus);
6806 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
6812 int radio::simRefreshInd(int slotId, int indicationType,
6813 int token, RIL_Errno e, void *response, size_t responseLen) {
6814 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6815 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
6816 RLOGE("simRefreshInd: invalid response");
6820 SimRefreshResult refreshResult = {};
6821 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
6822 refreshResult.type =
6823 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
6824 refreshResult.efId = simRefreshResponse->ef_id;
6825 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
6828 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
6830 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
6831 convertIntToRadioIndicationType(indicationType), refreshResult);
6832 radioService[slotId]->checkReturnStatus(retStatus);
6834 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
6840 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
6841 CdmaSignalInfoRecord& record) {
6842 record.isPresent = signalInfoRecord->isPresent;
6843 record.signalType = signalInfoRecord->signalType;
6844 record.alertPitch = signalInfoRecord->alertPitch;
6845 record.signal = signalInfoRecord->signal;
6848 int radio::callRingInd(int slotId, int indicationType,
6849 int token, RIL_Errno e, void *response, size_t responseLen) {
6850 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6852 CdmaSignalInfoRecord record = {};
6853 if (response == NULL || responseLen == 0) {
6857 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
6858 RLOGE("callRingInd: invalid response");
6861 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
6865 RLOGD("callRingInd: isGsm %d", isGsm);
6867 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
6868 convertIntToRadioIndicationType(indicationType), isGsm, record);
6869 radioService[slotId]->checkReturnStatus(retStatus);
6871 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
6877 int radio::simStatusChangedInd(int slotId,
6878 int indicationType, int token, RIL_Errno e, void *response,
6879 size_t responseLen) {
6880 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6882 RLOGD("simStatusChangedInd");
6884 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
6885 convertIntToRadioIndicationType(indicationType));
6886 radioService[slotId]->checkReturnStatus(retStatus);
6888 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6894 int radio::cdmaNewSmsInd(int slotId, int indicationType,
6895 int token, RIL_Errno e, void *response, size_t responseLen) {
6896 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6897 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
6898 RLOGE("cdmaNewSmsInd: invalid response");
6902 CdmaSmsMessage msg = {};
6903 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
6904 msg.teleserviceId = rilMsg->uTeleserviceID;
6905 msg.isServicePresent = rilMsg->bIsServicePresent;
6906 msg.serviceCategory = rilMsg->uServicecategory;
6907 msg.address.digitMode =
6908 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
6909 msg.address.numberMode =
6910 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
6911 msg.address.numberType =
6912 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
6913 msg.address.numberPlan =
6914 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
6916 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
6917 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
6919 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
6920 rilMsg->sSubAddress.subaddressType;
6921 msg.subAddress.odd = rilMsg->sSubAddress.odd;
6923 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
6924 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
6926 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
6927 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
6930 RLOGD("cdmaNewSmsInd");
6932 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
6933 convertIntToRadioIndicationType(indicationType), msg);
6934 radioService[slotId]->checkReturnStatus(retStatus);
6936 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6942 int radio::newBroadcastSmsInd(int slotId,
6943 int indicationType, int token, RIL_Errno e, void *response,
6944 size_t responseLen) {
6945 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6946 if (response == NULL || responseLen == 0) {
6947 RLOGE("newBroadcastSmsInd: invalid response");
6951 hidl_vec<uint8_t> data;
6952 data.setToExternal((uint8_t *) response, responseLen);
6954 RLOGD("newBroadcastSmsInd");
6956 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
6957 convertIntToRadioIndicationType(indicationType), data);
6958 radioService[slotId]->checkReturnStatus(retStatus);
6960 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6966 int radio::cdmaRuimSmsStorageFullInd(int slotId,
6967 int indicationType, int token, RIL_Errno e, void *response,
6968 size_t responseLen) {
6969 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6971 RLOGD("cdmaRuimSmsStorageFullInd");
6973 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
6974 convertIntToRadioIndicationType(indicationType));
6975 radioService[slotId]->checkReturnStatus(retStatus);
6977 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
6984 int radio::restrictedStateChangedInd(int slotId,
6985 int indicationType, int token, RIL_Errno e, void *response,
6986 size_t responseLen) {
6987 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6988 if (response == NULL || responseLen != sizeof(int)) {
6989 RLOGE("restrictedStateChangedInd: invalid response");
6992 int32_t state = ((int32_t *) response)[0];
6994 RLOGD("restrictedStateChangedInd: state %d", state);
6996 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
6997 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
6998 radioService[slotId]->checkReturnStatus(retStatus);
7000 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7007 int radio::enterEmergencyCallbackModeInd(int slotId,
7008 int indicationType, int token, RIL_Errno e, void *response,
7009 size_t responseLen) {
7010 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7012 RLOGD("enterEmergencyCallbackModeInd");
7014 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7015 convertIntToRadioIndicationType(indicationType));
7016 radioService[slotId]->checkReturnStatus(retStatus);
7018 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7025 int radio::cdmaCallWaitingInd(int slotId,
7026 int indicationType, int token, RIL_Errno e, void *response,
7027 size_t responseLen) {
7028 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7029 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7030 RLOGE("cdmaCallWaitingInd: invalid response");
7034 CdmaCallWaiting callWaitingRecord = {};
7035 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7036 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7037 callWaitingRecord.numberPresentation =
7038 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7039 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7040 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7041 callWaitingRecord.signalInfoRecord);
7042 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7043 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7046 RLOGD("cdmaCallWaitingInd");
7048 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7049 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7050 radioService[slotId]->checkReturnStatus(retStatus);
7052 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7058 int radio::cdmaOtaProvisionStatusInd(int slotId,
7059 int indicationType, int token, RIL_Errno e, void *response,
7060 size_t responseLen) {
7061 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7062 if (response == NULL || responseLen != sizeof(int)) {
7063 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7066 int32_t status = ((int32_t *) response)[0];
7068 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7070 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7071 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7072 radioService[slotId]->checkReturnStatus(retStatus);
7074 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7081 int radio::cdmaInfoRecInd(int slotId,
7082 int indicationType, int token, RIL_Errno e, void *response,
7083 size_t responseLen) {
7084 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7085 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7086 RLOGE("cdmaInfoRecInd: invalid response");
7090 CdmaInformationRecords records = {};
7091 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7093 char* string8 = NULL;
7094 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7095 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7096 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7097 "additional ones", recordsRil->numberOfInfoRecs,
7098 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7100 records.infoRec.resize(num);
7101 for (int i = 0 ; i < num ; i++) {
7102 CdmaInformationRecord *record = &records.infoRec[i];
7103 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7104 record->name = (CdmaInfoRecName) infoRec->name;
7105 // All vectors should be size 0 except one which will be size 1. Set everything to
7106 // size 0 initially.
7107 record->display.resize(0);
7108 record->number.resize(0);
7109 record->signal.resize(0);
7110 record->redir.resize(0);
7111 record->lineCtrl.resize(0);
7112 record->clir.resize(0);
7113 record->audioCtrl.resize(0);
7114 switch (infoRec->name) {
7115 case RIL_CDMA_DISPLAY_INFO_REC:
7116 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7117 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7118 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7119 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7120 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7123 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7124 if (string8 == NULL) {
7125 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7126 "responseCdmaInformationRecords");
7129 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7130 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7132 record->display.resize(1);
7133 record->display[0].alphaBuf = string8;
7139 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7140 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7141 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7142 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7143 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7144 "expected not more than %d", (int) infoRec->rec.number.len,
7145 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7148 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7149 if (string8 == NULL) {
7150 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7151 "responseCdmaInformationRecords");
7154 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7155 string8[(int)infoRec->rec.number.len] = '\0';
7157 record->number.resize(1);
7158 record->number[0].number = string8;
7161 record->number[0].numberType = infoRec->rec.number.number_type;
7162 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7163 record->number[0].pi = infoRec->rec.number.pi;
7164 record->number[0].si = infoRec->rec.number.si;
7168 case RIL_CDMA_SIGNAL_INFO_REC: {
7169 record->signal.resize(1);
7170 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7171 record->signal[0].signalType = infoRec->rec.signal.signalType;
7172 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7173 record->signal[0].signal = infoRec->rec.signal.signal;
7177 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7178 if (infoRec->rec.redir.redirectingNumber.len >
7179 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7180 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7181 "expected not more than %d\n",
7182 (int)infoRec->rec.redir.redirectingNumber.len,
7183 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7186 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7188 if (string8 == NULL) {
7189 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7190 "responseCdmaInformationRecords");
7193 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7194 infoRec->rec.redir.redirectingNumber.len);
7195 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7197 record->redir.resize(1);
7198 record->redir[0].redirectingNumber.number = string8;
7201 record->redir[0].redirectingNumber.numberType =
7202 infoRec->rec.redir.redirectingNumber.number_type;
7203 record->redir[0].redirectingNumber.numberPlan =
7204 infoRec->rec.redir.redirectingNumber.number_plan;
7205 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7206 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7207 record->redir[0].redirectingReason =
7208 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7212 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7213 record->lineCtrl.resize(1);
7214 record->lineCtrl[0].lineCtrlPolarityIncluded =
7215 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7216 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7217 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7218 record->lineCtrl[0].lineCtrlPowerDenial =
7219 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7223 case RIL_CDMA_T53_CLIR_INFO_REC: {
7224 record->clir.resize(1);
7225 record->clir[0].cause = infoRec->rec.clir.cause;
7229 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7230 record->audioCtrl.resize(1);
7231 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7232 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7236 case RIL_CDMA_T53_RELEASE_INFO_REC:
7237 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7241 RLOGE("cdmaInfoRecInd: Incorrect name value");
7247 RLOGD("cdmaInfoRecInd");
7249 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7250 convertIntToRadioIndicationType(indicationType), records);
7251 radioService[slotId]->checkReturnStatus(retStatus);
7253 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7259 int radio::indicateRingbackToneInd(int slotId,
7260 int indicationType, int token, RIL_Errno e, void *response,
7261 size_t responseLen) {
7262 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7263 if (response == NULL || responseLen != sizeof(int)) {
7264 RLOGE("indicateRingbackToneInd: invalid response");
7267 bool start = ((int32_t *) response)[0];
7269 RLOGD("indicateRingbackToneInd: start %d", start);
7271 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7272 convertIntToRadioIndicationType(indicationType), start);
7273 radioService[slotId]->checkReturnStatus(retStatus);
7275 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7281 int radio::resendIncallMuteInd(int slotId,
7282 int indicationType, int token, RIL_Errno e, void *response,
7283 size_t responseLen) {
7284 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7286 RLOGD("resendIncallMuteInd");
7288 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7289 convertIntToRadioIndicationType(indicationType));
7290 radioService[slotId]->checkReturnStatus(retStatus);
7292 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7298 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7299 int indicationType, int token, RIL_Errno e,
7300 void *response, size_t responseLen) {
7301 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7302 if (response == NULL || responseLen != sizeof(int)) {
7303 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7306 int32_t cdmaSource = ((int32_t *) response)[0];
7308 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7310 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7311 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7312 (CdmaSubscriptionSource) cdmaSource);
7313 radioService[slotId]->checkReturnStatus(retStatus);
7315 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7322 int radio::cdmaPrlChangedInd(int slotId,
7323 int indicationType, int token, RIL_Errno e, void *response,
7324 size_t responseLen) {
7325 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7326 if (response == NULL || responseLen != sizeof(int)) {
7327 RLOGE("cdmaPrlChangedInd: invalid response");
7330 int32_t version = ((int32_t *) response)[0];
7332 RLOGD("cdmaPrlChangedInd: version %d", version);
7334 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7335 convertIntToRadioIndicationType(indicationType), version);
7336 radioService[slotId]->checkReturnStatus(retStatus);
7338 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7344 int radio::exitEmergencyCallbackModeInd(int slotId,
7345 int indicationType, int token, RIL_Errno e, void *response,
7346 size_t responseLen) {
7347 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7349 RLOGD("exitEmergencyCallbackModeInd");
7351 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7352 convertIntToRadioIndicationType(indicationType));
7353 radioService[slotId]->checkReturnStatus(retStatus);
7355 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7362 int radio::rilConnectedInd(int slotId,
7363 int indicationType, int token, RIL_Errno e, void *response,
7364 size_t responseLen) {
7365 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7366 RLOGD("rilConnectedInd");
7367 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7368 convertIntToRadioIndicationType(indicationType));
7369 radioService[slotId]->checkReturnStatus(retStatus);
7371 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7377 int radio::voiceRadioTechChangedInd(int slotId,
7378 int indicationType, int token, RIL_Errno e, void *response,
7379 size_t responseLen) {
7380 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7381 if (response == NULL || responseLen != sizeof(int)) {
7382 RLOGE("voiceRadioTechChangedInd: invalid response");
7385 int32_t rat = ((int32_t *) response)[0];
7387 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7389 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7390 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7391 radioService[slotId]->checkReturnStatus(retStatus);
7393 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7400 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7401 int num = responseLen / sizeof(RIL_CellInfo_v12);
7402 records.resize(num);
7404 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7405 for (int i = 0; i < num; i++) {
7406 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7407 records[i].registered = rillCellInfo->registered;
7408 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7409 records[i].timeStamp = rillCellInfo->timeStamp;
7410 // All vectors should be size 0 except one which will be size 1. Set everything to
7411 // size 0 initially.
7412 records[i].gsm.resize(0);
7413 records[i].wcdma.resize(0);
7414 records[i].cdma.resize(0);
7415 records[i].lte.resize(0);
7416 records[i].tdscdma.resize(0);
7417 switch(rillCellInfo->cellInfoType) {
7418 case RIL_CELL_INFO_TYPE_GSM: {
7419 records[i].gsm.resize(1);
7420 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7421 cellInfoGsm->cellIdentityGsm.mcc =
7422 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7423 cellInfoGsm->cellIdentityGsm.mnc =
7424 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7425 cellInfoGsm->cellIdentityGsm.lac =
7426 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7427 cellInfoGsm->cellIdentityGsm.cid =
7428 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7429 cellInfoGsm->cellIdentityGsm.arfcn =
7430 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7431 cellInfoGsm->cellIdentityGsm.bsic =
7432 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7433 cellInfoGsm->signalStrengthGsm.signalStrength =
7434 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7435 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7436 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7437 cellInfoGsm->signalStrengthGsm.timingAdvance =
7438 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7442 case RIL_CELL_INFO_TYPE_WCDMA: {
7443 records[i].wcdma.resize(1);
7444 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7445 cellInfoWcdma->cellIdentityWcdma.mcc =
7446 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7447 cellInfoWcdma->cellIdentityWcdma.mnc =
7448 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7449 cellInfoWcdma->cellIdentityWcdma.lac =
7450 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7451 cellInfoWcdma->cellIdentityWcdma.cid =
7452 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7453 cellInfoWcdma->cellIdentityWcdma.psc =
7454 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7455 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7456 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7457 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7458 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7459 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7460 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7464 case RIL_CELL_INFO_TYPE_CDMA: {
7465 records[i].cdma.resize(1);
7466 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7467 cellInfoCdma->cellIdentityCdma.networkId =
7468 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7469 cellInfoCdma->cellIdentityCdma.systemId =
7470 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7471 cellInfoCdma->cellIdentityCdma.baseStationId =
7472 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7473 cellInfoCdma->cellIdentityCdma.longitude =
7474 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7475 cellInfoCdma->cellIdentityCdma.latitude =
7476 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7477 cellInfoCdma->signalStrengthCdma.dbm =
7478 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7479 cellInfoCdma->signalStrengthCdma.ecio =
7480 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7481 cellInfoCdma->signalStrengthEvdo.dbm =
7482 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7483 cellInfoCdma->signalStrengthEvdo.ecio =
7484 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7485 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7486 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7490 case RIL_CELL_INFO_TYPE_LTE: {
7491 records[i].lte.resize(1);
7492 CellInfoLte *cellInfoLte = &records[i].lte[0];
7493 cellInfoLte->cellIdentityLte.mcc =
7494 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7495 cellInfoLte->cellIdentityLte.mnc =
7496 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7497 cellInfoLte->cellIdentityLte.ci =
7498 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7499 cellInfoLte->cellIdentityLte.pci =
7500 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7501 cellInfoLte->cellIdentityLte.tac =
7502 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7503 cellInfoLte->cellIdentityLte.earfcn =
7504 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7505 cellInfoLte->signalStrengthLte.signalStrength =
7506 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7507 cellInfoLte->signalStrengthLte.rsrp =
7508 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7509 cellInfoLte->signalStrengthLte.rsrq =
7510 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7511 cellInfoLte->signalStrengthLte.rssnr =
7512 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7513 cellInfoLte->signalStrengthLte.cqi =
7514 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7515 cellInfoLte->signalStrengthLte.timingAdvance =
7516 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7520 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7521 records[i].tdscdma.resize(1);
7522 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7523 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7524 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7525 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7526 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7527 cellInfoTdscdma->cellIdentityTdscdma.lac =
7528 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7529 cellInfoTdscdma->cellIdentityTdscdma.cid =
7530 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7531 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7532 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7533 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7534 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7545 int radio::cellInfoListInd(int slotId,
7546 int indicationType, int token, RIL_Errno e, void *response,
7547 size_t responseLen) {
7548 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7549 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7550 RLOGE("cellInfoListInd: invalid response");
7554 hidl_vec<CellInfo> records;
7555 convertRilCellInfoListToHal(response, responseLen, records);
7558 RLOGD("cellInfoListInd");
7560 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7561 convertIntToRadioIndicationType(indicationType), records);
7562 radioService[slotId]->checkReturnStatus(retStatus);
7564 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7570 int radio::imsNetworkStateChangedInd(int slotId,
7571 int indicationType, int token, RIL_Errno e, void *response,
7572 size_t responseLen) {
7573 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7575 RLOGD("imsNetworkStateChangedInd");
7577 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7578 convertIntToRadioIndicationType(indicationType));
7579 radioService[slotId]->checkReturnStatus(retStatus);
7581 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7588 int radio::subscriptionStatusChangedInd(int slotId,
7589 int indicationType, int token, RIL_Errno e, void *response,
7590 size_t responseLen) {
7591 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7592 if (response == NULL || responseLen != sizeof(int)) {
7593 RLOGE("subscriptionStatusChangedInd: invalid response");
7596 bool activate = ((int32_t *) response)[0];
7598 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7600 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
7601 convertIntToRadioIndicationType(indicationType), activate);
7602 radioService[slotId]->checkReturnStatus(retStatus);
7604 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
7611 int radio::srvccStateNotifyInd(int slotId,
7612 int indicationType, int token, RIL_Errno e, void *response,
7613 size_t responseLen) {
7614 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7615 if (response == NULL || responseLen != sizeof(int)) {
7616 RLOGE("srvccStateNotifyInd: invalid response");
7619 int32_t state = ((int32_t *) response)[0];
7621 RLOGD("srvccStateNotifyInd: rat %d", state);
7623 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
7624 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
7625 radioService[slotId]->checkReturnStatus(retStatus);
7627 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7633 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7634 hidl_vec<HardwareConfig>& records) {
7635 int num = responseLen / sizeof(RIL_HardwareConfig);
7636 records.resize(num);
7638 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7639 for (int i = 0; i < num; i++) {
7640 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7641 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7642 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7643 switch (rilHardwareConfig[i].type) {
7644 case RIL_HARDWARE_CONFIG_MODEM: {
7645 records[i].modem.resize(1);
7646 records[i].sim.resize(0);
7647 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7648 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7649 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7650 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7651 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7655 case RIL_HARDWARE_CONFIG_SIM: {
7656 records[i].sim.resize(1);
7657 records[i].modem.resize(0);
7658 records[i].sim[0].modemUuid =
7659 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7666 int radio::hardwareConfigChangedInd(int slotId,
7667 int indicationType, int token, RIL_Errno e, void *response,
7668 size_t responseLen) {
7669 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7670 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7671 RLOGE("hardwareConfigChangedInd: invalid response");
7675 hidl_vec<HardwareConfig> configs;
7676 convertRilHardwareConfigListToHal(response, responseLen, configs);
7679 RLOGD("hardwareConfigChangedInd");
7681 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
7682 convertIntToRadioIndicationType(indicationType), configs);
7683 radioService[slotId]->checkReturnStatus(retStatus);
7685 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
7692 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7693 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7694 rc.session = rilRadioCapability->session;
7695 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7696 rc.raf = rilRadioCapability->rat;
7697 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7698 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
7701 int radio::radioCapabilityIndicationInd(int slotId,
7702 int indicationType, int token, RIL_Errno e, void *response,
7703 size_t responseLen) {
7704 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7705 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
7706 RLOGE("radioCapabilityIndicationInd: invalid response");
7710 RadioCapability rc = {};
7711 convertRilRadioCapabilityToHal(response, responseLen, rc);
7714 RLOGD("radioCapabilityIndicationInd");
7716 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
7717 convertIntToRadioIndicationType(indicationType), rc);
7718 radioService[slotId]->checkReturnStatus(retStatus);
7720 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
7727 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
7728 if ((reqType == SS_INTERROGATION) &&
7729 (serType == SS_CFU ||
7730 serType == SS_CF_BUSY ||
7731 serType == SS_CF_NO_REPLY ||
7732 serType == SS_CF_NOT_REACHABLE ||
7733 serType == SS_CF_ALL ||
7734 serType == SS_CF_ALL_CONDITIONAL)) {
7740 int radio::onSupplementaryServiceIndicationInd(int slotId,
7741 int indicationType, int token, RIL_Errno e,
7742 void *response, size_t responseLen) {
7743 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7744 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
7745 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
7749 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
7750 StkCcUnsolSsResult ss = {};
7751 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
7752 ss.requestType = (SsRequestType) rilSsResponse->requestType;
7753 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
7754 ss.serviceClass = rilSsResponse->serviceClass;
7755 ss.result = (RadioError) rilSsResponse->result;
7757 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
7759 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
7760 rilSsResponse->cfData.numValidIndexes);
7762 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
7763 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
7764 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
7765 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
7768 ss.cfData.resize(1);
7769 ss.ssInfo.resize(0);
7771 /* number of call info's */
7772 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
7774 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
7775 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
7776 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
7778 cfInfo->status = (CallForwardInfoStatus) cf.status;
7779 cfInfo->reason = cf.reason;
7780 cfInfo->serviceClass = cf.serviceClass;
7781 cfInfo->toa = cf.toa;
7782 cfInfo->number = convertCharPtrToHidlString(cf.number);
7783 cfInfo->timeSeconds = cf.timeSeconds;
7785 RLOGD("onSupplementaryServiceIndicationInd: "
7786 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
7787 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
7791 ss.ssInfo.resize(1);
7792 ss.cfData.resize(0);
7795 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
7796 for (int i = 0; i < SS_INFO_MAX; i++) {
7798 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
7799 rilSsResponse->ssInfo[i]);
7801 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
7806 RLOGD("onSupplementaryServiceIndicationInd");
7808 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7809 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
7811 radioService[slotId]->checkReturnStatus(retStatus);
7813 RLOGE("onSupplementaryServiceIndicationInd: "
7814 "radioService[%d]->mRadioIndication == NULL", slotId);
7820 int radio::stkCallControlAlphaNotifyInd(int slotId,
7821 int indicationType, int token, RIL_Errno e, void *response,
7822 size_t responseLen) {
7823 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7824 if (response == NULL || responseLen == 0) {
7825 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
7829 RLOGD("stkCallControlAlphaNotifyInd");
7831 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
7832 convertIntToRadioIndicationType(indicationType),
7833 convertCharPtrToHidlString((char *) response));
7834 radioService[slotId]->checkReturnStatus(retStatus);
7836 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
7843 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
7844 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
7845 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
7846 lce.confidenceLevel = rilLceDataInfo->confidence_level;
7847 lce.lceSuspended = rilLceDataInfo->lce_suspended;
7850 int radio::lceDataInd(int slotId,
7851 int indicationType, int token, RIL_Errno e, void *response,
7852 size_t responseLen) {
7853 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7854 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
7855 RLOGE("lceDataInd: invalid response");
7859 LceDataInfo lce = {};
7860 convertRilLceDataInfoToHal(response, responseLen, lce);
7862 RLOGD("lceDataInd");
7864 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
7865 convertIntToRadioIndicationType(indicationType), lce);
7866 radioService[slotId]->checkReturnStatus(retStatus);
7868 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7874 int radio::pcoDataInd(int slotId,
7875 int indicationType, int token, RIL_Errno e, void *response,
7876 size_t responseLen) {
7877 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7878 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
7879 RLOGE("pcoDataInd: invalid response");
7883 PcoDataInfo pco = {};
7884 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
7885 pco.cid = rilPcoData->cid;
7886 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
7887 pco.pcoId = rilPcoData->pco_id;
7888 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
7891 RLOGD("pcoDataInd");
7893 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
7894 convertIntToRadioIndicationType(indicationType), pco);
7895 radioService[slotId]->checkReturnStatus(retStatus);
7897 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7903 int radio::modemResetInd(int slotId,
7904 int indicationType, int token, RIL_Errno e, void *response,
7905 size_t responseLen) {
7906 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7907 if (response == NULL || responseLen == 0) {
7908 RLOGE("modemResetInd: invalid response");
7912 RLOGD("modemResetInd");
7914 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
7915 convertIntToRadioIndicationType(indicationType),
7916 convertCharPtrToHidlString((char *) response));
7917 radioService[slotId]->checkReturnStatus(retStatus);
7919 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
7925 int radio::oemHookRawInd(int slotId,
7926 int indicationType, int token, RIL_Errno e, void *response,
7927 size_t responseLen) {
7928 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
7929 if (response == NULL || responseLen == 0) {
7930 RLOGE("oemHookRawInd: invalid response");
7934 hidl_vec<uint8_t> data;
7935 data.setToExternal((uint8_t *) response, responseLen);
7937 RLOGD("oemHookRawInd");
7939 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
7940 convertIntToRadioIndicationType(indicationType), data);
7941 checkReturnStatus(slotId, retStatus, false);
7943 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
7949 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
7950 using namespace android::hardware;
7952 const char *serviceNames[] = {
7953 android::RIL_getServiceName()
7954 #if (SIM_COUNT >= 2)
7956 #if (SIM_COUNT >= 3)
7958 #if (SIM_COUNT >= 4)
7965 #if (SIM_COUNT >= 2)
7966 simCount = SIM_COUNT;
7969 configureRpcThreadpool(1, true /* callerWillJoin */);
7970 for (int i = 0; i < simCount; i++) {
7971 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
7972 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
7975 radioService[i] = new RadioImpl;
7976 radioService[i]->mSlotId = i;
7977 oemHookService[i] = new OemHookImpl;
7978 oemHookService[i]->mSlotId = i;
7979 RLOGD("registerService: starting IRadio %s", serviceNames[i]);
7980 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
7981 status = oemHookService[i]->registerAsService(serviceNames[i]);
7983 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
7987 s_vendorFunctions = callbacks;
7988 s_commands = commands;
7991 void rilc_thread_pool() {
7992 joinRpcThreadpool();
7995 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
7996 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
7998 #if (SIM_COUNT >= 2)
7999 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8000 #if (SIM_COUNT >= 3)
8001 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8002 #if (SIM_COUNT >= 4)
8003 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8008 return radioServiceRwlockPtr;