2 * Copyright (c) 2016 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #define LOG_TAG "RILC"
19 #include <android/hardware/radio/1.1/IRadio.h>
20 #include <android/hardware/radio/1.1/IRadioResponse.h>
21 #include <android/hardware/radio/1.1/IRadioIndication.h>
22 #include <android/hardware/radio/1.1/types.h>
24 #include <android/hardware/radio/deprecated/1.0/IOemHook.h>
26 #include <hwbinder/IPCThreadState.h>
27 #include <hwbinder/ProcessState.h>
28 #include <ril_service.h>
29 #include <hidl/HidlTransportSupport.h>
30 #include <utils/SystemClock.h>
33 #define INVALID_HEX_CHAR 16
35 using namespace android::hardware::radio::V1_0;
36 using namespace android::hardware::radio::deprecated::V1_0;
37 using ::android::hardware::configureRpcThreadpool;
38 using ::android::hardware::joinRpcThreadpool;
39 using ::android::hardware::Return;
40 using ::android::hardware::hidl_string;
41 using ::android::hardware::hidl_vec;
42 using ::android::hardware::hidl_array;
43 using ::android::hardware::radio::V1_1::NetworkScanRequest;
44 using ::android::hardware::radio::V1_1::KeepaliveRequest;
45 using ::android::hardware::Void;
46 using android::CommandInfo;
47 using android::RequestInfo;
48 using android::requestToString;
51 #define BOOL_TO_INT(x) (x ? 1 : 0)
52 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
53 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
55 RIL_RadioFunctions *s_vendorFunctions = NULL;
56 static CommandInfo *s_commands;
62 sp<RadioImpl> radioService[SIM_COUNT];
63 sp<OemHookImpl> oemHookService[SIM_COUNT];
64 // counter used for synchronization. It is incremented every time response callbacks are updated.
65 volatile int32_t mCounterRadio[SIM_COUNT];
66 volatile int32_t mCounterOemHook[SIM_COUNT];
68 sp<RadioImpl> radioService[1];
69 sp<OemHookImpl> oemHookService[1];
70 // counter used for synchronization. It is incremented every time response callbacks are updated.
71 volatile int32_t mCounterRadio[1];
72 volatile int32_t mCounterOemHook[1];
75 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
78 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
80 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
82 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
87 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
88 hidl_vec<HardwareConfig>& records);
90 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
92 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
94 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
95 SignalStrength& signalStrength);
97 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
98 SetupDataCallResult& dcResult);
100 void convertRilDataCallListToHal(void *response, size_t responseLen,
101 hidl_vec<SetupDataCallResult>& dcResultList);
103 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
105 struct RadioImpl : public ::android::hardware::radio::V1_1::IRadio {
107 sp<IRadioResponse> mRadioResponse;
108 sp<IRadioIndication> mRadioIndication;
110 Return<void> setResponseFunctions(
111 const ::android::sp<IRadioResponse>& radioResponse,
112 const ::android::sp<IRadioIndication>& radioIndication);
114 Return<void> getIccCardStatus(int32_t serial);
116 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
117 const hidl_string& aid);
119 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
120 const hidl_string& pin, const hidl_string& aid);
122 Return<void> supplyIccPin2ForApp(int32_t serial,
123 const hidl_string& pin2,
124 const hidl_string& aid);
126 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
127 const hidl_string& pin2, const hidl_string& aid);
129 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
130 const hidl_string& newPin, const hidl_string& aid);
132 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
133 const hidl_string& newPin2, const hidl_string& aid);
135 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
137 Return<void> getCurrentCalls(int32_t serial);
139 Return<void> dial(int32_t serial, const Dial& dialInfo);
141 Return<void> getImsiForApp(int32_t serial,
142 const ::android::hardware::hidl_string& aid);
144 Return<void> hangup(int32_t serial, int32_t gsmIndex);
146 Return<void> hangupWaitingOrBackground(int32_t serial);
148 Return<void> hangupForegroundResumeBackground(int32_t serial);
150 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
152 Return<void> conference(int32_t serial);
154 Return<void> rejectCall(int32_t serial);
156 Return<void> getLastCallFailCause(int32_t serial);
158 Return<void> getSignalStrength(int32_t serial);
160 Return<void> getVoiceRegistrationState(int32_t serial);
162 Return<void> getDataRegistrationState(int32_t serial);
164 Return<void> getOperator(int32_t serial);
166 Return<void> setRadioPower(int32_t serial, bool on);
168 Return<void> sendDtmf(int32_t serial,
169 const ::android::hardware::hidl_string& s);
171 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
173 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
175 Return<void> setupDataCall(int32_t serial,
176 RadioTechnology radioTechnology,
177 const DataProfileInfo& profileInfo,
182 Return<void> iccIOForApp(int32_t serial,
185 Return<void> sendUssd(int32_t serial,
186 const ::android::hardware::hidl_string& ussd);
188 Return<void> cancelPendingUssd(int32_t serial);
190 Return<void> getClir(int32_t serial);
192 Return<void> setClir(int32_t serial, int32_t status);
194 Return<void> getCallForwardStatus(int32_t serial,
195 const CallForwardInfo& callInfo);
197 Return<void> setCallForward(int32_t serial,
198 const CallForwardInfo& callInfo);
200 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
202 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
204 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
205 bool success, SmsAcknowledgeFailCause cause);
207 Return<void> acceptCall(int32_t serial);
209 Return<void> deactivateDataCall(int32_t serial,
210 int32_t cid, bool reasonRadioShutDown);
212 Return<void> getFacilityLockForApp(int32_t serial,
213 const ::android::hardware::hidl_string& facility,
214 const ::android::hardware::hidl_string& password,
215 int32_t serviceClass,
216 const ::android::hardware::hidl_string& appId);
218 Return<void> setFacilityLockForApp(int32_t serial,
219 const ::android::hardware::hidl_string& facility,
221 const ::android::hardware::hidl_string& password,
222 int32_t serviceClass,
223 const ::android::hardware::hidl_string& appId);
225 Return<void> setBarringPassword(int32_t serial,
226 const ::android::hardware::hidl_string& facility,
227 const ::android::hardware::hidl_string& oldPassword,
228 const ::android::hardware::hidl_string& newPassword);
230 Return<void> getNetworkSelectionMode(int32_t serial);
232 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
234 Return<void> setNetworkSelectionModeManual(int32_t serial,
235 const ::android::hardware::hidl_string& operatorNumeric);
237 Return<void> getAvailableNetworks(int32_t serial);
239 Return<void> startNetworkScan(int32_t serial, const NetworkScanRequest& request);
241 Return<void> stopNetworkScan(int32_t serial);
243 Return<void> startDtmf(int32_t serial,
244 const ::android::hardware::hidl_string& s);
246 Return<void> stopDtmf(int32_t serial);
248 Return<void> getBasebandVersion(int32_t serial);
250 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
252 Return<void> setMute(int32_t serial, bool enable);
254 Return<void> getMute(int32_t serial);
256 Return<void> getClip(int32_t serial);
258 Return<void> getDataCallList(int32_t serial);
260 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
262 Return<void> writeSmsToSim(int32_t serial,
263 const SmsWriteArgs& smsWriteArgs);
265 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
267 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
269 Return<void> getAvailableBandModes(int32_t serial);
271 Return<void> sendEnvelope(int32_t serial,
272 const ::android::hardware::hidl_string& command);
274 Return<void> sendTerminalResponseToSim(int32_t serial,
275 const ::android::hardware::hidl_string& commandResponse);
277 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
279 Return<void> explicitCallTransfer(int32_t serial);
281 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
283 Return<void> getPreferredNetworkType(int32_t serial);
285 Return<void> getNeighboringCids(int32_t serial);
287 Return<void> setLocationUpdates(int32_t serial, bool enable);
289 Return<void> setCdmaSubscriptionSource(int32_t serial,
290 CdmaSubscriptionSource cdmaSub);
292 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
294 Return<void> getCdmaRoamingPreference(int32_t serial);
296 Return<void> setTTYMode(int32_t serial, TtyMode mode);
298 Return<void> getTTYMode(int32_t serial);
300 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
302 Return<void> getPreferredVoicePrivacy(int32_t serial);
304 Return<void> sendCDMAFeatureCode(int32_t serial,
305 const ::android::hardware::hidl_string& featureCode);
307 Return<void> sendBurstDtmf(int32_t serial,
308 const ::android::hardware::hidl_string& dtmf,
312 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
314 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
315 const CdmaSmsAck& smsAck);
317 Return<void> getGsmBroadcastConfig(int32_t serial);
319 Return<void> setGsmBroadcastConfig(int32_t serial,
320 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
322 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
324 Return<void> getCdmaBroadcastConfig(int32_t serial);
326 Return<void> setCdmaBroadcastConfig(int32_t serial,
327 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
329 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
331 Return<void> getCDMASubscription(int32_t serial);
333 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
335 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
337 Return<void> getDeviceIdentity(int32_t serial);
339 Return<void> exitEmergencyCallbackMode(int32_t serial);
341 Return<void> getSmscAddress(int32_t serial);
343 Return<void> setSmscAddress(int32_t serial,
344 const ::android::hardware::hidl_string& smsc);
346 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
348 Return<void> reportStkServiceIsRunning(int32_t serial);
350 Return<void> getCdmaSubscriptionSource(int32_t serial);
352 Return<void> requestIsimAuthentication(int32_t serial,
353 const ::android::hardware::hidl_string& challenge);
355 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
357 const ::android::hardware::hidl_string& ackPdu);
359 Return<void> sendEnvelopeWithStatus(int32_t serial,
360 const ::android::hardware::hidl_string& contents);
362 Return<void> getVoiceRadioTechnology(int32_t serial);
364 Return<void> getCellInfoList(int32_t serial);
366 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
368 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
369 bool modemCognitive, bool isRoaming);
371 Return<void> getImsRegistrationState(int32_t serial);
373 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
375 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
377 Return<void> iccOpenLogicalChannel(int32_t serial,
378 const ::android::hardware::hidl_string& aid, int32_t p2);
380 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
382 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
384 Return<void> nvReadItem(int32_t serial, NvItem itemId);
386 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
388 Return<void> nvWriteCdmaPrl(int32_t serial,
389 const ::android::hardware::hidl_vec<uint8_t>& prl);
391 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
393 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
395 Return<void> setDataAllowed(int32_t serial, bool allow);
397 Return<void> getHardwareConfig(int32_t serial);
399 Return<void> requestIccSimAuthentication(int32_t serial,
401 const ::android::hardware::hidl_string& authData,
402 const ::android::hardware::hidl_string& aid);
404 Return<void> setDataProfile(int32_t serial,
405 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
407 Return<void> requestShutdown(int32_t serial);
409 Return<void> getRadioCapability(int32_t serial);
411 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
413 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
415 Return<void> stopLceService(int32_t serial);
417 Return<void> pullLceData(int32_t serial);
419 Return<void> getModemActivityInfo(int32_t serial);
421 Return<void> setAllowedCarriers(int32_t serial,
423 const CarrierRestrictions& carriers);
425 Return<void> getAllowedCarriers(int32_t serial);
427 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
429 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
431 Return<void> startKeepalive(int32_t serial, const KeepaliveRequest& keepalive);
433 Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
435 Return<void> setSimCardPower(int32_t serial, bool powerUp);
436 Return<void> setSimCardPower_1_1(int32_t serial,
437 const ::android::hardware::radio::V1_1::CardPowerState state);
439 Return<void> responseAcknowledgement();
441 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
442 const ::android::hardware::radio::V1_1::ImsiEncryptionInfo& message);
444 void checkReturnStatus(Return<void>& ret);
447 struct OemHookImpl : public IOemHook {
449 sp<IOemHookResponse> mOemHookResponse;
450 sp<IOemHookIndication> mOemHookIndication;
452 Return<void> setResponseFunctions(
453 const ::android::sp<IOemHookResponse>& oemHookResponse,
454 const ::android::sp<IOemHookIndication>& oemHookIndication);
456 Return<void> sendRequestRaw(int32_t serial,
457 const ::android::hardware::hidl_vec<uint8_t>& data);
459 Return<void> sendRequestStrings(int32_t serial,
460 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
463 void memsetAndFreeStrings(int numPointers, ...) {
465 va_start(ap, numPointers);
466 for (int i = 0; i < numPointers; i++) {
467 char *ptr = va_arg(ap, char *);
470 #define MAX_STRING_LENGTH 4096
471 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
479 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
480 pRI->pCI->responseFunction((int) pRI->socket_id,
481 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
485 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
486 * request with error RIL_E_NO_MEMORY.
487 * Returns true on success, and false on failure.
489 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
490 size_t len = src.size();
495 *dest = (char *) calloc(len + 1, sizeof(char));
497 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
498 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
501 strncpy(*dest, src.c_str(), len + 1);
505 hidl_string convertCharPtrToHidlString(const char *ptr) {
508 // TODO: replace this with strnlen
509 ret.setToExternal(ptr, strlen(ptr));
514 bool dispatchVoid(int serial, int slotId, int request) {
515 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
519 s_vendorFunctions->onRequest(request, NULL, 0, pRI);
523 bool dispatchString(int serial, int slotId, int request, const char * str) {
524 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
530 if (!copyHidlStringToRil(&pString, str, pRI)) {
534 s_vendorFunctions->onRequest(request, pString, sizeof(char *), pRI);
536 memsetAndFreeStrings(1, pString);
540 bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) {
541 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
547 pStrings = (char **)calloc(countStrings, sizeof(char *));
548 if (pStrings == NULL) {
549 RLOGE("Memory allocation failed for request %s", requestToString(request));
550 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
554 va_start(ap, countStrings);
555 for (int i = 0; i < countStrings; i++) {
556 const char* str = va_arg(ap, const char *);
557 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI)) {
559 for (int j = 0; j < i; j++) {
560 memsetAndFreeStrings(1, pStrings[j]);
568 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
570 if (pStrings != NULL) {
571 for (int i = 0 ; i < countStrings ; i++) {
572 memsetAndFreeStrings(1, pStrings[i]);
576 memset(pStrings, 0, countStrings * sizeof(char *));
583 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
584 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
589 int countStrings = data.size();
591 pStrings = (char **)calloc(countStrings, sizeof(char *));
592 if (pStrings == NULL) {
593 RLOGE("Memory allocation failed for request %s", requestToString(request));
594 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
598 for (int i = 0; i < countStrings; i++) {
599 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
600 for (int j = 0; j < i; j++) {
601 memsetAndFreeStrings(1, pStrings[j]);
608 s_vendorFunctions->onRequest(request, pStrings, countStrings * sizeof(char *), pRI);
610 if (pStrings != NULL) {
611 for (int i = 0 ; i < countStrings ; i++) {
612 memsetAndFreeStrings(1, pStrings[i]);
616 memset(pStrings, 0, countStrings * sizeof(char *));
623 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
624 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
629 int *pInts = (int *)calloc(countInts, sizeof(int));
632 RLOGE("Memory allocation failed for request %s", requestToString(request));
633 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
637 va_start(ap, countInts);
638 for (int i = 0; i < countInts; i++) {
639 pInts[i] = va_arg(ap, int);
643 s_vendorFunctions->onRequest(request, pInts, countInts * sizeof(int), pRI);
647 memset(pInts, 0, countInts * sizeof(int));
654 bool dispatchCallForwardStatus(int serial, int slotId, int request,
655 const CallForwardInfo& callInfo) {
656 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
661 RIL_CallForwardInfo cf;
662 cf.status = (int) callInfo.status;
663 cf.reason = callInfo.reason;
664 cf.serviceClass = callInfo.serviceClass;
665 cf.toa = callInfo.toa;
666 cf.timeSeconds = callInfo.timeSeconds;
668 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
672 s_vendorFunctions->onRequest(request, &cf, sizeof(cf), pRI);
674 memsetAndFreeStrings(1, cf.number);
679 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
680 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
685 const uint8_t *uData = rawBytes.data();
687 s_vendorFunctions->onRequest(request, (void *) uData, rawBytes.size(), pRI);
692 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
693 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
698 RIL_SIM_APDU apdu = {};
700 apdu.sessionid = message.sessionId;
701 apdu.cla = message.cla;
702 apdu.instruction = message.instruction;
703 apdu.p1 = message.p1;
704 apdu.p2 = message.p2;
705 apdu.p3 = message.p3;
707 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
711 s_vendorFunctions->onRequest(request, &apdu, sizeof(apdu), pRI);
713 memsetAndFreeStrings(1, apdu.data);
718 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
719 if (ret.isOk() == false) {
720 RLOGE("checkReturnStatus: unable to call response/indication callback");
721 // Remote process hosting the callbacks must be dead. Reset the callback objects;
722 // there's no other recovery to be done here. When the client process is back up, it will
723 // call setResponseFunctions()
725 // Caller should already hold rdlock, release that first
726 // note the current counter to avoid overwriting updates made by another thread before
727 // write lock is acquired.
728 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
729 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
730 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
734 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
737 // make sure the counter value has not changed
738 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
739 if (isRadioService) {
740 radioService[slotId]->mRadioResponse = NULL;
741 radioService[slotId]->mRadioIndication = NULL;
743 oemHookService[slotId]->mOemHookResponse = NULL;
744 oemHookService[slotId]->mOemHookIndication = NULL;
746 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
748 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
749 "got updated on another thread");
753 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
757 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
762 void RadioImpl::checkReturnStatus(Return<void>& ret) {
763 ::checkReturnStatus(mSlotId, ret, true);
766 Return<void> RadioImpl::setResponseFunctions(
767 const ::android::sp<IRadioResponse>& radioResponseParam,
768 const ::android::sp<IRadioIndication>& radioIndicationParam) {
769 RLOGD("setResponseFunctions");
771 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
772 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
775 mRadioResponse = radioResponseParam;
776 mRadioIndication = radioIndicationParam;
777 mCounterRadio[mSlotId]++;
779 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
782 // client is connected. Send initial indications.
783 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
788 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
790 RLOGD("getIccCardStatus: serial %d", serial);
792 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
796 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
797 const hidl_string& aid) {
799 RLOGD("supplyIccPinForApp: serial %d", serial);
801 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
802 2, pin.c_str(), aid.c_str());
806 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
807 const hidl_string& pin, const hidl_string& aid) {
809 RLOGD("supplyIccPukForApp: serial %d", serial);
811 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
812 3, puk.c_str(), pin.c_str(), aid.c_str());
816 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
817 const hidl_string& aid) {
819 RLOGD("supplyIccPin2ForApp: serial %d", serial);
821 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
822 2, pin2.c_str(), aid.c_str());
826 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
827 const hidl_string& pin2, const hidl_string& aid) {
829 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
831 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
832 3, puk2.c_str(), pin2.c_str(), aid.c_str());
836 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
837 const hidl_string& newPin, const hidl_string& aid) {
839 RLOGD("changeIccPinForApp: serial %d", serial);
841 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
842 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
846 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
847 const hidl_string& newPin2, const hidl_string& aid) {
849 RLOGD("changeIccPin2ForApp: serial %d", serial);
851 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
852 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
856 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
857 const hidl_string& netPin) {
859 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
861 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
866 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
868 RLOGD("getCurrentCalls: serial %d", serial);
870 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
874 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
876 RLOGD("dial: serial %d", serial);
878 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
883 RIL_UUS_Info uusInfo = {};
884 int32_t sizeOfDial = sizeof(dial);
886 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
889 dial.clir = (int) dialInfo.clir;
891 if (dialInfo.uusInfo.size() != 0) {
892 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
893 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
895 if (dialInfo.uusInfo[0].uusData.size() == 0) {
896 uusInfo.uusData = NULL;
897 uusInfo.uusLength = 0;
899 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
900 memsetAndFreeStrings(1, dial.address);
903 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
906 dial.uusInfo = &uusInfo;
909 s_vendorFunctions->onRequest(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI);
911 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
916 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
918 RLOGD("getImsiForApp: serial %d", serial);
920 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
925 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
927 RLOGD("hangup: serial %d", serial);
929 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
933 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
935 RLOGD("hangupWaitingOrBackground: serial %d", serial);
937 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
941 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
943 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
945 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
949 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
951 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
953 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
957 Return<void> RadioImpl::conference(int32_t serial) {
959 RLOGD("conference: serial %d", serial);
961 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
965 Return<void> RadioImpl::rejectCall(int32_t serial) {
967 RLOGD("rejectCall: serial %d", serial);
969 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
973 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
975 RLOGD("getLastCallFailCause: serial %d", serial);
977 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
981 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
983 RLOGD("getSignalStrength: serial %d", serial);
985 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
989 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
991 RLOGD("getVoiceRegistrationState: serial %d", serial);
993 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
997 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
999 RLOGD("getDataRegistrationState: serial %d", serial);
1001 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1005 Return<void> RadioImpl::getOperator(int32_t serial) {
1007 RLOGD("getOperator: serial %d", serial);
1009 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1013 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
1014 RLOGD("setRadioPower: serial %d on %d", serial, on);
1015 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1019 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1021 RLOGD("sendDtmf: serial %d", serial);
1023 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1027 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1029 RLOGD("sendSms: serial %d", serial);
1031 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
1032 2, message.smscPdu.c_str(), message.pdu.c_str());
1036 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1038 RLOGD("sendSMSExpectMore: serial %d", serial);
1040 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
1041 2, message.smscPdu.c_str(), message.pdu.c_str());
1045 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1047 case MvnoType::IMSI:
1048 str = (char *)"imsi";
1051 str = (char *)"gid";
1054 str = (char *)"spn";
1056 case MvnoType::NONE:
1063 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1064 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1065 bool roamingAllowed, bool isRoaming) {
1068 RLOGD("setupDataCall: serial %d", serial);
1071 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1072 const hidl_string &protocol =
1073 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1074 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
1075 std::to_string((int) radioTechnology + 2).c_str(),
1076 std::to_string((int) dataProfileInfo.profileId).c_str(),
1077 dataProfileInfo.apn.c_str(),
1078 dataProfileInfo.user.c_str(),
1079 dataProfileInfo.password.c_str(),
1080 std::to_string((int) dataProfileInfo.authType).c_str(),
1082 } else if (s_vendorFunctions->version >= 15) {
1083 char *mvnoTypeStr = NULL;
1084 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1085 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1086 RIL_REQUEST_SETUP_DATA_CALL);
1088 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1092 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1093 std::to_string((int) radioTechnology + 2).c_str(),
1094 std::to_string((int) dataProfileInfo.profileId).c_str(),
1095 dataProfileInfo.apn.c_str(),
1096 dataProfileInfo.user.c_str(),
1097 dataProfileInfo.password.c_str(),
1098 std::to_string((int) dataProfileInfo.authType).c_str(),
1099 dataProfileInfo.protocol.c_str(),
1100 dataProfileInfo.roamingProtocol.c_str(),
1101 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1102 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1103 modemCognitive ? "1" : "0",
1104 std::to_string(dataProfileInfo.mtu).c_str(),
1106 dataProfileInfo.mvnoMatchData.c_str(),
1107 roamingAllowed ? "1" : "0");
1109 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1110 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1111 RIL_REQUEST_SETUP_DATA_CALL);
1113 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1119 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1121 RLOGD("iccIOForApp: serial %d", serial);
1123 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1128 RIL_SIM_IO_v6 rilIccIo = {};
1129 rilIccIo.command = iccIo.command;
1130 rilIccIo.fileid = iccIo.fileId;
1131 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1135 rilIccIo.p1 = iccIo.p1;
1136 rilIccIo.p2 = iccIo.p2;
1137 rilIccIo.p3 = iccIo.p3;
1139 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1140 memsetAndFreeStrings(1, rilIccIo.path);
1144 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1145 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1149 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1150 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1154 s_vendorFunctions->onRequest(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI);
1156 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1161 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1163 RLOGD("sendUssd: serial %d", serial);
1165 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1169 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1171 RLOGD("cancelPendingUssd: serial %d", serial);
1173 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1177 Return<void> RadioImpl::getClir(int32_t serial) {
1179 RLOGD("getClir: serial %d", serial);
1181 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1185 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1187 RLOGD("setClir: serial %d", serial);
1189 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1193 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1195 RLOGD("getCallForwardStatus: serial %d", serial);
1197 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1202 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1204 RLOGD("setCallForward: serial %d", serial);
1206 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1211 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1213 RLOGD("getCallWaiting: serial %d", serial);
1215 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1219 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1221 RLOGD("setCallWaiting: serial %d", serial);
1223 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1228 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1229 bool success, SmsAcknowledgeFailCause cause) {
1231 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1233 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1238 Return<void> RadioImpl::acceptCall(int32_t serial) {
1240 RLOGD("acceptCall: serial %d", serial);
1242 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1246 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1247 int32_t cid, bool reasonRadioShutDown) {
1249 RLOGD("deactivateDataCall: serial %d", serial);
1251 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1252 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1256 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1257 const hidl_string& password, int32_t serviceClass,
1258 const hidl_string& appId) {
1260 RLOGD("getFacilityLockForApp: serial %d", serial);
1262 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1263 4, facility.c_str(), password.c_str(),
1264 (std::to_string(serviceClass)).c_str(), appId.c_str());
1268 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1269 bool lockState, const hidl_string& password,
1270 int32_t serviceClass, const hidl_string& appId) {
1272 RLOGD("setFacilityLockForApp: serial %d", serial);
1274 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1275 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1276 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1280 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1281 const hidl_string& oldPassword,
1282 const hidl_string& newPassword) {
1284 RLOGD("setBarringPassword: serial %d", serial);
1286 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1287 2, oldPassword.c_str(), newPassword.c_str());
1291 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1293 RLOGD("getNetworkSelectionMode: serial %d", serial);
1295 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1299 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1301 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1303 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1307 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1308 const hidl_string& operatorNumeric) {
1310 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1312 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1313 operatorNumeric.c_str());
1317 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1319 RLOGD("getAvailableNetworks: serial %d", serial);
1321 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1325 Return<void> RadioImpl::startNetworkScan(int32_t serial, const NetworkScanRequest& request) {
1327 RLOGD("startNetworkScan: serial %d", serial);
1330 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1335 if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
1336 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1340 RIL_NetworkScanRequest scan_request = {};
1342 scan_request.type = (RIL_ScanType) request.type;
1343 scan_request.interval = request.interval;
1344 scan_request.specifiers_length = request.specifiers.size();
1345 for (size_t i = 0; i < request.specifiers.size(); ++i) {
1346 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
1347 request.specifiers[i].utranBands.size() > MAX_BANDS ||
1348 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
1349 request.specifiers[i].channels.size() > MAX_CHANNELS) {
1350 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1353 const ::android::hardware::radio::V1_1::RadioAccessSpecifier& ras_from =
1354 request.specifiers[i];
1355 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
1357 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
1358 ras_to.channels_length = ras_from.channels.size();
1360 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
1361 const std::vector<uint32_t> * bands = nullptr;
1362 switch (request.specifiers[i].radioAccessNetwork) {
1363 case ::android::hardware::radio::V1_1::RadioAccessNetworks::GERAN:
1364 ras_to.bands_length = ras_from.geranBands.size();
1365 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
1367 case ::android::hardware::radio::V1_1::RadioAccessNetworks::UTRAN:
1368 ras_to.bands_length = ras_from.utranBands.size();
1369 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
1371 case ::android::hardware::radio::V1_1::RadioAccessNetworks::EUTRAN:
1372 ras_to.bands_length = ras_from.eutranBands.size();
1373 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
1376 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1379 // safe to copy to geran_bands because it's a union member
1380 std::memcpy(&ras_to.bands.geran_bands, bands, ras_to.bands_length * sizeof(uint32_t));
1383 s_vendorFunctions->onRequest(
1384 RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI);
1389 Return<void> RadioImpl::stopNetworkScan(int32_t serial) {
1391 RLOGD("stopNetworkScan: serial %d", serial);
1393 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1397 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1399 RLOGD("startDtmf: serial %d", serial);
1401 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1406 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1408 RLOGD("stopDtmf: serial %d", serial);
1410 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1414 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1416 RLOGD("getBasebandVersion: serial %d", serial);
1418 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1422 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1424 RLOGD("separateConnection: serial %d", serial);
1426 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1430 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1432 RLOGD("setMute: serial %d", serial);
1434 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1438 Return<void> RadioImpl::getMute(int32_t serial) {
1440 RLOGD("getMute: serial %d", serial);
1442 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1446 Return<void> RadioImpl::getClip(int32_t serial) {
1448 RLOGD("getClip: serial %d", serial);
1450 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1454 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1456 RLOGD("getDataCallList: serial %d", serial);
1458 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1462 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1464 RLOGD("setSuppServiceNotifications: serial %d", serial);
1466 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1467 BOOL_TO_INT(enable));
1471 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1473 RLOGD("writeSmsToSim: serial %d", serial);
1475 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1480 RIL_SMS_WriteArgs args;
1481 args.status = (int) smsWriteArgs.status;
1484 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1488 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1489 memsetAndFreeStrings(1, args.pdu);
1493 s_vendorFunctions->onRequest(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI);
1495 memsetAndFreeStrings(2, args.smsc, args.pdu);
1500 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1502 RLOGD("deleteSmsOnSim: serial %d", serial);
1504 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1508 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1510 RLOGD("setBandMode: serial %d", serial);
1512 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1516 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1518 RLOGD("getAvailableBandModes: serial %d", serial);
1520 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1524 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1526 RLOGD("sendEnvelope: serial %d", serial);
1528 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1533 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1534 const hidl_string& commandResponse) {
1536 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1538 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1539 commandResponse.c_str());
1543 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1545 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1547 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1548 1, BOOL_TO_INT(accept));
1552 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1554 RLOGD("explicitCallTransfer: serial %d", serial);
1556 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1560 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1562 RLOGD("setPreferredNetworkType: serial %d", serial);
1564 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1568 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1570 RLOGD("getPreferredNetworkType: serial %d", serial);
1572 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1576 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1578 RLOGD("getNeighboringCids: serial %d", serial);
1580 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1584 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1586 RLOGD("setLocationUpdates: serial %d", serial);
1588 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1592 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1594 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1596 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1600 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1602 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1604 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1608 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1610 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1612 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1616 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1618 RLOGD("setTTYMode: serial %d", serial);
1620 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1624 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1626 RLOGD("getTTYMode: serial %d", serial);
1628 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1632 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1634 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1636 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1637 1, BOOL_TO_INT(enable));
1641 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1643 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1645 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1649 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1651 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1653 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1654 featureCode.c_str());
1658 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1661 RLOGD("sendBurstDtmf: serial %d", serial);
1663 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1664 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1665 (std::to_string(off)).c_str());
1669 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1670 rcsm.uTeleserviceID = sms.teleserviceId;
1671 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1672 rcsm.uServicecategory = sms.serviceCategory;
1673 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1674 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1675 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1676 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1678 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1679 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1680 for (int i = 0; i < digitLimit; i++) {
1681 rcsm.sAddress.digits[i] = sms.address.digits[i];
1684 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1685 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1687 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1688 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1689 for (int i = 0; i < digitLimit; i++) {
1690 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1693 rcsm.uBearerDataLen = sms.bearerData.size();
1694 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1695 for (int i = 0; i < digitLimit; i++) {
1696 rcsm.aBearerData[i] = sms.bearerData[i];
1700 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1702 RLOGD("sendCdmaSms: serial %d", serial);
1704 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1709 RIL_CDMA_SMS_Message rcsm = {};
1710 constructCdmaSms(rcsm, sms);
1712 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI);
1716 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1718 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1720 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1725 RIL_CDMA_SMS_Ack rcsa = {};
1727 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1728 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1730 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI);
1734 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1736 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1738 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1742 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1743 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1746 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1748 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1749 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1754 int num = configInfo.size();
1755 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1756 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1758 for (int i = 0 ; i < num ; i++ ) {
1759 gsmBciPtrs[i] = &gsmBci[i];
1760 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1761 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1762 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1763 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1764 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1767 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, gsmBciPtrs,
1768 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI);
1772 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1774 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1776 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1777 1, BOOL_TO_INT(!activate));
1781 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1783 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1785 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1789 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1790 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1793 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1795 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1796 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1801 int num = configInfo.size();
1802 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1803 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1805 for (int i = 0 ; i < num ; i++ ) {
1806 cdmaBciPtrs[i] = &cdmaBci[i];
1807 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1808 cdmaBci[i].language = configInfo[i].language;
1809 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1812 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, cdmaBciPtrs,
1813 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI);
1817 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1819 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1821 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1822 1, BOOL_TO_INT(!activate));
1826 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1828 RLOGD("getCDMASubscription: serial %d", serial);
1830 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1834 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1836 RLOGD("writeSmsToRuim: serial %d", serial);
1838 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1839 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1844 RIL_CDMA_SMS_WriteArgs rcsw = {};
1845 rcsw.status = (int) cdmaSms.status;
1846 constructCdmaSms(rcsw.message, cdmaSms.message);
1848 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI);
1852 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1854 RLOGD("deleteSmsOnRuim: serial %d", serial);
1856 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1860 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1862 RLOGD("getDeviceIdentity: serial %d", serial);
1864 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1868 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1870 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1872 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1876 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1878 RLOGD("getSmscAddress: serial %d", serial);
1880 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1884 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1886 RLOGD("setSmscAddress: serial %d", serial);
1888 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1893 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1895 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1897 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1898 BOOL_TO_INT(available));
1902 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1904 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1906 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1910 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1912 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1914 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1918 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1920 RLOGD("requestIsimAuthentication: serial %d", serial);
1922 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1927 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1928 const hidl_string& ackPdu) {
1930 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1932 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1933 2, success ? "1" : "0", ackPdu.c_str());
1937 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1939 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1941 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1946 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1948 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1950 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1954 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1956 RLOGD("getCellInfoList: serial %d", serial);
1958 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1962 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1964 RLOGD("setCellInfoListRate: serial %d", serial);
1966 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1970 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1971 bool modemCognitive, bool isRoaming) {
1973 RLOGD("setInitialAttachApn: serial %d", serial);
1975 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1976 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
1981 if (s_vendorFunctions->version <= 14) {
1982 RIL_InitialAttachApn iaa = {};
1984 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
1988 const hidl_string &protocol =
1989 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1991 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
1992 memsetAndFreeStrings(1, iaa.apn);
1995 iaa.authtype = (int) dataProfileInfo.authType;
1996 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
1997 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2000 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2001 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
2005 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
2007 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
2009 RIL_InitialAttachApn_v15 iaa = {};
2011 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
2014 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
2015 memsetAndFreeStrings(1, iaa.apn);
2018 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
2019 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2022 iaa.authtype = (int) dataProfileInfo.authType;
2023 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2024 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
2027 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2028 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
2031 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
2032 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
2033 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
2034 iaa.mtu = dataProfileInfo.mtu;
2036 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
2037 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2038 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2043 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
2044 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2049 s_vendorFunctions->onRequest(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI);
2051 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2052 iaa.password, iaa.mvnoMatchData);
2058 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
2060 RLOGD("getImsRegistrationState: serial %d", serial);
2062 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2066 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2067 RIL_IMS_SMS_Message rism = {};
2069 int countStrings = 2;
2070 int dataLen = sizeof(char *) * countStrings;
2072 rism.tech = RADIO_TECH_3GPP;
2073 rism.retry = BOOL_TO_INT(message.retry);
2074 rism.messageRef = message.messageRef;
2076 if (message.gsmMessage.size() != 1) {
2077 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2078 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2082 pStrings = (char **)calloc(countStrings, sizeof(char *));
2083 if (pStrings == NULL) {
2084 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2085 requestToString(pRI->pCI->requestNumber));
2086 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2090 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2092 memset(pStrings, 0, dataLen);
2098 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2099 memsetAndFreeStrings(1, pStrings[0]);
2101 memset(pStrings, 0, dataLen);
2107 rism.message.gsmMessage = pStrings;
2108 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2109 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI);
2111 for (int i = 0 ; i < countStrings ; i++) {
2112 memsetAndFreeStrings(1, pStrings[i]);
2116 memset(pStrings, 0, dataLen);
2123 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2124 RIL_IMS_SMS_Message rism = {};
2125 RIL_CDMA_SMS_Message rcsm = {};
2127 if (message.cdmaMessage.size() != 1) {
2128 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2129 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2133 rism.tech = RADIO_TECH_3GPP2;
2134 rism.retry = BOOL_TO_INT(message.retry);
2135 rism.messageRef = message.messageRef;
2136 rism.message.cdmaMessage = &rcsm;
2138 constructCdmaSms(rcsm, message.cdmaMessage[0]);
2140 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2141 sizeof(uint8_t) + sizeof(int32_t) + sizeof(rcsm), pRI);
2146 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2148 RLOGD("sendImsSms: serial %d", serial);
2150 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2155 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2157 if (RADIO_TECH_3GPP == format) {
2158 dispatchImsGsmSms(message, pRI);
2159 } else if (RADIO_TECH_3GPP2 == format) {
2160 dispatchImsCdmaSms(message, pRI);
2162 RLOGE("sendImsSms: Invalid radio tech %s",
2163 requestToString(pRI->pCI->requestNumber));
2164 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2169 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2171 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2173 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2177 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2179 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2181 if (s_vendorFunctions->version < 15) {
2182 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2184 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2189 RIL_OpenChannelParams params = {};
2193 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2197 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI);
2199 memsetAndFreeStrings(1, params.aidPtr);
2204 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2206 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2208 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2212 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2214 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2216 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2220 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2222 RLOGD("nvReadItem: serial %d", serial);
2224 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2229 RIL_NV_ReadItem nvri = {};
2230 nvri.itemID = (RIL_NV_Item) itemId;
2232 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI);
2236 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2238 RLOGD("nvWriteItem: serial %d", serial);
2240 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2245 RIL_NV_WriteItem nvwi = {};
2247 nvwi.itemID = (RIL_NV_Item) item.itemId;
2249 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2253 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI);
2255 memsetAndFreeStrings(1, nvwi.value);
2259 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2261 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2263 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2267 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2268 int rilResetType = -1;
2270 RLOGD("nvResetConfig: serial %d", serial);
2272 /* Convert ResetNvType to RIL.h values
2273 * RIL_REQUEST_NV_RESET_CONFIG
2274 * 1 - reload all NV items
2275 * 2 - erase NV reset (SCRTN)
2276 * 3 - factory reset (RTN)
2279 case ResetNvType::RELOAD:
2282 case ResetNvType::ERASE:
2285 case ResetNvType::FACTORY_RESET:
2289 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2293 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2295 RLOGD("setUiccSubscription: serial %d", serial);
2297 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2298 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2303 RIL_SelectUiccSub rilUiccSub = {};
2305 rilUiccSub.slot = uiccSub.slot;
2306 rilUiccSub.app_index = uiccSub.appIndex;
2307 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2308 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2310 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI);
2314 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2316 RLOGD("setDataAllowed: serial %d", serial);
2318 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2322 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2324 RLOGD("getHardwareConfig: serial %d", serial);
2326 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2330 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2331 const hidl_string& authData, const hidl_string& aid) {
2333 RLOGD("requestIccSimAuthentication: serial %d", serial);
2335 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2340 RIL_SimAuthentication pf = {};
2342 pf.authContext = authContext;
2345 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2349 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2350 memsetAndFreeStrings(1, pf.authData);
2354 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI);
2356 memsetAndFreeStrings(2, pf.authData, pf.aid);
2361 * @param numProfiles number of data profile
2362 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2363 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2364 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2365 * @param numfields number of string-type member in the data profile structure
2366 * @param ... the variadic parameters are pointers to each string-type member
2368 template <typename T>
2369 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2370 int numfields, ...) {
2372 va_start(args, numfields);
2374 // Iterate through each string-type field that need to be free.
2375 for (int i = 0; i < numfields; i++) {
2376 // Iterate through each data profile and free that specific string-type field.
2377 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2378 char *T::*ptr = va_arg(args, char *T::*);
2379 for (int j = 0; j < numProfiles; j++) {
2380 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2387 memset(dataProfiles, 0, numProfiles * sizeof(T));
2388 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2391 free(dataProfilePtrs);
2394 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2397 RLOGD("setDataProfile: serial %d", serial);
2399 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2404 size_t num = profiles.size();
2405 bool success = false;
2407 if (s_vendorFunctions->version <= 14) {
2409 RIL_DataProfileInfo *dataProfiles =
2410 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2412 if (dataProfiles == NULL) {
2413 RLOGE("Memory allocation failed for request %s",
2414 requestToString(pRI->pCI->requestNumber));
2415 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2419 RIL_DataProfileInfo **dataProfilePtrs =
2420 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2421 if (dataProfilePtrs == NULL) {
2422 RLOGE("Memory allocation failed for request %s",
2423 requestToString(pRI->pCI->requestNumber));
2425 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2429 for (size_t i = 0; i < num; i++) {
2430 dataProfilePtrs[i] = &dataProfiles[i];
2432 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2434 const hidl_string &protocol =
2435 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2437 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2441 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2444 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2450 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2451 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2452 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2456 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2457 dataProfiles[i].authType = (int) profiles[i].authType;
2458 dataProfiles[i].type = (int) profiles[i].type;
2459 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2460 dataProfiles[i].maxConns = profiles[i].maxConns;
2461 dataProfiles[i].waitTime = profiles[i].waitTime;
2462 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2465 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2466 num * sizeof(RIL_DataProfileInfo *), pRI);
2468 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2469 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2470 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2472 RIL_DataProfileInfo_v15 *dataProfiles =
2473 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2475 if (dataProfiles == NULL) {
2476 RLOGE("Memory allocation failed for request %s",
2477 requestToString(pRI->pCI->requestNumber));
2478 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2482 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2483 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2484 if (dataProfilePtrs == NULL) {
2485 RLOGE("Memory allocation failed for request %s",
2486 requestToString(pRI->pCI->requestNumber));
2488 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2492 for (size_t i = 0; i < num; i++) {
2493 dataProfilePtrs[i] = &dataProfiles[i];
2495 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2496 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2500 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2501 profiles[i].roamingProtocol, pRI)) {
2504 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2507 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2511 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2512 profiles[i].mvnoMatchData, pRI)) {
2516 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2517 dataProfiles[i].mvnoType)) {
2518 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2523 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2524 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2525 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2526 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2530 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2531 dataProfiles[i].authType = (int) profiles[i].authType;
2532 dataProfiles[i].type = (int) profiles[i].type;
2533 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2534 dataProfiles[i].maxConns = profiles[i].maxConns;
2535 dataProfiles[i].waitTime = profiles[i].waitTime;
2536 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2537 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2538 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2539 dataProfiles[i].mtu = profiles[i].mtu;
2542 s_vendorFunctions->onRequest(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2543 num * sizeof(RIL_DataProfileInfo_v15 *), pRI);
2545 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2546 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2547 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2548 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2554 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2556 RLOGD("requestShutdown: serial %d", serial);
2558 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2562 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2564 RLOGD("getRadioCapability: serial %d", serial);
2566 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2570 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2572 RLOGD("setRadioCapability: serial %d", serial);
2574 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2579 RIL_RadioCapability rilRc = {};
2581 // TODO : set rilRc.version using HIDL version ?
2582 rilRc.session = rc.session;
2583 rilRc.phase = (int) rc.phase;
2584 rilRc.rat = (int) rc.raf;
2585 rilRc.status = (int) rc.status;
2586 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2588 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI);
2593 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2595 RLOGD("startLceService: serial %d", serial);
2597 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2598 BOOL_TO_INT(pullMode));
2602 Return<void> RadioImpl::stopLceService(int32_t serial) {
2604 RLOGD("stopLceService: serial %d", serial);
2606 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2610 Return<void> RadioImpl::pullLceData(int32_t serial) {
2612 RLOGD("pullLceData: serial %d", serial);
2614 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2618 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2620 RLOGD("getModemActivityInfo: serial %d", serial);
2622 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2626 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2627 const CarrierRestrictions& carriers) {
2629 RLOGD("setAllowedCarriers: serial %d", serial);
2631 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2632 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2637 RIL_CarrierRestrictions cr = {};
2638 RIL_Carrier *allowedCarriers = NULL;
2639 RIL_Carrier *excludedCarriers = NULL;
2641 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2642 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2643 if (allowedCarriers == NULL) {
2644 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2645 requestToString(pRI->pCI->requestNumber));
2646 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2649 cr.allowed_carriers = allowedCarriers;
2651 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2652 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2653 if (excludedCarriers == NULL) {
2654 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2655 requestToString(pRI->pCI->requestNumber));
2656 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2658 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2660 free(allowedCarriers);
2663 cr.excluded_carriers = excludedCarriers;
2665 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2666 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2667 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2668 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2669 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2672 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2673 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2674 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2675 excludedCarriers[i].match_type =
2676 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2677 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2680 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI);
2683 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2684 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2686 free(allowedCarriers);
2687 free(excludedCarriers);
2691 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2693 RLOGD("getAllowedCarriers: serial %d", serial);
2695 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2699 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2702 RLOGD("sendDeviceState: serial %d", serial);
2704 if (s_vendorFunctions->version < 15) {
2705 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2706 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2707 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2709 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2710 RIL_REQUEST_SEND_DEVICE_STATE);
2711 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2715 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2716 BOOL_TO_INT(state));
2720 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2722 RLOGD("setIndicationFilter: serial %d", serial);
2724 if (s_vendorFunctions->version < 15) {
2725 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2726 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2727 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2730 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2734 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2736 RLOGD("setSimCardPower: serial %d", serial);
2738 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2742 Return<void> RadioImpl::setSimCardPower_1_1(int32_t serial,
2743 const ::android::hardware::radio::V1_1::CardPowerState state) {
2745 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
2747 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
2751 Return<void> RadioImpl::responseAcknowledgement() {
2752 android::releaseWakeLock();
2756 Return<void> OemHookImpl::setResponseFunctions(
2757 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2758 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2760 RLOGD("OemHookImpl::setResponseFunctions");
2763 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2764 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2767 mOemHookResponse = oemHookResponseParam;
2768 mOemHookIndication = oemHookIndicationParam;
2769 mCounterOemHook[mSlotId]++;
2771 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2777 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2779 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2781 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2785 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2786 const hidl_vec<hidl_string>& data) {
2788 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2790 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2794 Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial,
2795 const ::android::hardware::radio::V1_1::ImsiEncryptionInfo& data) {
2796 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
2797 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
2798 RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
2800 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
2803 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
2804 memsetAndFreeStrings(1, imsiEncryption.mnc);
2807 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
2808 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
2811 int32_t lSize = data.carrierKey.size();
2812 imsiEncryption.carrierKey = new uint8_t[lSize];
2813 memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), lSize);
2814 imsiEncryption.expirationTime = data.expirationTime;
2815 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &imsiEncryption, sizeof(RIL_CarrierInfoForImsiEncryption), pRI);
2816 delete(imsiEncryption.carrierKey);
2820 Return<void> RadioImpl::startKeepalive(int32_t serial, const KeepaliveRequest& keepalive) {
2821 RLOGD("startKeepalive: serial %d", serial);
2825 Return<void> RadioImpl::stopKeepalive(int32_t serial, int32_t sessionHandle) {
2826 RLOGD("stopKeepalive: serial %d", serial);
2831 /***************************************************************************************************
2832 * RESPONSE FUNCTIONS
2833 * Functions above are used for requests going from framework to vendor code. The ones below are
2834 * responses for those requests coming back from the vendor code.
2835 **************************************************************************************************/
2837 void radio::acknowledgeRequest(int slotId, int serial) {
2838 if (radioService[slotId]->mRadioResponse != NULL) {
2839 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2840 radioService[slotId]->checkReturnStatus(retStatus);
2842 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2846 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2848 responseInfo.serial = serial;
2849 switch (responseType) {
2850 case RESPONSE_SOLICITED:
2851 responseInfo.type = RadioResponseType::SOLICITED;
2853 case RESPONSE_SOLICITED_ACK_EXP:
2854 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2857 responseInfo.error = (RadioError) e;
2860 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2861 void *response, size_t responseLen) {
2862 populateResponseInfo(responseInfo, serial, responseType, e);
2865 if (response == NULL && responseLen == 0) {
2866 // Earlier RILs did not send a response for some cases although the interface
2867 // expected an integer as response. Do not return error if response is empty. Instead
2868 // Return -1 in those cases to maintain backward compatibility.
2869 } else if (response == NULL || responseLen != sizeof(int)) {
2870 RLOGE("responseIntOrEmpty: Invalid response");
2871 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2873 int *p_int = (int *) response;
2879 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2880 void *response, size_t responseLen) {
2881 populateResponseInfo(responseInfo, serial, responseType, e);
2884 if (response == NULL || responseLen != sizeof(int)) {
2885 RLOGE("responseInt: Invalid response");
2886 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2888 int *p_int = (int *) response;
2894 int radio::getIccCardStatusResponse(int slotId,
2895 int responseType, int serial, RIL_Errno e,
2896 void *response, size_t responseLen) {
2897 if (radioService[slotId]->mRadioResponse != NULL) {
2898 RadioResponseInfo responseInfo = {};
2899 populateResponseInfo(responseInfo, serial, responseType, e);
2900 CardStatus cardStatus = {};
2901 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2902 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)
2903 || p_cur->gsm_umts_subscription_app_index >= p_cur->num_applications
2904 || p_cur->cdma_subscription_app_index >= p_cur->num_applications
2905 || p_cur->ims_subscription_app_index >= p_cur->num_applications) {
2906 RLOGE("getIccCardStatusResponse: Invalid response");
2907 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2909 cardStatus.cardState = (CardState) p_cur->card_state;
2910 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2911 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2912 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2913 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2915 RIL_AppStatus *rilAppStatus = p_cur->applications;
2916 cardStatus.applications.resize(p_cur->num_applications);
2917 AppStatus *appStatus = cardStatus.applications.data();
2919 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2921 for (int i = 0; i < p_cur->num_applications; i++) {
2922 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2923 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2924 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2925 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2926 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2927 rilAppStatus[i].app_label_ptr);
2928 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2929 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2930 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2934 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2935 getIccCardStatusResponse(responseInfo, cardStatus);
2936 radioService[slotId]->checkReturnStatus(retStatus);
2938 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2944 int radio::supplyIccPinForAppResponse(int slotId,
2945 int responseType, int serial, RIL_Errno e,
2946 void *response, size_t responseLen) {
2948 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
2951 if (radioService[slotId]->mRadioResponse != NULL) {
2952 RadioResponseInfo responseInfo = {};
2953 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2954 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2955 supplyIccPinForAppResponse(responseInfo, ret);
2956 radioService[slotId]->checkReturnStatus(retStatus);
2958 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
2965 int radio::supplyIccPukForAppResponse(int slotId,
2966 int responseType, int serial, RIL_Errno e,
2967 void *response, size_t responseLen) {
2969 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
2972 if (radioService[slotId]->mRadioResponse != NULL) {
2973 RadioResponseInfo responseInfo = {};
2974 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2975 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
2977 radioService[slotId]->checkReturnStatus(retStatus);
2979 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
2986 int radio::supplyIccPin2ForAppResponse(int slotId,
2987 int responseType, int serial, RIL_Errno e,
2988 void *response, size_t responseLen) {
2990 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
2993 if (radioService[slotId]->mRadioResponse != NULL) {
2994 RadioResponseInfo responseInfo = {};
2995 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
2996 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2997 supplyIccPin2ForAppResponse(responseInfo, ret);
2998 radioService[slotId]->checkReturnStatus(retStatus);
3000 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3007 int radio::supplyIccPuk2ForAppResponse(int slotId,
3008 int responseType, int serial, RIL_Errno e,
3009 void *response, size_t responseLen) {
3011 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
3014 if (radioService[slotId]->mRadioResponse != NULL) {
3015 RadioResponseInfo responseInfo = {};
3016 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3017 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3018 supplyIccPuk2ForAppResponse(responseInfo, ret);
3019 radioService[slotId]->checkReturnStatus(retStatus);
3021 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3028 int radio::changeIccPinForAppResponse(int slotId,
3029 int responseType, int serial, RIL_Errno e,
3030 void *response, size_t responseLen) {
3032 RLOGD("changeIccPinForAppResponse: serial %d", serial);
3035 if (radioService[slotId]->mRadioResponse != NULL) {
3036 RadioResponseInfo responseInfo = {};
3037 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3038 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3039 changeIccPinForAppResponse(responseInfo, ret);
3040 radioService[slotId]->checkReturnStatus(retStatus);
3042 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3049 int radio::changeIccPin2ForAppResponse(int slotId,
3050 int responseType, int serial, RIL_Errno e,
3051 void *response, size_t responseLen) {
3053 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
3056 if (radioService[slotId]->mRadioResponse != NULL) {
3057 RadioResponseInfo responseInfo = {};
3058 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3059 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3060 changeIccPin2ForAppResponse(responseInfo, ret);
3061 radioService[slotId]->checkReturnStatus(retStatus);
3063 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3070 int radio::supplyNetworkDepersonalizationResponse(int slotId,
3071 int responseType, int serial, RIL_Errno e,
3072 void *response, size_t responseLen) {
3074 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
3077 if (radioService[slotId]->mRadioResponse != NULL) {
3078 RadioResponseInfo responseInfo = {};
3079 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3080 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3081 supplyNetworkDepersonalizationResponse(responseInfo, ret);
3082 radioService[slotId]->checkReturnStatus(retStatus);
3084 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
3091 int radio::getCurrentCallsResponse(int slotId,
3092 int responseType, int serial, RIL_Errno e,
3093 void *response, size_t responseLen) {
3095 RLOGD("getCurrentCallsResponse: serial %d", serial);
3098 if (radioService[slotId]->mRadioResponse != NULL) {
3099 RadioResponseInfo responseInfo = {};
3100 populateResponseInfo(responseInfo, serial, responseType, e);
3102 hidl_vec<Call> calls;
3103 if (response == NULL || (responseLen % sizeof(RIL_Call *)) != 0) {
3104 RLOGE("getCurrentCallsResponse: Invalid response");
3105 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3107 int num = responseLen / sizeof(RIL_Call *);
3110 for (int i = 0 ; i < num ; i++) {
3111 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3112 /* each call info */
3113 calls[i].state = (CallState) p_cur->state;
3114 calls[i].index = p_cur->index;
3115 calls[i].toa = p_cur->toa;
3116 calls[i].isMpty = p_cur->isMpty;
3117 calls[i].isMT = p_cur->isMT;
3118 calls[i].als = p_cur->als;
3119 calls[i].isVoice = p_cur->isVoice;
3120 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3121 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3122 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3123 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3124 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3125 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3126 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3127 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3128 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3129 // convert uusInfo->uusData to a null-terminated string
3130 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3131 calls[i].uusInfo[0].uusData = nullTermStr;
3137 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3138 getCurrentCallsResponse(responseInfo, calls);
3139 radioService[slotId]->checkReturnStatus(retStatus);
3141 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3147 int radio::dialResponse(int slotId,
3148 int responseType, int serial, RIL_Errno e, void *response,
3149 size_t responseLen) {
3151 RLOGD("dialResponse: serial %d", serial);
3154 if (radioService[slotId]->mRadioResponse != NULL) {
3155 RadioResponseInfo responseInfo = {};
3156 populateResponseInfo(responseInfo, serial, responseType, e);
3157 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3158 radioService[slotId]->checkReturnStatus(retStatus);
3160 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3166 int radio::getIMSIForAppResponse(int slotId,
3167 int responseType, int serial, RIL_Errno e, void *response,
3168 size_t responseLen) {
3170 RLOGD("getIMSIForAppResponse: serial %d", serial);
3173 if (radioService[slotId]->mRadioResponse != NULL) {
3174 RadioResponseInfo responseInfo = {};
3175 populateResponseInfo(responseInfo, serial, responseType, e);
3176 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3177 responseInfo, convertCharPtrToHidlString((char *) response));
3178 radioService[slotId]->checkReturnStatus(retStatus);
3180 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3187 int radio::hangupConnectionResponse(int slotId,
3188 int responseType, int serial, RIL_Errno e,
3189 void *response, size_t responseLen) {
3191 RLOGD("hangupConnectionResponse: serial %d", serial);
3194 if (radioService[slotId]->mRadioResponse != NULL) {
3195 RadioResponseInfo responseInfo = {};
3196 populateResponseInfo(responseInfo, serial, responseType, e);
3197 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3199 radioService[slotId]->checkReturnStatus(retStatus);
3201 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3208 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3209 int responseType, int serial, RIL_Errno e,
3210 void *response, size_t responseLen) {
3212 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3215 if (radioService[slotId]->mRadioResponse != NULL) {
3216 RadioResponseInfo responseInfo = {};
3217 populateResponseInfo(responseInfo, serial, responseType, e);
3218 Return<void> retStatus =
3219 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3221 radioService[slotId]->checkReturnStatus(retStatus);
3223 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3230 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3231 RIL_Errno e, void *response,
3232 size_t responseLen) {
3234 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3237 if (radioService[slotId]->mRadioResponse != NULL) {
3238 RadioResponseInfo responseInfo = {};
3239 populateResponseInfo(responseInfo, serial, responseType, e);
3240 Return<void> retStatus =
3241 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3243 radioService[slotId]->checkReturnStatus(retStatus);
3245 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3252 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3253 RIL_Errno e, void *response,
3254 size_t responseLen) {
3256 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3259 if (radioService[slotId]->mRadioResponse != NULL) {
3260 RadioResponseInfo responseInfo = {};
3261 populateResponseInfo(responseInfo, serial, responseType, e);
3262 Return<void> retStatus =
3263 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3265 radioService[slotId]->checkReturnStatus(retStatus);
3267 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3274 int radio::conferenceResponse(int slotId, int responseType,
3275 int serial, RIL_Errno e, void *response, size_t responseLen) {
3277 RLOGD("conferenceResponse: serial %d", serial);
3280 if (radioService[slotId]->mRadioResponse != NULL) {
3281 RadioResponseInfo responseInfo = {};
3282 populateResponseInfo(responseInfo, serial, responseType, e);
3283 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3285 radioService[slotId]->checkReturnStatus(retStatus);
3287 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3294 int radio::rejectCallResponse(int slotId, int responseType,
3295 int serial, RIL_Errno e, void *response, size_t responseLen) {
3297 RLOGD("rejectCallResponse: serial %d", serial);
3300 if (radioService[slotId]->mRadioResponse != NULL) {
3301 RadioResponseInfo responseInfo = {};
3302 populateResponseInfo(responseInfo, serial, responseType, e);
3303 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3305 radioService[slotId]->checkReturnStatus(retStatus);
3307 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3314 int radio::getLastCallFailCauseResponse(int slotId,
3315 int responseType, int serial, RIL_Errno e, void *response,
3316 size_t responseLen) {
3318 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3321 if (radioService[slotId]->mRadioResponse != NULL) {
3322 RadioResponseInfo responseInfo = {};
3323 populateResponseInfo(responseInfo, serial, responseType, e);
3325 LastCallFailCauseInfo info = {};
3326 info.vendorCause = hidl_string();
3327 if (response == NULL) {
3328 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3329 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3330 } else if (responseLen == sizeof(int)) {
3331 int *pInt = (int *) response;
3332 info.causeCode = (LastCallFailCause) pInt[0];
3333 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3334 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3335 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3336 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3338 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3339 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3342 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3343 responseInfo, info);
3344 radioService[slotId]->checkReturnStatus(retStatus);
3346 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3353 int radio::getSignalStrengthResponse(int slotId,
3354 int responseType, int serial, RIL_Errno e,
3355 void *response, size_t responseLen) {
3357 RLOGD("getSignalStrengthResponse: serial %d", serial);
3360 if (radioService[slotId]->mRadioResponse != NULL) {
3361 RadioResponseInfo responseInfo = {};
3362 populateResponseInfo(responseInfo, serial, responseType, e);
3363 SignalStrength signalStrength = {};
3364 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3365 RLOGE("getSignalStrengthResponse: Invalid response");
3366 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3368 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3371 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3372 responseInfo, signalStrength);
3373 radioService[slotId]->checkReturnStatus(retStatus);
3375 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3382 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3384 return RIL_CELL_INFO_TYPE_NONE;
3387 int radioTech = atoi(rat);
3391 case RADIO_TECH_GPRS:
3392 case RADIO_TECH_EDGE:
3393 case RADIO_TECH_GSM: {
3394 return RIL_CELL_INFO_TYPE_GSM;
3397 case RADIO_TECH_UMTS:
3398 case RADIO_TECH_HSDPA:
3399 case RADIO_TECH_HSUPA:
3400 case RADIO_TECH_HSPA:
3401 case RADIO_TECH_HSPAP: {
3402 return RIL_CELL_INFO_TYPE_WCDMA;
3405 case RADIO_TECH_IS95A:
3406 case RADIO_TECH_IS95B:
3407 case RADIO_TECH_1xRTT:
3408 case RADIO_TECH_EVDO_0:
3409 case RADIO_TECH_EVDO_A:
3410 case RADIO_TECH_EVDO_B:
3411 case RADIO_TECH_EHRPD: {
3412 return RIL_CELL_INFO_TYPE_CDMA;
3415 case RADIO_TECH_LTE:
3416 case RADIO_TECH_LTE_CA: {
3417 return RIL_CELL_INFO_TYPE_LTE;
3420 case RADIO_TECH_TD_SCDMA: {
3421 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3429 return RIL_CELL_INFO_TYPE_NONE;
3433 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3435 cellIdentity.cellIdentityGsm.resize(0);
3436 cellIdentity.cellIdentityWcdma.resize(0);
3437 cellIdentity.cellIdentityCdma.resize(0);
3438 cellIdentity.cellIdentityTdscdma.resize(0);
3439 cellIdentity.cellIdentityLte.resize(0);
3440 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3441 switch(rilCellIdentity.cellInfoType) {
3443 case RIL_CELL_INFO_TYPE_GSM: {
3444 cellIdentity.cellIdentityGsm.resize(1);
3445 cellIdentity.cellIdentityGsm[0].mcc =
3446 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3447 cellIdentity.cellIdentityGsm[0].mnc =
3448 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3449 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3450 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3451 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3452 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3456 case RIL_CELL_INFO_TYPE_WCDMA: {
3457 cellIdentity.cellIdentityWcdma.resize(1);
3458 cellIdentity.cellIdentityWcdma[0].mcc =
3459 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3460 cellIdentity.cellIdentityWcdma[0].mnc =
3461 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3462 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3463 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3464 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3465 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3469 case RIL_CELL_INFO_TYPE_CDMA: {
3470 cellIdentity.cellIdentityCdma.resize(1);
3471 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3472 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3473 cellIdentity.cellIdentityCdma[0].baseStationId =
3474 rilCellIdentity.cellIdentityCdma.basestationId;
3475 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3476 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3480 case RIL_CELL_INFO_TYPE_LTE: {
3481 cellIdentity.cellIdentityLte.resize(1);
3482 cellIdentity.cellIdentityLte[0].mcc =
3483 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3484 cellIdentity.cellIdentityLte[0].mnc =
3485 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3486 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3487 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3488 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3489 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3493 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3494 cellIdentity.cellIdentityTdscdma.resize(1);
3495 cellIdentity.cellIdentityTdscdma[0].mcc =
3496 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3497 cellIdentity.cellIdentityTdscdma[0].mnc =
3498 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3499 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3500 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3501 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3511 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3512 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3513 return atoi(response[index]);
3519 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3520 int numStrings, char** response) {
3522 RIL_CellIdentity_v16 rilCellIdentity;
3523 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3525 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3526 switch(rilCellIdentity.cellInfoType) {
3528 case RIL_CELL_INFO_TYPE_GSM: {
3529 rilCellIdentity.cellIdentityGsm.lac =
3530 convertResponseStringEntryToInt(response, 1, numStrings);
3531 rilCellIdentity.cellIdentityGsm.cid =
3532 convertResponseStringEntryToInt(response, 2, numStrings);
3536 case RIL_CELL_INFO_TYPE_WCDMA: {
3537 rilCellIdentity.cellIdentityWcdma.lac =
3538 convertResponseStringEntryToInt(response, 1, numStrings);
3539 rilCellIdentity.cellIdentityWcdma.cid =
3540 convertResponseStringEntryToInt(response, 2, numStrings);
3541 rilCellIdentity.cellIdentityWcdma.psc =
3542 convertResponseStringEntryToInt(response, 14, numStrings);
3546 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3547 rilCellIdentity.cellIdentityTdscdma.lac =
3548 convertResponseStringEntryToInt(response, 1, numStrings);
3549 rilCellIdentity.cellIdentityTdscdma.cid =
3550 convertResponseStringEntryToInt(response, 2, numStrings);
3554 case RIL_CELL_INFO_TYPE_CDMA:{
3555 rilCellIdentity.cellIdentityCdma.basestationId =
3556 convertResponseStringEntryToInt(response, 4, numStrings);
3557 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
3558 rilCellIdentity.cellIdentityCdma.latitude =
3559 convertResponseStringEntryToInt(response, 5, numStrings);
3560 rilCellIdentity.cellIdentityCdma.longitude =
3561 convertResponseStringEntryToInt(response, 6, numStrings);
3562 rilCellIdentity.cellIdentityCdma.systemId =
3563 convertResponseStringEntryToInt(response, 8, numStrings);
3564 rilCellIdentity.cellIdentityCdma.networkId =
3565 convertResponseStringEntryToInt(response, 9, numStrings);
3569 case RIL_CELL_INFO_TYPE_LTE:{
3570 rilCellIdentity.cellIdentityLte.tac =
3571 convertResponseStringEntryToInt(response, 1, numStrings);
3572 rilCellIdentity.cellIdentityLte.ci =
3573 convertResponseStringEntryToInt(response, 2, numStrings);
3582 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3585 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3586 int numStrings, char** response) {
3588 RIL_CellIdentity_v16 rilCellIdentity;
3589 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3591 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3592 switch(rilCellIdentity.cellInfoType) {
3593 case RIL_CELL_INFO_TYPE_GSM: {
3594 rilCellIdentity.cellIdentityGsm.lac =
3595 convertResponseStringEntryToInt(response, 1, numStrings);
3596 rilCellIdentity.cellIdentityGsm.cid =
3597 convertResponseStringEntryToInt(response, 2, numStrings);
3600 case RIL_CELL_INFO_TYPE_WCDMA: {
3601 rilCellIdentity.cellIdentityWcdma.lac =
3602 convertResponseStringEntryToInt(response, 1, numStrings);
3603 rilCellIdentity.cellIdentityWcdma.cid =
3604 convertResponseStringEntryToInt(response, 2, numStrings);
3607 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3608 rilCellIdentity.cellIdentityTdscdma.lac =
3609 convertResponseStringEntryToInt(response, 1, numStrings);
3610 rilCellIdentity.cellIdentityTdscdma.cid =
3611 convertResponseStringEntryToInt(response, 2, numStrings);
3614 case RIL_CELL_INFO_TYPE_LTE: {
3615 rilCellIdentity.cellIdentityLte.tac =
3616 convertResponseStringEntryToInt(response, 6, numStrings);
3617 rilCellIdentity.cellIdentityLte.pci =
3618 convertResponseStringEntryToInt(response, 7, numStrings);
3619 rilCellIdentity.cellIdentityLte.ci =
3620 convertResponseStringEntryToInt(response, 8, numStrings);
3628 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3631 int radio::getVoiceRegistrationStateResponse(int slotId,
3632 int responseType, int serial, RIL_Errno e,
3633 void *response, size_t responseLen) {
3635 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3638 if (radioService[slotId]->mRadioResponse != NULL) {
3639 RadioResponseInfo responseInfo = {};
3640 populateResponseInfo(responseInfo, serial, responseType, e);
3642 VoiceRegStateResult voiceRegResponse = {};
3643 int numStrings = responseLen / sizeof(char *);
3644 if (response == NULL) {
3645 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3646 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3647 } else if (s_vendorFunctions->version <= 14) {
3648 if (numStrings != 15) {
3649 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3650 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3652 char **resp = (char **) response;
3653 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3654 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3655 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3656 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3657 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3658 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3659 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3660 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3664 RIL_VoiceRegistrationStateResponse *voiceRegState =
3665 (RIL_VoiceRegistrationStateResponse *)response;
3667 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3668 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3669 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3671 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3672 voiceRegResponse.rat = voiceRegState->rat;;
3673 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3674 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3675 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3676 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3677 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3678 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3679 voiceRegState->cellIdentity);
3683 Return<void> retStatus =
3684 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3685 responseInfo, voiceRegResponse);
3686 radioService[slotId]->checkReturnStatus(retStatus);
3688 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3695 int radio::getDataRegistrationStateResponse(int slotId,
3696 int responseType, int serial, RIL_Errno e,
3697 void *response, size_t responseLen) {
3699 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3702 if (radioService[slotId]->mRadioResponse != NULL) {
3703 RadioResponseInfo responseInfo = {};
3704 populateResponseInfo(responseInfo, serial, responseType, e);
3705 DataRegStateResult dataRegResponse = {};
3706 if (response == NULL) {
3707 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3708 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3709 } else if (s_vendorFunctions->version <= 14) {
3710 int numStrings = responseLen / sizeof(char *);
3711 if ((numStrings != 6) && (numStrings != 11)) {
3712 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3713 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3715 char **resp = (char **) response;
3716 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3717 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3718 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3719 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3720 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3724 RIL_DataRegistrationStateResponse *dataRegState =
3725 (RIL_DataRegistrationStateResponse *)response;
3727 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3728 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3729 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3731 dataRegResponse.regState = (RegState) dataRegState->regState;
3732 dataRegResponse.rat = dataRegState->rat;;
3733 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3734 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3735 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3739 Return<void> retStatus =
3740 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3742 radioService[slotId]->checkReturnStatus(retStatus);
3744 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3751 int radio::getOperatorResponse(int slotId,
3752 int responseType, int serial, RIL_Errno e, void *response,
3753 size_t responseLen) {
3755 RLOGD("getOperatorResponse: serial %d", serial);
3758 if (radioService[slotId]->mRadioResponse != NULL) {
3759 RadioResponseInfo responseInfo = {};
3760 populateResponseInfo(responseInfo, serial, responseType, e);
3761 hidl_string longName;
3762 hidl_string shortName;
3763 hidl_string numeric;
3764 int numStrings = responseLen / sizeof(char *);
3765 if (response == NULL || numStrings != 3) {
3766 RLOGE("getOperatorResponse Invalid response: NULL");
3767 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3770 char **resp = (char **) response;
3771 longName = convertCharPtrToHidlString(resp[0]);
3772 shortName = convertCharPtrToHidlString(resp[1]);
3773 numeric = convertCharPtrToHidlString(resp[2]);
3775 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3776 responseInfo, longName, shortName, numeric);
3777 radioService[slotId]->checkReturnStatus(retStatus);
3779 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3786 int radio::setRadioPowerResponse(int slotId,
3787 int responseType, int serial, RIL_Errno e, void *response,
3788 size_t responseLen) {
3789 RLOGD("setRadioPowerResponse: serial %d", serial);
3791 if (radioService[slotId]->mRadioResponse != NULL) {
3792 RadioResponseInfo responseInfo = {};
3793 populateResponseInfo(responseInfo, serial, responseType, e);
3794 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3796 radioService[slotId]->checkReturnStatus(retStatus);
3798 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3805 int radio::sendDtmfResponse(int slotId,
3806 int responseType, int serial, RIL_Errno e, void *response,
3807 size_t responseLen) {
3809 RLOGD("sendDtmfResponse: serial %d", serial);
3812 if (radioService[slotId]->mRadioResponse != NULL) {
3813 RadioResponseInfo responseInfo = {};
3814 populateResponseInfo(responseInfo, serial, responseType, e);
3815 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3817 radioService[slotId]->checkReturnStatus(retStatus);
3819 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3826 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3827 RIL_Errno e, void *response, size_t responseLen) {
3828 populateResponseInfo(responseInfo, serial, responseType, e);
3829 SendSmsResult result = {};
3831 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3832 RLOGE("Invalid response: NULL");
3833 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3834 result.ackPDU = hidl_string();
3836 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3837 result.messageRef = resp->messageRef;
3838 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3839 result.errorCode = resp->errorCode;
3844 int radio::sendSmsResponse(int slotId,
3845 int responseType, int serial, RIL_Errno e, void *response,
3846 size_t responseLen) {
3848 RLOGD("sendSmsResponse: serial %d", serial);
3851 if (radioService[slotId]->mRadioResponse != NULL) {
3852 RadioResponseInfo responseInfo = {};
3853 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3856 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3858 radioService[slotId]->checkReturnStatus(retStatus);
3860 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3866 int radio::sendSMSExpectMoreResponse(int slotId,
3867 int responseType, int serial, RIL_Errno e, void *response,
3868 size_t responseLen) {
3870 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3873 if (radioService[slotId]->mRadioResponse != NULL) {
3874 RadioResponseInfo responseInfo = {};
3875 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3878 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3879 responseInfo, result);
3880 radioService[slotId]->checkReturnStatus(retStatus);
3882 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3888 int radio::setupDataCallResponse(int slotId,
3889 int responseType, int serial, RIL_Errno e, void *response,
3890 size_t responseLen) {
3892 RLOGD("setupDataCallResponse: serial %d", serial);
3895 if (radioService[slotId]->mRadioResponse != NULL) {
3896 RadioResponseInfo responseInfo = {};
3897 populateResponseInfo(responseInfo, serial, responseType, e);
3899 SetupDataCallResult result = {};
3900 if (response == NULL || responseLen != sizeof(RIL_Data_Call_Response_v11)) {
3901 RLOGE("setupDataCallResponse: Invalid response");
3902 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3903 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3904 result.type = hidl_string();
3905 result.ifname = hidl_string();
3906 result.addresses = hidl_string();
3907 result.dnses = hidl_string();
3908 result.gateways = hidl_string();
3909 result.pcscf = hidl_string();
3911 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
3914 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
3915 responseInfo, result);
3916 radioService[slotId]->checkReturnStatus(retStatus);
3918 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3924 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
3925 RIL_Errno e, void *response, size_t responseLen) {
3926 populateResponseInfo(responseInfo, serial, responseType, e);
3927 IccIoResult result = {};
3929 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
3930 RLOGE("Invalid response: NULL");
3931 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3932 result.simResponse = hidl_string();
3934 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
3935 result.sw1 = resp->sw1;
3936 result.sw2 = resp->sw2;
3937 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
3942 int radio::iccIOForAppResponse(int slotId,
3943 int responseType, int serial, RIL_Errno e, void *response,
3944 size_t responseLen) {
3946 RLOGD("iccIOForAppResponse: serial %d", serial);
3949 if (radioService[slotId]->mRadioResponse != NULL) {
3950 RadioResponseInfo responseInfo = {};
3951 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
3954 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
3955 responseInfo, result);
3956 radioService[slotId]->checkReturnStatus(retStatus);
3958 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3964 int radio::sendUssdResponse(int slotId,
3965 int responseType, int serial, RIL_Errno e, void *response,
3966 size_t responseLen) {
3968 RLOGD("sendUssdResponse: serial %d", serial);
3971 if (radioService[slotId]->mRadioResponse != NULL) {
3972 RadioResponseInfo responseInfo = {};
3973 populateResponseInfo(responseInfo, serial, responseType, e);
3974 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
3976 radioService[slotId]->checkReturnStatus(retStatus);
3978 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
3985 int radio::cancelPendingUssdResponse(int slotId,
3986 int responseType, int serial, RIL_Errno e, void *response,
3987 size_t responseLen) {
3989 RLOGD("cancelPendingUssdResponse: serial %d", serial);
3992 if (radioService[slotId]->mRadioResponse != NULL) {
3993 RadioResponseInfo responseInfo = {};
3994 populateResponseInfo(responseInfo, serial, responseType, e);
3995 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
3997 radioService[slotId]->checkReturnStatus(retStatus);
3999 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
4006 int radio::getClirResponse(int slotId,
4007 int responseType, int serial, RIL_Errno e, void *response,
4008 size_t responseLen) {
4010 RLOGD("getClirResponse: serial %d", serial);
4013 if (radioService[slotId]->mRadioResponse != NULL) {
4014 RadioResponseInfo responseInfo = {};
4015 populateResponseInfo(responseInfo, serial, responseType, e);
4017 int numInts = responseLen / sizeof(int);
4018 if (response == NULL || numInts != 2) {
4019 RLOGE("getClirResponse Invalid response: NULL");
4020 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4022 int *pInt = (int *) response;
4026 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
4028 radioService[slotId]->checkReturnStatus(retStatus);
4030 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4036 int radio::setClirResponse(int slotId,
4037 int responseType, int serial, RIL_Errno e, void *response,
4038 size_t responseLen) {
4040 RLOGD("setClirResponse: serial %d", serial);
4043 if (radioService[slotId]->mRadioResponse != NULL) {
4044 RadioResponseInfo responseInfo = {};
4045 populateResponseInfo(responseInfo, serial, responseType, e);
4046 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
4048 radioService[slotId]->checkReturnStatus(retStatus);
4050 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4056 int radio::getCallForwardStatusResponse(int slotId,
4057 int responseType, int serial, RIL_Errno e,
4058 void *response, size_t responseLen) {
4060 RLOGD("getCallForwardStatusResponse: serial %d", serial);
4063 if (radioService[slotId]->mRadioResponse != NULL) {
4064 RadioResponseInfo responseInfo = {};
4065 populateResponseInfo(responseInfo, serial, responseType, e);
4066 hidl_vec<CallForwardInfo> callForwardInfos;
4068 if (response == NULL || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4069 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4070 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4072 int num = responseLen / sizeof(RIL_CallForwardInfo *);
4073 callForwardInfos.resize(num);
4074 for (int i = 0 ; i < num; i++) {
4075 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4076 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4077 callForwardInfos[i].reason = resp->reason;
4078 callForwardInfos[i].serviceClass = resp->serviceClass;
4079 callForwardInfos[i].toa = resp->toa;
4080 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4081 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4085 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4086 responseInfo, callForwardInfos);
4087 radioService[slotId]->checkReturnStatus(retStatus);
4089 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4096 int radio::setCallForwardResponse(int slotId,
4097 int responseType, int serial, RIL_Errno e, void *response,
4098 size_t responseLen) {
4100 RLOGD("setCallForwardResponse: serial %d", serial);
4103 if (radioService[slotId]->mRadioResponse != NULL) {
4104 RadioResponseInfo responseInfo = {};
4105 populateResponseInfo(responseInfo, serial, responseType, e);
4106 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4108 radioService[slotId]->checkReturnStatus(retStatus);
4110 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4116 int radio::getCallWaitingResponse(int slotId,
4117 int responseType, int serial, RIL_Errno e, void *response,
4118 size_t responseLen) {
4120 RLOGD("getCallWaitingResponse: serial %d", serial);
4123 if (radioService[slotId]->mRadioResponse != NULL) {
4124 RadioResponseInfo responseInfo = {};
4125 populateResponseInfo(responseInfo, serial, responseType, e);
4126 bool enable = false;
4127 int serviceClass = -1;
4128 int numInts = responseLen / sizeof(int);
4129 if (response == NULL || numInts != 2) {
4130 RLOGE("getCallWaitingResponse Invalid response: NULL");
4131 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4133 int *pInt = (int *) response;
4134 enable = pInt[0] == 1 ? true : false;
4135 serviceClass = pInt[1];
4137 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4138 responseInfo, enable, serviceClass);
4139 radioService[slotId]->checkReturnStatus(retStatus);
4141 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4147 int radio::setCallWaitingResponse(int slotId,
4148 int responseType, int serial, RIL_Errno e, void *response,
4149 size_t responseLen) {
4151 RLOGD("setCallWaitingResponse: serial %d", serial);
4154 if (radioService[slotId]->mRadioResponse != NULL) {
4155 RadioResponseInfo responseInfo = {};
4156 populateResponseInfo(responseInfo, serial, responseType, e);
4157 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4159 radioService[slotId]->checkReturnStatus(retStatus);
4161 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4167 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4168 int responseType, int serial, RIL_Errno e,
4169 void *response, size_t responseLen) {
4171 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4174 if (radioService[slotId]->mRadioResponse != NULL) {
4175 RadioResponseInfo responseInfo = {};
4176 populateResponseInfo(responseInfo, serial, responseType, e);
4177 Return<void> retStatus =
4178 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4180 radioService[slotId]->checkReturnStatus(retStatus);
4182 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4189 int radio::acceptCallResponse(int slotId,
4190 int responseType, int serial, RIL_Errno e,
4191 void *response, size_t responseLen) {
4193 RLOGD("acceptCallResponse: serial %d", serial);
4196 if (radioService[slotId]->mRadioResponse != NULL) {
4197 RadioResponseInfo responseInfo = {};
4198 populateResponseInfo(responseInfo, serial, responseType, e);
4199 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4201 radioService[slotId]->checkReturnStatus(retStatus);
4203 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4210 int radio::deactivateDataCallResponse(int slotId,
4211 int responseType, int serial, RIL_Errno e,
4212 void *response, size_t responseLen) {
4214 RLOGD("deactivateDataCallResponse: serial %d", serial);
4217 if (radioService[slotId]->mRadioResponse != NULL) {
4218 RadioResponseInfo responseInfo = {};
4219 populateResponseInfo(responseInfo, serial, responseType, e);
4220 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4222 radioService[slotId]->checkReturnStatus(retStatus);
4224 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4231 int radio::getFacilityLockForAppResponse(int slotId,
4232 int responseType, int serial, RIL_Errno e,
4233 void *response, size_t responseLen) {
4235 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4238 if (radioService[slotId]->mRadioResponse != NULL) {
4239 RadioResponseInfo responseInfo = {};
4240 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4241 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4242 getFacilityLockForAppResponse(responseInfo, ret);
4243 radioService[slotId]->checkReturnStatus(retStatus);
4245 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4252 int radio::setFacilityLockForAppResponse(int slotId,
4253 int responseType, int serial, RIL_Errno e,
4254 void *response, size_t responseLen) {
4256 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4259 if (radioService[slotId]->mRadioResponse != NULL) {
4260 RadioResponseInfo responseInfo = {};
4261 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4262 Return<void> retStatus
4263 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4265 radioService[slotId]->checkReturnStatus(retStatus);
4267 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4274 int radio::setBarringPasswordResponse(int slotId,
4275 int responseType, int serial, RIL_Errno e,
4276 void *response, size_t responseLen) {
4278 RLOGD("acceptCallResponse: serial %d", serial);
4281 if (radioService[slotId]->mRadioResponse != NULL) {
4282 RadioResponseInfo responseInfo = {};
4283 populateResponseInfo(responseInfo, serial, responseType, e);
4284 Return<void> retStatus
4285 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4286 radioService[slotId]->checkReturnStatus(retStatus);
4288 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4295 int radio::getNetworkSelectionModeResponse(int slotId,
4296 int responseType, int serial, RIL_Errno e, void *response,
4297 size_t responseLen) {
4299 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4302 if (radioService[slotId]->mRadioResponse != NULL) {
4303 RadioResponseInfo responseInfo = {};
4304 populateResponseInfo(responseInfo, serial, responseType, e);
4305 bool manual = false;
4307 if (response == NULL || responseLen != sizeof(int)) {
4308 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4309 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4311 int *pInt = (int *) response;
4312 manual = pInt[0] == 1 ? true : false;
4314 Return<void> retStatus
4315 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4318 radioService[slotId]->checkReturnStatus(retStatus);
4320 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4327 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4328 RIL_Errno e, void *response,
4329 size_t responseLen) {
4331 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4334 if (radioService[slotId]->mRadioResponse != NULL) {
4335 RadioResponseInfo responseInfo = {};
4336 populateResponseInfo(responseInfo, serial, responseType, e);
4337 Return<void> retStatus
4338 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4340 radioService[slotId]->checkReturnStatus(retStatus);
4342 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4349 int radio::setNetworkSelectionModeManualResponse(int slotId,
4350 int responseType, int serial, RIL_Errno e,
4351 void *response, size_t responseLen) {
4353 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4356 if (radioService[slotId]->mRadioResponse != NULL) {
4357 RadioResponseInfo responseInfo = {};
4358 populateResponseInfo(responseInfo, serial, responseType, e);
4359 Return<void> retStatus
4360 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4362 radioService[slotId]->checkReturnStatus(retStatus);
4364 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4371 int convertOperatorStatusToInt(const char *str) {
4372 if (strncmp("unknown", str, 9) == 0) {
4373 return (int) OperatorStatus::UNKNOWN;
4374 } else if (strncmp("available", str, 9) == 0) {
4375 return (int) OperatorStatus::AVAILABLE;
4376 } else if (strncmp("current", str, 9) == 0) {
4377 return (int) OperatorStatus::CURRENT;
4378 } else if (strncmp("forbidden", str, 9) == 0) {
4379 return (int) OperatorStatus::FORBIDDEN;
4385 int radio::getAvailableNetworksResponse(int slotId,
4386 int responseType, int serial, RIL_Errno e, void *response,
4387 size_t responseLen) {
4389 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4392 if (radioService[slotId]->mRadioResponse != NULL) {
4393 RadioResponseInfo responseInfo = {};
4394 populateResponseInfo(responseInfo, serial, responseType, e);
4395 hidl_vec<OperatorInfo> networks;
4396 if (response == NULL || responseLen % (4 * sizeof(char *))!= 0) {
4397 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4398 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4400 char **resp = (char **) response;
4401 int numStrings = responseLen / sizeof(char *);
4402 networks.resize(numStrings/4);
4403 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4404 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4405 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4406 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4407 int status = convertOperatorStatusToInt(resp[i + 3]);
4409 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4411 networks[j].status = (OperatorStatus) status;
4415 Return<void> retStatus
4416 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4418 radioService[slotId]->checkReturnStatus(retStatus);
4420 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4427 int radio::startDtmfResponse(int slotId,
4428 int responseType, int serial, RIL_Errno e,
4429 void *response, size_t responseLen) {
4431 RLOGD("startDtmfResponse: serial %d", serial);
4434 if (radioService[slotId]->mRadioResponse != NULL) {
4435 RadioResponseInfo responseInfo = {};
4436 populateResponseInfo(responseInfo, serial, responseType, e);
4437 Return<void> retStatus
4438 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4439 radioService[slotId]->checkReturnStatus(retStatus);
4441 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4447 int radio::stopDtmfResponse(int slotId,
4448 int responseType, int serial, RIL_Errno e,
4449 void *response, size_t responseLen) {
4451 RLOGD("stopDtmfResponse: serial %d", serial);
4454 if (radioService[slotId]->mRadioResponse != NULL) {
4455 RadioResponseInfo responseInfo = {};
4456 populateResponseInfo(responseInfo, serial, responseType, e);
4457 Return<void> retStatus
4458 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4459 radioService[slotId]->checkReturnStatus(retStatus);
4461 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4467 int radio::getBasebandVersionResponse(int slotId,
4468 int responseType, int serial, RIL_Errno e,
4469 void *response, size_t responseLen) {
4471 RLOGD("getBasebandVersionResponse: serial %d", serial);
4474 if (radioService[slotId]->mRadioResponse != NULL) {
4475 RadioResponseInfo responseInfo = {};
4476 populateResponseInfo(responseInfo, serial, responseType, e);
4477 Return<void> retStatus
4478 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4479 convertCharPtrToHidlString((char *) response));
4480 radioService[slotId]->checkReturnStatus(retStatus);
4482 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4488 int radio::separateConnectionResponse(int slotId,
4489 int responseType, int serial, RIL_Errno e,
4490 void *response, size_t responseLen) {
4492 RLOGD("separateConnectionResponse: serial %d", serial);
4495 if (radioService[slotId]->mRadioResponse != NULL) {
4496 RadioResponseInfo responseInfo = {};
4497 populateResponseInfo(responseInfo, serial, responseType, e);
4498 Return<void> retStatus
4499 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4500 radioService[slotId]->checkReturnStatus(retStatus);
4502 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4509 int radio::setMuteResponse(int slotId,
4510 int responseType, int serial, RIL_Errno e,
4511 void *response, size_t responseLen) {
4513 RLOGD("setMuteResponse: serial %d", serial);
4516 if (radioService[slotId]->mRadioResponse != NULL) {
4517 RadioResponseInfo responseInfo = {};
4518 populateResponseInfo(responseInfo, serial, responseType, e);
4519 Return<void> retStatus
4520 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4521 radioService[slotId]->checkReturnStatus(retStatus);
4523 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4529 int radio::getMuteResponse(int slotId,
4530 int responseType, int serial, RIL_Errno e, void *response,
4531 size_t responseLen) {
4533 RLOGD("getMuteResponse: serial %d", serial);
4536 if (radioService[slotId]->mRadioResponse != NULL) {
4537 RadioResponseInfo responseInfo = {};
4538 populateResponseInfo(responseInfo, serial, responseType, e);
4539 bool enable = false;
4541 if (response == NULL || responseLen != sizeof(int)) {
4542 RLOGE("getMuteResponse Invalid response: NULL");
4543 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4545 int *pInt = (int *) response;
4546 enable = pInt[0] == 1 ? true : false;
4548 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4550 radioService[slotId]->checkReturnStatus(retStatus);
4552 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4558 int radio::getClipResponse(int slotId,
4559 int responseType, int serial, RIL_Errno e,
4560 void *response, size_t responseLen) {
4562 RLOGD("getClipResponse: serial %d", serial);
4565 if (radioService[slotId]->mRadioResponse != NULL) {
4566 RadioResponseInfo responseInfo = {};
4567 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4568 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4570 radioService[slotId]->checkReturnStatus(retStatus);
4572 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4578 int radio::getDataCallListResponse(int slotId,
4579 int responseType, int serial, RIL_Errno e,
4580 void *response, size_t responseLen) {
4582 RLOGD("getDataCallListResponse: serial %d", serial);
4585 if (radioService[slotId]->mRadioResponse != NULL) {
4586 RadioResponseInfo responseInfo = {};
4587 populateResponseInfo(responseInfo, serial, responseType, e);
4589 hidl_vec<SetupDataCallResult> ret;
4590 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4591 RLOGE("getDataCallListResponse: invalid response");
4592 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4594 convertRilDataCallListToHal(response, responseLen, ret);
4597 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4599 radioService[slotId]->checkReturnStatus(retStatus);
4601 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4607 int radio::setSuppServiceNotificationsResponse(int slotId,
4608 int responseType, int serial, RIL_Errno e,
4609 void *response, size_t responseLen) {
4611 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4614 if (radioService[slotId]->mRadioResponse != NULL) {
4615 RadioResponseInfo responseInfo = {};
4616 populateResponseInfo(responseInfo, serial, responseType, e);
4617 Return<void> retStatus
4618 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4620 radioService[slotId]->checkReturnStatus(retStatus);
4622 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4629 int radio::deleteSmsOnSimResponse(int slotId,
4630 int responseType, int serial, RIL_Errno e,
4631 void *response, size_t responseLen) {
4633 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4636 if (radioService[slotId]->mRadioResponse != NULL) {
4637 RadioResponseInfo responseInfo = {};
4638 populateResponseInfo(responseInfo, serial, responseType, e);
4639 Return<void> retStatus
4640 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4641 radioService[slotId]->checkReturnStatus(retStatus);
4643 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4649 int radio::setBandModeResponse(int slotId,
4650 int responseType, int serial, RIL_Errno e,
4651 void *response, size_t responseLen) {
4653 RLOGD("setBandModeResponse: serial %d", serial);
4656 if (radioService[slotId]->mRadioResponse != NULL) {
4657 RadioResponseInfo responseInfo = {};
4658 populateResponseInfo(responseInfo, serial, responseType, e);
4659 Return<void> retStatus
4660 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4661 radioService[slotId]->checkReturnStatus(retStatus);
4663 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4669 int radio::writeSmsToSimResponse(int slotId,
4670 int responseType, int serial, RIL_Errno e,
4671 void *response, size_t responseLen) {
4673 RLOGD("writeSmsToSimResponse: serial %d", serial);
4676 if (radioService[slotId]->mRadioResponse != NULL) {
4677 RadioResponseInfo responseInfo = {};
4678 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4679 Return<void> retStatus
4680 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4681 radioService[slotId]->checkReturnStatus(retStatus);
4683 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4689 int radio::getAvailableBandModesResponse(int slotId,
4690 int responseType, int serial, RIL_Errno e, void *response,
4691 size_t responseLen) {
4693 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4696 if (radioService[slotId]->mRadioResponse != NULL) {
4697 RadioResponseInfo responseInfo = {};
4698 populateResponseInfo(responseInfo, serial, responseType, e);
4699 hidl_vec<RadioBandMode> modes;
4700 if (response == NULL || responseLen % sizeof(int) != 0) {
4701 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4702 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4704 int *pInt = (int *) response;
4705 int numInts = responseLen / sizeof(int);
4706 modes.resize(numInts);
4707 for (int i = 0; i < numInts; i++) {
4708 modes[i] = (RadioBandMode) pInt[i];
4711 Return<void> retStatus
4712 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4714 radioService[slotId]->checkReturnStatus(retStatus);
4716 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4723 int radio::sendEnvelopeResponse(int slotId,
4724 int responseType, int serial, RIL_Errno e,
4725 void *response, size_t responseLen) {
4727 RLOGD("sendEnvelopeResponse: serial %d", serial);
4730 if (radioService[slotId]->mRadioResponse != NULL) {
4731 RadioResponseInfo responseInfo = {};
4732 populateResponseInfo(responseInfo, serial, responseType, e);
4733 Return<void> retStatus
4734 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4735 convertCharPtrToHidlString((char *) response));
4736 radioService[slotId]->checkReturnStatus(retStatus);
4738 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4744 int radio::sendTerminalResponseToSimResponse(int slotId,
4745 int responseType, int serial, RIL_Errno e,
4746 void *response, size_t responseLen) {
4748 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4751 if (radioService[slotId]->mRadioResponse != NULL) {
4752 RadioResponseInfo responseInfo = {};
4753 populateResponseInfo(responseInfo, serial, responseType, e);
4754 Return<void> retStatus
4755 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4757 radioService[slotId]->checkReturnStatus(retStatus);
4759 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4766 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4767 int responseType, int serial,
4768 RIL_Errno e, void *response,
4769 size_t responseLen) {
4771 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4774 if (radioService[slotId]->mRadioResponse != NULL) {
4775 RadioResponseInfo responseInfo = {};
4776 populateResponseInfo(responseInfo, serial, responseType, e);
4777 Return<void> retStatus
4778 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4780 radioService[slotId]->checkReturnStatus(retStatus);
4782 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4789 int radio::explicitCallTransferResponse(int slotId,
4790 int responseType, int serial, RIL_Errno e,
4791 void *response, size_t responseLen) {
4793 RLOGD("explicitCallTransferResponse: serial %d", serial);
4796 if (radioService[slotId]->mRadioResponse != NULL) {
4797 RadioResponseInfo responseInfo = {};
4798 populateResponseInfo(responseInfo, serial, responseType, e);
4799 Return<void> retStatus
4800 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4801 radioService[slotId]->checkReturnStatus(retStatus);
4803 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4810 int radio::setPreferredNetworkTypeResponse(int slotId,
4811 int responseType, int serial, RIL_Errno e,
4812 void *response, size_t responseLen) {
4814 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4817 if (radioService[slotId]->mRadioResponse != NULL) {
4818 RadioResponseInfo responseInfo = {};
4819 populateResponseInfo(responseInfo, serial, responseType, e);
4820 Return<void> retStatus
4821 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4823 radioService[slotId]->checkReturnStatus(retStatus);
4825 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4833 int radio::getPreferredNetworkTypeResponse(int slotId,
4834 int responseType, int serial, RIL_Errno e,
4835 void *response, size_t responseLen) {
4837 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4840 if (radioService[slotId]->mRadioResponse != NULL) {
4841 RadioResponseInfo responseInfo = {};
4842 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4843 Return<void> retStatus
4844 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4845 responseInfo, (PreferredNetworkType) ret);
4846 radioService[slotId]->checkReturnStatus(retStatus);
4848 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4855 int radio::getNeighboringCidsResponse(int slotId,
4856 int responseType, int serial, RIL_Errno e,
4857 void *response, size_t responseLen) {
4859 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4862 if (radioService[slotId]->mRadioResponse != NULL) {
4863 RadioResponseInfo responseInfo = {};
4864 populateResponseInfo(responseInfo, serial, responseType, e);
4865 hidl_vec<NeighboringCell> cells;
4867 if (response == NULL || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4868 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4869 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4871 int num = responseLen / sizeof(RIL_NeighboringCell *);
4873 for (int i = 0 ; i < num; i++) {
4874 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4875 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4876 cells[i].rssi = resp->rssi;
4880 Return<void> retStatus
4881 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4883 radioService[slotId]->checkReturnStatus(retStatus);
4885 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4892 int radio::setLocationUpdatesResponse(int slotId,
4893 int responseType, int serial, RIL_Errno e,
4894 void *response, size_t responseLen) {
4896 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4899 if (radioService[slotId]->mRadioResponse != NULL) {
4900 RadioResponseInfo responseInfo = {};
4901 populateResponseInfo(responseInfo, serial, responseType, e);
4902 Return<void> retStatus
4903 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4904 radioService[slotId]->checkReturnStatus(retStatus);
4906 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
4913 int radio::setCdmaSubscriptionSourceResponse(int slotId,
4914 int responseType, int serial, RIL_Errno e,
4915 void *response, size_t responseLen) {
4917 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
4920 if (radioService[slotId]->mRadioResponse != NULL) {
4921 RadioResponseInfo responseInfo = {};
4922 populateResponseInfo(responseInfo, serial, responseType, e);
4923 Return<void> retStatus
4924 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
4926 radioService[slotId]->checkReturnStatus(retStatus);
4928 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
4935 int radio::setCdmaRoamingPreferenceResponse(int slotId,
4936 int responseType, int serial, RIL_Errno e,
4937 void *response, size_t responseLen) {
4939 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
4942 if (radioService[slotId]->mRadioResponse != NULL) {
4943 RadioResponseInfo responseInfo = {};
4944 populateResponseInfo(responseInfo, serial, responseType, e);
4945 Return<void> retStatus
4946 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
4948 radioService[slotId]->checkReturnStatus(retStatus);
4950 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4957 int radio::getCdmaRoamingPreferenceResponse(int slotId,
4958 int responseType, int serial, RIL_Errno e,
4959 void *response, size_t responseLen) {
4961 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
4964 if (radioService[slotId]->mRadioResponse != NULL) {
4965 RadioResponseInfo responseInfo = {};
4966 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4967 Return<void> retStatus
4968 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
4969 responseInfo, (CdmaRoamingType) ret);
4970 radioService[slotId]->checkReturnStatus(retStatus);
4972 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
4979 int radio::setTTYModeResponse(int slotId,
4980 int responseType, int serial, RIL_Errno e,
4981 void *response, size_t responseLen) {
4983 RLOGD("setTTYModeResponse: serial %d", serial);
4986 if (radioService[slotId]->mRadioResponse != NULL) {
4987 RadioResponseInfo responseInfo = {};
4988 populateResponseInfo(responseInfo, serial, responseType, e);
4989 Return<void> retStatus
4990 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
4991 radioService[slotId]->checkReturnStatus(retStatus);
4993 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4999 int radio::getTTYModeResponse(int slotId,
5000 int responseType, int serial, RIL_Errno e,
5001 void *response, size_t responseLen) {
5003 RLOGD("getTTYModeResponse: serial %d", serial);
5006 if (radioService[slotId]->mRadioResponse != NULL) {
5007 RadioResponseInfo responseInfo = {};
5008 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5009 Return<void> retStatus
5010 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
5012 radioService[slotId]->checkReturnStatus(retStatus);
5014 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5020 int radio::setPreferredVoicePrivacyResponse(int slotId,
5021 int responseType, int serial, RIL_Errno e,
5022 void *response, size_t responseLen) {
5024 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
5027 if (radioService[slotId]->mRadioResponse != NULL) {
5028 RadioResponseInfo responseInfo = {};
5029 populateResponseInfo(responseInfo, serial, responseType, e);
5030 Return<void> retStatus
5031 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
5033 radioService[slotId]->checkReturnStatus(retStatus);
5035 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5042 int radio::getPreferredVoicePrivacyResponse(int slotId,
5043 int responseType, int serial, RIL_Errno e,
5044 void *response, size_t responseLen) {
5046 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
5049 if (radioService[slotId]->mRadioResponse != NULL) {
5050 RadioResponseInfo responseInfo = {};
5051 populateResponseInfo(responseInfo, serial, responseType, e);
5052 bool enable = false;
5053 int numInts = responseLen / sizeof(int);
5054 if (response == NULL || numInts != 1) {
5055 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
5056 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5058 int *pInt = (int *) response;
5059 enable = pInt[0] == 1 ? true : false;
5061 Return<void> retStatus
5062 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5063 responseInfo, enable);
5064 radioService[slotId]->checkReturnStatus(retStatus);
5066 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5073 int radio::sendCDMAFeatureCodeResponse(int slotId,
5074 int responseType, int serial, RIL_Errno e,
5075 void *response, size_t responseLen) {
5077 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5080 if (radioService[slotId]->mRadioResponse != NULL) {
5081 RadioResponseInfo responseInfo = {};
5082 populateResponseInfo(responseInfo, serial, responseType, e);
5083 Return<void> retStatus
5084 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5085 radioService[slotId]->checkReturnStatus(retStatus);
5087 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5094 int radio::sendBurstDtmfResponse(int slotId,
5095 int responseType, int serial, RIL_Errno e,
5096 void *response, size_t responseLen) {
5098 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5101 if (radioService[slotId]->mRadioResponse != NULL) {
5102 RadioResponseInfo responseInfo = {};
5103 populateResponseInfo(responseInfo, serial, responseType, e);
5104 Return<void> retStatus
5105 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5106 radioService[slotId]->checkReturnStatus(retStatus);
5108 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5114 int radio::sendCdmaSmsResponse(int slotId,
5115 int responseType, int serial, RIL_Errno e, void *response,
5116 size_t responseLen) {
5118 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5121 if (radioService[slotId]->mRadioResponse != NULL) {
5122 RadioResponseInfo responseInfo = {};
5123 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5126 Return<void> retStatus
5127 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5128 radioService[slotId]->checkReturnStatus(retStatus);
5130 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5136 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5137 int responseType, int serial, RIL_Errno e,
5138 void *response, size_t responseLen) {
5140 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5143 if (radioService[slotId]->mRadioResponse != NULL) {
5144 RadioResponseInfo responseInfo = {};
5145 populateResponseInfo(responseInfo, serial, responseType, e);
5146 Return<void> retStatus
5147 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5149 radioService[slotId]->checkReturnStatus(retStatus);
5151 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5158 int radio::getGsmBroadcastConfigResponse(int slotId,
5159 int responseType, int serial, RIL_Errno e,
5160 void *response, size_t responseLen) {
5162 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5165 if (radioService[slotId]->mRadioResponse != NULL) {
5166 RadioResponseInfo responseInfo = {};
5167 populateResponseInfo(responseInfo, serial, responseType, e);
5168 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5170 if (response == NULL || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5171 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5172 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5174 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5175 configs.resize(num);
5176 for (int i = 0 ; i < num; i++) {
5177 RIL_GSM_BroadcastSmsConfigInfo *resp =
5178 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5179 configs[i].fromServiceId = resp->fromServiceId;
5180 configs[i].toServiceId = resp->toServiceId;
5181 configs[i].fromCodeScheme = resp->fromCodeScheme;
5182 configs[i].toCodeScheme = resp->toCodeScheme;
5183 configs[i].selected = resp->selected == 1 ? true : false;
5187 Return<void> retStatus
5188 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5190 radioService[slotId]->checkReturnStatus(retStatus);
5192 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5199 int radio::setGsmBroadcastConfigResponse(int slotId,
5200 int responseType, int serial, RIL_Errno e,
5201 void *response, size_t responseLen) {
5203 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5206 if (radioService[slotId]->mRadioResponse != NULL) {
5207 RadioResponseInfo responseInfo = {};
5208 populateResponseInfo(responseInfo, serial, responseType, e);
5209 Return<void> retStatus
5210 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5211 radioService[slotId]->checkReturnStatus(retStatus);
5213 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5220 int radio::setGsmBroadcastActivationResponse(int slotId,
5221 int responseType, int serial, RIL_Errno e,
5222 void *response, size_t responseLen) {
5224 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5227 if (radioService[slotId]->mRadioResponse != NULL) {
5228 RadioResponseInfo responseInfo = {};
5229 populateResponseInfo(responseInfo, serial, responseType, e);
5230 Return<void> retStatus
5231 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5233 radioService[slotId]->checkReturnStatus(retStatus);
5235 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5242 int radio::getCdmaBroadcastConfigResponse(int slotId,
5243 int responseType, int serial, RIL_Errno e,
5244 void *response, size_t responseLen) {
5246 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5249 if (radioService[slotId]->mRadioResponse != NULL) {
5250 RadioResponseInfo responseInfo = {};
5251 populateResponseInfo(responseInfo, serial, responseType, e);
5252 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5254 if (response == NULL || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5255 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5256 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5258 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5259 configs.resize(num);
5260 for (int i = 0 ; i < num; i++) {
5261 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5262 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5263 configs[i].serviceCategory = resp->service_category;
5264 configs[i].language = resp->language;
5265 configs[i].selected = resp->selected == 1 ? true : false;
5269 Return<void> retStatus
5270 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5272 radioService[slotId]->checkReturnStatus(retStatus);
5274 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5281 int radio::setCdmaBroadcastConfigResponse(int slotId,
5282 int responseType, int serial, RIL_Errno e,
5283 void *response, size_t responseLen) {
5285 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5288 if (radioService[slotId]->mRadioResponse != NULL) {
5289 RadioResponseInfo responseInfo = {};
5290 populateResponseInfo(responseInfo, serial, responseType, e);
5291 Return<void> retStatus
5292 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5294 radioService[slotId]->checkReturnStatus(retStatus);
5296 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5303 int radio::setCdmaBroadcastActivationResponse(int slotId,
5304 int responseType, int serial, RIL_Errno e,
5305 void *response, size_t responseLen) {
5307 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5310 if (radioService[slotId]->mRadioResponse != NULL) {
5311 RadioResponseInfo responseInfo = {};
5312 populateResponseInfo(responseInfo, serial, responseType, e);
5313 Return<void> retStatus
5314 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5316 radioService[slotId]->checkReturnStatus(retStatus);
5318 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5325 int radio::getCDMASubscriptionResponse(int slotId,
5326 int responseType, int serial, RIL_Errno e, void *response,
5327 size_t responseLen) {
5329 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5332 if (radioService[slotId]->mRadioResponse != NULL) {
5333 RadioResponseInfo responseInfo = {};
5334 populateResponseInfo(responseInfo, serial, responseType, e);
5336 int numStrings = responseLen / sizeof(char *);
5337 hidl_string emptyString;
5338 if (response == NULL || numStrings != 5) {
5339 RLOGE("getOperatorResponse Invalid response: NULL");
5340 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5341 Return<void> retStatus
5342 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5343 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5344 radioService[slotId]->checkReturnStatus(retStatus);
5346 char **resp = (char **) response;
5347 Return<void> retStatus
5348 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5350 convertCharPtrToHidlString(resp[0]),
5351 convertCharPtrToHidlString(resp[1]),
5352 convertCharPtrToHidlString(resp[2]),
5353 convertCharPtrToHidlString(resp[3]),
5354 convertCharPtrToHidlString(resp[4]));
5355 radioService[slotId]->checkReturnStatus(retStatus);
5358 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5365 int radio::writeSmsToRuimResponse(int slotId,
5366 int responseType, int serial, RIL_Errno e,
5367 void *response, size_t responseLen) {
5369 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5372 if (radioService[slotId]->mRadioResponse != NULL) {
5373 RadioResponseInfo responseInfo = {};
5374 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5375 Return<void> retStatus
5376 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5377 radioService[slotId]->checkReturnStatus(retStatus);
5379 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5385 int radio::deleteSmsOnRuimResponse(int slotId,
5386 int responseType, int serial, RIL_Errno e,
5387 void *response, size_t responseLen) {
5389 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5392 if (radioService[slotId]->mRadioResponse != NULL) {
5393 RadioResponseInfo responseInfo = {};
5394 populateResponseInfo(responseInfo, serial, responseType, e);
5395 Return<void> retStatus
5396 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5397 radioService[slotId]->checkReturnStatus(retStatus);
5399 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5405 int radio::getDeviceIdentityResponse(int slotId,
5406 int responseType, int serial, RIL_Errno e, void *response,
5407 size_t responseLen) {
5409 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5412 if (radioService[slotId]->mRadioResponse != NULL) {
5413 RadioResponseInfo responseInfo = {};
5414 populateResponseInfo(responseInfo, serial, responseType, e);
5416 int numStrings = responseLen / sizeof(char *);
5417 hidl_string emptyString;
5418 if (response == NULL || numStrings != 4) {
5419 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5420 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5421 Return<void> retStatus
5422 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5423 emptyString, emptyString, emptyString, emptyString);
5424 radioService[slotId]->checkReturnStatus(retStatus);
5426 char **resp = (char **) response;
5427 Return<void> retStatus
5428 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5429 convertCharPtrToHidlString(resp[0]),
5430 convertCharPtrToHidlString(resp[1]),
5431 convertCharPtrToHidlString(resp[2]),
5432 convertCharPtrToHidlString(resp[3]));
5433 radioService[slotId]->checkReturnStatus(retStatus);
5436 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5443 int radio::exitEmergencyCallbackModeResponse(int slotId,
5444 int responseType, int serial, RIL_Errno e,
5445 void *response, size_t responseLen) {
5447 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5450 if (radioService[slotId]->mRadioResponse != NULL) {
5451 RadioResponseInfo responseInfo = {};
5452 populateResponseInfo(responseInfo, serial, responseType, e);
5453 Return<void> retStatus
5454 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5456 radioService[slotId]->checkReturnStatus(retStatus);
5458 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5465 int radio::getSmscAddressResponse(int slotId,
5466 int responseType, int serial, RIL_Errno e,
5467 void *response, size_t responseLen) {
5469 RLOGD("getSmscAddressResponse: serial %d", serial);
5472 if (radioService[slotId]->mRadioResponse != NULL) {
5473 RadioResponseInfo responseInfo = {};
5474 populateResponseInfo(responseInfo, serial, responseType, e);
5475 Return<void> retStatus
5476 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5477 convertCharPtrToHidlString((char *) response));
5478 radioService[slotId]->checkReturnStatus(retStatus);
5480 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5486 int radio::setSmscAddressResponse(int slotId,
5487 int responseType, int serial, RIL_Errno e,
5488 void *response, size_t responseLen) {
5490 RLOGD("setSmscAddressResponse: serial %d", serial);
5493 if (radioService[slotId]->mRadioResponse != NULL) {
5494 RadioResponseInfo responseInfo = {};
5495 populateResponseInfo(responseInfo, serial, responseType, e);
5496 Return<void> retStatus
5497 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5498 radioService[slotId]->checkReturnStatus(retStatus);
5500 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5506 int radio::reportSmsMemoryStatusResponse(int slotId,
5507 int responseType, int serial, RIL_Errno e,
5508 void *response, size_t responseLen) {
5510 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5513 if (radioService[slotId]->mRadioResponse != NULL) {
5514 RadioResponseInfo responseInfo = {};
5515 populateResponseInfo(responseInfo, serial, responseType, e);
5516 Return<void> retStatus
5517 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5518 radioService[slotId]->checkReturnStatus(retStatus);
5520 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5527 int radio::reportStkServiceIsRunningResponse(int slotId,
5528 int responseType, int serial, RIL_Errno e,
5529 void *response, size_t responseLen) {
5531 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5534 if (radioService[slotId]->mRadioResponse != NULL) {
5535 RadioResponseInfo responseInfo = {};
5536 populateResponseInfo(responseInfo, serial, responseType, e);
5537 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5538 reportStkServiceIsRunningResponse(responseInfo);
5539 radioService[slotId]->checkReturnStatus(retStatus);
5541 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5548 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5549 int responseType, int serial, RIL_Errno e,
5550 void *response, size_t responseLen) {
5552 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5555 if (radioService[slotId]->mRadioResponse != NULL) {
5556 RadioResponseInfo responseInfo = {};
5557 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5558 Return<void> retStatus
5559 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5560 responseInfo, (CdmaSubscriptionSource) ret);
5561 radioService[slotId]->checkReturnStatus(retStatus);
5563 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5570 int radio::requestIsimAuthenticationResponse(int slotId,
5571 int responseType, int serial, RIL_Errno e,
5572 void *response, size_t responseLen) {
5574 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5577 if (radioService[slotId]->mRadioResponse != NULL) {
5578 RadioResponseInfo responseInfo = {};
5579 populateResponseInfo(responseInfo, serial, responseType, e);
5580 Return<void> retStatus
5581 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5583 convertCharPtrToHidlString((char *) response));
5584 radioService[slotId]->checkReturnStatus(retStatus);
5586 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5593 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5595 int serial, RIL_Errno e, void *response,
5596 size_t responseLen) {
5598 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5601 if (radioService[slotId]->mRadioResponse != NULL) {
5602 RadioResponseInfo responseInfo = {};
5603 populateResponseInfo(responseInfo, serial, responseType, e);
5604 Return<void> retStatus
5605 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5607 radioService[slotId]->checkReturnStatus(retStatus);
5609 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5616 int radio::sendEnvelopeWithStatusResponse(int slotId,
5617 int responseType, int serial, RIL_Errno e, void *response,
5618 size_t responseLen) {
5620 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5623 if (radioService[slotId]->mRadioResponse != NULL) {
5624 RadioResponseInfo responseInfo = {};
5625 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5626 response, responseLen);
5628 Return<void> retStatus
5629 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5631 radioService[slotId]->checkReturnStatus(retStatus);
5633 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5640 int radio::getVoiceRadioTechnologyResponse(int slotId,
5641 int responseType, int serial, RIL_Errno e,
5642 void *response, size_t responseLen) {
5644 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5647 if (radioService[slotId]->mRadioResponse != NULL) {
5648 RadioResponseInfo responseInfo = {};
5649 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5650 Return<void> retStatus
5651 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5652 responseInfo, (RadioTechnology) ret);
5653 radioService[slotId]->checkReturnStatus(retStatus);
5655 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5662 int radio::getCellInfoListResponse(int slotId,
5664 int serial, RIL_Errno e, void *response,
5665 size_t responseLen) {
5667 RLOGD("getCellInfoListResponse: serial %d", serial);
5670 if (radioService[slotId]->mRadioResponse != NULL) {
5671 RadioResponseInfo responseInfo = {};
5672 populateResponseInfo(responseInfo, serial, responseType, e);
5674 hidl_vec<CellInfo> ret;
5675 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5676 RLOGE("getCellInfoListResponse: Invalid response");
5677 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5679 convertRilCellInfoListToHal(response, responseLen, ret);
5682 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5684 radioService[slotId]->checkReturnStatus(retStatus);
5686 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5692 int radio::setCellInfoListRateResponse(int slotId,
5694 int serial, RIL_Errno e, void *response,
5695 size_t responseLen) {
5697 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5700 if (radioService[slotId]->mRadioResponse != NULL) {
5701 RadioResponseInfo responseInfo = {};
5702 populateResponseInfo(responseInfo, serial, responseType, e);
5703 Return<void> retStatus
5704 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5705 radioService[slotId]->checkReturnStatus(retStatus);
5707 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5714 int radio::setInitialAttachApnResponse(int slotId,
5715 int responseType, int serial, RIL_Errno e,
5716 void *response, size_t responseLen) {
5718 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5721 if (radioService[slotId]->mRadioResponse != NULL) {
5722 RadioResponseInfo responseInfo = {};
5723 populateResponseInfo(responseInfo, serial, responseType, e);
5724 Return<void> retStatus
5725 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5726 radioService[slotId]->checkReturnStatus(retStatus);
5728 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5735 int radio::getImsRegistrationStateResponse(int slotId,
5736 int responseType, int serial, RIL_Errno e,
5737 void *response, size_t responseLen) {
5739 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5742 if (radioService[slotId]->mRadioResponse != NULL) {
5743 RadioResponseInfo responseInfo = {};
5744 populateResponseInfo(responseInfo, serial, responseType, e);
5745 bool isRegistered = false;
5747 int numInts = responseLen / sizeof(int);
5748 if (response == NULL || numInts != 2) {
5749 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5750 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5752 int *pInt = (int *) response;
5753 isRegistered = pInt[0] == 1 ? true : false;
5754 ratFamily = pInt[1];
5756 Return<void> retStatus
5757 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5758 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5759 radioService[slotId]->checkReturnStatus(retStatus);
5761 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5768 int radio::sendImsSmsResponse(int slotId,
5769 int responseType, int serial, RIL_Errno e, void *response,
5770 size_t responseLen) {
5772 RLOGD("sendImsSmsResponse: serial %d", serial);
5775 if (radioService[slotId]->mRadioResponse != NULL) {
5776 RadioResponseInfo responseInfo = {};
5777 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5780 Return<void> retStatus
5781 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5782 radioService[slotId]->checkReturnStatus(retStatus);
5784 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5790 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5791 int responseType, int serial, RIL_Errno e,
5792 void *response, size_t responseLen) {
5794 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5797 if (radioService[slotId]->mRadioResponse != NULL) {
5798 RadioResponseInfo responseInfo = {};
5799 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5802 Return<void> retStatus
5803 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5804 responseInfo, result);
5805 radioService[slotId]->checkReturnStatus(retStatus);
5807 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5814 int radio::iccOpenLogicalChannelResponse(int slotId,
5815 int responseType, int serial, RIL_Errno e, void *response,
5816 size_t responseLen) {
5818 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5821 if (radioService[slotId]->mRadioResponse != NULL) {
5822 RadioResponseInfo responseInfo = {};
5823 populateResponseInfo(responseInfo, serial, responseType, e);
5825 hidl_vec<int8_t> selectResponse;
5826 int numInts = responseLen / sizeof(int);
5827 if (response == NULL || responseLen % sizeof(int) != 0) {
5828 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5829 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5831 int *pInt = (int *) response;
5832 channelId = pInt[0];
5833 selectResponse.resize(numInts - 1);
5834 for (int i = 1; i < numInts; i++) {
5835 selectResponse[i - 1] = (int8_t) pInt[i];
5838 Return<void> retStatus
5839 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5840 channelId, selectResponse);
5841 radioService[slotId]->checkReturnStatus(retStatus);
5843 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5850 int radio::iccCloseLogicalChannelResponse(int slotId,
5851 int responseType, int serial, RIL_Errno e,
5852 void *response, size_t responseLen) {
5854 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5857 if (radioService[slotId]->mRadioResponse != NULL) {
5858 RadioResponseInfo responseInfo = {};
5859 populateResponseInfo(responseInfo, serial, responseType, e);
5860 Return<void> retStatus
5861 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5863 radioService[slotId]->checkReturnStatus(retStatus);
5865 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5872 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5873 int responseType, int serial, RIL_Errno e,
5874 void *response, size_t responseLen) {
5876 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5879 if (radioService[slotId]->mRadioResponse != NULL) {
5880 RadioResponseInfo responseInfo = {};
5881 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5884 Return<void> retStatus
5885 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5886 responseInfo, result);
5887 radioService[slotId]->checkReturnStatus(retStatus);
5889 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5896 int radio::nvReadItemResponse(int slotId,
5897 int responseType, int serial, RIL_Errno e,
5898 void *response, size_t responseLen) {
5900 RLOGD("nvReadItemResponse: serial %d", serial);
5903 if (radioService[slotId]->mRadioResponse != NULL) {
5904 RadioResponseInfo responseInfo = {};
5905 populateResponseInfo(responseInfo, serial, responseType, e);
5906 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
5908 convertCharPtrToHidlString((char *) response));
5909 radioService[slotId]->checkReturnStatus(retStatus);
5911 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5917 int radio::nvWriteItemResponse(int slotId,
5918 int responseType, int serial, RIL_Errno e,
5919 void *response, size_t responseLen) {
5921 RLOGD("nvWriteItemResponse: serial %d", serial);
5924 if (radioService[slotId]->mRadioResponse != NULL) {
5925 RadioResponseInfo responseInfo = {};
5926 populateResponseInfo(responseInfo, serial, responseType, e);
5927 Return<void> retStatus
5928 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
5929 radioService[slotId]->checkReturnStatus(retStatus);
5931 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5937 int radio::nvWriteCdmaPrlResponse(int slotId,
5938 int responseType, int serial, RIL_Errno e,
5939 void *response, size_t responseLen) {
5941 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
5944 if (radioService[slotId]->mRadioResponse != NULL) {
5945 RadioResponseInfo responseInfo = {};
5946 populateResponseInfo(responseInfo, serial, responseType, e);
5947 Return<void> retStatus
5948 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
5949 radioService[slotId]->checkReturnStatus(retStatus);
5951 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5957 int radio::nvResetConfigResponse(int slotId,
5958 int responseType, int serial, RIL_Errno e,
5959 void *response, size_t responseLen) {
5961 RLOGD("nvResetConfigResponse: serial %d", serial);
5964 if (radioService[slotId]->mRadioResponse != NULL) {
5965 RadioResponseInfo responseInfo = {};
5966 populateResponseInfo(responseInfo, serial, responseType, e);
5967 Return<void> retStatus
5968 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
5969 radioService[slotId]->checkReturnStatus(retStatus);
5971 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5977 int radio::setUiccSubscriptionResponse(int slotId,
5978 int responseType, int serial, RIL_Errno e,
5979 void *response, size_t responseLen) {
5981 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
5984 if (radioService[slotId]->mRadioResponse != NULL) {
5985 RadioResponseInfo responseInfo = {};
5986 populateResponseInfo(responseInfo, serial, responseType, e);
5987 Return<void> retStatus
5988 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
5989 radioService[slotId]->checkReturnStatus(retStatus);
5991 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5998 int radio::setDataAllowedResponse(int slotId,
5999 int responseType, int serial, RIL_Errno e,
6000 void *response, size_t responseLen) {
6002 RLOGD("setDataAllowedResponse: serial %d", serial);
6005 if (radioService[slotId]->mRadioResponse != NULL) {
6006 RadioResponseInfo responseInfo = {};
6007 populateResponseInfo(responseInfo, serial, responseType, e);
6008 Return<void> retStatus
6009 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
6010 radioService[slotId]->checkReturnStatus(retStatus);
6012 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6018 int radio::getHardwareConfigResponse(int slotId,
6019 int responseType, int serial, RIL_Errno e,
6020 void *response, size_t responseLen) {
6022 RLOGD("getHardwareConfigResponse: serial %d", serial);
6025 if (radioService[slotId]->mRadioResponse != NULL) {
6026 RadioResponseInfo responseInfo = {};
6027 populateResponseInfo(responseInfo, serial, responseType, e);
6029 hidl_vec<HardwareConfig> result;
6030 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
6031 RLOGE("hardwareConfigChangedInd: invalid response");
6032 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6034 convertRilHardwareConfigListToHal(response, responseLen, result);
6037 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
6038 responseInfo, result);
6039 radioService[slotId]->checkReturnStatus(retStatus);
6041 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6047 int radio::requestIccSimAuthenticationResponse(int slotId,
6048 int responseType, int serial, RIL_Errno e,
6049 void *response, size_t responseLen) {
6051 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6054 if (radioService[slotId]->mRadioResponse != NULL) {
6055 RadioResponseInfo responseInfo = {};
6056 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6059 Return<void> retStatus
6060 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6061 responseInfo, result);
6062 radioService[slotId]->checkReturnStatus(retStatus);
6064 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6071 int radio::setDataProfileResponse(int slotId,
6072 int responseType, int serial, RIL_Errno e,
6073 void *response, size_t responseLen) {
6075 RLOGD("setDataProfileResponse: serial %d", serial);
6078 if (radioService[slotId]->mRadioResponse != NULL) {
6079 RadioResponseInfo responseInfo = {};
6080 populateResponseInfo(responseInfo, serial, responseType, e);
6081 Return<void> retStatus
6082 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6083 radioService[slotId]->checkReturnStatus(retStatus);
6085 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6091 int radio::requestShutdownResponse(int slotId,
6092 int responseType, int serial, RIL_Errno e,
6093 void *response, size_t responseLen) {
6095 RLOGD("requestShutdownResponse: serial %d", serial);
6098 if (radioService[slotId]->mRadioResponse != NULL) {
6099 RadioResponseInfo responseInfo = {};
6100 populateResponseInfo(responseInfo, serial, responseType, e);
6101 Return<void> retStatus
6102 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6103 radioService[slotId]->checkReturnStatus(retStatus);
6105 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6111 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6112 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6113 populateResponseInfo(responseInfo, serial, responseType, e);
6115 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6116 RLOGE("responseRadioCapability: Invalid response");
6117 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6118 rc.logicalModemUuid = hidl_string();
6120 convertRilRadioCapabilityToHal(response, responseLen, rc);
6124 int radio::getRadioCapabilityResponse(int slotId,
6125 int responseType, int serial, RIL_Errno e,
6126 void *response, size_t responseLen) {
6128 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6131 if (radioService[slotId]->mRadioResponse != NULL) {
6132 RadioResponseInfo responseInfo = {};
6133 RadioCapability result = {};
6134 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6136 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6137 responseInfo, result);
6138 radioService[slotId]->checkReturnStatus(retStatus);
6140 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6146 int radio::setRadioCapabilityResponse(int slotId,
6147 int responseType, int serial, RIL_Errno e,
6148 void *response, size_t responseLen) {
6150 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6153 if (radioService[slotId]->mRadioResponse != NULL) {
6154 RadioResponseInfo responseInfo = {};
6155 RadioCapability result = {};
6156 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6158 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6159 responseInfo, result);
6160 radioService[slotId]->checkReturnStatus(retStatus);
6162 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6168 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6169 RIL_Errno e, void *response, size_t responseLen) {
6170 populateResponseInfo(responseInfo, serial, responseType, e);
6171 LceStatusInfo result = {};
6173 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6174 RLOGE("Invalid response: NULL");
6175 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6177 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6178 result.lceStatus = (LceStatus) resp->lce_status;
6179 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6184 int radio::startLceServiceResponse(int slotId,
6185 int responseType, int serial, RIL_Errno e,
6186 void *response, size_t responseLen) {
6188 RLOGD("startLceServiceResponse: serial %d", serial);
6191 if (radioService[slotId]->mRadioResponse != NULL) {
6192 RadioResponseInfo responseInfo = {};
6193 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6194 response, responseLen);
6196 Return<void> retStatus
6197 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6199 radioService[slotId]->checkReturnStatus(retStatus);
6201 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6207 int radio::stopLceServiceResponse(int slotId,
6208 int responseType, int serial, RIL_Errno e,
6209 void *response, size_t responseLen) {
6211 RLOGD("stopLceServiceResponse: serial %d", serial);
6214 if (radioService[slotId]->mRadioResponse != NULL) {
6215 RadioResponseInfo responseInfo = {};
6216 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6217 response, responseLen);
6219 Return<void> retStatus
6220 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6222 radioService[slotId]->checkReturnStatus(retStatus);
6224 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6230 int radio::pullLceDataResponse(int slotId,
6231 int responseType, int serial, RIL_Errno e,
6232 void *response, size_t responseLen) {
6234 RLOGD("pullLceDataResponse: serial %d", serial);
6237 if (radioService[slotId]->mRadioResponse != NULL) {
6238 RadioResponseInfo responseInfo = {};
6239 populateResponseInfo(responseInfo, serial, responseType, e);
6241 LceDataInfo result = {};
6242 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6243 RLOGE("pullLceDataResponse: Invalid response");
6244 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6246 convertRilLceDataInfoToHal(response, responseLen, result);
6249 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6250 responseInfo, result);
6251 radioService[slotId]->checkReturnStatus(retStatus);
6253 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6259 int radio::getModemActivityInfoResponse(int slotId,
6260 int responseType, int serial, RIL_Errno e,
6261 void *response, size_t responseLen) {
6263 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6266 if (radioService[slotId]->mRadioResponse != NULL) {
6267 RadioResponseInfo responseInfo = {};
6268 populateResponseInfo(responseInfo, serial, responseType, e);
6269 ActivityStatsInfo info;
6270 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6271 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6272 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6274 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6275 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6276 info.idleModeTimeMs = resp->idle_mode_time_ms;
6277 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6278 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6280 info.rxModeTimeMs = resp->rx_mode_time_ms;
6283 Return<void> retStatus
6284 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6286 radioService[slotId]->checkReturnStatus(retStatus);
6288 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6295 int radio::setAllowedCarriersResponse(int slotId,
6296 int responseType, int serial, RIL_Errno e,
6297 void *response, size_t responseLen) {
6299 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6302 if (radioService[slotId]->mRadioResponse != NULL) {
6303 RadioResponseInfo responseInfo = {};
6304 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6305 Return<void> retStatus
6306 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6308 radioService[slotId]->checkReturnStatus(retStatus);
6310 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6317 int radio::getAllowedCarriersResponse(int slotId,
6318 int responseType, int serial, RIL_Errno e,
6319 void *response, size_t responseLen) {
6321 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6324 if (radioService[slotId]->mRadioResponse != NULL) {
6325 RadioResponseInfo responseInfo = {};
6326 populateResponseInfo(responseInfo, serial, responseType, e);
6327 CarrierRestrictions carrierInfo = {};
6328 bool allAllowed = true;
6329 if (response == NULL) {
6331 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6333 carrierInfo.allowedCarriers.resize(0);
6334 carrierInfo.excludedCarriers.resize(0);
6335 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6336 RLOGE("getAllowedCarriersResponse Invalid response");
6337 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6339 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6340 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6344 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6345 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6346 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6347 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6348 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6349 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6350 carrierInfo.allowedCarriers[i].matchData =
6351 convertCharPtrToHidlString(carrier->match_data);
6354 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6355 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6356 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6357 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6358 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6359 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6360 carrierInfo.excludedCarriers[i].matchData =
6361 convertCharPtrToHidlString(carrier->match_data);
6365 Return<void> retStatus
6366 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6367 allAllowed, carrierInfo);
6368 radioService[slotId]->checkReturnStatus(retStatus);
6370 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6377 int radio::sendDeviceStateResponse(int slotId,
6378 int responseType, int serial, RIL_Errno e,
6379 void *response, size_t responselen) {
6381 RLOGD("sendDeviceStateResponse: serial %d", serial);
6384 if (radioService[slotId]->mRadioResponse != NULL) {
6385 RadioResponseInfo responseInfo = {};
6386 populateResponseInfo(responseInfo, serial, responseType, e);
6387 Return<void> retStatus
6388 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6389 radioService[slotId]->checkReturnStatus(retStatus);
6391 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6397 int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
6398 int responseType, int serial, RIL_Errno e,
6399 void *response, size_t responseLen) {
6400 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
6401 if (radioService[slotId]->mRadioResponse != NULL) {
6402 RadioResponseInfo responseInfo = {};
6403 populateResponseInfo(responseInfo, serial, responseType, e);
6404 Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
6405 ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
6406 radioService[slotId]->mRadioResponse);
6408 sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
6409 Return<void> retStatus
6410 = radioResponseV1_1->setCarrierInfoForImsiEncryptionResponse(responseInfo);
6411 radioService[slotId]->checkReturnStatus(retStatus);
6413 RLOGE("setCarrierInfoForImsiEncryptionResponse: ret.isOk() == false for "
6414 "radioService[%d]" , slotId);
6417 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponse == NULL",
6423 int radio::setIndicationFilterResponse(int slotId,
6424 int responseType, int serial, RIL_Errno e,
6425 void *response, size_t responselen) {
6427 RLOGD("setIndicationFilterResponse: serial %d", serial);
6430 if (radioService[slotId]->mRadioResponse != NULL) {
6431 RadioResponseInfo responseInfo = {};
6432 populateResponseInfo(responseInfo, serial, responseType, e);
6433 Return<void> retStatus
6434 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6435 radioService[slotId]->checkReturnStatus(retStatus);
6437 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6444 int radio::setSimCardPowerResponse(int slotId,
6445 int responseType, int serial, RIL_Errno e,
6446 void *response, size_t responseLen) {
6448 RLOGD("setSimCardPowerResponse: serial %d", serial);
6451 if (radioService[slotId]->mRadioResponse != NULL) {
6452 RadioResponseInfo responseInfo = {};
6453 populateResponseInfo(responseInfo, serial, responseType, e);
6454 Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
6455 ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
6456 radioService[slotId]->mRadioResponse);
6458 sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
6459 Return<void> retStatus
6460 = radioResponseV1_1->setSimCardPowerResponse_1_1(responseInfo);
6461 radioService[slotId]->checkReturnStatus(retStatus);
6463 RLOGD("setSimCardPowerResponse: ret.isOK() == false for radioService[%d]",
6465 Return<void> retStatus
6466 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6467 radioService[slotId]->checkReturnStatus(retStatus);
6470 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL",
6476 int radio::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6477 void *response, size_t responseLen) {
6479 RLOGD("startNetworkScanResponse: serial %d", serial);
6482 if (radioService[slotId]->mRadioResponse != NULL) {
6483 RadioResponseInfo responseInfo = {};
6484 populateResponseInfo(responseInfo, serial, responseType, e);
6485 Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
6486 ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
6487 radioService[slotId]->mRadioResponse);
6489 sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
6490 Return<void> retStatus = radioResponseV1_1->startNetworkScanResponse(responseInfo);
6491 radioService[slotId]->checkReturnStatus(retStatus);
6493 RLOGD("startNetworkScanResponse: ret.isOK() == false for radioService[%d]", slotId);
6496 RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6502 int radio::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6503 void *response, size_t responseLen) {
6505 RLOGD("stopNetworkScanResponse: serial %d", serial);
6508 if (radioService[slotId]->mRadioResponse != NULL) {
6509 RadioResponseInfo responseInfo = {};
6510 populateResponseInfo(responseInfo, serial, responseType, e);
6511 Return<sp<::android::hardware::radio::V1_1::IRadioResponse>> ret =
6512 ::android::hardware::radio::V1_1::IRadioResponse::castFrom(
6513 radioService[slotId]->mRadioResponse);
6515 sp<::android::hardware::radio::V1_1::IRadioResponse> radioResponseV1_1 = ret;
6516 Return<void> retStatus = radioResponseV1_1->stopNetworkScanResponse(responseInfo);
6517 radioService[slotId]->checkReturnStatus(retStatus);
6519 RLOGD("stopNetworkScanResponse: ret.isOK() == false for radioService[%d]", slotId);
6522 RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6528 int radio::sendRequestRawResponse(int slotId,
6529 int responseType, int serial, RIL_Errno e,
6530 void *response, size_t responseLen) {
6532 RLOGD("sendRequestRawResponse: serial %d", serial);
6535 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6536 RadioResponseInfo responseInfo = {};
6537 populateResponseInfo(responseInfo, serial, responseType, e);
6538 hidl_vec<uint8_t> data;
6540 if (response == NULL) {
6541 RLOGE("sendRequestRawResponse: Invalid response");
6542 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6544 data.setToExternal((uint8_t *) response, responseLen);
6546 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6547 sendRequestRawResponse(responseInfo, data);
6548 checkReturnStatus(slotId, retStatus, false);
6550 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6557 int radio::sendRequestStringsResponse(int slotId,
6558 int responseType, int serial, RIL_Errno e,
6559 void *response, size_t responseLen) {
6561 RLOGD("sendRequestStringsResponse: serial %d", serial);
6564 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6565 RadioResponseInfo responseInfo = {};
6566 populateResponseInfo(responseInfo, serial, responseType, e);
6567 hidl_vec<hidl_string> data;
6569 if (response == NULL || responseLen % sizeof(char *) != 0) {
6570 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6571 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6573 char **resp = (char **) response;
6574 int numStrings = responseLen / sizeof(char *);
6575 data.resize(numStrings);
6576 for (int i = 0; i < numStrings; i++) {
6577 data[i] = convertCharPtrToHidlString(resp[i]);
6580 Return<void> retStatus
6581 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6582 responseInfo, data);
6583 checkReturnStatus(slotId, retStatus, false);
6585 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6592 // Radio Indication functions
6594 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6595 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6596 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6599 int radio::radioStateChangedInd(int slotId,
6600 int indicationType, int token, RIL_Errno e, void *response,
6601 size_t responseLen) {
6602 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6603 RadioState radioState = (RadioState) s_vendorFunctions->onStateRequest();
6604 RLOGD("radioStateChangedInd: radioState %d", radioState);
6605 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6606 convertIntToRadioIndicationType(indicationType), radioState);
6607 radioService[slotId]->checkReturnStatus(retStatus);
6609 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6615 int radio::callStateChangedInd(int slotId,
6616 int indicationType, int token, RIL_Errno e, void *response,
6617 size_t responseLen) {
6618 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6620 RLOGD("callStateChangedInd");
6622 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6623 convertIntToRadioIndicationType(indicationType));
6624 radioService[slotId]->checkReturnStatus(retStatus);
6626 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6632 int radio::networkStateChangedInd(int slotId,
6633 int indicationType, int token, RIL_Errno e, void *response,
6634 size_t responseLen) {
6635 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6637 RLOGD("networkStateChangedInd");
6639 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6640 convertIntToRadioIndicationType(indicationType));
6641 radioService[slotId]->checkReturnStatus(retStatus);
6643 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6650 uint8_t hexCharToInt(uint8_t c) {
6651 if (c >= '0' && c <= '9') return (c - '0');
6652 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6653 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6655 return INVALID_HEX_CHAR;
6658 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6659 if (responseLen % 2 != 0) {
6663 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6664 if (bytes == NULL) {
6665 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6668 uint8_t *hexString = (uint8_t *)response;
6670 for (size_t i = 0; i < responseLen; i += 2) {
6671 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6672 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6674 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6675 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6676 hexString[i], hexString[i + 1]);
6680 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6686 int radio::newSmsInd(int slotId, int indicationType,
6687 int token, RIL_Errno e, void *response, size_t responseLen) {
6688 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6689 if (response == NULL || responseLen == 0) {
6690 RLOGE("newSmsInd: invalid response");
6694 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6695 if (bytes == NULL) {
6696 RLOGE("newSmsInd: convertHexStringToBytes failed");
6700 hidl_vec<uint8_t> pdu;
6701 pdu.setToExternal(bytes, responseLen/2);
6705 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6706 convertIntToRadioIndicationType(indicationType), pdu);
6707 radioService[slotId]->checkReturnStatus(retStatus);
6710 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6716 int radio::newSmsStatusReportInd(int slotId,
6717 int indicationType, int token, RIL_Errno e, void *response,
6718 size_t responseLen) {
6719 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6720 if (response == NULL || responseLen == 0) {
6721 RLOGE("newSmsStatusReportInd: invalid response");
6725 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6726 if (bytes == NULL) {
6727 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6731 hidl_vec<uint8_t> pdu;
6732 pdu.setToExternal(bytes, responseLen/2);
6734 RLOGD("newSmsStatusReportInd");
6736 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6737 convertIntToRadioIndicationType(indicationType), pdu);
6738 radioService[slotId]->checkReturnStatus(retStatus);
6741 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6747 int radio::newSmsOnSimInd(int slotId, int indicationType,
6748 int token, RIL_Errno e, void *response, size_t responseLen) {
6749 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6750 if (response == NULL || responseLen != sizeof(int)) {
6751 RLOGE("newSmsOnSimInd: invalid response");
6754 int32_t recordNumber = ((int32_t *) response)[0];
6756 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6758 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6759 convertIntToRadioIndicationType(indicationType), recordNumber);
6760 radioService[slotId]->checkReturnStatus(retStatus);
6762 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6768 int radio::onUssdInd(int slotId, int indicationType,
6769 int token, RIL_Errno e, void *response, size_t responseLen) {
6770 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6771 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6772 RLOGE("onUssdInd: invalid response");
6775 char **strings = (char **) response;
6776 char *mode = strings[0];
6777 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6778 UssdModeType modeType = (UssdModeType) atoi(mode);
6780 RLOGD("onUssdInd: mode %s", mode);
6782 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6783 convertIntToRadioIndicationType(indicationType), modeType, msg);
6784 radioService[slotId]->checkReturnStatus(retStatus);
6786 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6792 int radio::nitzTimeReceivedInd(int slotId,
6793 int indicationType, int token, RIL_Errno e, void *response,
6794 size_t responseLen) {
6795 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6796 if (response == NULL || responseLen == 0) {
6797 RLOGE("nitzTimeReceivedInd: invalid response");
6800 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6801 int64_t timeReceived = android::elapsedRealtime();
6803 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6806 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6807 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6808 radioService[slotId]->checkReturnStatus(retStatus);
6810 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6817 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6818 SignalStrength& signalStrength) {
6819 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6821 // Fixup LTE for backwards compatibility
6822 // signalStrength: -1 -> 99
6823 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6824 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6826 // rsrp: -1 -> INT_MAX all other negative value to positive.
6828 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6829 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6830 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6831 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6833 // rsrq: -1 -> INT_MAX
6834 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6835 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6837 // Not remapping rssnr is already using INT_MAX
6838 // cqi: -1 -> INT_MAX
6839 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6840 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6843 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6844 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6845 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6846 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6847 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6848 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6849 signalStrength.evdo.signalNoiseRatio =
6850 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6851 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6852 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6853 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6854 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6855 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6856 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6857 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6860 int radio::currentSignalStrengthInd(int slotId,
6861 int indicationType, int token, RIL_Errno e,
6862 void *response, size_t responseLen) {
6863 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6864 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
6865 RLOGE("currentSignalStrengthInd: invalid response");
6869 SignalStrength signalStrength = {};
6870 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6873 RLOGD("currentSignalStrengthInd");
6875 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6876 convertIntToRadioIndicationType(indicationType), signalStrength);
6877 radioService[slotId]->checkReturnStatus(retStatus);
6879 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6886 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6887 SetupDataCallResult& dcResult) {
6888 dcResult.status = (DataCallFailCause) dcResponse->status;
6889 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6890 dcResult.cid = dcResponse->cid;
6891 dcResult.active = dcResponse->active;
6892 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6893 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6894 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6895 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6896 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6897 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6898 dcResult.mtu = dcResponse->mtu;
6901 void convertRilDataCallListToHal(void *response, size_t responseLen,
6902 hidl_vec<SetupDataCallResult>& dcResultList) {
6903 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6905 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6906 dcResultList.resize(num);
6907 for (int i = 0; i < num; i++) {
6908 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6912 int radio::dataCallListChangedInd(int slotId,
6913 int indicationType, int token, RIL_Errno e, void *response,
6914 size_t responseLen) {
6915 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6916 if (response == NULL || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
6917 RLOGE("dataCallListChangedInd: invalid response");
6920 hidl_vec<SetupDataCallResult> dcList;
6921 convertRilDataCallListToHal(response, responseLen, dcList);
6923 RLOGD("dataCallListChangedInd");
6925 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
6926 convertIntToRadioIndicationType(indicationType), dcList);
6927 radioService[slotId]->checkReturnStatus(retStatus);
6929 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6935 int radio::suppSvcNotifyInd(int slotId, int indicationType,
6936 int token, RIL_Errno e, void *response, size_t responseLen) {
6937 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6938 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
6939 RLOGE("suppSvcNotifyInd: invalid response");
6943 SuppSvcNotification suppSvc = {};
6944 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
6945 suppSvc.isMT = ssn->notificationType;
6946 suppSvc.code = ssn->code;
6947 suppSvc.index = ssn->index;
6948 suppSvc.type = ssn->type;
6949 suppSvc.number = convertCharPtrToHidlString(ssn->number);
6952 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
6953 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
6955 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
6956 convertIntToRadioIndicationType(indicationType), suppSvc);
6957 radioService[slotId]->checkReturnStatus(retStatus);
6959 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
6965 int radio::stkSessionEndInd(int slotId, int indicationType,
6966 int token, RIL_Errno e, void *response, size_t responseLen) {
6967 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6969 RLOGD("stkSessionEndInd");
6971 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
6972 convertIntToRadioIndicationType(indicationType));
6973 radioService[slotId]->checkReturnStatus(retStatus);
6975 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
6981 int radio::stkProactiveCommandInd(int slotId,
6982 int indicationType, int token, RIL_Errno e, void *response,
6983 size_t responseLen) {
6984 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6985 if (response == NULL || responseLen == 0) {
6986 RLOGE("stkProactiveCommandInd: invalid response");
6990 RLOGD("stkProactiveCommandInd");
6992 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
6993 convertIntToRadioIndicationType(indicationType),
6994 convertCharPtrToHidlString((char *) response));
6995 radioService[slotId]->checkReturnStatus(retStatus);
6997 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
7003 int radio::stkEventNotifyInd(int slotId, int indicationType,
7004 int token, RIL_Errno e, void *response, size_t responseLen) {
7005 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7006 if (response == NULL || responseLen == 0) {
7007 RLOGE("stkEventNotifyInd: invalid response");
7011 RLOGD("stkEventNotifyInd");
7013 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
7014 convertIntToRadioIndicationType(indicationType),
7015 convertCharPtrToHidlString((char *) response));
7016 radioService[slotId]->checkReturnStatus(retStatus);
7018 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7024 int radio::stkCallSetupInd(int slotId, int indicationType,
7025 int token, RIL_Errno e, void *response, size_t responseLen) {
7026 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7027 if (response == NULL || responseLen != sizeof(int)) {
7028 RLOGE("stkCallSetupInd: invalid response");
7031 int32_t timeout = ((int32_t *) response)[0];
7033 RLOGD("stkCallSetupInd: timeout %d", timeout);
7035 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
7036 convertIntToRadioIndicationType(indicationType), timeout);
7037 radioService[slotId]->checkReturnStatus(retStatus);
7039 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
7045 int radio::simSmsStorageFullInd(int slotId,
7046 int indicationType, int token, RIL_Errno e, void *response,
7047 size_t responseLen) {
7048 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7050 RLOGD("simSmsStorageFullInd");
7052 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
7053 convertIntToRadioIndicationType(indicationType));
7054 radioService[slotId]->checkReturnStatus(retStatus);
7056 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
7062 int radio::simRefreshInd(int slotId, int indicationType,
7063 int token, RIL_Errno e, void *response, size_t responseLen) {
7064 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7065 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
7066 RLOGE("simRefreshInd: invalid response");
7070 SimRefreshResult refreshResult = {};
7071 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
7072 refreshResult.type =
7073 (android::hardware::radio::V1_0::SimRefreshType) simRefreshResponse->result;
7074 refreshResult.efId = simRefreshResponse->ef_id;
7075 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
7078 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
7080 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
7081 convertIntToRadioIndicationType(indicationType), refreshResult);
7082 radioService[slotId]->checkReturnStatus(retStatus);
7084 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
7090 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
7091 CdmaSignalInfoRecord& record) {
7092 record.isPresent = signalInfoRecord->isPresent;
7093 record.signalType = signalInfoRecord->signalType;
7094 record.alertPitch = signalInfoRecord->alertPitch;
7095 record.signal = signalInfoRecord->signal;
7098 int radio::callRingInd(int slotId, int indicationType,
7099 int token, RIL_Errno e, void *response, size_t responseLen) {
7100 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7102 CdmaSignalInfoRecord record = {};
7103 if (response == NULL || responseLen == 0) {
7107 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
7108 RLOGE("callRingInd: invalid response");
7111 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
7115 RLOGD("callRingInd: isGsm %d", isGsm);
7117 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
7118 convertIntToRadioIndicationType(indicationType), isGsm, record);
7119 radioService[slotId]->checkReturnStatus(retStatus);
7121 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7127 int radio::simStatusChangedInd(int slotId,
7128 int indicationType, int token, RIL_Errno e, void *response,
7129 size_t responseLen) {
7130 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7132 RLOGD("simStatusChangedInd");
7134 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7135 convertIntToRadioIndicationType(indicationType));
7136 radioService[slotId]->checkReturnStatus(retStatus);
7138 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7144 int radio::cdmaNewSmsInd(int slotId, int indicationType,
7145 int token, RIL_Errno e, void *response, size_t responseLen) {
7146 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7147 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7148 RLOGE("cdmaNewSmsInd: invalid response");
7152 CdmaSmsMessage msg = {};
7153 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7154 msg.teleserviceId = rilMsg->uTeleserviceID;
7155 msg.isServicePresent = rilMsg->bIsServicePresent;
7156 msg.serviceCategory = rilMsg->uServicecategory;
7157 msg.address.digitMode =
7158 (android::hardware::radio::V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7159 msg.address.numberMode =
7160 (android::hardware::radio::V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7161 msg.address.numberType =
7162 (android::hardware::radio::V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7163 msg.address.numberPlan =
7164 (android::hardware::radio::V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7166 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7167 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7169 msg.subAddress.subaddressType = (android::hardware::radio::V1_0::CdmaSmsSubaddressType)
7170 rilMsg->sSubAddress.subaddressType;
7171 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7173 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7174 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7176 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7177 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7180 RLOGD("cdmaNewSmsInd");
7182 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7183 convertIntToRadioIndicationType(indicationType), msg);
7184 radioService[slotId]->checkReturnStatus(retStatus);
7186 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7192 int radio::newBroadcastSmsInd(int slotId,
7193 int indicationType, int token, RIL_Errno e, void *response,
7194 size_t responseLen) {
7195 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7196 if (response == NULL || responseLen == 0) {
7197 RLOGE("newBroadcastSmsInd: invalid response");
7201 hidl_vec<uint8_t> data;
7202 data.setToExternal((uint8_t *) response, responseLen);
7204 RLOGD("newBroadcastSmsInd");
7206 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7207 convertIntToRadioIndicationType(indicationType), data);
7208 radioService[slotId]->checkReturnStatus(retStatus);
7210 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7216 int radio::cdmaRuimSmsStorageFullInd(int slotId,
7217 int indicationType, int token, RIL_Errno e, void *response,
7218 size_t responseLen) {
7219 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7221 RLOGD("cdmaRuimSmsStorageFullInd");
7223 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7224 convertIntToRadioIndicationType(indicationType));
7225 radioService[slotId]->checkReturnStatus(retStatus);
7227 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7234 int radio::restrictedStateChangedInd(int slotId,
7235 int indicationType, int token, RIL_Errno e, void *response,
7236 size_t responseLen) {
7237 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7238 if (response == NULL || responseLen != sizeof(int)) {
7239 RLOGE("restrictedStateChangedInd: invalid response");
7242 int32_t state = ((int32_t *) response)[0];
7244 RLOGD("restrictedStateChangedInd: state %d", state);
7246 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7247 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7248 radioService[slotId]->checkReturnStatus(retStatus);
7250 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7257 int radio::enterEmergencyCallbackModeInd(int slotId,
7258 int indicationType, int token, RIL_Errno e, void *response,
7259 size_t responseLen) {
7260 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7262 RLOGD("enterEmergencyCallbackModeInd");
7264 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7265 convertIntToRadioIndicationType(indicationType));
7266 radioService[slotId]->checkReturnStatus(retStatus);
7268 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7275 int radio::cdmaCallWaitingInd(int slotId,
7276 int indicationType, int token, RIL_Errno e, void *response,
7277 size_t responseLen) {
7278 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7279 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7280 RLOGE("cdmaCallWaitingInd: invalid response");
7284 CdmaCallWaiting callWaitingRecord = {};
7285 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7286 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7287 callWaitingRecord.numberPresentation =
7288 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7289 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7290 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7291 callWaitingRecord.signalInfoRecord);
7292 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7293 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7296 RLOGD("cdmaCallWaitingInd");
7298 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7299 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7300 radioService[slotId]->checkReturnStatus(retStatus);
7302 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7308 int radio::cdmaOtaProvisionStatusInd(int slotId,
7309 int indicationType, int token, RIL_Errno e, void *response,
7310 size_t responseLen) {
7311 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7312 if (response == NULL || responseLen != sizeof(int)) {
7313 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7316 int32_t status = ((int32_t *) response)[0];
7318 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7320 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7321 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7322 radioService[slotId]->checkReturnStatus(retStatus);
7324 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7331 int radio::cdmaInfoRecInd(int slotId,
7332 int indicationType, int token, RIL_Errno e, void *response,
7333 size_t responseLen) {
7334 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7335 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7336 RLOGE("cdmaInfoRecInd: invalid response");
7340 CdmaInformationRecords records = {};
7341 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7343 char* string8 = NULL;
7344 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7345 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7346 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7347 "additional ones", recordsRil->numberOfInfoRecs,
7348 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7350 records.infoRec.resize(num);
7351 for (int i = 0 ; i < num ; i++) {
7352 CdmaInformationRecord *record = &records.infoRec[i];
7353 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7354 record->name = (CdmaInfoRecName) infoRec->name;
7355 // All vectors should be size 0 except one which will be size 1. Set everything to
7356 // size 0 initially.
7357 record->display.resize(0);
7358 record->number.resize(0);
7359 record->signal.resize(0);
7360 record->redir.resize(0);
7361 record->lineCtrl.resize(0);
7362 record->clir.resize(0);
7363 record->audioCtrl.resize(0);
7364 switch (infoRec->name) {
7365 case RIL_CDMA_DISPLAY_INFO_REC:
7366 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7367 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7368 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7369 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7370 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7373 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7374 if (string8 == NULL) {
7375 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7376 "responseCdmaInformationRecords");
7379 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7380 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7382 record->display.resize(1);
7383 record->display[0].alphaBuf = string8;
7389 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7390 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7391 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7392 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7393 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7394 "expected not more than %d", (int) infoRec->rec.number.len,
7395 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7398 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7399 if (string8 == NULL) {
7400 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7401 "responseCdmaInformationRecords");
7404 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7405 string8[(int)infoRec->rec.number.len] = '\0';
7407 record->number.resize(1);
7408 record->number[0].number = string8;
7411 record->number[0].numberType = infoRec->rec.number.number_type;
7412 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7413 record->number[0].pi = infoRec->rec.number.pi;
7414 record->number[0].si = infoRec->rec.number.si;
7418 case RIL_CDMA_SIGNAL_INFO_REC: {
7419 record->signal.resize(1);
7420 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7421 record->signal[0].signalType = infoRec->rec.signal.signalType;
7422 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7423 record->signal[0].signal = infoRec->rec.signal.signal;
7427 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7428 if (infoRec->rec.redir.redirectingNumber.len >
7429 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7430 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7431 "expected not more than %d\n",
7432 (int)infoRec->rec.redir.redirectingNumber.len,
7433 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7436 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7438 if (string8 == NULL) {
7439 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7440 "responseCdmaInformationRecords");
7443 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7444 infoRec->rec.redir.redirectingNumber.len);
7445 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7447 record->redir.resize(1);
7448 record->redir[0].redirectingNumber.number = string8;
7451 record->redir[0].redirectingNumber.numberType =
7452 infoRec->rec.redir.redirectingNumber.number_type;
7453 record->redir[0].redirectingNumber.numberPlan =
7454 infoRec->rec.redir.redirectingNumber.number_plan;
7455 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7456 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7457 record->redir[0].redirectingReason =
7458 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7462 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7463 record->lineCtrl.resize(1);
7464 record->lineCtrl[0].lineCtrlPolarityIncluded =
7465 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7466 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7467 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7468 record->lineCtrl[0].lineCtrlPowerDenial =
7469 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7473 case RIL_CDMA_T53_CLIR_INFO_REC: {
7474 record->clir.resize(1);
7475 record->clir[0].cause = infoRec->rec.clir.cause;
7479 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7480 record->audioCtrl.resize(1);
7481 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7482 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7486 case RIL_CDMA_T53_RELEASE_INFO_REC:
7487 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7491 RLOGE("cdmaInfoRecInd: Incorrect name value");
7497 RLOGD("cdmaInfoRecInd");
7499 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7500 convertIntToRadioIndicationType(indicationType), records);
7501 radioService[slotId]->checkReturnStatus(retStatus);
7503 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7509 int radio::indicateRingbackToneInd(int slotId,
7510 int indicationType, int token, RIL_Errno e, void *response,
7511 size_t responseLen) {
7512 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7513 if (response == NULL || responseLen != sizeof(int)) {
7514 RLOGE("indicateRingbackToneInd: invalid response");
7517 bool start = ((int32_t *) response)[0];
7519 RLOGD("indicateRingbackToneInd: start %d", start);
7521 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7522 convertIntToRadioIndicationType(indicationType), start);
7523 radioService[slotId]->checkReturnStatus(retStatus);
7525 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7531 int radio::resendIncallMuteInd(int slotId,
7532 int indicationType, int token, RIL_Errno e, void *response,
7533 size_t responseLen) {
7534 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7536 RLOGD("resendIncallMuteInd");
7538 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7539 convertIntToRadioIndicationType(indicationType));
7540 radioService[slotId]->checkReturnStatus(retStatus);
7542 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7548 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7549 int indicationType, int token, RIL_Errno e,
7550 void *response, size_t responseLen) {
7551 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7552 if (response == NULL || responseLen != sizeof(int)) {
7553 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7556 int32_t cdmaSource = ((int32_t *) response)[0];
7558 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7560 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7561 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7562 (CdmaSubscriptionSource) cdmaSource);
7563 radioService[slotId]->checkReturnStatus(retStatus);
7565 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7572 int radio::cdmaPrlChangedInd(int slotId,
7573 int indicationType, int token, RIL_Errno e, void *response,
7574 size_t responseLen) {
7575 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7576 if (response == NULL || responseLen != sizeof(int)) {
7577 RLOGE("cdmaPrlChangedInd: invalid response");
7580 int32_t version = ((int32_t *) response)[0];
7582 RLOGD("cdmaPrlChangedInd: version %d", version);
7584 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7585 convertIntToRadioIndicationType(indicationType), version);
7586 radioService[slotId]->checkReturnStatus(retStatus);
7588 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7594 int radio::exitEmergencyCallbackModeInd(int slotId,
7595 int indicationType, int token, RIL_Errno e, void *response,
7596 size_t responseLen) {
7597 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7599 RLOGD("exitEmergencyCallbackModeInd");
7601 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7602 convertIntToRadioIndicationType(indicationType));
7603 radioService[slotId]->checkReturnStatus(retStatus);
7605 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7612 int radio::rilConnectedInd(int slotId,
7613 int indicationType, int token, RIL_Errno e, void *response,
7614 size_t responseLen) {
7615 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7616 RLOGD("rilConnectedInd");
7617 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7618 convertIntToRadioIndicationType(indicationType));
7619 radioService[slotId]->checkReturnStatus(retStatus);
7621 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7627 int radio::voiceRadioTechChangedInd(int slotId,
7628 int indicationType, int token, RIL_Errno e, void *response,
7629 size_t responseLen) {
7630 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7631 if (response == NULL || responseLen != sizeof(int)) {
7632 RLOGE("voiceRadioTechChangedInd: invalid response");
7635 int32_t rat = ((int32_t *) response)[0];
7637 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7639 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7640 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7641 radioService[slotId]->checkReturnStatus(retStatus);
7643 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7650 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7651 int num = responseLen / sizeof(RIL_CellInfo_v12);
7652 records.resize(num);
7654 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7655 for (int i = 0; i < num; i++) {
7656 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7657 records[i].registered = rillCellInfo->registered;
7658 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7659 records[i].timeStamp = rillCellInfo->timeStamp;
7660 // All vectors should be size 0 except one which will be size 1. Set everything to
7661 // size 0 initially.
7662 records[i].gsm.resize(0);
7663 records[i].wcdma.resize(0);
7664 records[i].cdma.resize(0);
7665 records[i].lte.resize(0);
7666 records[i].tdscdma.resize(0);
7667 switch(rillCellInfo->cellInfoType) {
7668 case RIL_CELL_INFO_TYPE_GSM: {
7669 records[i].gsm.resize(1);
7670 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7671 cellInfoGsm->cellIdentityGsm.mcc =
7672 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7673 cellInfoGsm->cellIdentityGsm.mnc =
7674 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7675 cellInfoGsm->cellIdentityGsm.lac =
7676 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7677 cellInfoGsm->cellIdentityGsm.cid =
7678 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7679 cellInfoGsm->cellIdentityGsm.arfcn =
7680 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7681 cellInfoGsm->cellIdentityGsm.bsic =
7682 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7683 cellInfoGsm->signalStrengthGsm.signalStrength =
7684 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7685 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7686 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7687 cellInfoGsm->signalStrengthGsm.timingAdvance =
7688 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7692 case RIL_CELL_INFO_TYPE_WCDMA: {
7693 records[i].wcdma.resize(1);
7694 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7695 cellInfoWcdma->cellIdentityWcdma.mcc =
7696 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7697 cellInfoWcdma->cellIdentityWcdma.mnc =
7698 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7699 cellInfoWcdma->cellIdentityWcdma.lac =
7700 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7701 cellInfoWcdma->cellIdentityWcdma.cid =
7702 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7703 cellInfoWcdma->cellIdentityWcdma.psc =
7704 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7705 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7706 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7707 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7708 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7709 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7710 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7714 case RIL_CELL_INFO_TYPE_CDMA: {
7715 records[i].cdma.resize(1);
7716 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7717 cellInfoCdma->cellIdentityCdma.networkId =
7718 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7719 cellInfoCdma->cellIdentityCdma.systemId =
7720 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7721 cellInfoCdma->cellIdentityCdma.baseStationId =
7722 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7723 cellInfoCdma->cellIdentityCdma.longitude =
7724 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7725 cellInfoCdma->cellIdentityCdma.latitude =
7726 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7727 cellInfoCdma->signalStrengthCdma.dbm =
7728 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7729 cellInfoCdma->signalStrengthCdma.ecio =
7730 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7731 cellInfoCdma->signalStrengthEvdo.dbm =
7732 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7733 cellInfoCdma->signalStrengthEvdo.ecio =
7734 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7735 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7736 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7740 case RIL_CELL_INFO_TYPE_LTE: {
7741 records[i].lte.resize(1);
7742 CellInfoLte *cellInfoLte = &records[i].lte[0];
7743 cellInfoLte->cellIdentityLte.mcc =
7744 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7745 cellInfoLte->cellIdentityLte.mnc =
7746 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7747 cellInfoLte->cellIdentityLte.ci =
7748 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7749 cellInfoLte->cellIdentityLte.pci =
7750 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7751 cellInfoLte->cellIdentityLte.tac =
7752 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7753 cellInfoLte->cellIdentityLte.earfcn =
7754 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7755 cellInfoLte->signalStrengthLte.signalStrength =
7756 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7757 cellInfoLte->signalStrengthLte.rsrp =
7758 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7759 cellInfoLte->signalStrengthLte.rsrq =
7760 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7761 cellInfoLte->signalStrengthLte.rssnr =
7762 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7763 cellInfoLte->signalStrengthLte.cqi =
7764 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7765 cellInfoLte->signalStrengthLte.timingAdvance =
7766 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7770 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7771 records[i].tdscdma.resize(1);
7772 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7773 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7774 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7775 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7776 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7777 cellInfoTdscdma->cellIdentityTdscdma.lac =
7778 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7779 cellInfoTdscdma->cellIdentityTdscdma.cid =
7780 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7781 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7782 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7783 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7784 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7795 int radio::cellInfoListInd(int slotId,
7796 int indicationType, int token, RIL_Errno e, void *response,
7797 size_t responseLen) {
7798 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7799 if (response == NULL || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7800 RLOGE("cellInfoListInd: invalid response");
7804 hidl_vec<CellInfo> records;
7805 convertRilCellInfoListToHal(response, responseLen, records);
7808 RLOGD("cellInfoListInd");
7810 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7811 convertIntToRadioIndicationType(indicationType), records);
7812 radioService[slotId]->checkReturnStatus(retStatus);
7814 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7820 int radio::imsNetworkStateChangedInd(int slotId,
7821 int indicationType, int token, RIL_Errno e, void *response,
7822 size_t responseLen) {
7823 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7825 RLOGD("imsNetworkStateChangedInd");
7827 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7828 convertIntToRadioIndicationType(indicationType));
7829 radioService[slotId]->checkReturnStatus(retStatus);
7831 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7838 int radio::subscriptionStatusChangedInd(int slotId,
7839 int indicationType, int token, RIL_Errno e, void *response,
7840 size_t responseLen) {
7841 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7842 if (response == NULL || responseLen != sizeof(int)) {
7843 RLOGE("subscriptionStatusChangedInd: invalid response");
7846 bool activate = ((int32_t *) response)[0];
7848 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7850 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
7851 convertIntToRadioIndicationType(indicationType), activate);
7852 radioService[slotId]->checkReturnStatus(retStatus);
7854 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
7861 int radio::srvccStateNotifyInd(int slotId,
7862 int indicationType, int token, RIL_Errno e, void *response,
7863 size_t responseLen) {
7864 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7865 if (response == NULL || responseLen != sizeof(int)) {
7866 RLOGE("srvccStateNotifyInd: invalid response");
7869 int32_t state = ((int32_t *) response)[0];
7871 RLOGD("srvccStateNotifyInd: rat %d", state);
7873 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
7874 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
7875 radioService[slotId]->checkReturnStatus(retStatus);
7877 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7883 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7884 hidl_vec<HardwareConfig>& records) {
7885 int num = responseLen / sizeof(RIL_HardwareConfig);
7886 records.resize(num);
7888 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7889 for (int i = 0; i < num; i++) {
7890 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7891 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7892 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7893 switch (rilHardwareConfig[i].type) {
7894 case RIL_HARDWARE_CONFIG_MODEM: {
7895 records[i].modem.resize(1);
7896 records[i].sim.resize(0);
7897 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7898 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7899 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7900 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7901 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7905 case RIL_HARDWARE_CONFIG_SIM: {
7906 records[i].sim.resize(1);
7907 records[i].modem.resize(0);
7908 records[i].sim[0].modemUuid =
7909 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7916 int radio::hardwareConfigChangedInd(int slotId,
7917 int indicationType, int token, RIL_Errno e, void *response,
7918 size_t responseLen) {
7919 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7920 if (response == NULL || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7921 RLOGE("hardwareConfigChangedInd: invalid response");
7925 hidl_vec<HardwareConfig> configs;
7926 convertRilHardwareConfigListToHal(response, responseLen, configs);
7929 RLOGD("hardwareConfigChangedInd");
7931 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
7932 convertIntToRadioIndicationType(indicationType), configs);
7933 radioService[slotId]->checkReturnStatus(retStatus);
7935 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
7942 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
7943 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
7944 rc.session = rilRadioCapability->session;
7945 rc.phase = (android::hardware::radio::V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
7946 rc.raf = rilRadioCapability->rat;
7947 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
7948 rc.status = (android::hardware::radio::V1_0::RadioCapabilityStatus) rilRadioCapability->status;
7951 int radio::radioCapabilityIndicationInd(int slotId,
7952 int indicationType, int token, RIL_Errno e, void *response,
7953 size_t responseLen) {
7954 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7955 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
7956 RLOGE("radioCapabilityIndicationInd: invalid response");
7960 RadioCapability rc = {};
7961 convertRilRadioCapabilityToHal(response, responseLen, rc);
7964 RLOGD("radioCapabilityIndicationInd");
7966 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
7967 convertIntToRadioIndicationType(indicationType), rc);
7968 radioService[slotId]->checkReturnStatus(retStatus);
7970 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
7977 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
7978 if ((reqType == SS_INTERROGATION) &&
7979 (serType == SS_CFU ||
7980 serType == SS_CF_BUSY ||
7981 serType == SS_CF_NO_REPLY ||
7982 serType == SS_CF_NOT_REACHABLE ||
7983 serType == SS_CF_ALL ||
7984 serType == SS_CF_ALL_CONDITIONAL)) {
7990 int radio::onSupplementaryServiceIndicationInd(int slotId,
7991 int indicationType, int token, RIL_Errno e,
7992 void *response, size_t responseLen) {
7993 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7994 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
7995 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
7999 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
8000 StkCcUnsolSsResult ss = {};
8001 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
8002 ss.requestType = (SsRequestType) rilSsResponse->requestType;
8003 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
8004 ss.serviceClass = rilSsResponse->serviceClass;
8005 ss.result = (RadioError) rilSsResponse->result;
8007 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
8009 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
8010 rilSsResponse->cfData.numValidIndexes);
8012 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
8013 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
8014 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
8015 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
8018 ss.cfData.resize(1);
8019 ss.ssInfo.resize(0);
8021 /* number of call info's */
8022 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
8024 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
8025 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
8026 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
8028 cfInfo->status = (CallForwardInfoStatus) cf.status;
8029 cfInfo->reason = cf.reason;
8030 cfInfo->serviceClass = cf.serviceClass;
8031 cfInfo->toa = cf.toa;
8032 cfInfo->number = convertCharPtrToHidlString(cf.number);
8033 cfInfo->timeSeconds = cf.timeSeconds;
8035 RLOGD("onSupplementaryServiceIndicationInd: "
8036 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
8037 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
8041 ss.ssInfo.resize(1);
8042 ss.cfData.resize(0);
8045 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
8046 for (int i = 0; i < SS_INFO_MAX; i++) {
8048 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
8049 rilSsResponse->ssInfo[i]);
8051 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
8056 RLOGD("onSupplementaryServiceIndicationInd");
8058 Return<void> retStatus = radioService[slotId]->mRadioIndication->
8059 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
8061 radioService[slotId]->checkReturnStatus(retStatus);
8063 RLOGE("onSupplementaryServiceIndicationInd: "
8064 "radioService[%d]->mRadioIndication == NULL", slotId);
8070 int radio::stkCallControlAlphaNotifyInd(int slotId,
8071 int indicationType, int token, RIL_Errno e, void *response,
8072 size_t responseLen) {
8073 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8074 if (response == NULL || responseLen == 0) {
8075 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
8079 RLOGD("stkCallControlAlphaNotifyInd");
8081 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
8082 convertIntToRadioIndicationType(indicationType),
8083 convertCharPtrToHidlString((char *) response));
8084 radioService[slotId]->checkReturnStatus(retStatus);
8086 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
8093 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
8094 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
8095 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
8096 lce.confidenceLevel = rilLceDataInfo->confidence_level;
8097 lce.lceSuspended = rilLceDataInfo->lce_suspended;
8100 int radio::lceDataInd(int slotId,
8101 int indicationType, int token, RIL_Errno e, void *response,
8102 size_t responseLen) {
8103 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8104 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
8105 RLOGE("lceDataInd: invalid response");
8109 LceDataInfo lce = {};
8110 convertRilLceDataInfoToHal(response, responseLen, lce);
8112 RLOGD("lceDataInd");
8114 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
8115 convertIntToRadioIndicationType(indicationType), lce);
8116 radioService[slotId]->checkReturnStatus(retStatus);
8118 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8124 int radio::pcoDataInd(int slotId,
8125 int indicationType, int token, RIL_Errno e, void *response,
8126 size_t responseLen) {
8127 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8128 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8129 RLOGE("pcoDataInd: invalid response");
8133 PcoDataInfo pco = {};
8134 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8135 pco.cid = rilPcoData->cid;
8136 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8137 pco.pcoId = rilPcoData->pco_id;
8138 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8141 RLOGD("pcoDataInd");
8143 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8144 convertIntToRadioIndicationType(indicationType), pco);
8145 radioService[slotId]->checkReturnStatus(retStatus);
8147 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8153 int radio::modemResetInd(int slotId,
8154 int indicationType, int token, RIL_Errno e, void *response,
8155 size_t responseLen) {
8156 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8157 if (response == NULL || responseLen == 0) {
8158 RLOGE("modemResetInd: invalid response");
8162 RLOGD("modemResetInd");
8164 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8165 convertIntToRadioIndicationType(indicationType),
8166 convertCharPtrToHidlString((char *) response));
8167 radioService[slotId]->checkReturnStatus(retStatus);
8169 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8175 int radio::networkScanResultInd(int slotId,
8176 int indicationType, int token, RIL_Errno e, void *response,
8177 size_t responseLen) {
8179 RLOGD("networkScanResultInd");
8181 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8182 if (response == NULL || responseLen == 0) {
8183 RLOGE("networkScanResultInd: invalid response");
8186 RLOGD("networkScanResultInd");
8189 RLOGD("networkScanResultInd");
8192 Return<sp<::android::hardware::radio::V1_1::IRadioIndication>> ret =
8193 ::android::hardware::radio::V1_1::IRadioIndication::castFrom(
8194 radioService[slotId]->mRadioIndication);
8196 RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
8198 ::android::hardware::radio::V1_1::NetworkScanResult result;
8200 (::android::hardware::radio::V1_1::ScanStatus) networkScanResult->status;
8201 result.error = (RadioError) e;
8202 convertRilCellInfoListToHal(
8203 networkScanResult->network_infos,
8204 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
8205 result.networkInfos);
8207 sp<::android::hardware::radio::V1_1::IRadioIndication> radioIndicationV1_1 = ret;
8208 Return<void> retStatus = radioIndicationV1_1->networkScanResult(
8209 convertIntToRadioIndicationType(indicationType), result);
8210 radioService[slotId]->checkReturnStatus(retStatus);
8212 RLOGE("networkScanResultInd: ret.isOk() == false for radioService[%d]", slotId);
8215 RLOGE("networkScanResultInd: radioService[%d]->mRadioIndication == NULL", slotId);
8220 int radio::carrierInfoForImsiEncryption(int slotId,
8221 int indicationType, int token, RIL_Errno e, void *response,
8222 size_t responseLen) {
8223 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8224 if (response == NULL || responseLen == 0) {
8225 RLOGE("carrierInfoForImsiEncryption: invalid response");
8228 RLOGD("carrierInfoForImsiEncryption");
8229 Return<sp<::android::hardware::radio::V1_1::IRadioIndication>> ret =
8230 ::android::hardware::radio::V1_1::IRadioIndication::castFrom(
8231 radioService[slotId]->mRadioIndication);
8233 sp<::android::hardware::radio::V1_1::IRadioIndication> radioIndicationV1_1 = ret;
8234 Return<void> retStatus = radioIndicationV1_1->carrierInfoForImsiEncryption(
8235 convertIntToRadioIndicationType(indicationType));
8236 radioService[slotId]->checkReturnStatus(retStatus);
8238 RLOGE("carrierInfoForImsiEncryptionResponse: ret.isOk() == false for radioService[%d]",
8242 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndication == NULL", slotId);
8248 int radio::oemHookRawInd(int slotId,
8249 int indicationType, int token, RIL_Errno e, void *response,
8250 size_t responseLen) {
8251 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8252 if (response == NULL || responseLen == 0) {
8253 RLOGE("oemHookRawInd: invalid response");
8257 hidl_vec<uint8_t> data;
8258 data.setToExternal((uint8_t *) response, responseLen);
8260 RLOGD("oemHookRawInd");
8262 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8263 convertIntToRadioIndicationType(indicationType), data);
8264 checkReturnStatus(slotId, retStatus, false);
8266 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8272 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8273 using namespace android::hardware;
8275 const char *serviceNames[] = {
8276 android::RIL_getServiceName()
8277 #if (SIM_COUNT >= 2)
8279 #if (SIM_COUNT >= 3)
8281 #if (SIM_COUNT >= 4)
8288 #if (SIM_COUNT >= 2)
8289 simCount = SIM_COUNT;
8292 configureRpcThreadpool(1, true /* callerWillJoin */);
8293 for (int i = 0; i < simCount; i++) {
8294 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8295 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8298 radioService[i] = new RadioImpl;
8299 radioService[i]->mSlotId = i;
8300 oemHookService[i] = new OemHookImpl;
8301 oemHookService[i]->mSlotId = i;
8302 RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
8304 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8305 status = oemHookService[i]->registerAsService(serviceNames[i]);
8307 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8311 s_vendorFunctions = callbacks;
8312 s_commands = commands;
8315 void rilc_thread_pool() {
8316 joinRpcThreadpool();
8319 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8320 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8322 #if (SIM_COUNT >= 2)
8323 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8324 #if (SIM_COUNT >= 3)
8325 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8326 #if (SIM_COUNT >= 4)
8327 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8332 return radioServiceRwlockPtr;