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);
683 memset (&apdu, 0, sizeof(RIL_SIM_APDU));
685 apdu.sessionid = message.sessionId;
686 apdu.cla = message.cla;
687 apdu.instruction = message.instruction;
688 apdu.p1 = message.p1;
689 apdu.p2 = message.p2;
690 apdu.p3 = message.p3;
692 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
696 s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI);
698 memsetAndFreeStrings(1, apdu.data);
703 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
704 if (ret.isOk() == false) {
705 RLOGE("checkReturnStatus: unable to call response/indication callback");
706 // Remote process hosting the callbacks must be dead. Reset the callback objects;
707 // there's no other recovery to be done here. When the client process is back up, it will
708 // call setResponseFunctions()
710 // Caller should already hold rdlock, release that first
711 // note the current counter to avoid overwriting updates made by another thread before
712 // write lock is acquired.
713 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
714 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
715 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
719 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
722 // make sure the counter value has not changed
723 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
724 if (isRadioService) {
725 radioService[slotId]->mRadioResponse = NULL;
726 radioService[slotId]->mRadioIndication = NULL;
728 oemHookService[slotId]->mOemHookResponse = NULL;
729 oemHookService[slotId]->mOemHookIndication = NULL;
731 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
733 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
734 "got updated on another thread");
738 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
742 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
747 void RadioImpl::checkReturnStatus(Return<void>& ret) {
748 ::checkReturnStatus(mSlotId, ret, true);
751 Return<void> RadioImpl::setResponseFunctions(
752 const ::android::sp<IRadioResponse>& radioResponseParam,
753 const ::android::sp<IRadioIndication>& radioIndicationParam) {
754 RLOGD("setResponseFunctions");
756 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
757 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
760 mRadioResponse = radioResponseParam;
761 mRadioIndication = radioIndicationParam;
762 mCounterRadio[mSlotId]++;
764 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
767 // client is connected. Send initial indications.
768 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
773 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
775 RLOGD("getIccCardStatus: serial %d", serial);
777 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
781 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
782 const hidl_string& aid) {
784 RLOGD("supplyIccPinForApp: serial %d", serial);
786 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
787 2, pin.c_str(), aid.c_str());
791 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
792 const hidl_string& pin, const hidl_string& aid) {
794 RLOGD("supplyIccPukForApp: serial %d", serial);
796 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
797 3, puk.c_str(), pin.c_str(), aid.c_str());
801 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
802 const hidl_string& aid) {
804 RLOGD("supplyIccPin2ForApp: serial %d", serial);
806 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
807 2, pin2.c_str(), aid.c_str());
811 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
812 const hidl_string& pin2, const hidl_string& aid) {
814 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
816 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
817 3, puk2.c_str(), pin2.c_str(), aid.c_str());
821 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
822 const hidl_string& newPin, const hidl_string& aid) {
824 RLOGD("changeIccPinForApp: serial %d", serial);
826 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
827 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
831 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
832 const hidl_string& newPin2, const hidl_string& aid) {
834 RLOGD("changeIccPin2ForApp: serial %d", serial);
836 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
837 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
841 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
842 const hidl_string& netPin) {
844 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
846 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
851 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
853 RLOGD("getCurrentCalls: serial %d", serial);
855 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
859 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
861 RLOGD("dial: serial %d", serial);
863 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
868 RIL_UUS_Info uusInfo = {};
869 int32_t sizeOfDial = sizeof(dial);
871 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
874 dial.clir = (int) dialInfo.clir;
876 if (dialInfo.uusInfo.size() != 0) {
877 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
878 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
880 if (dialInfo.uusInfo[0].uusData.size() == 0) {
881 uusInfo.uusData = NULL;
882 uusInfo.uusLength = 0;
884 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
885 memsetAndFreeStrings(1, dial.address);
888 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
891 dial.uusInfo = &uusInfo;
894 s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI);
896 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
901 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
903 RLOGD("getImsiForApp: serial %d", serial);
905 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
910 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
912 RLOGD("hangup: serial %d", serial);
914 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
918 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
920 RLOGD("hangupWaitingOrBackground: serial %d", serial);
922 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
926 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
928 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
930 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
934 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
936 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
938 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
942 Return<void> RadioImpl::conference(int32_t serial) {
944 RLOGD("conference: serial %d", serial);
946 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
950 Return<void> RadioImpl::rejectCall(int32_t serial) {
952 RLOGD("rejectCall: serial %d", serial);
954 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
958 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
960 RLOGD("getLastCallFailCause: serial %d", serial);
962 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
966 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
968 RLOGD("getSignalStrength: serial %d", serial);
970 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
974 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
976 RLOGD("getVoiceRegistrationState: serial %d", serial);
978 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
982 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
984 RLOGD("getDataRegistrationState: serial %d", serial);
986 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
990 Return<void> RadioImpl::getOperator(int32_t serial) {
992 RLOGD("getOperator: serial %d", serial);
994 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
998 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
999 RLOGD("setRadioPower: serial %d on %d", serial, on);
1000 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1004 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1006 RLOGD("sendDtmf: serial %d", serial);
1008 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1012 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1014 RLOGD("sendSms: serial %d", serial);
1016 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
1017 2, message.smscPdu.c_str(), message.pdu.c_str());
1021 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1023 RLOGD("sendSMSExpectMore: serial %d", serial);
1025 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
1026 2, message.smscPdu.c_str(), message.pdu.c_str());
1030 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1032 case MvnoType::IMSI:
1033 str = (char *)"imsi";
1036 str = (char *)"gid";
1039 str = (char *)"spn";
1041 case MvnoType::NONE:
1048 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1049 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1050 bool roamingAllowed, bool isRoaming) {
1053 RLOGD("setupDataCall: serial %d", serial);
1056 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1057 const hidl_string &protocol =
1058 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1059 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
1060 std::to_string((int) radioTechnology + 2).c_str(),
1061 std::to_string((int) dataProfileInfo.profileId).c_str(),
1062 dataProfileInfo.apn.c_str(),
1063 dataProfileInfo.user.c_str(),
1064 dataProfileInfo.password.c_str(),
1065 std::to_string((int) dataProfileInfo.authType).c_str(),
1067 } else if (s_vendorFunctions->version >= 15) {
1068 char *mvnoTypeStr = NULL;
1069 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1070 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1071 RIL_REQUEST_SETUP_DATA_CALL);
1073 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1077 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1078 std::to_string((int) radioTechnology + 2).c_str(),
1079 std::to_string((int) dataProfileInfo.profileId).c_str(),
1080 dataProfileInfo.apn.c_str(),
1081 dataProfileInfo.user.c_str(),
1082 dataProfileInfo.password.c_str(),
1083 std::to_string((int) dataProfileInfo.authType).c_str(),
1084 dataProfileInfo.protocol.c_str(),
1085 dataProfileInfo.roamingProtocol.c_str(),
1086 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1087 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1088 modemCognitive ? "1" : "0",
1089 std::to_string(dataProfileInfo.mtu).c_str(),
1091 dataProfileInfo.mvnoMatchData.c_str(),
1092 roamingAllowed ? "1" : "0");
1094 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1095 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1096 RIL_REQUEST_SETUP_DATA_CALL);
1098 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1104 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1106 RLOGD("iccIOForApp: serial %d", serial);
1108 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1113 RIL_SIM_IO_v6 rilIccIo;
1114 rilIccIo.command = iccIo.command;
1115 rilIccIo.fileid = iccIo.fileId;
1116 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1120 rilIccIo.p1 = iccIo.p1;
1121 rilIccIo.p2 = iccIo.p2;
1122 rilIccIo.p3 = iccIo.p3;
1124 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1125 memsetAndFreeStrings(1, rilIccIo.path);
1129 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1130 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1134 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1135 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1139 s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI);
1141 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1146 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1148 RLOGD("sendUssd: serial %d", serial);
1150 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1154 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1156 RLOGD("cancelPendingUssd: serial %d", serial);
1158 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1162 Return<void> RadioImpl::getClir(int32_t serial) {
1164 RLOGD("getClir: serial %d", serial);
1166 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1170 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1172 RLOGD("setClir: serial %d", serial);
1174 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1178 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1180 RLOGD("getCallForwardStatus: serial %d", serial);
1182 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1187 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1189 RLOGD("setCallForward: serial %d", serial);
1191 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1196 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1198 RLOGD("getCallWaiting: serial %d", serial);
1200 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1204 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1206 RLOGD("setCallWaiting: serial %d", serial);
1208 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1213 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1214 bool success, SmsAcknowledgeFailCause cause) {
1216 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1218 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1223 Return<void> RadioImpl::acceptCall(int32_t serial) {
1225 RLOGD("acceptCall: serial %d", serial);
1227 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1231 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1232 int32_t cid, bool reasonRadioShutDown) {
1234 RLOGD("deactivateDataCall: serial %d", serial);
1236 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1237 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1241 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1242 const hidl_string& password, int32_t serviceClass,
1243 const hidl_string& appId) {
1245 RLOGD("getFacilityLockForApp: serial %d", serial);
1247 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1248 4, facility.c_str(), password.c_str(),
1249 (std::to_string(serviceClass)).c_str(), appId.c_str());
1253 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1254 bool lockState, const hidl_string& password,
1255 int32_t serviceClass, const hidl_string& appId) {
1257 RLOGD("setFacilityLockForApp: serial %d", serial);
1259 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1260 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1261 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1265 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1266 const hidl_string& oldPassword,
1267 const hidl_string& newPassword) {
1269 RLOGD("setBarringPassword: serial %d", serial);
1271 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1272 2, oldPassword.c_str(), newPassword.c_str());
1276 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1278 RLOGD("getNetworkSelectionMode: serial %d", serial);
1280 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1284 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1286 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1288 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1292 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1293 const hidl_string& operatorNumeric) {
1295 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1297 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1298 operatorNumeric.c_str());
1302 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1304 RLOGD("getAvailableNetworks: serial %d", serial);
1306 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1310 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1312 RLOGD("startDtmf: serial %d", serial);
1314 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1319 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1321 RLOGD("stopDtmf: serial %d", serial);
1323 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1327 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1329 RLOGD("getBasebandVersion: serial %d", serial);
1331 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1335 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1337 RLOGD("separateConnection: serial %d", serial);
1339 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1343 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1345 RLOGD("setMute: serial %d", serial);
1347 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1351 Return<void> RadioImpl::getMute(int32_t serial) {
1353 RLOGD("getMute: serial %d", serial);
1355 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1359 Return<void> RadioImpl::getClip(int32_t serial) {
1361 RLOGD("getClip: serial %d", serial);
1363 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1367 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1369 RLOGD("getDataCallList: serial %d", serial);
1371 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1375 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1377 RLOGD("setSuppServiceNotifications: serial %d", serial);
1379 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1380 BOOL_TO_INT(enable));
1384 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1386 RLOGD("writeSmsToSim: serial %d", serial);
1388 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1393 RIL_SMS_WriteArgs args;
1394 args.status = (int) smsWriteArgs.status;
1397 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1401 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1402 memsetAndFreeStrings(1, args.pdu);
1406 s_vendorFunctions->onRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI);
1408 memsetAndFreeStrings(2, args.smsc, args.pdu);
1413 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1415 RLOGD("deleteSmsOnSim: serial %d", serial);
1417 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1421 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1423 RLOGD("setBandMode: serial %d", serial);
1425 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1429 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1431 RLOGD("getAvailableBandModes: serial %d", serial);
1433 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1437 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1439 RLOGD("sendEnvelope: serial %d", serial);
1441 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1446 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1447 const hidl_string& commandResponse) {
1449 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1451 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1452 commandResponse.c_str());
1456 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1458 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1460 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1461 1, BOOL_TO_INT(accept));
1465 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1467 RLOGD("explicitCallTransfer: serial %d", serial);
1469 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1473 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1475 RLOGD("setPreferredNetworkType: serial %d", serial);
1477 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1481 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1483 RLOGD("getPreferredNetworkType: serial %d", serial);
1485 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1489 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1491 RLOGD("getNeighboringCids: serial %d", serial);
1493 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1497 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1499 RLOGD("setLocationUpdates: serial %d", serial);
1501 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1505 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1507 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1509 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1513 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1515 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1517 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1521 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1523 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1525 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1529 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1531 RLOGD("setTTYMode: serial %d", serial);
1533 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1537 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1539 RLOGD("getTTYMode: serial %d", serial);
1541 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1545 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1547 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1549 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1550 1, BOOL_TO_INT(enable));
1554 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1556 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1558 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1562 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1564 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1566 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1567 featureCode.c_str());
1571 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1574 RLOGD("sendBurstDtmf: serial %d", serial);
1576 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1577 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1578 (std::to_string(off)).c_str());
1582 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1583 memset(&rcsm, 0, sizeof(rcsm));
1585 rcsm.uTeleserviceID = sms.teleserviceId;
1586 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1587 rcsm.uServicecategory = sms.serviceCategory;
1588 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1589 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1590 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1591 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1593 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1594 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1595 for (int i = 0; i < digitLimit; i++) {
1596 rcsm.sAddress.digits[i] = sms.address.digits[i];
1599 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1600 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1602 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1603 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1604 for (int i = 0; i < digitLimit; i++) {
1605 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1608 rcsm.uBearerDataLen = sms.bearerData.size();
1609 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1610 for (int i = 0; i < digitLimit; i++) {
1611 rcsm.aBearerData[i] = sms.bearerData[i];
1615 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1617 RLOGD("sendCdmaSms: serial %d", serial);
1619 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1624 RIL_CDMA_SMS_Message rcsm;
1625 constructCdmaSms(rcsm, sms);
1627 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI);
1631 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1633 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1635 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1640 RIL_CDMA_SMS_Ack rcsa = {};
1642 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1643 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1645 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI);
1649 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1651 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1653 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1657 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1658 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1661 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1663 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1664 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1669 int num = configInfo.size();
1670 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1671 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1673 for (int i = 0 ; i < num ; i++ ) {
1674 gsmBciPtrs[i] = &gsmBci[i];
1675 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1676 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1677 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1678 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1679 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1682 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, gsmBciPtrs,
1683 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI);
1687 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1689 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1691 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1692 1, BOOL_TO_INT(!activate));
1696 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1698 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1700 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1704 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1705 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1708 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1710 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1711 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1716 int num = configInfo.size();
1717 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1718 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1720 for (int i = 0 ; i < num ; i++ ) {
1721 cdmaBciPtrs[i] = &cdmaBci[i];
1722 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1723 cdmaBci[i].language = configInfo[i].language;
1724 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1727 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, cdmaBciPtrs,
1728 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI);
1732 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1734 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1736 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1737 1, BOOL_TO_INT(!activate));
1741 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1743 RLOGD("getCDMASubscription: serial %d", serial);
1745 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1749 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1751 RLOGD("writeSmsToRuim: serial %d", serial);
1753 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1754 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1759 RIL_CDMA_SMS_WriteArgs rcsw = {};
1760 rcsw.status = (int) cdmaSms.status;
1761 constructCdmaSms(rcsw.message, cdmaSms.message);
1763 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI);
1767 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1769 RLOGD("deleteSmsOnRuim: serial %d", serial);
1771 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1775 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1777 RLOGD("getDeviceIdentity: serial %d", serial);
1779 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1783 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1785 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1787 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1791 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1793 RLOGD("getSmscAddress: serial %d", serial);
1795 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1799 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1801 RLOGD("setSmscAddress: serial %d", serial);
1803 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1808 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1810 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1812 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1813 BOOL_TO_INT(available));
1817 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1819 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1821 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1825 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1827 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1829 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1833 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1835 RLOGD("requestIsimAuthentication: serial %d", serial);
1837 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1842 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1843 const hidl_string& ackPdu) {
1845 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1847 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1848 2, success ? "1" : "0", ackPdu.c_str());
1852 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1854 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1856 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1861 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1863 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1865 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1869 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1871 RLOGD("getCellInfoList: serial %d", serial);
1873 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1877 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1879 RLOGD("setCellInfoListRate: serial %d", serial);
1881 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1885 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1886 bool modemCognitive, bool isRoaming) {
1888 RLOGD("setInitialAttachApn: serial %d", serial);
1890 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1891 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
1896 if (s_vendorFunctions->version <= 14) {
1897 RIL_InitialAttachApn iaa = {};
1899 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1903 const hidl_string &protocol =
1904 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1906 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
1909 iaa.authtype = (int) dataProfileInfo.authType;
1910 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1913 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
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)) {
1929 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
1932 iaa.authtype = (int) dataProfileInfo.authType;
1933 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1936 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1939 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
1940 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
1941 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
1942 iaa.mtu = dataProfileInfo.mtu;
1944 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
1945 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1949 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
1953 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1955 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1956 iaa.password, iaa.mvnoMatchData);
1962 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
1964 RLOGD("getImsRegistrationState: serial %d", serial);
1966 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
1970 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
1971 RIL_IMS_SMS_Message rism = {};
1973 int countStrings = 2;
1974 int dataLen = sizeof(char *) * countStrings;
1976 rism.tech = RADIO_TECH_3GPP;
1977 rism.retry = BOOL_TO_INT(message.retry);
1978 rism.messageRef = message.messageRef;
1980 if (message.gsmMessage.size() != 1) {
1981 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
1982 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1986 pStrings = (char **)calloc(countStrings, sizeof(char *));
1987 if (pStrings == NULL) {
1988 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
1989 requestToString(pRI->pCI->requestNumber));
1990 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
1994 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
1996 memset(pStrings, 0, dataLen);
2002 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2003 memsetAndFreeStrings(1, pStrings[0]);
2005 memset(pStrings, 0, dataLen);
2011 rism.message.gsmMessage = pStrings;
2012 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2013 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI);
2015 for (int i = 0 ; i < countStrings ; i++) {
2016 memsetAndFreeStrings(1, pStrings[i]);
2020 memset(pStrings, 0, dataLen);
2027 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2028 RIL_IMS_SMS_Message rism;
2029 RIL_CDMA_SMS_Message rcsm;
2031 if (message.cdmaMessage.size() != 1) {
2032 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2033 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2037 rism.tech = RADIO_TECH_3GPP2;
2038 rism.retry = BOOL_TO_INT(message.retry);
2039 rism.messageRef = message.messageRef;
2040 rism.message.cdmaMessage = &rcsm;
2042 constructCdmaSms(rcsm, message.cdmaMessage[0]);
2044 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2045 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI);
2050 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2052 RLOGD("sendImsSms: serial %d", serial);
2054 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2059 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2061 if (RADIO_TECH_3GPP == format) {
2062 dispatchImsGsmSms(message, pRI);
2063 } else if (RADIO_TECH_3GPP2 == format) {
2064 dispatchImsCdmaSms(message, pRI);
2066 RLOGE("sendImsSms: Invalid radio tech %s",
2067 requestToString(pRI->pCI->requestNumber));
2068 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2073 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2075 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2077 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2081 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2083 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2085 if (s_vendorFunctions->version < 15) {
2086 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2088 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2093 RIL_OpenChannelParams params;
2094 memset (¶ms, 0, sizeof(RIL_OpenChannelParams));
2098 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2102 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI);
2104 memsetAndFreeStrings(1, params.aidPtr);
2109 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2111 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2113 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2117 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2119 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2121 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2125 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2127 RLOGD("nvReadItem: serial %d", serial);
2129 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2134 RIL_NV_ReadItem nvri;
2135 memset (&nvri, 0, sizeof(nvri));
2136 nvri.itemID = (RIL_NV_Item) itemId;
2138 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI);
2142 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2144 RLOGD("nvWriteItem: serial %d", serial);
2146 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2151 RIL_NV_WriteItem nvwi;
2152 memset (&nvwi, 0, sizeof(nvwi));
2154 nvwi.itemID = (RIL_NV_Item) item.itemId;
2156 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2160 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI);
2162 memsetAndFreeStrings(1, nvwi.value);
2166 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2168 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2170 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2174 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2176 RLOGD("nvResetConfig: serial %d", serial);
2178 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, (int) resetType);
2182 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2184 RLOGD("setUiccSubscription: serial %d", serial);
2186 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2187 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2192 RIL_SelectUiccSub rilUiccSub = {};
2194 rilUiccSub.slot = uiccSub.slot;
2195 rilUiccSub.app_index = uiccSub.appIndex;
2196 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2197 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2199 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI);
2203 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2205 RLOGD("setDataAllowed: serial %d", serial);
2207 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2211 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2213 RLOGD("getHardwareConfig: serial %d", serial);
2215 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2219 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2220 const hidl_string& authData, const hidl_string& aid) {
2222 RLOGD("requestIccSimAuthentication: serial %d", serial);
2224 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2229 RIL_SimAuthentication pf;
2230 memset (&pf, 0, sizeof(pf));
2232 pf.authContext = authContext;
2235 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2239 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2240 memsetAndFreeStrings(1, pf.authData);
2244 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI);
2246 memsetAndFreeStrings(2, pf.authData, pf.aid);
2251 * @param numProfiles number of data profile
2252 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2253 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2254 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2255 * @param numfields number of string-type member in the data profile structure
2256 * @param ... the variadic parameters are pointers to each string-type member
2258 template <typename T>
2259 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2260 int numfields, ...) {
2262 va_start(args, numfields);
2264 // Iterate through each string-type field that need to be free.
2265 for (int i = 0; i < numfields; i++) {
2266 // Iterate through each data profile and free that specific string-type field.
2267 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2268 char *T::*ptr = va_arg(args, char *T::*);
2269 for (int j = 0; j < numProfiles; j++) {
2270 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2277 memset(dataProfiles, 0, numProfiles * sizeof(T));
2278 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2281 free(dataProfilePtrs);
2284 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2287 RLOGD("setDataProfile: serial %d", serial);
2289 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2294 size_t num = profiles.size();
2295 bool success = false;
2297 if (s_vendorFunctions->version <= 14) {
2299 RIL_DataProfileInfo *dataProfiles =
2300 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2302 if (dataProfiles == NULL) {
2303 RLOGE("Memory allocation failed for request %s",
2304 requestToString(pRI->pCI->requestNumber));
2305 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2309 RIL_DataProfileInfo **dataProfilePtrs =
2310 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2311 if (dataProfilePtrs == NULL) {
2312 RLOGE("Memory allocation failed for request %s",
2313 requestToString(pRI->pCI->requestNumber));
2315 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2319 for (size_t i = 0; i < num; i++) {
2320 dataProfilePtrs[i] = &dataProfiles[i];
2322 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2324 const hidl_string &protocol =
2325 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2327 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2331 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2334 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2340 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2341 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2342 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2346 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2347 dataProfiles[i].authType = (int) profiles[i].authType;
2348 dataProfiles[i].type = (int) profiles[i].type;
2349 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2350 dataProfiles[i].maxConns = profiles[i].maxConns;
2351 dataProfiles[i].waitTime = profiles[i].waitTime;
2352 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2355 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2356 num * sizeof(RIL_DataProfileInfo *), pRI);
2358 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2359 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2360 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2362 RIL_DataProfileInfo_v15 *dataProfiles =
2363 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2365 if (dataProfiles == NULL) {
2366 RLOGE("Memory allocation failed for request %s",
2367 requestToString(pRI->pCI->requestNumber));
2368 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2372 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2373 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2374 if (dataProfilePtrs == NULL) {
2375 RLOGE("Memory allocation failed for request %s",
2376 requestToString(pRI->pCI->requestNumber));
2378 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2382 for (size_t i = 0; i < num; i++) {
2383 dataProfilePtrs[i] = &dataProfiles[i];
2385 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2386 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2390 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2391 profiles[i].roamingProtocol, pRI)) {
2394 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2397 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2402 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2403 profiles[i].mvnoMatchData, pRI)) {
2407 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2408 dataProfiles[i].mvnoType)) {
2409 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2414 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2415 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2416 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2417 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2421 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2422 dataProfiles[i].authType = (int) profiles[i].authType;
2423 dataProfiles[i].type = (int) profiles[i].type;
2424 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2425 dataProfiles[i].maxConns = profiles[i].maxConns;
2426 dataProfiles[i].waitTime = profiles[i].waitTime;
2427 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2428 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2429 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2430 dataProfiles[i].mtu = profiles[i].mtu;
2433 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2434 num * sizeof(RIL_DataProfileInfo_v15 *), pRI);
2436 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2437 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2438 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2439 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2445 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2447 RLOGD("requestShutdown: serial %d", serial);
2449 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2453 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2455 RLOGD("getRadioCapability: serial %d", serial);
2457 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2461 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2463 RLOGD("setRadioCapability: serial %d", serial);
2465 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2470 RIL_RadioCapability rilRc;
2471 memset (&rilRc, 0, sizeof(rilRc));
2473 // TODO : set rilRc.version using HIDL version ?
2474 rilRc.session = rc.session;
2475 rilRc.phase = (int) rc.phase;
2476 rilRc.rat = (int) rc.raf;
2477 rilRc.status = (int) rc.status;
2478 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2480 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI);
2485 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2487 RLOGD("startLceService: serial %d", serial);
2489 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2490 BOOL_TO_INT(pullMode));
2494 Return<void> RadioImpl::stopLceService(int32_t serial) {
2496 RLOGD("stopLceService: serial %d", serial);
2498 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2502 Return<void> RadioImpl::pullLceData(int32_t serial) {
2504 RLOGD("pullLceData: serial %d", serial);
2506 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2510 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2512 RLOGD("getModemActivityInfo: serial %d", serial);
2514 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2518 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2519 const CarrierRestrictions& carriers) {
2521 RLOGD("setAllowedCarriers: serial %d", serial);
2523 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2524 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2529 RIL_CarrierRestrictions cr = {};
2530 RIL_Carrier *allowedCarriers = NULL;
2531 RIL_Carrier *excludedCarriers = NULL;
2533 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2534 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2535 if (allowedCarriers == NULL) {
2536 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2537 requestToString(pRI->pCI->requestNumber));
2538 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2541 cr.allowed_carriers = allowedCarriers;
2543 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2544 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2545 if (excludedCarriers == NULL) {
2546 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2547 requestToString(pRI->pCI->requestNumber));
2548 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2550 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2552 free(allowedCarriers);
2555 cr.excluded_carriers = excludedCarriers;
2557 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2558 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2559 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2560 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2561 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2564 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2565 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2566 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2567 excludedCarriers[i].match_type =
2568 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2569 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2572 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI);
2575 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2576 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2578 free(allowedCarriers);
2579 free(excludedCarriers);
2583 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2585 RLOGD("getAllowedCarriers: serial %d", serial);
2587 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2591 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2594 RLOGD("sendDeviceState: serial %d", serial);
2596 if (s_vendorFunctions->version < 15) {
2597 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2598 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2599 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2601 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2602 RIL_REQUEST_SEND_DEVICE_STATE);
2603 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2607 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2608 BOOL_TO_INT(state));
2612 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2614 RLOGD("setIndicationFilter: serial %d", serial);
2616 if (s_vendorFunctions->version < 15) {
2617 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2618 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2619 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2622 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2626 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2628 RLOGD("setSimCardPower: serial %d", serial);
2630 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2634 Return<void> RadioImpl::responseAcknowledgement() {
2635 android::releaseWakeLock();
2639 Return<void> OemHookImpl::setResponseFunctions(
2640 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2641 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2643 RLOGD("OemHookImpl::setResponseFunctions");
2646 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2647 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2650 mOemHookResponse = oemHookResponseParam;
2651 mOemHookIndication = oemHookIndicationParam;
2652 mCounterOemHook[mSlotId]++;
2654 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2660 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2662 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2664 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2668 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2669 const hidl_vec<hidl_string>& data) {
2671 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2673 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2677 /***************************************************************************************************
2678 * RESPONSE FUNCTIONS
2679 * Functions above are used for requests going from framework to vendor code. The ones below are
2680 * responses for those requests coming back from the vendor code.
2681 **************************************************************************************************/
2683 void radio::acknowledgeRequest(int slotId, int serial) {
2684 if (radioService[slotId]->mRadioResponse != NULL) {
2685 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2686 radioService[slotId]->checkReturnStatus(retStatus);
2688 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2692 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2694 responseInfo.serial = serial;
2695 switch (responseType) {
2696 case RESPONSE_SOLICITED:
2697 responseInfo.type = RadioResponseType::SOLICITED;
2699 case RESPONSE_SOLICITED_ACK_EXP:
2700 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2703 responseInfo.error = (RadioError) e;
2706 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2707 void *response, size_t responseLen) {
2708 populateResponseInfo(responseInfo, serial, responseType, e);
2711 if (response == NULL && responseLen == 0) {
2712 // Earlier RILs did not send a response for some cases although the interface
2713 // expected an integer as response. Do not return error if response is empty. Instead
2714 // Return -1 in those cases to maintain backward compatibility.
2715 } else if (response == NULL || responseLen != sizeof(int)) {
2716 RLOGE("responseIntOrEmpty: Invalid response");
2717 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2719 int *p_int = (int *) response;
2725 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2726 void *response, size_t responseLen) {
2727 populateResponseInfo(responseInfo, serial, responseType, e);
2730 if (response == NULL || responseLen != sizeof(int)) {
2731 RLOGE("responseInt: Invalid response");
2732 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2734 int *p_int = (int *) response;
2740 int radio::getIccCardStatusResponse(int slotId,
2741 int responseType, int serial, RIL_Errno e,
2742 void *response, size_t responseLen) {
2743 if (radioService[slotId]->mRadioResponse != NULL) {
2744 RadioResponseInfo responseInfo = {};
2745 populateResponseInfo(responseInfo, serial, responseType, e);
2746 CardStatus cardStatus = {};
2747 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2748 RLOGE("getIccCardStatusResponse: Invalid response");
2749 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2751 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2752 cardStatus.cardState = (CardState) p_cur->card_state;
2753 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2754 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2755 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2756 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2758 RIL_AppStatus *rilAppStatus = p_cur->applications;
2759 cardStatus.applications.resize(p_cur->num_applications);
2760 AppStatus *appStatus = cardStatus.applications.data();
2762 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2764 for (int i = 0; i < p_cur->num_applications; i++) {
2765 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2766 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2767 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2768 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2769 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2770 rilAppStatus[i].app_label_ptr);
2771 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2772 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2773 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2777 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2778 getIccCardStatusResponse(responseInfo, cardStatus);
2779 radioService[slotId]->checkReturnStatus(retStatus);
2781 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2787 int radio::supplyIccPinForAppResponse(int slotId,
2788 int responseType, int serial, RIL_Errno e,
2789 void *response, size_t responseLen) {
2791 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
2794 if (radioService[slotId]->mRadioResponse != NULL) {
2795 RadioResponseInfo responseInfo = {};
2796 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2797 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2798 supplyIccPinForAppResponse(responseInfo, ret);
2799 radioService[slotId]->checkReturnStatus(retStatus);
2801 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2808 int radio::supplyIccPukForAppResponse(int slotId,
2809 int responseType, int serial, RIL_Errno e,
2810 void *response, size_t responseLen) {
2812 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
2815 if (radioService[slotId]->mRadioResponse != NULL) {
2816 RadioResponseInfo responseInfo = {};
2817 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2818 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2820 radioService[slotId]->checkReturnStatus(retStatus);
2822 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2829 int radio::supplyIccPin2ForAppResponse(int slotId,
2830 int responseType, int serial, RIL_Errno e,
2831 void *response, size_t responseLen) {
2833 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
2836 if (radioService[slotId]->mRadioResponse != NULL) {
2837 RadioResponseInfo responseInfo = {};
2838 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2839 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2840 supplyIccPin2ForAppResponse(responseInfo, ret);
2841 radioService[slotId]->checkReturnStatus(retStatus);
2843 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2850 int radio::supplyIccPuk2ForAppResponse(int slotId,
2851 int responseType, int serial, RIL_Errno e,
2852 void *response, size_t responseLen) {
2854 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
2857 if (radioService[slotId]->mRadioResponse != NULL) {
2858 RadioResponseInfo responseInfo = {};
2859 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2860 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2861 supplyIccPuk2ForAppResponse(responseInfo, ret);
2862 radioService[slotId]->checkReturnStatus(retStatus);
2864 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2871 int radio::changeIccPinForAppResponse(int slotId,
2872 int responseType, int serial, RIL_Errno e,
2873 void *response, size_t responseLen) {
2875 RLOGD("changeIccPinForAppResponse: serial %d", serial);
2878 if (radioService[slotId]->mRadioResponse != NULL) {
2879 RadioResponseInfo responseInfo = {};
2880 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2881 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2882 changeIccPinForAppResponse(responseInfo, ret);
2883 radioService[slotId]->checkReturnStatus(retStatus);
2885 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2892 int radio::changeIccPin2ForAppResponse(int slotId,
2893 int responseType, int serial, RIL_Errno e,
2894 void *response, size_t responseLen) {
2896 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
2899 if (radioService[slotId]->mRadioResponse != NULL) {
2900 RadioResponseInfo responseInfo = {};
2901 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2902 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2903 changeIccPin2ForAppResponse(responseInfo, ret);
2904 radioService[slotId]->checkReturnStatus(retStatus);
2906 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2913 int radio::supplyNetworkDepersonalizationResponse(int slotId,
2914 int responseType, int serial, RIL_Errno e,
2915 void *response, size_t responseLen) {
2917 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
2920 if (radioService[slotId]->mRadioResponse != NULL) {
2921 RadioResponseInfo responseInfo = {};
2922 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2923 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2924 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2925 radioService[slotId]->checkReturnStatus(retStatus);
2927 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
2934 int radio::getCurrentCallsResponse(int slotId,
2935 int responseType, int serial, RIL_Errno e,
2936 void *response, size_t responseLen) {
2938 RLOGD("getCurrentCallsResponse: serial %d", serial);
2941 if (radioService[slotId]->mRadioResponse != NULL) {
2942 RadioResponseInfo responseInfo = {};
2943 populateResponseInfo(responseInfo, serial, responseType, e);
2945 hidl_vec<Call> calls;
2946 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) {
2947 RLOGE("getCurrentCallsResponse: Invalid response");
2948 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2950 int num = responseLen / sizeof(RIL_Call *);
2953 for (int i = 0 ; i < num ; i++) {
2954 RIL_Call *p_cur = ((RIL_Call **) response)[i];
2955 /* each call info */
2956 calls[i].state = (CallState) p_cur->state;
2957 calls[i].index = p_cur->index;
2958 calls[i].toa = p_cur->toa;
2959 calls[i].isMpty = p_cur->isMpty;
2960 calls[i].isMT = p_cur->isMT;
2961 calls[i].als = p_cur->als;
2962 calls[i].isVoice = p_cur->isVoice;
2963 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
2964 calls[i].number = convertCharPtrToHidlString(p_cur->number);
2965 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
2966 calls[i].name = convertCharPtrToHidlString(p_cur->name);
2967 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
2968 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
2969 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
2970 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
2971 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
2972 // convert uusInfo->uusData to a null-terminated string
2973 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
2974 calls[i].uusInfo[0].uusData = nullTermStr;
2980 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2981 getCurrentCallsResponse(responseInfo, calls);
2982 radioService[slotId]->checkReturnStatus(retStatus);
2984 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2990 int radio::dialResponse(int slotId,
2991 int responseType, int serial, RIL_Errno e, void *response,
2992 size_t responseLen) {
2994 RLOGD("dialResponse: serial %d", serial);
2997 if (radioService[slotId]->mRadioResponse != NULL) {
2998 RadioResponseInfo responseInfo = {};
2999 populateResponseInfo(responseInfo, serial, responseType, e);
3000 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3001 radioService[slotId]->checkReturnStatus(retStatus);
3003 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3009 int radio::getIMSIForAppResponse(int slotId,
3010 int responseType, int serial, RIL_Errno e, void *response,
3011 size_t responseLen) {
3013 RLOGD("getIMSIForAppResponse: serial %d", serial);
3016 if (radioService[slotId]->mRadioResponse != NULL) {
3017 RadioResponseInfo responseInfo = {};
3018 populateResponseInfo(responseInfo, serial, responseType, e);
3019 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3020 responseInfo, convertCharPtrToHidlString((char *) response));
3021 radioService[slotId]->checkReturnStatus(retStatus);
3023 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3030 int radio::hangupConnectionResponse(int slotId,
3031 int responseType, int serial, RIL_Errno e,
3032 void *response, size_t responseLen) {
3034 RLOGD("hangupConnectionResponse: serial %d", serial);
3037 if (radioService[slotId]->mRadioResponse != NULL) {
3038 RadioResponseInfo responseInfo = {};
3039 populateResponseInfo(responseInfo, serial, responseType, e);
3040 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3042 radioService[slotId]->checkReturnStatus(retStatus);
3044 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3051 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3052 int responseType, int serial, RIL_Errno e,
3053 void *response, size_t responseLen) {
3055 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3058 if (radioService[slotId]->mRadioResponse != NULL) {
3059 RadioResponseInfo responseInfo = {};
3060 populateResponseInfo(responseInfo, serial, responseType, e);
3061 Return<void> retStatus =
3062 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3064 radioService[slotId]->checkReturnStatus(retStatus);
3066 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3073 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3074 RIL_Errno e, void *response,
3075 size_t responseLen) {
3077 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3080 if (radioService[slotId]->mRadioResponse != NULL) {
3081 RadioResponseInfo responseInfo = {};
3082 populateResponseInfo(responseInfo, serial, responseType, e);
3083 Return<void> retStatus =
3084 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3086 radioService[slotId]->checkReturnStatus(retStatus);
3088 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3095 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3096 RIL_Errno e, void *response,
3097 size_t responseLen) {
3099 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3102 if (radioService[slotId]->mRadioResponse != NULL) {
3103 RadioResponseInfo responseInfo = {};
3104 populateResponseInfo(responseInfo, serial, responseType, e);
3105 Return<void> retStatus =
3106 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3108 radioService[slotId]->checkReturnStatus(retStatus);
3110 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3117 int radio::conferenceResponse(int slotId, int responseType,
3118 int serial, RIL_Errno e, void *response, size_t responseLen) {
3120 RLOGD("conferenceResponse: serial %d", serial);
3123 if (radioService[slotId]->mRadioResponse != NULL) {
3124 RadioResponseInfo responseInfo = {};
3125 populateResponseInfo(responseInfo, serial, responseType, e);
3126 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3128 radioService[slotId]->checkReturnStatus(retStatus);
3130 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3137 int radio::rejectCallResponse(int slotId, int responseType,
3138 int serial, RIL_Errno e, void *response, size_t responseLen) {
3140 RLOGD("rejectCallResponse: serial %d", serial);
3143 if (radioService[slotId]->mRadioResponse != NULL) {
3144 RadioResponseInfo responseInfo = {};
3145 populateResponseInfo(responseInfo, serial, responseType, e);
3146 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3148 radioService[slotId]->checkReturnStatus(retStatus);
3150 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3157 int radio::getLastCallFailCauseResponse(int slotId,
3158 int responseType, int serial, RIL_Errno e, void *response,
3159 size_t responseLen) {
3161 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3164 if (radioService[slotId]->mRadioResponse != NULL) {
3165 RadioResponseInfo responseInfo = {};
3166 populateResponseInfo(responseInfo, serial, responseType, e);
3168 LastCallFailCauseInfo info = {};
3169 info.vendorCause = hidl_string();
3170 if (response == NULL) {
3171 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3172 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3173 } else if (responseLen == sizeof(int)) {
3174 int *pInt = (int *) response;
3175 info.causeCode = (LastCallFailCause) pInt[0];
3176 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3177 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3178 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3179 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3181 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3182 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3185 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3186 responseInfo, info);
3187 radioService[slotId]->checkReturnStatus(retStatus);
3189 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3196 int radio::getSignalStrengthResponse(int slotId,
3197 int responseType, int serial, RIL_Errno e,
3198 void *response, size_t responseLen) {
3200 RLOGD("getSignalStrengthResponse: serial %d", serial);
3203 if (radioService[slotId]->mRadioResponse != NULL) {
3204 RadioResponseInfo responseInfo = {};
3205 populateResponseInfo(responseInfo, serial, responseType, e);
3206 SignalStrength signalStrength = {};
3207 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3208 RLOGE("getSignalStrengthResponse: Invalid response");
3209 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3211 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3214 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3215 responseInfo, signalStrength);
3216 radioService[slotId]->checkReturnStatus(retStatus);
3218 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3225 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3227 return RIL_CELL_INFO_TYPE_NONE;
3230 int radioTech = atoi(rat);
3234 case RADIO_TECH_GPRS:
3235 case RADIO_TECH_EDGE:
3236 case RADIO_TECH_GSM: {
3237 return RIL_CELL_INFO_TYPE_GSM;
3240 case RADIO_TECH_UMTS:
3241 case RADIO_TECH_HSDPA:
3242 case RADIO_TECH_HSUPA:
3243 case RADIO_TECH_HSPA:
3244 case RADIO_TECH_HSPAP: {
3245 return RIL_CELL_INFO_TYPE_WCDMA;
3248 case RADIO_TECH_IS95A:
3249 case RADIO_TECH_IS95B:
3250 case RADIO_TECH_1xRTT:
3251 case RADIO_TECH_EVDO_0:
3252 case RADIO_TECH_EVDO_A:
3253 case RADIO_TECH_EVDO_B:
3254 case RADIO_TECH_EHRPD: {
3255 return RIL_CELL_INFO_TYPE_CDMA;
3258 case RADIO_TECH_LTE:
3259 case RADIO_TECH_LTE_CA: {
3260 return RIL_CELL_INFO_TYPE_LTE;
3263 case RADIO_TECH_TD_SCDMA: {
3264 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3272 return RIL_CELL_INFO_TYPE_NONE;
3276 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3278 cellIdentity.cellIdentityGsm.resize(0);
3279 cellIdentity.cellIdentityWcdma.resize(0);
3280 cellIdentity.cellIdentityCdma.resize(0);
3281 cellIdentity.cellIdentityTdscdma.resize(0);
3282 cellIdentity.cellIdentityLte.resize(0);
3283 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3284 switch(rilCellIdentity.cellInfoType) {
3286 case RIL_CELL_INFO_TYPE_GSM: {
3287 cellIdentity.cellIdentityGsm.resize(1);
3288 cellIdentity.cellIdentityGsm[0].mcc =
3289 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3290 cellIdentity.cellIdentityGsm[0].mnc =
3291 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3292 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3293 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3294 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3295 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3299 case RIL_CELL_INFO_TYPE_WCDMA: {
3300 cellIdentity.cellIdentityWcdma.resize(1);
3301 cellIdentity.cellIdentityWcdma[0].mcc =
3302 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3303 cellIdentity.cellIdentityWcdma[0].mnc =
3304 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3305 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3306 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3307 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3308 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3312 case RIL_CELL_INFO_TYPE_CDMA: {
3313 cellIdentity.cellIdentityCdma.resize(1);
3314 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3315 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3316 cellIdentity.cellIdentityCdma[0].baseStationId =
3317 rilCellIdentity.cellIdentityCdma.basestationId;
3318 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3319 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3323 case RIL_CELL_INFO_TYPE_LTE: {
3324 cellIdentity.cellIdentityLte.resize(1);
3325 cellIdentity.cellIdentityLte[0].mcc =
3326 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3327 cellIdentity.cellIdentityLte[0].mnc =
3328 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3329 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3330 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3331 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3332 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3336 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3337 cellIdentity.cellIdentityTdscdma.resize(1);
3338 cellIdentity.cellIdentityTdscdma[0].mcc =
3339 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3340 cellIdentity.cellIdentityTdscdma[0].mnc =
3341 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3342 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3343 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3344 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3354 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3355 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3356 return atoi(response[index]);
3362 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3363 int numStrings, char** response) {
3365 RIL_CellIdentity_v16 rilCellIdentity;
3366 int32_t *tmp = (int32_t*)&rilCellIdentity;
3368 for (size_t i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) {
3372 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3373 switch(rilCellIdentity.cellInfoType) {
3375 case RIL_CELL_INFO_TYPE_GSM: {
3376 rilCellIdentity.cellIdentityGsm.lac =
3377 convertResponseStringEntryToInt(response, 1, numStrings);
3378 rilCellIdentity.cellIdentityGsm.cid =
3379 convertResponseStringEntryToInt(response, 2, numStrings);
3383 case RIL_CELL_INFO_TYPE_WCDMA: {
3384 rilCellIdentity.cellIdentityWcdma.lac =
3385 convertResponseStringEntryToInt(response, 1, numStrings);
3386 rilCellIdentity.cellIdentityWcdma.cid =
3387 convertResponseStringEntryToInt(response, 2, numStrings);
3388 rilCellIdentity.cellIdentityWcdma.psc =
3389 convertResponseStringEntryToInt(response, 14, numStrings);
3393 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3394 rilCellIdentity.cellIdentityTdscdma.lac =
3395 convertResponseStringEntryToInt(response, 1, numStrings);
3396 rilCellIdentity.cellIdentityTdscdma.cid =
3397 convertResponseStringEntryToInt(response, 2, numStrings);
3401 case RIL_CELL_INFO_TYPE_CDMA:{
3402 rilCellIdentity.cellIdentityCdma.basestationId =
3403 convertResponseStringEntryToInt(response, 4, numStrings);
3404 rilCellIdentity.cellIdentityCdma.longitude =
3405 convertResponseStringEntryToInt(response, 5, numStrings);
3406 rilCellIdentity.cellIdentityCdma.latitude =
3407 convertResponseStringEntryToInt(response, 6, numStrings);
3408 rilCellIdentity.cellIdentityCdma.systemId =
3409 convertResponseStringEntryToInt(response, 8, numStrings);
3410 rilCellIdentity.cellIdentityCdma.networkId =
3411 convertResponseStringEntryToInt(response, 9, numStrings);
3415 case RIL_CELL_INFO_TYPE_LTE:{
3416 rilCellIdentity.cellIdentityLte.tac =
3417 convertResponseStringEntryToInt(response, 1, numStrings);
3418 rilCellIdentity.cellIdentityLte.ci =
3419 convertResponseStringEntryToInt(response, 2, numStrings);
3428 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3431 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3432 int numStrings, char** response) {
3434 RIL_CellIdentity_v16 rilCellIdentity;
3435 int32_t *tmp = (int32_t*)&rilCellIdentity;
3437 for (size_t i = 0; i < sizeof(RIL_CellIdentity_v16)/sizeof(int32_t); i++) {
3441 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3442 switch(rilCellIdentity.cellInfoType) {
3443 case RIL_CELL_INFO_TYPE_GSM: {
3444 rilCellIdentity.cellIdentityGsm.lac =
3445 convertResponseStringEntryToInt(response, 1, numStrings);
3446 rilCellIdentity.cellIdentityGsm.cid =
3447 convertResponseStringEntryToInt(response, 2, numStrings);
3450 case RIL_CELL_INFO_TYPE_WCDMA: {
3451 rilCellIdentity.cellIdentityWcdma.lac =
3452 convertResponseStringEntryToInt(response, 1, numStrings);
3453 rilCellIdentity.cellIdentityWcdma.cid =
3454 convertResponseStringEntryToInt(response, 2, numStrings);
3457 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3458 rilCellIdentity.cellIdentityTdscdma.lac =
3459 convertResponseStringEntryToInt(response, 1, numStrings);
3460 rilCellIdentity.cellIdentityTdscdma.cid =
3461 convertResponseStringEntryToInt(response, 2, numStrings);
3464 case RIL_CELL_INFO_TYPE_LTE: {
3465 rilCellIdentity.cellIdentityLte.tac =
3466 convertResponseStringEntryToInt(response, 6, numStrings);
3467 rilCellIdentity.cellIdentityLte.pci =
3468 convertResponseStringEntryToInt(response, 7, numStrings);
3469 rilCellIdentity.cellIdentityLte.ci =
3470 convertResponseStringEntryToInt(response, 8, numStrings);
3478 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3481 int radio::getVoiceRegistrationStateResponse(int slotId,
3482 int responseType, int serial, RIL_Errno e,
3483 void *response, size_t responseLen) {
3485 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3488 if (radioService[slotId]->mRadioResponse != NULL) {
3489 RadioResponseInfo responseInfo = {};
3490 populateResponseInfo(responseInfo, serial, responseType, e);
3492 VoiceRegStateResult voiceRegResponse = {};
3493 int numStrings = responseLen / sizeof(char *);
3494 if (response == NULL) {
3495 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3496 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3497 } else if (s_vendorFunctions->version <= 14) {
3498 if (numStrings != 15) {
3499 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3500 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3502 char **resp = (char **) response;
3503 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3504 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3505 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3506 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3507 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3508 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3509 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3510 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3514 RIL_VoiceRegistrationStateResponse *voiceRegState =
3515 (RIL_VoiceRegistrationStateResponse *)response;
3517 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3518 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3519 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3521 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3522 voiceRegResponse.rat = voiceRegState->rat;;
3523 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3524 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3525 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3526 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3527 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3528 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3529 voiceRegState->cellIdentity);
3533 Return<void> retStatus =
3534 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3535 responseInfo, voiceRegResponse);
3536 radioService[slotId]->checkReturnStatus(retStatus);
3538 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3545 int radio::getDataRegistrationStateResponse(int slotId,
3546 int responseType, int serial, RIL_Errno e,
3547 void *response, size_t responseLen) {
3549 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3552 if (radioService[slotId]->mRadioResponse != NULL) {
3553 RadioResponseInfo responseInfo = {};
3554 populateResponseInfo(responseInfo, serial, responseType, e);
3555 DataRegStateResult dataRegResponse = {};
3556 if (response == NULL) {
3557 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3558 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3559 } else if (s_vendorFunctions->version <= 14) {
3560 int numStrings = responseLen / sizeof(char *);
3561 if ((numStrings != 6) && (numStrings != 11)) {
3562 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3563 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3565 char **resp = (char **) response;
3566 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3567 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3568 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3569 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3570 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3574 RIL_DataRegistrationStateResponse *dataRegState =
3575 (RIL_DataRegistrationStateResponse *)response;
3577 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3578 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3579 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3581 dataRegResponse.regState = (RegState) dataRegState->regState;
3582 dataRegResponse.rat = dataRegState->rat;;
3583 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3584 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3585 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3589 Return<void> retStatus =
3590 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3592 radioService[slotId]->checkReturnStatus(retStatus);
3594 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3601 int radio::getOperatorResponse(int slotId,
3602 int responseType, int serial, RIL_Errno e, void *response,
3603 size_t responseLen) {
3605 RLOGD("getOperatorResponse: serial %d", serial);
3608 if (radioService[slotId]->mRadioResponse != NULL) {
3609 RadioResponseInfo responseInfo = {};
3610 populateResponseInfo(responseInfo, serial, responseType, e);
3611 hidl_string longName;
3612 hidl_string shortName;
3613 hidl_string numeric;
3614 int numStrings = responseLen / sizeof(char *);
3615 if (response == NULL || numStrings != 3) {
3616 RLOGE("getOperatorResponse Invalid response: NULL");
3617 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3620 char **resp = (char **) response;
3621 longName = convertCharPtrToHidlString(resp[0]);
3622 shortName = convertCharPtrToHidlString(resp[1]);
3623 numeric = convertCharPtrToHidlString(resp[2]);
3625 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3626 responseInfo, longName, shortName, numeric);
3627 radioService[slotId]->checkReturnStatus(retStatus);
3629 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3636 int radio::setRadioPowerResponse(int slotId,
3637 int responseType, int serial, RIL_Errno e, void *response,
3638 size_t responseLen) {
3639 RLOGD("setRadioPowerResponse: serial %d", serial);
3641 if (radioService[slotId]->mRadioResponse != NULL) {
3642 RadioResponseInfo responseInfo = {};
3643 populateResponseInfo(responseInfo, serial, responseType, e);
3644 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3646 radioService[slotId]->checkReturnStatus(retStatus);
3648 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3655 int radio::sendDtmfResponse(int slotId,
3656 int responseType, int serial, RIL_Errno e, void *response,
3657 size_t responseLen) {
3659 RLOGD("sendDtmfResponse: serial %d", serial);
3662 if (radioService[slotId]->mRadioResponse != NULL) {
3663 RadioResponseInfo responseInfo = {};
3664 populateResponseInfo(responseInfo, serial, responseType, e);
3665 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3667 radioService[slotId]->checkReturnStatus(retStatus);
3669 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3676 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3677 RIL_Errno e, void *response, size_t responseLen) {
3678 populateResponseInfo(responseInfo, serial, responseType, e);
3679 SendSmsResult result = {};
3681 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3682 RLOGE("Invalid response: NULL");
3683 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3684 result.ackPDU = hidl_string();
3686 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3687 result.messageRef = resp->messageRef;
3688 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3689 result.errorCode = resp->errorCode;
3694 int radio::sendSmsResponse(int slotId,
3695 int responseType, int serial, RIL_Errno e, void *response,
3696 size_t responseLen) {
3698 RLOGD("sendSmsResponse: serial %d", serial);
3701 if (radioService[slotId]->mRadioResponse != NULL) {
3702 RadioResponseInfo responseInfo = {};
3703 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3706 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3708 radioService[slotId]->checkReturnStatus(retStatus);
3710 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3716 int radio::sendSMSExpectMoreResponse(int slotId,
3717 int responseType, int serial, RIL_Errno e, void *response,
3718 size_t responseLen) {
3720 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3723 if (radioService[slotId]->mRadioResponse != NULL) {
3724 RadioResponseInfo responseInfo = {};
3725 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3728 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3729 responseInfo, result);
3730 radioService[slotId]->checkReturnStatus(retStatus);
3732 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3738 int radio::setupDataCallResponse(int slotId,
3739 int responseType, int serial, RIL_Errno e, void *response,
3740 size_t responseLen) {
3742 RLOGD("setupDataCallResponse: serial %d", serial);
3745 if (radioService[slotId]->mRadioResponse != NULL) {
3746 RadioResponseInfo responseInfo = {};
3747 populateResponseInfo(responseInfo, serial, responseType, e);
3749 SetupDataCallResult result = {};
3750 if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) {
3751 RLOGE("setupDataCallResponse: Invalid response");
3752 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3753 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3754 result.type = hidl_string();
3755 result.ifname = hidl_string();
3756 result.addresses = hidl_string();
3757 result.dnses = hidl_string();
3758 result.gateways = hidl_string();
3759 result.pcscf = hidl_string();
3761 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3764 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3765 responseInfo, result);
3766 radioService[slotId]->checkReturnStatus(retStatus);
3768 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3774 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3775 RIL_Errno e, void *response, size_t responseLen) {
3776 populateResponseInfo(responseInfo, serial, responseType, e);
3777 IccIoResult result = {};
3779 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3780 RLOGE("Invalid response: NULL");
3781 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3782 result.simResponse = hidl_string();
3784 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3785 result.sw1 = resp->sw1;
3786 result.sw2 = resp->sw2;
3787 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3792 int radio::iccIOForAppResponse(int slotId,
3793 int responseType, int serial, RIL_Errno e, void *response,
3794 size_t responseLen) {
3796 RLOGD("iccIOForAppResponse: serial %d", serial);
3799 if (radioService[slotId]->mRadioResponse != NULL) {
3800 RadioResponseInfo responseInfo = {};
3801 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3804 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3805 responseInfo, result);
3806 radioService[slotId]->checkReturnStatus(retStatus);
3808 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3814 int radio::sendUssdResponse(int slotId,
3815 int responseType, int serial, RIL_Errno e, void *response,
3816 size_t responseLen) {
3818 RLOGD("sendUssdResponse: serial %d", serial);
3821 if (radioService[slotId]->mRadioResponse != NULL) {
3822 RadioResponseInfo responseInfo = {};
3823 populateResponseInfo(responseInfo, serial, responseType, e);
3824 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3826 radioService[slotId]->checkReturnStatus(retStatus);
3828 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3835 int radio::cancelPendingUssdResponse(int slotId,
3836 int responseType, int serial, RIL_Errno e, void *response,
3837 size_t responseLen) {
3839 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3842 if (radioService[slotId]->mRadioResponse != NULL) {
3843 RadioResponseInfo responseInfo = {};
3844 populateResponseInfo(responseInfo, serial, responseType, e);
3845 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3847 radioService[slotId]->checkReturnStatus(retStatus);
3849 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3856 int radio::getClirResponse(int slotId,
3857 int responseType, int serial, RIL_Errno e, void *response,
3858 size_t responseLen) {
3860 RLOGD("getClirResponse: serial %d", serial);
3863 if (radioService[slotId]->mRadioResponse != NULL) {
3864 RadioResponseInfo responseInfo = {};
3865 populateResponseInfo(responseInfo, serial, responseType, e);
3867 int numInts = responseLen / sizeof(int);
3868 if (response == NULL || numInts != 2) {
3869 RLOGE("getClirResponse Invalid response: NULL");
3870 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3872 int *pInt = (int *) response;
3876 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3878 radioService[slotId]->checkReturnStatus(retStatus);
3880 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3886 int radio::setClirResponse(int slotId,
3887 int responseType, int serial, RIL_Errno e, void *response,
3888 size_t responseLen) {
3890 RLOGD("setClirResponse: serial %d", serial);
3893 if (radioService[slotId]->mRadioResponse != NULL) {
3894 RadioResponseInfo responseInfo = {};
3895 populateResponseInfo(responseInfo, serial, responseType, e);
3896 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
3898 radioService[slotId]->checkReturnStatus(retStatus);
3900 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3906 int radio::getCallForwardStatusResponse(int slotId,
3907 int responseType, int serial, RIL_Errno e,
3908 void *response, size_t responseLen) {
3910 RLOGD("getCallForwardStatusResponse: serial %d", serial);
3913 if (radioService[slotId]->mRadioResponse != NULL) {
3914 RadioResponseInfo responseInfo = {};
3915 populateResponseInfo(responseInfo, serial, responseType, e);
3916 hidl_vec<CallForwardInfo> callForwardInfos;
3918 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
3919 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
3920 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3922 int num = responseLen / sizeof(RIL_CallForwardInfo *);
3923 callForwardInfos.resize(num);
3924 for (int i = 0 ; i < num; i++) {
3925 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
3926 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
3927 callForwardInfos[i].reason = resp->reason;
3928 callForwardInfos[i].serviceClass = resp->serviceClass;
3929 callForwardInfos[i].toa = resp->toa;
3930 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
3931 callForwardInfos[i].timeSeconds = resp->timeSeconds;
3935 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
3936 responseInfo, callForwardInfos);
3937 radioService[slotId]->checkReturnStatus(retStatus);
3939 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
3946 int radio::setCallForwardResponse(int slotId,
3947 int responseType, int serial, RIL_Errno e, void *response,
3948 size_t responseLen) {
3950 RLOGD("setCallForwardResponse: serial %d", serial);
3953 if (radioService[slotId]->mRadioResponse != NULL) {
3954 RadioResponseInfo responseInfo = {};
3955 populateResponseInfo(responseInfo, serial, responseType, e);
3956 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
3958 radioService[slotId]->checkReturnStatus(retStatus);
3960 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3966 int radio::getCallWaitingResponse(int slotId,
3967 int responseType, int serial, RIL_Errno e, void *response,
3968 size_t responseLen) {
3970 RLOGD("getCallWaitingResponse: serial %d", serial);
3973 if (radioService[slotId]->mRadioResponse != NULL) {
3974 RadioResponseInfo responseInfo = {};
3975 populateResponseInfo(responseInfo, serial, responseType, e);
3976 bool enable = false;
3977 int serviceClass = -1;
3978 int numInts = responseLen / sizeof(int);
3979 if (response == NULL || numInts != 2) {
3980 RLOGE("getCallWaitingResponse Invalid response: NULL");
3981 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3983 int *pInt = (int *) response;
3984 enable = pInt[0] == 1 ? true : false;
3985 serviceClass = pInt[1];
3987 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
3988 responseInfo, enable, serviceClass);
3989 radioService[slotId]->checkReturnStatus(retStatus);
3991 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3997 int radio::setCallWaitingResponse(int slotId,
3998 int responseType, int serial, RIL_Errno e, void *response,
3999 size_t responseLen) {
4001 RLOGD("setCallWaitingResponse: serial %d", serial);
4004 if (radioService[slotId]->mRadioResponse != NULL) {
4005 RadioResponseInfo responseInfo = {};
4006 populateResponseInfo(responseInfo, serial, responseType, e);
4007 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4009 radioService[slotId]->checkReturnStatus(retStatus);
4011 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4017 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4018 int responseType, int serial, RIL_Errno e,
4019 void *response, size_t responseLen) {
4021 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4024 if (radioService[slotId]->mRadioResponse != NULL) {
4025 RadioResponseInfo responseInfo = {};
4026 populateResponseInfo(responseInfo, serial, responseType, e);
4027 Return<void> retStatus =
4028 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4030 radioService[slotId]->checkReturnStatus(retStatus);
4032 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4039 int radio::acceptCallResponse(int slotId,
4040 int responseType, int serial, RIL_Errno e,
4041 void *response, size_t responseLen) {
4043 RLOGD("acceptCallResponse: serial %d", serial);
4046 if (radioService[slotId]->mRadioResponse != NULL) {
4047 RadioResponseInfo responseInfo = {};
4048 populateResponseInfo(responseInfo, serial, responseType, e);
4049 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4051 radioService[slotId]->checkReturnStatus(retStatus);
4053 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4060 int radio::deactivateDataCallResponse(int slotId,
4061 int responseType, int serial, RIL_Errno e,
4062 void *response, size_t responseLen) {
4064 RLOGD("deactivateDataCallResponse: serial %d", serial);
4067 if (radioService[slotId]->mRadioResponse != NULL) {
4068 RadioResponseInfo responseInfo = {};
4069 populateResponseInfo(responseInfo, serial, responseType, e);
4070 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4072 radioService[slotId]->checkReturnStatus(retStatus);
4074 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4081 int radio::getFacilityLockForAppResponse(int slotId,
4082 int responseType, int serial, RIL_Errno e,
4083 void *response, size_t responseLen) {
4085 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4088 if (radioService[slotId]->mRadioResponse != NULL) {
4089 RadioResponseInfo responseInfo = {};
4090 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4091 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4092 getFacilityLockForAppResponse(responseInfo, ret);
4093 radioService[slotId]->checkReturnStatus(retStatus);
4095 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4102 int radio::setFacilityLockForAppResponse(int slotId,
4103 int responseType, int serial, RIL_Errno e,
4104 void *response, size_t responseLen) {
4106 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4109 if (radioService[slotId]->mRadioResponse != NULL) {
4110 RadioResponseInfo responseInfo = {};
4111 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4112 Return<void> retStatus
4113 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4115 radioService[slotId]->checkReturnStatus(retStatus);
4117 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4124 int radio::setBarringPasswordResponse(int slotId,
4125 int responseType, int serial, RIL_Errno e,
4126 void *response, size_t responseLen) {
4128 RLOGD("acceptCallResponse: serial %d", serial);
4131 if (radioService[slotId]->mRadioResponse != NULL) {
4132 RadioResponseInfo responseInfo = {};
4133 populateResponseInfo(responseInfo, serial, responseType, e);
4134 Return<void> retStatus
4135 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4136 radioService[slotId]->checkReturnStatus(retStatus);
4138 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4145 int radio::getNetworkSelectionModeResponse(int slotId,
4146 int responseType, int serial, RIL_Errno e, void *response,
4147 size_t responseLen) {
4149 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4152 if (radioService[slotId]->mRadioResponse != NULL) {
4153 RadioResponseInfo responseInfo = {};
4154 populateResponseInfo(responseInfo, serial, responseType, e);
4155 bool manual = false;
4157 if (response == NULL || responseLen != sizeof(int)) {
4158 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4159 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4161 int *pInt = (int *) response;
4162 manual = pInt[0] == 1 ? true : false;
4164 Return<void> retStatus
4165 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4168 radioService[slotId]->checkReturnStatus(retStatus);
4170 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4177 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4178 RIL_Errno e, void *response,
4179 size_t responseLen) {
4181 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4184 if (radioService[slotId]->mRadioResponse != NULL) {
4185 RadioResponseInfo responseInfo = {};
4186 populateResponseInfo(responseInfo, serial, responseType, e);
4187 Return<void> retStatus
4188 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4190 radioService[slotId]->checkReturnStatus(retStatus);
4192 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4199 int radio::setNetworkSelectionModeManualResponse(int slotId,
4200 int responseType, int serial, RIL_Errno e,
4201 void *response, size_t responseLen) {
4203 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4206 if (radioService[slotId]->mRadioResponse != NULL) {
4207 RadioResponseInfo responseInfo = {};
4208 populateResponseInfo(responseInfo, serial, responseType, e);
4209 Return<void> retStatus
4210 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4212 radioService[slotId]->checkReturnStatus(retStatus);
4214 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4221 int convertOperatorStatusToInt(const char *str) {
4222 if (strncmp("unknown", str, 9) == 0) {
4223 return (int) OperatorStatus::UNKNOWN;
4224 } else if (strncmp("available", str, 9) == 0) {
4225 return (int) OperatorStatus::AVAILABLE;
4226 } else if (strncmp("current", str, 9) == 0) {
4227 return (int) OperatorStatus::CURRENT;
4228 } else if (strncmp("forbidden", str, 9) == 0) {
4229 return (int) OperatorStatus::FORBIDDEN;
4235 int radio::getAvailableNetworksResponse(int slotId,
4236 int responseType, int serial, RIL_Errno e, void *response,
4237 size_t responseLen) {
4239 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4242 if (radioService[slotId]->mRadioResponse != NULL) {
4243 RadioResponseInfo responseInfo = {};
4244 populateResponseInfo(responseInfo, serial, responseType, e);
4245 hidl_vec<OperatorInfo> networks;
4246 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) {
4247 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4248 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4250 char **resp = (char **) response;
4251 int numStrings = responseLen / sizeof(char *);
4252 networks.resize(numStrings/4);
4253 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4254 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4255 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4256 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4257 int status = convertOperatorStatusToInt(resp[i + 3]);
4259 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4261 networks[j].status = (OperatorStatus) status;
4265 Return<void> retStatus
4266 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4268 radioService[slotId]->checkReturnStatus(retStatus);
4270 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4277 int radio::startDtmfResponse(int slotId,
4278 int responseType, int serial, RIL_Errno e,
4279 void *response, size_t responseLen) {
4281 RLOGD("startDtmfResponse: serial %d", serial);
4284 if (radioService[slotId]->mRadioResponse != NULL) {
4285 RadioResponseInfo responseInfo = {};
4286 populateResponseInfo(responseInfo, serial, responseType, e);
4287 Return<void> retStatus
4288 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4289 radioService[slotId]->checkReturnStatus(retStatus);
4291 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4297 int radio::stopDtmfResponse(int slotId,
4298 int responseType, int serial, RIL_Errno e,
4299 void *response, size_t responseLen) {
4301 RLOGD("stopDtmfResponse: serial %d", serial);
4304 if (radioService[slotId]->mRadioResponse != NULL) {
4305 RadioResponseInfo responseInfo = {};
4306 populateResponseInfo(responseInfo, serial, responseType, e);
4307 Return<void> retStatus
4308 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4309 radioService[slotId]->checkReturnStatus(retStatus);
4311 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4317 int radio::getBasebandVersionResponse(int slotId,
4318 int responseType, int serial, RIL_Errno e,
4319 void *response, size_t responseLen) {
4321 RLOGD("getBasebandVersionResponse: serial %d", serial);
4324 if (radioService[slotId]->mRadioResponse != NULL) {
4325 RadioResponseInfo responseInfo = {};
4326 populateResponseInfo(responseInfo, serial, responseType, e);
4327 Return<void> retStatus
4328 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4329 convertCharPtrToHidlString((char *) response));
4330 radioService[slotId]->checkReturnStatus(retStatus);
4332 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4338 int radio::separateConnectionResponse(int slotId,
4339 int responseType, int serial, RIL_Errno e,
4340 void *response, size_t responseLen) {
4342 RLOGD("separateConnectionResponse: serial %d", serial);
4345 if (radioService[slotId]->mRadioResponse != NULL) {
4346 RadioResponseInfo responseInfo = {};
4347 populateResponseInfo(responseInfo, serial, responseType, e);
4348 Return<void> retStatus
4349 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4350 radioService[slotId]->checkReturnStatus(retStatus);
4352 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4359 int radio::setMuteResponse(int slotId,
4360 int responseType, int serial, RIL_Errno e,
4361 void *response, size_t responseLen) {
4363 RLOGD("setMuteResponse: serial %d", serial);
4366 if (radioService[slotId]->mRadioResponse != NULL) {
4367 RadioResponseInfo responseInfo = {};
4368 populateResponseInfo(responseInfo, serial, responseType, e);
4369 Return<void> retStatus
4370 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4371 radioService[slotId]->checkReturnStatus(retStatus);
4373 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4379 int radio::getMuteResponse(int slotId,
4380 int responseType, int serial, RIL_Errno e, void *response,
4381 size_t responseLen) {
4383 RLOGD("getMuteResponse: serial %d", serial);
4386 if (radioService[slotId]->mRadioResponse != NULL) {
4387 RadioResponseInfo responseInfo = {};
4388 populateResponseInfo(responseInfo, serial, responseType, e);
4389 bool enable = false;
4391 if (response == NULL || responseLen != sizeof(int)) {
4392 RLOGE("getMuteResponse Invalid response: NULL");
4393 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4395 int *pInt = (int *) response;
4396 enable = pInt[0] == 1 ? true : false;
4398 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4400 radioService[slotId]->checkReturnStatus(retStatus);
4402 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4408 int radio::getClipResponse(int slotId,
4409 int responseType, int serial, RIL_Errno e,
4410 void *response, size_t responseLen) {
4412 RLOGD("getClipResponse: serial %d", serial);
4415 if (radioService[slotId]->mRadioResponse != NULL) {
4416 RadioResponseInfo responseInfo = {};
4417 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4418 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4420 radioService[slotId]->checkReturnStatus(retStatus);
4422 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4428 int radio::getDataCallListResponse(int slotId,
4429 int responseType, int serial, RIL_Errno e,
4430 void *response, size_t responseLen) {
4432 RLOGD("getDataCallListResponse: serial %d", serial);
4435 if (radioService[slotId]->mRadioResponse != NULL) {
4436 RadioResponseInfo responseInfo = {};
4437 populateResponseInfo(responseInfo, serial, responseType, e);
4439 hidl_vec<SetupDataCallResult> ret;
4440 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4441 RLOGE("getDataCallListResponse: invalid response");
4442 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4444 convertRilDataCallListToHal(response, responseLen, ret);
4447 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4449 radioService[slotId]->checkReturnStatus(retStatus);
4451 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4457 int radio::setSuppServiceNotificationsResponse(int slotId,
4458 int responseType, int serial, RIL_Errno e,
4459 void *response, size_t responseLen) {
4461 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4464 if (radioService[slotId]->mRadioResponse != NULL) {
4465 RadioResponseInfo responseInfo = {};
4466 populateResponseInfo(responseInfo, serial, responseType, e);
4467 Return<void> retStatus
4468 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4470 radioService[slotId]->checkReturnStatus(retStatus);
4472 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4479 int radio::deleteSmsOnSimResponse(int slotId,
4480 int responseType, int serial, RIL_Errno e,
4481 void *response, size_t responseLen) {
4483 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4486 if (radioService[slotId]->mRadioResponse != NULL) {
4487 RadioResponseInfo responseInfo = {};
4488 populateResponseInfo(responseInfo, serial, responseType, e);
4489 Return<void> retStatus
4490 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4491 radioService[slotId]->checkReturnStatus(retStatus);
4493 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4499 int radio::setBandModeResponse(int slotId,
4500 int responseType, int serial, RIL_Errno e,
4501 void *response, size_t responseLen) {
4503 RLOGD("setBandModeResponse: serial %d", serial);
4506 if (radioService[slotId]->mRadioResponse != NULL) {
4507 RadioResponseInfo responseInfo = {};
4508 populateResponseInfo(responseInfo, serial, responseType, e);
4509 Return<void> retStatus
4510 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4511 radioService[slotId]->checkReturnStatus(retStatus);
4513 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4519 int radio::writeSmsToSimResponse(int slotId,
4520 int responseType, int serial, RIL_Errno e,
4521 void *response, size_t responseLen) {
4523 RLOGD("writeSmsToSimResponse: serial %d", serial);
4526 if (radioService[slotId]->mRadioResponse != NULL) {
4527 RadioResponseInfo responseInfo = {};
4528 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4529 Return<void> retStatus
4530 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4531 radioService[slotId]->checkReturnStatus(retStatus);
4533 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4539 int radio::getAvailableBandModesResponse(int slotId,
4540 int responseType, int serial, RIL_Errno e, void *response,
4541 size_t responseLen) {
4543 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4546 if (radioService[slotId]->mRadioResponse != NULL) {
4547 RadioResponseInfo responseInfo = {};
4548 populateResponseInfo(responseInfo, serial, responseType, e);
4549 hidl_vec<RadioBandMode> modes;
4550 if (response == NULL || responseLen % sizeof(int) != 0) {
4551 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4552 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4554 int *pInt = (int *) response;
4555 int numInts = responseLen / sizeof(int);
4556 modes.resize(numInts);
4557 for (int i = 0; i < numInts; i++) {
4558 modes[i] = (RadioBandMode) pInt[i];
4561 Return<void> retStatus
4562 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4564 radioService[slotId]->checkReturnStatus(retStatus);
4566 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4573 int radio::sendEnvelopeResponse(int slotId,
4574 int responseType, int serial, RIL_Errno e,
4575 void *response, size_t responseLen) {
4577 RLOGD("sendEnvelopeResponse: serial %d", serial);
4580 if (radioService[slotId]->mRadioResponse != NULL) {
4581 RadioResponseInfo responseInfo = {};
4582 populateResponseInfo(responseInfo, serial, responseType, e);
4583 Return<void> retStatus
4584 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4585 convertCharPtrToHidlString((char *) response));
4586 radioService[slotId]->checkReturnStatus(retStatus);
4588 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4594 int radio::sendTerminalResponseToSimResponse(int slotId,
4595 int responseType, int serial, RIL_Errno e,
4596 void *response, size_t responseLen) {
4598 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4601 if (radioService[slotId]->mRadioResponse != NULL) {
4602 RadioResponseInfo responseInfo = {};
4603 populateResponseInfo(responseInfo, serial, responseType, e);
4604 Return<void> retStatus
4605 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4607 radioService[slotId]->checkReturnStatus(retStatus);
4609 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4616 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4617 int responseType, int serial,
4618 RIL_Errno e, void *response,
4619 size_t responseLen) {
4621 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4624 if (radioService[slotId]->mRadioResponse != NULL) {
4625 RadioResponseInfo responseInfo = {};
4626 populateResponseInfo(responseInfo, serial, responseType, e);
4627 Return<void> retStatus
4628 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4630 radioService[slotId]->checkReturnStatus(retStatus);
4632 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4639 int radio::explicitCallTransferResponse(int slotId,
4640 int responseType, int serial, RIL_Errno e,
4641 void *response, size_t responseLen) {
4643 RLOGD("explicitCallTransferResponse: serial %d", serial);
4646 if (radioService[slotId]->mRadioResponse != NULL) {
4647 RadioResponseInfo responseInfo = {};
4648 populateResponseInfo(responseInfo, serial, responseType, e);
4649 Return<void> retStatus
4650 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4651 radioService[slotId]->checkReturnStatus(retStatus);
4653 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4660 int radio::setPreferredNetworkTypeResponse(int slotId,
4661 int responseType, int serial, RIL_Errno e,
4662 void *response, size_t responseLen) {
4664 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4667 if (radioService[slotId]->mRadioResponse != NULL) {
4668 RadioResponseInfo responseInfo = {};
4669 populateResponseInfo(responseInfo, serial, responseType, e);
4670 Return<void> retStatus
4671 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4673 radioService[slotId]->checkReturnStatus(retStatus);
4675 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4683 int radio::getPreferredNetworkTypeResponse(int slotId,
4684 int responseType, int serial, RIL_Errno e,
4685 void *response, size_t responseLen) {
4687 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4690 if (radioService[slotId]->mRadioResponse != NULL) {
4691 RadioResponseInfo responseInfo = {};
4692 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4693 Return<void> retStatus
4694 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4695 responseInfo, (PreferredNetworkType) ret);
4696 radioService[slotId]->checkReturnStatus(retStatus);
4698 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4705 int radio::getNeighboringCidsResponse(int slotId,
4706 int responseType, int serial, RIL_Errno e,
4707 void *response, size_t responseLen) {
4709 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4712 if (radioService[slotId]->mRadioResponse != NULL) {
4713 RadioResponseInfo responseInfo = {};
4714 populateResponseInfo(responseInfo, serial, responseType, e);
4715 hidl_vec<NeighboringCell> cells;
4717 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4718 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4719 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4721 int num = responseLen / sizeof(RIL_NeighboringCell *);
4723 for (int i = 0 ; i < num; i++) {
4724 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4725 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4726 cells[i].rssi = resp->rssi;
4730 Return<void> retStatus
4731 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4733 radioService[slotId]->checkReturnStatus(retStatus);
4735 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4742 int radio::setLocationUpdatesResponse(int slotId,
4743 int responseType, int serial, RIL_Errno e,
4744 void *response, size_t responseLen) {
4746 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4749 if (radioService[slotId]->mRadioResponse != NULL) {
4750 RadioResponseInfo responseInfo = {};
4751 populateResponseInfo(responseInfo, serial, responseType, e);
4752 Return<void> retStatus
4753 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4754 radioService[slotId]->checkReturnStatus(retStatus);
4756 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4763 int radio::setCdmaSubscriptionSourceResponse(int slotId,
4764 int responseType, int serial, RIL_Errno e,
4765 void *response, size_t responseLen) {
4767 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4770 if (radioService[slotId]->mRadioResponse != NULL) {
4771 RadioResponseInfo responseInfo = {};
4772 populateResponseInfo(responseInfo, serial, responseType, e);
4773 Return<void> retStatus
4774 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4776 radioService[slotId]->checkReturnStatus(retStatus);
4778 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4785 int radio::setCdmaRoamingPreferenceResponse(int slotId,
4786 int responseType, int serial, RIL_Errno e,
4787 void *response, size_t responseLen) {
4789 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4792 if (radioService[slotId]->mRadioResponse != NULL) {
4793 RadioResponseInfo responseInfo = {};
4794 populateResponseInfo(responseInfo, serial, responseType, e);
4795 Return<void> retStatus
4796 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4798 radioService[slotId]->checkReturnStatus(retStatus);
4800 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4807 int radio::getCdmaRoamingPreferenceResponse(int slotId,
4808 int responseType, int serial, RIL_Errno e,
4809 void *response, size_t responseLen) {
4811 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4814 if (radioService[slotId]->mRadioResponse != NULL) {
4815 RadioResponseInfo responseInfo = {};
4816 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4817 Return<void> retStatus
4818 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4819 responseInfo, (CdmaRoamingType) ret);
4820 radioService[slotId]->checkReturnStatus(retStatus);
4822 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4829 int radio::setTTYModeResponse(int slotId,
4830 int responseType, int serial, RIL_Errno e,
4831 void *response, size_t responseLen) {
4833 RLOGD("setTTYModeResponse: serial %d", serial);
4836 if (radioService[slotId]->mRadioResponse != NULL) {
4837 RadioResponseInfo responseInfo = {};
4838 populateResponseInfo(responseInfo, serial, responseType, e);
4839 Return<void> retStatus
4840 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4841 radioService[slotId]->checkReturnStatus(retStatus);
4843 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4849 int radio::getTTYModeResponse(int slotId,
4850 int responseType, int serial, RIL_Errno e,
4851 void *response, size_t responseLen) {
4853 RLOGD("getTTYModeResponse: serial %d", serial);
4856 if (radioService[slotId]->mRadioResponse != NULL) {
4857 RadioResponseInfo responseInfo = {};
4858 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4859 Return<void> retStatus
4860 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4862 radioService[slotId]->checkReturnStatus(retStatus);
4864 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4870 int radio::setPreferredVoicePrivacyResponse(int slotId,
4871 int responseType, int serial, RIL_Errno e,
4872 void *response, size_t responseLen) {
4874 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
4877 if (radioService[slotId]->mRadioResponse != NULL) {
4878 RadioResponseInfo responseInfo = {};
4879 populateResponseInfo(responseInfo, serial, responseType, e);
4880 Return<void> retStatus
4881 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4883 radioService[slotId]->checkReturnStatus(retStatus);
4885 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4892 int radio::getPreferredVoicePrivacyResponse(int slotId,
4893 int responseType, int serial, RIL_Errno e,
4894 void *response, size_t responseLen) {
4896 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
4899 if (radioService[slotId]->mRadioResponse != NULL) {
4900 RadioResponseInfo responseInfo = {};
4901 populateResponseInfo(responseInfo, serial, responseType, e);
4902 bool enable = false;
4903 int numInts = responseLen / sizeof(int);
4904 if (response == NULL || numInts != 1) {
4905 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
4906 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4908 int *pInt = (int *) response;
4909 enable = pInt[0] == 1 ? true : false;
4911 Return<void> retStatus
4912 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
4913 responseInfo, enable);
4914 radioService[slotId]->checkReturnStatus(retStatus);
4916 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4923 int radio::sendCDMAFeatureCodeResponse(int slotId,
4924 int responseType, int serial, RIL_Errno e,
4925 void *response, size_t responseLen) {
4927 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
4930 if (radioService[slotId]->mRadioResponse != NULL) {
4931 RadioResponseInfo responseInfo = {};
4932 populateResponseInfo(responseInfo, serial, responseType, e);
4933 Return<void> retStatus
4934 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
4935 radioService[slotId]->checkReturnStatus(retStatus);
4937 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
4944 int radio::sendBurstDtmfResponse(int slotId,
4945 int responseType, int serial, RIL_Errno e,
4946 void *response, size_t responseLen) {
4948 RLOGD("sendBurstDtmfResponse: serial %d", serial);
4951 if (radioService[slotId]->mRadioResponse != NULL) {
4952 RadioResponseInfo responseInfo = {};
4953 populateResponseInfo(responseInfo, serial, responseType, e);
4954 Return<void> retStatus
4955 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
4956 radioService[slotId]->checkReturnStatus(retStatus);
4958 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4964 int radio::sendCdmaSmsResponse(int slotId,
4965 int responseType, int serial, RIL_Errno e, void *response,
4966 size_t responseLen) {
4968 RLOGD("sendCdmaSmsResponse: serial %d", serial);
4971 if (radioService[slotId]->mRadioResponse != NULL) {
4972 RadioResponseInfo responseInfo = {};
4973 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4976 Return<void> retStatus
4977 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
4978 radioService[slotId]->checkReturnStatus(retStatus);
4980 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4986 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
4987 int responseType, int serial, RIL_Errno e,
4988 void *response, size_t responseLen) {
4990 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
4993 if (radioService[slotId]->mRadioResponse != NULL) {
4994 RadioResponseInfo responseInfo = {};
4995 populateResponseInfo(responseInfo, serial, responseType, e);
4996 Return<void> retStatus
4997 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
4999 radioService[slotId]->checkReturnStatus(retStatus);
5001 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5008 int radio::getGsmBroadcastConfigResponse(int slotId,
5009 int responseType, int serial, RIL_Errno e,
5010 void *response, size_t responseLen) {
5012 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5015 if (radioService[slotId]->mRadioResponse != NULL) {
5016 RadioResponseInfo responseInfo = {};
5017 populateResponseInfo(responseInfo, serial, responseType, e);
5018 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5020 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5021 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5022 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5024 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5025 configs.resize(num);
5026 for (int i = 0 ; i < num; i++) {
5027 RIL_GSM_BroadcastSmsConfigInfo *resp =
5028 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5029 configs[i].fromServiceId = resp->fromServiceId;
5030 configs[i].toServiceId = resp->toServiceId;
5031 configs[i].fromCodeScheme = resp->fromCodeScheme;
5032 configs[i].toCodeScheme = resp->toCodeScheme;
5033 configs[i].selected = resp->selected == 1 ? true : false;
5037 Return<void> retStatus
5038 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5040 radioService[slotId]->checkReturnStatus(retStatus);
5042 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5049 int radio::setGsmBroadcastConfigResponse(int slotId,
5050 int responseType, int serial, RIL_Errno e,
5051 void *response, size_t responseLen) {
5053 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5056 if (radioService[slotId]->mRadioResponse != NULL) {
5057 RadioResponseInfo responseInfo = {};
5058 populateResponseInfo(responseInfo, serial, responseType, e);
5059 Return<void> retStatus
5060 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5061 radioService[slotId]->checkReturnStatus(retStatus);
5063 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5070 int radio::setGsmBroadcastActivationResponse(int slotId,
5071 int responseType, int serial, RIL_Errno e,
5072 void *response, size_t responseLen) {
5074 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5077 if (radioService[slotId]->mRadioResponse != NULL) {
5078 RadioResponseInfo responseInfo = {};
5079 populateResponseInfo(responseInfo, serial, responseType, e);
5080 Return<void> retStatus
5081 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5083 radioService[slotId]->checkReturnStatus(retStatus);
5085 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5092 int radio::getCdmaBroadcastConfigResponse(int slotId,
5093 int responseType, int serial, RIL_Errno e,
5094 void *response, size_t responseLen) {
5096 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5099 if (radioService[slotId]->mRadioResponse != NULL) {
5100 RadioResponseInfo responseInfo = {};
5101 populateResponseInfo(responseInfo, serial, responseType, e);
5102 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5104 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5105 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5106 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5108 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5109 configs.resize(num);
5110 for (int i = 0 ; i < num; i++) {
5111 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5112 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5113 configs[i].serviceCategory = resp->service_category;
5114 configs[i].language = resp->language;
5115 configs[i].selected = resp->selected == 1 ? true : false;
5119 Return<void> retStatus
5120 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5122 radioService[slotId]->checkReturnStatus(retStatus);
5124 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5131 int radio::setCdmaBroadcastConfigResponse(int slotId,
5132 int responseType, int serial, RIL_Errno e,
5133 void *response, size_t responseLen) {
5135 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5138 if (radioService[slotId]->mRadioResponse != NULL) {
5139 RadioResponseInfo responseInfo = {};
5140 populateResponseInfo(responseInfo, serial, responseType, e);
5141 Return<void> retStatus
5142 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5144 radioService[slotId]->checkReturnStatus(retStatus);
5146 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5153 int radio::setCdmaBroadcastActivationResponse(int slotId,
5154 int responseType, int serial, RIL_Errno e,
5155 void *response, size_t responseLen) {
5157 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5160 if (radioService[slotId]->mRadioResponse != NULL) {
5161 RadioResponseInfo responseInfo = {};
5162 populateResponseInfo(responseInfo, serial, responseType, e);
5163 Return<void> retStatus
5164 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5166 radioService[slotId]->checkReturnStatus(retStatus);
5168 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5175 int radio::getCDMASubscriptionResponse(int slotId,
5176 int responseType, int serial, RIL_Errno e, void *response,
5177 size_t responseLen) {
5179 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5182 if (radioService[slotId]->mRadioResponse != NULL) {
5183 RadioResponseInfo responseInfo = {};
5184 populateResponseInfo(responseInfo, serial, responseType, e);
5186 int numStrings = responseLen / sizeof(char *);
5187 hidl_string emptyString;
5188 if (response == NULL || numStrings != 5) {
5189 RLOGE("getOperatorResponse Invalid response: NULL");
5190 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5191 Return<void> retStatus
5192 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5193 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5194 radioService[slotId]->checkReturnStatus(retStatus);
5196 char **resp = (char **) response;
5197 Return<void> retStatus
5198 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5200 convertCharPtrToHidlString(resp[0]),
5201 convertCharPtrToHidlString(resp[1]),
5202 convertCharPtrToHidlString(resp[2]),
5203 convertCharPtrToHidlString(resp[3]),
5204 convertCharPtrToHidlString(resp[4]));
5205 radioService[slotId]->checkReturnStatus(retStatus);
5208 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5215 int radio::writeSmsToRuimResponse(int slotId,
5216 int responseType, int serial, RIL_Errno e,
5217 void *response, size_t responseLen) {
5219 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5222 if (radioService[slotId]->mRadioResponse != NULL) {
5223 RadioResponseInfo responseInfo = {};
5224 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5225 Return<void> retStatus
5226 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5227 radioService[slotId]->checkReturnStatus(retStatus);
5229 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5235 int radio::deleteSmsOnRuimResponse(int slotId,
5236 int responseType, int serial, RIL_Errno e,
5237 void *response, size_t responseLen) {
5239 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5242 if (radioService[slotId]->mRadioResponse != NULL) {
5243 RadioResponseInfo responseInfo = {};
5244 populateResponseInfo(responseInfo, serial, responseType, e);
5245 Return<void> retStatus
5246 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5247 radioService[slotId]->checkReturnStatus(retStatus);
5249 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5255 int radio::getDeviceIdentityResponse(int slotId,
5256 int responseType, int serial, RIL_Errno e, void *response,
5257 size_t responseLen) {
5259 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5262 if (radioService[slotId]->mRadioResponse != NULL) {
5263 RadioResponseInfo responseInfo = {};
5264 populateResponseInfo(responseInfo, serial, responseType, e);
5266 int numStrings = responseLen / sizeof(char *);
5267 hidl_string emptyString;
5268 if (response == NULL || numStrings != 4) {
5269 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5270 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5271 Return<void> retStatus
5272 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5273 emptyString, emptyString, emptyString, emptyString);
5274 radioService[slotId]->checkReturnStatus(retStatus);
5276 char **resp = (char **) response;
5277 Return<void> retStatus
5278 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5279 convertCharPtrToHidlString(resp[0]),
5280 convertCharPtrToHidlString(resp[1]),
5281 convertCharPtrToHidlString(resp[2]),
5282 convertCharPtrToHidlString(resp[3]));
5283 radioService[slotId]->checkReturnStatus(retStatus);
5286 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5293 int radio::exitEmergencyCallbackModeResponse(int slotId,
5294 int responseType, int serial, RIL_Errno e,
5295 void *response, size_t responseLen) {
5297 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5300 if (radioService[slotId]->mRadioResponse != NULL) {
5301 RadioResponseInfo responseInfo = {};
5302 populateResponseInfo(responseInfo, serial, responseType, e);
5303 Return<void> retStatus
5304 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5306 radioService[slotId]->checkReturnStatus(retStatus);
5308 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5315 int radio::getSmscAddressResponse(int slotId,
5316 int responseType, int serial, RIL_Errno e,
5317 void *response, size_t responseLen) {
5319 RLOGD("getSmscAddressResponse: serial %d", serial);
5322 if (radioService[slotId]->mRadioResponse != NULL) {
5323 RadioResponseInfo responseInfo = {};
5324 populateResponseInfo(responseInfo, serial, responseType, e);
5325 Return<void> retStatus
5326 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5327 convertCharPtrToHidlString((char *) response));
5328 radioService[slotId]->checkReturnStatus(retStatus);
5330 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5336 int radio::setSmscAddressResponse(int slotId,
5337 int responseType, int serial, RIL_Errno e,
5338 void *response, size_t responseLen) {
5340 RLOGD("setSmscAddressResponse: serial %d", serial);
5343 if (radioService[slotId]->mRadioResponse != NULL) {
5344 RadioResponseInfo responseInfo = {};
5345 populateResponseInfo(responseInfo, serial, responseType, e);
5346 Return<void> retStatus
5347 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5348 radioService[slotId]->checkReturnStatus(retStatus);
5350 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5356 int radio::reportSmsMemoryStatusResponse(int slotId,
5357 int responseType, int serial, RIL_Errno e,
5358 void *response, size_t responseLen) {
5360 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5363 if (radioService[slotId]->mRadioResponse != NULL) {
5364 RadioResponseInfo responseInfo = {};
5365 populateResponseInfo(responseInfo, serial, responseType, e);
5366 Return<void> retStatus
5367 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5368 radioService[slotId]->checkReturnStatus(retStatus);
5370 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5377 int radio::reportStkServiceIsRunningResponse(int slotId,
5378 int responseType, int serial, RIL_Errno e,
5379 void *response, size_t responseLen) {
5381 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5384 if (radioService[slotId]->mRadioResponse != NULL) {
5385 RadioResponseInfo responseInfo = {};
5386 populateResponseInfo(responseInfo, serial, responseType, e);
5387 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5388 reportStkServiceIsRunningResponse(responseInfo);
5389 radioService[slotId]->checkReturnStatus(retStatus);
5391 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5398 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5399 int responseType, int serial, RIL_Errno e,
5400 void *response, size_t responseLen) {
5402 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5405 if (radioService[slotId]->mRadioResponse != NULL) {
5406 RadioResponseInfo responseInfo = {};
5407 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5408 Return<void> retStatus
5409 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5410 responseInfo, (CdmaSubscriptionSource) ret);
5411 radioService[slotId]->checkReturnStatus(retStatus);
5413 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5420 int radio::requestIsimAuthenticationResponse(int slotId,
5421 int responseType, int serial, RIL_Errno e,
5422 void *response, size_t responseLen) {
5424 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5427 if (radioService[slotId]->mRadioResponse != NULL) {
5428 RadioResponseInfo responseInfo = {};
5429 populateResponseInfo(responseInfo, serial, responseType, e);
5430 Return<void> retStatus
5431 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5433 convertCharPtrToHidlString((char *) response));
5434 radioService[slotId]->checkReturnStatus(retStatus);
5436 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5443 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5445 int serial, RIL_Errno e, void *response,
5446 size_t responseLen) {
5448 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5451 if (radioService[slotId]->mRadioResponse != NULL) {
5452 RadioResponseInfo responseInfo = {};
5453 populateResponseInfo(responseInfo, serial, responseType, e);
5454 Return<void> retStatus
5455 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5457 radioService[slotId]->checkReturnStatus(retStatus);
5459 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5466 int radio::sendEnvelopeWithStatusResponse(int slotId,
5467 int responseType, int serial, RIL_Errno e, void *response,
5468 size_t responseLen) {
5470 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5473 if (radioService[slotId]->mRadioResponse != NULL) {
5474 RadioResponseInfo responseInfo = {};
5475 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5476 response, responseLen);
5478 Return<void> retStatus
5479 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5481 radioService[slotId]->checkReturnStatus(retStatus);
5483 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5490 int radio::getVoiceRadioTechnologyResponse(int slotId,
5491 int responseType, int serial, RIL_Errno e,
5492 void *response, size_t responseLen) {
5494 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5497 if (radioService[slotId]->mRadioResponse != NULL) {
5498 RadioResponseInfo responseInfo = {};
5499 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5500 Return<void> retStatus
5501 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5502 responseInfo, (RadioTechnology) ret);
5503 radioService[slotId]->checkReturnStatus(retStatus);
5505 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5512 int radio::getCellInfoListResponse(int slotId,
5514 int serial, RIL_Errno e, void *response,
5515 size_t responseLen) {
5517 RLOGD("getCellInfoListResponse: serial %d", serial);
5520 if (radioService[slotId]->mRadioResponse != NULL) {
5521 RadioResponseInfo responseInfo = {};
5522 populateResponseInfo(responseInfo, serial, responseType, e);
5524 hidl_vec<CellInfo> ret;
5525 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5526 RLOGE("getCellInfoListResponse: Invalid response");
5527 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5529 convertRilCellInfoListToHal(response, responseLen, ret);
5532 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5534 radioService[slotId]->checkReturnStatus(retStatus);
5536 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5542 int radio::setCellInfoListRateResponse(int slotId,
5544 int serial, RIL_Errno e, void *response,
5545 size_t responseLen) {
5547 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5550 if (radioService[slotId]->mRadioResponse != NULL) {
5551 RadioResponseInfo responseInfo = {};
5552 populateResponseInfo(responseInfo, serial, responseType, e);
5553 Return<void> retStatus
5554 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5555 radioService[slotId]->checkReturnStatus(retStatus);
5557 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5564 int radio::setInitialAttachApnResponse(int slotId,
5565 int responseType, int serial, RIL_Errno e,
5566 void *response, size_t responseLen) {
5568 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5571 if (radioService[slotId]->mRadioResponse != NULL) {
5572 RadioResponseInfo responseInfo = {};
5573 populateResponseInfo(responseInfo, serial, responseType, e);
5574 Return<void> retStatus
5575 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5576 radioService[slotId]->checkReturnStatus(retStatus);
5578 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5585 int radio::getImsRegistrationStateResponse(int slotId,
5586 int responseType, int serial, RIL_Errno e,
5587 void *response, size_t responseLen) {
5589 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5592 if (radioService[slotId]->mRadioResponse != NULL) {
5593 RadioResponseInfo responseInfo = {};
5594 populateResponseInfo(responseInfo, serial, responseType, e);
5595 bool isRegistered = false;
5597 int numInts = responseLen / sizeof(int);
5598 if (response == NULL || numInts != 2) {
5599 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5600 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5602 int *pInt = (int *) response;
5603 isRegistered = pInt[0] == 1 ? true : false;
5604 ratFamily = pInt[1];
5606 Return<void> retStatus
5607 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5608 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5609 radioService[slotId]->checkReturnStatus(retStatus);
5611 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5618 int radio::sendImsSmsResponse(int slotId,
5619 int responseType, int serial, RIL_Errno e, void *response,
5620 size_t responseLen) {
5622 RLOGD("sendImsSmsResponse: serial %d", serial);
5625 if (radioService[slotId]->mRadioResponse != NULL) {
5626 RadioResponseInfo responseInfo = {};
5627 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5630 Return<void> retStatus
5631 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5632 radioService[slotId]->checkReturnStatus(retStatus);
5634 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5640 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5641 int responseType, int serial, RIL_Errno e,
5642 void *response, size_t responseLen) {
5644 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5647 if (radioService[slotId]->mRadioResponse != NULL) {
5648 RadioResponseInfo responseInfo = {};
5649 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5652 Return<void> retStatus
5653 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5654 responseInfo, result);
5655 radioService[slotId]->checkReturnStatus(retStatus);
5657 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5664 int radio::iccOpenLogicalChannelResponse(int slotId,
5665 int responseType, int serial, RIL_Errno e, void *response,
5666 size_t responseLen) {
5668 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5671 if (radioService[slotId]->mRadioResponse != NULL) {
5672 RadioResponseInfo responseInfo = {};
5673 populateResponseInfo(responseInfo, serial, responseType, e);
5675 hidl_vec<int8_t> selectResponse;
5676 int numInts = responseLen / sizeof(int);
5677 if (response == NULL || responseLen % sizeof(int) != 0) {
5678 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5679 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5681 int *pInt = (int *) response;
5682 channelId = pInt[0];
5683 selectResponse.resize(numInts - 1);
5684 for (int i = 1; i < numInts; i++) {
5685 selectResponse[i - 1] = (int8_t) pInt[i];
5688 Return<void> retStatus
5689 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5690 channelId, selectResponse);
5691 radioService[slotId]->checkReturnStatus(retStatus);
5693 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5700 int radio::iccCloseLogicalChannelResponse(int slotId,
5701 int responseType, int serial, RIL_Errno e,
5702 void *response, size_t responseLen) {
5704 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5707 if (radioService[slotId]->mRadioResponse != NULL) {
5708 RadioResponseInfo responseInfo = {};
5709 populateResponseInfo(responseInfo, serial, responseType, e);
5710 Return<void> retStatus
5711 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5713 radioService[slotId]->checkReturnStatus(retStatus);
5715 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5722 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5723 int responseType, int serial, RIL_Errno e,
5724 void *response, size_t responseLen) {
5726 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5729 if (radioService[slotId]->mRadioResponse != NULL) {
5730 RadioResponseInfo responseInfo = {};
5731 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5734 Return<void> retStatus
5735 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5736 responseInfo, result);
5737 radioService[slotId]->checkReturnStatus(retStatus);
5739 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5746 int radio::nvReadItemResponse(int slotId,
5747 int responseType, int serial, RIL_Errno e,
5748 void *response, size_t responseLen) {
5750 RLOGD("nvReadItemResponse: serial %d", serial);
5753 if (radioService[slotId]->mRadioResponse != NULL) {
5754 RadioResponseInfo responseInfo = {};
5755 populateResponseInfo(responseInfo, serial, responseType, e);
5756 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5758 convertCharPtrToHidlString((char *) response));
5759 radioService[slotId]->checkReturnStatus(retStatus);
5761 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5767 int radio::nvWriteItemResponse(int slotId,
5768 int responseType, int serial, RIL_Errno e,
5769 void *response, size_t responseLen) {
5771 RLOGD("nvWriteItemResponse: serial %d", serial);
5774 if (radioService[slotId]->mRadioResponse != NULL) {
5775 RadioResponseInfo responseInfo = {};
5776 populateResponseInfo(responseInfo, serial, responseType, e);
5777 Return<void> retStatus
5778 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5779 radioService[slotId]->checkReturnStatus(retStatus);
5781 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5787 int radio::nvWriteCdmaPrlResponse(int slotId,
5788 int responseType, int serial, RIL_Errno e,
5789 void *response, size_t responseLen) {
5791 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5794 if (radioService[slotId]->mRadioResponse != NULL) {
5795 RadioResponseInfo responseInfo = {};
5796 populateResponseInfo(responseInfo, serial, responseType, e);
5797 Return<void> retStatus
5798 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5799 radioService[slotId]->checkReturnStatus(retStatus);
5801 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5807 int radio::nvResetConfigResponse(int slotId,
5808 int responseType, int serial, RIL_Errno e,
5809 void *response, size_t responseLen) {
5811 RLOGD("nvResetConfigResponse: serial %d", serial);
5814 if (radioService[slotId]->mRadioResponse != NULL) {
5815 RadioResponseInfo responseInfo = {};
5816 populateResponseInfo(responseInfo, serial, responseType, e);
5817 Return<void> retStatus
5818 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5819 radioService[slotId]->checkReturnStatus(retStatus);
5821 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5827 int radio::setUiccSubscriptionResponse(int slotId,
5828 int responseType, int serial, RIL_Errno e,
5829 void *response, size_t responseLen) {
5831 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5834 if (radioService[slotId]->mRadioResponse != NULL) {
5835 RadioResponseInfo responseInfo = {};
5836 populateResponseInfo(responseInfo, serial, responseType, e);
5837 Return<void> retStatus
5838 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5839 radioService[slotId]->checkReturnStatus(retStatus);
5841 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5848 int radio::setDataAllowedResponse(int slotId,
5849 int responseType, int serial, RIL_Errno e,
5850 void *response, size_t responseLen) {
5852 RLOGD("setDataAllowedResponse: serial %d", serial);
5855 if (radioService[slotId]->mRadioResponse != NULL) {
5856 RadioResponseInfo responseInfo = {};
5857 populateResponseInfo(responseInfo, serial, responseType, e);
5858 Return<void> retStatus
5859 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5860 radioService[slotId]->checkReturnStatus(retStatus);
5862 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5868 int radio::getHardwareConfigResponse(int slotId,
5869 int responseType, int serial, RIL_Errno e,
5870 void *response, size_t responseLen) {
5872 RLOGD("getHardwareConfigResponse: serial %d", serial);
5875 if (radioService[slotId]->mRadioResponse != NULL) {
5876 RadioResponseInfo responseInfo = {};
5877 populateResponseInfo(responseInfo, serial, responseType, e);
5879 hidl_vec<HardwareConfig> result;
5880 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
5881 RLOGE("hardwareConfigChangedInd: invalid response");
5882 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5884 convertRilHardwareConfigListToHal(response, responseLen, result);
5887 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
5888 responseInfo, result);
5889 radioService[slotId]->checkReturnStatus(retStatus);
5891 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5897 int radio::requestIccSimAuthenticationResponse(int slotId,
5898 int responseType, int serial, RIL_Errno e,
5899 void *response, size_t responseLen) {
5901 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
5904 if (radioService[slotId]->mRadioResponse != NULL) {
5905 RadioResponseInfo responseInfo = {};
5906 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5909 Return<void> retStatus
5910 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
5911 responseInfo, result);
5912 radioService[slotId]->checkReturnStatus(retStatus);
5914 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
5921 int radio::setDataProfileResponse(int slotId,
5922 int responseType, int serial, RIL_Errno e,
5923 void *response, size_t responseLen) {
5925 RLOGD("setDataProfileResponse: serial %d", serial);
5928 if (radioService[slotId]->mRadioResponse != NULL) {
5929 RadioResponseInfo responseInfo = {};
5930 populateResponseInfo(responseInfo, serial, responseType, e);
5931 Return<void> retStatus
5932 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
5933 radioService[slotId]->checkReturnStatus(retStatus);
5935 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5941 int radio::requestShutdownResponse(int slotId,
5942 int responseType, int serial, RIL_Errno e,
5943 void *response, size_t responseLen) {
5945 RLOGD("requestShutdownResponse: serial %d", serial);
5948 if (radioService[slotId]->mRadioResponse != NULL) {
5949 RadioResponseInfo responseInfo = {};
5950 populateResponseInfo(responseInfo, serial, responseType, e);
5951 Return<void> retStatus
5952 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
5953 radioService[slotId]->checkReturnStatus(retStatus);
5955 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5961 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
5962 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
5963 populateResponseInfo(responseInfo, serial, responseType, e);
5965 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
5966 RLOGE("responseRadioCapability: Invalid response");
5967 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5968 rc.logicalModemUuid = hidl_string();
5970 convertRilRadioCapabilityToHal(response, responseLen, rc);
5974 int radio::getRadioCapabilityResponse(int slotId,
5975 int responseType, int serial, RIL_Errno e,
5976 void *response, size_t responseLen) {
5978 RLOGD("getRadioCapabilityResponse: serial %d", serial);
5981 if (radioService[slotId]->mRadioResponse != NULL) {
5982 RadioResponseInfo responseInfo = {};
5983 RadioCapability result = {};
5984 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
5986 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
5987 responseInfo, result);
5988 radioService[slotId]->checkReturnStatus(retStatus);
5990 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5996 int radio::setRadioCapabilityResponse(int slotId,
5997 int responseType, int serial, RIL_Errno e,
5998 void *response, size_t responseLen) {
6000 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6003 if (radioService[slotId]->mRadioResponse != NULL) {
6004 RadioResponseInfo responseInfo = {};
6005 RadioCapability result = {};
6006 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6008 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6009 responseInfo, result);
6010 radioService[slotId]->checkReturnStatus(retStatus);
6012 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6018 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6019 RIL_Errno e, void *response, size_t responseLen) {
6020 populateResponseInfo(responseInfo, serial, responseType, e);
6021 LceStatusInfo result = {};
6023 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6024 RLOGE("Invalid response: NULL");
6025 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6027 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6028 result.lceStatus = (LceStatus) resp->lce_status;
6029 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6034 int radio::startLceServiceResponse(int slotId,
6035 int responseType, int serial, RIL_Errno e,
6036 void *response, size_t responseLen) {
6038 RLOGD("startLceServiceResponse: serial %d", serial);
6041 if (radioService[slotId]->mRadioResponse != NULL) {
6042 RadioResponseInfo responseInfo = {};
6043 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6044 response, responseLen);
6046 Return<void> retStatus
6047 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6049 radioService[slotId]->checkReturnStatus(retStatus);
6051 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6057 int radio::stopLceServiceResponse(int slotId,
6058 int responseType, int serial, RIL_Errno e,
6059 void *response, size_t responseLen) {
6061 RLOGD("stopLceServiceResponse: serial %d", serial);
6064 if (radioService[slotId]->mRadioResponse != NULL) {
6065 RadioResponseInfo responseInfo = {};
6066 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6067 response, responseLen);
6069 Return<void> retStatus
6070 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6072 radioService[slotId]->checkReturnStatus(retStatus);
6074 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6080 int radio::pullLceDataResponse(int slotId,
6081 int responseType, int serial, RIL_Errno e,
6082 void *response, size_t responseLen) {
6084 RLOGD("pullLceDataResponse: serial %d", serial);
6087 if (radioService[slotId]->mRadioResponse != NULL) {
6088 RadioResponseInfo responseInfo = {};
6089 populateResponseInfo(responseInfo, serial, responseType, e);
6091 LceDataInfo result = {};
6092 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6093 RLOGE("pullLceDataResponse: Invalid response");
6094 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6096 convertRilLceDataInfoToHal(response, responseLen, result);
6099 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6100 responseInfo, result);
6101 radioService[slotId]->checkReturnStatus(retStatus);
6103 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6109 int radio::getModemActivityInfoResponse(int slotId,
6110 int responseType, int serial, RIL_Errno e,
6111 void *response, size_t responseLen) {
6113 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6116 if (radioService[slotId]->mRadioResponse != NULL) {
6117 RadioResponseInfo responseInfo = {};
6118 populateResponseInfo(responseInfo, serial, responseType, e);
6119 ActivityStatsInfo info;
6120 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6121 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6122 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6124 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6125 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6126 info.idleModeTimeMs = resp->idle_mode_time_ms;
6127 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6128 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6130 info.rxModeTimeMs = resp->rx_mode_time_ms;
6133 Return<void> retStatus
6134 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6136 radioService[slotId]->checkReturnStatus(retStatus);
6138 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6145 int radio::setAllowedCarriersResponse(int slotId,
6146 int responseType, int serial, RIL_Errno e,
6147 void *response, size_t responseLen) {
6149 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6152 if (radioService[slotId]->mRadioResponse != NULL) {
6153 RadioResponseInfo responseInfo = {};
6154 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6155 Return<void> retStatus
6156 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6158 radioService[slotId]->checkReturnStatus(retStatus);
6160 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6167 int radio::getAllowedCarriersResponse(int slotId,
6168 int responseType, int serial, RIL_Errno e,
6169 void *response, size_t responseLen) {
6171 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6174 if (radioService[slotId]->mRadioResponse != NULL) {
6175 RadioResponseInfo responseInfo = {};
6176 populateResponseInfo(responseInfo, serial, responseType, e);
6177 CarrierRestrictions carrierInfo = {};
6178 bool allAllowed = true;
6179 if (response == NULL || responseLen != sizeof(RIL_CarrierRestrictions)) {
6180 RLOGE("getAllowedCarriersResponse Invalid response: NULL");
6181 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6183 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6184 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6188 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6189 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6190 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6191 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6192 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6193 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6194 carrierInfo.allowedCarriers[i].matchData =
6195 convertCharPtrToHidlString(carrier->match_data);
6198 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6199 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6200 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6201 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6202 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6203 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6204 carrierInfo.excludedCarriers[i].matchData =
6205 convertCharPtrToHidlString(carrier->match_data);
6209 Return<void> retStatus
6210 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6211 allAllowed, carrierInfo);
6212 radioService[slotId]->checkReturnStatus(retStatus);
6214 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6221 int radio::sendDeviceStateResponse(int slotId,
6222 int responseType, int serial, RIL_Errno e,
6223 void *response, size_t responselen) {
6225 RLOGD("sendDeviceStateResponse: serial %d", serial);
6228 if (radioService[slotId]->mRadioResponse != NULL) {
6229 RadioResponseInfo responseInfo = {};
6230 populateResponseInfo(responseInfo, serial, responseType, e);
6231 Return<void> retStatus
6232 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6233 radioService[slotId]->checkReturnStatus(retStatus);
6235 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6241 int radio::setIndicationFilterResponse(int slotId,
6242 int responseType, int serial, RIL_Errno e,
6243 void *response, size_t responselen) {
6245 RLOGD("setIndicationFilterResponse: serial %d", serial);
6248 if (radioService[slotId]->mRadioResponse != NULL) {
6249 RadioResponseInfo responseInfo = {};
6250 populateResponseInfo(responseInfo, serial, responseType, e);
6251 Return<void> retStatus
6252 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6253 radioService[slotId]->checkReturnStatus(retStatus);
6255 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6263 int radio::setSimCardPowerResponse(int slotId,
6264 int responseType, int serial, RIL_Errno e,
6265 void *response, size_t responseLen) {
6267 RLOGD("setSimCardPowerResponse: serial %d", serial);
6270 if (radioService[slotId]->mRadioResponse != NULL) {
6271 RadioResponseInfo responseInfo = {};
6272 populateResponseInfo(responseInfo, serial, responseType, e);
6273 Return<void> retStatus
6274 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6275 radioService[slotId]->checkReturnStatus(retStatus);
6277 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6283 int radio::sendRequestRawResponse(int slotId,
6284 int responseType, int serial, RIL_Errno e,
6285 void *response, size_t responseLen) {
6287 RLOGD("sendRequestRawResponse: serial %d", serial);
6290 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6291 RadioResponseInfo responseInfo = {};
6292 populateResponseInfo(responseInfo, serial, responseType, e);
6293 hidl_vec<uint8_t> data;
6295 if (response == NULL) {
6296 RLOGE("sendRequestRawResponse: Invalid response");
6297 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6299 data.setToExternal((uint8_t *) response, responseLen);
6301 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6302 sendRequestRawResponse(responseInfo, data);
6303 checkReturnStatus(slotId, retStatus, false);
6305 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6312 int radio::sendRequestStringsResponse(int slotId,
6313 int responseType, int serial, RIL_Errno e,
6314 void *response, size_t responseLen) {
6316 RLOGD("sendRequestStringsResponse: serial %d", serial);
6319 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6320 RadioResponseInfo responseInfo = {};
6321 populateResponseInfo(responseInfo, serial, responseType, e);
6322 hidl_vec<hidl_string> data;
6324 if (response == NULL || responseLen % sizeof(char *) != 0) {
6325 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6326 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6328 char **resp = (char **) response;
6329 int numStrings = responseLen / sizeof(char *);
6330 data.resize(numStrings);
6331 for (int i = 0; i < numStrings; i++) {
6332 data[i] = convertCharPtrToHidlString(resp[i]);
6335 Return<void> retStatus
6336 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6337 responseInfo, data);
6338 checkReturnStatus(slotId, retStatus, false);
6340 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6347 // Radio Indication functions
6349 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6350 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6351 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6354 int radio::radioStateChangedInd(int slotId,
6355 int indicationType, int token, RIL_Errno e, void *response,
6356 size_t responseLen) {
6357 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6358 RadioState radioState = (RadioState) s_vendorFunctions->onStateRequest();
6359 RLOGD("radioStateChangedInd: radioState %d", radioState);
6360 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6361 convertIntToRadioIndicationType(indicationType), radioState);
6362 radioService[slotId]->checkReturnStatus(retStatus);
6364 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6370 int radio::callStateChangedInd(int slotId,
6371 int indicationType, int token, RIL_Errno e, void *response,
6372 size_t responseLen) {
6373 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6375 RLOGD("callStateChangedInd");
6377 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6378 convertIntToRadioIndicationType(indicationType));
6379 radioService[slotId]->checkReturnStatus(retStatus);
6381 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6387 int radio::networkStateChangedInd(int slotId,
6388 int indicationType, int token, RIL_Errno e, void *response,
6389 size_t responseLen) {
6390 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6392 RLOGD("networkStateChangedInd");
6394 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6395 convertIntToRadioIndicationType(indicationType));
6396 radioService[slotId]->checkReturnStatus(retStatus);
6398 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6405 uint8_t hexCharToInt(uint8_t c) {
6406 if (c >= '0' && c <= '9') return (c - '0');
6407 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6408 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6410 return INVALID_HEX_CHAR;
6413 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6414 if (responseLen % 2 != 0) {
6418 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6419 if (bytes == NULL) {
6420 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6423 uint8_t *hexString = (uint8_t *)response;
6425 for (size_t i = 0; i < responseLen; i += 2) {
6426 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6427 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6429 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6430 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6431 hexString[i], hexString[i + 1]);
6435 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6441 int radio::newSmsInd(int slotId, int indicationType,
6442 int token, RIL_Errno e, void *response, size_t responseLen) {
6443 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6444 if (response == NULL || responseLen == 0) {
6445 RLOGE("newSmsInd: invalid response");
6449 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6450 if (bytes == NULL) {
6451 RLOGE("newSmsInd: convertHexStringToBytes failed");
6455 hidl_vec<uint8_t> pdu;
6456 pdu.setToExternal(bytes, responseLen/2);
6460 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6461 convertIntToRadioIndicationType(indicationType), pdu);
6462 radioService[slotId]->checkReturnStatus(retStatus);
6465 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6471 int radio::newSmsStatusReportInd(int slotId,
6472 int indicationType, int token, RIL_Errno e, void *response,
6473 size_t responseLen) {
6474 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6475 if (response == NULL || responseLen == 0) {
6476 RLOGE("newSmsStatusReportInd: invalid response");
6480 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6481 if (bytes == NULL) {
6482 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6486 hidl_vec<uint8_t> pdu;
6487 pdu.setToExternal(bytes, responseLen/2);
6489 RLOGD("newSmsStatusReportInd");
6491 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6492 convertIntToRadioIndicationType(indicationType), pdu);
6493 radioService[slotId]->checkReturnStatus(retStatus);
6496 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6502 int radio::newSmsOnSimInd(int slotId, int indicationType,
6503 int token, RIL_Errno e, void *response, size_t responseLen) {
6504 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6505 if (response == NULL || responseLen != sizeof(int)) {
6506 RLOGE("newSmsOnSimInd: invalid response");
6509 int32_t recordNumber = ((int32_t *) response)[0];
6511 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6513 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6514 convertIntToRadioIndicationType(indicationType), recordNumber);
6515 radioService[slotId]->checkReturnStatus(retStatus);
6517 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6523 int radio::onUssdInd(int slotId, int indicationType,
6524 int token, RIL_Errno e, void *response, size_t responseLen) {
6525 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6526 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6527 RLOGE("onUssdInd: invalid response");
6530 char **strings = (char **) response;
6531 char *mode = strings[0];
6532 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6533 UssdModeType modeType = (UssdModeType) atoi(mode);
6535 RLOGD("onUssdInd: mode %s", mode);
6537 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6538 convertIntToRadioIndicationType(indicationType), modeType, msg);
6539 radioService[slotId]->checkReturnStatus(retStatus);
6541 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6547 int radio::nitzTimeReceivedInd(int slotId,
6548 int indicationType, int token, RIL_Errno e, void *response,
6549 size_t responseLen) {
6550 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6551 if (response == NULL || responseLen == 0) {
6552 RLOGE("nitzTimeReceivedInd: invalid response");
6555 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6556 int64_t timeReceived = android::elapsedRealtime();
6558 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6561 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6562 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6563 radioService[slotId]->checkReturnStatus(retStatus);
6565 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6572 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6573 SignalStrength& signalStrength) {
6574 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6576 // Fixup LTE for backwards compatibility
6577 // signalStrength: -1 -> 99
6578 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6579 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6581 // rsrp: -1 -> INT_MAX all other negative value to positive.
6583 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6584 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6585 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6586 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6588 // rsrq: -1 -> INT_MAX
6589 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6590 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6592 // Not remapping rssnr is already using INT_MAX
6593 // cqi: -1 -> INT_MAX
6594 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6595 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6598 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6599 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6600 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6601 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6602 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6603 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6604 signalStrength.evdo.signalNoiseRatio =
6605 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6606 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6607 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6608 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6609 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6610 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6611 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6612 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6615 int radio::currentSignalStrengthInd(int slotId,
6616 int indicationType, int token, RIL_Errno e,
6617 void *response, size_t responseLen) {
6618 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6619 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
6620 RLOGE("currentSignalStrengthInd: invalid response");
6624 SignalStrength signalStrength = {};
6625 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6628 RLOGD("currentSignalStrengthInd");
6630 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6631 convertIntToRadioIndicationType(indicationType), signalStrength);
6632 radioService[slotId]->checkReturnStatus(retStatus);
6634 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6641 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6642 SetupDataCallResult& dcResult) {
6643 dcResult.status = (DataCallFailCause) dcResponse->status;
6644 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6645 dcResult.cid = dcResponse->cid;
6646 dcResult.active = dcResponse->active;
6647 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6648 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6649 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6650 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6651 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6652 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6653 dcResult.mtu = dcResponse->mtu;
6656 void convertRilDataCallListToHal(void *response, size_t responseLen,
6657 hidl_vec<SetupDataCallResult>& dcResultList) {
6658 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6660 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6661 dcResultList.resize(num);
6662 for (int i = 0; i < num; i++) {
6663 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6667 int radio::dataCallListChangedInd(int slotId,
6668 int indicationType, int token, RIL_Errno e, void *response,
6669 size_t responseLen) {
6670 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6671 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
6672 RLOGE("dataCallListChangedInd: invalid response");
6675 hidl_vec<SetupDataCallResult> dcList;
6676 convertRilDataCallListToHal(response, responseLen, dcList);
6678 RLOGD("dataCallListChangedInd");
6680 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
6681 convertIntToRadioIndicationType(indicationType), dcList);
6682 radioService[slotId]->checkReturnStatus(retStatus);
6684 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6690 int radio::suppSvcNotifyInd(int slotId, int indicationType,
6691 int token, RIL_Errno e, void *response, size_t responseLen) {
6692 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6693 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
6694 RLOGE("suppSvcNotifyInd: invalid response");
6698 SuppSvcNotification suppSvc = {};
6699 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6700 suppSvc.isMT = ssn->notificationType;
6701 suppSvc.code = ssn->code;
6702 suppSvc.index = ssn->index;
6703 suppSvc.type = ssn->type;
6704 suppSvc.number = convertCharPtrToHidlString(ssn->number);
6707 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
6708 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
6710 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
6711 convertIntToRadioIndicationType(indicationType), suppSvc);
6712 radioService[slotId]->checkReturnStatus(retStatus);
6714 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6720 int radio::stkSessionEndInd(int slotId, int indicationType,
6721 int token, RIL_Errno e, void *response, size_t responseLen) {
6722 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6724 RLOGD("stkSessionEndInd");
6726 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
6727 convertIntToRadioIndicationType(indicationType));
6728 radioService[slotId]->checkReturnStatus(retStatus);
6730 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
6736 int radio::stkProactiveCommandInd(int slotId,
6737 int indicationType, int token, RIL_Errno e, void *response,
6738 size_t responseLen) {
6739 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6740 if (response == NULL || responseLen == 0) {
6741 RLOGE("stkProactiveCommandInd: invalid response");
6745 RLOGD("stkProactiveCommandInd");
6747 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
6748 convertIntToRadioIndicationType(indicationType),
6749 convertCharPtrToHidlString((char *) response));
6750 radioService[slotId]->checkReturnStatus(retStatus);
6752 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
6758 int radio::stkEventNotifyInd(int slotId, int indicationType,
6759 int token, RIL_Errno e, void *response, size_t responseLen) {
6760 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6761 if (response == NULL || responseLen == 0) {
6762 RLOGE("stkEventNotifyInd: invalid response");
6766 RLOGD("stkEventNotifyInd");
6768 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
6769 convertIntToRadioIndicationType(indicationType),
6770 convertCharPtrToHidlString((char *) response));
6771 radioService[slotId]->checkReturnStatus(retStatus);
6773 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6779 int radio::stkCallSetupInd(int slotId, int indicationType,
6780 int token, RIL_Errno e, void *response, size_t responseLen) {
6781 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6782 if (response == NULL || responseLen != sizeof(int)) {
6783 RLOGE("stkCallSetupInd: invalid response");
6786 int32_t timeout = ((int32_t *) response)[0];
6788 RLOGD("stkCallSetupInd: timeout %d", timeout);
6790 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
6791 convertIntToRadioIndicationType(indicationType), timeout);
6792 radioService[slotId]->checkReturnStatus(retStatus);
6794 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
6800 int radio::simSmsStorageFullInd(int slotId,
6801 int indicationType, int token, RIL_Errno e, void *response,
6802 size_t responseLen) {
6803 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6805 RLOGD("simSmsStorageFullInd");
6807 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
6808 convertIntToRadioIndicationType(indicationType));
6809 radioService[slotId]->checkReturnStatus(retStatus);
6811 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
6817 int radio::simRefreshInd(int slotId, int indicationType,
6818 int token, RIL_Errno e, void *response, size_t responseLen) {
6819 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6820 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
6821 RLOGE("simRefreshInd: invalid response");
6825 SimRefreshResult refreshResult = {};
6826 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
6827 refreshResult.type =
6828 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
6829 refreshResult.efId = simRefreshResponse->ef_id;
6830 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
6833 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
6835 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
6836 convertIntToRadioIndicationType(indicationType), refreshResult);
6837 radioService[slotId]->checkReturnStatus(retStatus);
6839 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
6845 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
6846 CdmaSignalInfoRecord& record) {
6847 record.isPresent = signalInfoRecord->isPresent;
6848 record.signalType = signalInfoRecord->signalType;
6849 record.alertPitch = signalInfoRecord->alertPitch;
6850 record.signal = signalInfoRecord->signal;
6853 int radio::callRingInd(int slotId, int indicationType,
6854 int token, RIL_Errno e, void *response, size_t responseLen) {
6855 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6857 CdmaSignalInfoRecord record = {};
6858 if (response == NULL || responseLen == 0) {
6862 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
6863 RLOGE("callRingInd: invalid response");
6866 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
6870 RLOGD("callRingInd: isGsm %d", isGsm);
6872 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
6873 convertIntToRadioIndicationType(indicationType), isGsm, record);
6874 radioService[slotId]->checkReturnStatus(retStatus);
6876 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
6882 int radio::simStatusChangedInd(int slotId,
6883 int indicationType, int token, RIL_Errno e, void *response,
6884 size_t responseLen) {
6885 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6887 RLOGD("simStatusChangedInd");
6889 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
6890 convertIntToRadioIndicationType(indicationType));
6891 radioService[slotId]->checkReturnStatus(retStatus);
6893 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6899 int radio::cdmaNewSmsInd(int slotId, int indicationType,
6900 int token, RIL_Errno e, void *response, size_t responseLen) {
6901 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6902 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
6903 RLOGE("cdmaNewSmsInd: invalid response");
6907 CdmaSmsMessage msg = {};
6908 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
6909 msg.teleserviceId = rilMsg->uTeleserviceID;
6910 msg.isServicePresent = rilMsg->bIsServicePresent;
6911 msg.serviceCategory = rilMsg->uServicecategory;
6912 msg.address.digitMode =
6913 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
6914 msg.address.numberMode =
6915 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
6916 msg.address.numberType =
6917 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
6918 msg.address.numberPlan =
6919 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
6921 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
6922 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
6924 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
6925 rilMsg->sSubAddress.subaddressType;
6926 msg.subAddress.odd = rilMsg->sSubAddress.odd;
6928 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
6929 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
6931 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
6932 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
6935 RLOGD("cdmaNewSmsInd");
6937 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
6938 convertIntToRadioIndicationType(indicationType), msg);
6939 radioService[slotId]->checkReturnStatus(retStatus);
6941 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6947 int radio::newBroadcastSmsInd(int slotId,
6948 int indicationType, int token, RIL_Errno e, void *response,
6949 size_t responseLen) {
6950 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6951 if (response == NULL || responseLen == 0) {
6952 RLOGE("newBroadcastSmsInd: invalid response");
6956 hidl_vec<uint8_t> data;
6957 data.setToExternal((uint8_t *) response, responseLen);
6959 RLOGD("newBroadcastSmsInd");
6961 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
6962 convertIntToRadioIndicationType(indicationType), data);
6963 radioService[slotId]->checkReturnStatus(retStatus);
6965 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6971 int radio::cdmaRuimSmsStorageFullInd(int slotId,
6972 int indicationType, int token, RIL_Errno e, void *response,
6973 size_t responseLen) {
6974 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6976 RLOGD("cdmaRuimSmsStorageFullInd");
6978 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
6979 convertIntToRadioIndicationType(indicationType));
6980 radioService[slotId]->checkReturnStatus(retStatus);
6982 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
6989 int radio::restrictedStateChangedInd(int slotId,
6990 int indicationType, int token, RIL_Errno e, void *response,
6991 size_t responseLen) {
6992 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6993 if (response == NULL || responseLen != sizeof(int)) {
6994 RLOGE("restrictedStateChangedInd: invalid response");
6997 int32_t state = ((int32_t *) response)[0];
6999 RLOGD("restrictedStateChangedInd: state %d", state);
7001 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7002 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7003 radioService[slotId]->checkReturnStatus(retStatus);
7005 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7012 int radio::enterEmergencyCallbackModeInd(int slotId,
7013 int indicationType, int token, RIL_Errno e, void *response,
7014 size_t responseLen) {
7015 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7017 RLOGD("enterEmergencyCallbackModeInd");
7019 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7020 convertIntToRadioIndicationType(indicationType));
7021 radioService[slotId]->checkReturnStatus(retStatus);
7023 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7030 int radio::cdmaCallWaitingInd(int slotId,
7031 int indicationType, int token, RIL_Errno e, void *response,
7032 size_t responseLen) {
7033 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7034 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7035 RLOGE("cdmaCallWaitingInd: invalid response");
7039 CdmaCallWaiting callWaitingRecord = {};
7040 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7041 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7042 callWaitingRecord.numberPresentation =
7043 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7044 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7045 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7046 callWaitingRecord.signalInfoRecord);
7047 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7048 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7051 RLOGD("cdmaCallWaitingInd");
7053 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7054 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7055 radioService[slotId]->checkReturnStatus(retStatus);
7057 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7063 int radio::cdmaOtaProvisionStatusInd(int slotId,
7064 int indicationType, int token, RIL_Errno e, void *response,
7065 size_t responseLen) {
7066 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7067 if (response == NULL || responseLen != sizeof(int)) {
7068 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7071 int32_t status = ((int32_t *) response)[0];
7073 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7075 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7076 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7077 radioService[slotId]->checkReturnStatus(retStatus);
7079 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7086 int radio::cdmaInfoRecInd(int slotId,
7087 int indicationType, int token, RIL_Errno e, void *response,
7088 size_t responseLen) {
7089 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7090 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7091 RLOGE("cdmaInfoRecInd: invalid response");
7095 CdmaInformationRecords records = {};
7096 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7098 char* string8 = NULL;
7099 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7100 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7101 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7102 "additional ones", recordsRil->numberOfInfoRecs,
7103 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7105 records.infoRec.resize(num);
7106 for (int i = 0 ; i < num ; i++) {
7107 CdmaInformationRecord *record = &records.infoRec[i];
7108 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7109 record->name = (CdmaInfoRecName) infoRec->name;
7110 // All vectors should be size 0 except one which will be size 1. Set everything to
7111 // size 0 initially.
7112 record->display.resize(0);
7113 record->number.resize(0);
7114 record->signal.resize(0);
7115 record->redir.resize(0);
7116 record->lineCtrl.resize(0);
7117 record->clir.resize(0);
7118 record->audioCtrl.resize(0);
7119 switch (infoRec->name) {
7120 case RIL_CDMA_DISPLAY_INFO_REC:
7121 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7122 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7123 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7124 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7125 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7128 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7129 if (string8 == NULL) {
7130 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7131 "responseCdmaInformationRecords");
7134 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7135 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7137 record->display.resize(1);
7138 record->display[0].alphaBuf = string8;
7144 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7145 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7146 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7147 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7148 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7149 "expected not more than %d", (int) infoRec->rec.number.len,
7150 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7153 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7154 if (string8 == NULL) {
7155 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7156 "responseCdmaInformationRecords");
7159 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7160 string8[(int)infoRec->rec.number.len] = '\0';
7162 record->number.resize(1);
7163 record->number[0].number = string8;
7166 record->number[0].numberType = infoRec->rec.number.number_type;
7167 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7168 record->number[0].pi = infoRec->rec.number.pi;
7169 record->number[0].si = infoRec->rec.number.si;
7173 case RIL_CDMA_SIGNAL_INFO_REC: {
7174 record->signal.resize(1);
7175 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7176 record->signal[0].signalType = infoRec->rec.signal.signalType;
7177 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7178 record->signal[0].signal = infoRec->rec.signal.signal;
7182 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7183 if (infoRec->rec.redir.redirectingNumber.len >
7184 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7185 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7186 "expected not more than %d\n",
7187 (int)infoRec->rec.redir.redirectingNumber.len,
7188 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7191 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7193 if (string8 == NULL) {
7194 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7195 "responseCdmaInformationRecords");
7198 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7199 infoRec->rec.redir.redirectingNumber.len);
7200 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7202 record->redir.resize(1);
7203 record->redir[0].redirectingNumber.number = string8;
7206 record->redir[0].redirectingNumber.numberType =
7207 infoRec->rec.redir.redirectingNumber.number_type;
7208 record->redir[0].redirectingNumber.numberPlan =
7209 infoRec->rec.redir.redirectingNumber.number_plan;
7210 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7211 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7212 record->redir[0].redirectingReason =
7213 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7217 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7218 record->lineCtrl.resize(1);
7219 record->lineCtrl[0].lineCtrlPolarityIncluded =
7220 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7221 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7222 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7223 record->lineCtrl[0].lineCtrlPowerDenial =
7224 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7228 case RIL_CDMA_T53_CLIR_INFO_REC: {
7229 record->clir.resize(1);
7230 record->clir[0].cause = infoRec->rec.clir.cause;
7234 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7235 record->audioCtrl.resize(1);
7236 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7237 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7241 case RIL_CDMA_T53_RELEASE_INFO_REC:
7242 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7246 RLOGE("cdmaInfoRecInd: Incorrect name value");
7252 RLOGD("cdmaInfoRecInd");
7254 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7255 convertIntToRadioIndicationType(indicationType), records);
7256 radioService[slotId]->checkReturnStatus(retStatus);
7258 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7264 int radio::indicateRingbackToneInd(int slotId,
7265 int indicationType, int token, RIL_Errno e, void *response,
7266 size_t responseLen) {
7267 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7268 if (response == NULL || responseLen != sizeof(int)) {
7269 RLOGE("indicateRingbackToneInd: invalid response");
7272 bool start = ((int32_t *) response)[0];
7274 RLOGD("indicateRingbackToneInd: start %d", start);
7276 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7277 convertIntToRadioIndicationType(indicationType), start);
7278 radioService[slotId]->checkReturnStatus(retStatus);
7280 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7286 int radio::resendIncallMuteInd(int slotId,
7287 int indicationType, int token, RIL_Errno e, void *response,
7288 size_t responseLen) {
7289 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7291 RLOGD("resendIncallMuteInd");
7293 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7294 convertIntToRadioIndicationType(indicationType));
7295 radioService[slotId]->checkReturnStatus(retStatus);
7297 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7303 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7304 int indicationType, int token, RIL_Errno e,
7305 void *response, size_t responseLen) {
7306 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7307 if (response == NULL || responseLen != sizeof(int)) {
7308 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7311 int32_t cdmaSource = ((int32_t *) response)[0];
7313 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7315 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7316 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7317 (CdmaSubscriptionSource) cdmaSource);
7318 radioService[slotId]->checkReturnStatus(retStatus);
7320 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7327 int radio::cdmaPrlChangedInd(int slotId,
7328 int indicationType, int token, RIL_Errno e, void *response,
7329 size_t responseLen) {
7330 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7331 if (response == NULL || responseLen != sizeof(int)) {
7332 RLOGE("cdmaPrlChangedInd: invalid response");
7335 int32_t version = ((int32_t *) response)[0];
7337 RLOGD("cdmaPrlChangedInd: version %d", version);
7339 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7340 convertIntToRadioIndicationType(indicationType), version);
7341 radioService[slotId]->checkReturnStatus(retStatus);
7343 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7349 int radio::exitEmergencyCallbackModeInd(int slotId,
7350 int indicationType, int token, RIL_Errno e, void *response,
7351 size_t responseLen) {
7352 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7354 RLOGD("exitEmergencyCallbackModeInd");
7356 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7357 convertIntToRadioIndicationType(indicationType));
7358 radioService[slotId]->checkReturnStatus(retStatus);
7360 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7367 int radio::rilConnectedInd(int slotId,
7368 int indicationType, int token, RIL_Errno e, void *response,
7369 size_t responseLen) {
7370 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7371 RLOGD("rilConnectedInd");
7372 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7373 convertIntToRadioIndicationType(indicationType));
7374 radioService[slotId]->checkReturnStatus(retStatus);
7376 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7382 int radio::voiceRadioTechChangedInd(int slotId,
7383 int indicationType, int token, RIL_Errno e, void *response,
7384 size_t responseLen) {
7385 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7386 if (response == NULL || responseLen != sizeof(int)) {
7387 RLOGE("voiceRadioTechChangedInd: invalid response");
7390 int32_t rat = ((int32_t *) response)[0];
7392 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7394 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7395 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7396 radioService[slotId]->checkReturnStatus(retStatus);
7398 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7405 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7406 int num = responseLen / sizeof(RIL_CellInfo_v12);
7407 records.resize(num);
7409 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7410 for (int i = 0; i < num; i++) {
7411 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7412 records[i].registered = rillCellInfo->registered;
7413 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7414 records[i].timeStamp = rillCellInfo->timeStamp;
7415 // All vectors should be size 0 except one which will be size 1. Set everything to
7416 // size 0 initially.
7417 records[i].gsm.resize(0);
7418 records[i].wcdma.resize(0);
7419 records[i].cdma.resize(0);
7420 records[i].lte.resize(0);
7421 records[i].tdscdma.resize(0);
7422 switch(rillCellInfo->cellInfoType) {
7423 case RIL_CELL_INFO_TYPE_GSM: {
7424 records[i].gsm.resize(1);
7425 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7426 cellInfoGsm->cellIdentityGsm.mcc =
7427 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7428 cellInfoGsm->cellIdentityGsm.mnc =
7429 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7430 cellInfoGsm->cellIdentityGsm.lac =
7431 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7432 cellInfoGsm->cellIdentityGsm.cid =
7433 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7434 cellInfoGsm->cellIdentityGsm.arfcn =
7435 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7436 cellInfoGsm->cellIdentityGsm.bsic =
7437 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7438 cellInfoGsm->signalStrengthGsm.signalStrength =
7439 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7440 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7441 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7442 cellInfoGsm->signalStrengthGsm.timingAdvance =
7443 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7447 case RIL_CELL_INFO_TYPE_WCDMA: {
7448 records[i].wcdma.resize(1);
7449 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7450 cellInfoWcdma->cellIdentityWcdma.mcc =
7451 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7452 cellInfoWcdma->cellIdentityWcdma.mnc =
7453 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7454 cellInfoWcdma->cellIdentityWcdma.lac =
7455 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7456 cellInfoWcdma->cellIdentityWcdma.cid =
7457 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7458 cellInfoWcdma->cellIdentityWcdma.psc =
7459 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7460 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7461 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7462 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7463 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7464 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7465 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7469 case RIL_CELL_INFO_TYPE_CDMA: {
7470 records[i].cdma.resize(1);
7471 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7472 cellInfoCdma->cellIdentityCdma.networkId =
7473 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7474 cellInfoCdma->cellIdentityCdma.systemId =
7475 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7476 cellInfoCdma->cellIdentityCdma.baseStationId =
7477 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7478 cellInfoCdma->cellIdentityCdma.longitude =
7479 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7480 cellInfoCdma->cellIdentityCdma.latitude =
7481 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7482 cellInfoCdma->signalStrengthCdma.dbm =
7483 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7484 cellInfoCdma->signalStrengthCdma.ecio =
7485 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7486 cellInfoCdma->signalStrengthEvdo.dbm =
7487 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7488 cellInfoCdma->signalStrengthEvdo.ecio =
7489 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7490 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7491 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7495 case RIL_CELL_INFO_TYPE_LTE: {
7496 records[i].lte.resize(1);
7497 CellInfoLte *cellInfoLte = &records[i].lte[0];
7498 cellInfoLte->cellIdentityLte.mcc =
7499 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7500 cellInfoLte->cellIdentityLte.mnc =
7501 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7502 cellInfoLte->cellIdentityLte.ci =
7503 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7504 cellInfoLte->cellIdentityLte.pci =
7505 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7506 cellInfoLte->cellIdentityLte.tac =
7507 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7508 cellInfoLte->cellIdentityLte.earfcn =
7509 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7510 cellInfoLte->signalStrengthLte.signalStrength =
7511 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7512 cellInfoLte->signalStrengthLte.rsrp =
7513 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7514 cellInfoLte->signalStrengthLte.rsrq =
7515 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7516 cellInfoLte->signalStrengthLte.rssnr =
7517 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7518 cellInfoLte->signalStrengthLte.cqi =
7519 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7520 cellInfoLte->signalStrengthLte.timingAdvance =
7521 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7525 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7526 records[i].tdscdma.resize(1);
7527 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7528 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7529 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7530 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7531 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7532 cellInfoTdscdma->cellIdentityTdscdma.lac =
7533 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7534 cellInfoTdscdma->cellIdentityTdscdma.cid =
7535 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7536 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7537 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7538 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7539 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7550 int radio::cellInfoListInd(int slotId,
7551 int indicationType, int token, RIL_Errno e, void *response,
7552 size_t responseLen) {
7553 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7554 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7555 RLOGE("cellInfoListInd: invalid response");
7559 hidl_vec<CellInfo> records;
7560 convertRilCellInfoListToHal(response, responseLen, records);
7563 RLOGD("cellInfoListInd");
7565 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7566 convertIntToRadioIndicationType(indicationType), records);
7567 radioService[slotId]->checkReturnStatus(retStatus);
7569 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7575 int radio::imsNetworkStateChangedInd(int slotId,
7576 int indicationType, int token, RIL_Errno e, void *response,
7577 size_t responseLen) {
7578 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7580 RLOGD("imsNetworkStateChangedInd");
7582 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7583 convertIntToRadioIndicationType(indicationType));
7584 radioService[slotId]->checkReturnStatus(retStatus);
7586 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7593 int radio::subscriptionStatusChangedInd(int slotId,
7594 int indicationType, int token, RIL_Errno e, void *response,
7595 size_t responseLen) {
7596 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7597 if (response == NULL || responseLen != sizeof(int)) {
7598 RLOGE("subscriptionStatusChangedInd: invalid response");
7601 bool activate = ((int32_t *) response)[0];
7603 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7605 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
7606 convertIntToRadioIndicationType(indicationType), activate);
7607 radioService[slotId]->checkReturnStatus(retStatus);
7609 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
7616 int radio::srvccStateNotifyInd(int slotId,
7617 int indicationType, int token, RIL_Errno e, void *response,
7618 size_t responseLen) {
7619 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7620 if (response == NULL || responseLen != sizeof(int)) {
7621 RLOGE("srvccStateNotifyInd: invalid response");
7624 int32_t state = ((int32_t *) response)[0];
7626 RLOGD("srvccStateNotifyInd: rat %d", state);
7628 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
7629 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
7630 radioService[slotId]->checkReturnStatus(retStatus);
7632 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7638 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7639 hidl_vec<HardwareConfig>& records) {
7640 int num = responseLen / sizeof(RIL_HardwareConfig);
7641 records.resize(num);
7643 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7644 for (int i = 0; i < num; i++) {
7645 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7646 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7647 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7648 switch (rilHardwareConfig[i].type) {
7649 case RIL_HARDWARE_CONFIG_MODEM: {
7650 records[i].modem.resize(1);
7651 records[i].sim.resize(0);
7652 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7653 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7654 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7655 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7656 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7660 case RIL_HARDWARE_CONFIG_SIM: {
7661 records[i].sim.resize(1);
7662 records[i].modem.resize(0);
7663 records[i].sim[0].modemUuid =
7664 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7671 int radio::hardwareConfigChangedInd(int slotId,
7672 int indicationType, int token, RIL_Errno e, void *response,
7673 size_t responseLen) {
7674 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7675 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7676 RLOGE("hardwareConfigChangedInd: invalid response");
7680 hidl_vec<HardwareConfig> configs;
7681 convertRilHardwareConfigListToHal(response, responseLen, configs);
7684 RLOGD("hardwareConfigChangedInd");
7686 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
7687 convertIntToRadioIndicationType(indicationType), configs);
7688 radioService[slotId]->checkReturnStatus(retStatus);
7690 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
7697 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7698 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7699 rc.session = rilRadioCapability->session;
7700 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7701 rc.raf = rilRadioCapability->rat;
7702 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7703 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
7706 int radio::radioCapabilityIndicationInd(int slotId,
7707 int indicationType, int token, RIL_Errno e, void *response,
7708 size_t responseLen) {
7709 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7710 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
7711 RLOGE("radioCapabilityIndicationInd: invalid response");
7715 RadioCapability rc = {};
7716 convertRilRadioCapabilityToHal(response, responseLen, rc);
7719 RLOGD("radioCapabilityIndicationInd");
7721 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
7722 convertIntToRadioIndicationType(indicationType), rc);
7723 radioService[slotId]->checkReturnStatus(retStatus);
7725 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
7732 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
7733 if ((reqType == SS_INTERROGATION) &&
7734 (serType == SS_CFU ||
7735 serType == SS_CF_BUSY ||
7736 serType == SS_CF_NO_REPLY ||
7737 serType == SS_CF_NOT_REACHABLE ||
7738 serType == SS_CF_ALL ||
7739 serType == SS_CF_ALL_CONDITIONAL)) {
7745 int radio::onSupplementaryServiceIndicationInd(int slotId,
7746 int indicationType, int token, RIL_Errno e,
7747 void *response, size_t responseLen) {
7748 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7749 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
7750 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
7754 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
7755 StkCcUnsolSsResult ss = {};
7756 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
7757 ss.requestType = (SsRequestType) rilSsResponse->requestType;
7758 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
7759 ss.serviceClass = rilSsResponse->serviceClass;
7760 ss.result = (RadioError) rilSsResponse->result;
7762 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
7764 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
7765 rilSsResponse->cfData.numValidIndexes);
7767 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
7768 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
7769 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
7770 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
7773 ss.cfData.resize(1);
7774 ss.ssInfo.resize(0);
7776 /* number of call info's */
7777 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
7779 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
7780 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
7781 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
7783 cfInfo->status = (CallForwardInfoStatus) cf.status;
7784 cfInfo->reason = cf.reason;
7785 cfInfo->serviceClass = cf.serviceClass;
7786 cfInfo->toa = cf.toa;
7787 cfInfo->number = convertCharPtrToHidlString(cf.number);
7788 cfInfo->timeSeconds = cf.timeSeconds;
7790 RLOGD("onSupplementaryServiceIndicationInd: "
7791 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
7792 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
7796 ss.ssInfo.resize(1);
7797 ss.cfData.resize(0);
7800 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
7801 for (int i = 0; i < SS_INFO_MAX; i++) {
7803 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
7804 rilSsResponse->ssInfo[i]);
7806 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
7811 RLOGD("onSupplementaryServiceIndicationInd");
7813 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7814 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
7816 radioService[slotId]->checkReturnStatus(retStatus);
7818 RLOGE("onSupplementaryServiceIndicationInd: "
7819 "radioService[%d]->mRadioIndication == NULL", slotId);
7825 int radio::stkCallControlAlphaNotifyInd(int slotId,
7826 int indicationType, int token, RIL_Errno e, void *response,
7827 size_t responseLen) {
7828 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7829 if (response == NULL || responseLen == 0) {
7830 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
7834 RLOGD("stkCallControlAlphaNotifyInd");
7836 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
7837 convertIntToRadioIndicationType(indicationType),
7838 convertCharPtrToHidlString((char *) response));
7839 radioService[slotId]->checkReturnStatus(retStatus);
7841 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
7848 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
7849 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
7850 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
7851 lce.confidenceLevel = rilLceDataInfo->confidence_level;
7852 lce.lceSuspended = rilLceDataInfo->lce_suspended;
7855 int radio::lceDataInd(int slotId,
7856 int indicationType, int token, RIL_Errno e, void *response,
7857 size_t responseLen) {
7858 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7859 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
7860 RLOGE("lceDataInd: invalid response");
7864 LceDataInfo lce = {};
7865 convertRilLceDataInfoToHal(response, responseLen, lce);
7867 RLOGD("lceDataInd");
7869 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
7870 convertIntToRadioIndicationType(indicationType), lce);
7871 radioService[slotId]->checkReturnStatus(retStatus);
7873 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7879 int radio::pcoDataInd(int slotId,
7880 int indicationType, int token, RIL_Errno e, void *response,
7881 size_t responseLen) {
7882 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7883 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
7884 RLOGE("pcoDataInd: invalid response");
7888 PcoDataInfo pco = {};
7889 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
7890 pco.cid = rilPcoData->cid;
7891 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
7892 pco.pcoId = rilPcoData->pco_id;
7893 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
7896 RLOGD("pcoDataInd");
7898 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
7899 convertIntToRadioIndicationType(indicationType), pco);
7900 radioService[slotId]->checkReturnStatus(retStatus);
7902 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7908 int radio::modemResetInd(int slotId,
7909 int indicationType, int token, RIL_Errno e, void *response,
7910 size_t responseLen) {
7911 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7912 if (response == NULL || responseLen == 0) {
7913 RLOGE("modemResetInd: invalid response");
7917 RLOGD("modemResetInd");
7919 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
7920 convertIntToRadioIndicationType(indicationType),
7921 convertCharPtrToHidlString((char *) response));
7922 radioService[slotId]->checkReturnStatus(retStatus);
7924 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
7930 int radio::oemHookRawInd(int slotId,
7931 int indicationType, int token, RIL_Errno e, void *response,
7932 size_t responseLen) {
7933 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
7934 if (response == NULL || responseLen == 0) {
7935 RLOGE("oemHookRawInd: invalid response");
7939 hidl_vec<uint8_t> data;
7940 data.setToExternal((uint8_t *) response, responseLen);
7942 RLOGD("oemHookRawInd");
7944 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
7945 convertIntToRadioIndicationType(indicationType), data);
7946 checkReturnStatus(slotId, retStatus, false);
7948 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
7954 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
7955 using namespace android::hardware;
7957 const char *serviceNames[] = {
7958 android::RIL_getServiceName()
7959 #if (SIM_COUNT >= 2)
7961 #if (SIM_COUNT >= 3)
7963 #if (SIM_COUNT >= 4)
7970 #if (SIM_COUNT >= 2)
7971 simCount = SIM_COUNT;
7974 configureRpcThreadpool(1, true /* callerWillJoin */);
7975 for (int i = 0; i < simCount; i++) {
7976 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
7977 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
7980 radioService[i] = new RadioImpl;
7981 radioService[i]->mSlotId = i;
7982 oemHookService[i] = new OemHookImpl;
7983 oemHookService[i]->mSlotId = i;
7984 RLOGD("registerService: starting IRadio %s", serviceNames[i]);
7985 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
7986 status = oemHookService[i]->registerAsService(serviceNames[i]);
7988 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
7992 s_vendorFunctions = callbacks;
7993 s_commands = commands;
7996 void rilc_thread_pool() {
7997 joinRpcThreadpool();
8000 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8001 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8003 #if (SIM_COUNT >= 2)
8004 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8005 #if (SIM_COUNT >= 3)
8006 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8007 #if (SIM_COUNT >= 4)
8008 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8013 return radioServiceRwlockPtr;