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>
23 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
25 #include <hwbinder/IPCThreadState.h>
26 #include <hwbinder/ProcessState.h>
27 #include <ril_service.h>
28 #include <hidl/HidlTransportSupport.h>
29 #include <utils/SystemClock.h>
32 #define INVALID_HEX_CHAR 16
34 // Enable verbose logging
37 using namespace android::hardware::radio::V1_0;
38 using namespace android::hardware::radio::deprecated::V1_0;
39 using ::android::hardware::configureRpcThreadpool;
40 using ::android::hardware::joinRpcThreadpool;
41 using ::android::hardware::Return;
42 using ::android::hardware::hidl_string;
43 using ::android::hardware::hidl_vec;
44 using ::android::hardware::hidl_array;
45 using ::android::hardware::Void;
46 using android::CommandInfo;
47 using android::RequestInfo;
48 using android::requestToString;
51 #define BOOL_TO_INT(x) (x ? 1 : 0)
52 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
53 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
55 RIL_RadioFunctions *s_vendorFunctions = NULL;
56 static CommandInfo *s_commands;
62 sp<RadioImpl> radioService[SIM_COUNT];
63 sp<OemHookImpl> oemHookService[SIM_COUNT];
64 // counter used for synchronization. It is incremented every time response callbacks are updated.
65 volatile int32_t mCounterRadio[SIM_COUNT];
66 volatile int32_t mCounterOemHook[SIM_COUNT];
68 sp<RadioImpl> radioService[1];
69 sp<OemHookImpl> oemHookService[1];
70 // counter used for synchronization. It is incremented every time response callbacks are updated.
71 volatile int32_t mCounterRadio[1];
72 volatile int32_t mCounterOemHook[1];
75 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
78 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
80 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
82 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
87 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
88 hidl_vec<HardwareConfig>& records);
90 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
92 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
94 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
95 SignalStrength& signalStrength);
97 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
98 SetupDataCallResult& dcResult);
100 void convertRilDataCallListToHal(void *response, size_t responseLen,
101 hidl_vec<SetupDataCallResult>& dcResultList);
103 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
105 struct RadioImpl : public ::android::hardware::radio::V1_1::IRadio {
107 sp<IRadioResponse> mRadioResponse;
108 sp<IRadioIndication> mRadioIndication;
110 Return<void> setResponseFunctions(
111 const ::android::sp<IRadioResponse>& radioResponse,
112 const ::android::sp<IRadioIndication>& radioIndication);
114 Return<void> getIccCardStatus(int32_t serial);
116 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
117 const hidl_string& aid);
119 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
120 const hidl_string& pin, const hidl_string& aid);
122 Return<void> supplyIccPin2ForApp(int32_t serial,
123 const hidl_string& pin2,
124 const hidl_string& aid);
126 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
127 const hidl_string& pin2, const hidl_string& aid);
129 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
130 const hidl_string& newPin, const hidl_string& aid);
132 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
133 const hidl_string& newPin2, const hidl_string& aid);
135 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
137 Return<void> getCurrentCalls(int32_t serial);
139 Return<void> dial(int32_t serial, const Dial& dialInfo);
141 Return<void> getImsiForApp(int32_t serial,
142 const ::android::hardware::hidl_string& aid);
144 Return<void> hangup(int32_t serial, int32_t gsmIndex);
146 Return<void> hangupWaitingOrBackground(int32_t serial);
148 Return<void> hangupForegroundResumeBackground(int32_t serial);
150 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
152 Return<void> conference(int32_t serial);
154 Return<void> rejectCall(int32_t serial);
156 Return<void> getLastCallFailCause(int32_t serial);
158 Return<void> getSignalStrength(int32_t serial);
160 Return<void> getVoiceRegistrationState(int32_t serial);
162 Return<void> getDataRegistrationState(int32_t serial);
164 Return<void> getOperator(int32_t serial);
166 Return<void> setRadioPower(int32_t serial, bool on);
168 Return<void> sendDtmf(int32_t serial,
169 const ::android::hardware::hidl_string& s);
171 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
173 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
175 Return<void> setupDataCall(int32_t serial,
176 RadioTechnology radioTechnology,
177 const DataProfileInfo& profileInfo,
182 Return<void> iccIOForApp(int32_t serial,
185 Return<void> sendUssd(int32_t serial,
186 const ::android::hardware::hidl_string& ussd);
188 Return<void> cancelPendingUssd(int32_t serial);
190 Return<void> getClir(int32_t serial);
192 Return<void> setClir(int32_t serial, int32_t status);
194 Return<void> getCallForwardStatus(int32_t serial,
195 const CallForwardInfo& callInfo);
197 Return<void> setCallForward(int32_t serial,
198 const CallForwardInfo& callInfo);
200 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
202 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
204 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
205 bool success, SmsAcknowledgeFailCause cause);
207 Return<void> acceptCall(int32_t serial);
209 Return<void> deactivateDataCall(int32_t serial,
210 int32_t cid, bool reasonRadioShutDown);
212 Return<void> getFacilityLockForApp(int32_t serial,
213 const ::android::hardware::hidl_string& facility,
214 const ::android::hardware::hidl_string& password,
215 int32_t serviceClass,
216 const ::android::hardware::hidl_string& appId);
218 Return<void> setFacilityLockForApp(int32_t serial,
219 const ::android::hardware::hidl_string& facility,
221 const ::android::hardware::hidl_string& password,
222 int32_t serviceClass,
223 const ::android::hardware::hidl_string& appId);
225 Return<void> setBarringPassword(int32_t serial,
226 const ::android::hardware::hidl_string& facility,
227 const ::android::hardware::hidl_string& oldPassword,
228 const ::android::hardware::hidl_string& newPassword);
230 Return<void> getNetworkSelectionMode(int32_t serial);
232 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
234 Return<void> setNetworkSelectionModeManual(int32_t serial,
235 const ::android::hardware::hidl_string& operatorNumeric);
237 Return<void> getAvailableNetworks(int32_t serial);
239 Return<void> startDtmf(int32_t serial,
240 const ::android::hardware::hidl_string& s);
242 Return<void> stopDtmf(int32_t serial);
244 Return<void> getBasebandVersion(int32_t serial);
246 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
248 Return<void> setMute(int32_t serial, bool enable);
250 Return<void> getMute(int32_t serial);
252 Return<void> getClip(int32_t serial);
254 Return<void> getDataCallList(int32_t serial);
256 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
258 Return<void> writeSmsToSim(int32_t serial,
259 const SmsWriteArgs& smsWriteArgs);
261 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
263 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
265 Return<void> getAvailableBandModes(int32_t serial);
267 Return<void> sendEnvelope(int32_t serial,
268 const ::android::hardware::hidl_string& command);
270 Return<void> sendTerminalResponseToSim(int32_t serial,
271 const ::android::hardware::hidl_string& commandResponse);
273 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
275 Return<void> explicitCallTransfer(int32_t serial);
277 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
279 Return<void> getPreferredNetworkType(int32_t serial);
281 Return<void> getNeighboringCids(int32_t serial);
283 Return<void> setLocationUpdates(int32_t serial, bool enable);
285 Return<void> setCdmaSubscriptionSource(int32_t serial,
286 CdmaSubscriptionSource cdmaSub);
288 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
290 Return<void> getCdmaRoamingPreference(int32_t serial);
292 Return<void> setTTYMode(int32_t serial, TtyMode mode);
294 Return<void> getTTYMode(int32_t serial);
296 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
298 Return<void> getPreferredVoicePrivacy(int32_t serial);
300 Return<void> sendCDMAFeatureCode(int32_t serial,
301 const ::android::hardware::hidl_string& featureCode);
303 Return<void> sendBurstDtmf(int32_t serial,
304 const ::android::hardware::hidl_string& dtmf,
308 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
310 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
311 const CdmaSmsAck& smsAck);
313 Return<void> getGsmBroadcastConfig(int32_t serial);
315 Return<void> setGsmBroadcastConfig(int32_t serial,
316 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
318 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
320 Return<void> getCdmaBroadcastConfig(int32_t serial);
322 Return<void> setCdmaBroadcastConfig(int32_t serial,
323 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
325 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
327 Return<void> getCDMASubscription(int32_t serial);
329 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
331 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
333 Return<void> getDeviceIdentity(int32_t serial);
335 Return<void> exitEmergencyCallbackMode(int32_t serial);
337 Return<void> getSmscAddress(int32_t serial);
339 Return<void> setSmscAddress(int32_t serial,
340 const ::android::hardware::hidl_string& smsc);
342 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
344 Return<void> reportStkServiceIsRunning(int32_t serial);
346 Return<void> getCdmaSubscriptionSource(int32_t serial);
348 Return<void> requestIsimAuthentication(int32_t serial,
349 const ::android::hardware::hidl_string& challenge);
351 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
353 const ::android::hardware::hidl_string& ackPdu);
355 Return<void> sendEnvelopeWithStatus(int32_t serial,
356 const ::android::hardware::hidl_string& contents);
358 Return<void> getVoiceRadioTechnology(int32_t serial);
360 Return<void> getCellInfoList(int32_t serial);
362 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
364 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
365 bool modemCognitive, bool isRoaming);
367 Return<void> getImsRegistrationState(int32_t serial);
369 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
371 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
373 Return<void> iccOpenLogicalChannel(int32_t serial,
374 const ::android::hardware::hidl_string& aid, int32_t p2);
376 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
378 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
380 Return<void> nvReadItem(int32_t serial, NvItem itemId);
382 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
384 Return<void> nvWriteCdmaPrl(int32_t serial,
385 const ::android::hardware::hidl_vec<uint8_t>& prl);
387 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
389 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
391 Return<void> setDataAllowed(int32_t serial, bool allow);
393 Return<void> getHardwareConfig(int32_t serial);
395 Return<void> requestIccSimAuthentication(int32_t serial,
397 const ::android::hardware::hidl_string& authData,
398 const ::android::hardware::hidl_string& aid);
400 Return<void> setDataProfile(int32_t serial,
401 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
403 Return<void> requestShutdown(int32_t serial);
405 Return<void> getRadioCapability(int32_t serial);
407 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
409 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
411 Return<void> stopLceService(int32_t serial);
413 Return<void> pullLceData(int32_t serial);
415 Return<void> getModemActivityInfo(int32_t serial);
417 Return<void> setAllowedCarriers(int32_t serial,
419 const CarrierRestrictions& carriers);
421 Return<void> getAllowedCarriers(int32_t serial);
423 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
425 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
427 Return<void> setSimCardPower(int32_t serial, bool powerUp);
429 Return<void> responseAcknowledgement();
431 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
432 const ::android::hardware::hidl_vec<uint8_t>& carrierKey,
433 const hidl_string& keyIdentifier);
435 void checkReturnStatus(Return<void>& ret);
438 struct OemHookImpl : public IOemHook {
440 sp<IOemHookResponse> mOemHookResponse;
441 sp<IOemHookIndication> mOemHookIndication;
443 Return<void> setResponseFunctions(
444 const ::android::sp<IOemHookResponse>& oemHookResponse,
445 const ::android::sp<IOemHookIndication>& oemHookIndication);
447 Return<void> sendRequestRaw(int32_t serial,
448 const ::android::hardware::hidl_vec<uint8_t>& data);
450 Return<void> sendRequestStrings(int32_t serial,
451 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
454 void memsetAndFreeStrings(int numPointers, ...) {
456 va_start(ap, numPointers);
457 for (int i = 0; i < numPointers; i++) {
458 char *ptr = va_arg(ap, char *);
461 #define MAX_STRING_LENGTH 4096
462 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
470 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
471 pRI->pCI->responseFunction((int) pRI->socket_id,
472 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
476 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
477 * request with error RIL_E_NO_MEMORY.
478 * Returns true on success, and false on failure.
480 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
481 size_t len = src.size();
486 *dest = (char *) calloc(len + 1, sizeof(char));
488 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
489 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
492 strncpy(*dest, src.c_str(), len + 1);
496 hidl_string convertCharPtrToHidlString(const char *ptr) {
499 // TODO: replace this with strnlen
500 ret.setToExternal(ptr, strlen(ptr));
505 bool dispatchVoid(int serial, int slotId, int request) {
506 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
510 s_vendorFunctions->onRequest(request, NULL, 0, pRI);
514 bool dispatchString(int serial, int slotId, int request, const char * str) {
515 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
521 if (!copyHidlStringToRil(&pString, str, pRI)) {
525 s_vendorFunctions->onRequest(request, pString, sizeof(char *), pRI);
527 memsetAndFreeStrings(1, pString);
531 bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) {
532 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
538 pStrings = (char **)calloc(countStrings, sizeof(char *));
539 if (pStrings == NULL) {
540 RLOGE("Memory allocation failed for request %s", requestToString(request));
541 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
545 va_start(ap, countStrings);
546 for (int i = 0; i < countStrings; i++) {
547 const char* str = va_arg(ap, const char *);
548 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI)) {
550 for (int j = 0; j < i; j++) {
551 memsetAndFreeStrings(1, pStrings[j]);
559 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
561 if (pStrings != NULL) {
562 for (int i = 0 ; i < countStrings ; i++) {
563 memsetAndFreeStrings(1, pStrings[i]);
567 memset(pStrings, 0, countStrings * sizeof(char *));
574 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
575 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
580 int countStrings = data.size();
582 pStrings = (char **)calloc(countStrings, sizeof(char *));
583 if (pStrings == NULL) {
584 RLOGE("Memory allocation failed for request %s", requestToString(request));
585 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
589 for (int i = 0; i < countStrings; i++) {
590 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
591 for (int j = 0; j < i; j++) {
592 memsetAndFreeStrings(1, pStrings[j]);
599 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
601 if (pStrings != NULL) {
602 for (int i = 0 ; i < countStrings ; i++) {
603 memsetAndFreeStrings(1, pStrings[i]);
607 memset(pStrings, 0, countStrings * sizeof(char *));
614 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
615 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
620 int *pInts = (int *)calloc(countInts, sizeof(int));
623 RLOGE("Memory allocation failed for request %s", requestToString(request));
624 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
628 va_start(ap, countInts);
629 for (int i = 0; i < countInts; i++) {
630 pInts[i] = va_arg(ap, int);
634 s_vendorFunctions->onRequest(request, pInts, countInts * sizeof(int), pRI);
638 memset(pInts, 0, countInts * sizeof(int));
645 bool dispatchCallForwardStatus(int serial, int slotId, int request,
646 const CallForwardInfo& callInfo) {
647 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
652 RIL_CallForwardInfo cf;
653 cf.status = (int) callInfo.status;
654 cf.reason = callInfo.reason;
655 cf.serviceClass = callInfo.serviceClass;
656 cf.toa = callInfo.toa;
657 cf.timeSeconds = callInfo.timeSeconds;
659 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
663 s_vendorFunctions->onRequest(request, &cf, sizeof(cf), pRI);
665 memsetAndFreeStrings(1, cf.number);
670 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
671 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
676 const uint8_t *uData = rawBytes.data();
678 s_vendorFunctions->onRequest(request, (void *) uData, rawBytes.size(), pRI);
683 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
684 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
689 RIL_SIM_APDU apdu = {};
691 apdu.sessionid = message.sessionId;
692 apdu.cla = message.cla;
693 apdu.instruction = message.instruction;
694 apdu.p1 = message.p1;
695 apdu.p2 = message.p2;
696 apdu.p3 = message.p3;
698 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
702 s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI);
704 memsetAndFreeStrings(1, apdu.data);
709 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
710 if (ret.isOk() == false) {
711 RLOGE("checkReturnStatus: unable to call response/indication callback");
712 // Remote process hosting the callbacks must be dead. Reset the callback objects;
713 // there's no other recovery to be done here. When the client process is back up, it will
714 // call setResponseFunctions()
716 // Caller should already hold rdlock, release that first
717 // note the current counter to avoid overwriting updates made by another thread before
718 // write lock is acquired.
719 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
720 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
721 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
725 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
728 // make sure the counter value has not changed
729 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
730 if (isRadioService) {
731 radioService[slotId]->mRadioResponse = NULL;
732 radioService[slotId]->mRadioIndication = NULL;
734 oemHookService[slotId]->mOemHookResponse = NULL;
735 oemHookService[slotId]->mOemHookIndication = NULL;
737 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
739 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
740 "got updated on another thread");
744 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
748 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
753 void RadioImpl::checkReturnStatus(Return<void>& ret) {
754 ::checkReturnStatus(mSlotId, ret, true);
757 Return<void> RadioImpl::setResponseFunctions(
758 const ::android::sp<IRadioResponse>& radioResponseParam,
759 const ::android::sp<IRadioIndication>& radioIndicationParam) {
760 RLOGD("setResponseFunctions");
762 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
763 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
766 mRadioResponse = radioResponseParam;
767 mRadioIndication = radioIndicationParam;
768 mCounterRadio[mSlotId]++;
770 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
773 // client is connected. Send initial indications.
774 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
779 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
781 RLOGD("getIccCardStatus: serial %d", serial);
783 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
787 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
788 const hidl_string& aid) {
790 RLOGD("supplyIccPinForApp: serial %d", serial);
792 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
793 2, pin.c_str(), aid.c_str());
797 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
798 const hidl_string& pin, const hidl_string& aid) {
800 RLOGD("supplyIccPukForApp: serial %d", serial);
802 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
803 3, puk.c_str(), pin.c_str(), aid.c_str());
807 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
808 const hidl_string& aid) {
810 RLOGD("supplyIccPin2ForApp: serial %d", serial);
812 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
813 2, pin2.c_str(), aid.c_str());
817 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
818 const hidl_string& pin2, const hidl_string& aid) {
820 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
822 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
823 3, puk2.c_str(), pin2.c_str(), aid.c_str());
827 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
828 const hidl_string& newPin, const hidl_string& aid) {
830 RLOGD("changeIccPinForApp: serial %d", serial);
832 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
833 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
837 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
838 const hidl_string& newPin2, const hidl_string& aid) {
840 RLOGD("changeIccPin2ForApp: serial %d", serial);
842 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
843 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
847 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
848 const hidl_string& netPin) {
850 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
852 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
857 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
859 RLOGD("getCurrentCalls: serial %d", serial);
861 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
865 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
867 RLOGD("dial: serial %d", serial);
869 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
874 RIL_UUS_Info uusInfo = {};
875 int32_t sizeOfDial = sizeof(dial);
877 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
880 dial.clir = (int) dialInfo.clir;
882 if (dialInfo.uusInfo.size() != 0) {
883 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
884 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
886 if (dialInfo.uusInfo[0].uusData.size() == 0) {
887 uusInfo.uusData = NULL;
888 uusInfo.uusLength = 0;
890 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
891 memsetAndFreeStrings(1, dial.address);
894 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
897 dial.uusInfo = &uusInfo;
900 s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI);
902 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
907 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
909 RLOGD("getImsiForApp: serial %d", serial);
911 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
916 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
918 RLOGD("hangup: serial %d", serial);
920 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
924 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
926 RLOGD("hangupWaitingOrBackground: serial %d", serial);
928 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
932 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
934 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
936 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
940 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
942 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
944 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
948 Return<void> RadioImpl::conference(int32_t serial) {
950 RLOGD("conference: serial %d", serial);
952 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
956 Return<void> RadioImpl::rejectCall(int32_t serial) {
958 RLOGD("rejectCall: serial %d", serial);
960 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
964 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
966 RLOGD("getLastCallFailCause: serial %d", serial);
968 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
972 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
974 RLOGD("getSignalStrength: serial %d", serial);
976 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
980 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
982 RLOGD("getVoiceRegistrationState: serial %d", serial);
984 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
988 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
990 RLOGD("getDataRegistrationState: serial %d", serial);
992 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
996 Return<void> RadioImpl::getOperator(int32_t serial) {
998 RLOGD("getOperator: serial %d", serial);
1000 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1004 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
1005 RLOGD("setRadioPower: serial %d on %d", serial, on);
1006 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1010 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1012 RLOGD("sendDtmf: serial %d", serial);
1014 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1018 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1020 RLOGD("sendSms: serial %d", serial);
1022 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
1023 2, message.smscPdu.c_str(), message.pdu.c_str());
1027 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1029 RLOGD("sendSMSExpectMore: serial %d", serial);
1031 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
1032 2, message.smscPdu.c_str(), message.pdu.c_str());
1036 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1038 case MvnoType::IMSI:
1039 str = (char *)"imsi";
1042 str = (char *)"gid";
1045 str = (char *)"spn";
1047 case MvnoType::NONE:
1054 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1055 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1056 bool roamingAllowed, bool isRoaming) {
1059 RLOGD("setupDataCall: serial %d", serial);
1062 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1063 const hidl_string &protocol =
1064 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1065 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
1066 std::to_string((int) radioTechnology + 2).c_str(),
1067 std::to_string((int) dataProfileInfo.profileId).c_str(),
1068 dataProfileInfo.apn.c_str(),
1069 dataProfileInfo.user.c_str(),
1070 dataProfileInfo.password.c_str(),
1071 std::to_string((int) dataProfileInfo.authType).c_str(),
1073 } else if (s_vendorFunctions->version >= 15) {
1074 char *mvnoTypeStr = NULL;
1075 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1076 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1077 RIL_REQUEST_SETUP_DATA_CALL);
1079 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1083 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1084 std::to_string((int) radioTechnology + 2).c_str(),
1085 std::to_string((int) dataProfileInfo.profileId).c_str(),
1086 dataProfileInfo.apn.c_str(),
1087 dataProfileInfo.user.c_str(),
1088 dataProfileInfo.password.c_str(),
1089 std::to_string((int) dataProfileInfo.authType).c_str(),
1090 dataProfileInfo.protocol.c_str(),
1091 dataProfileInfo.roamingProtocol.c_str(),
1092 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1093 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1094 modemCognitive ? "1" : "0",
1095 std::to_string(dataProfileInfo.mtu).c_str(),
1097 dataProfileInfo.mvnoMatchData.c_str(),
1098 roamingAllowed ? "1" : "0");
1100 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1101 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1102 RIL_REQUEST_SETUP_DATA_CALL);
1104 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1110 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1112 RLOGD("iccIOForApp: serial %d", serial);
1114 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1119 RIL_SIM_IO_v6 rilIccIo = {};
1120 rilIccIo.command = iccIo.command;
1121 rilIccIo.fileid = iccIo.fileId;
1122 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1126 rilIccIo.p1 = iccIo.p1;
1127 rilIccIo.p2 = iccIo.p2;
1128 rilIccIo.p3 = iccIo.p3;
1130 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1131 memsetAndFreeStrings(1, rilIccIo.path);
1135 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1136 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1140 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1141 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1145 s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI);
1147 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1152 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1154 RLOGD("sendUssd: serial %d", serial);
1156 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1160 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1162 RLOGD("cancelPendingUssd: serial %d", serial);
1164 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1168 Return<void> RadioImpl::getClir(int32_t serial) {
1170 RLOGD("getClir: serial %d", serial);
1172 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1176 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1178 RLOGD("setClir: serial %d", serial);
1180 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1184 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1186 RLOGD("getCallForwardStatus: serial %d", serial);
1188 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1193 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1195 RLOGD("setCallForward: serial %d", serial);
1197 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1202 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1204 RLOGD("getCallWaiting: serial %d", serial);
1206 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1210 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1212 RLOGD("setCallWaiting: serial %d", serial);
1214 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1219 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1220 bool success, SmsAcknowledgeFailCause cause) {
1222 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1224 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1229 Return<void> RadioImpl::acceptCall(int32_t serial) {
1231 RLOGD("acceptCall: serial %d", serial);
1233 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1237 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1238 int32_t cid, bool reasonRadioShutDown) {
1240 RLOGD("deactivateDataCall: serial %d", serial);
1242 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1243 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1247 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1248 const hidl_string& password, int32_t serviceClass,
1249 const hidl_string& appId) {
1251 RLOGD("getFacilityLockForApp: serial %d", serial);
1253 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1254 4, facility.c_str(), password.c_str(),
1255 (std::to_string(serviceClass)).c_str(), appId.c_str());
1259 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1260 bool lockState, const hidl_string& password,
1261 int32_t serviceClass, const hidl_string& appId) {
1263 RLOGD("setFacilityLockForApp: serial %d", serial);
1265 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1266 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1267 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1271 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1272 const hidl_string& oldPassword,
1273 const hidl_string& newPassword) {
1275 RLOGD("setBarringPassword: serial %d", serial);
1277 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1278 2, oldPassword.c_str(), newPassword.c_str());
1282 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1284 RLOGD("getNetworkSelectionMode: serial %d", serial);
1286 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1290 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1292 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1294 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1298 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1299 const hidl_string& operatorNumeric) {
1301 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1303 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1304 operatorNumeric.c_str());
1308 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1310 RLOGD("getAvailableNetworks: serial %d", serial);
1312 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1316 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1318 RLOGD("startDtmf: serial %d", serial);
1320 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1325 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1327 RLOGD("stopDtmf: serial %d", serial);
1329 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1333 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1335 RLOGD("getBasebandVersion: serial %d", serial);
1337 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1341 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1343 RLOGD("separateConnection: serial %d", serial);
1345 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1349 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1351 RLOGD("setMute: serial %d", serial);
1353 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1357 Return<void> RadioImpl::getMute(int32_t serial) {
1359 RLOGD("getMute: serial %d", serial);
1361 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1365 Return<void> RadioImpl::getClip(int32_t serial) {
1367 RLOGD("getClip: serial %d", serial);
1369 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1373 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1375 RLOGD("getDataCallList: serial %d", serial);
1377 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1381 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1383 RLOGD("setSuppServiceNotifications: serial %d", serial);
1385 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1386 BOOL_TO_INT(enable));
1390 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1392 RLOGD("writeSmsToSim: serial %d", serial);
1394 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1399 RIL_SMS_WriteArgs args;
1400 args.status = (int) smsWriteArgs.status;
1403 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1407 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1408 memsetAndFreeStrings(1, args.pdu);
1412 s_vendorFunctions->onRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI);
1414 memsetAndFreeStrings(2, args.smsc, args.pdu);
1419 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1421 RLOGD("deleteSmsOnSim: serial %d", serial);
1423 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1427 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1429 RLOGD("setBandMode: serial %d", serial);
1431 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1435 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1437 RLOGD("getAvailableBandModes: serial %d", serial);
1439 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1443 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1445 RLOGD("sendEnvelope: serial %d", serial);
1447 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1452 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1453 const hidl_string& commandResponse) {
1455 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1457 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1458 commandResponse.c_str());
1462 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1464 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1466 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1467 1, BOOL_TO_INT(accept));
1471 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1473 RLOGD("explicitCallTransfer: serial %d", serial);
1475 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1479 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1481 RLOGD("setPreferredNetworkType: serial %d", serial);
1483 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1487 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1489 RLOGD("getPreferredNetworkType: serial %d", serial);
1491 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1495 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1497 RLOGD("getNeighboringCids: serial %d", serial);
1499 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1503 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1505 RLOGD("setLocationUpdates: serial %d", serial);
1507 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1511 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1513 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1515 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1519 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1521 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1523 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1527 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1529 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1531 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1535 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1537 RLOGD("setTTYMode: serial %d", serial);
1539 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1543 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1545 RLOGD("getTTYMode: serial %d", serial);
1547 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1551 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1553 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1555 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1556 1, BOOL_TO_INT(enable));
1560 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1562 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1564 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1568 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1570 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1572 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1573 featureCode.c_str());
1577 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1580 RLOGD("sendBurstDtmf: serial %d", serial);
1582 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1583 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1584 (std::to_string(off)).c_str());
1588 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1589 rcsm.uTeleserviceID = sms.teleserviceId;
1590 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1591 rcsm.uServicecategory = sms.serviceCategory;
1592 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1593 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1594 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1595 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1597 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1598 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1599 for (int i = 0; i < digitLimit; i++) {
1600 rcsm.sAddress.digits[i] = sms.address.digits[i];
1603 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1604 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1606 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1607 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1608 for (int i = 0; i < digitLimit; i++) {
1609 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1612 rcsm.uBearerDataLen = sms.bearerData.size();
1613 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1614 for (int i = 0; i < digitLimit; i++) {
1615 rcsm.aBearerData[i] = sms.bearerData[i];
1619 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1621 RLOGD("sendCdmaSms: serial %d", serial);
1623 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1628 RIL_CDMA_SMS_Message rcsm = {};
1629 constructCdmaSms(rcsm, sms);
1631 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI);
1635 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1637 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1639 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1644 RIL_CDMA_SMS_Ack rcsa = {};
1646 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1647 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1649 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI);
1653 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1655 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1657 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1661 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1662 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1665 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1667 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1668 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1673 int num = configInfo.size();
1674 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1675 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1677 for (int i = 0 ; i < num ; i++ ) {
1678 gsmBciPtrs[i] = &gsmBci[i];
1679 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1680 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1681 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1682 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1683 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1686 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, gsmBciPtrs,
1687 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI);
1691 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1693 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1695 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1696 1, BOOL_TO_INT(!activate));
1700 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1702 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1704 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1708 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1709 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1712 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1714 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1715 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1720 int num = configInfo.size();
1721 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1722 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1724 for (int i = 0 ; i < num ; i++ ) {
1725 cdmaBciPtrs[i] = &cdmaBci[i];
1726 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1727 cdmaBci[i].language = configInfo[i].language;
1728 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1731 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, cdmaBciPtrs,
1732 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI);
1736 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1738 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1740 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1741 1, BOOL_TO_INT(!activate));
1745 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1747 RLOGD("getCDMASubscription: serial %d", serial);
1749 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1753 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1755 RLOGD("writeSmsToRuim: serial %d", serial);
1757 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1758 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1763 RIL_CDMA_SMS_WriteArgs rcsw = {};
1764 rcsw.status = (int) cdmaSms.status;
1765 constructCdmaSms(rcsw.message, cdmaSms.message);
1767 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI);
1771 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1773 RLOGD("deleteSmsOnRuim: serial %d", serial);
1775 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1779 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1781 RLOGD("getDeviceIdentity: serial %d", serial);
1783 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1787 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1789 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1791 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1795 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1797 RLOGD("getSmscAddress: serial %d", serial);
1799 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1803 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1805 RLOGD("setSmscAddress: serial %d", serial);
1807 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1812 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1814 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1816 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1817 BOOL_TO_INT(available));
1821 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1823 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1825 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1829 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1831 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1833 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1837 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1839 RLOGD("requestIsimAuthentication: serial %d", serial);
1841 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1846 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1847 const hidl_string& ackPdu) {
1849 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1851 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1852 2, success ? "1" : "0", ackPdu.c_str());
1856 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1858 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1860 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1865 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1867 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1869 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1873 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1875 RLOGD("getCellInfoList: serial %d", serial);
1877 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1881 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1883 RLOGD("setCellInfoListRate: serial %d", serial);
1885 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1889 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1890 bool modemCognitive, bool isRoaming) {
1892 RLOGD("setInitialAttachApn: serial %d", serial);
1894 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1895 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
1900 if (s_vendorFunctions->version <= 14) {
1901 RIL_InitialAttachApn iaa = {};
1903 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1907 const hidl_string &protocol =
1908 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1910 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
1911 memsetAndFreeStrings(1, iaa.apn);
1914 iaa.authtype = (int) dataProfileInfo.authType;
1915 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1916 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
1919 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1920 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
1924 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1926 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
1928 RIL_InitialAttachApn_v15 iaa = {};
1930 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1933 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
1934 memsetAndFreeStrings(1, iaa.apn);
1937 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
1938 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
1941 iaa.authtype = (int) dataProfileInfo.authType;
1942 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1943 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
1946 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
1947 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
1950 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
1951 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
1952 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
1953 iaa.mtu = dataProfileInfo.mtu;
1955 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
1956 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1957 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1962 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
1963 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1968 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
1970 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
1971 iaa.password, iaa.mvnoMatchData);
1977 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
1979 RLOGD("getImsRegistrationState: serial %d", serial);
1981 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
1985 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
1986 RIL_IMS_SMS_Message rism = {};
1988 int countStrings = 2;
1989 int dataLen = sizeof(char *) * countStrings;
1991 rism.tech = RADIO_TECH_3GPP;
1992 rism.retry = BOOL_TO_INT(message.retry);
1993 rism.messageRef = message.messageRef;
1995 if (message.gsmMessage.size() != 1) {
1996 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
1997 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2001 pStrings = (char **)calloc(countStrings, sizeof(char *));
2002 if (pStrings == NULL) {
2003 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2004 requestToString(pRI->pCI->requestNumber));
2005 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2009 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2011 memset(pStrings, 0, dataLen);
2017 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2018 memsetAndFreeStrings(1, pStrings[0]);
2020 memset(pStrings, 0, dataLen);
2026 rism.message.gsmMessage = pStrings;
2027 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2028 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI);
2030 for (int i = 0 ; i < countStrings ; i++) {
2031 memsetAndFreeStrings(1, pStrings[i]);
2035 memset(pStrings, 0, dataLen);
2042 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2043 RIL_IMS_SMS_Message rism = {};
2044 RIL_CDMA_SMS_Message rcsm = {};
2046 if (message.cdmaMessage.size() != 1) {
2047 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2048 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2052 rism.tech = RADIO_TECH_3GPP2;
2053 rism.retry = BOOL_TO_INT(message.retry);
2054 rism.messageRef = message.messageRef;
2055 rism.message.cdmaMessage = &rcsm;
2057 constructCdmaSms(rcsm, message.cdmaMessage[0]);
2059 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2060 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI);
2065 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2067 RLOGD("sendImsSms: serial %d", serial);
2069 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2074 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2076 if (RADIO_TECH_3GPP == format) {
2077 dispatchImsGsmSms(message, pRI);
2078 } else if (RADIO_TECH_3GPP2 == format) {
2079 dispatchImsCdmaSms(message, pRI);
2081 RLOGE("sendImsSms: Invalid radio tech %s",
2082 requestToString(pRI->pCI->requestNumber));
2083 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2088 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2090 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2092 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2096 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2098 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2100 if (s_vendorFunctions->version < 15) {
2101 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2103 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2108 RIL_OpenChannelParams params = {};
2112 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2116 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI);
2118 memsetAndFreeStrings(1, params.aidPtr);
2123 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2125 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2127 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2131 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2133 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2135 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2139 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2141 RLOGD("nvReadItem: serial %d", serial);
2143 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2148 RIL_NV_ReadItem nvri = {};
2149 nvri.itemID = (RIL_NV_Item) itemId;
2151 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI);
2155 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2157 RLOGD("nvWriteItem: serial %d", serial);
2159 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2164 RIL_NV_WriteItem nvwi = {};
2166 nvwi.itemID = (RIL_NV_Item) item.itemId;
2168 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2172 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI);
2174 memsetAndFreeStrings(1, nvwi.value);
2178 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2180 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2182 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2186 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2188 RLOGD("nvResetConfig: serial %d", serial);
2190 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, (int) resetType);
2194 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2196 RLOGD("setUiccSubscription: serial %d", serial);
2198 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2199 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2204 RIL_SelectUiccSub rilUiccSub = {};
2206 rilUiccSub.slot = uiccSub.slot;
2207 rilUiccSub.app_index = uiccSub.appIndex;
2208 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2209 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2211 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI);
2215 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2217 RLOGD("setDataAllowed: serial %d", serial);
2219 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2223 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2225 RLOGD("getHardwareConfig: serial %d", serial);
2227 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2231 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2232 const hidl_string& authData, const hidl_string& aid) {
2234 RLOGD("requestIccSimAuthentication: serial %d", serial);
2236 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2241 RIL_SimAuthentication pf = {};
2243 pf.authContext = authContext;
2246 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2250 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2251 memsetAndFreeStrings(1, pf.authData);
2255 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI);
2257 memsetAndFreeStrings(2, pf.authData, pf.aid);
2262 * @param numProfiles number of data profile
2263 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2264 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2265 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2266 * @param numfields number of string-type member in the data profile structure
2267 * @param ... the variadic parameters are pointers to each string-type member
2269 template <typename T>
2270 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2271 int numfields, ...) {
2273 va_start(args, numfields);
2275 // Iterate through each string-type field that need to be free.
2276 for (int i = 0; i < numfields; i++) {
2277 // Iterate through each data profile and free that specific string-type field.
2278 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2279 char *T::*ptr = va_arg(args, char *T::*);
2280 for (int j = 0; j < numProfiles; j++) {
2281 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2288 memset(dataProfiles, 0, numProfiles * sizeof(T));
2289 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2292 free(dataProfilePtrs);
2295 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2298 RLOGD("setDataProfile: serial %d", serial);
2300 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2305 size_t num = profiles.size();
2306 bool success = false;
2308 if (s_vendorFunctions->version <= 14) {
2310 RIL_DataProfileInfo *dataProfiles =
2311 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2313 if (dataProfiles == NULL) {
2314 RLOGE("Memory allocation failed for request %s",
2315 requestToString(pRI->pCI->requestNumber));
2316 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2320 RIL_DataProfileInfo **dataProfilePtrs =
2321 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2322 if (dataProfilePtrs == NULL) {
2323 RLOGE("Memory allocation failed for request %s",
2324 requestToString(pRI->pCI->requestNumber));
2326 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2330 for (size_t i = 0; i < num; i++) {
2331 dataProfilePtrs[i] = &dataProfiles[i];
2333 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2335 const hidl_string &protocol =
2336 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2338 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2342 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2345 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2351 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2352 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2353 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2357 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2358 dataProfiles[i].authType = (int) profiles[i].authType;
2359 dataProfiles[i].type = (int) profiles[i].type;
2360 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2361 dataProfiles[i].maxConns = profiles[i].maxConns;
2362 dataProfiles[i].waitTime = profiles[i].waitTime;
2363 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2366 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2367 num * sizeof(RIL_DataProfileInfo *), pRI);
2369 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2370 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2371 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2373 RIL_DataProfileInfo_v15 *dataProfiles =
2374 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2376 if (dataProfiles == NULL) {
2377 RLOGE("Memory allocation failed for request %s",
2378 requestToString(pRI->pCI->requestNumber));
2379 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2383 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2384 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2385 if (dataProfilePtrs == NULL) {
2386 RLOGE("Memory allocation failed for request %s",
2387 requestToString(pRI->pCI->requestNumber));
2389 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2393 for (size_t i = 0; i < num; i++) {
2394 dataProfilePtrs[i] = &dataProfiles[i];
2396 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2397 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2401 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2402 profiles[i].roamingProtocol, pRI)) {
2405 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2408 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2413 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2414 profiles[i].mvnoMatchData, pRI)) {
2418 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2419 dataProfiles[i].mvnoType)) {
2420 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2425 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2426 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2427 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2428 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2432 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2433 dataProfiles[i].authType = (int) profiles[i].authType;
2434 dataProfiles[i].type = (int) profiles[i].type;
2435 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2436 dataProfiles[i].maxConns = profiles[i].maxConns;
2437 dataProfiles[i].waitTime = profiles[i].waitTime;
2438 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2439 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2440 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2441 dataProfiles[i].mtu = profiles[i].mtu;
2444 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2445 num * sizeof(RIL_DataProfileInfo_v15 *), pRI);
2447 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2448 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2449 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2450 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2456 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2458 RLOGD("requestShutdown: serial %d", serial);
2460 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2464 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2466 RLOGD("getRadioCapability: serial %d", serial);
2468 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2472 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2474 RLOGD("setRadioCapability: serial %d", serial);
2476 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2481 RIL_RadioCapability rilRc = {};
2483 // TODO : set rilRc.version using HIDL version ?
2484 rilRc.session = rc.session;
2485 rilRc.phase = (int) rc.phase;
2486 rilRc.rat = (int) rc.raf;
2487 rilRc.status = (int) rc.status;
2488 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2490 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI);
2495 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2497 RLOGD("startLceService: serial %d", serial);
2499 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2500 BOOL_TO_INT(pullMode));
2504 Return<void> RadioImpl::stopLceService(int32_t serial) {
2506 RLOGD("stopLceService: serial %d", serial);
2508 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2512 Return<void> RadioImpl::pullLceData(int32_t serial) {
2514 RLOGD("pullLceData: serial %d", serial);
2516 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2520 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2522 RLOGD("getModemActivityInfo: serial %d", serial);
2524 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2528 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2529 const CarrierRestrictions& carriers) {
2531 RLOGD("setAllowedCarriers: serial %d", serial);
2533 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2534 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2539 RIL_CarrierRestrictions cr = {};
2540 RIL_Carrier *allowedCarriers = NULL;
2541 RIL_Carrier *excludedCarriers = NULL;
2543 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2544 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2545 if (allowedCarriers == NULL) {
2546 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2547 requestToString(pRI->pCI->requestNumber));
2548 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2551 cr.allowed_carriers = allowedCarriers;
2553 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2554 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2555 if (excludedCarriers == NULL) {
2556 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2557 requestToString(pRI->pCI->requestNumber));
2558 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2560 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2562 free(allowedCarriers);
2565 cr.excluded_carriers = excludedCarriers;
2567 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2568 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2569 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2570 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2571 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2574 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2575 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2576 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2577 excludedCarriers[i].match_type =
2578 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2579 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2582 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI);
2585 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2586 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2588 free(allowedCarriers);
2589 free(excludedCarriers);
2593 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2595 RLOGD("getAllowedCarriers: serial %d", serial);
2597 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2601 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2604 RLOGD("sendDeviceState: serial %d", serial);
2606 if (s_vendorFunctions->version < 15) {
2607 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2608 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2609 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2611 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2612 RIL_REQUEST_SEND_DEVICE_STATE);
2613 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2617 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2618 BOOL_TO_INT(state));
2622 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2624 RLOGD("setIndicationFilter: serial %d", serial);
2626 if (s_vendorFunctions->version < 15) {
2627 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2628 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2629 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2632 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2636 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2638 RLOGD("setSimCardPower: serial %d", serial);
2640 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2644 Return<void> RadioImpl::responseAcknowledgement() {
2645 android::releaseWakeLock();
2649 Return<void> OemHookImpl::setResponseFunctions(
2650 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2651 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2653 RLOGD("OemHookImpl::setResponseFunctions");
2656 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2657 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2660 mOemHookResponse = oemHookResponseParam;
2661 mOemHookIndication = oemHookIndicationParam;
2662 mCounterOemHook[mSlotId]++;
2664 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2670 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2672 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2674 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2678 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2679 const hidl_vec<hidl_string>& data) {
2681 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2683 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2687 Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial,
2688 const ::android::hardware::hidl_vec<uint8_t>& carrierKey,
2689 const hidl_string& keyIdentifier) {
2690 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
2691 dispatchRaw(serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION, carrierKey);
2695 /***************************************************************************************************
2696 * RESPONSE FUNCTIONS
2697 * Functions above are used for requests going from framework to vendor code. The ones below are
2698 * responses for those requests coming back from the vendor code.
2699 **************************************************************************************************/
2701 void radio::acknowledgeRequest(int slotId, int serial) {
2702 if (radioService[slotId]->mRadioResponse != NULL) {
2703 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2704 radioService[slotId]->checkReturnStatus(retStatus);
2706 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2710 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2712 responseInfo.serial = serial;
2713 switch (responseType) {
2714 case RESPONSE_SOLICITED:
2715 responseInfo.type = RadioResponseType::SOLICITED;
2717 case RESPONSE_SOLICITED_ACK_EXP:
2718 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2721 responseInfo.error = (RadioError) e;
2724 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2725 void *response, size_t responseLen) {
2726 populateResponseInfo(responseInfo, serial, responseType, e);
2729 if (response == NULL && responseLen == 0) {
2730 // Earlier RILs did not send a response for some cases although the interface
2731 // expected an integer as response. Do not return error if response is empty. Instead
2732 // Return -1 in those cases to maintain backward compatibility.
2733 } else if (response == NULL || responseLen != sizeof(int)) {
2734 RLOGE("responseIntOrEmpty: Invalid response");
2735 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2737 int *p_int = (int *) response;
2743 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2744 void *response, size_t responseLen) {
2745 populateResponseInfo(responseInfo, serial, responseType, e);
2748 if (response == NULL || responseLen != sizeof(int)) {
2749 RLOGE("responseInt: Invalid response");
2750 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2752 int *p_int = (int *) response;
2758 int radio::getIccCardStatusResponse(int slotId,
2759 int responseType, int serial, RIL_Errno e,
2760 void *response, size_t responseLen) {
2761 if (radioService[slotId]->mRadioResponse != NULL) {
2762 RadioResponseInfo responseInfo = {};
2763 populateResponseInfo(responseInfo, serial, responseType, e);
2764 CardStatus cardStatus = {};
2765 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2766 RLOGE("getIccCardStatusResponse: Invalid response");
2767 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2769 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2770 cardStatus.cardState = (CardState) p_cur->card_state;
2771 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2772 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2773 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2774 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2776 RIL_AppStatus *rilAppStatus = p_cur->applications;
2777 cardStatus.applications.resize(p_cur->num_applications);
2778 AppStatus *appStatus = cardStatus.applications.data();
2780 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2782 for (int i = 0; i < p_cur->num_applications; i++) {
2783 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2784 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2785 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2786 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2787 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2788 rilAppStatus[i].app_label_ptr);
2789 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2790 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2791 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2795 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2796 getIccCardStatusResponse(responseInfo, cardStatus);
2797 radioService[slotId]->checkReturnStatus(retStatus);
2799 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2805 int radio::supplyIccPinForAppResponse(int slotId,
2806 int responseType, int serial, RIL_Errno e,
2807 void *response, size_t responseLen) {
2809 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
2812 if (radioService[slotId]->mRadioResponse != NULL) {
2813 RadioResponseInfo responseInfo = {};
2814 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2815 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2816 supplyIccPinForAppResponse(responseInfo, ret);
2817 radioService[slotId]->checkReturnStatus(retStatus);
2819 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2826 int radio::supplyIccPukForAppResponse(int slotId,
2827 int responseType, int serial, RIL_Errno e,
2828 void *response, size_t responseLen) {
2830 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
2833 if (radioService[slotId]->mRadioResponse != NULL) {
2834 RadioResponseInfo responseInfo = {};
2835 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2836 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2838 radioService[slotId]->checkReturnStatus(retStatus);
2840 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2847 int radio::supplyIccPin2ForAppResponse(int slotId,
2848 int responseType, int serial, RIL_Errno e,
2849 void *response, size_t responseLen) {
2851 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
2854 if (radioService[slotId]->mRadioResponse != NULL) {
2855 RadioResponseInfo responseInfo = {};
2856 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2857 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2858 supplyIccPin2ForAppResponse(responseInfo, ret);
2859 radioService[slotId]->checkReturnStatus(retStatus);
2861 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2868 int radio::supplyIccPuk2ForAppResponse(int slotId,
2869 int responseType, int serial, RIL_Errno e,
2870 void *response, size_t responseLen) {
2872 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
2875 if (radioService[slotId]->mRadioResponse != NULL) {
2876 RadioResponseInfo responseInfo = {};
2877 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2878 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2879 supplyIccPuk2ForAppResponse(responseInfo, ret);
2880 radioService[slotId]->checkReturnStatus(retStatus);
2882 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2889 int radio::changeIccPinForAppResponse(int slotId,
2890 int responseType, int serial, RIL_Errno e,
2891 void *response, size_t responseLen) {
2893 RLOGD("changeIccPinForAppResponse: serial %d", serial);
2896 if (radioService[slotId]->mRadioResponse != NULL) {
2897 RadioResponseInfo responseInfo = {};
2898 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2899 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2900 changeIccPinForAppResponse(responseInfo, ret);
2901 radioService[slotId]->checkReturnStatus(retStatus);
2903 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2910 int radio::changeIccPin2ForAppResponse(int slotId,
2911 int responseType, int serial, RIL_Errno e,
2912 void *response, size_t responseLen) {
2914 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
2917 if (radioService[slotId]->mRadioResponse != NULL) {
2918 RadioResponseInfo responseInfo = {};
2919 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2920 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2921 changeIccPin2ForAppResponse(responseInfo, ret);
2922 radioService[slotId]->checkReturnStatus(retStatus);
2924 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2931 int radio::supplyNetworkDepersonalizationResponse(int slotId,
2932 int responseType, int serial, RIL_Errno e,
2933 void *response, size_t responseLen) {
2935 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
2938 if (radioService[slotId]->mRadioResponse != NULL) {
2939 RadioResponseInfo responseInfo = {};
2940 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2941 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2942 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2943 radioService[slotId]->checkReturnStatus(retStatus);
2945 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
2952 int radio::getCurrentCallsResponse(int slotId,
2953 int responseType, int serial, RIL_Errno e,
2954 void *response, size_t responseLen) {
2956 RLOGD("getCurrentCallsResponse: serial %d", serial);
2959 if (radioService[slotId]->mRadioResponse != NULL) {
2960 RadioResponseInfo responseInfo = {};
2961 populateResponseInfo(responseInfo, serial, responseType, e);
2963 hidl_vec<Call> calls;
2964 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) {
2965 RLOGE("getCurrentCallsResponse: Invalid response");
2966 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2968 int num = responseLen / sizeof(RIL_Call *);
2971 for (int i = 0 ; i < num ; i++) {
2972 RIL_Call *p_cur = ((RIL_Call **) response)[i];
2973 /* each call info */
2974 calls[i].state = (CallState) p_cur->state;
2975 calls[i].index = p_cur->index;
2976 calls[i].toa = p_cur->toa;
2977 calls[i].isMpty = p_cur->isMpty;
2978 calls[i].isMT = p_cur->isMT;
2979 calls[i].als = p_cur->als;
2980 calls[i].isVoice = p_cur->isVoice;
2981 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
2982 calls[i].number = convertCharPtrToHidlString(p_cur->number);
2983 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
2984 calls[i].name = convertCharPtrToHidlString(p_cur->name);
2985 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
2986 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
2987 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
2988 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
2989 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
2990 // convert uusInfo->uusData to a null-terminated string
2991 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
2992 calls[i].uusInfo[0].uusData = nullTermStr;
2998 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2999 getCurrentCallsResponse(responseInfo, calls);
3000 radioService[slotId]->checkReturnStatus(retStatus);
3002 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3008 int radio::dialResponse(int slotId,
3009 int responseType, int serial, RIL_Errno e, void *response,
3010 size_t responseLen) {
3012 RLOGD("dialResponse: serial %d", serial);
3015 if (radioService[slotId]->mRadioResponse != NULL) {
3016 RadioResponseInfo responseInfo = {};
3017 populateResponseInfo(responseInfo, serial, responseType, e);
3018 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3019 radioService[slotId]->checkReturnStatus(retStatus);
3021 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3027 int radio::getIMSIForAppResponse(int slotId,
3028 int responseType, int serial, RIL_Errno e, void *response,
3029 size_t responseLen) {
3031 RLOGD("getIMSIForAppResponse: serial %d", serial);
3034 if (radioService[slotId]->mRadioResponse != NULL) {
3035 RadioResponseInfo responseInfo = {};
3036 populateResponseInfo(responseInfo, serial, responseType, e);
3037 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3038 responseInfo, convertCharPtrToHidlString((char *) response));
3039 radioService[slotId]->checkReturnStatus(retStatus);
3041 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3048 int radio::hangupConnectionResponse(int slotId,
3049 int responseType, int serial, RIL_Errno e,
3050 void *response, size_t responseLen) {
3052 RLOGD("hangupConnectionResponse: serial %d", serial);
3055 if (radioService[slotId]->mRadioResponse != NULL) {
3056 RadioResponseInfo responseInfo = {};
3057 populateResponseInfo(responseInfo, serial, responseType, e);
3058 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3060 radioService[slotId]->checkReturnStatus(retStatus);
3062 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3069 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3070 int responseType, int serial, RIL_Errno e,
3071 void *response, size_t responseLen) {
3073 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3076 if (radioService[slotId]->mRadioResponse != NULL) {
3077 RadioResponseInfo responseInfo = {};
3078 populateResponseInfo(responseInfo, serial, responseType, e);
3079 Return<void> retStatus =
3080 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3082 radioService[slotId]->checkReturnStatus(retStatus);
3084 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3091 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3092 RIL_Errno e, void *response,
3093 size_t responseLen) {
3095 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3098 if (radioService[slotId]->mRadioResponse != NULL) {
3099 RadioResponseInfo responseInfo = {};
3100 populateResponseInfo(responseInfo, serial, responseType, e);
3101 Return<void> retStatus =
3102 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3104 radioService[slotId]->checkReturnStatus(retStatus);
3106 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3113 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3114 RIL_Errno e, void *response,
3115 size_t responseLen) {
3117 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3120 if (radioService[slotId]->mRadioResponse != NULL) {
3121 RadioResponseInfo responseInfo = {};
3122 populateResponseInfo(responseInfo, serial, responseType, e);
3123 Return<void> retStatus =
3124 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3126 radioService[slotId]->checkReturnStatus(retStatus);
3128 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3135 int radio::conferenceResponse(int slotId, int responseType,
3136 int serial, RIL_Errno e, void *response, size_t responseLen) {
3138 RLOGD("conferenceResponse: serial %d", serial);
3141 if (radioService[slotId]->mRadioResponse != NULL) {
3142 RadioResponseInfo responseInfo = {};
3143 populateResponseInfo(responseInfo, serial, responseType, e);
3144 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3146 radioService[slotId]->checkReturnStatus(retStatus);
3148 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3155 int radio::rejectCallResponse(int slotId, int responseType,
3156 int serial, RIL_Errno e, void *response, size_t responseLen) {
3158 RLOGD("rejectCallResponse: serial %d", serial);
3161 if (radioService[slotId]->mRadioResponse != NULL) {
3162 RadioResponseInfo responseInfo = {};
3163 populateResponseInfo(responseInfo, serial, responseType, e);
3164 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3166 radioService[slotId]->checkReturnStatus(retStatus);
3168 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3175 int radio::getLastCallFailCauseResponse(int slotId,
3176 int responseType, int serial, RIL_Errno e, void *response,
3177 size_t responseLen) {
3179 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3182 if (radioService[slotId]->mRadioResponse != NULL) {
3183 RadioResponseInfo responseInfo = {};
3184 populateResponseInfo(responseInfo, serial, responseType, e);
3186 LastCallFailCauseInfo info = {};
3187 info.vendorCause = hidl_string();
3188 if (response == NULL) {
3189 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3190 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3191 } else if (responseLen == sizeof(int)) {
3192 int *pInt = (int *) response;
3193 info.causeCode = (LastCallFailCause) pInt[0];
3194 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3195 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3196 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3197 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3199 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3200 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3203 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3204 responseInfo, info);
3205 radioService[slotId]->checkReturnStatus(retStatus);
3207 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3214 int radio::getSignalStrengthResponse(int slotId,
3215 int responseType, int serial, RIL_Errno e,
3216 void *response, size_t responseLen) {
3218 RLOGD("getSignalStrengthResponse: serial %d", serial);
3221 if (radioService[slotId]->mRadioResponse != NULL) {
3222 RadioResponseInfo responseInfo = {};
3223 populateResponseInfo(responseInfo, serial, responseType, e);
3224 SignalStrength signalStrength = {};
3225 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3226 RLOGE("getSignalStrengthResponse: Invalid response");
3227 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3229 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3232 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3233 responseInfo, signalStrength);
3234 radioService[slotId]->checkReturnStatus(retStatus);
3236 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3243 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3245 return RIL_CELL_INFO_TYPE_NONE;
3248 int radioTech = atoi(rat);
3252 case RADIO_TECH_GPRS:
3253 case RADIO_TECH_EDGE:
3254 case RADIO_TECH_GSM: {
3255 return RIL_CELL_INFO_TYPE_GSM;
3258 case RADIO_TECH_UMTS:
3259 case RADIO_TECH_HSDPA:
3260 case RADIO_TECH_HSUPA:
3261 case RADIO_TECH_HSPA:
3262 case RADIO_TECH_HSPAP: {
3263 return RIL_CELL_INFO_TYPE_WCDMA;
3266 case RADIO_TECH_IS95A:
3267 case RADIO_TECH_IS95B:
3268 case RADIO_TECH_1xRTT:
3269 case RADIO_TECH_EVDO_0:
3270 case RADIO_TECH_EVDO_A:
3271 case RADIO_TECH_EVDO_B:
3272 case RADIO_TECH_EHRPD: {
3273 return RIL_CELL_INFO_TYPE_CDMA;
3276 case RADIO_TECH_LTE:
3277 case RADIO_TECH_LTE_CA: {
3278 return RIL_CELL_INFO_TYPE_LTE;
3281 case RADIO_TECH_TD_SCDMA: {
3282 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3290 return RIL_CELL_INFO_TYPE_NONE;
3294 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3296 cellIdentity.cellIdentityGsm.resize(0);
3297 cellIdentity.cellIdentityWcdma.resize(0);
3298 cellIdentity.cellIdentityCdma.resize(0);
3299 cellIdentity.cellIdentityTdscdma.resize(0);
3300 cellIdentity.cellIdentityLte.resize(0);
3301 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3302 switch(rilCellIdentity.cellInfoType) {
3304 case RIL_CELL_INFO_TYPE_GSM: {
3305 cellIdentity.cellIdentityGsm.resize(1);
3306 cellIdentity.cellIdentityGsm[0].mcc =
3307 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3308 cellIdentity.cellIdentityGsm[0].mnc =
3309 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3310 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3311 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3312 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3313 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3317 case RIL_CELL_INFO_TYPE_WCDMA: {
3318 cellIdentity.cellIdentityWcdma.resize(1);
3319 cellIdentity.cellIdentityWcdma[0].mcc =
3320 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3321 cellIdentity.cellIdentityWcdma[0].mnc =
3322 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3323 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3324 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3325 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3326 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3330 case RIL_CELL_INFO_TYPE_CDMA: {
3331 cellIdentity.cellIdentityCdma.resize(1);
3332 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3333 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3334 cellIdentity.cellIdentityCdma[0].baseStationId =
3335 rilCellIdentity.cellIdentityCdma.basestationId;
3336 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3337 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3341 case RIL_CELL_INFO_TYPE_LTE: {
3342 cellIdentity.cellIdentityLte.resize(1);
3343 cellIdentity.cellIdentityLte[0].mcc =
3344 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3345 cellIdentity.cellIdentityLte[0].mnc =
3346 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3347 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3348 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3349 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3350 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3354 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3355 cellIdentity.cellIdentityTdscdma.resize(1);
3356 cellIdentity.cellIdentityTdscdma[0].mcc =
3357 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3358 cellIdentity.cellIdentityTdscdma[0].mnc =
3359 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3360 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3361 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3362 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3372 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3373 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3374 return atoi(response[index]);
3380 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3381 int numStrings, char** response) {
3383 RIL_CellIdentity_v16 rilCellIdentity;
3384 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3386 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3387 switch(rilCellIdentity.cellInfoType) {
3389 case RIL_CELL_INFO_TYPE_GSM: {
3390 rilCellIdentity.cellIdentityGsm.lac =
3391 convertResponseStringEntryToInt(response, 1, numStrings);
3392 rilCellIdentity.cellIdentityGsm.cid =
3393 convertResponseStringEntryToInt(response, 2, numStrings);
3397 case RIL_CELL_INFO_TYPE_WCDMA: {
3398 rilCellIdentity.cellIdentityWcdma.lac =
3399 convertResponseStringEntryToInt(response, 1, numStrings);
3400 rilCellIdentity.cellIdentityWcdma.cid =
3401 convertResponseStringEntryToInt(response, 2, numStrings);
3402 rilCellIdentity.cellIdentityWcdma.psc =
3403 convertResponseStringEntryToInt(response, 14, numStrings);
3407 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3408 rilCellIdentity.cellIdentityTdscdma.lac =
3409 convertResponseStringEntryToInt(response, 1, numStrings);
3410 rilCellIdentity.cellIdentityTdscdma.cid =
3411 convertResponseStringEntryToInt(response, 2, numStrings);
3415 case RIL_CELL_INFO_TYPE_CDMA:{
3416 rilCellIdentity.cellIdentityCdma.basestationId =
3417 convertResponseStringEntryToInt(response, 4, numStrings);
3418 rilCellIdentity.cellIdentityCdma.longitude =
3419 convertResponseStringEntryToInt(response, 5, numStrings);
3420 rilCellIdentity.cellIdentityCdma.latitude =
3421 convertResponseStringEntryToInt(response, 6, numStrings);
3422 rilCellIdentity.cellIdentityCdma.systemId =
3423 convertResponseStringEntryToInt(response, 8, numStrings);
3424 rilCellIdentity.cellIdentityCdma.networkId =
3425 convertResponseStringEntryToInt(response, 9, numStrings);
3429 case RIL_CELL_INFO_TYPE_LTE:{
3430 rilCellIdentity.cellIdentityLte.tac =
3431 convertResponseStringEntryToInt(response, 1, numStrings);
3432 rilCellIdentity.cellIdentityLte.ci =
3433 convertResponseStringEntryToInt(response, 2, numStrings);
3442 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3445 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3446 int numStrings, char** response) {
3448 RIL_CellIdentity_v16 rilCellIdentity;
3449 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3451 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3452 switch(rilCellIdentity.cellInfoType) {
3453 case RIL_CELL_INFO_TYPE_GSM: {
3454 rilCellIdentity.cellIdentityGsm.lac =
3455 convertResponseStringEntryToInt(response, 1, numStrings);
3456 rilCellIdentity.cellIdentityGsm.cid =
3457 convertResponseStringEntryToInt(response, 2, numStrings);
3460 case RIL_CELL_INFO_TYPE_WCDMA: {
3461 rilCellIdentity.cellIdentityWcdma.lac =
3462 convertResponseStringEntryToInt(response, 1, numStrings);
3463 rilCellIdentity.cellIdentityWcdma.cid =
3464 convertResponseStringEntryToInt(response, 2, numStrings);
3467 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3468 rilCellIdentity.cellIdentityTdscdma.lac =
3469 convertResponseStringEntryToInt(response, 1, numStrings);
3470 rilCellIdentity.cellIdentityTdscdma.cid =
3471 convertResponseStringEntryToInt(response, 2, numStrings);
3474 case RIL_CELL_INFO_TYPE_LTE: {
3475 rilCellIdentity.cellIdentityLte.tac =
3476 convertResponseStringEntryToInt(response, 6, numStrings);
3477 rilCellIdentity.cellIdentityLte.pci =
3478 convertResponseStringEntryToInt(response, 7, numStrings);
3479 rilCellIdentity.cellIdentityLte.ci =
3480 convertResponseStringEntryToInt(response, 8, numStrings);
3488 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3491 int radio::getVoiceRegistrationStateResponse(int slotId,
3492 int responseType, int serial, RIL_Errno e,
3493 void *response, size_t responseLen) {
3495 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3498 if (radioService[slotId]->mRadioResponse != NULL) {
3499 RadioResponseInfo responseInfo = {};
3500 populateResponseInfo(responseInfo, serial, responseType, e);
3502 VoiceRegStateResult voiceRegResponse = {};
3503 int numStrings = responseLen / sizeof(char *);
3504 if (response == NULL) {
3505 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3506 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3507 } else if (s_vendorFunctions->version <= 14) {
3508 if (numStrings != 15) {
3509 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3510 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3512 char **resp = (char **) response;
3513 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3514 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3515 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3516 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3517 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3518 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3519 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3520 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3524 RIL_VoiceRegistrationStateResponse *voiceRegState =
3525 (RIL_VoiceRegistrationStateResponse *)response;
3527 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3528 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3529 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3531 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3532 voiceRegResponse.rat = voiceRegState->rat;;
3533 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3534 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3535 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3536 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3537 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3538 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3539 voiceRegState->cellIdentity);
3543 Return<void> retStatus =
3544 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3545 responseInfo, voiceRegResponse);
3546 radioService[slotId]->checkReturnStatus(retStatus);
3548 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3555 int radio::getDataRegistrationStateResponse(int slotId,
3556 int responseType, int serial, RIL_Errno e,
3557 void *response, size_t responseLen) {
3559 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3562 if (radioService[slotId]->mRadioResponse != NULL) {
3563 RadioResponseInfo responseInfo = {};
3564 populateResponseInfo(responseInfo, serial, responseType, e);
3565 DataRegStateResult dataRegResponse = {};
3566 if (response == NULL) {
3567 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3568 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3569 } else if (s_vendorFunctions->version <= 14) {
3570 int numStrings = responseLen / sizeof(char *);
3571 if ((numStrings != 6) && (numStrings != 11)) {
3572 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3573 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3575 char **resp = (char **) response;
3576 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3577 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3578 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3579 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3580 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3584 RIL_DataRegistrationStateResponse *dataRegState =
3585 (RIL_DataRegistrationStateResponse *)response;
3587 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3588 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3589 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3591 dataRegResponse.regState = (RegState) dataRegState->regState;
3592 dataRegResponse.rat = dataRegState->rat;;
3593 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3594 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3595 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3599 Return<void> retStatus =
3600 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3602 radioService[slotId]->checkReturnStatus(retStatus);
3604 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3611 int radio::getOperatorResponse(int slotId,
3612 int responseType, int serial, RIL_Errno e, void *response,
3613 size_t responseLen) {
3615 RLOGD("getOperatorResponse: serial %d", serial);
3618 if (radioService[slotId]->mRadioResponse != NULL) {
3619 RadioResponseInfo responseInfo = {};
3620 populateResponseInfo(responseInfo, serial, responseType, e);
3621 hidl_string longName;
3622 hidl_string shortName;
3623 hidl_string numeric;
3624 int numStrings = responseLen / sizeof(char *);
3625 if (response == NULL || numStrings != 3) {
3626 RLOGE("getOperatorResponse Invalid response: NULL");
3627 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3630 char **resp = (char **) response;
3631 longName = convertCharPtrToHidlString(resp[0]);
3632 shortName = convertCharPtrToHidlString(resp[1]);
3633 numeric = convertCharPtrToHidlString(resp[2]);
3635 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3636 responseInfo, longName, shortName, numeric);
3637 radioService[slotId]->checkReturnStatus(retStatus);
3639 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3646 int radio::setRadioPowerResponse(int slotId,
3647 int responseType, int serial, RIL_Errno e, void *response,
3648 size_t responseLen) {
3649 RLOGD("setRadioPowerResponse: serial %d", serial);
3651 if (radioService[slotId]->mRadioResponse != NULL) {
3652 RadioResponseInfo responseInfo = {};
3653 populateResponseInfo(responseInfo, serial, responseType, e);
3654 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3656 radioService[slotId]->checkReturnStatus(retStatus);
3658 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3665 int radio::sendDtmfResponse(int slotId,
3666 int responseType, int serial, RIL_Errno e, void *response,
3667 size_t responseLen) {
3669 RLOGD("sendDtmfResponse: serial %d", serial);
3672 if (radioService[slotId]->mRadioResponse != NULL) {
3673 RadioResponseInfo responseInfo = {};
3674 populateResponseInfo(responseInfo, serial, responseType, e);
3675 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3677 radioService[slotId]->checkReturnStatus(retStatus);
3679 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3686 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3687 RIL_Errno e, void *response, size_t responseLen) {
3688 populateResponseInfo(responseInfo, serial, responseType, e);
3689 SendSmsResult result = {};
3691 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3692 RLOGE("Invalid response: NULL");
3693 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3694 result.ackPDU = hidl_string();
3696 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3697 result.messageRef = resp->messageRef;
3698 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3699 result.errorCode = resp->errorCode;
3704 int radio::sendSmsResponse(int slotId,
3705 int responseType, int serial, RIL_Errno e, void *response,
3706 size_t responseLen) {
3708 RLOGD("sendSmsResponse: serial %d", serial);
3711 if (radioService[slotId]->mRadioResponse != NULL) {
3712 RadioResponseInfo responseInfo = {};
3713 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3716 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3718 radioService[slotId]->checkReturnStatus(retStatus);
3720 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3726 int radio::sendSMSExpectMoreResponse(int slotId,
3727 int responseType, int serial, RIL_Errno e, void *response,
3728 size_t responseLen) {
3730 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3733 if (radioService[slotId]->mRadioResponse != NULL) {
3734 RadioResponseInfo responseInfo = {};
3735 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3738 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3739 responseInfo, result);
3740 radioService[slotId]->checkReturnStatus(retStatus);
3742 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3748 int radio::setupDataCallResponse(int slotId,
3749 int responseType, int serial, RIL_Errno e, void *response,
3750 size_t responseLen) {
3752 RLOGD("setupDataCallResponse: serial %d", serial);
3755 if (radioService[slotId]->mRadioResponse != NULL) {
3756 RadioResponseInfo responseInfo = {};
3757 populateResponseInfo(responseInfo, serial, responseType, e);
3759 SetupDataCallResult result = {};
3760 if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) {
3761 RLOGE("setupDataCallResponse: Invalid response");
3762 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3763 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3764 result.type = hidl_string();
3765 result.ifname = hidl_string();
3766 result.addresses = hidl_string();
3767 result.dnses = hidl_string();
3768 result.gateways = hidl_string();
3769 result.pcscf = hidl_string();
3771 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3774 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3775 responseInfo, result);
3776 radioService[slotId]->checkReturnStatus(retStatus);
3778 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3784 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3785 RIL_Errno e, void *response, size_t responseLen) {
3786 populateResponseInfo(responseInfo, serial, responseType, e);
3787 IccIoResult result = {};
3789 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3790 RLOGE("Invalid response: NULL");
3791 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3792 result.simResponse = hidl_string();
3794 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3795 result.sw1 = resp->sw1;
3796 result.sw2 = resp->sw2;
3797 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3802 int radio::iccIOForAppResponse(int slotId,
3803 int responseType, int serial, RIL_Errno e, void *response,
3804 size_t responseLen) {
3806 RLOGD("iccIOForAppResponse: serial %d", serial);
3809 if (radioService[slotId]->mRadioResponse != NULL) {
3810 RadioResponseInfo responseInfo = {};
3811 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3814 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3815 responseInfo, result);
3816 radioService[slotId]->checkReturnStatus(retStatus);
3818 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3824 int radio::sendUssdResponse(int slotId,
3825 int responseType, int serial, RIL_Errno e, void *response,
3826 size_t responseLen) {
3828 RLOGD("sendUssdResponse: serial %d", serial);
3831 if (radioService[slotId]->mRadioResponse != NULL) {
3832 RadioResponseInfo responseInfo = {};
3833 populateResponseInfo(responseInfo, serial, responseType, e);
3834 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3836 radioService[slotId]->checkReturnStatus(retStatus);
3838 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3845 int radio::cancelPendingUssdResponse(int slotId,
3846 int responseType, int serial, RIL_Errno e, void *response,
3847 size_t responseLen) {
3849 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3852 if (radioService[slotId]->mRadioResponse != NULL) {
3853 RadioResponseInfo responseInfo = {};
3854 populateResponseInfo(responseInfo, serial, responseType, e);
3855 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3857 radioService[slotId]->checkReturnStatus(retStatus);
3859 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3866 int radio::getClirResponse(int slotId,
3867 int responseType, int serial, RIL_Errno e, void *response,
3868 size_t responseLen) {
3870 RLOGD("getClirResponse: serial %d", serial);
3873 if (radioService[slotId]->mRadioResponse != NULL) {
3874 RadioResponseInfo responseInfo = {};
3875 populateResponseInfo(responseInfo, serial, responseType, e);
3877 int numInts = responseLen / sizeof(int);
3878 if (response == NULL || numInts != 2) {
3879 RLOGE("getClirResponse Invalid response: NULL");
3880 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3882 int *pInt = (int *) response;
3886 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3888 radioService[slotId]->checkReturnStatus(retStatus);
3890 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3896 int radio::setClirResponse(int slotId,
3897 int responseType, int serial, RIL_Errno e, void *response,
3898 size_t responseLen) {
3900 RLOGD("setClirResponse: serial %d", serial);
3903 if (radioService[slotId]->mRadioResponse != NULL) {
3904 RadioResponseInfo responseInfo = {};
3905 populateResponseInfo(responseInfo, serial, responseType, e);
3906 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
3908 radioService[slotId]->checkReturnStatus(retStatus);
3910 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3916 int radio::getCallForwardStatusResponse(int slotId,
3917 int responseType, int serial, RIL_Errno e,
3918 void *response, size_t responseLen) {
3920 RLOGD("getCallForwardStatusResponse: serial %d", serial);
3923 if (radioService[slotId]->mRadioResponse != NULL) {
3924 RadioResponseInfo responseInfo = {};
3925 populateResponseInfo(responseInfo, serial, responseType, e);
3926 hidl_vec<CallForwardInfo> callForwardInfos;
3928 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
3929 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
3930 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3932 int num = responseLen / sizeof(RIL_CallForwardInfo *);
3933 callForwardInfos.resize(num);
3934 for (int i = 0 ; i < num; i++) {
3935 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
3936 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
3937 callForwardInfos[i].reason = resp->reason;
3938 callForwardInfos[i].serviceClass = resp->serviceClass;
3939 callForwardInfos[i].toa = resp->toa;
3940 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
3941 callForwardInfos[i].timeSeconds = resp->timeSeconds;
3945 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
3946 responseInfo, callForwardInfos);
3947 radioService[slotId]->checkReturnStatus(retStatus);
3949 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
3956 int radio::setCallForwardResponse(int slotId,
3957 int responseType, int serial, RIL_Errno e, void *response,
3958 size_t responseLen) {
3960 RLOGD("setCallForwardResponse: serial %d", serial);
3963 if (radioService[slotId]->mRadioResponse != NULL) {
3964 RadioResponseInfo responseInfo = {};
3965 populateResponseInfo(responseInfo, serial, responseType, e);
3966 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
3968 radioService[slotId]->checkReturnStatus(retStatus);
3970 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3976 int radio::getCallWaitingResponse(int slotId,
3977 int responseType, int serial, RIL_Errno e, void *response,
3978 size_t responseLen) {
3980 RLOGD("getCallWaitingResponse: serial %d", serial);
3983 if (radioService[slotId]->mRadioResponse != NULL) {
3984 RadioResponseInfo responseInfo = {};
3985 populateResponseInfo(responseInfo, serial, responseType, e);
3986 bool enable = false;
3987 int serviceClass = -1;
3988 int numInts = responseLen / sizeof(int);
3989 if (response == NULL || numInts != 2) {
3990 RLOGE("getCallWaitingResponse Invalid response: NULL");
3991 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3993 int *pInt = (int *) response;
3994 enable = pInt[0] == 1 ? true : false;
3995 serviceClass = pInt[1];
3997 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
3998 responseInfo, enable, serviceClass);
3999 radioService[slotId]->checkReturnStatus(retStatus);
4001 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4007 int radio::setCallWaitingResponse(int slotId,
4008 int responseType, int serial, RIL_Errno e, void *response,
4009 size_t responseLen) {
4011 RLOGD("setCallWaitingResponse: serial %d", serial);
4014 if (radioService[slotId]->mRadioResponse != NULL) {
4015 RadioResponseInfo responseInfo = {};
4016 populateResponseInfo(responseInfo, serial, responseType, e);
4017 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4019 radioService[slotId]->checkReturnStatus(retStatus);
4021 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4027 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4028 int responseType, int serial, RIL_Errno e,
4029 void *response, size_t responseLen) {
4031 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4034 if (radioService[slotId]->mRadioResponse != NULL) {
4035 RadioResponseInfo responseInfo = {};
4036 populateResponseInfo(responseInfo, serial, responseType, e);
4037 Return<void> retStatus =
4038 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4040 radioService[slotId]->checkReturnStatus(retStatus);
4042 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4049 int radio::acceptCallResponse(int slotId,
4050 int responseType, int serial, RIL_Errno e,
4051 void *response, size_t responseLen) {
4053 RLOGD("acceptCallResponse: serial %d", serial);
4056 if (radioService[slotId]->mRadioResponse != NULL) {
4057 RadioResponseInfo responseInfo = {};
4058 populateResponseInfo(responseInfo, serial, responseType, e);
4059 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4061 radioService[slotId]->checkReturnStatus(retStatus);
4063 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4070 int radio::deactivateDataCallResponse(int slotId,
4071 int responseType, int serial, RIL_Errno e,
4072 void *response, size_t responseLen) {
4074 RLOGD("deactivateDataCallResponse: serial %d", serial);
4077 if (radioService[slotId]->mRadioResponse != NULL) {
4078 RadioResponseInfo responseInfo = {};
4079 populateResponseInfo(responseInfo, serial, responseType, e);
4080 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4082 radioService[slotId]->checkReturnStatus(retStatus);
4084 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4091 int radio::getFacilityLockForAppResponse(int slotId,
4092 int responseType, int serial, RIL_Errno e,
4093 void *response, size_t responseLen) {
4095 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4098 if (radioService[slotId]->mRadioResponse != NULL) {
4099 RadioResponseInfo responseInfo = {};
4100 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4101 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4102 getFacilityLockForAppResponse(responseInfo, ret);
4103 radioService[slotId]->checkReturnStatus(retStatus);
4105 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4112 int radio::setFacilityLockForAppResponse(int slotId,
4113 int responseType, int serial, RIL_Errno e,
4114 void *response, size_t responseLen) {
4116 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4119 if (radioService[slotId]->mRadioResponse != NULL) {
4120 RadioResponseInfo responseInfo = {};
4121 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4122 Return<void> retStatus
4123 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4125 radioService[slotId]->checkReturnStatus(retStatus);
4127 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4134 int radio::setBarringPasswordResponse(int slotId,
4135 int responseType, int serial, RIL_Errno e,
4136 void *response, size_t responseLen) {
4138 RLOGD("acceptCallResponse: serial %d", serial);
4141 if (radioService[slotId]->mRadioResponse != NULL) {
4142 RadioResponseInfo responseInfo = {};
4143 populateResponseInfo(responseInfo, serial, responseType, e);
4144 Return<void> retStatus
4145 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4146 radioService[slotId]->checkReturnStatus(retStatus);
4148 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4155 int radio::getNetworkSelectionModeResponse(int slotId,
4156 int responseType, int serial, RIL_Errno e, void *response,
4157 size_t responseLen) {
4159 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4162 if (radioService[slotId]->mRadioResponse != NULL) {
4163 RadioResponseInfo responseInfo = {};
4164 populateResponseInfo(responseInfo, serial, responseType, e);
4165 bool manual = false;
4167 if (response == NULL || responseLen != sizeof(int)) {
4168 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4169 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4171 int *pInt = (int *) response;
4172 manual = pInt[0] == 1 ? true : false;
4174 Return<void> retStatus
4175 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4178 radioService[slotId]->checkReturnStatus(retStatus);
4180 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4187 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4188 RIL_Errno e, void *response,
4189 size_t responseLen) {
4191 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4194 if (radioService[slotId]->mRadioResponse != NULL) {
4195 RadioResponseInfo responseInfo = {};
4196 populateResponseInfo(responseInfo, serial, responseType, e);
4197 Return<void> retStatus
4198 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4200 radioService[slotId]->checkReturnStatus(retStatus);
4202 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4209 int radio::setNetworkSelectionModeManualResponse(int slotId,
4210 int responseType, int serial, RIL_Errno e,
4211 void *response, size_t responseLen) {
4213 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4216 if (radioService[slotId]->mRadioResponse != NULL) {
4217 RadioResponseInfo responseInfo = {};
4218 populateResponseInfo(responseInfo, serial, responseType, e);
4219 Return<void> retStatus
4220 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4222 radioService[slotId]->checkReturnStatus(retStatus);
4224 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4231 int convertOperatorStatusToInt(const char *str) {
4232 if (strncmp("unknown", str, 9) == 0) {
4233 return (int) OperatorStatus::UNKNOWN;
4234 } else if (strncmp("available", str, 9) == 0) {
4235 return (int) OperatorStatus::AVAILABLE;
4236 } else if (strncmp("current", str, 9) == 0) {
4237 return (int) OperatorStatus::CURRENT;
4238 } else if (strncmp("forbidden", str, 9) == 0) {
4239 return (int) OperatorStatus::FORBIDDEN;
4245 int radio::getAvailableNetworksResponse(int slotId,
4246 int responseType, int serial, RIL_Errno e, void *response,
4247 size_t responseLen) {
4249 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4252 if (radioService[slotId]->mRadioResponse != NULL) {
4253 RadioResponseInfo responseInfo = {};
4254 populateResponseInfo(responseInfo, serial, responseType, e);
4255 hidl_vec<OperatorInfo> networks;
4256 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) {
4257 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4258 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4260 char **resp = (char **) response;
4261 int numStrings = responseLen / sizeof(char *);
4262 networks.resize(numStrings/4);
4263 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4264 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4265 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4266 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4267 int status = convertOperatorStatusToInt(resp[i + 3]);
4269 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4271 networks[j].status = (OperatorStatus) status;
4275 Return<void> retStatus
4276 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4278 radioService[slotId]->checkReturnStatus(retStatus);
4280 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4287 int radio::startDtmfResponse(int slotId,
4288 int responseType, int serial, RIL_Errno e,
4289 void *response, size_t responseLen) {
4291 RLOGD("startDtmfResponse: serial %d", serial);
4294 if (radioService[slotId]->mRadioResponse != NULL) {
4295 RadioResponseInfo responseInfo = {};
4296 populateResponseInfo(responseInfo, serial, responseType, e);
4297 Return<void> retStatus
4298 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4299 radioService[slotId]->checkReturnStatus(retStatus);
4301 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4307 int radio::stopDtmfResponse(int slotId,
4308 int responseType, int serial, RIL_Errno e,
4309 void *response, size_t responseLen) {
4311 RLOGD("stopDtmfResponse: serial %d", serial);
4314 if (radioService[slotId]->mRadioResponse != NULL) {
4315 RadioResponseInfo responseInfo = {};
4316 populateResponseInfo(responseInfo, serial, responseType, e);
4317 Return<void> retStatus
4318 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4319 radioService[slotId]->checkReturnStatus(retStatus);
4321 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4327 int radio::getBasebandVersionResponse(int slotId,
4328 int responseType, int serial, RIL_Errno e,
4329 void *response, size_t responseLen) {
4331 RLOGD("getBasebandVersionResponse: serial %d", serial);
4334 if (radioService[slotId]->mRadioResponse != NULL) {
4335 RadioResponseInfo responseInfo = {};
4336 populateResponseInfo(responseInfo, serial, responseType, e);
4337 Return<void> retStatus
4338 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4339 convertCharPtrToHidlString((char *) response));
4340 radioService[slotId]->checkReturnStatus(retStatus);
4342 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4348 int radio::separateConnectionResponse(int slotId,
4349 int responseType, int serial, RIL_Errno e,
4350 void *response, size_t responseLen) {
4352 RLOGD("separateConnectionResponse: serial %d", serial);
4355 if (radioService[slotId]->mRadioResponse != NULL) {
4356 RadioResponseInfo responseInfo = {};
4357 populateResponseInfo(responseInfo, serial, responseType, e);
4358 Return<void> retStatus
4359 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4360 radioService[slotId]->checkReturnStatus(retStatus);
4362 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4369 int radio::setMuteResponse(int slotId,
4370 int responseType, int serial, RIL_Errno e,
4371 void *response, size_t responseLen) {
4373 RLOGD("setMuteResponse: serial %d", serial);
4376 if (radioService[slotId]->mRadioResponse != NULL) {
4377 RadioResponseInfo responseInfo = {};
4378 populateResponseInfo(responseInfo, serial, responseType, e);
4379 Return<void> retStatus
4380 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4381 radioService[slotId]->checkReturnStatus(retStatus);
4383 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4389 int radio::getMuteResponse(int slotId,
4390 int responseType, int serial, RIL_Errno e, void *response,
4391 size_t responseLen) {
4393 RLOGD("getMuteResponse: serial %d", serial);
4396 if (radioService[slotId]->mRadioResponse != NULL) {
4397 RadioResponseInfo responseInfo = {};
4398 populateResponseInfo(responseInfo, serial, responseType, e);
4399 bool enable = false;
4401 if (response == NULL || responseLen != sizeof(int)) {
4402 RLOGE("getMuteResponse Invalid response: NULL");
4403 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4405 int *pInt = (int *) response;
4406 enable = pInt[0] == 1 ? true : false;
4408 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4410 radioService[slotId]->checkReturnStatus(retStatus);
4412 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4418 int radio::getClipResponse(int slotId,
4419 int responseType, int serial, RIL_Errno e,
4420 void *response, size_t responseLen) {
4422 RLOGD("getClipResponse: serial %d", serial);
4425 if (radioService[slotId]->mRadioResponse != NULL) {
4426 RadioResponseInfo responseInfo = {};
4427 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4428 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4430 radioService[slotId]->checkReturnStatus(retStatus);
4432 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4438 int radio::getDataCallListResponse(int slotId,
4439 int responseType, int serial, RIL_Errno e,
4440 void *response, size_t responseLen) {
4442 RLOGD("getDataCallListResponse: serial %d", serial);
4445 if (radioService[slotId]->mRadioResponse != NULL) {
4446 RadioResponseInfo responseInfo = {};
4447 populateResponseInfo(responseInfo, serial, responseType, e);
4449 hidl_vec<SetupDataCallResult> ret;
4450 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4451 RLOGE("getDataCallListResponse: invalid response");
4452 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4454 convertRilDataCallListToHal(response, responseLen, ret);
4457 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4459 radioService[slotId]->checkReturnStatus(retStatus);
4461 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4467 int radio::setSuppServiceNotificationsResponse(int slotId,
4468 int responseType, int serial, RIL_Errno e,
4469 void *response, size_t responseLen) {
4471 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4474 if (radioService[slotId]->mRadioResponse != NULL) {
4475 RadioResponseInfo responseInfo = {};
4476 populateResponseInfo(responseInfo, serial, responseType, e);
4477 Return<void> retStatus
4478 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4480 radioService[slotId]->checkReturnStatus(retStatus);
4482 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4489 int radio::deleteSmsOnSimResponse(int slotId,
4490 int responseType, int serial, RIL_Errno e,
4491 void *response, size_t responseLen) {
4493 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4496 if (radioService[slotId]->mRadioResponse != NULL) {
4497 RadioResponseInfo responseInfo = {};
4498 populateResponseInfo(responseInfo, serial, responseType, e);
4499 Return<void> retStatus
4500 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4501 radioService[slotId]->checkReturnStatus(retStatus);
4503 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4509 int radio::setBandModeResponse(int slotId,
4510 int responseType, int serial, RIL_Errno e,
4511 void *response, size_t responseLen) {
4513 RLOGD("setBandModeResponse: serial %d", serial);
4516 if (radioService[slotId]->mRadioResponse != NULL) {
4517 RadioResponseInfo responseInfo = {};
4518 populateResponseInfo(responseInfo, serial, responseType, e);
4519 Return<void> retStatus
4520 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4521 radioService[slotId]->checkReturnStatus(retStatus);
4523 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4529 int radio::writeSmsToSimResponse(int slotId,
4530 int responseType, int serial, RIL_Errno e,
4531 void *response, size_t responseLen) {
4533 RLOGD("writeSmsToSimResponse: serial %d", serial);
4536 if (radioService[slotId]->mRadioResponse != NULL) {
4537 RadioResponseInfo responseInfo = {};
4538 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4539 Return<void> retStatus
4540 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4541 radioService[slotId]->checkReturnStatus(retStatus);
4543 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4549 int radio::getAvailableBandModesResponse(int slotId,
4550 int responseType, int serial, RIL_Errno e, void *response,
4551 size_t responseLen) {
4553 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4556 if (radioService[slotId]->mRadioResponse != NULL) {
4557 RadioResponseInfo responseInfo = {};
4558 populateResponseInfo(responseInfo, serial, responseType, e);
4559 hidl_vec<RadioBandMode> modes;
4560 if (response == NULL || responseLen % sizeof(int) != 0) {
4561 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4562 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4564 int *pInt = (int *) response;
4565 int numInts = responseLen / sizeof(int);
4566 modes.resize(numInts);
4567 for (int i = 0; i < numInts; i++) {
4568 modes[i] = (RadioBandMode) pInt[i];
4571 Return<void> retStatus
4572 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4574 radioService[slotId]->checkReturnStatus(retStatus);
4576 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4583 int radio::sendEnvelopeResponse(int slotId,
4584 int responseType, int serial, RIL_Errno e,
4585 void *response, size_t responseLen) {
4587 RLOGD("sendEnvelopeResponse: serial %d", serial);
4590 if (radioService[slotId]->mRadioResponse != NULL) {
4591 RadioResponseInfo responseInfo = {};
4592 populateResponseInfo(responseInfo, serial, responseType, e);
4593 Return<void> retStatus
4594 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4595 convertCharPtrToHidlString((char *) response));
4596 radioService[slotId]->checkReturnStatus(retStatus);
4598 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4604 int radio::sendTerminalResponseToSimResponse(int slotId,
4605 int responseType, int serial, RIL_Errno e,
4606 void *response, size_t responseLen) {
4608 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4611 if (radioService[slotId]->mRadioResponse != NULL) {
4612 RadioResponseInfo responseInfo = {};
4613 populateResponseInfo(responseInfo, serial, responseType, e);
4614 Return<void> retStatus
4615 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4617 radioService[slotId]->checkReturnStatus(retStatus);
4619 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4626 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4627 int responseType, int serial,
4628 RIL_Errno e, void *response,
4629 size_t responseLen) {
4631 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4634 if (radioService[slotId]->mRadioResponse != NULL) {
4635 RadioResponseInfo responseInfo = {};
4636 populateResponseInfo(responseInfo, serial, responseType, e);
4637 Return<void> retStatus
4638 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4640 radioService[slotId]->checkReturnStatus(retStatus);
4642 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4649 int radio::explicitCallTransferResponse(int slotId,
4650 int responseType, int serial, RIL_Errno e,
4651 void *response, size_t responseLen) {
4653 RLOGD("explicitCallTransferResponse: serial %d", serial);
4656 if (radioService[slotId]->mRadioResponse != NULL) {
4657 RadioResponseInfo responseInfo = {};
4658 populateResponseInfo(responseInfo, serial, responseType, e);
4659 Return<void> retStatus
4660 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4661 radioService[slotId]->checkReturnStatus(retStatus);
4663 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4670 int radio::setPreferredNetworkTypeResponse(int slotId,
4671 int responseType, int serial, RIL_Errno e,
4672 void *response, size_t responseLen) {
4674 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4677 if (radioService[slotId]->mRadioResponse != NULL) {
4678 RadioResponseInfo responseInfo = {};
4679 populateResponseInfo(responseInfo, serial, responseType, e);
4680 Return<void> retStatus
4681 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4683 radioService[slotId]->checkReturnStatus(retStatus);
4685 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4693 int radio::getPreferredNetworkTypeResponse(int slotId,
4694 int responseType, int serial, RIL_Errno e,
4695 void *response, size_t responseLen) {
4697 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4700 if (radioService[slotId]->mRadioResponse != NULL) {
4701 RadioResponseInfo responseInfo = {};
4702 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4703 Return<void> retStatus
4704 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4705 responseInfo, (PreferredNetworkType) ret);
4706 radioService[slotId]->checkReturnStatus(retStatus);
4708 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4715 int radio::getNeighboringCidsResponse(int slotId,
4716 int responseType, int serial, RIL_Errno e,
4717 void *response, size_t responseLen) {
4719 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4722 if (radioService[slotId]->mRadioResponse != NULL) {
4723 RadioResponseInfo responseInfo = {};
4724 populateResponseInfo(responseInfo, serial, responseType, e);
4725 hidl_vec<NeighboringCell> cells;
4727 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4728 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4729 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4731 int num = responseLen / sizeof(RIL_NeighboringCell *);
4733 for (int i = 0 ; i < num; i++) {
4734 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4735 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4736 cells[i].rssi = resp->rssi;
4740 Return<void> retStatus
4741 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4743 radioService[slotId]->checkReturnStatus(retStatus);
4745 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4752 int radio::setLocationUpdatesResponse(int slotId,
4753 int responseType, int serial, RIL_Errno e,
4754 void *response, size_t responseLen) {
4756 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4759 if (radioService[slotId]->mRadioResponse != NULL) {
4760 RadioResponseInfo responseInfo = {};
4761 populateResponseInfo(responseInfo, serial, responseType, e);
4762 Return<void> retStatus
4763 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4764 radioService[slotId]->checkReturnStatus(retStatus);
4766 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4773 int radio::setCdmaSubscriptionSourceResponse(int slotId,
4774 int responseType, int serial, RIL_Errno e,
4775 void *response, size_t responseLen) {
4777 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4780 if (radioService[slotId]->mRadioResponse != NULL) {
4781 RadioResponseInfo responseInfo = {};
4782 populateResponseInfo(responseInfo, serial, responseType, e);
4783 Return<void> retStatus
4784 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4786 radioService[slotId]->checkReturnStatus(retStatus);
4788 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4795 int radio::setCdmaRoamingPreferenceResponse(int slotId,
4796 int responseType, int serial, RIL_Errno e,
4797 void *response, size_t responseLen) {
4799 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4802 if (radioService[slotId]->mRadioResponse != NULL) {
4803 RadioResponseInfo responseInfo = {};
4804 populateResponseInfo(responseInfo, serial, responseType, e);
4805 Return<void> retStatus
4806 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4808 radioService[slotId]->checkReturnStatus(retStatus);
4810 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4817 int radio::getCdmaRoamingPreferenceResponse(int slotId,
4818 int responseType, int serial, RIL_Errno e,
4819 void *response, size_t responseLen) {
4821 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4824 if (radioService[slotId]->mRadioResponse != NULL) {
4825 RadioResponseInfo responseInfo = {};
4826 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4827 Return<void> retStatus
4828 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4829 responseInfo, (CdmaRoamingType) ret);
4830 radioService[slotId]->checkReturnStatus(retStatus);
4832 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4839 int radio::setTTYModeResponse(int slotId,
4840 int responseType, int serial, RIL_Errno e,
4841 void *response, size_t responseLen) {
4843 RLOGD("setTTYModeResponse: serial %d", serial);
4846 if (radioService[slotId]->mRadioResponse != NULL) {
4847 RadioResponseInfo responseInfo = {};
4848 populateResponseInfo(responseInfo, serial, responseType, e);
4849 Return<void> retStatus
4850 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4851 radioService[slotId]->checkReturnStatus(retStatus);
4853 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4859 int radio::getTTYModeResponse(int slotId,
4860 int responseType, int serial, RIL_Errno e,
4861 void *response, size_t responseLen) {
4863 RLOGD("getTTYModeResponse: serial %d", serial);
4866 if (radioService[slotId]->mRadioResponse != NULL) {
4867 RadioResponseInfo responseInfo = {};
4868 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4869 Return<void> retStatus
4870 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4872 radioService[slotId]->checkReturnStatus(retStatus);
4874 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4880 int radio::setPreferredVoicePrivacyResponse(int slotId,
4881 int responseType, int serial, RIL_Errno e,
4882 void *response, size_t responseLen) {
4884 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
4887 if (radioService[slotId]->mRadioResponse != NULL) {
4888 RadioResponseInfo responseInfo = {};
4889 populateResponseInfo(responseInfo, serial, responseType, e);
4890 Return<void> retStatus
4891 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4893 radioService[slotId]->checkReturnStatus(retStatus);
4895 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4902 int radio::getPreferredVoicePrivacyResponse(int slotId,
4903 int responseType, int serial, RIL_Errno e,
4904 void *response, size_t responseLen) {
4906 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
4909 if (radioService[slotId]->mRadioResponse != NULL) {
4910 RadioResponseInfo responseInfo = {};
4911 populateResponseInfo(responseInfo, serial, responseType, e);
4912 bool enable = false;
4913 int numInts = responseLen / sizeof(int);
4914 if (response == NULL || numInts != 1) {
4915 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
4916 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4918 int *pInt = (int *) response;
4919 enable = pInt[0] == 1 ? true : false;
4921 Return<void> retStatus
4922 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
4923 responseInfo, enable);
4924 radioService[slotId]->checkReturnStatus(retStatus);
4926 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4933 int radio::sendCDMAFeatureCodeResponse(int slotId,
4934 int responseType, int serial, RIL_Errno e,
4935 void *response, size_t responseLen) {
4937 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
4940 if (radioService[slotId]->mRadioResponse != NULL) {
4941 RadioResponseInfo responseInfo = {};
4942 populateResponseInfo(responseInfo, serial, responseType, e);
4943 Return<void> retStatus
4944 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
4945 radioService[slotId]->checkReturnStatus(retStatus);
4947 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
4954 int radio::sendBurstDtmfResponse(int slotId,
4955 int responseType, int serial, RIL_Errno e,
4956 void *response, size_t responseLen) {
4958 RLOGD("sendBurstDtmfResponse: serial %d", serial);
4961 if (radioService[slotId]->mRadioResponse != NULL) {
4962 RadioResponseInfo responseInfo = {};
4963 populateResponseInfo(responseInfo, serial, responseType, e);
4964 Return<void> retStatus
4965 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
4966 radioService[slotId]->checkReturnStatus(retStatus);
4968 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4974 int radio::sendCdmaSmsResponse(int slotId,
4975 int responseType, int serial, RIL_Errno e, void *response,
4976 size_t responseLen) {
4978 RLOGD("sendCdmaSmsResponse: serial %d", serial);
4981 if (radioService[slotId]->mRadioResponse != NULL) {
4982 RadioResponseInfo responseInfo = {};
4983 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4986 Return<void> retStatus
4987 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
4988 radioService[slotId]->checkReturnStatus(retStatus);
4990 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4996 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
4997 int responseType, int serial, RIL_Errno e,
4998 void *response, size_t responseLen) {
5000 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5003 if (radioService[slotId]->mRadioResponse != NULL) {
5004 RadioResponseInfo responseInfo = {};
5005 populateResponseInfo(responseInfo, serial, responseType, e);
5006 Return<void> retStatus
5007 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5009 radioService[slotId]->checkReturnStatus(retStatus);
5011 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5018 int radio::getGsmBroadcastConfigResponse(int slotId,
5019 int responseType, int serial, RIL_Errno e,
5020 void *response, size_t responseLen) {
5022 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5025 if (radioService[slotId]->mRadioResponse != NULL) {
5026 RadioResponseInfo responseInfo = {};
5027 populateResponseInfo(responseInfo, serial, responseType, e);
5028 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5030 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5031 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5032 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5034 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5035 configs.resize(num);
5036 for (int i = 0 ; i < num; i++) {
5037 RIL_GSM_BroadcastSmsConfigInfo *resp =
5038 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5039 configs[i].fromServiceId = resp->fromServiceId;
5040 configs[i].toServiceId = resp->toServiceId;
5041 configs[i].fromCodeScheme = resp->fromCodeScheme;
5042 configs[i].toCodeScheme = resp->toCodeScheme;
5043 configs[i].selected = resp->selected == 1 ? true : false;
5047 Return<void> retStatus
5048 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5050 radioService[slotId]->checkReturnStatus(retStatus);
5052 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5059 int radio::setGsmBroadcastConfigResponse(int slotId,
5060 int responseType, int serial, RIL_Errno e,
5061 void *response, size_t responseLen) {
5063 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5066 if (radioService[slotId]->mRadioResponse != NULL) {
5067 RadioResponseInfo responseInfo = {};
5068 populateResponseInfo(responseInfo, serial, responseType, e);
5069 Return<void> retStatus
5070 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5071 radioService[slotId]->checkReturnStatus(retStatus);
5073 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5080 int radio::setGsmBroadcastActivationResponse(int slotId,
5081 int responseType, int serial, RIL_Errno e,
5082 void *response, size_t responseLen) {
5084 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5087 if (radioService[slotId]->mRadioResponse != NULL) {
5088 RadioResponseInfo responseInfo = {};
5089 populateResponseInfo(responseInfo, serial, responseType, e);
5090 Return<void> retStatus
5091 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5093 radioService[slotId]->checkReturnStatus(retStatus);
5095 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5102 int radio::getCdmaBroadcastConfigResponse(int slotId,
5103 int responseType, int serial, RIL_Errno e,
5104 void *response, size_t responseLen) {
5106 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5109 if (radioService[slotId]->mRadioResponse != NULL) {
5110 RadioResponseInfo responseInfo = {};
5111 populateResponseInfo(responseInfo, serial, responseType, e);
5112 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5114 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5115 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5116 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5118 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5119 configs.resize(num);
5120 for (int i = 0 ; i < num; i++) {
5121 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5122 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5123 configs[i].serviceCategory = resp->service_category;
5124 configs[i].language = resp->language;
5125 configs[i].selected = resp->selected == 1 ? true : false;
5129 Return<void> retStatus
5130 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5132 radioService[slotId]->checkReturnStatus(retStatus);
5134 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5141 int radio::setCdmaBroadcastConfigResponse(int slotId,
5142 int responseType, int serial, RIL_Errno e,
5143 void *response, size_t responseLen) {
5145 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5148 if (radioService[slotId]->mRadioResponse != NULL) {
5149 RadioResponseInfo responseInfo = {};
5150 populateResponseInfo(responseInfo, serial, responseType, e);
5151 Return<void> retStatus
5152 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5154 radioService[slotId]->checkReturnStatus(retStatus);
5156 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5163 int radio::setCdmaBroadcastActivationResponse(int slotId,
5164 int responseType, int serial, RIL_Errno e,
5165 void *response, size_t responseLen) {
5167 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5170 if (radioService[slotId]->mRadioResponse != NULL) {
5171 RadioResponseInfo responseInfo = {};
5172 populateResponseInfo(responseInfo, serial, responseType, e);
5173 Return<void> retStatus
5174 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5176 radioService[slotId]->checkReturnStatus(retStatus);
5178 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5185 int radio::getCDMASubscriptionResponse(int slotId,
5186 int responseType, int serial, RIL_Errno e, void *response,
5187 size_t responseLen) {
5189 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5192 if (radioService[slotId]->mRadioResponse != NULL) {
5193 RadioResponseInfo responseInfo = {};
5194 populateResponseInfo(responseInfo, serial, responseType, e);
5196 int numStrings = responseLen / sizeof(char *);
5197 hidl_string emptyString;
5198 if (response == NULL || numStrings != 5) {
5199 RLOGE("getOperatorResponse Invalid response: NULL");
5200 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5201 Return<void> retStatus
5202 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5203 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5204 radioService[slotId]->checkReturnStatus(retStatus);
5206 char **resp = (char **) response;
5207 Return<void> retStatus
5208 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5210 convertCharPtrToHidlString(resp[0]),
5211 convertCharPtrToHidlString(resp[1]),
5212 convertCharPtrToHidlString(resp[2]),
5213 convertCharPtrToHidlString(resp[3]),
5214 convertCharPtrToHidlString(resp[4]));
5215 radioService[slotId]->checkReturnStatus(retStatus);
5218 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5225 int radio::writeSmsToRuimResponse(int slotId,
5226 int responseType, int serial, RIL_Errno e,
5227 void *response, size_t responseLen) {
5229 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5232 if (radioService[slotId]->mRadioResponse != NULL) {
5233 RadioResponseInfo responseInfo = {};
5234 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5235 Return<void> retStatus
5236 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5237 radioService[slotId]->checkReturnStatus(retStatus);
5239 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5245 int radio::deleteSmsOnRuimResponse(int slotId,
5246 int responseType, int serial, RIL_Errno e,
5247 void *response, size_t responseLen) {
5249 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5252 if (radioService[slotId]->mRadioResponse != NULL) {
5253 RadioResponseInfo responseInfo = {};
5254 populateResponseInfo(responseInfo, serial, responseType, e);
5255 Return<void> retStatus
5256 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5257 radioService[slotId]->checkReturnStatus(retStatus);
5259 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5265 int radio::getDeviceIdentityResponse(int slotId,
5266 int responseType, int serial, RIL_Errno e, void *response,
5267 size_t responseLen) {
5269 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5272 if (radioService[slotId]->mRadioResponse != NULL) {
5273 RadioResponseInfo responseInfo = {};
5274 populateResponseInfo(responseInfo, serial, responseType, e);
5276 int numStrings = responseLen / sizeof(char *);
5277 hidl_string emptyString;
5278 if (response == NULL || numStrings != 4) {
5279 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5280 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5281 Return<void> retStatus
5282 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5283 emptyString, emptyString, emptyString, emptyString);
5284 radioService[slotId]->checkReturnStatus(retStatus);
5286 char **resp = (char **) response;
5287 Return<void> retStatus
5288 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5289 convertCharPtrToHidlString(resp[0]),
5290 convertCharPtrToHidlString(resp[1]),
5291 convertCharPtrToHidlString(resp[2]),
5292 convertCharPtrToHidlString(resp[3]));
5293 radioService[slotId]->checkReturnStatus(retStatus);
5296 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5303 int radio::exitEmergencyCallbackModeResponse(int slotId,
5304 int responseType, int serial, RIL_Errno e,
5305 void *response, size_t responseLen) {
5307 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5310 if (radioService[slotId]->mRadioResponse != NULL) {
5311 RadioResponseInfo responseInfo = {};
5312 populateResponseInfo(responseInfo, serial, responseType, e);
5313 Return<void> retStatus
5314 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5316 radioService[slotId]->checkReturnStatus(retStatus);
5318 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5325 int radio::getSmscAddressResponse(int slotId,
5326 int responseType, int serial, RIL_Errno e,
5327 void *response, size_t responseLen) {
5329 RLOGD("getSmscAddressResponse: serial %d", serial);
5332 if (radioService[slotId]->mRadioResponse != NULL) {
5333 RadioResponseInfo responseInfo = {};
5334 populateResponseInfo(responseInfo, serial, responseType, e);
5335 Return<void> retStatus
5336 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5337 convertCharPtrToHidlString((char *) response));
5338 radioService[slotId]->checkReturnStatus(retStatus);
5340 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5346 int radio::setSmscAddressResponse(int slotId,
5347 int responseType, int serial, RIL_Errno e,
5348 void *response, size_t responseLen) {
5350 RLOGD("setSmscAddressResponse: serial %d", serial);
5353 if (radioService[slotId]->mRadioResponse != NULL) {
5354 RadioResponseInfo responseInfo = {};
5355 populateResponseInfo(responseInfo, serial, responseType, e);
5356 Return<void> retStatus
5357 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5358 radioService[slotId]->checkReturnStatus(retStatus);
5360 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5366 int radio::reportSmsMemoryStatusResponse(int slotId,
5367 int responseType, int serial, RIL_Errno e,
5368 void *response, size_t responseLen) {
5370 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5373 if (radioService[slotId]->mRadioResponse != NULL) {
5374 RadioResponseInfo responseInfo = {};
5375 populateResponseInfo(responseInfo, serial, responseType, e);
5376 Return<void> retStatus
5377 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5378 radioService[slotId]->checkReturnStatus(retStatus);
5380 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5387 int radio::reportStkServiceIsRunningResponse(int slotId,
5388 int responseType, int serial, RIL_Errno e,
5389 void *response, size_t responseLen) {
5391 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5394 if (radioService[slotId]->mRadioResponse != NULL) {
5395 RadioResponseInfo responseInfo = {};
5396 populateResponseInfo(responseInfo, serial, responseType, e);
5397 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5398 reportStkServiceIsRunningResponse(responseInfo);
5399 radioService[slotId]->checkReturnStatus(retStatus);
5401 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5408 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5409 int responseType, int serial, RIL_Errno e,
5410 void *response, size_t responseLen) {
5412 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5415 if (radioService[slotId]->mRadioResponse != NULL) {
5416 RadioResponseInfo responseInfo = {};
5417 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5418 Return<void> retStatus
5419 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5420 responseInfo, (CdmaSubscriptionSource) ret);
5421 radioService[slotId]->checkReturnStatus(retStatus);
5423 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5430 int radio::requestIsimAuthenticationResponse(int slotId,
5431 int responseType, int serial, RIL_Errno e,
5432 void *response, size_t responseLen) {
5434 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5437 if (radioService[slotId]->mRadioResponse != NULL) {
5438 RadioResponseInfo responseInfo = {};
5439 populateResponseInfo(responseInfo, serial, responseType, e);
5440 Return<void> retStatus
5441 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5443 convertCharPtrToHidlString((char *) response));
5444 radioService[slotId]->checkReturnStatus(retStatus);
5446 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5453 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5455 int serial, RIL_Errno e, void *response,
5456 size_t responseLen) {
5458 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5461 if (radioService[slotId]->mRadioResponse != NULL) {
5462 RadioResponseInfo responseInfo = {};
5463 populateResponseInfo(responseInfo, serial, responseType, e);
5464 Return<void> retStatus
5465 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5467 radioService[slotId]->checkReturnStatus(retStatus);
5469 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5476 int radio::sendEnvelopeWithStatusResponse(int slotId,
5477 int responseType, int serial, RIL_Errno e, void *response,
5478 size_t responseLen) {
5480 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5483 if (radioService[slotId]->mRadioResponse != NULL) {
5484 RadioResponseInfo responseInfo = {};
5485 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5486 response, responseLen);
5488 Return<void> retStatus
5489 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5491 radioService[slotId]->checkReturnStatus(retStatus);
5493 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5500 int radio::getVoiceRadioTechnologyResponse(int slotId,
5501 int responseType, int serial, RIL_Errno e,
5502 void *response, size_t responseLen) {
5504 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5507 if (radioService[slotId]->mRadioResponse != NULL) {
5508 RadioResponseInfo responseInfo = {};
5509 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5510 Return<void> retStatus
5511 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5512 responseInfo, (RadioTechnology) ret);
5513 radioService[slotId]->checkReturnStatus(retStatus);
5515 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5522 int radio::getCellInfoListResponse(int slotId,
5524 int serial, RIL_Errno e, void *response,
5525 size_t responseLen) {
5527 RLOGD("getCellInfoListResponse: serial %d", serial);
5530 if (radioService[slotId]->mRadioResponse != NULL) {
5531 RadioResponseInfo responseInfo = {};
5532 populateResponseInfo(responseInfo, serial, responseType, e);
5534 hidl_vec<CellInfo> ret;
5535 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5536 RLOGE("getCellInfoListResponse: Invalid response");
5537 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5539 convertRilCellInfoListToHal(response, responseLen, ret);
5542 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5544 radioService[slotId]->checkReturnStatus(retStatus);
5546 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5552 int radio::setCellInfoListRateResponse(int slotId,
5554 int serial, RIL_Errno e, void *response,
5555 size_t responseLen) {
5557 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5560 if (radioService[slotId]->mRadioResponse != NULL) {
5561 RadioResponseInfo responseInfo = {};
5562 populateResponseInfo(responseInfo, serial, responseType, e);
5563 Return<void> retStatus
5564 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5565 radioService[slotId]->checkReturnStatus(retStatus);
5567 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5574 int radio::setInitialAttachApnResponse(int slotId,
5575 int responseType, int serial, RIL_Errno e,
5576 void *response, size_t responseLen) {
5578 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5581 if (radioService[slotId]->mRadioResponse != NULL) {
5582 RadioResponseInfo responseInfo = {};
5583 populateResponseInfo(responseInfo, serial, responseType, e);
5584 Return<void> retStatus
5585 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5586 radioService[slotId]->checkReturnStatus(retStatus);
5588 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5595 int radio::getImsRegistrationStateResponse(int slotId,
5596 int responseType, int serial, RIL_Errno e,
5597 void *response, size_t responseLen) {
5599 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5602 if (radioService[slotId]->mRadioResponse != NULL) {
5603 RadioResponseInfo responseInfo = {};
5604 populateResponseInfo(responseInfo, serial, responseType, e);
5605 bool isRegistered = false;
5607 int numInts = responseLen / sizeof(int);
5608 if (response == NULL || numInts != 2) {
5609 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5610 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5612 int *pInt = (int *) response;
5613 isRegistered = pInt[0] == 1 ? true : false;
5614 ratFamily = pInt[1];
5616 Return<void> retStatus
5617 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5618 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5619 radioService[slotId]->checkReturnStatus(retStatus);
5621 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5628 int radio::sendImsSmsResponse(int slotId,
5629 int responseType, int serial, RIL_Errno e, void *response,
5630 size_t responseLen) {
5632 RLOGD("sendImsSmsResponse: serial %d", serial);
5635 if (radioService[slotId]->mRadioResponse != NULL) {
5636 RadioResponseInfo responseInfo = {};
5637 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5640 Return<void> retStatus
5641 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5642 radioService[slotId]->checkReturnStatus(retStatus);
5644 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5650 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5651 int responseType, int serial, RIL_Errno e,
5652 void *response, size_t responseLen) {
5654 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5657 if (radioService[slotId]->mRadioResponse != NULL) {
5658 RadioResponseInfo responseInfo = {};
5659 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5662 Return<void> retStatus
5663 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5664 responseInfo, result);
5665 radioService[slotId]->checkReturnStatus(retStatus);
5667 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5674 int radio::iccOpenLogicalChannelResponse(int slotId,
5675 int responseType, int serial, RIL_Errno e, void *response,
5676 size_t responseLen) {
5678 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5681 if (radioService[slotId]->mRadioResponse != NULL) {
5682 RadioResponseInfo responseInfo = {};
5683 populateResponseInfo(responseInfo, serial, responseType, e);
5685 hidl_vec<int8_t> selectResponse;
5686 int numInts = responseLen / sizeof(int);
5687 if (response == NULL || responseLen % sizeof(int) != 0) {
5688 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5689 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5691 int *pInt = (int *) response;
5692 channelId = pInt[0];
5693 selectResponse.resize(numInts - 1);
5694 for (int i = 1; i < numInts; i++) {
5695 selectResponse[i - 1] = (int8_t) pInt[i];
5698 Return<void> retStatus
5699 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5700 channelId, selectResponse);
5701 radioService[slotId]->checkReturnStatus(retStatus);
5703 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5710 int radio::iccCloseLogicalChannelResponse(int slotId,
5711 int responseType, int serial, RIL_Errno e,
5712 void *response, size_t responseLen) {
5714 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5717 if (radioService[slotId]->mRadioResponse != NULL) {
5718 RadioResponseInfo responseInfo = {};
5719 populateResponseInfo(responseInfo, serial, responseType, e);
5720 Return<void> retStatus
5721 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5723 radioService[slotId]->checkReturnStatus(retStatus);
5725 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5732 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5733 int responseType, int serial, RIL_Errno e,
5734 void *response, size_t responseLen) {
5736 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5739 if (radioService[slotId]->mRadioResponse != NULL) {
5740 RadioResponseInfo responseInfo = {};
5741 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5744 Return<void> retStatus
5745 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5746 responseInfo, result);
5747 radioService[slotId]->checkReturnStatus(retStatus);
5749 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5756 int radio::nvReadItemResponse(int slotId,
5757 int responseType, int serial, RIL_Errno e,
5758 void *response, size_t responseLen) {
5760 RLOGD("nvReadItemResponse: serial %d", serial);
5763 if (radioService[slotId]->mRadioResponse != NULL) {
5764 RadioResponseInfo responseInfo = {};
5765 populateResponseInfo(responseInfo, serial, responseType, e);
5766 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5768 convertCharPtrToHidlString((char *) response));
5769 radioService[slotId]->checkReturnStatus(retStatus);
5771 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5777 int radio::nvWriteItemResponse(int slotId,
5778 int responseType, int serial, RIL_Errno e,
5779 void *response, size_t responseLen) {
5781 RLOGD("nvWriteItemResponse: serial %d", serial);
5784 if (radioService[slotId]->mRadioResponse != NULL) {
5785 RadioResponseInfo responseInfo = {};
5786 populateResponseInfo(responseInfo, serial, responseType, e);
5787 Return<void> retStatus
5788 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5789 radioService[slotId]->checkReturnStatus(retStatus);
5791 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5797 int radio::nvWriteCdmaPrlResponse(int slotId,
5798 int responseType, int serial, RIL_Errno e,
5799 void *response, size_t responseLen) {
5801 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5804 if (radioService[slotId]->mRadioResponse != NULL) {
5805 RadioResponseInfo responseInfo = {};
5806 populateResponseInfo(responseInfo, serial, responseType, e);
5807 Return<void> retStatus
5808 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5809 radioService[slotId]->checkReturnStatus(retStatus);
5811 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5817 int radio::nvResetConfigResponse(int slotId,
5818 int responseType, int serial, RIL_Errno e,
5819 void *response, size_t responseLen) {
5821 RLOGD("nvResetConfigResponse: serial %d", serial);
5824 if (radioService[slotId]->mRadioResponse != NULL) {
5825 RadioResponseInfo responseInfo = {};
5826 populateResponseInfo(responseInfo, serial, responseType, e);
5827 Return<void> retStatus
5828 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5829 radioService[slotId]->checkReturnStatus(retStatus);
5831 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5837 int radio::setUiccSubscriptionResponse(int slotId,
5838 int responseType, int serial, RIL_Errno e,
5839 void *response, size_t responseLen) {
5841 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5844 if (radioService[slotId]->mRadioResponse != NULL) {
5845 RadioResponseInfo responseInfo = {};
5846 populateResponseInfo(responseInfo, serial, responseType, e);
5847 Return<void> retStatus
5848 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5849 radioService[slotId]->checkReturnStatus(retStatus);
5851 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5858 int radio::setDataAllowedResponse(int slotId,
5859 int responseType, int serial, RIL_Errno e,
5860 void *response, size_t responseLen) {
5862 RLOGD("setDataAllowedResponse: serial %d", serial);
5865 if (radioService[slotId]->mRadioResponse != NULL) {
5866 RadioResponseInfo responseInfo = {};
5867 populateResponseInfo(responseInfo, serial, responseType, e);
5868 Return<void> retStatus
5869 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5870 radioService[slotId]->checkReturnStatus(retStatus);
5872 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5878 int radio::getHardwareConfigResponse(int slotId,
5879 int responseType, int serial, RIL_Errno e,
5880 void *response, size_t responseLen) {
5882 RLOGD("getHardwareConfigResponse: serial %d", serial);
5885 if (radioService[slotId]->mRadioResponse != NULL) {
5886 RadioResponseInfo responseInfo = {};
5887 populateResponseInfo(responseInfo, serial, responseType, e);
5889 hidl_vec<HardwareConfig> result;
5890 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
5891 RLOGE("hardwareConfigChangedInd: invalid response");
5892 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5894 convertRilHardwareConfigListToHal(response, responseLen, result);
5897 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
5898 responseInfo, result);
5899 radioService[slotId]->checkReturnStatus(retStatus);
5901 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5907 int radio::requestIccSimAuthenticationResponse(int slotId,
5908 int responseType, int serial, RIL_Errno e,
5909 void *response, size_t responseLen) {
5911 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
5914 if (radioService[slotId]->mRadioResponse != NULL) {
5915 RadioResponseInfo responseInfo = {};
5916 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5919 Return<void> retStatus
5920 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
5921 responseInfo, result);
5922 radioService[slotId]->checkReturnStatus(retStatus);
5924 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
5931 int radio::setDataProfileResponse(int slotId,
5932 int responseType, int serial, RIL_Errno e,
5933 void *response, size_t responseLen) {
5935 RLOGD("setDataProfileResponse: serial %d", serial);
5938 if (radioService[slotId]->mRadioResponse != NULL) {
5939 RadioResponseInfo responseInfo = {};
5940 populateResponseInfo(responseInfo, serial, responseType, e);
5941 Return<void> retStatus
5942 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
5943 radioService[slotId]->checkReturnStatus(retStatus);
5945 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5951 int radio::requestShutdownResponse(int slotId,
5952 int responseType, int serial, RIL_Errno e,
5953 void *response, size_t responseLen) {
5955 RLOGD("requestShutdownResponse: serial %d", serial);
5958 if (radioService[slotId]->mRadioResponse != NULL) {
5959 RadioResponseInfo responseInfo = {};
5960 populateResponseInfo(responseInfo, serial, responseType, e);
5961 Return<void> retStatus
5962 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
5963 radioService[slotId]->checkReturnStatus(retStatus);
5965 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5971 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
5972 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
5973 populateResponseInfo(responseInfo, serial, responseType, e);
5975 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
5976 RLOGE("responseRadioCapability: Invalid response");
5977 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5978 rc.logicalModemUuid = hidl_string();
5980 convertRilRadioCapabilityToHal(response, responseLen, rc);
5984 int radio::getRadioCapabilityResponse(int slotId,
5985 int responseType, int serial, RIL_Errno e,
5986 void *response, size_t responseLen) {
5988 RLOGD("getRadioCapabilityResponse: serial %d", serial);
5991 if (radioService[slotId]->mRadioResponse != NULL) {
5992 RadioResponseInfo responseInfo = {};
5993 RadioCapability result = {};
5994 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
5996 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
5997 responseInfo, result);
5998 radioService[slotId]->checkReturnStatus(retStatus);
6000 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6006 int radio::setRadioCapabilityResponse(int slotId,
6007 int responseType, int serial, RIL_Errno e,
6008 void *response, size_t responseLen) {
6010 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6013 if (radioService[slotId]->mRadioResponse != NULL) {
6014 RadioResponseInfo responseInfo = {};
6015 RadioCapability result = {};
6016 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6018 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6019 responseInfo, result);
6020 radioService[slotId]->checkReturnStatus(retStatus);
6022 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6028 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6029 RIL_Errno e, void *response, size_t responseLen) {
6030 populateResponseInfo(responseInfo, serial, responseType, e);
6031 LceStatusInfo result = {};
6033 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6034 RLOGE("Invalid response: NULL");
6035 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6037 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6038 result.lceStatus = (LceStatus) resp->lce_status;
6039 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6044 int radio::startLceServiceResponse(int slotId,
6045 int responseType, int serial, RIL_Errno e,
6046 void *response, size_t responseLen) {
6048 RLOGD("startLceServiceResponse: serial %d", serial);
6051 if (radioService[slotId]->mRadioResponse != NULL) {
6052 RadioResponseInfo responseInfo = {};
6053 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6054 response, responseLen);
6056 Return<void> retStatus
6057 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6059 radioService[slotId]->checkReturnStatus(retStatus);
6061 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6067 int radio::stopLceServiceResponse(int slotId,
6068 int responseType, int serial, RIL_Errno e,
6069 void *response, size_t responseLen) {
6071 RLOGD("stopLceServiceResponse: serial %d", serial);
6074 if (radioService[slotId]->mRadioResponse != NULL) {
6075 RadioResponseInfo responseInfo = {};
6076 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6077 response, responseLen);
6079 Return<void> retStatus
6080 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6082 radioService[slotId]->checkReturnStatus(retStatus);
6084 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6090 int radio::pullLceDataResponse(int slotId,
6091 int responseType, int serial, RIL_Errno e,
6092 void *response, size_t responseLen) {
6094 RLOGD("pullLceDataResponse: serial %d", serial);
6097 if (radioService[slotId]->mRadioResponse != NULL) {
6098 RadioResponseInfo responseInfo = {};
6099 populateResponseInfo(responseInfo, serial, responseType, e);
6101 LceDataInfo result = {};
6102 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6103 RLOGE("pullLceDataResponse: Invalid response");
6104 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6106 convertRilLceDataInfoToHal(response, responseLen, result);
6109 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6110 responseInfo, result);
6111 radioService[slotId]->checkReturnStatus(retStatus);
6113 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6119 int radio::getModemActivityInfoResponse(int slotId,
6120 int responseType, int serial, RIL_Errno e,
6121 void *response, size_t responseLen) {
6123 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6126 if (radioService[slotId]->mRadioResponse != NULL) {
6127 RadioResponseInfo responseInfo = {};
6128 populateResponseInfo(responseInfo, serial, responseType, e);
6129 ActivityStatsInfo info;
6130 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6131 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6132 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6134 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6135 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6136 info.idleModeTimeMs = resp->idle_mode_time_ms;
6137 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6138 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6140 info.rxModeTimeMs = resp->rx_mode_time_ms;
6143 Return<void> retStatus
6144 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6146 radioService[slotId]->checkReturnStatus(retStatus);
6148 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6155 int radio::setAllowedCarriersResponse(int slotId,
6156 int responseType, int serial, RIL_Errno e,
6157 void *response, size_t responseLen) {
6159 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6162 if (radioService[slotId]->mRadioResponse != NULL) {
6163 RadioResponseInfo responseInfo = {};
6164 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6165 Return<void> retStatus
6166 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6168 radioService[slotId]->checkReturnStatus(retStatus);
6170 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6177 int radio::getAllowedCarriersResponse(int slotId,
6178 int responseType, int serial, RIL_Errno e,
6179 void *response, size_t responseLen) {
6181 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6184 if (radioService[slotId]->mRadioResponse != NULL) {
6185 RadioResponseInfo responseInfo = {};
6186 populateResponseInfo(responseInfo, serial, responseType, e);
6187 CarrierRestrictions carrierInfo = {};
6188 bool allAllowed = true;
6189 if (response == NULL || responseLen != sizeof(RIL_CarrierRestrictions)) {
6190 RLOGE("getAllowedCarriersResponse Invalid response: NULL");
6191 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6193 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6194 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6198 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6199 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6200 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6201 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6202 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6203 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6204 carrierInfo.allowedCarriers[i].matchData =
6205 convertCharPtrToHidlString(carrier->match_data);
6208 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6209 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6210 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6211 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6212 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6213 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6214 carrierInfo.excludedCarriers[i].matchData =
6215 convertCharPtrToHidlString(carrier->match_data);
6219 Return<void> retStatus
6220 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6221 allAllowed, carrierInfo);
6222 radioService[slotId]->checkReturnStatus(retStatus);
6224 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6231 int radio::sendDeviceStateResponse(int slotId,
6232 int responseType, int serial, RIL_Errno e,
6233 void *response, size_t responselen) {
6235 RLOGD("sendDeviceStateResponse: serial %d", serial);
6238 if (radioService[slotId]->mRadioResponse != NULL) {
6239 RadioResponseInfo responseInfo = {};
6240 populateResponseInfo(responseInfo, serial, responseType, e);
6241 Return<void> retStatus
6242 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6243 radioService[slotId]->checkReturnStatus(retStatus);
6245 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6251 int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
6252 int responseType, int serial, RIL_Errno e,
6253 void *response, size_t responseLen) {
6254 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
6255 if (radioService[slotId]->mRadioResponse != NULL) {
6256 RadioResponseInfo responseInfo = {};
6257 populateResponseInfo(responseInfo, serial, responseType, e);
6258 Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
6259 ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
6260 radioService[slotId]->mRadioResponse);
6262 sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
6263 Return<void> retStatus
6264 = radioResponseV1_1->setCarrierInfoForImsiEncryptionResponse(responseInfo);
6265 radioService[slotId]->checkReturnStatus(retStatus);
6267 RLOGE("setCarrierInfoForImsiEncryptionResponse: ret.isOk() == false for "
6268 "radioService[%d]" , slotId);
6271 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponse == NULL",
6277 int radio::setIndicationFilterResponse(int slotId,
6278 int responseType, int serial, RIL_Errno e,
6279 void *response, size_t responselen) {
6281 RLOGD("setIndicationFilterResponse: serial %d", serial);
6284 if (radioService[slotId]->mRadioResponse != NULL) {
6285 RadioResponseInfo responseInfo = {};
6286 populateResponseInfo(responseInfo, serial, responseType, e);
6287 Return<void> retStatus
6288 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6289 radioService[slotId]->checkReturnStatus(retStatus);
6291 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6299 int radio::setSimCardPowerResponse(int slotId,
6300 int responseType, int serial, RIL_Errno e,
6301 void *response, size_t responseLen) {
6303 RLOGD("setSimCardPowerResponse: serial %d", serial);
6306 if (radioService[slotId]->mRadioResponse != NULL) {
6307 RadioResponseInfo responseInfo = {};
6308 populateResponseInfo(responseInfo, serial, responseType, e);
6309 Return<void> retStatus
6310 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6311 radioService[slotId]->checkReturnStatus(retStatus);
6313 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6319 int radio::sendRequestRawResponse(int slotId,
6320 int responseType, int serial, RIL_Errno e,
6321 void *response, size_t responseLen) {
6323 RLOGD("sendRequestRawResponse: serial %d", serial);
6326 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6327 RadioResponseInfo responseInfo = {};
6328 populateResponseInfo(responseInfo, serial, responseType, e);
6329 hidl_vec<uint8_t> data;
6331 if (response == NULL) {
6332 RLOGE("sendRequestRawResponse: Invalid response");
6333 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6335 data.setToExternal((uint8_t *) response, responseLen);
6337 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6338 sendRequestRawResponse(responseInfo, data);
6339 checkReturnStatus(slotId, retStatus, false);
6341 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6348 int radio::sendRequestStringsResponse(int slotId,
6349 int responseType, int serial, RIL_Errno e,
6350 void *response, size_t responseLen) {
6352 RLOGD("sendRequestStringsResponse: serial %d", serial);
6355 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6356 RadioResponseInfo responseInfo = {};
6357 populateResponseInfo(responseInfo, serial, responseType, e);
6358 hidl_vec<hidl_string> data;
6360 if (response == NULL || responseLen % sizeof(char *) != 0) {
6361 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6362 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6364 char **resp = (char **) response;
6365 int numStrings = responseLen / sizeof(char *);
6366 data.resize(numStrings);
6367 for (int i = 0; i < numStrings; i++) {
6368 data[i] = convertCharPtrToHidlString(resp[i]);
6371 Return<void> retStatus
6372 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6373 responseInfo, data);
6374 checkReturnStatus(slotId, retStatus, false);
6376 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6383 // Radio Indication functions
6385 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6386 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6387 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6390 int radio::radioStateChangedInd(int slotId,
6391 int indicationType, int token, RIL_Errno e, void *response,
6392 size_t responseLen) {
6393 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6394 RadioState radioState = (RadioState) s_vendorFunctions->onStateRequest();
6395 RLOGD("radioStateChangedInd: radioState %d", radioState);
6396 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6397 convertIntToRadioIndicationType(indicationType), radioState);
6398 radioService[slotId]->checkReturnStatus(retStatus);
6400 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6406 int radio::callStateChangedInd(int slotId,
6407 int indicationType, int token, RIL_Errno e, void *response,
6408 size_t responseLen) {
6409 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6411 RLOGD("callStateChangedInd");
6413 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6414 convertIntToRadioIndicationType(indicationType));
6415 radioService[slotId]->checkReturnStatus(retStatus);
6417 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6423 int radio::networkStateChangedInd(int slotId,
6424 int indicationType, int token, RIL_Errno e, void *response,
6425 size_t responseLen) {
6426 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6428 RLOGD("networkStateChangedInd");
6430 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6431 convertIntToRadioIndicationType(indicationType));
6432 radioService[slotId]->checkReturnStatus(retStatus);
6434 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6441 uint8_t hexCharToInt(uint8_t c) {
6442 if (c >= '0' && c <= '9') return (c - '0');
6443 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6444 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6446 return INVALID_HEX_CHAR;
6449 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6450 if (responseLen % 2 != 0) {
6454 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6455 if (bytes == NULL) {
6456 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6459 uint8_t *hexString = (uint8_t *)response;
6461 for (size_t i = 0; i < responseLen; i += 2) {
6462 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6463 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6465 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6466 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6467 hexString[i], hexString[i + 1]);
6471 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6477 int radio::newSmsInd(int slotId, int indicationType,
6478 int token, RIL_Errno e, void *response, size_t responseLen) {
6479 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6480 if (response == NULL || responseLen == 0) {
6481 RLOGE("newSmsInd: invalid response");
6485 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6486 if (bytes == NULL) {
6487 RLOGE("newSmsInd: convertHexStringToBytes failed");
6491 hidl_vec<uint8_t> pdu;
6492 pdu.setToExternal(bytes, responseLen/2);
6496 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6497 convertIntToRadioIndicationType(indicationType), pdu);
6498 radioService[slotId]->checkReturnStatus(retStatus);
6501 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6507 int radio::newSmsStatusReportInd(int slotId,
6508 int indicationType, int token, RIL_Errno e, void *response,
6509 size_t responseLen) {
6510 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6511 if (response == NULL || responseLen == 0) {
6512 RLOGE("newSmsStatusReportInd: invalid response");
6516 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6517 if (bytes == NULL) {
6518 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6522 hidl_vec<uint8_t> pdu;
6523 pdu.setToExternal(bytes, responseLen/2);
6525 RLOGD("newSmsStatusReportInd");
6527 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6528 convertIntToRadioIndicationType(indicationType), pdu);
6529 radioService[slotId]->checkReturnStatus(retStatus);
6532 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6538 int radio::newSmsOnSimInd(int slotId, int indicationType,
6539 int token, RIL_Errno e, void *response, size_t responseLen) {
6540 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6541 if (response == NULL || responseLen != sizeof(int)) {
6542 RLOGE("newSmsOnSimInd: invalid response");
6545 int32_t recordNumber = ((int32_t *) response)[0];
6547 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6549 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6550 convertIntToRadioIndicationType(indicationType), recordNumber);
6551 radioService[slotId]->checkReturnStatus(retStatus);
6553 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6559 int radio::onUssdInd(int slotId, int indicationType,
6560 int token, RIL_Errno e, void *response, size_t responseLen) {
6561 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6562 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6563 RLOGE("onUssdInd: invalid response");
6566 char **strings = (char **) response;
6567 char *mode = strings[0];
6568 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6569 UssdModeType modeType = (UssdModeType) atoi(mode);
6571 RLOGD("onUssdInd: mode %s", mode);
6573 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6574 convertIntToRadioIndicationType(indicationType), modeType, msg);
6575 radioService[slotId]->checkReturnStatus(retStatus);
6577 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6583 int radio::nitzTimeReceivedInd(int slotId,
6584 int indicationType, int token, RIL_Errno e, void *response,
6585 size_t responseLen) {
6586 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6587 if (response == NULL || responseLen == 0) {
6588 RLOGE("nitzTimeReceivedInd: invalid response");
6591 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6592 int64_t timeReceived = android::elapsedRealtime();
6594 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6597 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6598 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6599 radioService[slotId]->checkReturnStatus(retStatus);
6601 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6608 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6609 SignalStrength& signalStrength) {
6610 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6612 // Fixup LTE for backwards compatibility
6613 // signalStrength: -1 -> 99
6614 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6615 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6617 // rsrp: -1 -> INT_MAX all other negative value to positive.
6619 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6620 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6621 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6622 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6624 // rsrq: -1 -> INT_MAX
6625 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6626 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6628 // Not remapping rssnr is already using INT_MAX
6629 // cqi: -1 -> INT_MAX
6630 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6631 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6634 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6635 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6636 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6637 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6638 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6639 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6640 signalStrength.evdo.signalNoiseRatio =
6641 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6642 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6643 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6644 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6645 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6646 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6647 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6648 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6651 int radio::currentSignalStrengthInd(int slotId,
6652 int indicationType, int token, RIL_Errno e,
6653 void *response, size_t responseLen) {
6654 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6655 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
6656 RLOGE("currentSignalStrengthInd: invalid response");
6660 SignalStrength signalStrength = {};
6661 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6664 RLOGD("currentSignalStrengthInd");
6666 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6667 convertIntToRadioIndicationType(indicationType), signalStrength);
6668 radioService[slotId]->checkReturnStatus(retStatus);
6670 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6677 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6678 SetupDataCallResult& dcResult) {
6679 dcResult.status = (DataCallFailCause) dcResponse->status;
6680 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6681 dcResult.cid = dcResponse->cid;
6682 dcResult.active = dcResponse->active;
6683 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6684 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6685 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6686 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6687 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6688 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6689 dcResult.mtu = dcResponse->mtu;
6692 void convertRilDataCallListToHal(void *response, size_t responseLen,
6693 hidl_vec<SetupDataCallResult>& dcResultList) {
6694 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6696 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6697 dcResultList.resize(num);
6698 for (int i = 0; i < num; i++) {
6699 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6703 int radio::dataCallListChangedInd(int slotId,
6704 int indicationType, int token, RIL_Errno e, void *response,
6705 size_t responseLen) {
6706 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6707 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
6708 RLOGE("dataCallListChangedInd: invalid response");
6711 hidl_vec<SetupDataCallResult> dcList;
6712 convertRilDataCallListToHal(response, responseLen, dcList);
6714 RLOGD("dataCallListChangedInd");
6716 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
6717 convertIntToRadioIndicationType(indicationType), dcList);
6718 radioService[slotId]->checkReturnStatus(retStatus);
6720 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6726 int radio::suppSvcNotifyInd(int slotId, int indicationType,
6727 int token, RIL_Errno e, void *response, size_t responseLen) {
6728 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6729 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
6730 RLOGE("suppSvcNotifyInd: invalid response");
6734 SuppSvcNotification suppSvc = {};
6735 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6736 suppSvc.isMT = ssn->notificationType;
6737 suppSvc.code = ssn->code;
6738 suppSvc.index = ssn->index;
6739 suppSvc.type = ssn->type;
6740 suppSvc.number = convertCharPtrToHidlString(ssn->number);
6743 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
6744 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
6746 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
6747 convertIntToRadioIndicationType(indicationType), suppSvc);
6748 radioService[slotId]->checkReturnStatus(retStatus);
6750 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6756 int radio::stkSessionEndInd(int slotId, int indicationType,
6757 int token, RIL_Errno e, void *response, size_t responseLen) {
6758 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6760 RLOGD("stkSessionEndInd");
6762 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
6763 convertIntToRadioIndicationType(indicationType));
6764 radioService[slotId]->checkReturnStatus(retStatus);
6766 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
6772 int radio::stkProactiveCommandInd(int slotId,
6773 int indicationType, int token, RIL_Errno e, void *response,
6774 size_t responseLen) {
6775 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6776 if (response == NULL || responseLen == 0) {
6777 RLOGE("stkProactiveCommandInd: invalid response");
6781 RLOGD("stkProactiveCommandInd");
6783 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
6784 convertIntToRadioIndicationType(indicationType),
6785 convertCharPtrToHidlString((char *) response));
6786 radioService[slotId]->checkReturnStatus(retStatus);
6788 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
6794 int radio::stkEventNotifyInd(int slotId, int indicationType,
6795 int token, RIL_Errno e, void *response, size_t responseLen) {
6796 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6797 if (response == NULL || responseLen == 0) {
6798 RLOGE("stkEventNotifyInd: invalid response");
6802 RLOGD("stkEventNotifyInd");
6804 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
6805 convertIntToRadioIndicationType(indicationType),
6806 convertCharPtrToHidlString((char *) response));
6807 radioService[slotId]->checkReturnStatus(retStatus);
6809 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6815 int radio::stkCallSetupInd(int slotId, int indicationType,
6816 int token, RIL_Errno e, void *response, size_t responseLen) {
6817 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6818 if (response == NULL || responseLen != sizeof(int)) {
6819 RLOGE("stkCallSetupInd: invalid response");
6822 int32_t timeout = ((int32_t *) response)[0];
6824 RLOGD("stkCallSetupInd: timeout %d", timeout);
6826 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
6827 convertIntToRadioIndicationType(indicationType), timeout);
6828 radioService[slotId]->checkReturnStatus(retStatus);
6830 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
6836 int radio::simSmsStorageFullInd(int slotId,
6837 int indicationType, int token, RIL_Errno e, void *response,
6838 size_t responseLen) {
6839 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6841 RLOGD("simSmsStorageFullInd");
6843 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
6844 convertIntToRadioIndicationType(indicationType));
6845 radioService[slotId]->checkReturnStatus(retStatus);
6847 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
6853 int radio::simRefreshInd(int slotId, int indicationType,
6854 int token, RIL_Errno e, void *response, size_t responseLen) {
6855 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6856 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
6857 RLOGE("simRefreshInd: invalid response");
6861 SimRefreshResult refreshResult = {};
6862 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
6863 refreshResult.type =
6864 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
6865 refreshResult.efId = simRefreshResponse->ef_id;
6866 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
6869 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
6871 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
6872 convertIntToRadioIndicationType(indicationType), refreshResult);
6873 radioService[slotId]->checkReturnStatus(retStatus);
6875 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
6881 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
6882 CdmaSignalInfoRecord& record) {
6883 record.isPresent = signalInfoRecord->isPresent;
6884 record.signalType = signalInfoRecord->signalType;
6885 record.alertPitch = signalInfoRecord->alertPitch;
6886 record.signal = signalInfoRecord->signal;
6889 int radio::callRingInd(int slotId, int indicationType,
6890 int token, RIL_Errno e, void *response, size_t responseLen) {
6891 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6893 CdmaSignalInfoRecord record = {};
6894 if (response == NULL || responseLen == 0) {
6898 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
6899 RLOGE("callRingInd: invalid response");
6902 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
6906 RLOGD("callRingInd: isGsm %d", isGsm);
6908 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
6909 convertIntToRadioIndicationType(indicationType), isGsm, record);
6910 radioService[slotId]->checkReturnStatus(retStatus);
6912 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
6918 int radio::simStatusChangedInd(int slotId,
6919 int indicationType, int token, RIL_Errno e, void *response,
6920 size_t responseLen) {
6921 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6923 RLOGD("simStatusChangedInd");
6925 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
6926 convertIntToRadioIndicationType(indicationType));
6927 radioService[slotId]->checkReturnStatus(retStatus);
6929 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6935 int radio::cdmaNewSmsInd(int slotId, int indicationType,
6936 int token, RIL_Errno e, void *response, size_t responseLen) {
6937 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6938 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
6939 RLOGE("cdmaNewSmsInd: invalid response");
6943 CdmaSmsMessage msg = {};
6944 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
6945 msg.teleserviceId = rilMsg->uTeleserviceID;
6946 msg.isServicePresent = rilMsg->bIsServicePresent;
6947 msg.serviceCategory = rilMsg->uServicecategory;
6948 msg.address.digitMode =
6949 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
6950 msg.address.numberMode =
6951 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
6952 msg.address.numberType =
6953 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
6954 msg.address.numberPlan =
6955 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
6957 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
6958 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
6960 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
6961 rilMsg->sSubAddress.subaddressType;
6962 msg.subAddress.odd = rilMsg->sSubAddress.odd;
6964 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
6965 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
6967 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
6968 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
6971 RLOGD("cdmaNewSmsInd");
6973 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
6974 convertIntToRadioIndicationType(indicationType), msg);
6975 radioService[slotId]->checkReturnStatus(retStatus);
6977 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6983 int radio::newBroadcastSmsInd(int slotId,
6984 int indicationType, int token, RIL_Errno e, void *response,
6985 size_t responseLen) {
6986 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6987 if (response == NULL || responseLen == 0) {
6988 RLOGE("newBroadcastSmsInd: invalid response");
6992 hidl_vec<uint8_t> data;
6993 data.setToExternal((uint8_t *) response, responseLen);
6995 RLOGD("newBroadcastSmsInd");
6997 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
6998 convertIntToRadioIndicationType(indicationType), data);
6999 radioService[slotId]->checkReturnStatus(retStatus);
7001 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7007 int radio::cdmaRuimSmsStorageFullInd(int slotId,
7008 int indicationType, int token, RIL_Errno e, void *response,
7009 size_t responseLen) {
7010 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7012 RLOGD("cdmaRuimSmsStorageFullInd");
7014 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7015 convertIntToRadioIndicationType(indicationType));
7016 radioService[slotId]->checkReturnStatus(retStatus);
7018 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7025 int radio::restrictedStateChangedInd(int slotId,
7026 int indicationType, int token, RIL_Errno e, void *response,
7027 size_t responseLen) {
7028 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7029 if (response == NULL || responseLen != sizeof(int)) {
7030 RLOGE("restrictedStateChangedInd: invalid response");
7033 int32_t state = ((int32_t *) response)[0];
7035 RLOGD("restrictedStateChangedInd: state %d", state);
7037 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7038 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7039 radioService[slotId]->checkReturnStatus(retStatus);
7041 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7048 int radio::enterEmergencyCallbackModeInd(int slotId,
7049 int indicationType, int token, RIL_Errno e, void *response,
7050 size_t responseLen) {
7051 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7053 RLOGD("enterEmergencyCallbackModeInd");
7055 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7056 convertIntToRadioIndicationType(indicationType));
7057 radioService[slotId]->checkReturnStatus(retStatus);
7059 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7066 int radio::cdmaCallWaitingInd(int slotId,
7067 int indicationType, int token, RIL_Errno e, void *response,
7068 size_t responseLen) {
7069 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7070 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7071 RLOGE("cdmaCallWaitingInd: invalid response");
7075 CdmaCallWaiting callWaitingRecord = {};
7076 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7077 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7078 callWaitingRecord.numberPresentation =
7079 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7080 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7081 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7082 callWaitingRecord.signalInfoRecord);
7083 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7084 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7087 RLOGD("cdmaCallWaitingInd");
7089 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7090 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7091 radioService[slotId]->checkReturnStatus(retStatus);
7093 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7099 int radio::cdmaOtaProvisionStatusInd(int slotId,
7100 int indicationType, int token, RIL_Errno e, void *response,
7101 size_t responseLen) {
7102 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7103 if (response == NULL || responseLen != sizeof(int)) {
7104 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7107 int32_t status = ((int32_t *) response)[0];
7109 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7111 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7112 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7113 radioService[slotId]->checkReturnStatus(retStatus);
7115 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7122 int radio::cdmaInfoRecInd(int slotId,
7123 int indicationType, int token, RIL_Errno e, void *response,
7124 size_t responseLen) {
7125 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7126 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7127 RLOGE("cdmaInfoRecInd: invalid response");
7131 CdmaInformationRecords records = {};
7132 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7134 char* string8 = NULL;
7135 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7136 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7137 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7138 "additional ones", recordsRil->numberOfInfoRecs,
7139 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7141 records.infoRec.resize(num);
7142 for (int i = 0 ; i < num ; i++) {
7143 CdmaInformationRecord *record = &records.infoRec[i];
7144 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7145 record->name = (CdmaInfoRecName) infoRec->name;
7146 // All vectors should be size 0 except one which will be size 1. Set everything to
7147 // size 0 initially.
7148 record->display.resize(0);
7149 record->number.resize(0);
7150 record->signal.resize(0);
7151 record->redir.resize(0);
7152 record->lineCtrl.resize(0);
7153 record->clir.resize(0);
7154 record->audioCtrl.resize(0);
7155 switch (infoRec->name) {
7156 case RIL_CDMA_DISPLAY_INFO_REC:
7157 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7158 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7159 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7160 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7161 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7164 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7165 if (string8 == NULL) {
7166 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7167 "responseCdmaInformationRecords");
7170 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7171 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7173 record->display.resize(1);
7174 record->display[0].alphaBuf = string8;
7180 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7181 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7182 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7183 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7184 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7185 "expected not more than %d", (int) infoRec->rec.number.len,
7186 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7189 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7190 if (string8 == NULL) {
7191 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7192 "responseCdmaInformationRecords");
7195 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7196 string8[(int)infoRec->rec.number.len] = '\0';
7198 record->number.resize(1);
7199 record->number[0].number = string8;
7202 record->number[0].numberType = infoRec->rec.number.number_type;
7203 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7204 record->number[0].pi = infoRec->rec.number.pi;
7205 record->number[0].si = infoRec->rec.number.si;
7209 case RIL_CDMA_SIGNAL_INFO_REC: {
7210 record->signal.resize(1);
7211 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7212 record->signal[0].signalType = infoRec->rec.signal.signalType;
7213 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7214 record->signal[0].signal = infoRec->rec.signal.signal;
7218 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7219 if (infoRec->rec.redir.redirectingNumber.len >
7220 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7221 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7222 "expected not more than %d\n",
7223 (int)infoRec->rec.redir.redirectingNumber.len,
7224 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7227 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7229 if (string8 == NULL) {
7230 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7231 "responseCdmaInformationRecords");
7234 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7235 infoRec->rec.redir.redirectingNumber.len);
7236 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7238 record->redir.resize(1);
7239 record->redir[0].redirectingNumber.number = string8;
7242 record->redir[0].redirectingNumber.numberType =
7243 infoRec->rec.redir.redirectingNumber.number_type;
7244 record->redir[0].redirectingNumber.numberPlan =
7245 infoRec->rec.redir.redirectingNumber.number_plan;
7246 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7247 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7248 record->redir[0].redirectingReason =
7249 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7253 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7254 record->lineCtrl.resize(1);
7255 record->lineCtrl[0].lineCtrlPolarityIncluded =
7256 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7257 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7258 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7259 record->lineCtrl[0].lineCtrlPowerDenial =
7260 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7264 case RIL_CDMA_T53_CLIR_INFO_REC: {
7265 record->clir.resize(1);
7266 record->clir[0].cause = infoRec->rec.clir.cause;
7270 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7271 record->audioCtrl.resize(1);
7272 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7273 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7277 case RIL_CDMA_T53_RELEASE_INFO_REC:
7278 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7282 RLOGE("cdmaInfoRecInd: Incorrect name value");
7288 RLOGD("cdmaInfoRecInd");
7290 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7291 convertIntToRadioIndicationType(indicationType), records);
7292 radioService[slotId]->checkReturnStatus(retStatus);
7294 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7300 int radio::indicateRingbackToneInd(int slotId,
7301 int indicationType, int token, RIL_Errno e, void *response,
7302 size_t responseLen) {
7303 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7304 if (response == NULL || responseLen != sizeof(int)) {
7305 RLOGE("indicateRingbackToneInd: invalid response");
7308 bool start = ((int32_t *) response)[0];
7310 RLOGD("indicateRingbackToneInd: start %d", start);
7312 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7313 convertIntToRadioIndicationType(indicationType), start);
7314 radioService[slotId]->checkReturnStatus(retStatus);
7316 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7322 int radio::resendIncallMuteInd(int slotId,
7323 int indicationType, int token, RIL_Errno e, void *response,
7324 size_t responseLen) {
7325 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7327 RLOGD("resendIncallMuteInd");
7329 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7330 convertIntToRadioIndicationType(indicationType));
7331 radioService[slotId]->checkReturnStatus(retStatus);
7333 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7339 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7340 int indicationType, int token, RIL_Errno e,
7341 void *response, size_t responseLen) {
7342 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7343 if (response == NULL || responseLen != sizeof(int)) {
7344 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7347 int32_t cdmaSource = ((int32_t *) response)[0];
7349 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7351 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7352 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7353 (CdmaSubscriptionSource) cdmaSource);
7354 radioService[slotId]->checkReturnStatus(retStatus);
7356 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7363 int radio::cdmaPrlChangedInd(int slotId,
7364 int indicationType, int token, RIL_Errno e, void *response,
7365 size_t responseLen) {
7366 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7367 if (response == NULL || responseLen != sizeof(int)) {
7368 RLOGE("cdmaPrlChangedInd: invalid response");
7371 int32_t version = ((int32_t *) response)[0];
7373 RLOGD("cdmaPrlChangedInd: version %d", version);
7375 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7376 convertIntToRadioIndicationType(indicationType), version);
7377 radioService[slotId]->checkReturnStatus(retStatus);
7379 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7385 int radio::exitEmergencyCallbackModeInd(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) {
7390 RLOGD("exitEmergencyCallbackModeInd");
7392 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7393 convertIntToRadioIndicationType(indicationType));
7394 radioService[slotId]->checkReturnStatus(retStatus);
7396 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7403 int radio::rilConnectedInd(int slotId,
7404 int indicationType, int token, RIL_Errno e, void *response,
7405 size_t responseLen) {
7406 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7407 RLOGD("rilConnectedInd");
7408 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7409 convertIntToRadioIndicationType(indicationType));
7410 radioService[slotId]->checkReturnStatus(retStatus);
7412 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7418 int radio::voiceRadioTechChangedInd(int slotId,
7419 int indicationType, int token, RIL_Errno e, void *response,
7420 size_t responseLen) {
7421 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7422 if (response == NULL || responseLen != sizeof(int)) {
7423 RLOGE("voiceRadioTechChangedInd: invalid response");
7426 int32_t rat = ((int32_t *) response)[0];
7428 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7430 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7431 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7432 radioService[slotId]->checkReturnStatus(retStatus);
7434 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7441 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7442 int num = responseLen / sizeof(RIL_CellInfo_v12);
7443 records.resize(num);
7445 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7446 for (int i = 0; i < num; i++) {
7447 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7448 records[i].registered = rillCellInfo->registered;
7449 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7450 records[i].timeStamp = rillCellInfo->timeStamp;
7451 // All vectors should be size 0 except one which will be size 1. Set everything to
7452 // size 0 initially.
7453 records[i].gsm.resize(0);
7454 records[i].wcdma.resize(0);
7455 records[i].cdma.resize(0);
7456 records[i].lte.resize(0);
7457 records[i].tdscdma.resize(0);
7458 switch(rillCellInfo->cellInfoType) {
7459 case RIL_CELL_INFO_TYPE_GSM: {
7460 records[i].gsm.resize(1);
7461 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7462 cellInfoGsm->cellIdentityGsm.mcc =
7463 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7464 cellInfoGsm->cellIdentityGsm.mnc =
7465 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7466 cellInfoGsm->cellIdentityGsm.lac =
7467 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7468 cellInfoGsm->cellIdentityGsm.cid =
7469 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7470 cellInfoGsm->cellIdentityGsm.arfcn =
7471 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7472 cellInfoGsm->cellIdentityGsm.bsic =
7473 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7474 cellInfoGsm->signalStrengthGsm.signalStrength =
7475 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7476 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7477 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7478 cellInfoGsm->signalStrengthGsm.timingAdvance =
7479 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7483 case RIL_CELL_INFO_TYPE_WCDMA: {
7484 records[i].wcdma.resize(1);
7485 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7486 cellInfoWcdma->cellIdentityWcdma.mcc =
7487 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7488 cellInfoWcdma->cellIdentityWcdma.mnc =
7489 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7490 cellInfoWcdma->cellIdentityWcdma.lac =
7491 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7492 cellInfoWcdma->cellIdentityWcdma.cid =
7493 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7494 cellInfoWcdma->cellIdentityWcdma.psc =
7495 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7496 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7497 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7498 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7499 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7500 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7501 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7505 case RIL_CELL_INFO_TYPE_CDMA: {
7506 records[i].cdma.resize(1);
7507 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7508 cellInfoCdma->cellIdentityCdma.networkId =
7509 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7510 cellInfoCdma->cellIdentityCdma.systemId =
7511 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7512 cellInfoCdma->cellIdentityCdma.baseStationId =
7513 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7514 cellInfoCdma->cellIdentityCdma.longitude =
7515 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7516 cellInfoCdma->cellIdentityCdma.latitude =
7517 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7518 cellInfoCdma->signalStrengthCdma.dbm =
7519 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7520 cellInfoCdma->signalStrengthCdma.ecio =
7521 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7522 cellInfoCdma->signalStrengthEvdo.dbm =
7523 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7524 cellInfoCdma->signalStrengthEvdo.ecio =
7525 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7526 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7527 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7531 case RIL_CELL_INFO_TYPE_LTE: {
7532 records[i].lte.resize(1);
7533 CellInfoLte *cellInfoLte = &records[i].lte[0];
7534 cellInfoLte->cellIdentityLte.mcc =
7535 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7536 cellInfoLte->cellIdentityLte.mnc =
7537 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7538 cellInfoLte->cellIdentityLte.ci =
7539 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7540 cellInfoLte->cellIdentityLte.pci =
7541 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7542 cellInfoLte->cellIdentityLte.tac =
7543 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7544 cellInfoLte->cellIdentityLte.earfcn =
7545 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7546 cellInfoLte->signalStrengthLte.signalStrength =
7547 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7548 cellInfoLte->signalStrengthLte.rsrp =
7549 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7550 cellInfoLte->signalStrengthLte.rsrq =
7551 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7552 cellInfoLte->signalStrengthLte.rssnr =
7553 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7554 cellInfoLte->signalStrengthLte.cqi =
7555 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7556 cellInfoLte->signalStrengthLte.timingAdvance =
7557 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7561 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7562 records[i].tdscdma.resize(1);
7563 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7564 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7565 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7566 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7567 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7568 cellInfoTdscdma->cellIdentityTdscdma.lac =
7569 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7570 cellInfoTdscdma->cellIdentityTdscdma.cid =
7571 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7572 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7573 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7574 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7575 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7586 int radio::cellInfoListInd(int slotId,
7587 int indicationType, int token, RIL_Errno e, void *response,
7588 size_t responseLen) {
7589 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7590 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7591 RLOGE("cellInfoListInd: invalid response");
7595 hidl_vec<CellInfo> records;
7596 convertRilCellInfoListToHal(response, responseLen, records);
7599 RLOGD("cellInfoListInd");
7601 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7602 convertIntToRadioIndicationType(indicationType), records);
7603 radioService[slotId]->checkReturnStatus(retStatus);
7605 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7611 int radio::imsNetworkStateChangedInd(int slotId,
7612 int indicationType, int token, RIL_Errno e, void *response,
7613 size_t responseLen) {
7614 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7616 RLOGD("imsNetworkStateChangedInd");
7618 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7619 convertIntToRadioIndicationType(indicationType));
7620 radioService[slotId]->checkReturnStatus(retStatus);
7622 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7629 int radio::subscriptionStatusChangedInd(int slotId,
7630 int indicationType, int token, RIL_Errno e, void *response,
7631 size_t responseLen) {
7632 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7633 if (response == NULL || responseLen != sizeof(int)) {
7634 RLOGE("subscriptionStatusChangedInd: invalid response");
7637 bool activate = ((int32_t *) response)[0];
7639 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7641 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
7642 convertIntToRadioIndicationType(indicationType), activate);
7643 radioService[slotId]->checkReturnStatus(retStatus);
7645 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
7652 int radio::srvccStateNotifyInd(int slotId,
7653 int indicationType, int token, RIL_Errno e, void *response,
7654 size_t responseLen) {
7655 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7656 if (response == NULL || responseLen != sizeof(int)) {
7657 RLOGE("srvccStateNotifyInd: invalid response");
7660 int32_t state = ((int32_t *) response)[0];
7662 RLOGD("srvccStateNotifyInd: rat %d", state);
7664 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
7665 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
7666 radioService[slotId]->checkReturnStatus(retStatus);
7668 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7674 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7675 hidl_vec<HardwareConfig>& records) {
7676 int num = responseLen / sizeof(RIL_HardwareConfig);
7677 records.resize(num);
7679 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7680 for (int i = 0; i < num; i++) {
7681 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7682 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7683 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7684 switch (rilHardwareConfig[i].type) {
7685 case RIL_HARDWARE_CONFIG_MODEM: {
7686 records[i].modem.resize(1);
7687 records[i].sim.resize(0);
7688 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7689 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7690 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7691 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7692 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7696 case RIL_HARDWARE_CONFIG_SIM: {
7697 records[i].sim.resize(1);
7698 records[i].modem.resize(0);
7699 records[i].sim[0].modemUuid =
7700 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7707 int radio::hardwareConfigChangedInd(int slotId,
7708 int indicationType, int token, RIL_Errno e, void *response,
7709 size_t responseLen) {
7710 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7711 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7712 RLOGE("hardwareConfigChangedInd: invalid response");
7716 hidl_vec<HardwareConfig> configs;
7717 convertRilHardwareConfigListToHal(response, responseLen, configs);
7720 RLOGD("hardwareConfigChangedInd");
7722 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
7723 convertIntToRadioIndicationType(indicationType), configs);
7724 radioService[slotId]->checkReturnStatus(retStatus);
7726 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
7733 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7734 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7735 rc.session = rilRadioCapability->session;
7736 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7737 rc.raf = rilRadioCapability->rat;
7738 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7739 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
7742 int radio::radioCapabilityIndicationInd(int slotId,
7743 int indicationType, int token, RIL_Errno e, void *response,
7744 size_t responseLen) {
7745 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7746 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
7747 RLOGE("radioCapabilityIndicationInd: invalid response");
7751 RadioCapability rc = {};
7752 convertRilRadioCapabilityToHal(response, responseLen, rc);
7755 RLOGD("radioCapabilityIndicationInd");
7757 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
7758 convertIntToRadioIndicationType(indicationType), rc);
7759 radioService[slotId]->checkReturnStatus(retStatus);
7761 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
7768 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
7769 if ((reqType == SS_INTERROGATION) &&
7770 (serType == SS_CFU ||
7771 serType == SS_CF_BUSY ||
7772 serType == SS_CF_NO_REPLY ||
7773 serType == SS_CF_NOT_REACHABLE ||
7774 serType == SS_CF_ALL ||
7775 serType == SS_CF_ALL_CONDITIONAL)) {
7781 int radio::onSupplementaryServiceIndicationInd(int slotId,
7782 int indicationType, int token, RIL_Errno e,
7783 void *response, size_t responseLen) {
7784 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7785 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
7786 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
7790 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
7791 StkCcUnsolSsResult ss = {};
7792 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
7793 ss.requestType = (SsRequestType) rilSsResponse->requestType;
7794 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
7795 ss.serviceClass = rilSsResponse->serviceClass;
7796 ss.result = (RadioError) rilSsResponse->result;
7798 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
7800 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
7801 rilSsResponse->cfData.numValidIndexes);
7803 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
7804 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
7805 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
7806 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
7809 ss.cfData.resize(1);
7810 ss.ssInfo.resize(0);
7812 /* number of call info's */
7813 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
7815 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
7816 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
7817 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
7819 cfInfo->status = (CallForwardInfoStatus) cf.status;
7820 cfInfo->reason = cf.reason;
7821 cfInfo->serviceClass = cf.serviceClass;
7822 cfInfo->toa = cf.toa;
7823 cfInfo->number = convertCharPtrToHidlString(cf.number);
7824 cfInfo->timeSeconds = cf.timeSeconds;
7826 RLOGD("onSupplementaryServiceIndicationInd: "
7827 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
7828 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
7832 ss.ssInfo.resize(1);
7833 ss.cfData.resize(0);
7836 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
7837 for (int i = 0; i < SS_INFO_MAX; i++) {
7839 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
7840 rilSsResponse->ssInfo[i]);
7842 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
7847 RLOGD("onSupplementaryServiceIndicationInd");
7849 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7850 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
7852 radioService[slotId]->checkReturnStatus(retStatus);
7854 RLOGE("onSupplementaryServiceIndicationInd: "
7855 "radioService[%d]->mRadioIndication == NULL", slotId);
7861 int radio::stkCallControlAlphaNotifyInd(int slotId,
7862 int indicationType, int token, RIL_Errno e, void *response,
7863 size_t responseLen) {
7864 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7865 if (response == NULL || responseLen == 0) {
7866 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
7870 RLOGD("stkCallControlAlphaNotifyInd");
7872 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
7873 convertIntToRadioIndicationType(indicationType),
7874 convertCharPtrToHidlString((char *) response));
7875 radioService[slotId]->checkReturnStatus(retStatus);
7877 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
7884 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
7885 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
7886 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
7887 lce.confidenceLevel = rilLceDataInfo->confidence_level;
7888 lce.lceSuspended = rilLceDataInfo->lce_suspended;
7891 int radio::lceDataInd(int slotId,
7892 int indicationType, int token, RIL_Errno e, void *response,
7893 size_t responseLen) {
7894 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7895 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
7896 RLOGE("lceDataInd: invalid response");
7900 LceDataInfo lce = {};
7901 convertRilLceDataInfoToHal(response, responseLen, lce);
7903 RLOGD("lceDataInd");
7905 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
7906 convertIntToRadioIndicationType(indicationType), lce);
7907 radioService[slotId]->checkReturnStatus(retStatus);
7909 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7915 int radio::pcoDataInd(int slotId,
7916 int indicationType, int token, RIL_Errno e, void *response,
7917 size_t responseLen) {
7918 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7919 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
7920 RLOGE("pcoDataInd: invalid response");
7924 PcoDataInfo pco = {};
7925 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
7926 pco.cid = rilPcoData->cid;
7927 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
7928 pco.pcoId = rilPcoData->pco_id;
7929 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
7932 RLOGD("pcoDataInd");
7934 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
7935 convertIntToRadioIndicationType(indicationType), pco);
7936 radioService[slotId]->checkReturnStatus(retStatus);
7938 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7944 int radio::modemResetInd(int slotId,
7945 int indicationType, int token, RIL_Errno e, void *response,
7946 size_t responseLen) {
7947 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7948 if (response == NULL || responseLen == 0) {
7949 RLOGE("modemResetInd: invalid response");
7953 RLOGD("modemResetInd");
7955 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
7956 convertIntToRadioIndicationType(indicationType),
7957 convertCharPtrToHidlString((char *) response));
7958 radioService[slotId]->checkReturnStatus(retStatus);
7960 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
7966 int radio::carrierInfoForImsiEncryption(int slotId,
7967 int indicationType, int token, RIL_Errno e, void *response,
7968 size_t responseLen) {
7969 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7970 if (response == NULL || responseLen == 0) {
7971 RLOGE("carrierInfoForImsiEncryption: invalid response");
7974 RLOGD("carrierInfoForImsiEncryption");
7975 Return<sp<::android::hardware::radio::V1_1::IRadioIndication>> ret =
7976 ::android::hardware::radio::V1_1::IRadioIndication::castFrom(
7977 radioService[slotId]->mRadioIndication);
7979 sp<::android::hardware::radio::V1_1::IRadioIndication> radioIndicationV1_1 = ret;
7980 Return<void> retStatus = radioIndicationV1_1->carrierInfoForImsiEncryption(
7981 convertIntToRadioIndicationType(indicationType));
7982 radioService[slotId]->checkReturnStatus(retStatus);
7984 RLOGE("carrierInfoForImsiEncryptionResponse: ret.isOk() == false for radioService[%d]",
7988 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndication == NULL", slotId);
7994 int radio::oemHookRawInd(int slotId,
7995 int indicationType, int token, RIL_Errno e, void *response,
7996 size_t responseLen) {
7997 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
7998 if (response == NULL || responseLen == 0) {
7999 RLOGE("oemHookRawInd: invalid response");
8003 hidl_vec<uint8_t> data;
8004 data.setToExternal((uint8_t *) response, responseLen);
8006 RLOGD("oemHookRawInd");
8008 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8009 convertIntToRadioIndicationType(indicationType), data);
8010 checkReturnStatus(slotId, retStatus, false);
8012 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8018 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8019 using namespace android::hardware;
8021 const char *serviceNames[] = {
8022 android::RIL_getServiceName()
8023 #if (SIM_COUNT >= 2)
8025 #if (SIM_COUNT >= 3)
8027 #if (SIM_COUNT >= 4)
8034 #if (SIM_COUNT >= 2)
8035 simCount = SIM_COUNT;
8038 configureRpcThreadpool(1, true /* callerWillJoin */);
8039 for (int i = 0; i < simCount; i++) {
8040 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8041 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8044 radioService[i] = new RadioImpl;
8045 radioService[i]->mSlotId = i;
8046 oemHookService[i] = new OemHookImpl;
8047 oemHookService[i]->mSlotId = i;
8048 RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
8050 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8051 status = oemHookService[i]->registerAsService(serviceNames[i]);
8053 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8057 s_vendorFunctions = callbacks;
8058 s_commands = commands;
8061 void rilc_thread_pool() {
8062 joinRpcThreadpool();
8065 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8066 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8068 #if (SIM_COUNT >= 2)
8069 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8070 #if (SIM_COUNT >= 3)
8071 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8072 #if (SIM_COUNT >= 4)
8073 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8078 return radioServiceRwlockPtr;