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.1/IRadio.h>
20 #include <android/hardware/radio/1.1/IRadioResponse.h>
21 #include <android/hardware/radio/1.1/IRadioIndication.h>
22 #include <android/hardware/radio/1.1/types.h>
24 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
26 #include <hwbinder/IPCThreadState.h>
27 #include <hwbinder/ProcessState.h>
28 #include <ril_service.h>
29 #include <hidl/HidlTransportSupport.h>
30 #include <utils/SystemClock.h>
33 #define INVALID_HEX_CHAR 16
35 using namespace android::hardware::radio::V1_0;
36 using namespace android::hardware::radio::deprecated::V1_0;
37 using ::android::hardware::configureRpcThreadpool;
38 using ::android::hardware::joinRpcThreadpool;
39 using ::android::hardware::Return;
40 using ::android::hardware::hidl_string;
41 using ::android::hardware::hidl_vec;
42 using ::android::hardware::hidl_array;
43 using ::android::hardware::radio::V1_1::NetworkScanRequest;
44 using ::android::hardware::Void;
45 using android::CommandInfo;
46 using android::RequestInfo;
47 using android::requestToString;
50 #define BOOL_TO_INT(x) (x ? 1 : 0)
51 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
52 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
54 RIL_RadioFunctions *s_vendorFunctions = NULL;
55 static CommandInfo *s_commands;
61 sp<RadioImpl> radioService[SIM_COUNT];
62 sp<OemHookImpl> oemHookService[SIM_COUNT];
63 // counter used for synchronization. It is incremented every time response callbacks are updated.
64 volatile int32_t mCounterRadio[SIM_COUNT];
65 volatile int32_t mCounterOemHook[SIM_COUNT];
67 sp<RadioImpl> radioService[1];
68 sp<OemHookImpl> oemHookService[1];
69 // counter used for synchronization. It is incremented every time response callbacks are updated.
70 volatile int32_t mCounterRadio[1];
71 volatile int32_t mCounterOemHook[1];
74 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
77 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
79 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
81 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
86 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
87 hidl_vec<HardwareConfig>& records);
89 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
91 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
93 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
94 SignalStrength& signalStrength);
96 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
97 SetupDataCallResult& dcResult);
99 void convertRilDataCallListToHal(void *response, size_t responseLen,
100 hidl_vec<SetupDataCallResult>& dcResultList);
102 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
104 struct RadioImpl : public ::android::hardware::radio::V1_1::IRadio {
106 sp<IRadioResponse> mRadioResponse;
107 sp<IRadioIndication> mRadioIndication;
109 Return<void> setResponseFunctions(
110 const ::android::sp<IRadioResponse>& radioResponse,
111 const ::android::sp<IRadioIndication>& radioIndication);
113 Return<void> getIccCardStatus(int32_t serial);
115 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
116 const hidl_string& aid);
118 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
119 const hidl_string& pin, const hidl_string& aid);
121 Return<void> supplyIccPin2ForApp(int32_t serial,
122 const hidl_string& pin2,
123 const hidl_string& aid);
125 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
126 const hidl_string& pin2, const hidl_string& aid);
128 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
129 const hidl_string& newPin, const hidl_string& aid);
131 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
132 const hidl_string& newPin2, const hidl_string& aid);
134 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
136 Return<void> getCurrentCalls(int32_t serial);
138 Return<void> dial(int32_t serial, const Dial& dialInfo);
140 Return<void> getImsiForApp(int32_t serial,
141 const ::android::hardware::hidl_string& aid);
143 Return<void> hangup(int32_t serial, int32_t gsmIndex);
145 Return<void> hangupWaitingOrBackground(int32_t serial);
147 Return<void> hangupForegroundResumeBackground(int32_t serial);
149 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
151 Return<void> conference(int32_t serial);
153 Return<void> rejectCall(int32_t serial);
155 Return<void> getLastCallFailCause(int32_t serial);
157 Return<void> getSignalStrength(int32_t serial);
159 Return<void> getVoiceRegistrationState(int32_t serial);
161 Return<void> getDataRegistrationState(int32_t serial);
163 Return<void> getOperator(int32_t serial);
165 Return<void> setRadioPower(int32_t serial, bool on);
167 Return<void> sendDtmf(int32_t serial,
168 const ::android::hardware::hidl_string& s);
170 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
172 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
174 Return<void> setupDataCall(int32_t serial,
175 RadioTechnology radioTechnology,
176 const DataProfileInfo& profileInfo,
181 Return<void> iccIOForApp(int32_t serial,
184 Return<void> sendUssd(int32_t serial,
185 const ::android::hardware::hidl_string& ussd);
187 Return<void> cancelPendingUssd(int32_t serial);
189 Return<void> getClir(int32_t serial);
191 Return<void> setClir(int32_t serial, int32_t status);
193 Return<void> getCallForwardStatus(int32_t serial,
194 const CallForwardInfo& callInfo);
196 Return<void> setCallForward(int32_t serial,
197 const CallForwardInfo& callInfo);
199 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
201 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
203 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
204 bool success, SmsAcknowledgeFailCause cause);
206 Return<void> acceptCall(int32_t serial);
208 Return<void> deactivateDataCall(int32_t serial,
209 int32_t cid, bool reasonRadioShutDown);
211 Return<void> getFacilityLockForApp(int32_t serial,
212 const ::android::hardware::hidl_string& facility,
213 const ::android::hardware::hidl_string& password,
214 int32_t serviceClass,
215 const ::android::hardware::hidl_string& appId);
217 Return<void> setFacilityLockForApp(int32_t serial,
218 const ::android::hardware::hidl_string& facility,
220 const ::android::hardware::hidl_string& password,
221 int32_t serviceClass,
222 const ::android::hardware::hidl_string& appId);
224 Return<void> setBarringPassword(int32_t serial,
225 const ::android::hardware::hidl_string& facility,
226 const ::android::hardware::hidl_string& oldPassword,
227 const ::android::hardware::hidl_string& newPassword);
229 Return<void> getNetworkSelectionMode(int32_t serial);
231 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
233 Return<void> setNetworkSelectionModeManual(int32_t serial,
234 const ::android::hardware::hidl_string& operatorNumeric);
236 Return<void> getAvailableNetworks(int32_t serial);
238 Return<void> startNetworkScan(int32_t serial, const NetworkScanRequest& request);
240 Return<void> stopNetworkScan(int32_t serial);
242 Return<void> startDtmf(int32_t serial,
243 const ::android::hardware::hidl_string& s);
245 Return<void> stopDtmf(int32_t serial);
247 Return<void> getBasebandVersion(int32_t serial);
249 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
251 Return<void> setMute(int32_t serial, bool enable);
253 Return<void> getMute(int32_t serial);
255 Return<void> getClip(int32_t serial);
257 Return<void> getDataCallList(int32_t serial);
259 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
261 Return<void> writeSmsToSim(int32_t serial,
262 const SmsWriteArgs& smsWriteArgs);
264 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
266 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
268 Return<void> getAvailableBandModes(int32_t serial);
270 Return<void> sendEnvelope(int32_t serial,
271 const ::android::hardware::hidl_string& command);
273 Return<void> sendTerminalResponseToSim(int32_t serial,
274 const ::android::hardware::hidl_string& commandResponse);
276 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
278 Return<void> explicitCallTransfer(int32_t serial);
280 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
282 Return<void> getPreferredNetworkType(int32_t serial);
284 Return<void> getNeighboringCids(int32_t serial);
286 Return<void> setLocationUpdates(int32_t serial, bool enable);
288 Return<void> setCdmaSubscriptionSource(int32_t serial,
289 CdmaSubscriptionSource cdmaSub);
291 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
293 Return<void> getCdmaRoamingPreference(int32_t serial);
295 Return<void> setTTYMode(int32_t serial, TtyMode mode);
297 Return<void> getTTYMode(int32_t serial);
299 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
301 Return<void> getPreferredVoicePrivacy(int32_t serial);
303 Return<void> sendCDMAFeatureCode(int32_t serial,
304 const ::android::hardware::hidl_string& featureCode);
306 Return<void> sendBurstDtmf(int32_t serial,
307 const ::android::hardware::hidl_string& dtmf,
311 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
313 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
314 const CdmaSmsAck& smsAck);
316 Return<void> getGsmBroadcastConfig(int32_t serial);
318 Return<void> setGsmBroadcastConfig(int32_t serial,
319 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
321 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
323 Return<void> getCdmaBroadcastConfig(int32_t serial);
325 Return<void> setCdmaBroadcastConfig(int32_t serial,
326 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
328 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
330 Return<void> getCDMASubscription(int32_t serial);
332 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
334 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
336 Return<void> getDeviceIdentity(int32_t serial);
338 Return<void> exitEmergencyCallbackMode(int32_t serial);
340 Return<void> getSmscAddress(int32_t serial);
342 Return<void> setSmscAddress(int32_t serial,
343 const ::android::hardware::hidl_string& smsc);
345 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
347 Return<void> reportStkServiceIsRunning(int32_t serial);
349 Return<void> getCdmaSubscriptionSource(int32_t serial);
351 Return<void> requestIsimAuthentication(int32_t serial,
352 const ::android::hardware::hidl_string& challenge);
354 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
356 const ::android::hardware::hidl_string& ackPdu);
358 Return<void> sendEnvelopeWithStatus(int32_t serial,
359 const ::android::hardware::hidl_string& contents);
361 Return<void> getVoiceRadioTechnology(int32_t serial);
363 Return<void> getCellInfoList(int32_t serial);
365 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
367 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
368 bool modemCognitive, bool isRoaming);
370 Return<void> getImsRegistrationState(int32_t serial);
372 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
374 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
376 Return<void> iccOpenLogicalChannel(int32_t serial,
377 const ::android::hardware::hidl_string& aid, int32_t p2);
379 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
381 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
383 Return<void> nvReadItem(int32_t serial, NvItem itemId);
385 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
387 Return<void> nvWriteCdmaPrl(int32_t serial,
388 const ::android::hardware::hidl_vec<uint8_t>& prl);
390 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
392 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
394 Return<void> setDataAllowed(int32_t serial, bool allow);
396 Return<void> getHardwareConfig(int32_t serial);
398 Return<void> requestIccSimAuthentication(int32_t serial,
400 const ::android::hardware::hidl_string& authData,
401 const ::android::hardware::hidl_string& aid);
403 Return<void> setDataProfile(int32_t serial,
404 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
406 Return<void> requestShutdown(int32_t serial);
408 Return<void> getRadioCapability(int32_t serial);
410 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
412 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
414 Return<void> stopLceService(int32_t serial);
416 Return<void> pullLceData(int32_t serial);
418 Return<void> getModemActivityInfo(int32_t serial);
420 Return<void> setAllowedCarriers(int32_t serial,
422 const CarrierRestrictions& carriers);
424 Return<void> getAllowedCarriers(int32_t serial);
426 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
428 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
430 Return<void> setSimCardPower(int32_t serial, bool powerUp);
431 Return<void> setSimCardPower_1_1(int32_t serial,
432 const ::android::hardware::radio::V1_1::CardPowerState state);
434 Return<void> responseAcknowledgement();
436 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
437 const ::android::hardware::hidl_vec<uint8_t>& carrierKey,
438 const hidl_string& keyIdentifier);
440 void checkReturnStatus(Return<void>& ret);
443 struct OemHookImpl : public IOemHook {
445 sp<IOemHookResponse> mOemHookResponse;
446 sp<IOemHookIndication> mOemHookIndication;
448 Return<void> setResponseFunctions(
449 const ::android::sp<IOemHookResponse>& oemHookResponse,
450 const ::android::sp<IOemHookIndication>& oemHookIndication);
452 Return<void> sendRequestRaw(int32_t serial,
453 const ::android::hardware::hidl_vec<uint8_t>& data);
455 Return<void> sendRequestStrings(int32_t serial,
456 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
459 void memsetAndFreeStrings(int numPointers, ...) {
461 va_start(ap, numPointers);
462 for (int i = 0; i < numPointers; i++) {
463 char *ptr = va_arg(ap, char *);
466 #define MAX_STRING_LENGTH 4096
467 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
475 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
476 pRI->pCI->responseFunction((int) pRI->socket_id,
477 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
481 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
482 * request with error RIL_E_NO_MEMORY.
483 * Returns true on success, and false on failure.
485 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
486 size_t len = src.size();
491 *dest = (char *) calloc(len + 1, sizeof(char));
493 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
494 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
497 strncpy(*dest, src.c_str(), len + 1);
501 hidl_string convertCharPtrToHidlString(const char *ptr) {
504 // TODO: replace this with strnlen
505 ret.setToExternal(ptr, strlen(ptr));
510 bool dispatchVoid(int serial, int slotId, int request) {
511 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
515 s_vendorFunctions->onRequest(request, NULL, 0, pRI);
519 bool dispatchString(int serial, int slotId, int request, const char * str) {
520 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
526 if (!copyHidlStringToRil(&pString, str, pRI)) {
530 s_vendorFunctions->onRequest(request, pString, sizeof(char *), pRI);
532 memsetAndFreeStrings(1, pString);
536 bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) {
537 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
543 pStrings = (char **)calloc(countStrings, sizeof(char *));
544 if (pStrings == NULL) {
545 RLOGE("Memory allocation failed for request %s", requestToString(request));
546 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
550 va_start(ap, countStrings);
551 for (int i = 0; i < countStrings; i++) {
552 const char* str = va_arg(ap, const char *);
553 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI)) {
555 for (int j = 0; j < i; j++) {
556 memsetAndFreeStrings(1, pStrings[j]);
564 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
566 if (pStrings != NULL) {
567 for (int i = 0 ; i < countStrings ; i++) {
568 memsetAndFreeStrings(1, pStrings[i]);
572 memset(pStrings, 0, countStrings * sizeof(char *));
579 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
580 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
585 int countStrings = data.size();
587 pStrings = (char **)calloc(countStrings, sizeof(char *));
588 if (pStrings == NULL) {
589 RLOGE("Memory allocation failed for request %s", requestToString(request));
590 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
594 for (int i = 0; i < countStrings; i++) {
595 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
596 for (int j = 0; j < i; j++) {
597 memsetAndFreeStrings(1, pStrings[j]);
604 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
606 if (pStrings != NULL) {
607 for (int i = 0 ; i < countStrings ; i++) {
608 memsetAndFreeStrings(1, pStrings[i]);
612 memset(pStrings, 0, countStrings * sizeof(char *));
619 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
620 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
625 int *pInts = (int *)calloc(countInts, sizeof(int));
628 RLOGE("Memory allocation failed for request %s", requestToString(request));
629 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
633 va_start(ap, countInts);
634 for (int i = 0; i < countInts; i++) {
635 pInts[i] = va_arg(ap, int);
639 s_vendorFunctions->onRequest(request, pInts, countInts * sizeof(int), pRI);
643 memset(pInts, 0, countInts * sizeof(int));
650 bool dispatchCallForwardStatus(int serial, int slotId, int request,
651 const CallForwardInfo& callInfo) {
652 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
657 RIL_CallForwardInfo cf;
658 cf.status = (int) callInfo.status;
659 cf.reason = callInfo.reason;
660 cf.serviceClass = callInfo.serviceClass;
661 cf.toa = callInfo.toa;
662 cf.timeSeconds = callInfo.timeSeconds;
664 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
668 s_vendorFunctions->onRequest(request, &cf, sizeof(cf), pRI);
670 memsetAndFreeStrings(1, cf.number);
675 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
676 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
681 const uint8_t *uData = rawBytes.data();
683 s_vendorFunctions->onRequest(request, (void *) uData, rawBytes.size(), pRI);
688 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
689 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
694 RIL_SIM_APDU apdu = {};
696 apdu.sessionid = message.sessionId;
697 apdu.cla = message.cla;
698 apdu.instruction = message.instruction;
699 apdu.p1 = message.p1;
700 apdu.p2 = message.p2;
701 apdu.p3 = message.p3;
703 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
707 s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI);
709 memsetAndFreeStrings(1, apdu.data);
714 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
715 if (ret.isOk() == false) {
716 RLOGE("checkReturnStatus: unable to call response/indication callback");
717 // Remote process hosting the callbacks must be dead. Reset the callback objects;
718 // there's no other recovery to be done here. When the client process is back up, it will
719 // call setResponseFunctions()
721 // Caller should already hold rdlock, release that first
722 // note the current counter to avoid overwriting updates made by another thread before
723 // write lock is acquired.
724 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
725 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
726 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
730 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
733 // make sure the counter value has not changed
734 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
735 if (isRadioService) {
736 radioService[slotId]->mRadioResponse = NULL;
737 radioService[slotId]->mRadioIndication = NULL;
739 oemHookService[slotId]->mOemHookResponse = NULL;
740 oemHookService[slotId]->mOemHookIndication = NULL;
742 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
744 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
745 "got updated on another thread");
749 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
753 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
758 void RadioImpl::checkReturnStatus(Return<void>& ret) {
759 ::checkReturnStatus(mSlotId, ret, true);
762 Return<void> RadioImpl::setResponseFunctions(
763 const ::android::sp<IRadioResponse>& radioResponseParam,
764 const ::android::sp<IRadioIndication>& radioIndicationParam) {
765 RLOGD("setResponseFunctions");
767 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
768 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
771 mRadioResponse = radioResponseParam;
772 mRadioIndication = radioIndicationParam;
773 mCounterRadio[mSlotId]++;
775 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
778 // client is connected. Send initial indications.
779 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
784 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
786 RLOGD("getIccCardStatus: serial %d", serial);
788 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
792 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
793 const hidl_string& aid) {
795 RLOGD("supplyIccPinForApp: serial %d", serial);
797 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
798 2, pin.c_str(), aid.c_str());
802 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
803 const hidl_string& pin, const hidl_string& aid) {
805 RLOGD("supplyIccPukForApp: serial %d", serial);
807 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
808 3, puk.c_str(), pin.c_str(), aid.c_str());
812 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
813 const hidl_string& aid) {
815 RLOGD("supplyIccPin2ForApp: serial %d", serial);
817 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
818 2, pin2.c_str(), aid.c_str());
822 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
823 const hidl_string& pin2, const hidl_string& aid) {
825 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
827 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
828 3, puk2.c_str(), pin2.c_str(), aid.c_str());
832 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
833 const hidl_string& newPin, const hidl_string& aid) {
835 RLOGD("changeIccPinForApp: serial %d", serial);
837 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
838 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
842 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
843 const hidl_string& newPin2, const hidl_string& aid) {
845 RLOGD("changeIccPin2ForApp: serial %d", serial);
847 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
848 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
852 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
853 const hidl_string& netPin) {
855 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
857 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
862 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
864 RLOGD("getCurrentCalls: serial %d", serial);
866 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
870 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
872 RLOGD("dial: serial %d", serial);
874 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
879 RIL_UUS_Info uusInfo = {};
880 int32_t sizeOfDial = sizeof(dial);
882 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
885 dial.clir = (int) dialInfo.clir;
887 if (dialInfo.uusInfo.size() != 0) {
888 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
889 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
891 if (dialInfo.uusInfo[0].uusData.size() == 0) {
892 uusInfo.uusData = NULL;
893 uusInfo.uusLength = 0;
895 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
896 memsetAndFreeStrings(1, dial.address);
899 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
902 dial.uusInfo = &uusInfo;
905 s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI);
907 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
912 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
914 RLOGD("getImsiForApp: serial %d", serial);
916 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
921 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
923 RLOGD("hangup: serial %d", serial);
925 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
929 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
931 RLOGD("hangupWaitingOrBackground: serial %d", serial);
933 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
937 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
939 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
941 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
945 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
947 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
949 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
953 Return<void> RadioImpl::conference(int32_t serial) {
955 RLOGD("conference: serial %d", serial);
957 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
961 Return<void> RadioImpl::rejectCall(int32_t serial) {
963 RLOGD("rejectCall: serial %d", serial);
965 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
969 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
971 RLOGD("getLastCallFailCause: serial %d", serial);
973 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
977 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
979 RLOGD("getSignalStrength: serial %d", serial);
981 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
985 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
987 RLOGD("getVoiceRegistrationState: serial %d", serial);
989 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
993 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
995 RLOGD("getDataRegistrationState: serial %d", serial);
997 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1001 Return<void> RadioImpl::getOperator(int32_t serial) {
1003 RLOGD("getOperator: serial %d", serial);
1005 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1009 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
1010 RLOGD("setRadioPower: serial %d on %d", serial, on);
1011 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1015 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1017 RLOGD("sendDtmf: serial %d", serial);
1019 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1023 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1025 RLOGD("sendSms: serial %d", serial);
1027 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
1028 2, message.smscPdu.c_str(), message.pdu.c_str());
1032 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1034 RLOGD("sendSMSExpectMore: serial %d", serial);
1036 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
1037 2, message.smscPdu.c_str(), message.pdu.c_str());
1041 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1043 case MvnoType::IMSI:
1044 str = (char *)"imsi";
1047 str = (char *)"gid";
1050 str = (char *)"spn";
1052 case MvnoType::NONE:
1059 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1060 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1061 bool roamingAllowed, bool isRoaming) {
1064 RLOGD("setupDataCall: serial %d", serial);
1067 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1068 const hidl_string &protocol =
1069 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1070 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
1071 std::to_string((int) radioTechnology + 2).c_str(),
1072 std::to_string((int) dataProfileInfo.profileId).c_str(),
1073 dataProfileInfo.apn.c_str(),
1074 dataProfileInfo.user.c_str(),
1075 dataProfileInfo.password.c_str(),
1076 std::to_string((int) dataProfileInfo.authType).c_str(),
1078 } else if (s_vendorFunctions->version >= 15) {
1079 char *mvnoTypeStr = NULL;
1080 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1081 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1082 RIL_REQUEST_SETUP_DATA_CALL);
1084 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1088 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1089 std::to_string((int) radioTechnology + 2).c_str(),
1090 std::to_string((int) dataProfileInfo.profileId).c_str(),
1091 dataProfileInfo.apn.c_str(),
1092 dataProfileInfo.user.c_str(),
1093 dataProfileInfo.password.c_str(),
1094 std::to_string((int) dataProfileInfo.authType).c_str(),
1095 dataProfileInfo.protocol.c_str(),
1096 dataProfileInfo.roamingProtocol.c_str(),
1097 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1098 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1099 modemCognitive ? "1" : "0",
1100 std::to_string(dataProfileInfo.mtu).c_str(),
1102 dataProfileInfo.mvnoMatchData.c_str(),
1103 roamingAllowed ? "1" : "0");
1105 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1106 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1107 RIL_REQUEST_SETUP_DATA_CALL);
1109 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1115 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1117 RLOGD("iccIOForApp: serial %d", serial);
1119 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1124 RIL_SIM_IO_v6 rilIccIo = {};
1125 rilIccIo.command = iccIo.command;
1126 rilIccIo.fileid = iccIo.fileId;
1127 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1131 rilIccIo.p1 = iccIo.p1;
1132 rilIccIo.p2 = iccIo.p2;
1133 rilIccIo.p3 = iccIo.p3;
1135 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1136 memsetAndFreeStrings(1, rilIccIo.path);
1140 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1141 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1145 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1146 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1150 s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI);
1152 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1157 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1159 RLOGD("sendUssd: serial %d", serial);
1161 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1165 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1167 RLOGD("cancelPendingUssd: serial %d", serial);
1169 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1173 Return<void> RadioImpl::getClir(int32_t serial) {
1175 RLOGD("getClir: serial %d", serial);
1177 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1181 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1183 RLOGD("setClir: serial %d", serial);
1185 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1189 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1191 RLOGD("getCallForwardStatus: serial %d", serial);
1193 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1198 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1200 RLOGD("setCallForward: serial %d", serial);
1202 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1207 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1209 RLOGD("getCallWaiting: serial %d", serial);
1211 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1215 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1217 RLOGD("setCallWaiting: serial %d", serial);
1219 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1224 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1225 bool success, SmsAcknowledgeFailCause cause) {
1227 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1229 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1234 Return<void> RadioImpl::acceptCall(int32_t serial) {
1236 RLOGD("acceptCall: serial %d", serial);
1238 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1242 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1243 int32_t cid, bool reasonRadioShutDown) {
1245 RLOGD("deactivateDataCall: serial %d", serial);
1247 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1248 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1252 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1253 const hidl_string& password, int32_t serviceClass,
1254 const hidl_string& appId) {
1256 RLOGD("getFacilityLockForApp: serial %d", serial);
1258 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1259 4, facility.c_str(), password.c_str(),
1260 (std::to_string(serviceClass)).c_str(), appId.c_str());
1264 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1265 bool lockState, const hidl_string& password,
1266 int32_t serviceClass, const hidl_string& appId) {
1268 RLOGD("setFacilityLockForApp: serial %d", serial);
1270 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1271 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1272 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1276 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1277 const hidl_string& oldPassword,
1278 const hidl_string& newPassword) {
1280 RLOGD("setBarringPassword: serial %d", serial);
1282 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1283 2, oldPassword.c_str(), newPassword.c_str());
1287 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1289 RLOGD("getNetworkSelectionMode: serial %d", serial);
1291 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1295 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1297 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1299 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1303 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1304 const hidl_string& operatorNumeric) {
1306 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1308 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1309 operatorNumeric.c_str());
1313 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1315 RLOGD("getAvailableNetworks: serial %d", serial);
1317 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1321 Return<void> RadioImpl::startNetworkScan(int32_t serial, const NetworkScanRequest& request) {
1323 RLOGD("startNetworkScan: serial %d", serial);
1325 // TODO(b/30954762): Add implementation to start network scan.
1326 dispatchVoid(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1330 Return<void> RadioImpl::stopNetworkScan(int32_t serial) {
1332 RLOGD("stopNetworkScan: serial %d", serial);
1334 // TODO(b/30954762): Add implementation to stop network scan.
1335 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1339 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1341 RLOGD("startDtmf: serial %d", serial);
1343 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1348 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1350 RLOGD("stopDtmf: serial %d", serial);
1352 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1356 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1358 RLOGD("getBasebandVersion: serial %d", serial);
1360 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1364 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1366 RLOGD("separateConnection: serial %d", serial);
1368 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1372 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1374 RLOGD("setMute: serial %d", serial);
1376 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1380 Return<void> RadioImpl::getMute(int32_t serial) {
1382 RLOGD("getMute: serial %d", serial);
1384 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1388 Return<void> RadioImpl::getClip(int32_t serial) {
1390 RLOGD("getClip: serial %d", serial);
1392 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1396 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1398 RLOGD("getDataCallList: serial %d", serial);
1400 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1404 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1406 RLOGD("setSuppServiceNotifications: serial %d", serial);
1408 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1409 BOOL_TO_INT(enable));
1413 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1415 RLOGD("writeSmsToSim: serial %d", serial);
1417 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1422 RIL_SMS_WriteArgs args;
1423 args.status = (int) smsWriteArgs.status;
1426 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1430 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1431 memsetAndFreeStrings(1, args.pdu);
1435 s_vendorFunctions->onRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI);
1437 memsetAndFreeStrings(2, args.smsc, args.pdu);
1442 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1444 RLOGD("deleteSmsOnSim: serial %d", serial);
1446 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1450 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1452 RLOGD("setBandMode: serial %d", serial);
1454 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1458 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1460 RLOGD("getAvailableBandModes: serial %d", serial);
1462 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1466 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1468 RLOGD("sendEnvelope: serial %d", serial);
1470 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1475 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1476 const hidl_string& commandResponse) {
1478 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1480 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1481 commandResponse.c_str());
1485 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1487 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1489 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1490 1, BOOL_TO_INT(accept));
1494 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1496 RLOGD("explicitCallTransfer: serial %d", serial);
1498 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1502 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1504 RLOGD("setPreferredNetworkType: serial %d", serial);
1506 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1510 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1512 RLOGD("getPreferredNetworkType: serial %d", serial);
1514 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1518 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1520 RLOGD("getNeighboringCids: serial %d", serial);
1522 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1526 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1528 RLOGD("setLocationUpdates: serial %d", serial);
1530 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1534 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1536 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1538 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1542 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1544 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1546 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1550 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1552 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1554 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1558 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1560 RLOGD("setTTYMode: serial %d", serial);
1562 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1566 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1568 RLOGD("getTTYMode: serial %d", serial);
1570 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1574 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1576 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1578 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1579 1, BOOL_TO_INT(enable));
1583 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1585 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1587 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1591 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1593 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1595 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1596 featureCode.c_str());
1600 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1603 RLOGD("sendBurstDtmf: serial %d", serial);
1605 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1606 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1607 (std::to_string(off)).c_str());
1611 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1612 rcsm.uTeleserviceID = sms.teleserviceId;
1613 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1614 rcsm.uServicecategory = sms.serviceCategory;
1615 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1616 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1617 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1618 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1620 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1621 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1622 for (int i = 0; i < digitLimit; i++) {
1623 rcsm.sAddress.digits[i] = sms.address.digits[i];
1626 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1627 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1629 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1630 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1631 for (int i = 0; i < digitLimit; i++) {
1632 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1635 rcsm.uBearerDataLen = sms.bearerData.size();
1636 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1637 for (int i = 0; i < digitLimit; i++) {
1638 rcsm.aBearerData[i] = sms.bearerData[i];
1642 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1644 RLOGD("sendCdmaSms: serial %d", serial);
1646 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1651 RIL_CDMA_SMS_Message rcsm = {};
1652 constructCdmaSms(rcsm, sms);
1654 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI);
1658 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1660 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1662 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1667 RIL_CDMA_SMS_Ack rcsa = {};
1669 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1670 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1672 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI);
1676 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1678 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1680 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1684 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1685 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1688 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1690 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1691 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1696 int num = configInfo.size();
1697 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1698 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1700 for (int i = 0 ; i < num ; i++ ) {
1701 gsmBciPtrs[i] = &gsmBci[i];
1702 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1703 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1704 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1705 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1706 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1709 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, gsmBciPtrs,
1710 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI);
1714 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1716 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1718 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1719 1, BOOL_TO_INT(!activate));
1723 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1725 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1727 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1731 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1732 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1735 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1737 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1738 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1743 int num = configInfo.size();
1744 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1745 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1747 for (int i = 0 ; i < num ; i++ ) {
1748 cdmaBciPtrs[i] = &cdmaBci[i];
1749 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1750 cdmaBci[i].language = configInfo[i].language;
1751 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1754 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, cdmaBciPtrs,
1755 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI);
1759 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1761 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1763 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1764 1, BOOL_TO_INT(!activate));
1768 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1770 RLOGD("getCDMASubscription: serial %d", serial);
1772 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1776 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1778 RLOGD("writeSmsToRuim: serial %d", serial);
1780 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1781 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1786 RIL_CDMA_SMS_WriteArgs rcsw = {};
1787 rcsw.status = (int) cdmaSms.status;
1788 constructCdmaSms(rcsw.message, cdmaSms.message);
1790 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI);
1794 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1796 RLOGD("deleteSmsOnRuim: serial %d", serial);
1798 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1802 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1804 RLOGD("getDeviceIdentity: serial %d", serial);
1806 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1810 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1812 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1814 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1818 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1820 RLOGD("getSmscAddress: serial %d", serial);
1822 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1826 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1828 RLOGD("setSmscAddress: serial %d", serial);
1830 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1835 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1837 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1839 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1840 BOOL_TO_INT(available));
1844 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1846 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1848 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1852 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1854 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1856 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1860 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1862 RLOGD("requestIsimAuthentication: serial %d", serial);
1864 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1869 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1870 const hidl_string& ackPdu) {
1872 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1874 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1875 2, success ? "1" : "0", ackPdu.c_str());
1879 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1881 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1883 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1888 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1890 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1892 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1896 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1898 RLOGD("getCellInfoList: serial %d", serial);
1900 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1904 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1906 RLOGD("setCellInfoListRate: serial %d", serial);
1908 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1912 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1913 bool modemCognitive, bool isRoaming) {
1915 RLOGD("setInitialAttachApn: serial %d", serial);
1917 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1918 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
1923 if (s_vendorFunctions->version <= 14) {
1924 RIL_InitialAttachApn iaa = {};
1926 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1930 const hidl_string &protocol =
1931 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1933 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
1934 memsetAndFreeStrings(1, iaa.apn);
1937 iaa.authtype = (int) dataProfileInfo.authType;
1938 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1939 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
1942 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1943 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
1947 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1949 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
1951 RIL_InitialAttachApn_v15 iaa = {};
1953 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1956 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
1957 memsetAndFreeStrings(1, iaa.apn);
1960 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
1961 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
1964 iaa.authtype = (int) dataProfileInfo.authType;
1965 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1966 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
1969 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1970 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
1973 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
1974 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
1975 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
1976 iaa.mtu = dataProfileInfo.mtu;
1978 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
1979 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1980 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1985 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
1986 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1991 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1993 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1994 iaa.password, iaa.mvnoMatchData);
2000 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
2002 RLOGD("getImsRegistrationState: serial %d", serial);
2004 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2008 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2009 RIL_IMS_SMS_Message rism = {};
2011 int countStrings = 2;
2012 int dataLen = sizeof(char *) * countStrings;
2014 rism.tech = RADIO_TECH_3GPP;
2015 rism.retry = BOOL_TO_INT(message.retry);
2016 rism.messageRef = message.messageRef;
2018 if (message.gsmMessage.size() != 1) {
2019 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2020 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2024 pStrings = (char **)calloc(countStrings, sizeof(char *));
2025 if (pStrings == NULL) {
2026 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2027 requestToString(pRI->pCI->requestNumber));
2028 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2032 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2034 memset(pStrings, 0, dataLen);
2040 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2041 memsetAndFreeStrings(1, pStrings[0]);
2043 memset(pStrings, 0, dataLen);
2049 rism.message.gsmMessage = pStrings;
2050 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2051 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI);
2053 for (int i = 0 ; i < countStrings ; i++) {
2054 memsetAndFreeStrings(1, pStrings[i]);
2058 memset(pStrings, 0, dataLen);
2065 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2066 RIL_IMS_SMS_Message rism = {};
2067 RIL_CDMA_SMS_Message rcsm = {};
2069 if (message.cdmaMessage.size() != 1) {
2070 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2071 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2075 rism.tech = RADIO_TECH_3GPP2;
2076 rism.retry = BOOL_TO_INT(message.retry);
2077 rism.messageRef = message.messageRef;
2078 rism.message.cdmaMessage = &rcsm;
2080 constructCdmaSms(rcsm, message.cdmaMessage[0]);
2082 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2083 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI);
2088 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2090 RLOGD("sendImsSms: serial %d", serial);
2092 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2097 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2099 if (RADIO_TECH_3GPP == format) {
2100 dispatchImsGsmSms(message, pRI);
2101 } else if (RADIO_TECH_3GPP2 == format) {
2102 dispatchImsCdmaSms(message, pRI);
2104 RLOGE("sendImsSms: Invalid radio tech %s",
2105 requestToString(pRI->pCI->requestNumber));
2106 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2111 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2113 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2115 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2119 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2121 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2123 if (s_vendorFunctions->version < 15) {
2124 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2126 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2131 RIL_OpenChannelParams params = {};
2135 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2139 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI);
2141 memsetAndFreeStrings(1, params.aidPtr);
2146 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2148 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2150 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2154 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2156 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2158 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2162 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2164 RLOGD("nvReadItem: serial %d", serial);
2166 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2171 RIL_NV_ReadItem nvri = {};
2172 nvri.itemID = (RIL_NV_Item) itemId;
2174 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI);
2178 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2180 RLOGD("nvWriteItem: serial %d", serial);
2182 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2187 RIL_NV_WriteItem nvwi = {};
2189 nvwi.itemID = (RIL_NV_Item) item.itemId;
2191 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2195 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI);
2197 memsetAndFreeStrings(1, nvwi.value);
2201 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2203 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2205 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2209 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2210 int rilResetType = -1;
2212 RLOGD("nvResetConfig: serial %d", serial);
2214 /* Convert ResetNvType to RIL.h values
2215 * RIL_REQUEST_NV_RESET_CONFIG
2216 * 1 - reload all NV items
2217 * 2 - erase NV reset (SCRTN)
2218 * 3 - factory reset (RTN)
2221 case ResetNvType::RELOAD:
2224 case ResetNvType::ERASE:
2227 case ResetNvType::FACTORY_RESET:
2231 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2235 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2237 RLOGD("setUiccSubscription: serial %d", serial);
2239 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2240 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2245 RIL_SelectUiccSub rilUiccSub = {};
2247 rilUiccSub.slot = uiccSub.slot;
2248 rilUiccSub.app_index = uiccSub.appIndex;
2249 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2250 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2252 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI);
2256 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2258 RLOGD("setDataAllowed: serial %d", serial);
2260 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2264 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2266 RLOGD("getHardwareConfig: serial %d", serial);
2268 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2272 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2273 const hidl_string& authData, const hidl_string& aid) {
2275 RLOGD("requestIccSimAuthentication: serial %d", serial);
2277 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2282 RIL_SimAuthentication pf = {};
2284 pf.authContext = authContext;
2287 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2291 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2292 memsetAndFreeStrings(1, pf.authData);
2296 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI);
2298 memsetAndFreeStrings(2, pf.authData, pf.aid);
2303 * @param numProfiles number of data profile
2304 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2305 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2306 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2307 * @param numfields number of string-type member in the data profile structure
2308 * @param ... the variadic parameters are pointers to each string-type member
2310 template <typename T>
2311 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2312 int numfields, ...) {
2314 va_start(args, numfields);
2316 // Iterate through each string-type field that need to be free.
2317 for (int i = 0; i < numfields; i++) {
2318 // Iterate through each data profile and free that specific string-type field.
2319 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2320 char *T::*ptr = va_arg(args, char *T::*);
2321 for (int j = 0; j < numProfiles; j++) {
2322 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2329 memset(dataProfiles, 0, numProfiles * sizeof(T));
2330 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2333 free(dataProfilePtrs);
2336 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2339 RLOGD("setDataProfile: serial %d", serial);
2341 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2346 size_t num = profiles.size();
2347 bool success = false;
2349 if (s_vendorFunctions->version <= 14) {
2351 RIL_DataProfileInfo *dataProfiles =
2352 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2354 if (dataProfiles == NULL) {
2355 RLOGE("Memory allocation failed for request %s",
2356 requestToString(pRI->pCI->requestNumber));
2357 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2361 RIL_DataProfileInfo **dataProfilePtrs =
2362 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2363 if (dataProfilePtrs == NULL) {
2364 RLOGE("Memory allocation failed for request %s",
2365 requestToString(pRI->pCI->requestNumber));
2367 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2371 for (size_t i = 0; i < num; i++) {
2372 dataProfilePtrs[i] = &dataProfiles[i];
2374 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2376 const hidl_string &protocol =
2377 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2379 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2383 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2386 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2392 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2393 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2394 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2398 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2399 dataProfiles[i].authType = (int) profiles[i].authType;
2400 dataProfiles[i].type = (int) profiles[i].type;
2401 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2402 dataProfiles[i].maxConns = profiles[i].maxConns;
2403 dataProfiles[i].waitTime = profiles[i].waitTime;
2404 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2407 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2408 num * sizeof(RIL_DataProfileInfo *), pRI);
2410 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2411 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2412 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2414 RIL_DataProfileInfo_v15 *dataProfiles =
2415 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2417 if (dataProfiles == NULL) {
2418 RLOGE("Memory allocation failed for request %s",
2419 requestToString(pRI->pCI->requestNumber));
2420 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2424 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2425 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2426 if (dataProfilePtrs == NULL) {
2427 RLOGE("Memory allocation failed for request %s",
2428 requestToString(pRI->pCI->requestNumber));
2430 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2434 for (size_t i = 0; i < num; i++) {
2435 dataProfilePtrs[i] = &dataProfiles[i];
2437 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2438 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2442 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2443 profiles[i].roamingProtocol, pRI)) {
2446 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2449 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2454 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2455 profiles[i].mvnoMatchData, pRI)) {
2459 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2460 dataProfiles[i].mvnoType)) {
2461 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2466 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2467 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2468 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2469 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2473 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2474 dataProfiles[i].authType = (int) profiles[i].authType;
2475 dataProfiles[i].type = (int) profiles[i].type;
2476 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2477 dataProfiles[i].maxConns = profiles[i].maxConns;
2478 dataProfiles[i].waitTime = profiles[i].waitTime;
2479 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2480 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2481 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2482 dataProfiles[i].mtu = profiles[i].mtu;
2485 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2486 num * sizeof(RIL_DataProfileInfo_v15 *), pRI);
2488 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2489 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2490 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2491 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2497 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2499 RLOGD("requestShutdown: serial %d", serial);
2501 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2505 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2507 RLOGD("getRadioCapability: serial %d", serial);
2509 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2513 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2515 RLOGD("setRadioCapability: serial %d", serial);
2517 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2522 RIL_RadioCapability rilRc = {};
2524 // TODO : set rilRc.version using HIDL version ?
2525 rilRc.session = rc.session;
2526 rilRc.phase = (int) rc.phase;
2527 rilRc.rat = (int) rc.raf;
2528 rilRc.status = (int) rc.status;
2529 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2531 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI);
2536 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2538 RLOGD("startLceService: serial %d", serial);
2540 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2541 BOOL_TO_INT(pullMode));
2545 Return<void> RadioImpl::stopLceService(int32_t serial) {
2547 RLOGD("stopLceService: serial %d", serial);
2549 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2553 Return<void> RadioImpl::pullLceData(int32_t serial) {
2555 RLOGD("pullLceData: serial %d", serial);
2557 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2561 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2563 RLOGD("getModemActivityInfo: serial %d", serial);
2565 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2569 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2570 const CarrierRestrictions& carriers) {
2572 RLOGD("setAllowedCarriers: serial %d", serial);
2574 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2575 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2580 RIL_CarrierRestrictions cr = {};
2581 RIL_Carrier *allowedCarriers = NULL;
2582 RIL_Carrier *excludedCarriers = NULL;
2584 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2585 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2586 if (allowedCarriers == NULL) {
2587 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2588 requestToString(pRI->pCI->requestNumber));
2589 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2592 cr.allowed_carriers = allowedCarriers;
2594 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2595 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2596 if (excludedCarriers == NULL) {
2597 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2598 requestToString(pRI->pCI->requestNumber));
2599 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2601 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2603 free(allowedCarriers);
2606 cr.excluded_carriers = excludedCarriers;
2608 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2609 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2610 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2611 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2612 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2615 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2616 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2617 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2618 excludedCarriers[i].match_type =
2619 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2620 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2623 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI);
2626 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2627 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2629 free(allowedCarriers);
2630 free(excludedCarriers);
2634 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2636 RLOGD("getAllowedCarriers: serial %d", serial);
2638 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2642 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2645 RLOGD("sendDeviceState: serial %d", serial);
2647 if (s_vendorFunctions->version < 15) {
2648 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2649 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2650 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2652 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2653 RIL_REQUEST_SEND_DEVICE_STATE);
2654 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2658 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2659 BOOL_TO_INT(state));
2663 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2665 RLOGD("setIndicationFilter: serial %d", serial);
2667 if (s_vendorFunctions->version < 15) {
2668 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2669 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2670 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2673 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2677 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2679 RLOGD("setSimCardPower: serial %d", serial);
2681 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2685 Return<void> RadioImpl::setSimCardPower_1_1(int32_t serial,
2686 const ::android::hardware::radio::V1_1::CardPowerState state) {
2688 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
2690 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
2694 Return<void> RadioImpl::responseAcknowledgement() {
2695 android::releaseWakeLock();
2699 Return<void> OemHookImpl::setResponseFunctions(
2700 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2701 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2703 RLOGD("OemHookImpl::setResponseFunctions");
2706 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2707 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2710 mOemHookResponse = oemHookResponseParam;
2711 mOemHookIndication = oemHookIndicationParam;
2712 mCounterOemHook[mSlotId]++;
2714 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2720 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2722 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2724 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2728 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2729 const hidl_vec<hidl_string>& data) {
2731 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2733 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2737 Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial,
2738 const ::android::hardware::hidl_vec<uint8_t>& carrierKey,
2739 const hidl_string& keyIdentifier) {
2740 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
2741 dispatchRaw(serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION, carrierKey);
2745 /***************************************************************************************************
2746 * RESPONSE FUNCTIONS
2747 * Functions above are used for requests going from framework to vendor code. The ones below are
2748 * responses for those requests coming back from the vendor code.
2749 **************************************************************************************************/
2751 void radio::acknowledgeRequest(int slotId, int serial) {
2752 if (radioService[slotId]->mRadioResponse != NULL) {
2753 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2754 radioService[slotId]->checkReturnStatus(retStatus);
2756 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2760 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2762 responseInfo.serial = serial;
2763 switch (responseType) {
2764 case RESPONSE_SOLICITED:
2765 responseInfo.type = RadioResponseType::SOLICITED;
2767 case RESPONSE_SOLICITED_ACK_EXP:
2768 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2771 responseInfo.error = (RadioError) e;
2774 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2775 void *response, size_t responseLen) {
2776 populateResponseInfo(responseInfo, serial, responseType, e);
2779 if (response == NULL && responseLen == 0) {
2780 // Earlier RILs did not send a response for some cases although the interface
2781 // expected an integer as response. Do not return error if response is empty. Instead
2782 // Return -1 in those cases to maintain backward compatibility.
2783 } else if (response == NULL || responseLen != sizeof(int)) {
2784 RLOGE("responseIntOrEmpty: Invalid response");
2785 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2787 int *p_int = (int *) response;
2793 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2794 void *response, size_t responseLen) {
2795 populateResponseInfo(responseInfo, serial, responseType, e);
2798 if (response == NULL || responseLen != sizeof(int)) {
2799 RLOGE("responseInt: Invalid response");
2800 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2802 int *p_int = (int *) response;
2808 int radio::getIccCardStatusResponse(int slotId,
2809 int responseType, int serial, RIL_Errno e,
2810 void *response, size_t responseLen) {
2811 if (radioService[slotId]->mRadioResponse != NULL) {
2812 RadioResponseInfo responseInfo = {};
2813 populateResponseInfo(responseInfo, serial, responseType, e);
2814 CardStatus cardStatus = {};
2815 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2816 RLOGE("getIccCardStatusResponse: Invalid response");
2817 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2819 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2820 cardStatus.cardState = (CardState) p_cur->card_state;
2821 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2822 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2823 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2824 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2826 RIL_AppStatus *rilAppStatus = p_cur->applications;
2827 cardStatus.applications.resize(p_cur->num_applications);
2828 AppStatus *appStatus = cardStatus.applications.data();
2830 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2832 for (int i = 0; i < p_cur->num_applications; i++) {
2833 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2834 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2835 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2836 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2837 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2838 rilAppStatus[i].app_label_ptr);
2839 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2840 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2841 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2845 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2846 getIccCardStatusResponse(responseInfo, cardStatus);
2847 radioService[slotId]->checkReturnStatus(retStatus);
2849 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2855 int radio::supplyIccPinForAppResponse(int slotId,
2856 int responseType, int serial, RIL_Errno e,
2857 void *response, size_t responseLen) {
2859 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
2862 if (radioService[slotId]->mRadioResponse != NULL) {
2863 RadioResponseInfo responseInfo = {};
2864 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2865 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2866 supplyIccPinForAppResponse(responseInfo, ret);
2867 radioService[slotId]->checkReturnStatus(retStatus);
2869 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2876 int radio::supplyIccPukForAppResponse(int slotId,
2877 int responseType, int serial, RIL_Errno e,
2878 void *response, size_t responseLen) {
2880 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
2883 if (radioService[slotId]->mRadioResponse != NULL) {
2884 RadioResponseInfo responseInfo = {};
2885 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2886 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2888 radioService[slotId]->checkReturnStatus(retStatus);
2890 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2897 int radio::supplyIccPin2ForAppResponse(int slotId,
2898 int responseType, int serial, RIL_Errno e,
2899 void *response, size_t responseLen) {
2901 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
2904 if (radioService[slotId]->mRadioResponse != NULL) {
2905 RadioResponseInfo responseInfo = {};
2906 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2907 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2908 supplyIccPin2ForAppResponse(responseInfo, ret);
2909 radioService[slotId]->checkReturnStatus(retStatus);
2911 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2918 int radio::supplyIccPuk2ForAppResponse(int slotId,
2919 int responseType, int serial, RIL_Errno e,
2920 void *response, size_t responseLen) {
2922 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
2925 if (radioService[slotId]->mRadioResponse != NULL) {
2926 RadioResponseInfo responseInfo = {};
2927 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2928 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2929 supplyIccPuk2ForAppResponse(responseInfo, ret);
2930 radioService[slotId]->checkReturnStatus(retStatus);
2932 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2939 int radio::changeIccPinForAppResponse(int slotId,
2940 int responseType, int serial, RIL_Errno e,
2941 void *response, size_t responseLen) {
2943 RLOGD("changeIccPinForAppResponse: serial %d", serial);
2946 if (radioService[slotId]->mRadioResponse != NULL) {
2947 RadioResponseInfo responseInfo = {};
2948 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2949 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2950 changeIccPinForAppResponse(responseInfo, ret);
2951 radioService[slotId]->checkReturnStatus(retStatus);
2953 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2960 int radio::changeIccPin2ForAppResponse(int slotId,
2961 int responseType, int serial, RIL_Errno e,
2962 void *response, size_t responseLen) {
2964 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
2967 if (radioService[slotId]->mRadioResponse != NULL) {
2968 RadioResponseInfo responseInfo = {};
2969 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2970 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2971 changeIccPin2ForAppResponse(responseInfo, ret);
2972 radioService[slotId]->checkReturnStatus(retStatus);
2974 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2981 int radio::supplyNetworkDepersonalizationResponse(int slotId,
2982 int responseType, int serial, RIL_Errno e,
2983 void *response, size_t responseLen) {
2985 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
2988 if (radioService[slotId]->mRadioResponse != NULL) {
2989 RadioResponseInfo responseInfo = {};
2990 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2991 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2992 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2993 radioService[slotId]->checkReturnStatus(retStatus);
2995 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
3002 int radio::getCurrentCallsResponse(int slotId,
3003 int responseType, int serial, RIL_Errno e,
3004 void *response, size_t responseLen) {
3006 RLOGD("getCurrentCallsResponse: serial %d", serial);
3009 if (radioService[slotId]->mRadioResponse != NULL) {
3010 RadioResponseInfo responseInfo = {};
3011 populateResponseInfo(responseInfo, serial, responseType, e);
3013 hidl_vec<Call> calls;
3014 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) {
3015 RLOGE("getCurrentCallsResponse: Invalid response");
3016 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3018 int num = responseLen / sizeof(RIL_Call *);
3021 for (int i = 0 ; i < num ; i++) {
3022 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3023 /* each call info */
3024 calls[i].state = (CallState) p_cur->state;
3025 calls[i].index = p_cur->index;
3026 calls[i].toa = p_cur->toa;
3027 calls[i].isMpty = p_cur->isMpty;
3028 calls[i].isMT = p_cur->isMT;
3029 calls[i].als = p_cur->als;
3030 calls[i].isVoice = p_cur->isVoice;
3031 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3032 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3033 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3034 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3035 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3036 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3037 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3038 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3039 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3040 // convert uusInfo->uusData to a null-terminated string
3041 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3042 calls[i].uusInfo[0].uusData = nullTermStr;
3048 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3049 getCurrentCallsResponse(responseInfo, calls);
3050 radioService[slotId]->checkReturnStatus(retStatus);
3052 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3058 int radio::dialResponse(int slotId,
3059 int responseType, int serial, RIL_Errno e, void *response,
3060 size_t responseLen) {
3062 RLOGD("dialResponse: serial %d", serial);
3065 if (radioService[slotId]->mRadioResponse != NULL) {
3066 RadioResponseInfo responseInfo = {};
3067 populateResponseInfo(responseInfo, serial, responseType, e);
3068 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3069 radioService[slotId]->checkReturnStatus(retStatus);
3071 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3077 int radio::getIMSIForAppResponse(int slotId,
3078 int responseType, int serial, RIL_Errno e, void *response,
3079 size_t responseLen) {
3081 RLOGD("getIMSIForAppResponse: serial %d", serial);
3084 if (radioService[slotId]->mRadioResponse != NULL) {
3085 RadioResponseInfo responseInfo = {};
3086 populateResponseInfo(responseInfo, serial, responseType, e);
3087 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3088 responseInfo, convertCharPtrToHidlString((char *) response));
3089 radioService[slotId]->checkReturnStatus(retStatus);
3091 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3098 int radio::hangupConnectionResponse(int slotId,
3099 int responseType, int serial, RIL_Errno e,
3100 void *response, size_t responseLen) {
3102 RLOGD("hangupConnectionResponse: serial %d", serial);
3105 if (radioService[slotId]->mRadioResponse != NULL) {
3106 RadioResponseInfo responseInfo = {};
3107 populateResponseInfo(responseInfo, serial, responseType, e);
3108 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3110 radioService[slotId]->checkReturnStatus(retStatus);
3112 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3119 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3120 int responseType, int serial, RIL_Errno e,
3121 void *response, size_t responseLen) {
3123 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3126 if (radioService[slotId]->mRadioResponse != NULL) {
3127 RadioResponseInfo responseInfo = {};
3128 populateResponseInfo(responseInfo, serial, responseType, e);
3129 Return<void> retStatus =
3130 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3132 radioService[slotId]->checkReturnStatus(retStatus);
3134 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3141 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3142 RIL_Errno e, void *response,
3143 size_t responseLen) {
3145 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3148 if (radioService[slotId]->mRadioResponse != NULL) {
3149 RadioResponseInfo responseInfo = {};
3150 populateResponseInfo(responseInfo, serial, responseType, e);
3151 Return<void> retStatus =
3152 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3154 radioService[slotId]->checkReturnStatus(retStatus);
3156 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3163 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3164 RIL_Errno e, void *response,
3165 size_t responseLen) {
3167 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3170 if (radioService[slotId]->mRadioResponse != NULL) {
3171 RadioResponseInfo responseInfo = {};
3172 populateResponseInfo(responseInfo, serial, responseType, e);
3173 Return<void> retStatus =
3174 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3176 radioService[slotId]->checkReturnStatus(retStatus);
3178 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3185 int radio::conferenceResponse(int slotId, int responseType,
3186 int serial, RIL_Errno e, void *response, size_t responseLen) {
3188 RLOGD("conferenceResponse: serial %d", serial);
3191 if (radioService[slotId]->mRadioResponse != NULL) {
3192 RadioResponseInfo responseInfo = {};
3193 populateResponseInfo(responseInfo, serial, responseType, e);
3194 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3196 radioService[slotId]->checkReturnStatus(retStatus);
3198 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3205 int radio::rejectCallResponse(int slotId, int responseType,
3206 int serial, RIL_Errno e, void *response, size_t responseLen) {
3208 RLOGD("rejectCallResponse: serial %d", serial);
3211 if (radioService[slotId]->mRadioResponse != NULL) {
3212 RadioResponseInfo responseInfo = {};
3213 populateResponseInfo(responseInfo, serial, responseType, e);
3214 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3216 radioService[slotId]->checkReturnStatus(retStatus);
3218 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3225 int radio::getLastCallFailCauseResponse(int slotId,
3226 int responseType, int serial, RIL_Errno e, void *response,
3227 size_t responseLen) {
3229 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3232 if (radioService[slotId]->mRadioResponse != NULL) {
3233 RadioResponseInfo responseInfo = {};
3234 populateResponseInfo(responseInfo, serial, responseType, e);
3236 LastCallFailCauseInfo info = {};
3237 info.vendorCause = hidl_string();
3238 if (response == NULL) {
3239 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3240 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3241 } else if (responseLen == sizeof(int)) {
3242 int *pInt = (int *) response;
3243 info.causeCode = (LastCallFailCause) pInt[0];
3244 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3245 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3246 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3247 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3249 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3250 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3253 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3254 responseInfo, info);
3255 radioService[slotId]->checkReturnStatus(retStatus);
3257 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3264 int radio::getSignalStrengthResponse(int slotId,
3265 int responseType, int serial, RIL_Errno e,
3266 void *response, size_t responseLen) {
3268 RLOGD("getSignalStrengthResponse: serial %d", serial);
3271 if (radioService[slotId]->mRadioResponse != NULL) {
3272 RadioResponseInfo responseInfo = {};
3273 populateResponseInfo(responseInfo, serial, responseType, e);
3274 SignalStrength signalStrength = {};
3275 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3276 RLOGE("getSignalStrengthResponse: Invalid response");
3277 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3279 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3282 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3283 responseInfo, signalStrength);
3284 radioService[slotId]->checkReturnStatus(retStatus);
3286 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3293 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3295 return RIL_CELL_INFO_TYPE_NONE;
3298 int radioTech = atoi(rat);
3302 case RADIO_TECH_GPRS:
3303 case RADIO_TECH_EDGE:
3304 case RADIO_TECH_GSM: {
3305 return RIL_CELL_INFO_TYPE_GSM;
3308 case RADIO_TECH_UMTS:
3309 case RADIO_TECH_HSDPA:
3310 case RADIO_TECH_HSUPA:
3311 case RADIO_TECH_HSPA:
3312 case RADIO_TECH_HSPAP: {
3313 return RIL_CELL_INFO_TYPE_WCDMA;
3316 case RADIO_TECH_IS95A:
3317 case RADIO_TECH_IS95B:
3318 case RADIO_TECH_1xRTT:
3319 case RADIO_TECH_EVDO_0:
3320 case RADIO_TECH_EVDO_A:
3321 case RADIO_TECH_EVDO_B:
3322 case RADIO_TECH_EHRPD: {
3323 return RIL_CELL_INFO_TYPE_CDMA;
3326 case RADIO_TECH_LTE:
3327 case RADIO_TECH_LTE_CA: {
3328 return RIL_CELL_INFO_TYPE_LTE;
3331 case RADIO_TECH_TD_SCDMA: {
3332 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3340 return RIL_CELL_INFO_TYPE_NONE;
3344 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3346 cellIdentity.cellIdentityGsm.resize(0);
3347 cellIdentity.cellIdentityWcdma.resize(0);
3348 cellIdentity.cellIdentityCdma.resize(0);
3349 cellIdentity.cellIdentityTdscdma.resize(0);
3350 cellIdentity.cellIdentityLte.resize(0);
3351 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3352 switch(rilCellIdentity.cellInfoType) {
3354 case RIL_CELL_INFO_TYPE_GSM: {
3355 cellIdentity.cellIdentityGsm.resize(1);
3356 cellIdentity.cellIdentityGsm[0].mcc =
3357 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3358 cellIdentity.cellIdentityGsm[0].mnc =
3359 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3360 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3361 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3362 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3363 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3367 case RIL_CELL_INFO_TYPE_WCDMA: {
3368 cellIdentity.cellIdentityWcdma.resize(1);
3369 cellIdentity.cellIdentityWcdma[0].mcc =
3370 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3371 cellIdentity.cellIdentityWcdma[0].mnc =
3372 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3373 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3374 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3375 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3376 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3380 case RIL_CELL_INFO_TYPE_CDMA: {
3381 cellIdentity.cellIdentityCdma.resize(1);
3382 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3383 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3384 cellIdentity.cellIdentityCdma[0].baseStationId =
3385 rilCellIdentity.cellIdentityCdma.basestationId;
3386 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3387 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3391 case RIL_CELL_INFO_TYPE_LTE: {
3392 cellIdentity.cellIdentityLte.resize(1);
3393 cellIdentity.cellIdentityLte[0].mcc =
3394 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3395 cellIdentity.cellIdentityLte[0].mnc =
3396 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3397 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3398 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3399 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3400 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3404 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3405 cellIdentity.cellIdentityTdscdma.resize(1);
3406 cellIdentity.cellIdentityTdscdma[0].mcc =
3407 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3408 cellIdentity.cellIdentityTdscdma[0].mnc =
3409 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3410 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3411 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3412 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3422 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3423 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3424 return atoi(response[index]);
3430 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3431 int numStrings, char** response) {
3433 RIL_CellIdentity_v16 rilCellIdentity;
3434 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3436 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3437 switch(rilCellIdentity.cellInfoType) {
3439 case RIL_CELL_INFO_TYPE_GSM: {
3440 rilCellIdentity.cellIdentityGsm.lac =
3441 convertResponseStringEntryToInt(response, 1, numStrings);
3442 rilCellIdentity.cellIdentityGsm.cid =
3443 convertResponseStringEntryToInt(response, 2, numStrings);
3447 case RIL_CELL_INFO_TYPE_WCDMA: {
3448 rilCellIdentity.cellIdentityWcdma.lac =
3449 convertResponseStringEntryToInt(response, 1, numStrings);
3450 rilCellIdentity.cellIdentityWcdma.cid =
3451 convertResponseStringEntryToInt(response, 2, numStrings);
3452 rilCellIdentity.cellIdentityWcdma.psc =
3453 convertResponseStringEntryToInt(response, 14, 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);
3465 case RIL_CELL_INFO_TYPE_CDMA:{
3466 rilCellIdentity.cellIdentityCdma.basestationId =
3467 convertResponseStringEntryToInt(response, 4, numStrings);
3468 rilCellIdentity.cellIdentityCdma.longitude =
3469 convertResponseStringEntryToInt(response, 5, numStrings);
3470 rilCellIdentity.cellIdentityCdma.latitude =
3471 convertResponseStringEntryToInt(response, 6, numStrings);
3472 rilCellIdentity.cellIdentityCdma.systemId =
3473 convertResponseStringEntryToInt(response, 8, numStrings);
3474 rilCellIdentity.cellIdentityCdma.networkId =
3475 convertResponseStringEntryToInt(response, 9, numStrings);
3479 case RIL_CELL_INFO_TYPE_LTE:{
3480 rilCellIdentity.cellIdentityLte.tac =
3481 convertResponseStringEntryToInt(response, 1, numStrings);
3482 rilCellIdentity.cellIdentityLte.ci =
3483 convertResponseStringEntryToInt(response, 2, numStrings);
3492 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3495 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3496 int numStrings, char** response) {
3498 RIL_CellIdentity_v16 rilCellIdentity;
3499 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3501 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3502 switch(rilCellIdentity.cellInfoType) {
3503 case RIL_CELL_INFO_TYPE_GSM: {
3504 rilCellIdentity.cellIdentityGsm.lac =
3505 convertResponseStringEntryToInt(response, 1, numStrings);
3506 rilCellIdentity.cellIdentityGsm.cid =
3507 convertResponseStringEntryToInt(response, 2, numStrings);
3510 case RIL_CELL_INFO_TYPE_WCDMA: {
3511 rilCellIdentity.cellIdentityWcdma.lac =
3512 convertResponseStringEntryToInt(response, 1, numStrings);
3513 rilCellIdentity.cellIdentityWcdma.cid =
3514 convertResponseStringEntryToInt(response, 2, numStrings);
3517 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3518 rilCellIdentity.cellIdentityTdscdma.lac =
3519 convertResponseStringEntryToInt(response, 1, numStrings);
3520 rilCellIdentity.cellIdentityTdscdma.cid =
3521 convertResponseStringEntryToInt(response, 2, numStrings);
3524 case RIL_CELL_INFO_TYPE_LTE: {
3525 rilCellIdentity.cellIdentityLte.tac =
3526 convertResponseStringEntryToInt(response, 6, numStrings);
3527 rilCellIdentity.cellIdentityLte.pci =
3528 convertResponseStringEntryToInt(response, 7, numStrings);
3529 rilCellIdentity.cellIdentityLte.ci =
3530 convertResponseStringEntryToInt(response, 8, numStrings);
3538 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3541 int radio::getVoiceRegistrationStateResponse(int slotId,
3542 int responseType, int serial, RIL_Errno e,
3543 void *response, size_t responseLen) {
3545 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3548 if (radioService[slotId]->mRadioResponse != NULL) {
3549 RadioResponseInfo responseInfo = {};
3550 populateResponseInfo(responseInfo, serial, responseType, e);
3552 VoiceRegStateResult voiceRegResponse = {};
3553 int numStrings = responseLen / sizeof(char *);
3554 if (response == NULL) {
3555 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3556 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3557 } else if (s_vendorFunctions->version <= 14) {
3558 if (numStrings != 15) {
3559 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3560 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3562 char **resp = (char **) response;
3563 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3564 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3565 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3566 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3567 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3568 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3569 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3570 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3574 RIL_VoiceRegistrationStateResponse *voiceRegState =
3575 (RIL_VoiceRegistrationStateResponse *)response;
3577 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3578 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3579 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3581 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3582 voiceRegResponse.rat = voiceRegState->rat;;
3583 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3584 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3585 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3586 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3587 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3588 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3589 voiceRegState->cellIdentity);
3593 Return<void> retStatus =
3594 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3595 responseInfo, voiceRegResponse);
3596 radioService[slotId]->checkReturnStatus(retStatus);
3598 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3605 int radio::getDataRegistrationStateResponse(int slotId,
3606 int responseType, int serial, RIL_Errno e,
3607 void *response, size_t responseLen) {
3609 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3612 if (radioService[slotId]->mRadioResponse != NULL) {
3613 RadioResponseInfo responseInfo = {};
3614 populateResponseInfo(responseInfo, serial, responseType, e);
3615 DataRegStateResult dataRegResponse = {};
3616 if (response == NULL) {
3617 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3618 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3619 } else if (s_vendorFunctions->version <= 14) {
3620 int numStrings = responseLen / sizeof(char *);
3621 if ((numStrings != 6) && (numStrings != 11)) {
3622 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3623 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3625 char **resp = (char **) response;
3626 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3627 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3628 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3629 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3630 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3634 RIL_DataRegistrationStateResponse *dataRegState =
3635 (RIL_DataRegistrationStateResponse *)response;
3637 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3638 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3639 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3641 dataRegResponse.regState = (RegState) dataRegState->regState;
3642 dataRegResponse.rat = dataRegState->rat;;
3643 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3644 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3645 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3649 Return<void> retStatus =
3650 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3652 radioService[slotId]->checkReturnStatus(retStatus);
3654 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3661 int radio::getOperatorResponse(int slotId,
3662 int responseType, int serial, RIL_Errno e, void *response,
3663 size_t responseLen) {
3665 RLOGD("getOperatorResponse: serial %d", serial);
3668 if (radioService[slotId]->mRadioResponse != NULL) {
3669 RadioResponseInfo responseInfo = {};
3670 populateResponseInfo(responseInfo, serial, responseType, e);
3671 hidl_string longName;
3672 hidl_string shortName;
3673 hidl_string numeric;
3674 int numStrings = responseLen / sizeof(char *);
3675 if (response == NULL || numStrings != 3) {
3676 RLOGE("getOperatorResponse Invalid response: NULL");
3677 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3680 char **resp = (char **) response;
3681 longName = convertCharPtrToHidlString(resp[0]);
3682 shortName = convertCharPtrToHidlString(resp[1]);
3683 numeric = convertCharPtrToHidlString(resp[2]);
3685 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3686 responseInfo, longName, shortName, numeric);
3687 radioService[slotId]->checkReturnStatus(retStatus);
3689 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3696 int radio::setRadioPowerResponse(int slotId,
3697 int responseType, int serial, RIL_Errno e, void *response,
3698 size_t responseLen) {
3699 RLOGD("setRadioPowerResponse: serial %d", serial);
3701 if (radioService[slotId]->mRadioResponse != NULL) {
3702 RadioResponseInfo responseInfo = {};
3703 populateResponseInfo(responseInfo, serial, responseType, e);
3704 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3706 radioService[slotId]->checkReturnStatus(retStatus);
3708 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3715 int radio::sendDtmfResponse(int slotId,
3716 int responseType, int serial, RIL_Errno e, void *response,
3717 size_t responseLen) {
3719 RLOGD("sendDtmfResponse: serial %d", serial);
3722 if (radioService[slotId]->mRadioResponse != NULL) {
3723 RadioResponseInfo responseInfo = {};
3724 populateResponseInfo(responseInfo, serial, responseType, e);
3725 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3727 radioService[slotId]->checkReturnStatus(retStatus);
3729 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3736 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3737 RIL_Errno e, void *response, size_t responseLen) {
3738 populateResponseInfo(responseInfo, serial, responseType, e);
3739 SendSmsResult result = {};
3741 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3742 RLOGE("Invalid response: NULL");
3743 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3744 result.ackPDU = hidl_string();
3746 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3747 result.messageRef = resp->messageRef;
3748 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3749 result.errorCode = resp->errorCode;
3754 int radio::sendSmsResponse(int slotId,
3755 int responseType, int serial, RIL_Errno e, void *response,
3756 size_t responseLen) {
3758 RLOGD("sendSmsResponse: serial %d", serial);
3761 if (radioService[slotId]->mRadioResponse != NULL) {
3762 RadioResponseInfo responseInfo = {};
3763 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3766 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3768 radioService[slotId]->checkReturnStatus(retStatus);
3770 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3776 int radio::sendSMSExpectMoreResponse(int slotId,
3777 int responseType, int serial, RIL_Errno e, void *response,
3778 size_t responseLen) {
3780 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3783 if (radioService[slotId]->mRadioResponse != NULL) {
3784 RadioResponseInfo responseInfo = {};
3785 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3788 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3789 responseInfo, result);
3790 radioService[slotId]->checkReturnStatus(retStatus);
3792 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3798 int radio::setupDataCallResponse(int slotId,
3799 int responseType, int serial, RIL_Errno e, void *response,
3800 size_t responseLen) {
3802 RLOGD("setupDataCallResponse: serial %d", serial);
3805 if (radioService[slotId]->mRadioResponse != NULL) {
3806 RadioResponseInfo responseInfo = {};
3807 populateResponseInfo(responseInfo, serial, responseType, e);
3809 SetupDataCallResult result = {};
3810 if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) {
3811 RLOGE("setupDataCallResponse: Invalid response");
3812 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3813 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3814 result.type = hidl_string();
3815 result.ifname = hidl_string();
3816 result.addresses = hidl_string();
3817 result.dnses = hidl_string();
3818 result.gateways = hidl_string();
3819 result.pcscf = hidl_string();
3821 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3824 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3825 responseInfo, result);
3826 radioService[slotId]->checkReturnStatus(retStatus);
3828 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3834 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3835 RIL_Errno e, void *response, size_t responseLen) {
3836 populateResponseInfo(responseInfo, serial, responseType, e);
3837 IccIoResult result = {};
3839 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3840 RLOGE("Invalid response: NULL");
3841 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3842 result.simResponse = hidl_string();
3844 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3845 result.sw1 = resp->sw1;
3846 result.sw2 = resp->sw2;
3847 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3852 int radio::iccIOForAppResponse(int slotId,
3853 int responseType, int serial, RIL_Errno e, void *response,
3854 size_t responseLen) {
3856 RLOGD("iccIOForAppResponse: serial %d", serial);
3859 if (radioService[slotId]->mRadioResponse != NULL) {
3860 RadioResponseInfo responseInfo = {};
3861 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3864 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3865 responseInfo, result);
3866 radioService[slotId]->checkReturnStatus(retStatus);
3868 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3874 int radio::sendUssdResponse(int slotId,
3875 int responseType, int serial, RIL_Errno e, void *response,
3876 size_t responseLen) {
3878 RLOGD("sendUssdResponse: serial %d", serial);
3881 if (radioService[slotId]->mRadioResponse != NULL) {
3882 RadioResponseInfo responseInfo = {};
3883 populateResponseInfo(responseInfo, serial, responseType, e);
3884 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3886 radioService[slotId]->checkReturnStatus(retStatus);
3888 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3895 int radio::cancelPendingUssdResponse(int slotId,
3896 int responseType, int serial, RIL_Errno e, void *response,
3897 size_t responseLen) {
3899 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3902 if (radioService[slotId]->mRadioResponse != NULL) {
3903 RadioResponseInfo responseInfo = {};
3904 populateResponseInfo(responseInfo, serial, responseType, e);
3905 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3907 radioService[slotId]->checkReturnStatus(retStatus);
3909 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3916 int radio::getClirResponse(int slotId,
3917 int responseType, int serial, RIL_Errno e, void *response,
3918 size_t responseLen) {
3920 RLOGD("getClirResponse: serial %d", serial);
3923 if (radioService[slotId]->mRadioResponse != NULL) {
3924 RadioResponseInfo responseInfo = {};
3925 populateResponseInfo(responseInfo, serial, responseType, e);
3927 int numInts = responseLen / sizeof(int);
3928 if (response == NULL || numInts != 2) {
3929 RLOGE("getClirResponse Invalid response: NULL");
3930 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3932 int *pInt = (int *) response;
3936 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3938 radioService[slotId]->checkReturnStatus(retStatus);
3940 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3946 int radio::setClirResponse(int slotId,
3947 int responseType, int serial, RIL_Errno e, void *response,
3948 size_t responseLen) {
3950 RLOGD("setClirResponse: 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->setClirResponse(
3958 radioService[slotId]->checkReturnStatus(retStatus);
3960 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3966 int radio::getCallForwardStatusResponse(int slotId,
3967 int responseType, int serial, RIL_Errno e,
3968 void *response, size_t responseLen) {
3970 RLOGD("getCallForwardStatusResponse: serial %d", serial);
3973 if (radioService[slotId]->mRadioResponse != NULL) {
3974 RadioResponseInfo responseInfo = {};
3975 populateResponseInfo(responseInfo, serial, responseType, e);
3976 hidl_vec<CallForwardInfo> callForwardInfos;
3978 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
3979 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
3980 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3982 int num = responseLen / sizeof(RIL_CallForwardInfo *);
3983 callForwardInfos.resize(num);
3984 for (int i = 0 ; i < num; i++) {
3985 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
3986 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
3987 callForwardInfos[i].reason = resp->reason;
3988 callForwardInfos[i].serviceClass = resp->serviceClass;
3989 callForwardInfos[i].toa = resp->toa;
3990 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
3991 callForwardInfos[i].timeSeconds = resp->timeSeconds;
3995 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
3996 responseInfo, callForwardInfos);
3997 radioService[slotId]->checkReturnStatus(retStatus);
3999 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4006 int radio::setCallForwardResponse(int slotId,
4007 int responseType, int serial, RIL_Errno e, void *response,
4008 size_t responseLen) {
4010 RLOGD("setCallForwardResponse: serial %d", serial);
4013 if (radioService[slotId]->mRadioResponse != NULL) {
4014 RadioResponseInfo responseInfo = {};
4015 populateResponseInfo(responseInfo, serial, responseType, e);
4016 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4018 radioService[slotId]->checkReturnStatus(retStatus);
4020 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4026 int radio::getCallWaitingResponse(int slotId,
4027 int responseType, int serial, RIL_Errno e, void *response,
4028 size_t responseLen) {
4030 RLOGD("getCallWaitingResponse: serial %d", serial);
4033 if (radioService[slotId]->mRadioResponse != NULL) {
4034 RadioResponseInfo responseInfo = {};
4035 populateResponseInfo(responseInfo, serial, responseType, e);
4036 bool enable = false;
4037 int serviceClass = -1;
4038 int numInts = responseLen / sizeof(int);
4039 if (response == NULL || numInts != 2) {
4040 RLOGE("getCallWaitingResponse Invalid response: NULL");
4041 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4043 int *pInt = (int *) response;
4044 enable = pInt[0] == 1 ? true : false;
4045 serviceClass = pInt[1];
4047 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4048 responseInfo, enable, serviceClass);
4049 radioService[slotId]->checkReturnStatus(retStatus);
4051 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4057 int radio::setCallWaitingResponse(int slotId,
4058 int responseType, int serial, RIL_Errno e, void *response,
4059 size_t responseLen) {
4061 RLOGD("setCallWaitingResponse: serial %d", serial);
4064 if (radioService[slotId]->mRadioResponse != NULL) {
4065 RadioResponseInfo responseInfo = {};
4066 populateResponseInfo(responseInfo, serial, responseType, e);
4067 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4069 radioService[slotId]->checkReturnStatus(retStatus);
4071 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4077 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4078 int responseType, int serial, RIL_Errno e,
4079 void *response, size_t responseLen) {
4081 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4084 if (radioService[slotId]->mRadioResponse != NULL) {
4085 RadioResponseInfo responseInfo = {};
4086 populateResponseInfo(responseInfo, serial, responseType, e);
4087 Return<void> retStatus =
4088 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4090 radioService[slotId]->checkReturnStatus(retStatus);
4092 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4099 int radio::acceptCallResponse(int slotId,
4100 int responseType, int serial, RIL_Errno e,
4101 void *response, size_t responseLen) {
4103 RLOGD("acceptCallResponse: serial %d", serial);
4106 if (radioService[slotId]->mRadioResponse != NULL) {
4107 RadioResponseInfo responseInfo = {};
4108 populateResponseInfo(responseInfo, serial, responseType, e);
4109 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4111 radioService[slotId]->checkReturnStatus(retStatus);
4113 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4120 int radio::deactivateDataCallResponse(int slotId,
4121 int responseType, int serial, RIL_Errno e,
4122 void *response, size_t responseLen) {
4124 RLOGD("deactivateDataCallResponse: serial %d", serial);
4127 if (radioService[slotId]->mRadioResponse != NULL) {
4128 RadioResponseInfo responseInfo = {};
4129 populateResponseInfo(responseInfo, serial, responseType, e);
4130 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4132 radioService[slotId]->checkReturnStatus(retStatus);
4134 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4141 int radio::getFacilityLockForAppResponse(int slotId,
4142 int responseType, int serial, RIL_Errno e,
4143 void *response, size_t responseLen) {
4145 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4148 if (radioService[slotId]->mRadioResponse != NULL) {
4149 RadioResponseInfo responseInfo = {};
4150 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4151 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4152 getFacilityLockForAppResponse(responseInfo, ret);
4153 radioService[slotId]->checkReturnStatus(retStatus);
4155 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4162 int radio::setFacilityLockForAppResponse(int slotId,
4163 int responseType, int serial, RIL_Errno e,
4164 void *response, size_t responseLen) {
4166 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4169 if (radioService[slotId]->mRadioResponse != NULL) {
4170 RadioResponseInfo responseInfo = {};
4171 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4172 Return<void> retStatus
4173 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4175 radioService[slotId]->checkReturnStatus(retStatus);
4177 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4184 int radio::setBarringPasswordResponse(int slotId,
4185 int responseType, int serial, RIL_Errno e,
4186 void *response, size_t responseLen) {
4188 RLOGD("acceptCallResponse: serial %d", serial);
4191 if (radioService[slotId]->mRadioResponse != NULL) {
4192 RadioResponseInfo responseInfo = {};
4193 populateResponseInfo(responseInfo, serial, responseType, e);
4194 Return<void> retStatus
4195 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4196 radioService[slotId]->checkReturnStatus(retStatus);
4198 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4205 int radio::getNetworkSelectionModeResponse(int slotId,
4206 int responseType, int serial, RIL_Errno e, void *response,
4207 size_t responseLen) {
4209 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4212 if (radioService[slotId]->mRadioResponse != NULL) {
4213 RadioResponseInfo responseInfo = {};
4214 populateResponseInfo(responseInfo, serial, responseType, e);
4215 bool manual = false;
4217 if (response == NULL || responseLen != sizeof(int)) {
4218 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4219 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4221 int *pInt = (int *) response;
4222 manual = pInt[0] == 1 ? true : false;
4224 Return<void> retStatus
4225 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4228 radioService[slotId]->checkReturnStatus(retStatus);
4230 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4237 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4238 RIL_Errno e, void *response,
4239 size_t responseLen) {
4241 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4244 if (radioService[slotId]->mRadioResponse != NULL) {
4245 RadioResponseInfo responseInfo = {};
4246 populateResponseInfo(responseInfo, serial, responseType, e);
4247 Return<void> retStatus
4248 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4250 radioService[slotId]->checkReturnStatus(retStatus);
4252 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4259 int radio::setNetworkSelectionModeManualResponse(int slotId,
4260 int responseType, int serial, RIL_Errno e,
4261 void *response, size_t responseLen) {
4263 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4266 if (radioService[slotId]->mRadioResponse != NULL) {
4267 RadioResponseInfo responseInfo = {};
4268 populateResponseInfo(responseInfo, serial, responseType, e);
4269 Return<void> retStatus
4270 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4272 radioService[slotId]->checkReturnStatus(retStatus);
4274 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4281 int convertOperatorStatusToInt(const char *str) {
4282 if (strncmp("unknown", str, 9) == 0) {
4283 return (int) OperatorStatus::UNKNOWN;
4284 } else if (strncmp("available", str, 9) == 0) {
4285 return (int) OperatorStatus::AVAILABLE;
4286 } else if (strncmp("current", str, 9) == 0) {
4287 return (int) OperatorStatus::CURRENT;
4288 } else if (strncmp("forbidden", str, 9) == 0) {
4289 return (int) OperatorStatus::FORBIDDEN;
4295 int radio::getAvailableNetworksResponse(int slotId,
4296 int responseType, int serial, RIL_Errno e, void *response,
4297 size_t responseLen) {
4299 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4302 if (radioService[slotId]->mRadioResponse != NULL) {
4303 RadioResponseInfo responseInfo = {};
4304 populateResponseInfo(responseInfo, serial, responseType, e);
4305 hidl_vec<OperatorInfo> networks;
4306 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) {
4307 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4308 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4310 char **resp = (char **) response;
4311 int numStrings = responseLen / sizeof(char *);
4312 networks.resize(numStrings/4);
4313 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4314 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4315 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4316 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4317 int status = convertOperatorStatusToInt(resp[i + 3]);
4319 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4321 networks[j].status = (OperatorStatus) status;
4325 Return<void> retStatus
4326 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4328 radioService[slotId]->checkReturnStatus(retStatus);
4330 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4337 int radio::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
4338 void *response, size_t responseLen) {
4340 RLOGD("startNetworkScanResponse: serial %d", serial);
4342 // TODO(b/30954762): Add implementation to generate startNetworkScanResponse.
4346 int radio::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
4347 void *response, size_t responseLen) {
4349 RLOGD("stopNetworkScanResponse: serial %d", serial);
4351 // TODO(b/30954762): Add implementation to generate stopNetworkScanResponse.
4355 int radio::startDtmfResponse(int slotId,
4356 int responseType, int serial, RIL_Errno e,
4357 void *response, size_t responseLen) {
4359 RLOGD("startDtmfResponse: serial %d", serial);
4362 if (radioService[slotId]->mRadioResponse != NULL) {
4363 RadioResponseInfo responseInfo = {};
4364 populateResponseInfo(responseInfo, serial, responseType, e);
4365 Return<void> retStatus
4366 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4367 radioService[slotId]->checkReturnStatus(retStatus);
4369 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4375 int radio::stopDtmfResponse(int slotId,
4376 int responseType, int serial, RIL_Errno e,
4377 void *response, size_t responseLen) {
4379 RLOGD("stopDtmfResponse: serial %d", serial);
4382 if (radioService[slotId]->mRadioResponse != NULL) {
4383 RadioResponseInfo responseInfo = {};
4384 populateResponseInfo(responseInfo, serial, responseType, e);
4385 Return<void> retStatus
4386 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4387 radioService[slotId]->checkReturnStatus(retStatus);
4389 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4395 int radio::getBasebandVersionResponse(int slotId,
4396 int responseType, int serial, RIL_Errno e,
4397 void *response, size_t responseLen) {
4399 RLOGD("getBasebandVersionResponse: serial %d", serial);
4402 if (radioService[slotId]->mRadioResponse != NULL) {
4403 RadioResponseInfo responseInfo = {};
4404 populateResponseInfo(responseInfo, serial, responseType, e);
4405 Return<void> retStatus
4406 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4407 convertCharPtrToHidlString((char *) response));
4408 radioService[slotId]->checkReturnStatus(retStatus);
4410 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4416 int radio::separateConnectionResponse(int slotId,
4417 int responseType, int serial, RIL_Errno e,
4418 void *response, size_t responseLen) {
4420 RLOGD("separateConnectionResponse: serial %d", serial);
4423 if (radioService[slotId]->mRadioResponse != NULL) {
4424 RadioResponseInfo responseInfo = {};
4425 populateResponseInfo(responseInfo, serial, responseType, e);
4426 Return<void> retStatus
4427 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4428 radioService[slotId]->checkReturnStatus(retStatus);
4430 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4437 int radio::setMuteResponse(int slotId,
4438 int responseType, int serial, RIL_Errno e,
4439 void *response, size_t responseLen) {
4441 RLOGD("setMuteResponse: serial %d", serial);
4444 if (radioService[slotId]->mRadioResponse != NULL) {
4445 RadioResponseInfo responseInfo = {};
4446 populateResponseInfo(responseInfo, serial, responseType, e);
4447 Return<void> retStatus
4448 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4449 radioService[slotId]->checkReturnStatus(retStatus);
4451 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4457 int radio::getMuteResponse(int slotId,
4458 int responseType, int serial, RIL_Errno e, void *response,
4459 size_t responseLen) {
4461 RLOGD("getMuteResponse: serial %d", serial);
4464 if (radioService[slotId]->mRadioResponse != NULL) {
4465 RadioResponseInfo responseInfo = {};
4466 populateResponseInfo(responseInfo, serial, responseType, e);
4467 bool enable = false;
4469 if (response == NULL || responseLen != sizeof(int)) {
4470 RLOGE("getMuteResponse Invalid response: NULL");
4471 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4473 int *pInt = (int *) response;
4474 enable = pInt[0] == 1 ? true : false;
4476 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4478 radioService[slotId]->checkReturnStatus(retStatus);
4480 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4486 int radio::getClipResponse(int slotId,
4487 int responseType, int serial, RIL_Errno e,
4488 void *response, size_t responseLen) {
4490 RLOGD("getClipResponse: serial %d", serial);
4493 if (radioService[slotId]->mRadioResponse != NULL) {
4494 RadioResponseInfo responseInfo = {};
4495 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4496 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4498 radioService[slotId]->checkReturnStatus(retStatus);
4500 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4506 int radio::getDataCallListResponse(int slotId,
4507 int responseType, int serial, RIL_Errno e,
4508 void *response, size_t responseLen) {
4510 RLOGD("getDataCallListResponse: serial %d", serial);
4513 if (radioService[slotId]->mRadioResponse != NULL) {
4514 RadioResponseInfo responseInfo = {};
4515 populateResponseInfo(responseInfo, serial, responseType, e);
4517 hidl_vec<SetupDataCallResult> ret;
4518 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4519 RLOGE("getDataCallListResponse: invalid response");
4520 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4522 convertRilDataCallListToHal(response, responseLen, ret);
4525 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4527 radioService[slotId]->checkReturnStatus(retStatus);
4529 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4535 int radio::setSuppServiceNotificationsResponse(int slotId,
4536 int responseType, int serial, RIL_Errno e,
4537 void *response, size_t responseLen) {
4539 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4542 if (radioService[slotId]->mRadioResponse != NULL) {
4543 RadioResponseInfo responseInfo = {};
4544 populateResponseInfo(responseInfo, serial, responseType, e);
4545 Return<void> retStatus
4546 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4548 radioService[slotId]->checkReturnStatus(retStatus);
4550 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4557 int radio::deleteSmsOnSimResponse(int slotId,
4558 int responseType, int serial, RIL_Errno e,
4559 void *response, size_t responseLen) {
4561 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4564 if (radioService[slotId]->mRadioResponse != NULL) {
4565 RadioResponseInfo responseInfo = {};
4566 populateResponseInfo(responseInfo, serial, responseType, e);
4567 Return<void> retStatus
4568 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4569 radioService[slotId]->checkReturnStatus(retStatus);
4571 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4577 int radio::setBandModeResponse(int slotId,
4578 int responseType, int serial, RIL_Errno e,
4579 void *response, size_t responseLen) {
4581 RLOGD("setBandModeResponse: serial %d", serial);
4584 if (radioService[slotId]->mRadioResponse != NULL) {
4585 RadioResponseInfo responseInfo = {};
4586 populateResponseInfo(responseInfo, serial, responseType, e);
4587 Return<void> retStatus
4588 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4589 radioService[slotId]->checkReturnStatus(retStatus);
4591 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4597 int radio::writeSmsToSimResponse(int slotId,
4598 int responseType, int serial, RIL_Errno e,
4599 void *response, size_t responseLen) {
4601 RLOGD("writeSmsToSimResponse: serial %d", serial);
4604 if (radioService[slotId]->mRadioResponse != NULL) {
4605 RadioResponseInfo responseInfo = {};
4606 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4607 Return<void> retStatus
4608 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4609 radioService[slotId]->checkReturnStatus(retStatus);
4611 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4617 int radio::getAvailableBandModesResponse(int slotId,
4618 int responseType, int serial, RIL_Errno e, void *response,
4619 size_t responseLen) {
4621 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4624 if (radioService[slotId]->mRadioResponse != NULL) {
4625 RadioResponseInfo responseInfo = {};
4626 populateResponseInfo(responseInfo, serial, responseType, e);
4627 hidl_vec<RadioBandMode> modes;
4628 if (response == NULL || responseLen % sizeof(int) != 0) {
4629 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4630 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4632 int *pInt = (int *) response;
4633 int numInts = responseLen / sizeof(int);
4634 modes.resize(numInts);
4635 for (int i = 0; i < numInts; i++) {
4636 modes[i] = (RadioBandMode) pInt[i];
4639 Return<void> retStatus
4640 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4642 radioService[slotId]->checkReturnStatus(retStatus);
4644 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4651 int radio::sendEnvelopeResponse(int slotId,
4652 int responseType, int serial, RIL_Errno e,
4653 void *response, size_t responseLen) {
4655 RLOGD("sendEnvelopeResponse: serial %d", serial);
4658 if (radioService[slotId]->mRadioResponse != NULL) {
4659 RadioResponseInfo responseInfo = {};
4660 populateResponseInfo(responseInfo, serial, responseType, e);
4661 Return<void> retStatus
4662 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4663 convertCharPtrToHidlString((char *) response));
4664 radioService[slotId]->checkReturnStatus(retStatus);
4666 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4672 int radio::sendTerminalResponseToSimResponse(int slotId,
4673 int responseType, int serial, RIL_Errno e,
4674 void *response, size_t responseLen) {
4676 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4679 if (radioService[slotId]->mRadioResponse != NULL) {
4680 RadioResponseInfo responseInfo = {};
4681 populateResponseInfo(responseInfo, serial, responseType, e);
4682 Return<void> retStatus
4683 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4685 radioService[slotId]->checkReturnStatus(retStatus);
4687 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4694 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4695 int responseType, int serial,
4696 RIL_Errno e, void *response,
4697 size_t responseLen) {
4699 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4702 if (radioService[slotId]->mRadioResponse != NULL) {
4703 RadioResponseInfo responseInfo = {};
4704 populateResponseInfo(responseInfo, serial, responseType, e);
4705 Return<void> retStatus
4706 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4708 radioService[slotId]->checkReturnStatus(retStatus);
4710 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4717 int radio::explicitCallTransferResponse(int slotId,
4718 int responseType, int serial, RIL_Errno e,
4719 void *response, size_t responseLen) {
4721 RLOGD("explicitCallTransferResponse: serial %d", serial);
4724 if (radioService[slotId]->mRadioResponse != NULL) {
4725 RadioResponseInfo responseInfo = {};
4726 populateResponseInfo(responseInfo, serial, responseType, e);
4727 Return<void> retStatus
4728 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4729 radioService[slotId]->checkReturnStatus(retStatus);
4731 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4738 int radio::setPreferredNetworkTypeResponse(int slotId,
4739 int responseType, int serial, RIL_Errno e,
4740 void *response, size_t responseLen) {
4742 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4745 if (radioService[slotId]->mRadioResponse != NULL) {
4746 RadioResponseInfo responseInfo = {};
4747 populateResponseInfo(responseInfo, serial, responseType, e);
4748 Return<void> retStatus
4749 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4751 radioService[slotId]->checkReturnStatus(retStatus);
4753 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4761 int radio::getPreferredNetworkTypeResponse(int slotId,
4762 int responseType, int serial, RIL_Errno e,
4763 void *response, size_t responseLen) {
4765 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4768 if (radioService[slotId]->mRadioResponse != NULL) {
4769 RadioResponseInfo responseInfo = {};
4770 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4771 Return<void> retStatus
4772 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4773 responseInfo, (PreferredNetworkType) ret);
4774 radioService[slotId]->checkReturnStatus(retStatus);
4776 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4783 int radio::getNeighboringCidsResponse(int slotId,
4784 int responseType, int serial, RIL_Errno e,
4785 void *response, size_t responseLen) {
4787 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4790 if (radioService[slotId]->mRadioResponse != NULL) {
4791 RadioResponseInfo responseInfo = {};
4792 populateResponseInfo(responseInfo, serial, responseType, e);
4793 hidl_vec<NeighboringCell> cells;
4795 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4796 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4797 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4799 int num = responseLen / sizeof(RIL_NeighboringCell *);
4801 for (int i = 0 ; i < num; i++) {
4802 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4803 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4804 cells[i].rssi = resp->rssi;
4808 Return<void> retStatus
4809 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4811 radioService[slotId]->checkReturnStatus(retStatus);
4813 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4820 int radio::setLocationUpdatesResponse(int slotId,
4821 int responseType, int serial, RIL_Errno e,
4822 void *response, size_t responseLen) {
4824 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4827 if (radioService[slotId]->mRadioResponse != NULL) {
4828 RadioResponseInfo responseInfo = {};
4829 populateResponseInfo(responseInfo, serial, responseType, e);
4830 Return<void> retStatus
4831 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4832 radioService[slotId]->checkReturnStatus(retStatus);
4834 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4841 int radio::setCdmaSubscriptionSourceResponse(int slotId,
4842 int responseType, int serial, RIL_Errno e,
4843 void *response, size_t responseLen) {
4845 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4848 if (radioService[slotId]->mRadioResponse != NULL) {
4849 RadioResponseInfo responseInfo = {};
4850 populateResponseInfo(responseInfo, serial, responseType, e);
4851 Return<void> retStatus
4852 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4854 radioService[slotId]->checkReturnStatus(retStatus);
4856 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4863 int radio::setCdmaRoamingPreferenceResponse(int slotId,
4864 int responseType, int serial, RIL_Errno e,
4865 void *response, size_t responseLen) {
4867 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4870 if (radioService[slotId]->mRadioResponse != NULL) {
4871 RadioResponseInfo responseInfo = {};
4872 populateResponseInfo(responseInfo, serial, responseType, e);
4873 Return<void> retStatus
4874 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4876 radioService[slotId]->checkReturnStatus(retStatus);
4878 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4885 int radio::getCdmaRoamingPreferenceResponse(int slotId,
4886 int responseType, int serial, RIL_Errno e,
4887 void *response, size_t responseLen) {
4889 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4892 if (radioService[slotId]->mRadioResponse != NULL) {
4893 RadioResponseInfo responseInfo = {};
4894 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4895 Return<void> retStatus
4896 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4897 responseInfo, (CdmaRoamingType) ret);
4898 radioService[slotId]->checkReturnStatus(retStatus);
4900 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4907 int radio::setTTYModeResponse(int slotId,
4908 int responseType, int serial, RIL_Errno e,
4909 void *response, size_t responseLen) {
4911 RLOGD("setTTYModeResponse: serial %d", serial);
4914 if (radioService[slotId]->mRadioResponse != NULL) {
4915 RadioResponseInfo responseInfo = {};
4916 populateResponseInfo(responseInfo, serial, responseType, e);
4917 Return<void> retStatus
4918 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4919 radioService[slotId]->checkReturnStatus(retStatus);
4921 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4927 int radio::getTTYModeResponse(int slotId,
4928 int responseType, int serial, RIL_Errno e,
4929 void *response, size_t responseLen) {
4931 RLOGD("getTTYModeResponse: serial %d", serial);
4934 if (radioService[slotId]->mRadioResponse != NULL) {
4935 RadioResponseInfo responseInfo = {};
4936 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4937 Return<void> retStatus
4938 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4940 radioService[slotId]->checkReturnStatus(retStatus);
4942 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4948 int radio::setPreferredVoicePrivacyResponse(int slotId,
4949 int responseType, int serial, RIL_Errno e,
4950 void *response, size_t responseLen) {
4952 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
4955 if (radioService[slotId]->mRadioResponse != NULL) {
4956 RadioResponseInfo responseInfo = {};
4957 populateResponseInfo(responseInfo, serial, responseType, e);
4958 Return<void> retStatus
4959 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4961 radioService[slotId]->checkReturnStatus(retStatus);
4963 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4970 int radio::getPreferredVoicePrivacyResponse(int slotId,
4971 int responseType, int serial, RIL_Errno e,
4972 void *response, size_t responseLen) {
4974 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
4977 if (radioService[slotId]->mRadioResponse != NULL) {
4978 RadioResponseInfo responseInfo = {};
4979 populateResponseInfo(responseInfo, serial, responseType, e);
4980 bool enable = false;
4981 int numInts = responseLen / sizeof(int);
4982 if (response == NULL || numInts != 1) {
4983 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
4984 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4986 int *pInt = (int *) response;
4987 enable = pInt[0] == 1 ? true : false;
4989 Return<void> retStatus
4990 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
4991 responseInfo, enable);
4992 radioService[slotId]->checkReturnStatus(retStatus);
4994 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5001 int radio::sendCDMAFeatureCodeResponse(int slotId,
5002 int responseType, int serial, RIL_Errno e,
5003 void *response, size_t responseLen) {
5005 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5008 if (radioService[slotId]->mRadioResponse != NULL) {
5009 RadioResponseInfo responseInfo = {};
5010 populateResponseInfo(responseInfo, serial, responseType, e);
5011 Return<void> retStatus
5012 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5013 radioService[slotId]->checkReturnStatus(retStatus);
5015 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5022 int radio::sendBurstDtmfResponse(int slotId,
5023 int responseType, int serial, RIL_Errno e,
5024 void *response, size_t responseLen) {
5026 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5029 if (radioService[slotId]->mRadioResponse != NULL) {
5030 RadioResponseInfo responseInfo = {};
5031 populateResponseInfo(responseInfo, serial, responseType, e);
5032 Return<void> retStatus
5033 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5034 radioService[slotId]->checkReturnStatus(retStatus);
5036 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5042 int radio::sendCdmaSmsResponse(int slotId,
5043 int responseType, int serial, RIL_Errno e, void *response,
5044 size_t responseLen) {
5046 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5049 if (radioService[slotId]->mRadioResponse != NULL) {
5050 RadioResponseInfo responseInfo = {};
5051 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5054 Return<void> retStatus
5055 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5056 radioService[slotId]->checkReturnStatus(retStatus);
5058 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5064 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5065 int responseType, int serial, RIL_Errno e,
5066 void *response, size_t responseLen) {
5068 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5071 if (radioService[slotId]->mRadioResponse != NULL) {
5072 RadioResponseInfo responseInfo = {};
5073 populateResponseInfo(responseInfo, serial, responseType, e);
5074 Return<void> retStatus
5075 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5077 radioService[slotId]->checkReturnStatus(retStatus);
5079 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5086 int radio::getGsmBroadcastConfigResponse(int slotId,
5087 int responseType, int serial, RIL_Errno e,
5088 void *response, size_t responseLen) {
5090 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5093 if (radioService[slotId]->mRadioResponse != NULL) {
5094 RadioResponseInfo responseInfo = {};
5095 populateResponseInfo(responseInfo, serial, responseType, e);
5096 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5098 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5099 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5100 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5102 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5103 configs.resize(num);
5104 for (int i = 0 ; i < num; i++) {
5105 RIL_GSM_BroadcastSmsConfigInfo *resp =
5106 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5107 configs[i].fromServiceId = resp->fromServiceId;
5108 configs[i].toServiceId = resp->toServiceId;
5109 configs[i].fromCodeScheme = resp->fromCodeScheme;
5110 configs[i].toCodeScheme = resp->toCodeScheme;
5111 configs[i].selected = resp->selected == 1 ? true : false;
5115 Return<void> retStatus
5116 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5118 radioService[slotId]->checkReturnStatus(retStatus);
5120 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5127 int radio::setGsmBroadcastConfigResponse(int slotId,
5128 int responseType, int serial, RIL_Errno e,
5129 void *response, size_t responseLen) {
5131 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5134 if (radioService[slotId]->mRadioResponse != NULL) {
5135 RadioResponseInfo responseInfo = {};
5136 populateResponseInfo(responseInfo, serial, responseType, e);
5137 Return<void> retStatus
5138 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5139 radioService[slotId]->checkReturnStatus(retStatus);
5141 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5148 int radio::setGsmBroadcastActivationResponse(int slotId,
5149 int responseType, int serial, RIL_Errno e,
5150 void *response, size_t responseLen) {
5152 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5155 if (radioService[slotId]->mRadioResponse != NULL) {
5156 RadioResponseInfo responseInfo = {};
5157 populateResponseInfo(responseInfo, serial, responseType, e);
5158 Return<void> retStatus
5159 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5161 radioService[slotId]->checkReturnStatus(retStatus);
5163 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5170 int radio::getCdmaBroadcastConfigResponse(int slotId,
5171 int responseType, int serial, RIL_Errno e,
5172 void *response, size_t responseLen) {
5174 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5177 if (radioService[slotId]->mRadioResponse != NULL) {
5178 RadioResponseInfo responseInfo = {};
5179 populateResponseInfo(responseInfo, serial, responseType, e);
5180 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5182 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5183 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5184 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5186 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5187 configs.resize(num);
5188 for (int i = 0 ; i < num; i++) {
5189 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5190 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5191 configs[i].serviceCategory = resp->service_category;
5192 configs[i].language = resp->language;
5193 configs[i].selected = resp->selected == 1 ? true : false;
5197 Return<void> retStatus
5198 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5200 radioService[slotId]->checkReturnStatus(retStatus);
5202 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5209 int radio::setCdmaBroadcastConfigResponse(int slotId,
5210 int responseType, int serial, RIL_Errno e,
5211 void *response, size_t responseLen) {
5213 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5216 if (radioService[slotId]->mRadioResponse != NULL) {
5217 RadioResponseInfo responseInfo = {};
5218 populateResponseInfo(responseInfo, serial, responseType, e);
5219 Return<void> retStatus
5220 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5222 radioService[slotId]->checkReturnStatus(retStatus);
5224 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5231 int radio::setCdmaBroadcastActivationResponse(int slotId,
5232 int responseType, int serial, RIL_Errno e,
5233 void *response, size_t responseLen) {
5235 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5238 if (radioService[slotId]->mRadioResponse != NULL) {
5239 RadioResponseInfo responseInfo = {};
5240 populateResponseInfo(responseInfo, serial, responseType, e);
5241 Return<void> retStatus
5242 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5244 radioService[slotId]->checkReturnStatus(retStatus);
5246 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5253 int radio::getCDMASubscriptionResponse(int slotId,
5254 int responseType, int serial, RIL_Errno e, void *response,
5255 size_t responseLen) {
5257 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5260 if (radioService[slotId]->mRadioResponse != NULL) {
5261 RadioResponseInfo responseInfo = {};
5262 populateResponseInfo(responseInfo, serial, responseType, e);
5264 int numStrings = responseLen / sizeof(char *);
5265 hidl_string emptyString;
5266 if (response == NULL || numStrings != 5) {
5267 RLOGE("getOperatorResponse Invalid response: NULL");
5268 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5269 Return<void> retStatus
5270 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5271 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5272 radioService[slotId]->checkReturnStatus(retStatus);
5274 char **resp = (char **) response;
5275 Return<void> retStatus
5276 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5278 convertCharPtrToHidlString(resp[0]),
5279 convertCharPtrToHidlString(resp[1]),
5280 convertCharPtrToHidlString(resp[2]),
5281 convertCharPtrToHidlString(resp[3]),
5282 convertCharPtrToHidlString(resp[4]));
5283 radioService[slotId]->checkReturnStatus(retStatus);
5286 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5293 int radio::writeSmsToRuimResponse(int slotId,
5294 int responseType, int serial, RIL_Errno e,
5295 void *response, size_t responseLen) {
5297 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5300 if (radioService[slotId]->mRadioResponse != NULL) {
5301 RadioResponseInfo responseInfo = {};
5302 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5303 Return<void> retStatus
5304 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5305 radioService[slotId]->checkReturnStatus(retStatus);
5307 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5313 int radio::deleteSmsOnRuimResponse(int slotId,
5314 int responseType, int serial, RIL_Errno e,
5315 void *response, size_t responseLen) {
5317 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5320 if (radioService[slotId]->mRadioResponse != NULL) {
5321 RadioResponseInfo responseInfo = {};
5322 populateResponseInfo(responseInfo, serial, responseType, e);
5323 Return<void> retStatus
5324 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5325 radioService[slotId]->checkReturnStatus(retStatus);
5327 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5333 int radio::getDeviceIdentityResponse(int slotId,
5334 int responseType, int serial, RIL_Errno e, void *response,
5335 size_t responseLen) {
5337 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5340 if (radioService[slotId]->mRadioResponse != NULL) {
5341 RadioResponseInfo responseInfo = {};
5342 populateResponseInfo(responseInfo, serial, responseType, e);
5344 int numStrings = responseLen / sizeof(char *);
5345 hidl_string emptyString;
5346 if (response == NULL || numStrings != 4) {
5347 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5348 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5349 Return<void> retStatus
5350 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5351 emptyString, emptyString, emptyString, emptyString);
5352 radioService[slotId]->checkReturnStatus(retStatus);
5354 char **resp = (char **) response;
5355 Return<void> retStatus
5356 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5357 convertCharPtrToHidlString(resp[0]),
5358 convertCharPtrToHidlString(resp[1]),
5359 convertCharPtrToHidlString(resp[2]),
5360 convertCharPtrToHidlString(resp[3]));
5361 radioService[slotId]->checkReturnStatus(retStatus);
5364 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5371 int radio::exitEmergencyCallbackModeResponse(int slotId,
5372 int responseType, int serial, RIL_Errno e,
5373 void *response, size_t responseLen) {
5375 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5378 if (radioService[slotId]->mRadioResponse != NULL) {
5379 RadioResponseInfo responseInfo = {};
5380 populateResponseInfo(responseInfo, serial, responseType, e);
5381 Return<void> retStatus
5382 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5384 radioService[slotId]->checkReturnStatus(retStatus);
5386 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5393 int radio::getSmscAddressResponse(int slotId,
5394 int responseType, int serial, RIL_Errno e,
5395 void *response, size_t responseLen) {
5397 RLOGD("getSmscAddressResponse: serial %d", serial);
5400 if (radioService[slotId]->mRadioResponse != NULL) {
5401 RadioResponseInfo responseInfo = {};
5402 populateResponseInfo(responseInfo, serial, responseType, e);
5403 Return<void> retStatus
5404 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5405 convertCharPtrToHidlString((char *) response));
5406 radioService[slotId]->checkReturnStatus(retStatus);
5408 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5414 int radio::setSmscAddressResponse(int slotId,
5415 int responseType, int serial, RIL_Errno e,
5416 void *response, size_t responseLen) {
5418 RLOGD("setSmscAddressResponse: serial %d", serial);
5421 if (radioService[slotId]->mRadioResponse != NULL) {
5422 RadioResponseInfo responseInfo = {};
5423 populateResponseInfo(responseInfo, serial, responseType, e);
5424 Return<void> retStatus
5425 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5426 radioService[slotId]->checkReturnStatus(retStatus);
5428 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5434 int radio::reportSmsMemoryStatusResponse(int slotId,
5435 int responseType, int serial, RIL_Errno e,
5436 void *response, size_t responseLen) {
5438 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5441 if (radioService[slotId]->mRadioResponse != NULL) {
5442 RadioResponseInfo responseInfo = {};
5443 populateResponseInfo(responseInfo, serial, responseType, e);
5444 Return<void> retStatus
5445 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5446 radioService[slotId]->checkReturnStatus(retStatus);
5448 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5455 int radio::reportStkServiceIsRunningResponse(int slotId,
5456 int responseType, int serial, RIL_Errno e,
5457 void *response, size_t responseLen) {
5459 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5462 if (radioService[slotId]->mRadioResponse != NULL) {
5463 RadioResponseInfo responseInfo = {};
5464 populateResponseInfo(responseInfo, serial, responseType, e);
5465 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5466 reportStkServiceIsRunningResponse(responseInfo);
5467 radioService[slotId]->checkReturnStatus(retStatus);
5469 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5476 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5477 int responseType, int serial, RIL_Errno e,
5478 void *response, size_t responseLen) {
5480 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5483 if (radioService[slotId]->mRadioResponse != NULL) {
5484 RadioResponseInfo responseInfo = {};
5485 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5486 Return<void> retStatus
5487 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5488 responseInfo, (CdmaSubscriptionSource) ret);
5489 radioService[slotId]->checkReturnStatus(retStatus);
5491 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5498 int radio::requestIsimAuthenticationResponse(int slotId,
5499 int responseType, int serial, RIL_Errno e,
5500 void *response, size_t responseLen) {
5502 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5505 if (radioService[slotId]->mRadioResponse != NULL) {
5506 RadioResponseInfo responseInfo = {};
5507 populateResponseInfo(responseInfo, serial, responseType, e);
5508 Return<void> retStatus
5509 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5511 convertCharPtrToHidlString((char *) response));
5512 radioService[slotId]->checkReturnStatus(retStatus);
5514 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5521 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5523 int serial, RIL_Errno e, void *response,
5524 size_t responseLen) {
5526 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5529 if (radioService[slotId]->mRadioResponse != NULL) {
5530 RadioResponseInfo responseInfo = {};
5531 populateResponseInfo(responseInfo, serial, responseType, e);
5532 Return<void> retStatus
5533 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5535 radioService[slotId]->checkReturnStatus(retStatus);
5537 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5544 int radio::sendEnvelopeWithStatusResponse(int slotId,
5545 int responseType, int serial, RIL_Errno e, void *response,
5546 size_t responseLen) {
5548 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5551 if (radioService[slotId]->mRadioResponse != NULL) {
5552 RadioResponseInfo responseInfo = {};
5553 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5554 response, responseLen);
5556 Return<void> retStatus
5557 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5559 radioService[slotId]->checkReturnStatus(retStatus);
5561 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5568 int radio::getVoiceRadioTechnologyResponse(int slotId,
5569 int responseType, int serial, RIL_Errno e,
5570 void *response, size_t responseLen) {
5572 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5575 if (radioService[slotId]->mRadioResponse != NULL) {
5576 RadioResponseInfo responseInfo = {};
5577 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5578 Return<void> retStatus
5579 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5580 responseInfo, (RadioTechnology) ret);
5581 radioService[slotId]->checkReturnStatus(retStatus);
5583 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5590 int radio::getCellInfoListResponse(int slotId,
5592 int serial, RIL_Errno e, void *response,
5593 size_t responseLen) {
5595 RLOGD("getCellInfoListResponse: serial %d", serial);
5598 if (radioService[slotId]->mRadioResponse != NULL) {
5599 RadioResponseInfo responseInfo = {};
5600 populateResponseInfo(responseInfo, serial, responseType, e);
5602 hidl_vec<CellInfo> ret;
5603 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5604 RLOGE("getCellInfoListResponse: Invalid response");
5605 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5607 convertRilCellInfoListToHal(response, responseLen, ret);
5610 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5612 radioService[slotId]->checkReturnStatus(retStatus);
5614 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5620 int radio::setCellInfoListRateResponse(int slotId,
5622 int serial, RIL_Errno e, void *response,
5623 size_t responseLen) {
5625 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5628 if (radioService[slotId]->mRadioResponse != NULL) {
5629 RadioResponseInfo responseInfo = {};
5630 populateResponseInfo(responseInfo, serial, responseType, e);
5631 Return<void> retStatus
5632 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5633 radioService[slotId]->checkReturnStatus(retStatus);
5635 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5642 int radio::setInitialAttachApnResponse(int slotId,
5643 int responseType, int serial, RIL_Errno e,
5644 void *response, size_t responseLen) {
5646 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5649 if (radioService[slotId]->mRadioResponse != NULL) {
5650 RadioResponseInfo responseInfo = {};
5651 populateResponseInfo(responseInfo, serial, responseType, e);
5652 Return<void> retStatus
5653 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5654 radioService[slotId]->checkReturnStatus(retStatus);
5656 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5663 int radio::getImsRegistrationStateResponse(int slotId,
5664 int responseType, int serial, RIL_Errno e,
5665 void *response, size_t responseLen) {
5667 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5670 if (radioService[slotId]->mRadioResponse != NULL) {
5671 RadioResponseInfo responseInfo = {};
5672 populateResponseInfo(responseInfo, serial, responseType, e);
5673 bool isRegistered = false;
5675 int numInts = responseLen / sizeof(int);
5676 if (response == NULL || numInts != 2) {
5677 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5678 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5680 int *pInt = (int *) response;
5681 isRegistered = pInt[0] == 1 ? true : false;
5682 ratFamily = pInt[1];
5684 Return<void> retStatus
5685 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5686 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5687 radioService[slotId]->checkReturnStatus(retStatus);
5689 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5696 int radio::sendImsSmsResponse(int slotId,
5697 int responseType, int serial, RIL_Errno e, void *response,
5698 size_t responseLen) {
5700 RLOGD("sendImsSmsResponse: serial %d", serial);
5703 if (radioService[slotId]->mRadioResponse != NULL) {
5704 RadioResponseInfo responseInfo = {};
5705 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5708 Return<void> retStatus
5709 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5710 radioService[slotId]->checkReturnStatus(retStatus);
5712 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5718 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5719 int responseType, int serial, RIL_Errno e,
5720 void *response, size_t responseLen) {
5722 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5725 if (radioService[slotId]->mRadioResponse != NULL) {
5726 RadioResponseInfo responseInfo = {};
5727 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5730 Return<void> retStatus
5731 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5732 responseInfo, result);
5733 radioService[slotId]->checkReturnStatus(retStatus);
5735 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5742 int radio::iccOpenLogicalChannelResponse(int slotId,
5743 int responseType, int serial, RIL_Errno e, void *response,
5744 size_t responseLen) {
5746 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5749 if (radioService[slotId]->mRadioResponse != NULL) {
5750 RadioResponseInfo responseInfo = {};
5751 populateResponseInfo(responseInfo, serial, responseType, e);
5753 hidl_vec<int8_t> selectResponse;
5754 int numInts = responseLen / sizeof(int);
5755 if (response == NULL || responseLen % sizeof(int) != 0) {
5756 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5757 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5759 int *pInt = (int *) response;
5760 channelId = pInt[0];
5761 selectResponse.resize(numInts - 1);
5762 for (int i = 1; i < numInts; i++) {
5763 selectResponse[i - 1] = (int8_t) pInt[i];
5766 Return<void> retStatus
5767 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5768 channelId, selectResponse);
5769 radioService[slotId]->checkReturnStatus(retStatus);
5771 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5778 int radio::iccCloseLogicalChannelResponse(int slotId,
5779 int responseType, int serial, RIL_Errno e,
5780 void *response, size_t responseLen) {
5782 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5785 if (radioService[slotId]->mRadioResponse != NULL) {
5786 RadioResponseInfo responseInfo = {};
5787 populateResponseInfo(responseInfo, serial, responseType, e);
5788 Return<void> retStatus
5789 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5791 radioService[slotId]->checkReturnStatus(retStatus);
5793 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5800 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5801 int responseType, int serial, RIL_Errno e,
5802 void *response, size_t responseLen) {
5804 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5807 if (radioService[slotId]->mRadioResponse != NULL) {
5808 RadioResponseInfo responseInfo = {};
5809 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5812 Return<void> retStatus
5813 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5814 responseInfo, result);
5815 radioService[slotId]->checkReturnStatus(retStatus);
5817 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5824 int radio::nvReadItemResponse(int slotId,
5825 int responseType, int serial, RIL_Errno e,
5826 void *response, size_t responseLen) {
5828 RLOGD("nvReadItemResponse: serial %d", serial);
5831 if (radioService[slotId]->mRadioResponse != NULL) {
5832 RadioResponseInfo responseInfo = {};
5833 populateResponseInfo(responseInfo, serial, responseType, e);
5834 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5836 convertCharPtrToHidlString((char *) response));
5837 radioService[slotId]->checkReturnStatus(retStatus);
5839 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5845 int radio::nvWriteItemResponse(int slotId,
5846 int responseType, int serial, RIL_Errno e,
5847 void *response, size_t responseLen) {
5849 RLOGD("nvWriteItemResponse: serial %d", serial);
5852 if (radioService[slotId]->mRadioResponse != NULL) {
5853 RadioResponseInfo responseInfo = {};
5854 populateResponseInfo(responseInfo, serial, responseType, e);
5855 Return<void> retStatus
5856 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5857 radioService[slotId]->checkReturnStatus(retStatus);
5859 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5865 int radio::nvWriteCdmaPrlResponse(int slotId,
5866 int responseType, int serial, RIL_Errno e,
5867 void *response, size_t responseLen) {
5869 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5872 if (radioService[slotId]->mRadioResponse != NULL) {
5873 RadioResponseInfo responseInfo = {};
5874 populateResponseInfo(responseInfo, serial, responseType, e);
5875 Return<void> retStatus
5876 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5877 radioService[slotId]->checkReturnStatus(retStatus);
5879 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5885 int radio::nvResetConfigResponse(int slotId,
5886 int responseType, int serial, RIL_Errno e,
5887 void *response, size_t responseLen) {
5889 RLOGD("nvResetConfigResponse: serial %d", serial);
5892 if (radioService[slotId]->mRadioResponse != NULL) {
5893 RadioResponseInfo responseInfo = {};
5894 populateResponseInfo(responseInfo, serial, responseType, e);
5895 Return<void> retStatus
5896 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5897 radioService[slotId]->checkReturnStatus(retStatus);
5899 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5905 int radio::setUiccSubscriptionResponse(int slotId,
5906 int responseType, int serial, RIL_Errno e,
5907 void *response, size_t responseLen) {
5909 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5912 if (radioService[slotId]->mRadioResponse != NULL) {
5913 RadioResponseInfo responseInfo = {};
5914 populateResponseInfo(responseInfo, serial, responseType, e);
5915 Return<void> retStatus
5916 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5917 radioService[slotId]->checkReturnStatus(retStatus);
5919 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5926 int radio::setDataAllowedResponse(int slotId,
5927 int responseType, int serial, RIL_Errno e,
5928 void *response, size_t responseLen) {
5930 RLOGD("setDataAllowedResponse: serial %d", serial);
5933 if (radioService[slotId]->mRadioResponse != NULL) {
5934 RadioResponseInfo responseInfo = {};
5935 populateResponseInfo(responseInfo, serial, responseType, e);
5936 Return<void> retStatus
5937 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5938 radioService[slotId]->checkReturnStatus(retStatus);
5940 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5946 int radio::getHardwareConfigResponse(int slotId,
5947 int responseType, int serial, RIL_Errno e,
5948 void *response, size_t responseLen) {
5950 RLOGD("getHardwareConfigResponse: serial %d", serial);
5953 if (radioService[slotId]->mRadioResponse != NULL) {
5954 RadioResponseInfo responseInfo = {};
5955 populateResponseInfo(responseInfo, serial, responseType, e);
5957 hidl_vec<HardwareConfig> result;
5958 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
5959 RLOGE("hardwareConfigChangedInd: invalid response");
5960 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5962 convertRilHardwareConfigListToHal(response, responseLen, result);
5965 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
5966 responseInfo, result);
5967 radioService[slotId]->checkReturnStatus(retStatus);
5969 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5975 int radio::requestIccSimAuthenticationResponse(int slotId,
5976 int responseType, int serial, RIL_Errno e,
5977 void *response, size_t responseLen) {
5979 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
5982 if (radioService[slotId]->mRadioResponse != NULL) {
5983 RadioResponseInfo responseInfo = {};
5984 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5987 Return<void> retStatus
5988 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
5989 responseInfo, result);
5990 radioService[slotId]->checkReturnStatus(retStatus);
5992 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
5999 int radio::setDataProfileResponse(int slotId,
6000 int responseType, int serial, RIL_Errno e,
6001 void *response, size_t responseLen) {
6003 RLOGD("setDataProfileResponse: serial %d", serial);
6006 if (radioService[slotId]->mRadioResponse != NULL) {
6007 RadioResponseInfo responseInfo = {};
6008 populateResponseInfo(responseInfo, serial, responseType, e);
6009 Return<void> retStatus
6010 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6011 radioService[slotId]->checkReturnStatus(retStatus);
6013 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6019 int radio::requestShutdownResponse(int slotId,
6020 int responseType, int serial, RIL_Errno e,
6021 void *response, size_t responseLen) {
6023 RLOGD("requestShutdownResponse: serial %d", serial);
6026 if (radioService[slotId]->mRadioResponse != NULL) {
6027 RadioResponseInfo responseInfo = {};
6028 populateResponseInfo(responseInfo, serial, responseType, e);
6029 Return<void> retStatus
6030 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6031 radioService[slotId]->checkReturnStatus(retStatus);
6033 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6039 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6040 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6041 populateResponseInfo(responseInfo, serial, responseType, e);
6043 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6044 RLOGE("responseRadioCapability: Invalid response");
6045 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6046 rc.logicalModemUuid = hidl_string();
6048 convertRilRadioCapabilityToHal(response, responseLen, rc);
6052 int radio::getRadioCapabilityResponse(int slotId,
6053 int responseType, int serial, RIL_Errno e,
6054 void *response, size_t responseLen) {
6056 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6059 if (radioService[slotId]->mRadioResponse != NULL) {
6060 RadioResponseInfo responseInfo = {};
6061 RadioCapability result = {};
6062 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6064 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6065 responseInfo, result);
6066 radioService[slotId]->checkReturnStatus(retStatus);
6068 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6074 int radio::setRadioCapabilityResponse(int slotId,
6075 int responseType, int serial, RIL_Errno e,
6076 void *response, size_t responseLen) {
6078 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6081 if (radioService[slotId]->mRadioResponse != NULL) {
6082 RadioResponseInfo responseInfo = {};
6083 RadioCapability result = {};
6084 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6086 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6087 responseInfo, result);
6088 radioService[slotId]->checkReturnStatus(retStatus);
6090 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6096 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6097 RIL_Errno e, void *response, size_t responseLen) {
6098 populateResponseInfo(responseInfo, serial, responseType, e);
6099 LceStatusInfo result = {};
6101 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6102 RLOGE("Invalid response: NULL");
6103 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6105 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6106 result.lceStatus = (LceStatus) resp->lce_status;
6107 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6112 int radio::startLceServiceResponse(int slotId,
6113 int responseType, int serial, RIL_Errno e,
6114 void *response, size_t responseLen) {
6116 RLOGD("startLceServiceResponse: serial %d", serial);
6119 if (radioService[slotId]->mRadioResponse != NULL) {
6120 RadioResponseInfo responseInfo = {};
6121 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6122 response, responseLen);
6124 Return<void> retStatus
6125 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6127 radioService[slotId]->checkReturnStatus(retStatus);
6129 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6135 int radio::stopLceServiceResponse(int slotId,
6136 int responseType, int serial, RIL_Errno e,
6137 void *response, size_t responseLen) {
6139 RLOGD("stopLceServiceResponse: serial %d", serial);
6142 if (radioService[slotId]->mRadioResponse != NULL) {
6143 RadioResponseInfo responseInfo = {};
6144 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6145 response, responseLen);
6147 Return<void> retStatus
6148 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6150 radioService[slotId]->checkReturnStatus(retStatus);
6152 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6158 int radio::pullLceDataResponse(int slotId,
6159 int responseType, int serial, RIL_Errno e,
6160 void *response, size_t responseLen) {
6162 RLOGD("pullLceDataResponse: serial %d", serial);
6165 if (radioService[slotId]->mRadioResponse != NULL) {
6166 RadioResponseInfo responseInfo = {};
6167 populateResponseInfo(responseInfo, serial, responseType, e);
6169 LceDataInfo result = {};
6170 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6171 RLOGE("pullLceDataResponse: Invalid response");
6172 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6174 convertRilLceDataInfoToHal(response, responseLen, result);
6177 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6178 responseInfo, result);
6179 radioService[slotId]->checkReturnStatus(retStatus);
6181 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6187 int radio::getModemActivityInfoResponse(int slotId,
6188 int responseType, int serial, RIL_Errno e,
6189 void *response, size_t responseLen) {
6191 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6194 if (radioService[slotId]->mRadioResponse != NULL) {
6195 RadioResponseInfo responseInfo = {};
6196 populateResponseInfo(responseInfo, serial, responseType, e);
6197 ActivityStatsInfo info;
6198 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6199 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6200 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6202 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6203 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6204 info.idleModeTimeMs = resp->idle_mode_time_ms;
6205 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6206 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6208 info.rxModeTimeMs = resp->rx_mode_time_ms;
6211 Return<void> retStatus
6212 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6214 radioService[slotId]->checkReturnStatus(retStatus);
6216 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6223 int radio::setAllowedCarriersResponse(int slotId,
6224 int responseType, int serial, RIL_Errno e,
6225 void *response, size_t responseLen) {
6227 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6230 if (radioService[slotId]->mRadioResponse != NULL) {
6231 RadioResponseInfo responseInfo = {};
6232 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6233 Return<void> retStatus
6234 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6236 radioService[slotId]->checkReturnStatus(retStatus);
6238 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6245 int radio::getAllowedCarriersResponse(int slotId,
6246 int responseType, int serial, RIL_Errno e,
6247 void *response, size_t responseLen) {
6249 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6252 if (radioService[slotId]->mRadioResponse != NULL) {
6253 RadioResponseInfo responseInfo = {};
6254 populateResponseInfo(responseInfo, serial, responseType, e);
6255 CarrierRestrictions carrierInfo = {};
6256 bool allAllowed = true;
6257 if (response == NULL) {
6259 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6261 carrierInfo.allowedCarriers.resize(0);
6262 carrierInfo.excludedCarriers.resize(0);
6263 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6264 RLOGE("getAllowedCarriersResponse Invalid response");
6265 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6267 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6268 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6272 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6273 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6274 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6275 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6276 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6277 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6278 carrierInfo.allowedCarriers[i].matchData =
6279 convertCharPtrToHidlString(carrier->match_data);
6282 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6283 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6284 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6285 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6286 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6287 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6288 carrierInfo.excludedCarriers[i].matchData =
6289 convertCharPtrToHidlString(carrier->match_data);
6293 Return<void> retStatus
6294 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6295 allAllowed, carrierInfo);
6296 radioService[slotId]->checkReturnStatus(retStatus);
6298 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6305 int radio::sendDeviceStateResponse(int slotId,
6306 int responseType, int serial, RIL_Errno e,
6307 void *response, size_t responselen) {
6309 RLOGD("sendDeviceStateResponse: serial %d", serial);
6312 if (radioService[slotId]->mRadioResponse != NULL) {
6313 RadioResponseInfo responseInfo = {};
6314 populateResponseInfo(responseInfo, serial, responseType, e);
6315 Return<void> retStatus
6316 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6317 radioService[slotId]->checkReturnStatus(retStatus);
6319 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6325 int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
6326 int responseType, int serial, RIL_Errno e,
6327 void *response, size_t responseLen) {
6328 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
6329 if (radioService[slotId]->mRadioResponse != NULL) {
6330 RadioResponseInfo responseInfo = {};
6331 populateResponseInfo(responseInfo, serial, responseType, e);
6332 Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
6333 ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
6334 radioService[slotId]->mRadioResponse);
6336 sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
6337 Return<void> retStatus
6338 = radioResponseV1_1->setCarrierInfoForImsiEncryptionResponse(responseInfo);
6339 radioService[slotId]->checkReturnStatus(retStatus);
6341 RLOGE("setCarrierInfoForImsiEncryptionResponse: ret.isOk() == false for "
6342 "radioService[%d]" , slotId);
6345 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponse == NULL",
6351 int radio::setIndicationFilterResponse(int slotId,
6352 int responseType, int serial, RIL_Errno e,
6353 void *response, size_t responselen) {
6355 RLOGD("setIndicationFilterResponse: serial %d", serial);
6358 if (radioService[slotId]->mRadioResponse != NULL) {
6359 RadioResponseInfo responseInfo = {};
6360 populateResponseInfo(responseInfo, serial, responseType, e);
6361 Return<void> retStatus
6362 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6363 radioService[slotId]->checkReturnStatus(retStatus);
6365 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6372 int radio::setSimCardPowerResponse(int slotId,
6373 int responseType, int serial, RIL_Errno e,
6374 void *response, size_t responseLen) {
6376 RLOGD("setSimCardPowerResponse: serial %d", serial);
6379 if (radioService[slotId]->mRadioResponse != NULL) {
6380 RadioResponseInfo responseInfo = {};
6381 populateResponseInfo(responseInfo, serial, responseType, e);
6382 Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
6383 ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
6384 radioService[slotId]->mRadioResponse);
6386 sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
6387 Return<void> retStatus
6388 = radioResponseV1_1->setSimCardPowerResponse_1_1(responseInfo);
6389 radioService[slotId]->checkReturnStatus(retStatus);
6391 RLOGD("setSimCardPowerResponse: ret.isOK() == false for radioService[%d]",
6393 Return<void> retStatus
6394 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6395 radioService[slotId]->checkReturnStatus(retStatus);
6398 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL",
6404 int radio::sendRequestRawResponse(int slotId,
6405 int responseType, int serial, RIL_Errno e,
6406 void *response, size_t responseLen) {
6408 RLOGD("sendRequestRawResponse: serial %d", serial);
6411 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6412 RadioResponseInfo responseInfo = {};
6413 populateResponseInfo(responseInfo, serial, responseType, e);
6414 hidl_vec<uint8_t> data;
6416 if (response == NULL) {
6417 RLOGE("sendRequestRawResponse: Invalid response");
6418 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6420 data.setToExternal((uint8_t *) response, responseLen);
6422 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6423 sendRequestRawResponse(responseInfo, data);
6424 checkReturnStatus(slotId, retStatus, false);
6426 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6433 int radio::sendRequestStringsResponse(int slotId,
6434 int responseType, int serial, RIL_Errno e,
6435 void *response, size_t responseLen) {
6437 RLOGD("sendRequestStringsResponse: serial %d", serial);
6440 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6441 RadioResponseInfo responseInfo = {};
6442 populateResponseInfo(responseInfo, serial, responseType, e);
6443 hidl_vec<hidl_string> data;
6445 if (response == NULL || responseLen % sizeof(char *) != 0) {
6446 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6447 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6449 char **resp = (char **) response;
6450 int numStrings = responseLen / sizeof(char *);
6451 data.resize(numStrings);
6452 for (int i = 0; i < numStrings; i++) {
6453 data[i] = convertCharPtrToHidlString(resp[i]);
6456 Return<void> retStatus
6457 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6458 responseInfo, data);
6459 checkReturnStatus(slotId, retStatus, false);
6461 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6468 // Radio Indication functions
6470 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6471 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6472 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6475 int radio::radioStateChangedInd(int slotId,
6476 int indicationType, int token, RIL_Errno e, void *response,
6477 size_t responseLen) {
6478 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6479 RadioState radioState = (RadioState) s_vendorFunctions->onStateRequest();
6480 RLOGD("radioStateChangedInd: radioState %d", radioState);
6481 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6482 convertIntToRadioIndicationType(indicationType), radioState);
6483 radioService[slotId]->checkReturnStatus(retStatus);
6485 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6491 int radio::callStateChangedInd(int slotId,
6492 int indicationType, int token, RIL_Errno e, void *response,
6493 size_t responseLen) {
6494 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6496 RLOGD("callStateChangedInd");
6498 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6499 convertIntToRadioIndicationType(indicationType));
6500 radioService[slotId]->checkReturnStatus(retStatus);
6502 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6508 int radio::networkStateChangedInd(int slotId,
6509 int indicationType, int token, RIL_Errno e, void *response,
6510 size_t responseLen) {
6511 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6513 RLOGD("networkStateChangedInd");
6515 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6516 convertIntToRadioIndicationType(indicationType));
6517 radioService[slotId]->checkReturnStatus(retStatus);
6519 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6526 uint8_t hexCharToInt(uint8_t c) {
6527 if (c >= '0' && c <= '9') return (c - '0');
6528 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6529 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6531 return INVALID_HEX_CHAR;
6534 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6535 if (responseLen % 2 != 0) {
6539 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6540 if (bytes == NULL) {
6541 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6544 uint8_t *hexString = (uint8_t *)response;
6546 for (size_t i = 0; i < responseLen; i += 2) {
6547 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6548 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6550 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6551 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6552 hexString[i], hexString[i + 1]);
6556 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6562 int radio::newSmsInd(int slotId, int indicationType,
6563 int token, RIL_Errno e, void *response, size_t responseLen) {
6564 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6565 if (response == NULL || responseLen == 0) {
6566 RLOGE("newSmsInd: invalid response");
6570 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6571 if (bytes == NULL) {
6572 RLOGE("newSmsInd: convertHexStringToBytes failed");
6576 hidl_vec<uint8_t> pdu;
6577 pdu.setToExternal(bytes, responseLen/2);
6581 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6582 convertIntToRadioIndicationType(indicationType), pdu);
6583 radioService[slotId]->checkReturnStatus(retStatus);
6586 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6592 int radio::newSmsStatusReportInd(int slotId,
6593 int indicationType, int token, RIL_Errno e, void *response,
6594 size_t responseLen) {
6595 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6596 if (response == NULL || responseLen == 0) {
6597 RLOGE("newSmsStatusReportInd: invalid response");
6601 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6602 if (bytes == NULL) {
6603 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6607 hidl_vec<uint8_t> pdu;
6608 pdu.setToExternal(bytes, responseLen/2);
6610 RLOGD("newSmsStatusReportInd");
6612 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6613 convertIntToRadioIndicationType(indicationType), pdu);
6614 radioService[slotId]->checkReturnStatus(retStatus);
6617 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6623 int radio::newSmsOnSimInd(int slotId, int indicationType,
6624 int token, RIL_Errno e, void *response, size_t responseLen) {
6625 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6626 if (response == NULL || responseLen != sizeof(int)) {
6627 RLOGE("newSmsOnSimInd: invalid response");
6630 int32_t recordNumber = ((int32_t *) response)[0];
6632 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6634 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6635 convertIntToRadioIndicationType(indicationType), recordNumber);
6636 radioService[slotId]->checkReturnStatus(retStatus);
6638 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6644 int radio::onUssdInd(int slotId, int indicationType,
6645 int token, RIL_Errno e, void *response, size_t responseLen) {
6646 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6647 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6648 RLOGE("onUssdInd: invalid response");
6651 char **strings = (char **) response;
6652 char *mode = strings[0];
6653 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6654 UssdModeType modeType = (UssdModeType) atoi(mode);
6656 RLOGD("onUssdInd: mode %s", mode);
6658 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6659 convertIntToRadioIndicationType(indicationType), modeType, msg);
6660 radioService[slotId]->checkReturnStatus(retStatus);
6662 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6668 int radio::nitzTimeReceivedInd(int slotId,
6669 int indicationType, int token, RIL_Errno e, void *response,
6670 size_t responseLen) {
6671 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6672 if (response == NULL || responseLen == 0) {
6673 RLOGE("nitzTimeReceivedInd: invalid response");
6676 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6677 int64_t timeReceived = android::elapsedRealtime();
6679 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6682 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6683 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6684 radioService[slotId]->checkReturnStatus(retStatus);
6686 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6693 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6694 SignalStrength& signalStrength) {
6695 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6697 // Fixup LTE for backwards compatibility
6698 // signalStrength: -1 -> 99
6699 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6700 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6702 // rsrp: -1 -> INT_MAX all other negative value to positive.
6704 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6705 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6706 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6707 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6709 // rsrq: -1 -> INT_MAX
6710 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6711 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6713 // Not remapping rssnr is already using INT_MAX
6714 // cqi: -1 -> INT_MAX
6715 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6716 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6719 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6720 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6721 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6722 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6723 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6724 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6725 signalStrength.evdo.signalNoiseRatio =
6726 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6727 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6728 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6729 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6730 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6731 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6732 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6733 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6736 int radio::currentSignalStrengthInd(int slotId,
6737 int indicationType, int token, RIL_Errno e,
6738 void *response, size_t responseLen) {
6739 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6740 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
6741 RLOGE("currentSignalStrengthInd: invalid response");
6745 SignalStrength signalStrength = {};
6746 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6749 RLOGD("currentSignalStrengthInd");
6751 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6752 convertIntToRadioIndicationType(indicationType), signalStrength);
6753 radioService[slotId]->checkReturnStatus(retStatus);
6755 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6762 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6763 SetupDataCallResult& dcResult) {
6764 dcResult.status = (DataCallFailCause) dcResponse->status;
6765 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6766 dcResult.cid = dcResponse->cid;
6767 dcResult.active = dcResponse->active;
6768 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6769 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6770 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6771 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6772 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6773 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6774 dcResult.mtu = dcResponse->mtu;
6777 void convertRilDataCallListToHal(void *response, size_t responseLen,
6778 hidl_vec<SetupDataCallResult>& dcResultList) {
6779 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6781 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6782 dcResultList.resize(num);
6783 for (int i = 0; i < num; i++) {
6784 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6788 int radio::dataCallListChangedInd(int slotId,
6789 int indicationType, int token, RIL_Errno e, void *response,
6790 size_t responseLen) {
6791 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6792 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
6793 RLOGE("dataCallListChangedInd: invalid response");
6796 hidl_vec<SetupDataCallResult> dcList;
6797 convertRilDataCallListToHal(response, responseLen, dcList);
6799 RLOGD("dataCallListChangedInd");
6801 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
6802 convertIntToRadioIndicationType(indicationType), dcList);
6803 radioService[slotId]->checkReturnStatus(retStatus);
6805 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6811 int radio::suppSvcNotifyInd(int slotId, int indicationType,
6812 int token, RIL_Errno e, void *response, size_t responseLen) {
6813 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6814 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
6815 RLOGE("suppSvcNotifyInd: invalid response");
6819 SuppSvcNotification suppSvc = {};
6820 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6821 suppSvc.isMT = ssn->notificationType;
6822 suppSvc.code = ssn->code;
6823 suppSvc.index = ssn->index;
6824 suppSvc.type = ssn->type;
6825 suppSvc.number = convertCharPtrToHidlString(ssn->number);
6828 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
6829 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
6831 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
6832 convertIntToRadioIndicationType(indicationType), suppSvc);
6833 radioService[slotId]->checkReturnStatus(retStatus);
6835 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6841 int radio::stkSessionEndInd(int slotId, int indicationType,
6842 int token, RIL_Errno e, void *response, size_t responseLen) {
6843 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6845 RLOGD("stkSessionEndInd");
6847 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
6848 convertIntToRadioIndicationType(indicationType));
6849 radioService[slotId]->checkReturnStatus(retStatus);
6851 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
6857 int radio::stkProactiveCommandInd(int slotId,
6858 int indicationType, int token, RIL_Errno e, void *response,
6859 size_t responseLen) {
6860 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6861 if (response == NULL || responseLen == 0) {
6862 RLOGE("stkProactiveCommandInd: invalid response");
6866 RLOGD("stkProactiveCommandInd");
6868 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
6869 convertIntToRadioIndicationType(indicationType),
6870 convertCharPtrToHidlString((char *) response));
6871 radioService[slotId]->checkReturnStatus(retStatus);
6873 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
6879 int radio::stkEventNotifyInd(int slotId, int indicationType,
6880 int token, RIL_Errno e, void *response, size_t responseLen) {
6881 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6882 if (response == NULL || responseLen == 0) {
6883 RLOGE("stkEventNotifyInd: invalid response");
6887 RLOGD("stkEventNotifyInd");
6889 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
6890 convertIntToRadioIndicationType(indicationType),
6891 convertCharPtrToHidlString((char *) response));
6892 radioService[slotId]->checkReturnStatus(retStatus);
6894 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6900 int radio::stkCallSetupInd(int slotId, int indicationType,
6901 int token, RIL_Errno e, void *response, size_t responseLen) {
6902 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6903 if (response == NULL || responseLen != sizeof(int)) {
6904 RLOGE("stkCallSetupInd: invalid response");
6907 int32_t timeout = ((int32_t *) response)[0];
6909 RLOGD("stkCallSetupInd: timeout %d", timeout);
6911 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
6912 convertIntToRadioIndicationType(indicationType), timeout);
6913 radioService[slotId]->checkReturnStatus(retStatus);
6915 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
6921 int radio::simSmsStorageFullInd(int slotId,
6922 int indicationType, int token, RIL_Errno e, void *response,
6923 size_t responseLen) {
6924 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6926 RLOGD("simSmsStorageFullInd");
6928 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
6929 convertIntToRadioIndicationType(indicationType));
6930 radioService[slotId]->checkReturnStatus(retStatus);
6932 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
6938 int radio::simRefreshInd(int slotId, int indicationType,
6939 int token, RIL_Errno e, void *response, size_t responseLen) {
6940 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6941 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
6942 RLOGE("simRefreshInd: invalid response");
6946 SimRefreshResult refreshResult = {};
6947 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
6948 refreshResult.type =
6949 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
6950 refreshResult.efId = simRefreshResponse->ef_id;
6951 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
6954 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
6956 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
6957 convertIntToRadioIndicationType(indicationType), refreshResult);
6958 radioService[slotId]->checkReturnStatus(retStatus);
6960 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
6966 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
6967 CdmaSignalInfoRecord& record) {
6968 record.isPresent = signalInfoRecord->isPresent;
6969 record.signalType = signalInfoRecord->signalType;
6970 record.alertPitch = signalInfoRecord->alertPitch;
6971 record.signal = signalInfoRecord->signal;
6974 int radio::callRingInd(int slotId, int indicationType,
6975 int token, RIL_Errno e, void *response, size_t responseLen) {
6976 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6978 CdmaSignalInfoRecord record = {};
6979 if (response == NULL || responseLen == 0) {
6983 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
6984 RLOGE("callRingInd: invalid response");
6987 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
6991 RLOGD("callRingInd: isGsm %d", isGsm);
6993 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
6994 convertIntToRadioIndicationType(indicationType), isGsm, record);
6995 radioService[slotId]->checkReturnStatus(retStatus);
6997 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7003 int radio::simStatusChangedInd(int slotId,
7004 int indicationType, int token, RIL_Errno e, void *response,
7005 size_t responseLen) {
7006 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7008 RLOGD("simStatusChangedInd");
7010 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7011 convertIntToRadioIndicationType(indicationType));
7012 radioService[slotId]->checkReturnStatus(retStatus);
7014 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7020 int radio::cdmaNewSmsInd(int slotId, int indicationType,
7021 int token, RIL_Errno e, void *response, size_t responseLen) {
7022 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7023 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7024 RLOGE("cdmaNewSmsInd: invalid response");
7028 CdmaSmsMessage msg = {};
7029 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7030 msg.teleserviceId = rilMsg->uTeleserviceID;
7031 msg.isServicePresent = rilMsg->bIsServicePresent;
7032 msg.serviceCategory = rilMsg->uServicecategory;
7033 msg.address.digitMode =
7034 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7035 msg.address.numberMode =
7036 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7037 msg.address.numberType =
7038 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7039 msg.address.numberPlan =
7040 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7042 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7043 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7045 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
7046 rilMsg->sSubAddress.subaddressType;
7047 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7049 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7050 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7052 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7053 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7056 RLOGD("cdmaNewSmsInd");
7058 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7059 convertIntToRadioIndicationType(indicationType), msg);
7060 radioService[slotId]->checkReturnStatus(retStatus);
7062 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7068 int radio::newBroadcastSmsInd(int slotId,
7069 int indicationType, int token, RIL_Errno e, void *response,
7070 size_t responseLen) {
7071 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7072 if (response == NULL || responseLen == 0) {
7073 RLOGE("newBroadcastSmsInd: invalid response");
7077 hidl_vec<uint8_t> data;
7078 data.setToExternal((uint8_t *) response, responseLen);
7080 RLOGD("newBroadcastSmsInd");
7082 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7083 convertIntToRadioIndicationType(indicationType), data);
7084 radioService[slotId]->checkReturnStatus(retStatus);
7086 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7092 int radio::cdmaRuimSmsStorageFullInd(int slotId,
7093 int indicationType, int token, RIL_Errno e, void *response,
7094 size_t responseLen) {
7095 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7097 RLOGD("cdmaRuimSmsStorageFullInd");
7099 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7100 convertIntToRadioIndicationType(indicationType));
7101 radioService[slotId]->checkReturnStatus(retStatus);
7103 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7110 int radio::restrictedStateChangedInd(int slotId,
7111 int indicationType, int token, RIL_Errno e, void *response,
7112 size_t responseLen) {
7113 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7114 if (response == NULL || responseLen != sizeof(int)) {
7115 RLOGE("restrictedStateChangedInd: invalid response");
7118 int32_t state = ((int32_t *) response)[0];
7120 RLOGD("restrictedStateChangedInd: state %d", state);
7122 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7123 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7124 radioService[slotId]->checkReturnStatus(retStatus);
7126 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7133 int radio::enterEmergencyCallbackModeInd(int slotId,
7134 int indicationType, int token, RIL_Errno e, void *response,
7135 size_t responseLen) {
7136 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7138 RLOGD("enterEmergencyCallbackModeInd");
7140 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7141 convertIntToRadioIndicationType(indicationType));
7142 radioService[slotId]->checkReturnStatus(retStatus);
7144 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7151 int radio::cdmaCallWaitingInd(int slotId,
7152 int indicationType, int token, RIL_Errno e, void *response,
7153 size_t responseLen) {
7154 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7155 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7156 RLOGE("cdmaCallWaitingInd: invalid response");
7160 CdmaCallWaiting callWaitingRecord = {};
7161 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7162 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7163 callWaitingRecord.numberPresentation =
7164 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7165 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7166 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7167 callWaitingRecord.signalInfoRecord);
7168 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7169 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7172 RLOGD("cdmaCallWaitingInd");
7174 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7175 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7176 radioService[slotId]->checkReturnStatus(retStatus);
7178 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7184 int radio::cdmaOtaProvisionStatusInd(int slotId,
7185 int indicationType, int token, RIL_Errno e, void *response,
7186 size_t responseLen) {
7187 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7188 if (response == NULL || responseLen != sizeof(int)) {
7189 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7192 int32_t status = ((int32_t *) response)[0];
7194 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7196 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7197 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7198 radioService[slotId]->checkReturnStatus(retStatus);
7200 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7207 int radio::cdmaInfoRecInd(int slotId,
7208 int indicationType, int token, RIL_Errno e, void *response,
7209 size_t responseLen) {
7210 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7211 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7212 RLOGE("cdmaInfoRecInd: invalid response");
7216 CdmaInformationRecords records = {};
7217 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7219 char* string8 = NULL;
7220 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7221 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7222 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7223 "additional ones", recordsRil->numberOfInfoRecs,
7224 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7226 records.infoRec.resize(num);
7227 for (int i = 0 ; i < num ; i++) {
7228 CdmaInformationRecord *record = &records.infoRec[i];
7229 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7230 record->name = (CdmaInfoRecName) infoRec->name;
7231 // All vectors should be size 0 except one which will be size 1. Set everything to
7232 // size 0 initially.
7233 record->display.resize(0);
7234 record->number.resize(0);
7235 record->signal.resize(0);
7236 record->redir.resize(0);
7237 record->lineCtrl.resize(0);
7238 record->clir.resize(0);
7239 record->audioCtrl.resize(0);
7240 switch (infoRec->name) {
7241 case RIL_CDMA_DISPLAY_INFO_REC:
7242 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7243 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7244 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7245 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7246 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7249 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7250 if (string8 == NULL) {
7251 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7252 "responseCdmaInformationRecords");
7255 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7256 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7258 record->display.resize(1);
7259 record->display[0].alphaBuf = string8;
7265 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7266 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7267 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7268 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7269 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7270 "expected not more than %d", (int) infoRec->rec.number.len,
7271 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7274 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7275 if (string8 == NULL) {
7276 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7277 "responseCdmaInformationRecords");
7280 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7281 string8[(int)infoRec->rec.number.len] = '\0';
7283 record->number.resize(1);
7284 record->number[0].number = string8;
7287 record->number[0].numberType = infoRec->rec.number.number_type;
7288 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7289 record->number[0].pi = infoRec->rec.number.pi;
7290 record->number[0].si = infoRec->rec.number.si;
7294 case RIL_CDMA_SIGNAL_INFO_REC: {
7295 record->signal.resize(1);
7296 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7297 record->signal[0].signalType = infoRec->rec.signal.signalType;
7298 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7299 record->signal[0].signal = infoRec->rec.signal.signal;
7303 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7304 if (infoRec->rec.redir.redirectingNumber.len >
7305 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7306 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7307 "expected not more than %d\n",
7308 (int)infoRec->rec.redir.redirectingNumber.len,
7309 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7312 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7314 if (string8 == NULL) {
7315 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7316 "responseCdmaInformationRecords");
7319 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7320 infoRec->rec.redir.redirectingNumber.len);
7321 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7323 record->redir.resize(1);
7324 record->redir[0].redirectingNumber.number = string8;
7327 record->redir[0].redirectingNumber.numberType =
7328 infoRec->rec.redir.redirectingNumber.number_type;
7329 record->redir[0].redirectingNumber.numberPlan =
7330 infoRec->rec.redir.redirectingNumber.number_plan;
7331 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7332 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7333 record->redir[0].redirectingReason =
7334 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7338 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7339 record->lineCtrl.resize(1);
7340 record->lineCtrl[0].lineCtrlPolarityIncluded =
7341 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7342 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7343 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7344 record->lineCtrl[0].lineCtrlPowerDenial =
7345 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7349 case RIL_CDMA_T53_CLIR_INFO_REC: {
7350 record->clir.resize(1);
7351 record->clir[0].cause = infoRec->rec.clir.cause;
7355 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7356 record->audioCtrl.resize(1);
7357 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7358 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7362 case RIL_CDMA_T53_RELEASE_INFO_REC:
7363 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7367 RLOGE("cdmaInfoRecInd: Incorrect name value");
7373 RLOGD("cdmaInfoRecInd");
7375 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7376 convertIntToRadioIndicationType(indicationType), records);
7377 radioService[slotId]->checkReturnStatus(retStatus);
7379 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7385 int radio::indicateRingbackToneInd(int slotId,
7386 int indicationType, int token, RIL_Errno e, void *response,
7387 size_t responseLen) {
7388 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7389 if (response == NULL || responseLen != sizeof(int)) {
7390 RLOGE("indicateRingbackToneInd: invalid response");
7393 bool start = ((int32_t *) response)[0];
7395 RLOGD("indicateRingbackToneInd: start %d", start);
7397 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7398 convertIntToRadioIndicationType(indicationType), start);
7399 radioService[slotId]->checkReturnStatus(retStatus);
7401 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7407 int radio::resendIncallMuteInd(int slotId,
7408 int indicationType, int token, RIL_Errno e, void *response,
7409 size_t responseLen) {
7410 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7412 RLOGD("resendIncallMuteInd");
7414 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7415 convertIntToRadioIndicationType(indicationType));
7416 radioService[slotId]->checkReturnStatus(retStatus);
7418 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7424 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7425 int indicationType, int token, RIL_Errno e,
7426 void *response, size_t responseLen) {
7427 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7428 if (response == NULL || responseLen != sizeof(int)) {
7429 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7432 int32_t cdmaSource = ((int32_t *) response)[0];
7434 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7436 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7437 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7438 (CdmaSubscriptionSource) cdmaSource);
7439 radioService[slotId]->checkReturnStatus(retStatus);
7441 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7448 int radio::cdmaPrlChangedInd(int slotId,
7449 int indicationType, int token, RIL_Errno e, void *response,
7450 size_t responseLen) {
7451 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7452 if (response == NULL || responseLen != sizeof(int)) {
7453 RLOGE("cdmaPrlChangedInd: invalid response");
7456 int32_t version = ((int32_t *) response)[0];
7458 RLOGD("cdmaPrlChangedInd: version %d", version);
7460 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7461 convertIntToRadioIndicationType(indicationType), version);
7462 radioService[slotId]->checkReturnStatus(retStatus);
7464 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7470 int radio::exitEmergencyCallbackModeInd(int slotId,
7471 int indicationType, int token, RIL_Errno e, void *response,
7472 size_t responseLen) {
7473 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7475 RLOGD("exitEmergencyCallbackModeInd");
7477 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7478 convertIntToRadioIndicationType(indicationType));
7479 radioService[slotId]->checkReturnStatus(retStatus);
7481 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7488 int radio::rilConnectedInd(int slotId,
7489 int indicationType, int token, RIL_Errno e, void *response,
7490 size_t responseLen) {
7491 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7492 RLOGD("rilConnectedInd");
7493 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7494 convertIntToRadioIndicationType(indicationType));
7495 radioService[slotId]->checkReturnStatus(retStatus);
7497 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7503 int radio::voiceRadioTechChangedInd(int slotId,
7504 int indicationType, int token, RIL_Errno e, void *response,
7505 size_t responseLen) {
7506 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7507 if (response == NULL || responseLen != sizeof(int)) {
7508 RLOGE("voiceRadioTechChangedInd: invalid response");
7511 int32_t rat = ((int32_t *) response)[0];
7513 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7515 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7516 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7517 radioService[slotId]->checkReturnStatus(retStatus);
7519 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7526 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7527 int num = responseLen / sizeof(RIL_CellInfo_v12);
7528 records.resize(num);
7530 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7531 for (int i = 0; i < num; i++) {
7532 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7533 records[i].registered = rillCellInfo->registered;
7534 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7535 records[i].timeStamp = rillCellInfo->timeStamp;
7536 // All vectors should be size 0 except one which will be size 1. Set everything to
7537 // size 0 initially.
7538 records[i].gsm.resize(0);
7539 records[i].wcdma.resize(0);
7540 records[i].cdma.resize(0);
7541 records[i].lte.resize(0);
7542 records[i].tdscdma.resize(0);
7543 switch(rillCellInfo->cellInfoType) {
7544 case RIL_CELL_INFO_TYPE_GSM: {
7545 records[i].gsm.resize(1);
7546 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7547 cellInfoGsm->cellIdentityGsm.mcc =
7548 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7549 cellInfoGsm->cellIdentityGsm.mnc =
7550 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7551 cellInfoGsm->cellIdentityGsm.lac =
7552 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7553 cellInfoGsm->cellIdentityGsm.cid =
7554 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7555 cellInfoGsm->cellIdentityGsm.arfcn =
7556 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7557 cellInfoGsm->cellIdentityGsm.bsic =
7558 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7559 cellInfoGsm->signalStrengthGsm.signalStrength =
7560 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7561 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7562 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7563 cellInfoGsm->signalStrengthGsm.timingAdvance =
7564 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7568 case RIL_CELL_INFO_TYPE_WCDMA: {
7569 records[i].wcdma.resize(1);
7570 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7571 cellInfoWcdma->cellIdentityWcdma.mcc =
7572 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7573 cellInfoWcdma->cellIdentityWcdma.mnc =
7574 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7575 cellInfoWcdma->cellIdentityWcdma.lac =
7576 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7577 cellInfoWcdma->cellIdentityWcdma.cid =
7578 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7579 cellInfoWcdma->cellIdentityWcdma.psc =
7580 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7581 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7582 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7583 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7584 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7585 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7586 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7590 case RIL_CELL_INFO_TYPE_CDMA: {
7591 records[i].cdma.resize(1);
7592 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7593 cellInfoCdma->cellIdentityCdma.networkId =
7594 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7595 cellInfoCdma->cellIdentityCdma.systemId =
7596 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7597 cellInfoCdma->cellIdentityCdma.baseStationId =
7598 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7599 cellInfoCdma->cellIdentityCdma.longitude =
7600 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7601 cellInfoCdma->cellIdentityCdma.latitude =
7602 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7603 cellInfoCdma->signalStrengthCdma.dbm =
7604 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7605 cellInfoCdma->signalStrengthCdma.ecio =
7606 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7607 cellInfoCdma->signalStrengthEvdo.dbm =
7608 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7609 cellInfoCdma->signalStrengthEvdo.ecio =
7610 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7611 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7612 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7616 case RIL_CELL_INFO_TYPE_LTE: {
7617 records[i].lte.resize(1);
7618 CellInfoLte *cellInfoLte = &records[i].lte[0];
7619 cellInfoLte->cellIdentityLte.mcc =
7620 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7621 cellInfoLte->cellIdentityLte.mnc =
7622 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7623 cellInfoLte->cellIdentityLte.ci =
7624 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7625 cellInfoLte->cellIdentityLte.pci =
7626 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7627 cellInfoLte->cellIdentityLte.tac =
7628 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7629 cellInfoLte->cellIdentityLte.earfcn =
7630 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7631 cellInfoLte->signalStrengthLte.signalStrength =
7632 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7633 cellInfoLte->signalStrengthLte.rsrp =
7634 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7635 cellInfoLte->signalStrengthLte.rsrq =
7636 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7637 cellInfoLte->signalStrengthLte.rssnr =
7638 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7639 cellInfoLte->signalStrengthLte.cqi =
7640 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7641 cellInfoLte->signalStrengthLte.timingAdvance =
7642 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7646 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7647 records[i].tdscdma.resize(1);
7648 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7649 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7650 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7651 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7652 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7653 cellInfoTdscdma->cellIdentityTdscdma.lac =
7654 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7655 cellInfoTdscdma->cellIdentityTdscdma.cid =
7656 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7657 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7658 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7659 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7660 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7671 int radio::cellInfoListInd(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_CellInfo_v12) != 0) {
7676 RLOGE("cellInfoListInd: invalid response");
7680 hidl_vec<CellInfo> records;
7681 convertRilCellInfoListToHal(response, responseLen, records);
7684 RLOGD("cellInfoListInd");
7686 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7687 convertIntToRadioIndicationType(indicationType), records);
7688 radioService[slotId]->checkReturnStatus(retStatus);
7690 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7696 int radio::imsNetworkStateChangedInd(int slotId,
7697 int indicationType, int token, RIL_Errno e, void *response,
7698 size_t responseLen) {
7699 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7701 RLOGD("imsNetworkStateChangedInd");
7703 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7704 convertIntToRadioIndicationType(indicationType));
7705 radioService[slotId]->checkReturnStatus(retStatus);
7707 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7714 int radio::subscriptionStatusChangedInd(int slotId,
7715 int indicationType, int token, RIL_Errno e, void *response,
7716 size_t responseLen) {
7717 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7718 if (response == NULL || responseLen != sizeof(int)) {
7719 RLOGE("subscriptionStatusChangedInd: invalid response");
7722 bool activate = ((int32_t *) response)[0];
7724 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7726 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
7727 convertIntToRadioIndicationType(indicationType), activate);
7728 radioService[slotId]->checkReturnStatus(retStatus);
7730 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
7737 int radio::srvccStateNotifyInd(int slotId,
7738 int indicationType, int token, RIL_Errno e, void *response,
7739 size_t responseLen) {
7740 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7741 if (response == NULL || responseLen != sizeof(int)) {
7742 RLOGE("srvccStateNotifyInd: invalid response");
7745 int32_t state = ((int32_t *) response)[0];
7747 RLOGD("srvccStateNotifyInd: rat %d", state);
7749 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
7750 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
7751 radioService[slotId]->checkReturnStatus(retStatus);
7753 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7759 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7760 hidl_vec<HardwareConfig>& records) {
7761 int num = responseLen / sizeof(RIL_HardwareConfig);
7762 records.resize(num);
7764 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7765 for (int i = 0; i < num; i++) {
7766 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7767 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7768 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7769 switch (rilHardwareConfig[i].type) {
7770 case RIL_HARDWARE_CONFIG_MODEM: {
7771 records[i].modem.resize(1);
7772 records[i].sim.resize(0);
7773 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7774 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7775 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7776 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7777 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7781 case RIL_HARDWARE_CONFIG_SIM: {
7782 records[i].sim.resize(1);
7783 records[i].modem.resize(0);
7784 records[i].sim[0].modemUuid =
7785 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7792 int radio::hardwareConfigChangedInd(int slotId,
7793 int indicationType, int token, RIL_Errno e, void *response,
7794 size_t responseLen) {
7795 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7796 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7797 RLOGE("hardwareConfigChangedInd: invalid response");
7801 hidl_vec<HardwareConfig> configs;
7802 convertRilHardwareConfigListToHal(response, responseLen, configs);
7805 RLOGD("hardwareConfigChangedInd");
7807 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
7808 convertIntToRadioIndicationType(indicationType), configs);
7809 radioService[slotId]->checkReturnStatus(retStatus);
7811 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
7818 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7819 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7820 rc.session = rilRadioCapability->session;
7821 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7822 rc.raf = rilRadioCapability->rat;
7823 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7824 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
7827 int radio::radioCapabilityIndicationInd(int slotId,
7828 int indicationType, int token, RIL_Errno e, void *response,
7829 size_t responseLen) {
7830 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7831 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
7832 RLOGE("radioCapabilityIndicationInd: invalid response");
7836 RadioCapability rc = {};
7837 convertRilRadioCapabilityToHal(response, responseLen, rc);
7840 RLOGD("radioCapabilityIndicationInd");
7842 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
7843 convertIntToRadioIndicationType(indicationType), rc);
7844 radioService[slotId]->checkReturnStatus(retStatus);
7846 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
7853 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
7854 if ((reqType == SS_INTERROGATION) &&
7855 (serType == SS_CFU ||
7856 serType == SS_CF_BUSY ||
7857 serType == SS_CF_NO_REPLY ||
7858 serType == SS_CF_NOT_REACHABLE ||
7859 serType == SS_CF_ALL ||
7860 serType == SS_CF_ALL_CONDITIONAL)) {
7866 int radio::onSupplementaryServiceIndicationInd(int slotId,
7867 int indicationType, int token, RIL_Errno e,
7868 void *response, size_t responseLen) {
7869 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7870 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
7871 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
7875 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
7876 StkCcUnsolSsResult ss = {};
7877 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
7878 ss.requestType = (SsRequestType) rilSsResponse->requestType;
7879 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
7880 ss.serviceClass = rilSsResponse->serviceClass;
7881 ss.result = (RadioError) rilSsResponse->result;
7883 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
7885 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
7886 rilSsResponse->cfData.numValidIndexes);
7888 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
7889 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
7890 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
7891 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
7894 ss.cfData.resize(1);
7895 ss.ssInfo.resize(0);
7897 /* number of call info's */
7898 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
7900 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
7901 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
7902 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
7904 cfInfo->status = (CallForwardInfoStatus) cf.status;
7905 cfInfo->reason = cf.reason;
7906 cfInfo->serviceClass = cf.serviceClass;
7907 cfInfo->toa = cf.toa;
7908 cfInfo->number = convertCharPtrToHidlString(cf.number);
7909 cfInfo->timeSeconds = cf.timeSeconds;
7911 RLOGD("onSupplementaryServiceIndicationInd: "
7912 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
7913 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
7917 ss.ssInfo.resize(1);
7918 ss.cfData.resize(0);
7921 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
7922 for (int i = 0; i < SS_INFO_MAX; i++) {
7924 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
7925 rilSsResponse->ssInfo[i]);
7927 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
7932 RLOGD("onSupplementaryServiceIndicationInd");
7934 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7935 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
7937 radioService[slotId]->checkReturnStatus(retStatus);
7939 RLOGE("onSupplementaryServiceIndicationInd: "
7940 "radioService[%d]->mRadioIndication == NULL", slotId);
7946 int radio::stkCallControlAlphaNotifyInd(int slotId,
7947 int indicationType, int token, RIL_Errno e, void *response,
7948 size_t responseLen) {
7949 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7950 if (response == NULL || responseLen == 0) {
7951 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
7955 RLOGD("stkCallControlAlphaNotifyInd");
7957 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
7958 convertIntToRadioIndicationType(indicationType),
7959 convertCharPtrToHidlString((char *) response));
7960 radioService[slotId]->checkReturnStatus(retStatus);
7962 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
7969 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
7970 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
7971 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
7972 lce.confidenceLevel = rilLceDataInfo->confidence_level;
7973 lce.lceSuspended = rilLceDataInfo->lce_suspended;
7976 int radio::lceDataInd(int slotId,
7977 int indicationType, int token, RIL_Errno e, void *response,
7978 size_t responseLen) {
7979 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7980 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
7981 RLOGE("lceDataInd: invalid response");
7985 LceDataInfo lce = {};
7986 convertRilLceDataInfoToHal(response, responseLen, lce);
7988 RLOGD("lceDataInd");
7990 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
7991 convertIntToRadioIndicationType(indicationType), lce);
7992 radioService[slotId]->checkReturnStatus(retStatus);
7994 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8000 int radio::pcoDataInd(int slotId,
8001 int indicationType, int token, RIL_Errno e, void *response,
8002 size_t responseLen) {
8003 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8004 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8005 RLOGE("pcoDataInd: invalid response");
8009 PcoDataInfo pco = {};
8010 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8011 pco.cid = rilPcoData->cid;
8012 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8013 pco.pcoId = rilPcoData->pco_id;
8014 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8017 RLOGD("pcoDataInd");
8019 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8020 convertIntToRadioIndicationType(indicationType), pco);
8021 radioService[slotId]->checkReturnStatus(retStatus);
8023 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8029 int radio::modemResetInd(int slotId,
8030 int indicationType, int token, RIL_Errno e, void *response,
8031 size_t responseLen) {
8032 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8033 if (response == NULL || responseLen == 0) {
8034 RLOGE("modemResetInd: invalid response");
8038 RLOGD("modemResetInd");
8040 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8041 convertIntToRadioIndicationType(indicationType),
8042 convertCharPtrToHidlString((char *) response));
8043 radioService[slotId]->checkReturnStatus(retStatus);
8045 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8051 int radio::networkScanResultInd(int slotId,
8052 int indicationType, int token, RIL_Errno e, void *response,
8053 size_t responselen) {
8055 RLOGD("networkScanResultInd");
8057 // TODO(b/30954762): Add implementation for networkScanResultInd.
8061 int radio::carrierInfoForImsiEncryption(int slotId,
8062 int indicationType, int token, RIL_Errno e, void *response,
8063 size_t responseLen) {
8064 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8065 if (response == NULL || responseLen == 0) {
8066 RLOGE("carrierInfoForImsiEncryption: invalid response");
8069 RLOGD("carrierInfoForImsiEncryption");
8070 Return<sp<::android::hardware::radio::V1_1::IRadioIndication>> ret =
8071 ::android::hardware::radio::V1_1::IRadioIndication::castFrom(
8072 radioService[slotId]->mRadioIndication);
8074 sp<::android::hardware::radio::V1_1::IRadioIndication> radioIndicationV1_1 = ret;
8075 Return<void> retStatus = radioIndicationV1_1->carrierInfoForImsiEncryption(
8076 convertIntToRadioIndicationType(indicationType));
8077 radioService[slotId]->checkReturnStatus(retStatus);
8079 RLOGE("carrierInfoForImsiEncryptionResponse: ret.isOk() == false for radioService[%d]",
8083 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndication == NULL", slotId);
8089 int radio::oemHookRawInd(int slotId,
8090 int indicationType, int token, RIL_Errno e, void *response,
8091 size_t responseLen) {
8092 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8093 if (response == NULL || responseLen == 0) {
8094 RLOGE("oemHookRawInd: invalid response");
8098 hidl_vec<uint8_t> data;
8099 data.setToExternal((uint8_t *) response, responseLen);
8101 RLOGD("oemHookRawInd");
8103 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8104 convertIntToRadioIndicationType(indicationType), data);
8105 checkReturnStatus(slotId, retStatus, false);
8107 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8113 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8114 using namespace android::hardware;
8116 const char *serviceNames[] = {
8117 android::RIL_getServiceName()
8118 #if (SIM_COUNT >= 2)
8120 #if (SIM_COUNT >= 3)
8122 #if (SIM_COUNT >= 4)
8129 #if (SIM_COUNT >= 2)
8130 simCount = SIM_COUNT;
8133 configureRpcThreadpool(1, true /* callerWillJoin */);
8134 for (int i = 0; i < simCount; i++) {
8135 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8136 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8139 radioService[i] = new RadioImpl;
8140 radioService[i]->mSlotId = i;
8141 oemHookService[i] = new OemHookImpl;
8142 oemHookService[i]->mSlotId = i;
8143 RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
8145 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8146 status = oemHookService[i]->registerAsService(serviceNames[i]);
8148 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8152 s_vendorFunctions = callbacks;
8153 s_commands = commands;
8156 void rilc_thread_pool() {
8157 joinRpcThreadpool();
8160 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8161 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8163 #if (SIM_COUNT >= 2)
8164 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8165 #if (SIM_COUNT >= 3)
8166 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8167 #if (SIM_COUNT >= 4)
8168 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8173 return radioServiceRwlockPtr;