2 * Copyright (c) 2016 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #define LOG_TAG "RILC"
19 #include <android/hardware/radio/1.1/IRadio.h>
20 #include <android/hardware/radio/1.1/IRadioResponse.h>
21 #include <android/hardware/radio/1.1/IRadioIndication.h>
22 #include <android/hardware/radio/1.1/types.h>
24 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
26 #include <hwbinder/IPCThreadState.h>
27 #include <hwbinder/ProcessState.h>
28 #include <ril_service.h>
29 #include <hidl/HidlTransportSupport.h>
30 #include <utils/SystemClock.h>
33 #define INVALID_HEX_CHAR 16
35 using namespace android::hardware::radio::V1_0;
36 using namespace android::hardware::radio::deprecated::V1_0;
37 using ::android::hardware::configureRpcThreadpool;
38 using ::android::hardware::joinRpcThreadpool;
39 using ::android::hardware::Return;
40 using ::android::hardware::hidl_string;
41 using ::android::hardware::hidl_vec;
42 using ::android::hardware::hidl_array;
43 using ::android::hardware::Void;
44 using android::CommandInfo;
45 using android::RequestInfo;
46 using android::requestToString;
49 #define BOOL_TO_INT(x) (x ? 1 : 0)
50 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
51 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
53 RIL_RadioFunctions *s_vendorFunctions = NULL;
54 static CommandInfo *s_commands;
60 sp<RadioImpl> radioService[SIM_COUNT];
61 sp<OemHookImpl> oemHookService[SIM_COUNT];
62 // counter used for synchronization. It is incremented every time response callbacks are updated.
63 volatile int32_t mCounterRadio[SIM_COUNT];
64 volatile int32_t mCounterOemHook[SIM_COUNT];
66 sp<RadioImpl> radioService[1];
67 sp<OemHookImpl> oemHookService[1];
68 // counter used for synchronization. It is incremented every time response callbacks are updated.
69 volatile int32_t mCounterRadio[1];
70 volatile int32_t mCounterOemHook[1];
73 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
76 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
78 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
80 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
85 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
86 hidl_vec<HardwareConfig>& records);
88 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
90 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
92 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
93 SignalStrength& signalStrength);
95 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
96 SetupDataCallResult& dcResult);
98 void convertRilDataCallListToHal(void *response, size_t responseLen,
99 hidl_vec<SetupDataCallResult>& dcResultList);
101 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
103 struct RadioImpl : public ::android::hardware::radio::V1_1::IRadio {
105 sp<IRadioResponse> mRadioResponse;
106 sp<IRadioIndication> mRadioIndication;
108 Return<void> setResponseFunctions(
109 const ::android::sp<IRadioResponse>& radioResponse,
110 const ::android::sp<IRadioIndication>& radioIndication);
112 Return<void> getIccCardStatus(int32_t serial);
114 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
115 const hidl_string& aid);
117 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
118 const hidl_string& pin, const hidl_string& aid);
120 Return<void> supplyIccPin2ForApp(int32_t serial,
121 const hidl_string& pin2,
122 const hidl_string& aid);
124 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
125 const hidl_string& pin2, const hidl_string& aid);
127 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
128 const hidl_string& newPin, const hidl_string& aid);
130 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
131 const hidl_string& newPin2, const hidl_string& aid);
133 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
135 Return<void> getCurrentCalls(int32_t serial);
137 Return<void> dial(int32_t serial, const Dial& dialInfo);
139 Return<void> getImsiForApp(int32_t serial,
140 const ::android::hardware::hidl_string& aid);
142 Return<void> hangup(int32_t serial, int32_t gsmIndex);
144 Return<void> hangupWaitingOrBackground(int32_t serial);
146 Return<void> hangupForegroundResumeBackground(int32_t serial);
148 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
150 Return<void> conference(int32_t serial);
152 Return<void> rejectCall(int32_t serial);
154 Return<void> getLastCallFailCause(int32_t serial);
156 Return<void> getSignalStrength(int32_t serial);
158 Return<void> getVoiceRegistrationState(int32_t serial);
160 Return<void> getDataRegistrationState(int32_t serial);
162 Return<void> getOperator(int32_t serial);
164 Return<void> setRadioPower(int32_t serial, bool on);
166 Return<void> sendDtmf(int32_t serial,
167 const ::android::hardware::hidl_string& s);
169 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
171 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
173 Return<void> setupDataCall(int32_t serial,
174 RadioTechnology radioTechnology,
175 const DataProfileInfo& profileInfo,
180 Return<void> iccIOForApp(int32_t serial,
183 Return<void> sendUssd(int32_t serial,
184 const ::android::hardware::hidl_string& ussd);
186 Return<void> cancelPendingUssd(int32_t serial);
188 Return<void> getClir(int32_t serial);
190 Return<void> setClir(int32_t serial, int32_t status);
192 Return<void> getCallForwardStatus(int32_t serial,
193 const CallForwardInfo& callInfo);
195 Return<void> setCallForward(int32_t serial,
196 const CallForwardInfo& callInfo);
198 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
200 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
202 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
203 bool success, SmsAcknowledgeFailCause cause);
205 Return<void> acceptCall(int32_t serial);
207 Return<void> deactivateDataCall(int32_t serial,
208 int32_t cid, bool reasonRadioShutDown);
210 Return<void> getFacilityLockForApp(int32_t serial,
211 const ::android::hardware::hidl_string& facility,
212 const ::android::hardware::hidl_string& password,
213 int32_t serviceClass,
214 const ::android::hardware::hidl_string& appId);
216 Return<void> setFacilityLockForApp(int32_t serial,
217 const ::android::hardware::hidl_string& facility,
219 const ::android::hardware::hidl_string& password,
220 int32_t serviceClass,
221 const ::android::hardware::hidl_string& appId);
223 Return<void> setBarringPassword(int32_t serial,
224 const ::android::hardware::hidl_string& facility,
225 const ::android::hardware::hidl_string& oldPassword,
226 const ::android::hardware::hidl_string& newPassword);
228 Return<void> getNetworkSelectionMode(int32_t serial);
230 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
232 Return<void> setNetworkSelectionModeManual(int32_t serial,
233 const ::android::hardware::hidl_string& operatorNumeric);
235 Return<void> getAvailableNetworks(int32_t serial);
237 Return<void> startDtmf(int32_t serial,
238 const ::android::hardware::hidl_string& s);
240 Return<void> stopDtmf(int32_t serial);
242 Return<void> getBasebandVersion(int32_t serial);
244 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
246 Return<void> setMute(int32_t serial, bool enable);
248 Return<void> getMute(int32_t serial);
250 Return<void> getClip(int32_t serial);
252 Return<void> getDataCallList(int32_t serial);
254 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
256 Return<void> writeSmsToSim(int32_t serial,
257 const SmsWriteArgs& smsWriteArgs);
259 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
261 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
263 Return<void> getAvailableBandModes(int32_t serial);
265 Return<void> sendEnvelope(int32_t serial,
266 const ::android::hardware::hidl_string& command);
268 Return<void> sendTerminalResponseToSim(int32_t serial,
269 const ::android::hardware::hidl_string& commandResponse);
271 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
273 Return<void> explicitCallTransfer(int32_t serial);
275 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
277 Return<void> getPreferredNetworkType(int32_t serial);
279 Return<void> getNeighboringCids(int32_t serial);
281 Return<void> setLocationUpdates(int32_t serial, bool enable);
283 Return<void> setCdmaSubscriptionSource(int32_t serial,
284 CdmaSubscriptionSource cdmaSub);
286 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
288 Return<void> getCdmaRoamingPreference(int32_t serial);
290 Return<void> setTTYMode(int32_t serial, TtyMode mode);
292 Return<void> getTTYMode(int32_t serial);
294 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
296 Return<void> getPreferredVoicePrivacy(int32_t serial);
298 Return<void> sendCDMAFeatureCode(int32_t serial,
299 const ::android::hardware::hidl_string& featureCode);
301 Return<void> sendBurstDtmf(int32_t serial,
302 const ::android::hardware::hidl_string& dtmf,
306 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
308 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
309 const CdmaSmsAck& smsAck);
311 Return<void> getGsmBroadcastConfig(int32_t serial);
313 Return<void> setGsmBroadcastConfig(int32_t serial,
314 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
316 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
318 Return<void> getCdmaBroadcastConfig(int32_t serial);
320 Return<void> setCdmaBroadcastConfig(int32_t serial,
321 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
323 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
325 Return<void> getCDMASubscription(int32_t serial);
327 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
329 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
331 Return<void> getDeviceIdentity(int32_t serial);
333 Return<void> exitEmergencyCallbackMode(int32_t serial);
335 Return<void> getSmscAddress(int32_t serial);
337 Return<void> setSmscAddress(int32_t serial,
338 const ::android::hardware::hidl_string& smsc);
340 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
342 Return<void> reportStkServiceIsRunning(int32_t serial);
344 Return<void> getCdmaSubscriptionSource(int32_t serial);
346 Return<void> requestIsimAuthentication(int32_t serial,
347 const ::android::hardware::hidl_string& challenge);
349 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
351 const ::android::hardware::hidl_string& ackPdu);
353 Return<void> sendEnvelopeWithStatus(int32_t serial,
354 const ::android::hardware::hidl_string& contents);
356 Return<void> getVoiceRadioTechnology(int32_t serial);
358 Return<void> getCellInfoList(int32_t serial);
360 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
362 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
363 bool modemCognitive, bool isRoaming);
365 Return<void> getImsRegistrationState(int32_t serial);
367 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
369 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
371 Return<void> iccOpenLogicalChannel(int32_t serial,
372 const ::android::hardware::hidl_string& aid, int32_t p2);
374 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
376 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
378 Return<void> nvReadItem(int32_t serial, NvItem itemId);
380 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
382 Return<void> nvWriteCdmaPrl(int32_t serial,
383 const ::android::hardware::hidl_vec<uint8_t>& prl);
385 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
387 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
389 Return<void> setDataAllowed(int32_t serial, bool allow);
391 Return<void> getHardwareConfig(int32_t serial);
393 Return<void> requestIccSimAuthentication(int32_t serial,
395 const ::android::hardware::hidl_string& authData,
396 const ::android::hardware::hidl_string& aid);
398 Return<void> setDataProfile(int32_t serial,
399 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
401 Return<void> requestShutdown(int32_t serial);
403 Return<void> getRadioCapability(int32_t serial);
405 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
407 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
409 Return<void> stopLceService(int32_t serial);
411 Return<void> pullLceData(int32_t serial);
413 Return<void> getModemActivityInfo(int32_t serial);
415 Return<void> setAllowedCarriers(int32_t serial,
417 const CarrierRestrictions& carriers);
419 Return<void> getAllowedCarriers(int32_t serial);
421 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
423 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
425 Return<void> setSimCardPower(int32_t serial, bool powerUp);
426 Return<void> setSimCardPower_1_1(int32_t serial,
427 const ::android::hardware::radio::V1_1::CardPowerState state);
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) {
2187 int rilResetType = -1;
2189 RLOGD("nvResetConfig: serial %d", serial);
2191 /* Convert ResetNvType to RIL.h values
2192 * RIL_REQUEST_NV_RESET_CONFIG
2193 * 1 - reload all NV items
2194 * 2 - erase NV reset (SCRTN)
2195 * 3 - factory reset (RTN)
2198 case ResetNvType::RELOAD:
2201 case ResetNvType::ERASE:
2204 case ResetNvType::FACTORY_RESET:
2208 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2212 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2214 RLOGD("setUiccSubscription: serial %d", serial);
2216 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2217 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2222 RIL_SelectUiccSub rilUiccSub = {};
2224 rilUiccSub.slot = uiccSub.slot;
2225 rilUiccSub.app_index = uiccSub.appIndex;
2226 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2227 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2229 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI);
2233 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2235 RLOGD("setDataAllowed: serial %d", serial);
2237 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2241 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2243 RLOGD("getHardwareConfig: serial %d", serial);
2245 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2249 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2250 const hidl_string& authData, const hidl_string& aid) {
2252 RLOGD("requestIccSimAuthentication: serial %d", serial);
2254 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2259 RIL_SimAuthentication pf = {};
2261 pf.authContext = authContext;
2264 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2268 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2269 memsetAndFreeStrings(1, pf.authData);
2273 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI);
2275 memsetAndFreeStrings(2, pf.authData, pf.aid);
2280 * @param numProfiles number of data profile
2281 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2282 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2283 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2284 * @param numfields number of string-type member in the data profile structure
2285 * @param ... the variadic parameters are pointers to each string-type member
2287 template <typename T>
2288 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2289 int numfields, ...) {
2291 va_start(args, numfields);
2293 // Iterate through each string-type field that need to be free.
2294 for (int i = 0; i < numfields; i++) {
2295 // Iterate through each data profile and free that specific string-type field.
2296 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2297 char *T::*ptr = va_arg(args, char *T::*);
2298 for (int j = 0; j < numProfiles; j++) {
2299 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2306 memset(dataProfiles, 0, numProfiles * sizeof(T));
2307 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2310 free(dataProfilePtrs);
2313 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2316 RLOGD("setDataProfile: serial %d", serial);
2318 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2323 size_t num = profiles.size();
2324 bool success = false;
2326 if (s_vendorFunctions->version <= 14) {
2328 RIL_DataProfileInfo *dataProfiles =
2329 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2331 if (dataProfiles == NULL) {
2332 RLOGE("Memory allocation failed for request %s",
2333 requestToString(pRI->pCI->requestNumber));
2334 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2338 RIL_DataProfileInfo **dataProfilePtrs =
2339 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2340 if (dataProfilePtrs == NULL) {
2341 RLOGE("Memory allocation failed for request %s",
2342 requestToString(pRI->pCI->requestNumber));
2344 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2348 for (size_t i = 0; i < num; i++) {
2349 dataProfilePtrs[i] = &dataProfiles[i];
2351 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2353 const hidl_string &protocol =
2354 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2356 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2360 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2363 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2369 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2370 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2371 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2375 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2376 dataProfiles[i].authType = (int) profiles[i].authType;
2377 dataProfiles[i].type = (int) profiles[i].type;
2378 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2379 dataProfiles[i].maxConns = profiles[i].maxConns;
2380 dataProfiles[i].waitTime = profiles[i].waitTime;
2381 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2384 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2385 num * sizeof(RIL_DataProfileInfo *), pRI);
2387 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2388 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2389 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2391 RIL_DataProfileInfo_v15 *dataProfiles =
2392 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2394 if (dataProfiles == NULL) {
2395 RLOGE("Memory allocation failed for request %s",
2396 requestToString(pRI->pCI->requestNumber));
2397 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2401 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2402 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2403 if (dataProfilePtrs == NULL) {
2404 RLOGE("Memory allocation failed for request %s",
2405 requestToString(pRI->pCI->requestNumber));
2407 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2411 for (size_t i = 0; i < num; i++) {
2412 dataProfilePtrs[i] = &dataProfiles[i];
2414 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2415 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2419 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2420 profiles[i].roamingProtocol, pRI)) {
2423 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2426 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2431 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2432 profiles[i].mvnoMatchData, pRI)) {
2436 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2437 dataProfiles[i].mvnoType)) {
2438 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2443 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2444 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2445 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2446 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2450 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2451 dataProfiles[i].authType = (int) profiles[i].authType;
2452 dataProfiles[i].type = (int) profiles[i].type;
2453 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2454 dataProfiles[i].maxConns = profiles[i].maxConns;
2455 dataProfiles[i].waitTime = profiles[i].waitTime;
2456 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2457 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2458 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2459 dataProfiles[i].mtu = profiles[i].mtu;
2462 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2463 num * sizeof(RIL_DataProfileInfo_v15 *), pRI);
2465 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2466 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2467 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2468 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2474 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2476 RLOGD("requestShutdown: serial %d", serial);
2478 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2482 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2484 RLOGD("getRadioCapability: serial %d", serial);
2486 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2490 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2492 RLOGD("setRadioCapability: serial %d", serial);
2494 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2499 RIL_RadioCapability rilRc = {};
2501 // TODO : set rilRc.version using HIDL version ?
2502 rilRc.session = rc.session;
2503 rilRc.phase = (int) rc.phase;
2504 rilRc.rat = (int) rc.raf;
2505 rilRc.status = (int) rc.status;
2506 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2508 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI);
2513 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2515 RLOGD("startLceService: serial %d", serial);
2517 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2518 BOOL_TO_INT(pullMode));
2522 Return<void> RadioImpl::stopLceService(int32_t serial) {
2524 RLOGD("stopLceService: serial %d", serial);
2526 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2530 Return<void> RadioImpl::pullLceData(int32_t serial) {
2532 RLOGD("pullLceData: serial %d", serial);
2534 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2538 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2540 RLOGD("getModemActivityInfo: serial %d", serial);
2542 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2546 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2547 const CarrierRestrictions& carriers) {
2549 RLOGD("setAllowedCarriers: serial %d", serial);
2551 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2552 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2557 RIL_CarrierRestrictions cr = {};
2558 RIL_Carrier *allowedCarriers = NULL;
2559 RIL_Carrier *excludedCarriers = NULL;
2561 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2562 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2563 if (allowedCarriers == NULL) {
2564 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2565 requestToString(pRI->pCI->requestNumber));
2566 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2569 cr.allowed_carriers = allowedCarriers;
2571 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2572 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2573 if (excludedCarriers == NULL) {
2574 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2575 requestToString(pRI->pCI->requestNumber));
2576 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2578 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2580 free(allowedCarriers);
2583 cr.excluded_carriers = excludedCarriers;
2585 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2586 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2587 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2588 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2589 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2592 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2593 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2594 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2595 excludedCarriers[i].match_type =
2596 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2597 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2600 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI);
2603 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2604 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2606 free(allowedCarriers);
2607 free(excludedCarriers);
2611 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2613 RLOGD("getAllowedCarriers: serial %d", serial);
2615 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2619 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2622 RLOGD("sendDeviceState: serial %d", serial);
2624 if (s_vendorFunctions->version < 15) {
2625 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2626 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2627 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2629 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2630 RIL_REQUEST_SEND_DEVICE_STATE);
2631 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2635 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2636 BOOL_TO_INT(state));
2640 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2642 RLOGD("setIndicationFilter: serial %d", serial);
2644 if (s_vendorFunctions->version < 15) {
2645 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2646 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2647 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2650 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2654 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2656 RLOGD("setSimCardPower: serial %d", serial);
2658 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2662 Return<void> RadioImpl::setSimCardPower_1_1(int32_t serial,
2663 const ::android::hardware::radio::V1_1::CardPowerState state) {
2665 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
2667 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
2671 Return<void> RadioImpl::responseAcknowledgement() {
2672 android::releaseWakeLock();
2676 Return<void> OemHookImpl::setResponseFunctions(
2677 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2678 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2680 RLOGD("OemHookImpl::setResponseFunctions");
2683 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2684 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2687 mOemHookResponse = oemHookResponseParam;
2688 mOemHookIndication = oemHookIndicationParam;
2689 mCounterOemHook[mSlotId]++;
2691 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2697 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2699 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2701 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2705 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2706 const hidl_vec<hidl_string>& data) {
2708 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2710 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2714 Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial,
2715 const ::android::hardware::hidl_vec<uint8_t>& carrierKey,
2716 const hidl_string& keyIdentifier) {
2717 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
2718 dispatchRaw(serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION, carrierKey);
2722 /***************************************************************************************************
2723 * RESPONSE FUNCTIONS
2724 * Functions above are used for requests going from framework to vendor code. The ones below are
2725 * responses for those requests coming back from the vendor code.
2726 **************************************************************************************************/
2728 void radio::acknowledgeRequest(int slotId, int serial) {
2729 if (radioService[slotId]->mRadioResponse != NULL) {
2730 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2731 radioService[slotId]->checkReturnStatus(retStatus);
2733 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2737 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2739 responseInfo.serial = serial;
2740 switch (responseType) {
2741 case RESPONSE_SOLICITED:
2742 responseInfo.type = RadioResponseType::SOLICITED;
2744 case RESPONSE_SOLICITED_ACK_EXP:
2745 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2748 responseInfo.error = (RadioError) e;
2751 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2752 void *response, size_t responseLen) {
2753 populateResponseInfo(responseInfo, serial, responseType, e);
2756 if (response == NULL && responseLen == 0) {
2757 // Earlier RILs did not send a response for some cases although the interface
2758 // expected an integer as response. Do not return error if response is empty. Instead
2759 // Return -1 in those cases to maintain backward compatibility.
2760 } else if (response == NULL || responseLen != sizeof(int)) {
2761 RLOGE("responseIntOrEmpty: Invalid response");
2762 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2764 int *p_int = (int *) response;
2770 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2771 void *response, size_t responseLen) {
2772 populateResponseInfo(responseInfo, serial, responseType, e);
2775 if (response == NULL || responseLen != sizeof(int)) {
2776 RLOGE("responseInt: Invalid response");
2777 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2779 int *p_int = (int *) response;
2785 int radio::getIccCardStatusResponse(int slotId,
2786 int responseType, int serial, RIL_Errno e,
2787 void *response, size_t responseLen) {
2788 if (radioService[slotId]->mRadioResponse != NULL) {
2789 RadioResponseInfo responseInfo = {};
2790 populateResponseInfo(responseInfo, serial, responseType, e);
2791 CardStatus cardStatus = {};
2792 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2793 RLOGE("getIccCardStatusResponse: Invalid response");
2794 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2796 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2797 cardStatus.cardState = (CardState) p_cur->card_state;
2798 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2799 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2800 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2801 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2803 RIL_AppStatus *rilAppStatus = p_cur->applications;
2804 cardStatus.applications.resize(p_cur->num_applications);
2805 AppStatus *appStatus = cardStatus.applications.data();
2807 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2809 for (int i = 0; i < p_cur->num_applications; i++) {
2810 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2811 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2812 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2813 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2814 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2815 rilAppStatus[i].app_label_ptr);
2816 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2817 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2818 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2822 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2823 getIccCardStatusResponse(responseInfo, cardStatus);
2824 radioService[slotId]->checkReturnStatus(retStatus);
2826 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2832 int radio::supplyIccPinForAppResponse(int slotId,
2833 int responseType, int serial, RIL_Errno e,
2834 void *response, size_t responseLen) {
2836 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
2839 if (radioService[slotId]->mRadioResponse != NULL) {
2840 RadioResponseInfo responseInfo = {};
2841 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2842 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2843 supplyIccPinForAppResponse(responseInfo, ret);
2844 radioService[slotId]->checkReturnStatus(retStatus);
2846 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2853 int radio::supplyIccPukForAppResponse(int slotId,
2854 int responseType, int serial, RIL_Errno e,
2855 void *response, size_t responseLen) {
2857 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
2860 if (radioService[slotId]->mRadioResponse != NULL) {
2861 RadioResponseInfo responseInfo = {};
2862 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2863 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2865 radioService[slotId]->checkReturnStatus(retStatus);
2867 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2874 int radio::supplyIccPin2ForAppResponse(int slotId,
2875 int responseType, int serial, RIL_Errno e,
2876 void *response, size_t responseLen) {
2878 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
2881 if (radioService[slotId]->mRadioResponse != NULL) {
2882 RadioResponseInfo responseInfo = {};
2883 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2884 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2885 supplyIccPin2ForAppResponse(responseInfo, ret);
2886 radioService[slotId]->checkReturnStatus(retStatus);
2888 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2895 int radio::supplyIccPuk2ForAppResponse(int slotId,
2896 int responseType, int serial, RIL_Errno e,
2897 void *response, size_t responseLen) {
2899 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
2902 if (radioService[slotId]->mRadioResponse != NULL) {
2903 RadioResponseInfo responseInfo = {};
2904 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2905 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2906 supplyIccPuk2ForAppResponse(responseInfo, ret);
2907 radioService[slotId]->checkReturnStatus(retStatus);
2909 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2916 int radio::changeIccPinForAppResponse(int slotId,
2917 int responseType, int serial, RIL_Errno e,
2918 void *response, size_t responseLen) {
2920 RLOGD("changeIccPinForAppResponse: serial %d", serial);
2923 if (radioService[slotId]->mRadioResponse != NULL) {
2924 RadioResponseInfo responseInfo = {};
2925 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2926 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2927 changeIccPinForAppResponse(responseInfo, ret);
2928 radioService[slotId]->checkReturnStatus(retStatus);
2930 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2937 int radio::changeIccPin2ForAppResponse(int slotId,
2938 int responseType, int serial, RIL_Errno e,
2939 void *response, size_t responseLen) {
2941 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
2944 if (radioService[slotId]->mRadioResponse != NULL) {
2945 RadioResponseInfo responseInfo = {};
2946 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2947 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2948 changeIccPin2ForAppResponse(responseInfo, ret);
2949 radioService[slotId]->checkReturnStatus(retStatus);
2951 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
2958 int radio::supplyNetworkDepersonalizationResponse(int slotId,
2959 int responseType, int serial, RIL_Errno e,
2960 void *response, size_t responseLen) {
2962 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
2965 if (radioService[slotId]->mRadioResponse != NULL) {
2966 RadioResponseInfo responseInfo = {};
2967 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2968 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2969 supplyNetworkDepersonalizationResponse(responseInfo, ret);
2970 radioService[slotId]->checkReturnStatus(retStatus);
2972 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
2979 int radio::getCurrentCallsResponse(int slotId,
2980 int responseType, int serial, RIL_Errno e,
2981 void *response, size_t responseLen) {
2983 RLOGD("getCurrentCallsResponse: serial %d", serial);
2986 if (radioService[slotId]->mRadioResponse != NULL) {
2987 RadioResponseInfo responseInfo = {};
2988 populateResponseInfo(responseInfo, serial, responseType, e);
2990 hidl_vec<Call> calls;
2991 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) {
2992 RLOGE("getCurrentCallsResponse: Invalid response");
2993 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2995 int num = responseLen / sizeof(RIL_Call *);
2998 for (int i = 0 ; i < num ; i++) {
2999 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3000 /* each call info */
3001 calls[i].state = (CallState) p_cur->state;
3002 calls[i].index = p_cur->index;
3003 calls[i].toa = p_cur->toa;
3004 calls[i].isMpty = p_cur->isMpty;
3005 calls[i].isMT = p_cur->isMT;
3006 calls[i].als = p_cur->als;
3007 calls[i].isVoice = p_cur->isVoice;
3008 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3009 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3010 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3011 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3012 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3013 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3014 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3015 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3016 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3017 // convert uusInfo->uusData to a null-terminated string
3018 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3019 calls[i].uusInfo[0].uusData = nullTermStr;
3025 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3026 getCurrentCallsResponse(responseInfo, calls);
3027 radioService[slotId]->checkReturnStatus(retStatus);
3029 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3035 int radio::dialResponse(int slotId,
3036 int responseType, int serial, RIL_Errno e, void *response,
3037 size_t responseLen) {
3039 RLOGD("dialResponse: serial %d", serial);
3042 if (radioService[slotId]->mRadioResponse != NULL) {
3043 RadioResponseInfo responseInfo = {};
3044 populateResponseInfo(responseInfo, serial, responseType, e);
3045 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3046 radioService[slotId]->checkReturnStatus(retStatus);
3048 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3054 int radio::getIMSIForAppResponse(int slotId,
3055 int responseType, int serial, RIL_Errno e, void *response,
3056 size_t responseLen) {
3058 RLOGD("getIMSIForAppResponse: serial %d", serial);
3061 if (radioService[slotId]->mRadioResponse != NULL) {
3062 RadioResponseInfo responseInfo = {};
3063 populateResponseInfo(responseInfo, serial, responseType, e);
3064 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3065 responseInfo, convertCharPtrToHidlString((char *) response));
3066 radioService[slotId]->checkReturnStatus(retStatus);
3068 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3075 int radio::hangupConnectionResponse(int slotId,
3076 int responseType, int serial, RIL_Errno e,
3077 void *response, size_t responseLen) {
3079 RLOGD("hangupConnectionResponse: serial %d", serial);
3082 if (radioService[slotId]->mRadioResponse != NULL) {
3083 RadioResponseInfo responseInfo = {};
3084 populateResponseInfo(responseInfo, serial, responseType, e);
3085 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3087 radioService[slotId]->checkReturnStatus(retStatus);
3089 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3096 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3097 int responseType, int serial, RIL_Errno e,
3098 void *response, size_t responseLen) {
3100 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3103 if (radioService[slotId]->mRadioResponse != NULL) {
3104 RadioResponseInfo responseInfo = {};
3105 populateResponseInfo(responseInfo, serial, responseType, e);
3106 Return<void> retStatus =
3107 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3109 radioService[slotId]->checkReturnStatus(retStatus);
3111 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3118 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3119 RIL_Errno e, void *response,
3120 size_t responseLen) {
3122 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3125 if (radioService[slotId]->mRadioResponse != NULL) {
3126 RadioResponseInfo responseInfo = {};
3127 populateResponseInfo(responseInfo, serial, responseType, e);
3128 Return<void> retStatus =
3129 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3131 radioService[slotId]->checkReturnStatus(retStatus);
3133 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3140 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3141 RIL_Errno e, void *response,
3142 size_t responseLen) {
3144 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3147 if (radioService[slotId]->mRadioResponse != NULL) {
3148 RadioResponseInfo responseInfo = {};
3149 populateResponseInfo(responseInfo, serial, responseType, e);
3150 Return<void> retStatus =
3151 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3153 radioService[slotId]->checkReturnStatus(retStatus);
3155 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3162 int radio::conferenceResponse(int slotId, int responseType,
3163 int serial, RIL_Errno e, void *response, size_t responseLen) {
3165 RLOGD("conferenceResponse: serial %d", serial);
3168 if (radioService[slotId]->mRadioResponse != NULL) {
3169 RadioResponseInfo responseInfo = {};
3170 populateResponseInfo(responseInfo, serial, responseType, e);
3171 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3173 radioService[slotId]->checkReturnStatus(retStatus);
3175 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3182 int radio::rejectCallResponse(int slotId, int responseType,
3183 int serial, RIL_Errno e, void *response, size_t responseLen) {
3185 RLOGD("rejectCallResponse: serial %d", serial);
3188 if (radioService[slotId]->mRadioResponse != NULL) {
3189 RadioResponseInfo responseInfo = {};
3190 populateResponseInfo(responseInfo, serial, responseType, e);
3191 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3193 radioService[slotId]->checkReturnStatus(retStatus);
3195 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3202 int radio::getLastCallFailCauseResponse(int slotId,
3203 int responseType, int serial, RIL_Errno e, void *response,
3204 size_t responseLen) {
3206 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3209 if (radioService[slotId]->mRadioResponse != NULL) {
3210 RadioResponseInfo responseInfo = {};
3211 populateResponseInfo(responseInfo, serial, responseType, e);
3213 LastCallFailCauseInfo info = {};
3214 info.vendorCause = hidl_string();
3215 if (response == NULL) {
3216 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3217 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3218 } else if (responseLen == sizeof(int)) {
3219 int *pInt = (int *) response;
3220 info.causeCode = (LastCallFailCause) pInt[0];
3221 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3222 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3223 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3224 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3226 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3227 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3230 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3231 responseInfo, info);
3232 radioService[slotId]->checkReturnStatus(retStatus);
3234 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3241 int radio::getSignalStrengthResponse(int slotId,
3242 int responseType, int serial, RIL_Errno e,
3243 void *response, size_t responseLen) {
3245 RLOGD("getSignalStrengthResponse: serial %d", serial);
3248 if (radioService[slotId]->mRadioResponse != NULL) {
3249 RadioResponseInfo responseInfo = {};
3250 populateResponseInfo(responseInfo, serial, responseType, e);
3251 SignalStrength signalStrength = {};
3252 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3253 RLOGE("getSignalStrengthResponse: Invalid response");
3254 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3256 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3259 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3260 responseInfo, signalStrength);
3261 radioService[slotId]->checkReturnStatus(retStatus);
3263 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3270 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3272 return RIL_CELL_INFO_TYPE_NONE;
3275 int radioTech = atoi(rat);
3279 case RADIO_TECH_GPRS:
3280 case RADIO_TECH_EDGE:
3281 case RADIO_TECH_GSM: {
3282 return RIL_CELL_INFO_TYPE_GSM;
3285 case RADIO_TECH_UMTS:
3286 case RADIO_TECH_HSDPA:
3287 case RADIO_TECH_HSUPA:
3288 case RADIO_TECH_HSPA:
3289 case RADIO_TECH_HSPAP: {
3290 return RIL_CELL_INFO_TYPE_WCDMA;
3293 case RADIO_TECH_IS95A:
3294 case RADIO_TECH_IS95B:
3295 case RADIO_TECH_1xRTT:
3296 case RADIO_TECH_EVDO_0:
3297 case RADIO_TECH_EVDO_A:
3298 case RADIO_TECH_EVDO_B:
3299 case RADIO_TECH_EHRPD: {
3300 return RIL_CELL_INFO_TYPE_CDMA;
3303 case RADIO_TECH_LTE:
3304 case RADIO_TECH_LTE_CA: {
3305 return RIL_CELL_INFO_TYPE_LTE;
3308 case RADIO_TECH_TD_SCDMA: {
3309 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3317 return RIL_CELL_INFO_TYPE_NONE;
3321 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3323 cellIdentity.cellIdentityGsm.resize(0);
3324 cellIdentity.cellIdentityWcdma.resize(0);
3325 cellIdentity.cellIdentityCdma.resize(0);
3326 cellIdentity.cellIdentityTdscdma.resize(0);
3327 cellIdentity.cellIdentityLte.resize(0);
3328 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3329 switch(rilCellIdentity.cellInfoType) {
3331 case RIL_CELL_INFO_TYPE_GSM: {
3332 cellIdentity.cellIdentityGsm.resize(1);
3333 cellIdentity.cellIdentityGsm[0].mcc =
3334 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3335 cellIdentity.cellIdentityGsm[0].mnc =
3336 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3337 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3338 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3339 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3340 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3344 case RIL_CELL_INFO_TYPE_WCDMA: {
3345 cellIdentity.cellIdentityWcdma.resize(1);
3346 cellIdentity.cellIdentityWcdma[0].mcc =
3347 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3348 cellIdentity.cellIdentityWcdma[0].mnc =
3349 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3350 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3351 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3352 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3353 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3357 case RIL_CELL_INFO_TYPE_CDMA: {
3358 cellIdentity.cellIdentityCdma.resize(1);
3359 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3360 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3361 cellIdentity.cellIdentityCdma[0].baseStationId =
3362 rilCellIdentity.cellIdentityCdma.basestationId;
3363 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3364 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3368 case RIL_CELL_INFO_TYPE_LTE: {
3369 cellIdentity.cellIdentityLte.resize(1);
3370 cellIdentity.cellIdentityLte[0].mcc =
3371 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3372 cellIdentity.cellIdentityLte[0].mnc =
3373 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3374 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3375 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3376 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3377 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3381 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3382 cellIdentity.cellIdentityTdscdma.resize(1);
3383 cellIdentity.cellIdentityTdscdma[0].mcc =
3384 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3385 cellIdentity.cellIdentityTdscdma[0].mnc =
3386 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3387 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3388 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3389 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3399 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3400 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3401 return atoi(response[index]);
3407 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3408 int numStrings, char** response) {
3410 RIL_CellIdentity_v16 rilCellIdentity;
3411 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3413 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3414 switch(rilCellIdentity.cellInfoType) {
3416 case RIL_CELL_INFO_TYPE_GSM: {
3417 rilCellIdentity.cellIdentityGsm.lac =
3418 convertResponseStringEntryToInt(response, 1, numStrings);
3419 rilCellIdentity.cellIdentityGsm.cid =
3420 convertResponseStringEntryToInt(response, 2, numStrings);
3424 case RIL_CELL_INFO_TYPE_WCDMA: {
3425 rilCellIdentity.cellIdentityWcdma.lac =
3426 convertResponseStringEntryToInt(response, 1, numStrings);
3427 rilCellIdentity.cellIdentityWcdma.cid =
3428 convertResponseStringEntryToInt(response, 2, numStrings);
3429 rilCellIdentity.cellIdentityWcdma.psc =
3430 convertResponseStringEntryToInt(response, 14, numStrings);
3434 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3435 rilCellIdentity.cellIdentityTdscdma.lac =
3436 convertResponseStringEntryToInt(response, 1, numStrings);
3437 rilCellIdentity.cellIdentityTdscdma.cid =
3438 convertResponseStringEntryToInt(response, 2, numStrings);
3442 case RIL_CELL_INFO_TYPE_CDMA:{
3443 rilCellIdentity.cellIdentityCdma.basestationId =
3444 convertResponseStringEntryToInt(response, 4, numStrings);
3445 rilCellIdentity.cellIdentityCdma.longitude =
3446 convertResponseStringEntryToInt(response, 5, numStrings);
3447 rilCellIdentity.cellIdentityCdma.latitude =
3448 convertResponseStringEntryToInt(response, 6, numStrings);
3449 rilCellIdentity.cellIdentityCdma.systemId =
3450 convertResponseStringEntryToInt(response, 8, numStrings);
3451 rilCellIdentity.cellIdentityCdma.networkId =
3452 convertResponseStringEntryToInt(response, 9, numStrings);
3456 case RIL_CELL_INFO_TYPE_LTE:{
3457 rilCellIdentity.cellIdentityLte.tac =
3458 convertResponseStringEntryToInt(response, 1, numStrings);
3459 rilCellIdentity.cellIdentityLte.ci =
3460 convertResponseStringEntryToInt(response, 2, numStrings);
3469 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3472 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3473 int numStrings, char** response) {
3475 RIL_CellIdentity_v16 rilCellIdentity;
3476 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3478 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3479 switch(rilCellIdentity.cellInfoType) {
3480 case RIL_CELL_INFO_TYPE_GSM: {
3481 rilCellIdentity.cellIdentityGsm.lac =
3482 convertResponseStringEntryToInt(response, 1, numStrings);
3483 rilCellIdentity.cellIdentityGsm.cid =
3484 convertResponseStringEntryToInt(response, 2, numStrings);
3487 case RIL_CELL_INFO_TYPE_WCDMA: {
3488 rilCellIdentity.cellIdentityWcdma.lac =
3489 convertResponseStringEntryToInt(response, 1, numStrings);
3490 rilCellIdentity.cellIdentityWcdma.cid =
3491 convertResponseStringEntryToInt(response, 2, numStrings);
3494 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3495 rilCellIdentity.cellIdentityTdscdma.lac =
3496 convertResponseStringEntryToInt(response, 1, numStrings);
3497 rilCellIdentity.cellIdentityTdscdma.cid =
3498 convertResponseStringEntryToInt(response, 2, numStrings);
3501 case RIL_CELL_INFO_TYPE_LTE: {
3502 rilCellIdentity.cellIdentityLte.tac =
3503 convertResponseStringEntryToInt(response, 6, numStrings);
3504 rilCellIdentity.cellIdentityLte.pci =
3505 convertResponseStringEntryToInt(response, 7, numStrings);
3506 rilCellIdentity.cellIdentityLte.ci =
3507 convertResponseStringEntryToInt(response, 8, numStrings);
3515 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3518 int radio::getVoiceRegistrationStateResponse(int slotId,
3519 int responseType, int serial, RIL_Errno e,
3520 void *response, size_t responseLen) {
3522 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3525 if (radioService[slotId]->mRadioResponse != NULL) {
3526 RadioResponseInfo responseInfo = {};
3527 populateResponseInfo(responseInfo, serial, responseType, e);
3529 VoiceRegStateResult voiceRegResponse = {};
3530 int numStrings = responseLen / sizeof(char *);
3531 if (response == NULL) {
3532 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3533 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3534 } else if (s_vendorFunctions->version <= 14) {
3535 if (numStrings != 15) {
3536 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3537 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3539 char **resp = (char **) response;
3540 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3541 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3542 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3543 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3544 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3545 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3546 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3547 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3551 RIL_VoiceRegistrationStateResponse *voiceRegState =
3552 (RIL_VoiceRegistrationStateResponse *)response;
3554 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3555 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3556 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3558 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3559 voiceRegResponse.rat = voiceRegState->rat;;
3560 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3561 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3562 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3563 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3564 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3565 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3566 voiceRegState->cellIdentity);
3570 Return<void> retStatus =
3571 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3572 responseInfo, voiceRegResponse);
3573 radioService[slotId]->checkReturnStatus(retStatus);
3575 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3582 int radio::getDataRegistrationStateResponse(int slotId,
3583 int responseType, int serial, RIL_Errno e,
3584 void *response, size_t responseLen) {
3586 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3589 if (radioService[slotId]->mRadioResponse != NULL) {
3590 RadioResponseInfo responseInfo = {};
3591 populateResponseInfo(responseInfo, serial, responseType, e);
3592 DataRegStateResult dataRegResponse = {};
3593 if (response == NULL) {
3594 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3595 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3596 } else if (s_vendorFunctions->version <= 14) {
3597 int numStrings = responseLen / sizeof(char *);
3598 if ((numStrings != 6) && (numStrings != 11)) {
3599 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3600 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3602 char **resp = (char **) response;
3603 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3604 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3605 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3606 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3607 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3611 RIL_DataRegistrationStateResponse *dataRegState =
3612 (RIL_DataRegistrationStateResponse *)response;
3614 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3615 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3616 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3618 dataRegResponse.regState = (RegState) dataRegState->regState;
3619 dataRegResponse.rat = dataRegState->rat;;
3620 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3621 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3622 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3626 Return<void> retStatus =
3627 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3629 radioService[slotId]->checkReturnStatus(retStatus);
3631 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3638 int radio::getOperatorResponse(int slotId,
3639 int responseType, int serial, RIL_Errno e, void *response,
3640 size_t responseLen) {
3642 RLOGD("getOperatorResponse: serial %d", serial);
3645 if (radioService[slotId]->mRadioResponse != NULL) {
3646 RadioResponseInfo responseInfo = {};
3647 populateResponseInfo(responseInfo, serial, responseType, e);
3648 hidl_string longName;
3649 hidl_string shortName;
3650 hidl_string numeric;
3651 int numStrings = responseLen / sizeof(char *);
3652 if (response == NULL || numStrings != 3) {
3653 RLOGE("getOperatorResponse Invalid response: NULL");
3654 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3657 char **resp = (char **) response;
3658 longName = convertCharPtrToHidlString(resp[0]);
3659 shortName = convertCharPtrToHidlString(resp[1]);
3660 numeric = convertCharPtrToHidlString(resp[2]);
3662 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3663 responseInfo, longName, shortName, numeric);
3664 radioService[slotId]->checkReturnStatus(retStatus);
3666 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3673 int radio::setRadioPowerResponse(int slotId,
3674 int responseType, int serial, RIL_Errno e, void *response,
3675 size_t responseLen) {
3676 RLOGD("setRadioPowerResponse: serial %d", serial);
3678 if (radioService[slotId]->mRadioResponse != NULL) {
3679 RadioResponseInfo responseInfo = {};
3680 populateResponseInfo(responseInfo, serial, responseType, e);
3681 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3683 radioService[slotId]->checkReturnStatus(retStatus);
3685 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3692 int radio::sendDtmfResponse(int slotId,
3693 int responseType, int serial, RIL_Errno e, void *response,
3694 size_t responseLen) {
3696 RLOGD("sendDtmfResponse: serial %d", serial);
3699 if (radioService[slotId]->mRadioResponse != NULL) {
3700 RadioResponseInfo responseInfo = {};
3701 populateResponseInfo(responseInfo, serial, responseType, e);
3702 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3704 radioService[slotId]->checkReturnStatus(retStatus);
3706 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3713 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3714 RIL_Errno e, void *response, size_t responseLen) {
3715 populateResponseInfo(responseInfo, serial, responseType, e);
3716 SendSmsResult result = {};
3718 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3719 RLOGE("Invalid response: NULL");
3720 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3721 result.ackPDU = hidl_string();
3723 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3724 result.messageRef = resp->messageRef;
3725 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3726 result.errorCode = resp->errorCode;
3731 int radio::sendSmsResponse(int slotId,
3732 int responseType, int serial, RIL_Errno e, void *response,
3733 size_t responseLen) {
3735 RLOGD("sendSmsResponse: serial %d", serial);
3738 if (radioService[slotId]->mRadioResponse != NULL) {
3739 RadioResponseInfo responseInfo = {};
3740 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3743 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3745 radioService[slotId]->checkReturnStatus(retStatus);
3747 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3753 int radio::sendSMSExpectMoreResponse(int slotId,
3754 int responseType, int serial, RIL_Errno e, void *response,
3755 size_t responseLen) {
3757 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3760 if (radioService[slotId]->mRadioResponse != NULL) {
3761 RadioResponseInfo responseInfo = {};
3762 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3765 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3766 responseInfo, result);
3767 radioService[slotId]->checkReturnStatus(retStatus);
3769 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3775 int radio::setupDataCallResponse(int slotId,
3776 int responseType, int serial, RIL_Errno e, void *response,
3777 size_t responseLen) {
3779 RLOGD("setupDataCallResponse: serial %d", serial);
3782 if (radioService[slotId]->mRadioResponse != NULL) {
3783 RadioResponseInfo responseInfo = {};
3784 populateResponseInfo(responseInfo, serial, responseType, e);
3786 SetupDataCallResult result = {};
3787 if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) {
3788 RLOGE("setupDataCallResponse: Invalid response");
3789 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3790 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3791 result.type = hidl_string();
3792 result.ifname = hidl_string();
3793 result.addresses = hidl_string();
3794 result.dnses = hidl_string();
3795 result.gateways = hidl_string();
3796 result.pcscf = hidl_string();
3798 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3801 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3802 responseInfo, result);
3803 radioService[slotId]->checkReturnStatus(retStatus);
3805 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3811 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3812 RIL_Errno e, void *response, size_t responseLen) {
3813 populateResponseInfo(responseInfo, serial, responseType, e);
3814 IccIoResult result = {};
3816 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3817 RLOGE("Invalid response: NULL");
3818 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3819 result.simResponse = hidl_string();
3821 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3822 result.sw1 = resp->sw1;
3823 result.sw2 = resp->sw2;
3824 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3829 int radio::iccIOForAppResponse(int slotId,
3830 int responseType, int serial, RIL_Errno e, void *response,
3831 size_t responseLen) {
3833 RLOGD("iccIOForAppResponse: serial %d", serial);
3836 if (radioService[slotId]->mRadioResponse != NULL) {
3837 RadioResponseInfo responseInfo = {};
3838 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3841 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3842 responseInfo, result);
3843 radioService[slotId]->checkReturnStatus(retStatus);
3845 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3851 int radio::sendUssdResponse(int slotId,
3852 int responseType, int serial, RIL_Errno e, void *response,
3853 size_t responseLen) {
3855 RLOGD("sendUssdResponse: serial %d", serial);
3858 if (radioService[slotId]->mRadioResponse != NULL) {
3859 RadioResponseInfo responseInfo = {};
3860 populateResponseInfo(responseInfo, serial, responseType, e);
3861 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3863 radioService[slotId]->checkReturnStatus(retStatus);
3865 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3872 int radio::cancelPendingUssdResponse(int slotId,
3873 int responseType, int serial, RIL_Errno e, void *response,
3874 size_t responseLen) {
3876 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3879 if (radioService[slotId]->mRadioResponse != NULL) {
3880 RadioResponseInfo responseInfo = {};
3881 populateResponseInfo(responseInfo, serial, responseType, e);
3882 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3884 radioService[slotId]->checkReturnStatus(retStatus);
3886 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
3893 int radio::getClirResponse(int slotId,
3894 int responseType, int serial, RIL_Errno e, void *response,
3895 size_t responseLen) {
3897 RLOGD("getClirResponse: serial %d", serial);
3900 if (radioService[slotId]->mRadioResponse != NULL) {
3901 RadioResponseInfo responseInfo = {};
3902 populateResponseInfo(responseInfo, serial, responseType, e);
3904 int numInts = responseLen / sizeof(int);
3905 if (response == NULL || numInts != 2) {
3906 RLOGE("getClirResponse Invalid response: NULL");
3907 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3909 int *pInt = (int *) response;
3913 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
3915 radioService[slotId]->checkReturnStatus(retStatus);
3917 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3923 int radio::setClirResponse(int slotId,
3924 int responseType, int serial, RIL_Errno e, void *response,
3925 size_t responseLen) {
3927 RLOGD("setClirResponse: serial %d", serial);
3930 if (radioService[slotId]->mRadioResponse != NULL) {
3931 RadioResponseInfo responseInfo = {};
3932 populateResponseInfo(responseInfo, serial, responseType, e);
3933 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
3935 radioService[slotId]->checkReturnStatus(retStatus);
3937 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3943 int radio::getCallForwardStatusResponse(int slotId,
3944 int responseType, int serial, RIL_Errno e,
3945 void *response, size_t responseLen) {
3947 RLOGD("getCallForwardStatusResponse: serial %d", serial);
3950 if (radioService[slotId]->mRadioResponse != NULL) {
3951 RadioResponseInfo responseInfo = {};
3952 populateResponseInfo(responseInfo, serial, responseType, e);
3953 hidl_vec<CallForwardInfo> callForwardInfos;
3955 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
3956 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
3957 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3959 int num = responseLen / sizeof(RIL_CallForwardInfo *);
3960 callForwardInfos.resize(num);
3961 for (int i = 0 ; i < num; i++) {
3962 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
3963 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
3964 callForwardInfos[i].reason = resp->reason;
3965 callForwardInfos[i].serviceClass = resp->serviceClass;
3966 callForwardInfos[i].toa = resp->toa;
3967 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
3968 callForwardInfos[i].timeSeconds = resp->timeSeconds;
3972 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
3973 responseInfo, callForwardInfos);
3974 radioService[slotId]->checkReturnStatus(retStatus);
3976 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
3983 int radio::setCallForwardResponse(int slotId,
3984 int responseType, int serial, RIL_Errno e, void *response,
3985 size_t responseLen) {
3987 RLOGD("setCallForwardResponse: serial %d", serial);
3990 if (radioService[slotId]->mRadioResponse != NULL) {
3991 RadioResponseInfo responseInfo = {};
3992 populateResponseInfo(responseInfo, serial, responseType, e);
3993 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
3995 radioService[slotId]->checkReturnStatus(retStatus);
3997 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4003 int radio::getCallWaitingResponse(int slotId,
4004 int responseType, int serial, RIL_Errno e, void *response,
4005 size_t responseLen) {
4007 RLOGD("getCallWaitingResponse: serial %d", serial);
4010 if (radioService[slotId]->mRadioResponse != NULL) {
4011 RadioResponseInfo responseInfo = {};
4012 populateResponseInfo(responseInfo, serial, responseType, e);
4013 bool enable = false;
4014 int serviceClass = -1;
4015 int numInts = responseLen / sizeof(int);
4016 if (response == NULL || numInts != 2) {
4017 RLOGE("getCallWaitingResponse Invalid response: NULL");
4018 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4020 int *pInt = (int *) response;
4021 enable = pInt[0] == 1 ? true : false;
4022 serviceClass = pInt[1];
4024 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4025 responseInfo, enable, serviceClass);
4026 radioService[slotId]->checkReturnStatus(retStatus);
4028 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4034 int radio::setCallWaitingResponse(int slotId,
4035 int responseType, int serial, RIL_Errno e, void *response,
4036 size_t responseLen) {
4038 RLOGD("setCallWaitingResponse: serial %d", serial);
4041 if (radioService[slotId]->mRadioResponse != NULL) {
4042 RadioResponseInfo responseInfo = {};
4043 populateResponseInfo(responseInfo, serial, responseType, e);
4044 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4046 radioService[slotId]->checkReturnStatus(retStatus);
4048 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4054 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4055 int responseType, int serial, RIL_Errno e,
4056 void *response, size_t responseLen) {
4058 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4061 if (radioService[slotId]->mRadioResponse != NULL) {
4062 RadioResponseInfo responseInfo = {};
4063 populateResponseInfo(responseInfo, serial, responseType, e);
4064 Return<void> retStatus =
4065 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4067 radioService[slotId]->checkReturnStatus(retStatus);
4069 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4076 int radio::acceptCallResponse(int slotId,
4077 int responseType, int serial, RIL_Errno e,
4078 void *response, size_t responseLen) {
4080 RLOGD("acceptCallResponse: serial %d", serial);
4083 if (radioService[slotId]->mRadioResponse != NULL) {
4084 RadioResponseInfo responseInfo = {};
4085 populateResponseInfo(responseInfo, serial, responseType, e);
4086 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4088 radioService[slotId]->checkReturnStatus(retStatus);
4090 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4097 int radio::deactivateDataCallResponse(int slotId,
4098 int responseType, int serial, RIL_Errno e,
4099 void *response, size_t responseLen) {
4101 RLOGD("deactivateDataCallResponse: serial %d", serial);
4104 if (radioService[slotId]->mRadioResponse != NULL) {
4105 RadioResponseInfo responseInfo = {};
4106 populateResponseInfo(responseInfo, serial, responseType, e);
4107 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4109 radioService[slotId]->checkReturnStatus(retStatus);
4111 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4118 int radio::getFacilityLockForAppResponse(int slotId,
4119 int responseType, int serial, RIL_Errno e,
4120 void *response, size_t responseLen) {
4122 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4125 if (radioService[slotId]->mRadioResponse != NULL) {
4126 RadioResponseInfo responseInfo = {};
4127 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4128 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4129 getFacilityLockForAppResponse(responseInfo, ret);
4130 radioService[slotId]->checkReturnStatus(retStatus);
4132 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4139 int radio::setFacilityLockForAppResponse(int slotId,
4140 int responseType, int serial, RIL_Errno e,
4141 void *response, size_t responseLen) {
4143 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4146 if (radioService[slotId]->mRadioResponse != NULL) {
4147 RadioResponseInfo responseInfo = {};
4148 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4149 Return<void> retStatus
4150 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4152 radioService[slotId]->checkReturnStatus(retStatus);
4154 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4161 int radio::setBarringPasswordResponse(int slotId,
4162 int responseType, int serial, RIL_Errno e,
4163 void *response, size_t responseLen) {
4165 RLOGD("acceptCallResponse: serial %d", serial);
4168 if (radioService[slotId]->mRadioResponse != NULL) {
4169 RadioResponseInfo responseInfo = {};
4170 populateResponseInfo(responseInfo, serial, responseType, e);
4171 Return<void> retStatus
4172 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4173 radioService[slotId]->checkReturnStatus(retStatus);
4175 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4182 int radio::getNetworkSelectionModeResponse(int slotId,
4183 int responseType, int serial, RIL_Errno e, void *response,
4184 size_t responseLen) {
4186 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4189 if (radioService[slotId]->mRadioResponse != NULL) {
4190 RadioResponseInfo responseInfo = {};
4191 populateResponseInfo(responseInfo, serial, responseType, e);
4192 bool manual = false;
4194 if (response == NULL || responseLen != sizeof(int)) {
4195 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4196 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4198 int *pInt = (int *) response;
4199 manual = pInt[0] == 1 ? true : false;
4201 Return<void> retStatus
4202 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4205 radioService[slotId]->checkReturnStatus(retStatus);
4207 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4214 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4215 RIL_Errno e, void *response,
4216 size_t responseLen) {
4218 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4221 if (radioService[slotId]->mRadioResponse != NULL) {
4222 RadioResponseInfo responseInfo = {};
4223 populateResponseInfo(responseInfo, serial, responseType, e);
4224 Return<void> retStatus
4225 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4227 radioService[slotId]->checkReturnStatus(retStatus);
4229 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4236 int radio::setNetworkSelectionModeManualResponse(int slotId,
4237 int responseType, int serial, RIL_Errno e,
4238 void *response, size_t responseLen) {
4240 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4243 if (radioService[slotId]->mRadioResponse != NULL) {
4244 RadioResponseInfo responseInfo = {};
4245 populateResponseInfo(responseInfo, serial, responseType, e);
4246 Return<void> retStatus
4247 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4249 radioService[slotId]->checkReturnStatus(retStatus);
4251 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4258 int convertOperatorStatusToInt(const char *str) {
4259 if (strncmp("unknown", str, 9) == 0) {
4260 return (int) OperatorStatus::UNKNOWN;
4261 } else if (strncmp("available", str, 9) == 0) {
4262 return (int) OperatorStatus::AVAILABLE;
4263 } else if (strncmp("current", str, 9) == 0) {
4264 return (int) OperatorStatus::CURRENT;
4265 } else if (strncmp("forbidden", str, 9) == 0) {
4266 return (int) OperatorStatus::FORBIDDEN;
4272 int radio::getAvailableNetworksResponse(int slotId,
4273 int responseType, int serial, RIL_Errno e, void *response,
4274 size_t responseLen) {
4276 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4279 if (radioService[slotId]->mRadioResponse != NULL) {
4280 RadioResponseInfo responseInfo = {};
4281 populateResponseInfo(responseInfo, serial, responseType, e);
4282 hidl_vec<OperatorInfo> networks;
4283 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) {
4284 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4285 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4287 char **resp = (char **) response;
4288 int numStrings = responseLen / sizeof(char *);
4289 networks.resize(numStrings/4);
4290 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4291 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4292 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4293 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4294 int status = convertOperatorStatusToInt(resp[i + 3]);
4296 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4298 networks[j].status = (OperatorStatus) status;
4302 Return<void> retStatus
4303 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4305 radioService[slotId]->checkReturnStatus(retStatus);
4307 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4314 int radio::startDtmfResponse(int slotId,
4315 int responseType, int serial, RIL_Errno e,
4316 void *response, size_t responseLen) {
4318 RLOGD("startDtmfResponse: serial %d", serial);
4321 if (radioService[slotId]->mRadioResponse != NULL) {
4322 RadioResponseInfo responseInfo = {};
4323 populateResponseInfo(responseInfo, serial, responseType, e);
4324 Return<void> retStatus
4325 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4326 radioService[slotId]->checkReturnStatus(retStatus);
4328 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4334 int radio::stopDtmfResponse(int slotId,
4335 int responseType, int serial, RIL_Errno e,
4336 void *response, size_t responseLen) {
4338 RLOGD("stopDtmfResponse: serial %d", serial);
4341 if (radioService[slotId]->mRadioResponse != NULL) {
4342 RadioResponseInfo responseInfo = {};
4343 populateResponseInfo(responseInfo, serial, responseType, e);
4344 Return<void> retStatus
4345 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4346 radioService[slotId]->checkReturnStatus(retStatus);
4348 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4354 int radio::getBasebandVersionResponse(int slotId,
4355 int responseType, int serial, RIL_Errno e,
4356 void *response, size_t responseLen) {
4358 RLOGD("getBasebandVersionResponse: serial %d", serial);
4361 if (radioService[slotId]->mRadioResponse != NULL) {
4362 RadioResponseInfo responseInfo = {};
4363 populateResponseInfo(responseInfo, serial, responseType, e);
4364 Return<void> retStatus
4365 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4366 convertCharPtrToHidlString((char *) response));
4367 radioService[slotId]->checkReturnStatus(retStatus);
4369 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4375 int radio::separateConnectionResponse(int slotId,
4376 int responseType, int serial, RIL_Errno e,
4377 void *response, size_t responseLen) {
4379 RLOGD("separateConnectionResponse: serial %d", serial);
4382 if (radioService[slotId]->mRadioResponse != NULL) {
4383 RadioResponseInfo responseInfo = {};
4384 populateResponseInfo(responseInfo, serial, responseType, e);
4385 Return<void> retStatus
4386 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4387 radioService[slotId]->checkReturnStatus(retStatus);
4389 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4396 int radio::setMuteResponse(int slotId,
4397 int responseType, int serial, RIL_Errno e,
4398 void *response, size_t responseLen) {
4400 RLOGD("setMuteResponse: serial %d", serial);
4403 if (radioService[slotId]->mRadioResponse != NULL) {
4404 RadioResponseInfo responseInfo = {};
4405 populateResponseInfo(responseInfo, serial, responseType, e);
4406 Return<void> retStatus
4407 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4408 radioService[slotId]->checkReturnStatus(retStatus);
4410 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4416 int radio::getMuteResponse(int slotId,
4417 int responseType, int serial, RIL_Errno e, void *response,
4418 size_t responseLen) {
4420 RLOGD("getMuteResponse: serial %d", serial);
4423 if (radioService[slotId]->mRadioResponse != NULL) {
4424 RadioResponseInfo responseInfo = {};
4425 populateResponseInfo(responseInfo, serial, responseType, e);
4426 bool enable = false;
4428 if (response == NULL || responseLen != sizeof(int)) {
4429 RLOGE("getMuteResponse Invalid response: NULL");
4430 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4432 int *pInt = (int *) response;
4433 enable = pInt[0] == 1 ? true : false;
4435 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4437 radioService[slotId]->checkReturnStatus(retStatus);
4439 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4445 int radio::getClipResponse(int slotId,
4446 int responseType, int serial, RIL_Errno e,
4447 void *response, size_t responseLen) {
4449 RLOGD("getClipResponse: serial %d", serial);
4452 if (radioService[slotId]->mRadioResponse != NULL) {
4453 RadioResponseInfo responseInfo = {};
4454 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4455 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4457 radioService[slotId]->checkReturnStatus(retStatus);
4459 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4465 int radio::getDataCallListResponse(int slotId,
4466 int responseType, int serial, RIL_Errno e,
4467 void *response, size_t responseLen) {
4469 RLOGD("getDataCallListResponse: serial %d", serial);
4472 if (radioService[slotId]->mRadioResponse != NULL) {
4473 RadioResponseInfo responseInfo = {};
4474 populateResponseInfo(responseInfo, serial, responseType, e);
4476 hidl_vec<SetupDataCallResult> ret;
4477 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4478 RLOGE("getDataCallListResponse: invalid response");
4479 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4481 convertRilDataCallListToHal(response, responseLen, ret);
4484 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4486 radioService[slotId]->checkReturnStatus(retStatus);
4488 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4494 int radio::setSuppServiceNotificationsResponse(int slotId,
4495 int responseType, int serial, RIL_Errno e,
4496 void *response, size_t responseLen) {
4498 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4501 if (radioService[slotId]->mRadioResponse != NULL) {
4502 RadioResponseInfo responseInfo = {};
4503 populateResponseInfo(responseInfo, serial, responseType, e);
4504 Return<void> retStatus
4505 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4507 radioService[slotId]->checkReturnStatus(retStatus);
4509 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4516 int radio::deleteSmsOnSimResponse(int slotId,
4517 int responseType, int serial, RIL_Errno e,
4518 void *response, size_t responseLen) {
4520 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4523 if (radioService[slotId]->mRadioResponse != NULL) {
4524 RadioResponseInfo responseInfo = {};
4525 populateResponseInfo(responseInfo, serial, responseType, e);
4526 Return<void> retStatus
4527 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4528 radioService[slotId]->checkReturnStatus(retStatus);
4530 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4536 int radio::setBandModeResponse(int slotId,
4537 int responseType, int serial, RIL_Errno e,
4538 void *response, size_t responseLen) {
4540 RLOGD("setBandModeResponse: serial %d", serial);
4543 if (radioService[slotId]->mRadioResponse != NULL) {
4544 RadioResponseInfo responseInfo = {};
4545 populateResponseInfo(responseInfo, serial, responseType, e);
4546 Return<void> retStatus
4547 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4548 radioService[slotId]->checkReturnStatus(retStatus);
4550 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4556 int radio::writeSmsToSimResponse(int slotId,
4557 int responseType, int serial, RIL_Errno e,
4558 void *response, size_t responseLen) {
4560 RLOGD("writeSmsToSimResponse: serial %d", serial);
4563 if (radioService[slotId]->mRadioResponse != NULL) {
4564 RadioResponseInfo responseInfo = {};
4565 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4566 Return<void> retStatus
4567 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4568 radioService[slotId]->checkReturnStatus(retStatus);
4570 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4576 int radio::getAvailableBandModesResponse(int slotId,
4577 int responseType, int serial, RIL_Errno e, void *response,
4578 size_t responseLen) {
4580 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4583 if (radioService[slotId]->mRadioResponse != NULL) {
4584 RadioResponseInfo responseInfo = {};
4585 populateResponseInfo(responseInfo, serial, responseType, e);
4586 hidl_vec<RadioBandMode> modes;
4587 if (response == NULL || responseLen % sizeof(int) != 0) {
4588 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4589 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4591 int *pInt = (int *) response;
4592 int numInts = responseLen / sizeof(int);
4593 modes.resize(numInts);
4594 for (int i = 0; i < numInts; i++) {
4595 modes[i] = (RadioBandMode) pInt[i];
4598 Return<void> retStatus
4599 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4601 radioService[slotId]->checkReturnStatus(retStatus);
4603 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4610 int radio::sendEnvelopeResponse(int slotId,
4611 int responseType, int serial, RIL_Errno e,
4612 void *response, size_t responseLen) {
4614 RLOGD("sendEnvelopeResponse: serial %d", serial);
4617 if (radioService[slotId]->mRadioResponse != NULL) {
4618 RadioResponseInfo responseInfo = {};
4619 populateResponseInfo(responseInfo, serial, responseType, e);
4620 Return<void> retStatus
4621 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4622 convertCharPtrToHidlString((char *) response));
4623 radioService[slotId]->checkReturnStatus(retStatus);
4625 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4631 int radio::sendTerminalResponseToSimResponse(int slotId,
4632 int responseType, int serial, RIL_Errno e,
4633 void *response, size_t responseLen) {
4635 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4638 if (radioService[slotId]->mRadioResponse != NULL) {
4639 RadioResponseInfo responseInfo = {};
4640 populateResponseInfo(responseInfo, serial, responseType, e);
4641 Return<void> retStatus
4642 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4644 radioService[slotId]->checkReturnStatus(retStatus);
4646 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4653 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4654 int responseType, int serial,
4655 RIL_Errno e, void *response,
4656 size_t responseLen) {
4658 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4661 if (radioService[slotId]->mRadioResponse != NULL) {
4662 RadioResponseInfo responseInfo = {};
4663 populateResponseInfo(responseInfo, serial, responseType, e);
4664 Return<void> retStatus
4665 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4667 radioService[slotId]->checkReturnStatus(retStatus);
4669 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4676 int radio::explicitCallTransferResponse(int slotId,
4677 int responseType, int serial, RIL_Errno e,
4678 void *response, size_t responseLen) {
4680 RLOGD("explicitCallTransferResponse: serial %d", serial);
4683 if (radioService[slotId]->mRadioResponse != NULL) {
4684 RadioResponseInfo responseInfo = {};
4685 populateResponseInfo(responseInfo, serial, responseType, e);
4686 Return<void> retStatus
4687 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4688 radioService[slotId]->checkReturnStatus(retStatus);
4690 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4697 int radio::setPreferredNetworkTypeResponse(int slotId,
4698 int responseType, int serial, RIL_Errno e,
4699 void *response, size_t responseLen) {
4701 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4704 if (radioService[slotId]->mRadioResponse != NULL) {
4705 RadioResponseInfo responseInfo = {};
4706 populateResponseInfo(responseInfo, serial, responseType, e);
4707 Return<void> retStatus
4708 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4710 radioService[slotId]->checkReturnStatus(retStatus);
4712 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4720 int radio::getPreferredNetworkTypeResponse(int slotId,
4721 int responseType, int serial, RIL_Errno e,
4722 void *response, size_t responseLen) {
4724 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4727 if (radioService[slotId]->mRadioResponse != NULL) {
4728 RadioResponseInfo responseInfo = {};
4729 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4730 Return<void> retStatus
4731 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4732 responseInfo, (PreferredNetworkType) ret);
4733 radioService[slotId]->checkReturnStatus(retStatus);
4735 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4742 int radio::getNeighboringCidsResponse(int slotId,
4743 int responseType, int serial, RIL_Errno e,
4744 void *response, size_t responseLen) {
4746 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4749 if (radioService[slotId]->mRadioResponse != NULL) {
4750 RadioResponseInfo responseInfo = {};
4751 populateResponseInfo(responseInfo, serial, responseType, e);
4752 hidl_vec<NeighboringCell> cells;
4754 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4755 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4756 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4758 int num = responseLen / sizeof(RIL_NeighboringCell *);
4760 for (int i = 0 ; i < num; i++) {
4761 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4762 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4763 cells[i].rssi = resp->rssi;
4767 Return<void> retStatus
4768 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4770 radioService[slotId]->checkReturnStatus(retStatus);
4772 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4779 int radio::setLocationUpdatesResponse(int slotId,
4780 int responseType, int serial, RIL_Errno e,
4781 void *response, size_t responseLen) {
4783 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4786 if (radioService[slotId]->mRadioResponse != NULL) {
4787 RadioResponseInfo responseInfo = {};
4788 populateResponseInfo(responseInfo, serial, responseType, e);
4789 Return<void> retStatus
4790 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4791 radioService[slotId]->checkReturnStatus(retStatus);
4793 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4800 int radio::setCdmaSubscriptionSourceResponse(int slotId,
4801 int responseType, int serial, RIL_Errno e,
4802 void *response, size_t responseLen) {
4804 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4807 if (radioService[slotId]->mRadioResponse != NULL) {
4808 RadioResponseInfo responseInfo = {};
4809 populateResponseInfo(responseInfo, serial, responseType, e);
4810 Return<void> retStatus
4811 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4813 radioService[slotId]->checkReturnStatus(retStatus);
4815 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4822 int radio::setCdmaRoamingPreferenceResponse(int slotId,
4823 int responseType, int serial, RIL_Errno e,
4824 void *response, size_t responseLen) {
4826 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4829 if (radioService[slotId]->mRadioResponse != NULL) {
4830 RadioResponseInfo responseInfo = {};
4831 populateResponseInfo(responseInfo, serial, responseType, e);
4832 Return<void> retStatus
4833 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4835 radioService[slotId]->checkReturnStatus(retStatus);
4837 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4844 int radio::getCdmaRoamingPreferenceResponse(int slotId,
4845 int responseType, int serial, RIL_Errno e,
4846 void *response, size_t responseLen) {
4848 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4851 if (radioService[slotId]->mRadioResponse != NULL) {
4852 RadioResponseInfo responseInfo = {};
4853 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4854 Return<void> retStatus
4855 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4856 responseInfo, (CdmaRoamingType) ret);
4857 radioService[slotId]->checkReturnStatus(retStatus);
4859 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4866 int radio::setTTYModeResponse(int slotId,
4867 int responseType, int serial, RIL_Errno e,
4868 void *response, size_t responseLen) {
4870 RLOGD("setTTYModeResponse: serial %d", serial);
4873 if (radioService[slotId]->mRadioResponse != NULL) {
4874 RadioResponseInfo responseInfo = {};
4875 populateResponseInfo(responseInfo, serial, responseType, e);
4876 Return<void> retStatus
4877 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4878 radioService[slotId]->checkReturnStatus(retStatus);
4880 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4886 int radio::getTTYModeResponse(int slotId,
4887 int responseType, int serial, RIL_Errno e,
4888 void *response, size_t responseLen) {
4890 RLOGD("getTTYModeResponse: serial %d", serial);
4893 if (radioService[slotId]->mRadioResponse != NULL) {
4894 RadioResponseInfo responseInfo = {};
4895 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4896 Return<void> retStatus
4897 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
4899 radioService[slotId]->checkReturnStatus(retStatus);
4901 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4907 int radio::setPreferredVoicePrivacyResponse(int slotId,
4908 int responseType, int serial, RIL_Errno e,
4909 void *response, size_t responseLen) {
4911 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
4914 if (radioService[slotId]->mRadioResponse != NULL) {
4915 RadioResponseInfo responseInfo = {};
4916 populateResponseInfo(responseInfo, serial, responseType, e);
4917 Return<void> retStatus
4918 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
4920 radioService[slotId]->checkReturnStatus(retStatus);
4922 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4929 int radio::getPreferredVoicePrivacyResponse(int slotId,
4930 int responseType, int serial, RIL_Errno e,
4931 void *response, size_t responseLen) {
4933 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
4936 if (radioService[slotId]->mRadioResponse != NULL) {
4937 RadioResponseInfo responseInfo = {};
4938 populateResponseInfo(responseInfo, serial, responseType, e);
4939 bool enable = false;
4940 int numInts = responseLen / sizeof(int);
4941 if (response == NULL || numInts != 1) {
4942 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
4943 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4945 int *pInt = (int *) response;
4946 enable = pInt[0] == 1 ? true : false;
4948 Return<void> retStatus
4949 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
4950 responseInfo, enable);
4951 radioService[slotId]->checkReturnStatus(retStatus);
4953 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
4960 int radio::sendCDMAFeatureCodeResponse(int slotId,
4961 int responseType, int serial, RIL_Errno e,
4962 void *response, size_t responseLen) {
4964 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
4967 if (radioService[slotId]->mRadioResponse != NULL) {
4968 RadioResponseInfo responseInfo = {};
4969 populateResponseInfo(responseInfo, serial, responseType, e);
4970 Return<void> retStatus
4971 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
4972 radioService[slotId]->checkReturnStatus(retStatus);
4974 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
4981 int radio::sendBurstDtmfResponse(int slotId,
4982 int responseType, int serial, RIL_Errno e,
4983 void *response, size_t responseLen) {
4985 RLOGD("sendBurstDtmfResponse: serial %d", serial);
4988 if (radioService[slotId]->mRadioResponse != NULL) {
4989 RadioResponseInfo responseInfo = {};
4990 populateResponseInfo(responseInfo, serial, responseType, e);
4991 Return<void> retStatus
4992 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
4993 radioService[slotId]->checkReturnStatus(retStatus);
4995 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5001 int radio::sendCdmaSmsResponse(int slotId,
5002 int responseType, int serial, RIL_Errno e, void *response,
5003 size_t responseLen) {
5005 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5008 if (radioService[slotId]->mRadioResponse != NULL) {
5009 RadioResponseInfo responseInfo = {};
5010 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5013 Return<void> retStatus
5014 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5015 radioService[slotId]->checkReturnStatus(retStatus);
5017 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5023 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5024 int responseType, int serial, RIL_Errno e,
5025 void *response, size_t responseLen) {
5027 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5030 if (radioService[slotId]->mRadioResponse != NULL) {
5031 RadioResponseInfo responseInfo = {};
5032 populateResponseInfo(responseInfo, serial, responseType, e);
5033 Return<void> retStatus
5034 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5036 radioService[slotId]->checkReturnStatus(retStatus);
5038 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5045 int radio::getGsmBroadcastConfigResponse(int slotId,
5046 int responseType, int serial, RIL_Errno e,
5047 void *response, size_t responseLen) {
5049 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5052 if (radioService[slotId]->mRadioResponse != NULL) {
5053 RadioResponseInfo responseInfo = {};
5054 populateResponseInfo(responseInfo, serial, responseType, e);
5055 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5057 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5058 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5059 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5061 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5062 configs.resize(num);
5063 for (int i = 0 ; i < num; i++) {
5064 RIL_GSM_BroadcastSmsConfigInfo *resp =
5065 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5066 configs[i].fromServiceId = resp->fromServiceId;
5067 configs[i].toServiceId = resp->toServiceId;
5068 configs[i].fromCodeScheme = resp->fromCodeScheme;
5069 configs[i].toCodeScheme = resp->toCodeScheme;
5070 configs[i].selected = resp->selected == 1 ? true : false;
5074 Return<void> retStatus
5075 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5077 radioService[slotId]->checkReturnStatus(retStatus);
5079 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5086 int radio::setGsmBroadcastConfigResponse(int slotId,
5087 int responseType, int serial, RIL_Errno e,
5088 void *response, size_t responseLen) {
5090 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5093 if (radioService[slotId]->mRadioResponse != NULL) {
5094 RadioResponseInfo responseInfo = {};
5095 populateResponseInfo(responseInfo, serial, responseType, e);
5096 Return<void> retStatus
5097 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5098 radioService[slotId]->checkReturnStatus(retStatus);
5100 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5107 int radio::setGsmBroadcastActivationResponse(int slotId,
5108 int responseType, int serial, RIL_Errno e,
5109 void *response, size_t responseLen) {
5111 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5114 if (radioService[slotId]->mRadioResponse != NULL) {
5115 RadioResponseInfo responseInfo = {};
5116 populateResponseInfo(responseInfo, serial, responseType, e);
5117 Return<void> retStatus
5118 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5120 radioService[slotId]->checkReturnStatus(retStatus);
5122 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5129 int radio::getCdmaBroadcastConfigResponse(int slotId,
5130 int responseType, int serial, RIL_Errno e,
5131 void *response, size_t responseLen) {
5133 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5136 if (radioService[slotId]->mRadioResponse != NULL) {
5137 RadioResponseInfo responseInfo = {};
5138 populateResponseInfo(responseInfo, serial, responseType, e);
5139 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5141 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5142 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5143 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5145 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5146 configs.resize(num);
5147 for (int i = 0 ; i < num; i++) {
5148 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5149 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5150 configs[i].serviceCategory = resp->service_category;
5151 configs[i].language = resp->language;
5152 configs[i].selected = resp->selected == 1 ? true : false;
5156 Return<void> retStatus
5157 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5159 radioService[slotId]->checkReturnStatus(retStatus);
5161 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5168 int radio::setCdmaBroadcastConfigResponse(int slotId,
5169 int responseType, int serial, RIL_Errno e,
5170 void *response, size_t responseLen) {
5172 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5175 if (radioService[slotId]->mRadioResponse != NULL) {
5176 RadioResponseInfo responseInfo = {};
5177 populateResponseInfo(responseInfo, serial, responseType, e);
5178 Return<void> retStatus
5179 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5181 radioService[slotId]->checkReturnStatus(retStatus);
5183 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5190 int radio::setCdmaBroadcastActivationResponse(int slotId,
5191 int responseType, int serial, RIL_Errno e,
5192 void *response, size_t responseLen) {
5194 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5197 if (radioService[slotId]->mRadioResponse != NULL) {
5198 RadioResponseInfo responseInfo = {};
5199 populateResponseInfo(responseInfo, serial, responseType, e);
5200 Return<void> retStatus
5201 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5203 radioService[slotId]->checkReturnStatus(retStatus);
5205 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5212 int radio::getCDMASubscriptionResponse(int slotId,
5213 int responseType, int serial, RIL_Errno e, void *response,
5214 size_t responseLen) {
5216 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5219 if (radioService[slotId]->mRadioResponse != NULL) {
5220 RadioResponseInfo responseInfo = {};
5221 populateResponseInfo(responseInfo, serial, responseType, e);
5223 int numStrings = responseLen / sizeof(char *);
5224 hidl_string emptyString;
5225 if (response == NULL || numStrings != 5) {
5226 RLOGE("getOperatorResponse Invalid response: NULL");
5227 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5228 Return<void> retStatus
5229 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5230 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5231 radioService[slotId]->checkReturnStatus(retStatus);
5233 char **resp = (char **) response;
5234 Return<void> retStatus
5235 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5237 convertCharPtrToHidlString(resp[0]),
5238 convertCharPtrToHidlString(resp[1]),
5239 convertCharPtrToHidlString(resp[2]),
5240 convertCharPtrToHidlString(resp[3]),
5241 convertCharPtrToHidlString(resp[4]));
5242 radioService[slotId]->checkReturnStatus(retStatus);
5245 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5252 int radio::writeSmsToRuimResponse(int slotId,
5253 int responseType, int serial, RIL_Errno e,
5254 void *response, size_t responseLen) {
5256 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5259 if (radioService[slotId]->mRadioResponse != NULL) {
5260 RadioResponseInfo responseInfo = {};
5261 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5262 Return<void> retStatus
5263 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5264 radioService[slotId]->checkReturnStatus(retStatus);
5266 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5272 int radio::deleteSmsOnRuimResponse(int slotId,
5273 int responseType, int serial, RIL_Errno e,
5274 void *response, size_t responseLen) {
5276 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5279 if (radioService[slotId]->mRadioResponse != NULL) {
5280 RadioResponseInfo responseInfo = {};
5281 populateResponseInfo(responseInfo, serial, responseType, e);
5282 Return<void> retStatus
5283 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5284 radioService[slotId]->checkReturnStatus(retStatus);
5286 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5292 int radio::getDeviceIdentityResponse(int slotId,
5293 int responseType, int serial, RIL_Errno e, void *response,
5294 size_t responseLen) {
5296 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5299 if (radioService[slotId]->mRadioResponse != NULL) {
5300 RadioResponseInfo responseInfo = {};
5301 populateResponseInfo(responseInfo, serial, responseType, e);
5303 int numStrings = responseLen / sizeof(char *);
5304 hidl_string emptyString;
5305 if (response == NULL || numStrings != 4) {
5306 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5307 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5308 Return<void> retStatus
5309 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5310 emptyString, emptyString, emptyString, emptyString);
5311 radioService[slotId]->checkReturnStatus(retStatus);
5313 char **resp = (char **) response;
5314 Return<void> retStatus
5315 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5316 convertCharPtrToHidlString(resp[0]),
5317 convertCharPtrToHidlString(resp[1]),
5318 convertCharPtrToHidlString(resp[2]),
5319 convertCharPtrToHidlString(resp[3]));
5320 radioService[slotId]->checkReturnStatus(retStatus);
5323 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5330 int radio::exitEmergencyCallbackModeResponse(int slotId,
5331 int responseType, int serial, RIL_Errno e,
5332 void *response, size_t responseLen) {
5334 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5337 if (radioService[slotId]->mRadioResponse != NULL) {
5338 RadioResponseInfo responseInfo = {};
5339 populateResponseInfo(responseInfo, serial, responseType, e);
5340 Return<void> retStatus
5341 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5343 radioService[slotId]->checkReturnStatus(retStatus);
5345 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5352 int radio::getSmscAddressResponse(int slotId,
5353 int responseType, int serial, RIL_Errno e,
5354 void *response, size_t responseLen) {
5356 RLOGD("getSmscAddressResponse: serial %d", serial);
5359 if (radioService[slotId]->mRadioResponse != NULL) {
5360 RadioResponseInfo responseInfo = {};
5361 populateResponseInfo(responseInfo, serial, responseType, e);
5362 Return<void> retStatus
5363 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5364 convertCharPtrToHidlString((char *) response));
5365 radioService[slotId]->checkReturnStatus(retStatus);
5367 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5373 int radio::setSmscAddressResponse(int slotId,
5374 int responseType, int serial, RIL_Errno e,
5375 void *response, size_t responseLen) {
5377 RLOGD("setSmscAddressResponse: serial %d", serial);
5380 if (radioService[slotId]->mRadioResponse != NULL) {
5381 RadioResponseInfo responseInfo = {};
5382 populateResponseInfo(responseInfo, serial, responseType, e);
5383 Return<void> retStatus
5384 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5385 radioService[slotId]->checkReturnStatus(retStatus);
5387 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5393 int radio::reportSmsMemoryStatusResponse(int slotId,
5394 int responseType, int serial, RIL_Errno e,
5395 void *response, size_t responseLen) {
5397 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5400 if (radioService[slotId]->mRadioResponse != NULL) {
5401 RadioResponseInfo responseInfo = {};
5402 populateResponseInfo(responseInfo, serial, responseType, e);
5403 Return<void> retStatus
5404 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5405 radioService[slotId]->checkReturnStatus(retStatus);
5407 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5414 int radio::reportStkServiceIsRunningResponse(int slotId,
5415 int responseType, int serial, RIL_Errno e,
5416 void *response, size_t responseLen) {
5418 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5421 if (radioService[slotId]->mRadioResponse != NULL) {
5422 RadioResponseInfo responseInfo = {};
5423 populateResponseInfo(responseInfo, serial, responseType, e);
5424 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5425 reportStkServiceIsRunningResponse(responseInfo);
5426 radioService[slotId]->checkReturnStatus(retStatus);
5428 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5435 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5436 int responseType, int serial, RIL_Errno e,
5437 void *response, size_t responseLen) {
5439 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5442 if (radioService[slotId]->mRadioResponse != NULL) {
5443 RadioResponseInfo responseInfo = {};
5444 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5445 Return<void> retStatus
5446 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5447 responseInfo, (CdmaSubscriptionSource) ret);
5448 radioService[slotId]->checkReturnStatus(retStatus);
5450 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5457 int radio::requestIsimAuthenticationResponse(int slotId,
5458 int responseType, int serial, RIL_Errno e,
5459 void *response, size_t responseLen) {
5461 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5464 if (radioService[slotId]->mRadioResponse != NULL) {
5465 RadioResponseInfo responseInfo = {};
5466 populateResponseInfo(responseInfo, serial, responseType, e);
5467 Return<void> retStatus
5468 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5470 convertCharPtrToHidlString((char *) response));
5471 radioService[slotId]->checkReturnStatus(retStatus);
5473 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5480 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5482 int serial, RIL_Errno e, void *response,
5483 size_t responseLen) {
5485 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5488 if (radioService[slotId]->mRadioResponse != NULL) {
5489 RadioResponseInfo responseInfo = {};
5490 populateResponseInfo(responseInfo, serial, responseType, e);
5491 Return<void> retStatus
5492 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5494 radioService[slotId]->checkReturnStatus(retStatus);
5496 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5503 int radio::sendEnvelopeWithStatusResponse(int slotId,
5504 int responseType, int serial, RIL_Errno e, void *response,
5505 size_t responseLen) {
5507 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5510 if (radioService[slotId]->mRadioResponse != NULL) {
5511 RadioResponseInfo responseInfo = {};
5512 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5513 response, responseLen);
5515 Return<void> retStatus
5516 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5518 radioService[slotId]->checkReturnStatus(retStatus);
5520 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5527 int radio::getVoiceRadioTechnologyResponse(int slotId,
5528 int responseType, int serial, RIL_Errno e,
5529 void *response, size_t responseLen) {
5531 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5534 if (radioService[slotId]->mRadioResponse != NULL) {
5535 RadioResponseInfo responseInfo = {};
5536 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5537 Return<void> retStatus
5538 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5539 responseInfo, (RadioTechnology) ret);
5540 radioService[slotId]->checkReturnStatus(retStatus);
5542 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5549 int radio::getCellInfoListResponse(int slotId,
5551 int serial, RIL_Errno e, void *response,
5552 size_t responseLen) {
5554 RLOGD("getCellInfoListResponse: serial %d", serial);
5557 if (radioService[slotId]->mRadioResponse != NULL) {
5558 RadioResponseInfo responseInfo = {};
5559 populateResponseInfo(responseInfo, serial, responseType, e);
5561 hidl_vec<CellInfo> ret;
5562 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5563 RLOGE("getCellInfoListResponse: Invalid response");
5564 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5566 convertRilCellInfoListToHal(response, responseLen, ret);
5569 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5571 radioService[slotId]->checkReturnStatus(retStatus);
5573 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5579 int radio::setCellInfoListRateResponse(int slotId,
5581 int serial, RIL_Errno e, void *response,
5582 size_t responseLen) {
5584 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5587 if (radioService[slotId]->mRadioResponse != NULL) {
5588 RadioResponseInfo responseInfo = {};
5589 populateResponseInfo(responseInfo, serial, responseType, e);
5590 Return<void> retStatus
5591 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5592 radioService[slotId]->checkReturnStatus(retStatus);
5594 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5601 int radio::setInitialAttachApnResponse(int slotId,
5602 int responseType, int serial, RIL_Errno e,
5603 void *response, size_t responseLen) {
5605 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5608 if (radioService[slotId]->mRadioResponse != NULL) {
5609 RadioResponseInfo responseInfo = {};
5610 populateResponseInfo(responseInfo, serial, responseType, e);
5611 Return<void> retStatus
5612 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5613 radioService[slotId]->checkReturnStatus(retStatus);
5615 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5622 int radio::getImsRegistrationStateResponse(int slotId,
5623 int responseType, int serial, RIL_Errno e,
5624 void *response, size_t responseLen) {
5626 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5629 if (radioService[slotId]->mRadioResponse != NULL) {
5630 RadioResponseInfo responseInfo = {};
5631 populateResponseInfo(responseInfo, serial, responseType, e);
5632 bool isRegistered = false;
5634 int numInts = responseLen / sizeof(int);
5635 if (response == NULL || numInts != 2) {
5636 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5637 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5639 int *pInt = (int *) response;
5640 isRegistered = pInt[0] == 1 ? true : false;
5641 ratFamily = pInt[1];
5643 Return<void> retStatus
5644 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5645 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5646 radioService[slotId]->checkReturnStatus(retStatus);
5648 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5655 int radio::sendImsSmsResponse(int slotId,
5656 int responseType, int serial, RIL_Errno e, void *response,
5657 size_t responseLen) {
5659 RLOGD("sendImsSmsResponse: serial %d", serial);
5662 if (radioService[slotId]->mRadioResponse != NULL) {
5663 RadioResponseInfo responseInfo = {};
5664 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5667 Return<void> retStatus
5668 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5669 radioService[slotId]->checkReturnStatus(retStatus);
5671 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5677 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5678 int responseType, int serial, RIL_Errno e,
5679 void *response, size_t responseLen) {
5681 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5684 if (radioService[slotId]->mRadioResponse != NULL) {
5685 RadioResponseInfo responseInfo = {};
5686 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5689 Return<void> retStatus
5690 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5691 responseInfo, result);
5692 radioService[slotId]->checkReturnStatus(retStatus);
5694 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5701 int radio::iccOpenLogicalChannelResponse(int slotId,
5702 int responseType, int serial, RIL_Errno e, void *response,
5703 size_t responseLen) {
5705 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5708 if (radioService[slotId]->mRadioResponse != NULL) {
5709 RadioResponseInfo responseInfo = {};
5710 populateResponseInfo(responseInfo, serial, responseType, e);
5712 hidl_vec<int8_t> selectResponse;
5713 int numInts = responseLen / sizeof(int);
5714 if (response == NULL || responseLen % sizeof(int) != 0) {
5715 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5716 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5718 int *pInt = (int *) response;
5719 channelId = pInt[0];
5720 selectResponse.resize(numInts - 1);
5721 for (int i = 1; i < numInts; i++) {
5722 selectResponse[i - 1] = (int8_t) pInt[i];
5725 Return<void> retStatus
5726 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5727 channelId, selectResponse);
5728 radioService[slotId]->checkReturnStatus(retStatus);
5730 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5737 int radio::iccCloseLogicalChannelResponse(int slotId,
5738 int responseType, int serial, RIL_Errno e,
5739 void *response, size_t responseLen) {
5741 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5744 if (radioService[slotId]->mRadioResponse != NULL) {
5745 RadioResponseInfo responseInfo = {};
5746 populateResponseInfo(responseInfo, serial, responseType, e);
5747 Return<void> retStatus
5748 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5750 radioService[slotId]->checkReturnStatus(retStatus);
5752 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5759 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5760 int responseType, int serial, RIL_Errno e,
5761 void *response, size_t responseLen) {
5763 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5766 if (radioService[slotId]->mRadioResponse != NULL) {
5767 RadioResponseInfo responseInfo = {};
5768 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5771 Return<void> retStatus
5772 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5773 responseInfo, result);
5774 radioService[slotId]->checkReturnStatus(retStatus);
5776 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5783 int radio::nvReadItemResponse(int slotId,
5784 int responseType, int serial, RIL_Errno e,
5785 void *response, size_t responseLen) {
5787 RLOGD("nvReadItemResponse: serial %d", serial);
5790 if (radioService[slotId]->mRadioResponse != NULL) {
5791 RadioResponseInfo responseInfo = {};
5792 populateResponseInfo(responseInfo, serial, responseType, e);
5793 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5795 convertCharPtrToHidlString((char *) response));
5796 radioService[slotId]->checkReturnStatus(retStatus);
5798 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5804 int radio::nvWriteItemResponse(int slotId,
5805 int responseType, int serial, RIL_Errno e,
5806 void *response, size_t responseLen) {
5808 RLOGD("nvWriteItemResponse: serial %d", serial);
5811 if (radioService[slotId]->mRadioResponse != NULL) {
5812 RadioResponseInfo responseInfo = {};
5813 populateResponseInfo(responseInfo, serial, responseType, e);
5814 Return<void> retStatus
5815 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5816 radioService[slotId]->checkReturnStatus(retStatus);
5818 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5824 int radio::nvWriteCdmaPrlResponse(int slotId,
5825 int responseType, int serial, RIL_Errno e,
5826 void *response, size_t responseLen) {
5828 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5831 if (radioService[slotId]->mRadioResponse != NULL) {
5832 RadioResponseInfo responseInfo = {};
5833 populateResponseInfo(responseInfo, serial, responseType, e);
5834 Return<void> retStatus
5835 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5836 radioService[slotId]->checkReturnStatus(retStatus);
5838 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5844 int radio::nvResetConfigResponse(int slotId,
5845 int responseType, int serial, RIL_Errno e,
5846 void *response, size_t responseLen) {
5848 RLOGD("nvResetConfigResponse: serial %d", serial);
5851 if (radioService[slotId]->mRadioResponse != NULL) {
5852 RadioResponseInfo responseInfo = {};
5853 populateResponseInfo(responseInfo, serial, responseType, e);
5854 Return<void> retStatus
5855 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5856 radioService[slotId]->checkReturnStatus(retStatus);
5858 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5864 int radio::setUiccSubscriptionResponse(int slotId,
5865 int responseType, int serial, RIL_Errno e,
5866 void *response, size_t responseLen) {
5868 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5871 if (radioService[slotId]->mRadioResponse != NULL) {
5872 RadioResponseInfo responseInfo = {};
5873 populateResponseInfo(responseInfo, serial, responseType, e);
5874 Return<void> retStatus
5875 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5876 radioService[slotId]->checkReturnStatus(retStatus);
5878 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5885 int radio::setDataAllowedResponse(int slotId,
5886 int responseType, int serial, RIL_Errno e,
5887 void *response, size_t responseLen) {
5889 RLOGD("setDataAllowedResponse: serial %d", serial);
5892 if (radioService[slotId]->mRadioResponse != NULL) {
5893 RadioResponseInfo responseInfo = {};
5894 populateResponseInfo(responseInfo, serial, responseType, e);
5895 Return<void> retStatus
5896 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
5897 radioService[slotId]->checkReturnStatus(retStatus);
5899 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5905 int radio::getHardwareConfigResponse(int slotId,
5906 int responseType, int serial, RIL_Errno e,
5907 void *response, size_t responseLen) {
5909 RLOGD("getHardwareConfigResponse: serial %d", serial);
5912 if (radioService[slotId]->mRadioResponse != NULL) {
5913 RadioResponseInfo responseInfo = {};
5914 populateResponseInfo(responseInfo, serial, responseType, e);
5916 hidl_vec<HardwareConfig> result;
5917 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
5918 RLOGE("hardwareConfigChangedInd: invalid response");
5919 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5921 convertRilHardwareConfigListToHal(response, responseLen, result);
5924 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
5925 responseInfo, result);
5926 radioService[slotId]->checkReturnStatus(retStatus);
5928 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5934 int radio::requestIccSimAuthenticationResponse(int slotId,
5935 int responseType, int serial, RIL_Errno e,
5936 void *response, size_t responseLen) {
5938 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
5941 if (radioService[slotId]->mRadioResponse != NULL) {
5942 RadioResponseInfo responseInfo = {};
5943 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5946 Return<void> retStatus
5947 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
5948 responseInfo, result);
5949 radioService[slotId]->checkReturnStatus(retStatus);
5951 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
5958 int radio::setDataProfileResponse(int slotId,
5959 int responseType, int serial, RIL_Errno e,
5960 void *response, size_t responseLen) {
5962 RLOGD("setDataProfileResponse: serial %d", serial);
5965 if (radioService[slotId]->mRadioResponse != NULL) {
5966 RadioResponseInfo responseInfo = {};
5967 populateResponseInfo(responseInfo, serial, responseType, e);
5968 Return<void> retStatus
5969 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
5970 radioService[slotId]->checkReturnStatus(retStatus);
5972 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5978 int radio::requestShutdownResponse(int slotId,
5979 int responseType, int serial, RIL_Errno e,
5980 void *response, size_t responseLen) {
5982 RLOGD("requestShutdownResponse: serial %d", serial);
5985 if (radioService[slotId]->mRadioResponse != NULL) {
5986 RadioResponseInfo responseInfo = {};
5987 populateResponseInfo(responseInfo, serial, responseType, e);
5988 Return<void> retStatus
5989 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
5990 radioService[slotId]->checkReturnStatus(retStatus);
5992 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5998 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
5999 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6000 populateResponseInfo(responseInfo, serial, responseType, e);
6002 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6003 RLOGE("responseRadioCapability: Invalid response");
6004 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6005 rc.logicalModemUuid = hidl_string();
6007 convertRilRadioCapabilityToHal(response, responseLen, rc);
6011 int radio::getRadioCapabilityResponse(int slotId,
6012 int responseType, int serial, RIL_Errno e,
6013 void *response, size_t responseLen) {
6015 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6018 if (radioService[slotId]->mRadioResponse != NULL) {
6019 RadioResponseInfo responseInfo = {};
6020 RadioCapability result = {};
6021 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6023 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6024 responseInfo, result);
6025 radioService[slotId]->checkReturnStatus(retStatus);
6027 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6033 int radio::setRadioCapabilityResponse(int slotId,
6034 int responseType, int serial, RIL_Errno e,
6035 void *response, size_t responseLen) {
6037 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6040 if (radioService[slotId]->mRadioResponse != NULL) {
6041 RadioResponseInfo responseInfo = {};
6042 RadioCapability result = {};
6043 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6045 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6046 responseInfo, result);
6047 radioService[slotId]->checkReturnStatus(retStatus);
6049 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6055 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6056 RIL_Errno e, void *response, size_t responseLen) {
6057 populateResponseInfo(responseInfo, serial, responseType, e);
6058 LceStatusInfo result = {};
6060 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6061 RLOGE("Invalid response: NULL");
6062 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6064 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6065 result.lceStatus = (LceStatus) resp->lce_status;
6066 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6071 int radio::startLceServiceResponse(int slotId,
6072 int responseType, int serial, RIL_Errno e,
6073 void *response, size_t responseLen) {
6075 RLOGD("startLceServiceResponse: serial %d", serial);
6078 if (radioService[slotId]->mRadioResponse != NULL) {
6079 RadioResponseInfo responseInfo = {};
6080 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6081 response, responseLen);
6083 Return<void> retStatus
6084 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6086 radioService[slotId]->checkReturnStatus(retStatus);
6088 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6094 int radio::stopLceServiceResponse(int slotId,
6095 int responseType, int serial, RIL_Errno e,
6096 void *response, size_t responseLen) {
6098 RLOGD("stopLceServiceResponse: serial %d", serial);
6101 if (radioService[slotId]->mRadioResponse != NULL) {
6102 RadioResponseInfo responseInfo = {};
6103 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6104 response, responseLen);
6106 Return<void> retStatus
6107 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6109 radioService[slotId]->checkReturnStatus(retStatus);
6111 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6117 int radio::pullLceDataResponse(int slotId,
6118 int responseType, int serial, RIL_Errno e,
6119 void *response, size_t responseLen) {
6121 RLOGD("pullLceDataResponse: serial %d", serial);
6124 if (radioService[slotId]->mRadioResponse != NULL) {
6125 RadioResponseInfo responseInfo = {};
6126 populateResponseInfo(responseInfo, serial, responseType, e);
6128 LceDataInfo result = {};
6129 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6130 RLOGE("pullLceDataResponse: Invalid response");
6131 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6133 convertRilLceDataInfoToHal(response, responseLen, result);
6136 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6137 responseInfo, result);
6138 radioService[slotId]->checkReturnStatus(retStatus);
6140 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6146 int radio::getModemActivityInfoResponse(int slotId,
6147 int responseType, int serial, RIL_Errno e,
6148 void *response, size_t responseLen) {
6150 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6153 if (radioService[slotId]->mRadioResponse != NULL) {
6154 RadioResponseInfo responseInfo = {};
6155 populateResponseInfo(responseInfo, serial, responseType, e);
6156 ActivityStatsInfo info;
6157 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6158 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6159 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6161 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6162 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6163 info.idleModeTimeMs = resp->idle_mode_time_ms;
6164 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6165 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6167 info.rxModeTimeMs = resp->rx_mode_time_ms;
6170 Return<void> retStatus
6171 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6173 radioService[slotId]->checkReturnStatus(retStatus);
6175 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6182 int radio::setAllowedCarriersResponse(int slotId,
6183 int responseType, int serial, RIL_Errno e,
6184 void *response, size_t responseLen) {
6186 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6189 if (radioService[slotId]->mRadioResponse != NULL) {
6190 RadioResponseInfo responseInfo = {};
6191 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6192 Return<void> retStatus
6193 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6195 radioService[slotId]->checkReturnStatus(retStatus);
6197 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6204 int radio::getAllowedCarriersResponse(int slotId,
6205 int responseType, int serial, RIL_Errno e,
6206 void *response, size_t responseLen) {
6208 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6211 if (radioService[slotId]->mRadioResponse != NULL) {
6212 RadioResponseInfo responseInfo = {};
6213 populateResponseInfo(responseInfo, serial, responseType, e);
6214 CarrierRestrictions carrierInfo = {};
6215 bool allAllowed = true;
6216 if (response == NULL) {
6218 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6220 carrierInfo.allowedCarriers.resize(0);
6221 carrierInfo.excludedCarriers.resize(0);
6222 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6223 RLOGE("getAllowedCarriersResponse Invalid response");
6224 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6226 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6227 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6231 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6232 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6233 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6234 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6235 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6236 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6237 carrierInfo.allowedCarriers[i].matchData =
6238 convertCharPtrToHidlString(carrier->match_data);
6241 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6242 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6243 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6244 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6245 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6246 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6247 carrierInfo.excludedCarriers[i].matchData =
6248 convertCharPtrToHidlString(carrier->match_data);
6252 Return<void> retStatus
6253 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6254 allAllowed, carrierInfo);
6255 radioService[slotId]->checkReturnStatus(retStatus);
6257 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6264 int radio::sendDeviceStateResponse(int slotId,
6265 int responseType, int serial, RIL_Errno e,
6266 void *response, size_t responselen) {
6268 RLOGD("sendDeviceStateResponse: serial %d", serial);
6271 if (radioService[slotId]->mRadioResponse != NULL) {
6272 RadioResponseInfo responseInfo = {};
6273 populateResponseInfo(responseInfo, serial, responseType, e);
6274 Return<void> retStatus
6275 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6276 radioService[slotId]->checkReturnStatus(retStatus);
6278 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6284 int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
6285 int responseType, int serial, RIL_Errno e,
6286 void *response, size_t responseLen) {
6287 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
6288 if (radioService[slotId]->mRadioResponse != NULL) {
6289 RadioResponseInfo responseInfo = {};
6290 populateResponseInfo(responseInfo, serial, responseType, e);
6291 Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
6292 ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
6293 radioService[slotId]->mRadioResponse);
6295 sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
6296 Return<void> retStatus
6297 = radioResponseV1_1->setCarrierInfoForImsiEncryptionResponse(responseInfo);
6298 radioService[slotId]->checkReturnStatus(retStatus);
6300 RLOGE("setCarrierInfoForImsiEncryptionResponse: ret.isOk() == false for "
6301 "radioService[%d]" , slotId);
6304 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponse == NULL",
6310 int radio::setIndicationFilterResponse(int slotId,
6311 int responseType, int serial, RIL_Errno e,
6312 void *response, size_t responselen) {
6314 RLOGD("setIndicationFilterResponse: serial %d", serial);
6317 if (radioService[slotId]->mRadioResponse != NULL) {
6318 RadioResponseInfo responseInfo = {};
6319 populateResponseInfo(responseInfo, serial, responseType, e);
6320 Return<void> retStatus
6321 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6322 radioService[slotId]->checkReturnStatus(retStatus);
6324 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6331 int radio::setSimCardPowerResponse(int slotId,
6332 int responseType, int serial, RIL_Errno e,
6333 void *response, size_t responseLen) {
6335 RLOGD("setSimCardPowerResponse: serial %d", serial);
6338 if (radioService[slotId]->mRadioResponse != NULL) {
6339 RadioResponseInfo responseInfo = {};
6340 populateResponseInfo(responseInfo, serial, responseType, e);
6341 Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
6342 ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
6343 radioService[slotId]->mRadioResponse);
6345 sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
6346 Return<void> retStatus
6347 = radioResponseV1_1->setSimCardPowerResponse_1_1(responseInfo);
6348 radioService[slotId]->checkReturnStatus(retStatus);
6350 RLOGD("setSimCardPowerResponse: ret.isOK() == false for radioService[%d]",
6352 Return<void> retStatus
6353 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6354 radioService[slotId]->checkReturnStatus(retStatus);
6357 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL",
6363 int radio::sendRequestRawResponse(int slotId,
6364 int responseType, int serial, RIL_Errno e,
6365 void *response, size_t responseLen) {
6367 RLOGD("sendRequestRawResponse: serial %d", serial);
6370 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6371 RadioResponseInfo responseInfo = {};
6372 populateResponseInfo(responseInfo, serial, responseType, e);
6373 hidl_vec<uint8_t> data;
6375 if (response == NULL) {
6376 RLOGE("sendRequestRawResponse: Invalid response");
6377 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6379 data.setToExternal((uint8_t *) response, responseLen);
6381 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6382 sendRequestRawResponse(responseInfo, data);
6383 checkReturnStatus(slotId, retStatus, false);
6385 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6392 int radio::sendRequestStringsResponse(int slotId,
6393 int responseType, int serial, RIL_Errno e,
6394 void *response, size_t responseLen) {
6396 RLOGD("sendRequestStringsResponse: serial %d", serial);
6399 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6400 RadioResponseInfo responseInfo = {};
6401 populateResponseInfo(responseInfo, serial, responseType, e);
6402 hidl_vec<hidl_string> data;
6404 if (response == NULL || responseLen % sizeof(char *) != 0) {
6405 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6406 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6408 char **resp = (char **) response;
6409 int numStrings = responseLen / sizeof(char *);
6410 data.resize(numStrings);
6411 for (int i = 0; i < numStrings; i++) {
6412 data[i] = convertCharPtrToHidlString(resp[i]);
6415 Return<void> retStatus
6416 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6417 responseInfo, data);
6418 checkReturnStatus(slotId, retStatus, false);
6420 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6427 // Radio Indication functions
6429 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6430 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6431 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6434 int radio::radioStateChangedInd(int slotId,
6435 int indicationType, int token, RIL_Errno e, void *response,
6436 size_t responseLen) {
6437 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6438 RadioState radioState = (RadioState) s_vendorFunctions->onStateRequest();
6439 RLOGD("radioStateChangedInd: radioState %d", radioState);
6440 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6441 convertIntToRadioIndicationType(indicationType), radioState);
6442 radioService[slotId]->checkReturnStatus(retStatus);
6444 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6450 int radio::callStateChangedInd(int slotId,
6451 int indicationType, int token, RIL_Errno e, void *response,
6452 size_t responseLen) {
6453 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6455 RLOGD("callStateChangedInd");
6457 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6458 convertIntToRadioIndicationType(indicationType));
6459 radioService[slotId]->checkReturnStatus(retStatus);
6461 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6467 int radio::networkStateChangedInd(int slotId,
6468 int indicationType, int token, RIL_Errno e, void *response,
6469 size_t responseLen) {
6470 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6472 RLOGD("networkStateChangedInd");
6474 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6475 convertIntToRadioIndicationType(indicationType));
6476 radioService[slotId]->checkReturnStatus(retStatus);
6478 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6485 uint8_t hexCharToInt(uint8_t c) {
6486 if (c >= '0' && c <= '9') return (c - '0');
6487 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6488 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6490 return INVALID_HEX_CHAR;
6493 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6494 if (responseLen % 2 != 0) {
6498 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6499 if (bytes == NULL) {
6500 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6503 uint8_t *hexString = (uint8_t *)response;
6505 for (size_t i = 0; i < responseLen; i += 2) {
6506 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6507 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6509 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6510 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6511 hexString[i], hexString[i + 1]);
6515 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6521 int radio::newSmsInd(int slotId, int indicationType,
6522 int token, RIL_Errno e, void *response, size_t responseLen) {
6523 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6524 if (response == NULL || responseLen == 0) {
6525 RLOGE("newSmsInd: invalid response");
6529 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6530 if (bytes == NULL) {
6531 RLOGE("newSmsInd: convertHexStringToBytes failed");
6535 hidl_vec<uint8_t> pdu;
6536 pdu.setToExternal(bytes, responseLen/2);
6540 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6541 convertIntToRadioIndicationType(indicationType), pdu);
6542 radioService[slotId]->checkReturnStatus(retStatus);
6545 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6551 int radio::newSmsStatusReportInd(int slotId,
6552 int indicationType, int token, RIL_Errno e, void *response,
6553 size_t responseLen) {
6554 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6555 if (response == NULL || responseLen == 0) {
6556 RLOGE("newSmsStatusReportInd: invalid response");
6560 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6561 if (bytes == NULL) {
6562 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6566 hidl_vec<uint8_t> pdu;
6567 pdu.setToExternal(bytes, responseLen/2);
6569 RLOGD("newSmsStatusReportInd");
6571 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6572 convertIntToRadioIndicationType(indicationType), pdu);
6573 radioService[slotId]->checkReturnStatus(retStatus);
6576 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6582 int radio::newSmsOnSimInd(int slotId, int indicationType,
6583 int token, RIL_Errno e, void *response, size_t responseLen) {
6584 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6585 if (response == NULL || responseLen != sizeof(int)) {
6586 RLOGE("newSmsOnSimInd: invalid response");
6589 int32_t recordNumber = ((int32_t *) response)[0];
6591 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6593 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6594 convertIntToRadioIndicationType(indicationType), recordNumber);
6595 radioService[slotId]->checkReturnStatus(retStatus);
6597 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6603 int radio::onUssdInd(int slotId, int indicationType,
6604 int token, RIL_Errno e, void *response, size_t responseLen) {
6605 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6606 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6607 RLOGE("onUssdInd: invalid response");
6610 char **strings = (char **) response;
6611 char *mode = strings[0];
6612 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6613 UssdModeType modeType = (UssdModeType) atoi(mode);
6615 RLOGD("onUssdInd: mode %s", mode);
6617 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6618 convertIntToRadioIndicationType(indicationType), modeType, msg);
6619 radioService[slotId]->checkReturnStatus(retStatus);
6621 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6627 int radio::nitzTimeReceivedInd(int slotId,
6628 int indicationType, int token, RIL_Errno e, void *response,
6629 size_t responseLen) {
6630 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6631 if (response == NULL || responseLen == 0) {
6632 RLOGE("nitzTimeReceivedInd: invalid response");
6635 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6636 int64_t timeReceived = android::elapsedRealtime();
6638 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6641 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6642 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6643 radioService[slotId]->checkReturnStatus(retStatus);
6645 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6652 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6653 SignalStrength& signalStrength) {
6654 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6656 // Fixup LTE for backwards compatibility
6657 // signalStrength: -1 -> 99
6658 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6659 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6661 // rsrp: -1 -> INT_MAX all other negative value to positive.
6663 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6664 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6665 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6666 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6668 // rsrq: -1 -> INT_MAX
6669 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6670 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6672 // Not remapping rssnr is already using INT_MAX
6673 // cqi: -1 -> INT_MAX
6674 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6675 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6678 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6679 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6680 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6681 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6682 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6683 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6684 signalStrength.evdo.signalNoiseRatio =
6685 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6686 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6687 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6688 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6689 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6690 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6691 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6692 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6695 int radio::currentSignalStrengthInd(int slotId,
6696 int indicationType, int token, RIL_Errno e,
6697 void *response, size_t responseLen) {
6698 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6699 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
6700 RLOGE("currentSignalStrengthInd: invalid response");
6704 SignalStrength signalStrength = {};
6705 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6708 RLOGD("currentSignalStrengthInd");
6710 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6711 convertIntToRadioIndicationType(indicationType), signalStrength);
6712 radioService[slotId]->checkReturnStatus(retStatus);
6714 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6721 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6722 SetupDataCallResult& dcResult) {
6723 dcResult.status = (DataCallFailCause) dcResponse->status;
6724 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6725 dcResult.cid = dcResponse->cid;
6726 dcResult.active = dcResponse->active;
6727 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6728 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6729 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6730 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6731 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6732 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6733 dcResult.mtu = dcResponse->mtu;
6736 void convertRilDataCallListToHal(void *response, size_t responseLen,
6737 hidl_vec<SetupDataCallResult>& dcResultList) {
6738 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6740 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6741 dcResultList.resize(num);
6742 for (int i = 0; i < num; i++) {
6743 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6747 int radio::dataCallListChangedInd(int slotId,
6748 int indicationType, int token, RIL_Errno e, void *response,
6749 size_t responseLen) {
6750 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6751 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
6752 RLOGE("dataCallListChangedInd: invalid response");
6755 hidl_vec<SetupDataCallResult> dcList;
6756 convertRilDataCallListToHal(response, responseLen, dcList);
6758 RLOGD("dataCallListChangedInd");
6760 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
6761 convertIntToRadioIndicationType(indicationType), dcList);
6762 radioService[slotId]->checkReturnStatus(retStatus);
6764 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6770 int radio::suppSvcNotifyInd(int slotId, int indicationType,
6771 int token, RIL_Errno e, void *response, size_t responseLen) {
6772 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6773 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
6774 RLOGE("suppSvcNotifyInd: invalid response");
6778 SuppSvcNotification suppSvc = {};
6779 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6780 suppSvc.isMT = ssn->notificationType;
6781 suppSvc.code = ssn->code;
6782 suppSvc.index = ssn->index;
6783 suppSvc.type = ssn->type;
6784 suppSvc.number = convertCharPtrToHidlString(ssn->number);
6787 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
6788 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
6790 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
6791 convertIntToRadioIndicationType(indicationType), suppSvc);
6792 radioService[slotId]->checkReturnStatus(retStatus);
6794 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6800 int radio::stkSessionEndInd(int slotId, int indicationType,
6801 int token, RIL_Errno e, void *response, size_t responseLen) {
6802 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6804 RLOGD("stkSessionEndInd");
6806 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
6807 convertIntToRadioIndicationType(indicationType));
6808 radioService[slotId]->checkReturnStatus(retStatus);
6810 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
6816 int radio::stkProactiveCommandInd(int slotId,
6817 int indicationType, int token, RIL_Errno e, void *response,
6818 size_t responseLen) {
6819 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6820 if (response == NULL || responseLen == 0) {
6821 RLOGE("stkProactiveCommandInd: invalid response");
6825 RLOGD("stkProactiveCommandInd");
6827 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
6828 convertIntToRadioIndicationType(indicationType),
6829 convertCharPtrToHidlString((char *) response));
6830 radioService[slotId]->checkReturnStatus(retStatus);
6832 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
6838 int radio::stkEventNotifyInd(int slotId, int indicationType,
6839 int token, RIL_Errno e, void *response, size_t responseLen) {
6840 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6841 if (response == NULL || responseLen == 0) {
6842 RLOGE("stkEventNotifyInd: invalid response");
6846 RLOGD("stkEventNotifyInd");
6848 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
6849 convertIntToRadioIndicationType(indicationType),
6850 convertCharPtrToHidlString((char *) response));
6851 radioService[slotId]->checkReturnStatus(retStatus);
6853 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6859 int radio::stkCallSetupInd(int slotId, int indicationType,
6860 int token, RIL_Errno e, void *response, size_t responseLen) {
6861 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6862 if (response == NULL || responseLen != sizeof(int)) {
6863 RLOGE("stkCallSetupInd: invalid response");
6866 int32_t timeout = ((int32_t *) response)[0];
6868 RLOGD("stkCallSetupInd: timeout %d", timeout);
6870 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
6871 convertIntToRadioIndicationType(indicationType), timeout);
6872 radioService[slotId]->checkReturnStatus(retStatus);
6874 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
6880 int radio::simSmsStorageFullInd(int slotId,
6881 int indicationType, int token, RIL_Errno e, void *response,
6882 size_t responseLen) {
6883 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6885 RLOGD("simSmsStorageFullInd");
6887 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
6888 convertIntToRadioIndicationType(indicationType));
6889 radioService[slotId]->checkReturnStatus(retStatus);
6891 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
6897 int radio::simRefreshInd(int slotId, int indicationType,
6898 int token, RIL_Errno e, void *response, size_t responseLen) {
6899 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6900 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
6901 RLOGE("simRefreshInd: invalid response");
6905 SimRefreshResult refreshResult = {};
6906 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
6907 refreshResult.type =
6908 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
6909 refreshResult.efId = simRefreshResponse->ef_id;
6910 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
6913 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
6915 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
6916 convertIntToRadioIndicationType(indicationType), refreshResult);
6917 radioService[slotId]->checkReturnStatus(retStatus);
6919 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
6925 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
6926 CdmaSignalInfoRecord& record) {
6927 record.isPresent = signalInfoRecord->isPresent;
6928 record.signalType = signalInfoRecord->signalType;
6929 record.alertPitch = signalInfoRecord->alertPitch;
6930 record.signal = signalInfoRecord->signal;
6933 int radio::callRingInd(int slotId, int indicationType,
6934 int token, RIL_Errno e, void *response, size_t responseLen) {
6935 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6937 CdmaSignalInfoRecord record = {};
6938 if (response == NULL || responseLen == 0) {
6942 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
6943 RLOGE("callRingInd: invalid response");
6946 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
6950 RLOGD("callRingInd: isGsm %d", isGsm);
6952 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
6953 convertIntToRadioIndicationType(indicationType), isGsm, record);
6954 radioService[slotId]->checkReturnStatus(retStatus);
6956 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
6962 int radio::simStatusChangedInd(int slotId,
6963 int indicationType, int token, RIL_Errno e, void *response,
6964 size_t responseLen) {
6965 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6967 RLOGD("simStatusChangedInd");
6969 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
6970 convertIntToRadioIndicationType(indicationType));
6971 radioService[slotId]->checkReturnStatus(retStatus);
6973 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6979 int radio::cdmaNewSmsInd(int slotId, int indicationType,
6980 int token, RIL_Errno e, void *response, size_t responseLen) {
6981 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6982 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
6983 RLOGE("cdmaNewSmsInd: invalid response");
6987 CdmaSmsMessage msg = {};
6988 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
6989 msg.teleserviceId = rilMsg->uTeleserviceID;
6990 msg.isServicePresent = rilMsg->bIsServicePresent;
6991 msg.serviceCategory = rilMsg->uServicecategory;
6992 msg.address.digitMode =
6993 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
6994 msg.address.numberMode =
6995 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
6996 msg.address.numberType =
6997 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
6998 msg.address.numberPlan =
6999 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7001 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7002 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7004 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
7005 rilMsg->sSubAddress.subaddressType;
7006 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7008 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7009 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7011 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7012 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7015 RLOGD("cdmaNewSmsInd");
7017 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7018 convertIntToRadioIndicationType(indicationType), msg);
7019 radioService[slotId]->checkReturnStatus(retStatus);
7021 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7027 int radio::newBroadcastSmsInd(int slotId,
7028 int indicationType, int token, RIL_Errno e, void *response,
7029 size_t responseLen) {
7030 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7031 if (response == NULL || responseLen == 0) {
7032 RLOGE("newBroadcastSmsInd: invalid response");
7036 hidl_vec<uint8_t> data;
7037 data.setToExternal((uint8_t *) response, responseLen);
7039 RLOGD("newBroadcastSmsInd");
7041 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7042 convertIntToRadioIndicationType(indicationType), data);
7043 radioService[slotId]->checkReturnStatus(retStatus);
7045 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7051 int radio::cdmaRuimSmsStorageFullInd(int slotId,
7052 int indicationType, int token, RIL_Errno e, void *response,
7053 size_t responseLen) {
7054 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7056 RLOGD("cdmaRuimSmsStorageFullInd");
7058 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7059 convertIntToRadioIndicationType(indicationType));
7060 radioService[slotId]->checkReturnStatus(retStatus);
7062 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7069 int radio::restrictedStateChangedInd(int slotId,
7070 int indicationType, int token, RIL_Errno e, void *response,
7071 size_t responseLen) {
7072 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7073 if (response == NULL || responseLen != sizeof(int)) {
7074 RLOGE("restrictedStateChangedInd: invalid response");
7077 int32_t state = ((int32_t *) response)[0];
7079 RLOGD("restrictedStateChangedInd: state %d", state);
7081 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7082 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7083 radioService[slotId]->checkReturnStatus(retStatus);
7085 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7092 int radio::enterEmergencyCallbackModeInd(int slotId,
7093 int indicationType, int token, RIL_Errno e, void *response,
7094 size_t responseLen) {
7095 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7097 RLOGD("enterEmergencyCallbackModeInd");
7099 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7100 convertIntToRadioIndicationType(indicationType));
7101 radioService[slotId]->checkReturnStatus(retStatus);
7103 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7110 int radio::cdmaCallWaitingInd(int slotId,
7111 int indicationType, int token, RIL_Errno e, void *response,
7112 size_t responseLen) {
7113 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7114 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7115 RLOGE("cdmaCallWaitingInd: invalid response");
7119 CdmaCallWaiting callWaitingRecord = {};
7120 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7121 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7122 callWaitingRecord.numberPresentation =
7123 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7124 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7125 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7126 callWaitingRecord.signalInfoRecord);
7127 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7128 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7131 RLOGD("cdmaCallWaitingInd");
7133 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7134 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7135 radioService[slotId]->checkReturnStatus(retStatus);
7137 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7143 int radio::cdmaOtaProvisionStatusInd(int slotId,
7144 int indicationType, int token, RIL_Errno e, void *response,
7145 size_t responseLen) {
7146 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7147 if (response == NULL || responseLen != sizeof(int)) {
7148 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7151 int32_t status = ((int32_t *) response)[0];
7153 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7155 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7156 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7157 radioService[slotId]->checkReturnStatus(retStatus);
7159 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7166 int radio::cdmaInfoRecInd(int slotId,
7167 int indicationType, int token, RIL_Errno e, void *response,
7168 size_t responseLen) {
7169 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7170 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7171 RLOGE("cdmaInfoRecInd: invalid response");
7175 CdmaInformationRecords records = {};
7176 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7178 char* string8 = NULL;
7179 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7180 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7181 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7182 "additional ones", recordsRil->numberOfInfoRecs,
7183 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7185 records.infoRec.resize(num);
7186 for (int i = 0 ; i < num ; i++) {
7187 CdmaInformationRecord *record = &records.infoRec[i];
7188 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7189 record->name = (CdmaInfoRecName) infoRec->name;
7190 // All vectors should be size 0 except one which will be size 1. Set everything to
7191 // size 0 initially.
7192 record->display.resize(0);
7193 record->number.resize(0);
7194 record->signal.resize(0);
7195 record->redir.resize(0);
7196 record->lineCtrl.resize(0);
7197 record->clir.resize(0);
7198 record->audioCtrl.resize(0);
7199 switch (infoRec->name) {
7200 case RIL_CDMA_DISPLAY_INFO_REC:
7201 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7202 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7203 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7204 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7205 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7208 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7209 if (string8 == NULL) {
7210 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7211 "responseCdmaInformationRecords");
7214 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7215 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7217 record->display.resize(1);
7218 record->display[0].alphaBuf = string8;
7224 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7225 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7226 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7227 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7228 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7229 "expected not more than %d", (int) infoRec->rec.number.len,
7230 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7233 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7234 if (string8 == NULL) {
7235 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7236 "responseCdmaInformationRecords");
7239 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7240 string8[(int)infoRec->rec.number.len] = '\0';
7242 record->number.resize(1);
7243 record->number[0].number = string8;
7246 record->number[0].numberType = infoRec->rec.number.number_type;
7247 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7248 record->number[0].pi = infoRec->rec.number.pi;
7249 record->number[0].si = infoRec->rec.number.si;
7253 case RIL_CDMA_SIGNAL_INFO_REC: {
7254 record->signal.resize(1);
7255 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7256 record->signal[0].signalType = infoRec->rec.signal.signalType;
7257 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7258 record->signal[0].signal = infoRec->rec.signal.signal;
7262 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7263 if (infoRec->rec.redir.redirectingNumber.len >
7264 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7265 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7266 "expected not more than %d\n",
7267 (int)infoRec->rec.redir.redirectingNumber.len,
7268 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7271 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7273 if (string8 == NULL) {
7274 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7275 "responseCdmaInformationRecords");
7278 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7279 infoRec->rec.redir.redirectingNumber.len);
7280 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7282 record->redir.resize(1);
7283 record->redir[0].redirectingNumber.number = string8;
7286 record->redir[0].redirectingNumber.numberType =
7287 infoRec->rec.redir.redirectingNumber.number_type;
7288 record->redir[0].redirectingNumber.numberPlan =
7289 infoRec->rec.redir.redirectingNumber.number_plan;
7290 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7291 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7292 record->redir[0].redirectingReason =
7293 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7297 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7298 record->lineCtrl.resize(1);
7299 record->lineCtrl[0].lineCtrlPolarityIncluded =
7300 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7301 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7302 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7303 record->lineCtrl[0].lineCtrlPowerDenial =
7304 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7308 case RIL_CDMA_T53_CLIR_INFO_REC: {
7309 record->clir.resize(1);
7310 record->clir[0].cause = infoRec->rec.clir.cause;
7314 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7315 record->audioCtrl.resize(1);
7316 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7317 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7321 case RIL_CDMA_T53_RELEASE_INFO_REC:
7322 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7326 RLOGE("cdmaInfoRecInd: Incorrect name value");
7332 RLOGD("cdmaInfoRecInd");
7334 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7335 convertIntToRadioIndicationType(indicationType), records);
7336 radioService[slotId]->checkReturnStatus(retStatus);
7338 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7344 int radio::indicateRingbackToneInd(int slotId,
7345 int indicationType, int token, RIL_Errno e, void *response,
7346 size_t responseLen) {
7347 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7348 if (response == NULL || responseLen != sizeof(int)) {
7349 RLOGE("indicateRingbackToneInd: invalid response");
7352 bool start = ((int32_t *) response)[0];
7354 RLOGD("indicateRingbackToneInd: start %d", start);
7356 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7357 convertIntToRadioIndicationType(indicationType), start);
7358 radioService[slotId]->checkReturnStatus(retStatus);
7360 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7366 int radio::resendIncallMuteInd(int slotId,
7367 int indicationType, int token, RIL_Errno e, void *response,
7368 size_t responseLen) {
7369 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7371 RLOGD("resendIncallMuteInd");
7373 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7374 convertIntToRadioIndicationType(indicationType));
7375 radioService[slotId]->checkReturnStatus(retStatus);
7377 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7383 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7384 int indicationType, int token, RIL_Errno e,
7385 void *response, size_t responseLen) {
7386 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7387 if (response == NULL || responseLen != sizeof(int)) {
7388 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7391 int32_t cdmaSource = ((int32_t *) response)[0];
7393 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7395 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7396 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7397 (CdmaSubscriptionSource) cdmaSource);
7398 radioService[slotId]->checkReturnStatus(retStatus);
7400 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7407 int radio::cdmaPrlChangedInd(int slotId,
7408 int indicationType, int token, RIL_Errno e, void *response,
7409 size_t responseLen) {
7410 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7411 if (response == NULL || responseLen != sizeof(int)) {
7412 RLOGE("cdmaPrlChangedInd: invalid response");
7415 int32_t version = ((int32_t *) response)[0];
7417 RLOGD("cdmaPrlChangedInd: version %d", version);
7419 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7420 convertIntToRadioIndicationType(indicationType), version);
7421 radioService[slotId]->checkReturnStatus(retStatus);
7423 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7429 int radio::exitEmergencyCallbackModeInd(int slotId,
7430 int indicationType, int token, RIL_Errno e, void *response,
7431 size_t responseLen) {
7432 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7434 RLOGD("exitEmergencyCallbackModeInd");
7436 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7437 convertIntToRadioIndicationType(indicationType));
7438 radioService[slotId]->checkReturnStatus(retStatus);
7440 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7447 int radio::rilConnectedInd(int slotId,
7448 int indicationType, int token, RIL_Errno e, void *response,
7449 size_t responseLen) {
7450 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7451 RLOGD("rilConnectedInd");
7452 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7453 convertIntToRadioIndicationType(indicationType));
7454 radioService[slotId]->checkReturnStatus(retStatus);
7456 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7462 int radio::voiceRadioTechChangedInd(int slotId,
7463 int indicationType, int token, RIL_Errno e, void *response,
7464 size_t responseLen) {
7465 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7466 if (response == NULL || responseLen != sizeof(int)) {
7467 RLOGE("voiceRadioTechChangedInd: invalid response");
7470 int32_t rat = ((int32_t *) response)[0];
7472 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7474 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7475 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7476 radioService[slotId]->checkReturnStatus(retStatus);
7478 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7485 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7486 int num = responseLen / sizeof(RIL_CellInfo_v12);
7487 records.resize(num);
7489 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7490 for (int i = 0; i < num; i++) {
7491 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7492 records[i].registered = rillCellInfo->registered;
7493 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7494 records[i].timeStamp = rillCellInfo->timeStamp;
7495 // All vectors should be size 0 except one which will be size 1. Set everything to
7496 // size 0 initially.
7497 records[i].gsm.resize(0);
7498 records[i].wcdma.resize(0);
7499 records[i].cdma.resize(0);
7500 records[i].lte.resize(0);
7501 records[i].tdscdma.resize(0);
7502 switch(rillCellInfo->cellInfoType) {
7503 case RIL_CELL_INFO_TYPE_GSM: {
7504 records[i].gsm.resize(1);
7505 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7506 cellInfoGsm->cellIdentityGsm.mcc =
7507 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7508 cellInfoGsm->cellIdentityGsm.mnc =
7509 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7510 cellInfoGsm->cellIdentityGsm.lac =
7511 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7512 cellInfoGsm->cellIdentityGsm.cid =
7513 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7514 cellInfoGsm->cellIdentityGsm.arfcn =
7515 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7516 cellInfoGsm->cellIdentityGsm.bsic =
7517 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7518 cellInfoGsm->signalStrengthGsm.signalStrength =
7519 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7520 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7521 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7522 cellInfoGsm->signalStrengthGsm.timingAdvance =
7523 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7527 case RIL_CELL_INFO_TYPE_WCDMA: {
7528 records[i].wcdma.resize(1);
7529 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7530 cellInfoWcdma->cellIdentityWcdma.mcc =
7531 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7532 cellInfoWcdma->cellIdentityWcdma.mnc =
7533 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7534 cellInfoWcdma->cellIdentityWcdma.lac =
7535 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7536 cellInfoWcdma->cellIdentityWcdma.cid =
7537 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7538 cellInfoWcdma->cellIdentityWcdma.psc =
7539 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7540 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7541 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7542 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7543 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7544 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7545 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7549 case RIL_CELL_INFO_TYPE_CDMA: {
7550 records[i].cdma.resize(1);
7551 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7552 cellInfoCdma->cellIdentityCdma.networkId =
7553 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7554 cellInfoCdma->cellIdentityCdma.systemId =
7555 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7556 cellInfoCdma->cellIdentityCdma.baseStationId =
7557 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7558 cellInfoCdma->cellIdentityCdma.longitude =
7559 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7560 cellInfoCdma->cellIdentityCdma.latitude =
7561 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7562 cellInfoCdma->signalStrengthCdma.dbm =
7563 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7564 cellInfoCdma->signalStrengthCdma.ecio =
7565 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7566 cellInfoCdma->signalStrengthEvdo.dbm =
7567 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7568 cellInfoCdma->signalStrengthEvdo.ecio =
7569 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7570 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7571 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7575 case RIL_CELL_INFO_TYPE_LTE: {
7576 records[i].lte.resize(1);
7577 CellInfoLte *cellInfoLte = &records[i].lte[0];
7578 cellInfoLte->cellIdentityLte.mcc =
7579 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7580 cellInfoLte->cellIdentityLte.mnc =
7581 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7582 cellInfoLte->cellIdentityLte.ci =
7583 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7584 cellInfoLte->cellIdentityLte.pci =
7585 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7586 cellInfoLte->cellIdentityLte.tac =
7587 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7588 cellInfoLte->cellIdentityLte.earfcn =
7589 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7590 cellInfoLte->signalStrengthLte.signalStrength =
7591 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7592 cellInfoLte->signalStrengthLte.rsrp =
7593 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7594 cellInfoLte->signalStrengthLte.rsrq =
7595 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7596 cellInfoLte->signalStrengthLte.rssnr =
7597 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7598 cellInfoLte->signalStrengthLte.cqi =
7599 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7600 cellInfoLte->signalStrengthLte.timingAdvance =
7601 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7605 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7606 records[i].tdscdma.resize(1);
7607 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7608 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7609 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7610 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7611 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7612 cellInfoTdscdma->cellIdentityTdscdma.lac =
7613 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7614 cellInfoTdscdma->cellIdentityTdscdma.cid =
7615 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7616 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7617 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7618 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7619 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7630 int radio::cellInfoListInd(int slotId,
7631 int indicationType, int token, RIL_Errno e, void *response,
7632 size_t responseLen) {
7633 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7634 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7635 RLOGE("cellInfoListInd: invalid response");
7639 hidl_vec<CellInfo> records;
7640 convertRilCellInfoListToHal(response, responseLen, records);
7643 RLOGD("cellInfoListInd");
7645 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7646 convertIntToRadioIndicationType(indicationType), records);
7647 radioService[slotId]->checkReturnStatus(retStatus);
7649 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7655 int radio::imsNetworkStateChangedInd(int slotId,
7656 int indicationType, int token, RIL_Errno e, void *response,
7657 size_t responseLen) {
7658 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7660 RLOGD("imsNetworkStateChangedInd");
7662 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7663 convertIntToRadioIndicationType(indicationType));
7664 radioService[slotId]->checkReturnStatus(retStatus);
7666 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7673 int radio::subscriptionStatusChangedInd(int slotId,
7674 int indicationType, int token, RIL_Errno e, void *response,
7675 size_t responseLen) {
7676 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7677 if (response == NULL || responseLen != sizeof(int)) {
7678 RLOGE("subscriptionStatusChangedInd: invalid response");
7681 bool activate = ((int32_t *) response)[0];
7683 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7685 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
7686 convertIntToRadioIndicationType(indicationType), activate);
7687 radioService[slotId]->checkReturnStatus(retStatus);
7689 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
7696 int radio::srvccStateNotifyInd(int slotId,
7697 int indicationType, int token, RIL_Errno e, void *response,
7698 size_t responseLen) {
7699 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7700 if (response == NULL || responseLen != sizeof(int)) {
7701 RLOGE("srvccStateNotifyInd: invalid response");
7704 int32_t state = ((int32_t *) response)[0];
7706 RLOGD("srvccStateNotifyInd: rat %d", state);
7708 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
7709 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
7710 radioService[slotId]->checkReturnStatus(retStatus);
7712 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7718 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7719 hidl_vec<HardwareConfig>& records) {
7720 int num = responseLen / sizeof(RIL_HardwareConfig);
7721 records.resize(num);
7723 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7724 for (int i = 0; i < num; i++) {
7725 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7726 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7727 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7728 switch (rilHardwareConfig[i].type) {
7729 case RIL_HARDWARE_CONFIG_MODEM: {
7730 records[i].modem.resize(1);
7731 records[i].sim.resize(0);
7732 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7733 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7734 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7735 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7736 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7740 case RIL_HARDWARE_CONFIG_SIM: {
7741 records[i].sim.resize(1);
7742 records[i].modem.resize(0);
7743 records[i].sim[0].modemUuid =
7744 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7751 int radio::hardwareConfigChangedInd(int slotId,
7752 int indicationType, int token, RIL_Errno e, void *response,
7753 size_t responseLen) {
7754 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7755 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7756 RLOGE("hardwareConfigChangedInd: invalid response");
7760 hidl_vec<HardwareConfig> configs;
7761 convertRilHardwareConfigListToHal(response, responseLen, configs);
7764 RLOGD("hardwareConfigChangedInd");
7766 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
7767 convertIntToRadioIndicationType(indicationType), configs);
7768 radioService[slotId]->checkReturnStatus(retStatus);
7770 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
7777 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7778 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7779 rc.session = rilRadioCapability->session;
7780 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7781 rc.raf = rilRadioCapability->rat;
7782 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7783 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
7786 int radio::radioCapabilityIndicationInd(int slotId,
7787 int indicationType, int token, RIL_Errno e, void *response,
7788 size_t responseLen) {
7789 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7790 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
7791 RLOGE("radioCapabilityIndicationInd: invalid response");
7795 RadioCapability rc = {};
7796 convertRilRadioCapabilityToHal(response, responseLen, rc);
7799 RLOGD("radioCapabilityIndicationInd");
7801 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
7802 convertIntToRadioIndicationType(indicationType), rc);
7803 radioService[slotId]->checkReturnStatus(retStatus);
7805 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
7812 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
7813 if ((reqType == SS_INTERROGATION) &&
7814 (serType == SS_CFU ||
7815 serType == SS_CF_BUSY ||
7816 serType == SS_CF_NO_REPLY ||
7817 serType == SS_CF_NOT_REACHABLE ||
7818 serType == SS_CF_ALL ||
7819 serType == SS_CF_ALL_CONDITIONAL)) {
7825 int radio::onSupplementaryServiceIndicationInd(int slotId,
7826 int indicationType, int token, RIL_Errno e,
7827 void *response, size_t responseLen) {
7828 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7829 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
7830 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
7834 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
7835 StkCcUnsolSsResult ss = {};
7836 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
7837 ss.requestType = (SsRequestType) rilSsResponse->requestType;
7838 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
7839 ss.serviceClass = rilSsResponse->serviceClass;
7840 ss.result = (RadioError) rilSsResponse->result;
7842 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
7844 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
7845 rilSsResponse->cfData.numValidIndexes);
7847 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
7848 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
7849 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
7850 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
7853 ss.cfData.resize(1);
7854 ss.ssInfo.resize(0);
7856 /* number of call info's */
7857 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
7859 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
7860 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
7861 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
7863 cfInfo->status = (CallForwardInfoStatus) cf.status;
7864 cfInfo->reason = cf.reason;
7865 cfInfo->serviceClass = cf.serviceClass;
7866 cfInfo->toa = cf.toa;
7867 cfInfo->number = convertCharPtrToHidlString(cf.number);
7868 cfInfo->timeSeconds = cf.timeSeconds;
7870 RLOGD("onSupplementaryServiceIndicationInd: "
7871 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
7872 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
7876 ss.ssInfo.resize(1);
7877 ss.cfData.resize(0);
7880 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
7881 for (int i = 0; i < SS_INFO_MAX; i++) {
7883 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
7884 rilSsResponse->ssInfo[i]);
7886 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
7891 RLOGD("onSupplementaryServiceIndicationInd");
7893 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7894 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
7896 radioService[slotId]->checkReturnStatus(retStatus);
7898 RLOGE("onSupplementaryServiceIndicationInd: "
7899 "radioService[%d]->mRadioIndication == NULL", slotId);
7905 int radio::stkCallControlAlphaNotifyInd(int slotId,
7906 int indicationType, int token, RIL_Errno e, void *response,
7907 size_t responseLen) {
7908 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7909 if (response == NULL || responseLen == 0) {
7910 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
7914 RLOGD("stkCallControlAlphaNotifyInd");
7916 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
7917 convertIntToRadioIndicationType(indicationType),
7918 convertCharPtrToHidlString((char *) response));
7919 radioService[slotId]->checkReturnStatus(retStatus);
7921 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
7928 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
7929 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
7930 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
7931 lce.confidenceLevel = rilLceDataInfo->confidence_level;
7932 lce.lceSuspended = rilLceDataInfo->lce_suspended;
7935 int radio::lceDataInd(int slotId,
7936 int indicationType, int token, RIL_Errno e, void *response,
7937 size_t responseLen) {
7938 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7939 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
7940 RLOGE("lceDataInd: invalid response");
7944 LceDataInfo lce = {};
7945 convertRilLceDataInfoToHal(response, responseLen, lce);
7947 RLOGD("lceDataInd");
7949 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
7950 convertIntToRadioIndicationType(indicationType), lce);
7951 radioService[slotId]->checkReturnStatus(retStatus);
7953 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7959 int radio::pcoDataInd(int slotId,
7960 int indicationType, int token, RIL_Errno e, void *response,
7961 size_t responseLen) {
7962 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7963 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
7964 RLOGE("pcoDataInd: invalid response");
7968 PcoDataInfo pco = {};
7969 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
7970 pco.cid = rilPcoData->cid;
7971 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
7972 pco.pcoId = rilPcoData->pco_id;
7973 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
7976 RLOGD("pcoDataInd");
7978 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
7979 convertIntToRadioIndicationType(indicationType), pco);
7980 radioService[slotId]->checkReturnStatus(retStatus);
7982 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
7988 int radio::modemResetInd(int slotId,
7989 int indicationType, int token, RIL_Errno e, void *response,
7990 size_t responseLen) {
7991 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7992 if (response == NULL || responseLen == 0) {
7993 RLOGE("modemResetInd: invalid response");
7997 RLOGD("modemResetInd");
7999 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8000 convertIntToRadioIndicationType(indicationType),
8001 convertCharPtrToHidlString((char *) response));
8002 radioService[slotId]->checkReturnStatus(retStatus);
8004 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8010 int radio::carrierInfoForImsiEncryption(int slotId,
8011 int indicationType, int token, RIL_Errno e, void *response,
8012 size_t responseLen) {
8013 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8014 if (response == NULL || responseLen == 0) {
8015 RLOGE("carrierInfoForImsiEncryption: invalid response");
8018 RLOGD("carrierInfoForImsiEncryption");
8019 Return<sp<::android::hardware::radio::V1_1::IRadioIndication>> ret =
8020 ::android::hardware::radio::V1_1::IRadioIndication::castFrom(
8021 radioService[slotId]->mRadioIndication);
8023 sp<::android::hardware::radio::V1_1::IRadioIndication> radioIndicationV1_1 = ret;
8024 Return<void> retStatus = radioIndicationV1_1->carrierInfoForImsiEncryption(
8025 convertIntToRadioIndicationType(indicationType));
8026 radioService[slotId]->checkReturnStatus(retStatus);
8028 RLOGE("carrierInfoForImsiEncryptionResponse: ret.isOk() == false for radioService[%d]",
8032 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndication == NULL", slotId);
8038 int radio::oemHookRawInd(int slotId,
8039 int indicationType, int token, RIL_Errno e, void *response,
8040 size_t responseLen) {
8041 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8042 if (response == NULL || responseLen == 0) {
8043 RLOGE("oemHookRawInd: invalid response");
8047 hidl_vec<uint8_t> data;
8048 data.setToExternal((uint8_t *) response, responseLen);
8050 RLOGD("oemHookRawInd");
8052 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8053 convertIntToRadioIndicationType(indicationType), data);
8054 checkReturnStatus(slotId, retStatus, false);
8056 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8062 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8063 using namespace android::hardware;
8065 const char *serviceNames[] = {
8066 android::RIL_getServiceName()
8067 #if (SIM_COUNT >= 2)
8069 #if (SIM_COUNT >= 3)
8071 #if (SIM_COUNT >= 4)
8078 #if (SIM_COUNT >= 2)
8079 simCount = SIM_COUNT;
8082 configureRpcThreadpool(1, true /* callerWillJoin */);
8083 for (int i = 0; i < simCount; i++) {
8084 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8085 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8088 radioService[i] = new RadioImpl;
8089 radioService[i]->mSlotId = i;
8090 oemHookService[i] = new OemHookImpl;
8091 oemHookService[i]->mSlotId = i;
8092 RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
8094 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8095 status = oemHookService[i]->registerAsService(serviceNames[i]);
8097 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8101 s_vendorFunctions = callbacks;
8102 s_commands = commands;
8105 void rilc_thread_pool() {
8106 joinRpcThreadpool();
8109 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8110 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8112 #if (SIM_COUNT >= 2)
8113 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8114 #if (SIM_COUNT >= 3)
8115 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8116 #if (SIM_COUNT >= 4)
8117 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8122 return radioServiceRwlockPtr;