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;
36 using namespace android::hardware::radio::V1_0;
37 using namespace android::hardware::radio::deprecated::V1_0;
38 using ::android::hardware::configureRpcThreadpool;
39 using ::android::hardware::joinRpcThreadpool;
40 using ::android::hardware::Return;
41 using ::android::hardware::hidl_string;
42 using ::android::hardware::hidl_vec;
43 using ::android::hardware::hidl_array;
44 using ::android::hardware::Void;
45 using android::CommandInfo;
46 using android::RequestInfo;
47 using android::requestToString;
50 #define BOOL_TO_INT(x) (x ? 1 : 0)
51 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
52 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
54 #if defined(ANDROID_MULTI_SIM)
55 #define CALL_ONREQUEST(a, b, c, d, e) \
56 s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e)))
57 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a))
59 #define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d))
60 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
63 RIL_RadioFunctions *s_vendorFunctions = NULL;
64 static CommandInfo *s_commands;
70 sp<RadioImpl> radioService[SIM_COUNT];
71 sp<OemHookImpl> oemHookService[SIM_COUNT];
72 // counter used for synchronization. It is incremented every time response callbacks are updated.
73 volatile int32_t mCounterRadio[SIM_COUNT];
74 volatile int32_t mCounterOemHook[SIM_COUNT];
76 sp<RadioImpl> radioService[1];
77 sp<OemHookImpl> oemHookService[1];
78 // counter used for synchronization. It is incremented every time response callbacks are updated.
79 volatile int32_t mCounterRadio[1];
80 volatile int32_t mCounterOemHook[1];
83 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
86 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
88 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
90 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
95 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
96 hidl_vec<HardwareConfig>& records);
98 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
100 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
102 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
103 SignalStrength& signalStrength);
105 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
106 SetupDataCallResult& dcResult);
108 void convertRilDataCallListToHal(void *response, size_t responseLen,
109 hidl_vec<SetupDataCallResult>& dcResultList);
111 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
113 struct RadioImpl : public V1_1::IRadio {
115 sp<IRadioResponse> mRadioResponse;
116 sp<IRadioIndication> mRadioIndication;
117 sp<V1_1::IRadioResponse> mRadioResponseV1_1;
118 sp<V1_1::IRadioIndication> mRadioIndicationV1_1;
120 Return<void> setResponseFunctions(
121 const ::android::sp<IRadioResponse>& radioResponse,
122 const ::android::sp<IRadioIndication>& radioIndication);
124 Return<void> getIccCardStatus(int32_t serial);
126 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
127 const hidl_string& aid);
129 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
130 const hidl_string& pin, const hidl_string& aid);
132 Return<void> supplyIccPin2ForApp(int32_t serial,
133 const hidl_string& pin2,
134 const hidl_string& aid);
136 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
137 const hidl_string& pin2, const hidl_string& aid);
139 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
140 const hidl_string& newPin, const hidl_string& aid);
142 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
143 const hidl_string& newPin2, const hidl_string& aid);
145 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
147 Return<void> getCurrentCalls(int32_t serial);
149 Return<void> dial(int32_t serial, const Dial& dialInfo);
151 Return<void> getImsiForApp(int32_t serial,
152 const ::android::hardware::hidl_string& aid);
154 Return<void> hangup(int32_t serial, int32_t gsmIndex);
156 Return<void> hangupWaitingOrBackground(int32_t serial);
158 Return<void> hangupForegroundResumeBackground(int32_t serial);
160 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
162 Return<void> conference(int32_t serial);
164 Return<void> rejectCall(int32_t serial);
166 Return<void> getLastCallFailCause(int32_t serial);
168 Return<void> getSignalStrength(int32_t serial);
170 Return<void> getVoiceRegistrationState(int32_t serial);
172 Return<void> getDataRegistrationState(int32_t serial);
174 Return<void> getOperator(int32_t serial);
176 Return<void> setRadioPower(int32_t serial, bool on);
178 Return<void> sendDtmf(int32_t serial,
179 const ::android::hardware::hidl_string& s);
181 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
183 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
185 Return<void> setupDataCall(int32_t serial,
186 RadioTechnology radioTechnology,
187 const DataProfileInfo& profileInfo,
192 Return<void> iccIOForApp(int32_t serial,
195 Return<void> sendUssd(int32_t serial,
196 const ::android::hardware::hidl_string& ussd);
198 Return<void> cancelPendingUssd(int32_t serial);
200 Return<void> getClir(int32_t serial);
202 Return<void> setClir(int32_t serial, int32_t status);
204 Return<void> getCallForwardStatus(int32_t serial,
205 const CallForwardInfo& callInfo);
207 Return<void> setCallForward(int32_t serial,
208 const CallForwardInfo& callInfo);
210 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
212 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
214 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
215 bool success, SmsAcknowledgeFailCause cause);
217 Return<void> acceptCall(int32_t serial);
219 Return<void> deactivateDataCall(int32_t serial,
220 int32_t cid, bool reasonRadioShutDown);
222 Return<void> getFacilityLockForApp(int32_t serial,
223 const ::android::hardware::hidl_string& facility,
224 const ::android::hardware::hidl_string& password,
225 int32_t serviceClass,
226 const ::android::hardware::hidl_string& appId);
228 Return<void> setFacilityLockForApp(int32_t serial,
229 const ::android::hardware::hidl_string& facility,
231 const ::android::hardware::hidl_string& password,
232 int32_t serviceClass,
233 const ::android::hardware::hidl_string& appId);
235 Return<void> setBarringPassword(int32_t serial,
236 const ::android::hardware::hidl_string& facility,
237 const ::android::hardware::hidl_string& oldPassword,
238 const ::android::hardware::hidl_string& newPassword);
240 Return<void> getNetworkSelectionMode(int32_t serial);
242 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
244 Return<void> setNetworkSelectionModeManual(int32_t serial,
245 const ::android::hardware::hidl_string& operatorNumeric);
247 Return<void> getAvailableNetworks(int32_t serial);
249 Return<void> startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request);
251 Return<void> stopNetworkScan(int32_t serial);
253 Return<void> startDtmf(int32_t serial,
254 const ::android::hardware::hidl_string& s);
256 Return<void> stopDtmf(int32_t serial);
258 Return<void> getBasebandVersion(int32_t serial);
260 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
262 Return<void> setMute(int32_t serial, bool enable);
264 Return<void> getMute(int32_t serial);
266 Return<void> getClip(int32_t serial);
268 Return<void> getDataCallList(int32_t serial);
270 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
272 Return<void> writeSmsToSim(int32_t serial,
273 const SmsWriteArgs& smsWriteArgs);
275 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
277 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
279 Return<void> getAvailableBandModes(int32_t serial);
281 Return<void> sendEnvelope(int32_t serial,
282 const ::android::hardware::hidl_string& command);
284 Return<void> sendTerminalResponseToSim(int32_t serial,
285 const ::android::hardware::hidl_string& commandResponse);
287 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
289 Return<void> explicitCallTransfer(int32_t serial);
291 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
293 Return<void> getPreferredNetworkType(int32_t serial);
295 Return<void> getNeighboringCids(int32_t serial);
297 Return<void> setLocationUpdates(int32_t serial, bool enable);
299 Return<void> setCdmaSubscriptionSource(int32_t serial,
300 CdmaSubscriptionSource cdmaSub);
302 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
304 Return<void> getCdmaRoamingPreference(int32_t serial);
306 Return<void> setTTYMode(int32_t serial, TtyMode mode);
308 Return<void> getTTYMode(int32_t serial);
310 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
312 Return<void> getPreferredVoicePrivacy(int32_t serial);
314 Return<void> sendCDMAFeatureCode(int32_t serial,
315 const ::android::hardware::hidl_string& featureCode);
317 Return<void> sendBurstDtmf(int32_t serial,
318 const ::android::hardware::hidl_string& dtmf,
322 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
324 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
325 const CdmaSmsAck& smsAck);
327 Return<void> getGsmBroadcastConfig(int32_t serial);
329 Return<void> setGsmBroadcastConfig(int32_t serial,
330 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
332 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
334 Return<void> getCdmaBroadcastConfig(int32_t serial);
336 Return<void> setCdmaBroadcastConfig(int32_t serial,
337 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
339 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
341 Return<void> getCDMASubscription(int32_t serial);
343 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
345 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
347 Return<void> getDeviceIdentity(int32_t serial);
349 Return<void> exitEmergencyCallbackMode(int32_t serial);
351 Return<void> getSmscAddress(int32_t serial);
353 Return<void> setSmscAddress(int32_t serial,
354 const ::android::hardware::hidl_string& smsc);
356 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
358 Return<void> reportStkServiceIsRunning(int32_t serial);
360 Return<void> getCdmaSubscriptionSource(int32_t serial);
362 Return<void> requestIsimAuthentication(int32_t serial,
363 const ::android::hardware::hidl_string& challenge);
365 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
367 const ::android::hardware::hidl_string& ackPdu);
369 Return<void> sendEnvelopeWithStatus(int32_t serial,
370 const ::android::hardware::hidl_string& contents);
372 Return<void> getVoiceRadioTechnology(int32_t serial);
374 Return<void> getCellInfoList(int32_t serial);
376 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
378 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
379 bool modemCognitive, bool isRoaming);
381 Return<void> getImsRegistrationState(int32_t serial);
383 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
385 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
387 Return<void> iccOpenLogicalChannel(int32_t serial,
388 const ::android::hardware::hidl_string& aid, int32_t p2);
390 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
392 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
394 Return<void> nvReadItem(int32_t serial, NvItem itemId);
396 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
398 Return<void> nvWriteCdmaPrl(int32_t serial,
399 const ::android::hardware::hidl_vec<uint8_t>& prl);
401 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
403 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
405 Return<void> setDataAllowed(int32_t serial, bool allow);
407 Return<void> getHardwareConfig(int32_t serial);
409 Return<void> requestIccSimAuthentication(int32_t serial,
411 const ::android::hardware::hidl_string& authData,
412 const ::android::hardware::hidl_string& aid);
414 Return<void> setDataProfile(int32_t serial,
415 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
417 Return<void> requestShutdown(int32_t serial);
419 Return<void> getRadioCapability(int32_t serial);
421 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
423 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
425 Return<void> stopLceService(int32_t serial);
427 Return<void> pullLceData(int32_t serial);
429 Return<void> getModemActivityInfo(int32_t serial);
431 Return<void> setAllowedCarriers(int32_t serial,
433 const CarrierRestrictions& carriers);
435 Return<void> getAllowedCarriers(int32_t serial);
437 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
439 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
441 Return<void> startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive);
443 Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
445 Return<void> setSimCardPower(int32_t serial, bool powerUp);
446 Return<void> setSimCardPower_1_1(int32_t serial,
447 const V1_1::CardPowerState state);
449 Return<void> responseAcknowledgement();
451 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
452 const V1_1::ImsiEncryptionInfo& message);
454 void checkReturnStatus(Return<void>& ret);
457 struct OemHookImpl : public IOemHook {
459 sp<IOemHookResponse> mOemHookResponse;
460 sp<IOemHookIndication> mOemHookIndication;
462 Return<void> setResponseFunctions(
463 const ::android::sp<IOemHookResponse>& oemHookResponse,
464 const ::android::sp<IOemHookIndication>& oemHookIndication);
466 Return<void> sendRequestRaw(int32_t serial,
467 const ::android::hardware::hidl_vec<uint8_t>& data);
469 Return<void> sendRequestStrings(int32_t serial,
470 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
473 void memsetAndFreeStrings(int numPointers, ...) {
475 va_start(ap, numPointers);
476 for (int i = 0; i < numPointers; i++) {
477 char *ptr = va_arg(ap, char *);
480 #define MAX_STRING_LENGTH 4096
481 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
489 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
490 pRI->pCI->responseFunction((int) pRI->socket_id,
491 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
495 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
496 * request with error RIL_E_NO_MEMORY.
497 * Returns true on success, and false on failure.
499 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI, bool allowEmpty) {
500 size_t len = src.size();
501 if (len == 0 && !allowEmpty) {
505 *dest = (char *) calloc(len + 1, sizeof(char));
507 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
508 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
511 strncpy(*dest, src.c_str(), len + 1);
515 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
516 return copyHidlStringToRil(dest, src, pRI, false);
519 hidl_string convertCharPtrToHidlString(const char *ptr) {
522 // TODO: replace this with strnlen
523 ret.setToExternal(ptr, strlen(ptr));
528 bool dispatchVoid(int serial, int slotId, int request) {
529 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
533 CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
537 bool dispatchString(int serial, int slotId, int request, const char * str) {
538 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
544 if (!copyHidlStringToRil(&pString, str, pRI)) {
548 CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
550 memsetAndFreeStrings(1, pString);
554 bool dispatchStrings(int serial, int slotId, int request, bool allowEmpty, int countStrings, ...) {
555 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
561 pStrings = (char **)calloc(countStrings, sizeof(char *));
562 if (pStrings == NULL) {
563 RLOGE("Memory allocation failed for request %s", requestToString(request));
564 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
568 va_start(ap, countStrings);
569 for (int i = 0; i < countStrings; i++) {
570 const char* str = va_arg(ap, const char *);
571 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI, allowEmpty)) {
573 for (int j = 0; j < i; j++) {
574 memsetAndFreeStrings(1, pStrings[j]);
582 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
584 if (pStrings != NULL) {
585 for (int i = 0 ; i < countStrings ; i++) {
586 memsetAndFreeStrings(1, pStrings[i]);
590 memset(pStrings, 0, countStrings * sizeof(char *));
597 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
598 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
603 int countStrings = data.size();
605 pStrings = (char **)calloc(countStrings, sizeof(char *));
606 if (pStrings == NULL) {
607 RLOGE("Memory allocation failed for request %s", requestToString(request));
608 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
612 for (int i = 0; i < countStrings; i++) {
613 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
614 for (int j = 0; j < i; j++) {
615 memsetAndFreeStrings(1, pStrings[j]);
622 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
624 if (pStrings != NULL) {
625 for (int i = 0 ; i < countStrings ; i++) {
626 memsetAndFreeStrings(1, pStrings[i]);
630 memset(pStrings, 0, countStrings * sizeof(char *));
637 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
638 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
643 int *pInts = (int *)calloc(countInts, sizeof(int));
646 RLOGE("Memory allocation failed for request %s", requestToString(request));
647 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
651 va_start(ap, countInts);
652 for (int i = 0; i < countInts; i++) {
653 pInts[i] = va_arg(ap, int);
657 CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
661 memset(pInts, 0, countInts * sizeof(int));
668 bool dispatchCallForwardStatus(int serial, int slotId, int request,
669 const CallForwardInfo& callInfo) {
670 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
675 RIL_CallForwardInfo cf;
676 cf.status = (int) callInfo.status;
677 cf.reason = callInfo.reason;
678 cf.serviceClass = callInfo.serviceClass;
679 cf.toa = callInfo.toa;
680 cf.timeSeconds = callInfo.timeSeconds;
682 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
686 CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
688 memsetAndFreeStrings(1, cf.number);
693 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
694 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
699 const uint8_t *uData = rawBytes.data();
701 CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
706 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
707 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
712 RIL_SIM_APDU apdu = {};
714 apdu.sessionid = message.sessionId;
715 apdu.cla = message.cla;
716 apdu.instruction = message.instruction;
717 apdu.p1 = message.p1;
718 apdu.p2 = message.p2;
719 apdu.p3 = message.p3;
721 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
725 CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
727 memsetAndFreeStrings(1, apdu.data);
732 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
733 if (ret.isOk() == false) {
734 RLOGE("checkReturnStatus: unable to call response/indication callback");
735 // Remote process hosting the callbacks must be dead. Reset the callback objects;
736 // there's no other recovery to be done here. When the client process is back up, it will
737 // call setResponseFunctions()
739 // Caller should already hold rdlock, release that first
740 // note the current counter to avoid overwriting updates made by another thread before
741 // write lock is acquired.
742 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
743 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
744 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
748 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
751 // make sure the counter value has not changed
752 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
753 if (isRadioService) {
754 radioService[slotId]->mRadioResponse = NULL;
755 radioService[slotId]->mRadioIndication = NULL;
756 radioService[slotId]->mRadioResponseV1_1 = NULL;
757 radioService[slotId]->mRadioIndicationV1_1 = NULL;
759 oemHookService[slotId]->mOemHookResponse = NULL;
760 oemHookService[slotId]->mOemHookIndication = NULL;
762 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
764 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
765 "got updated on another thread");
769 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
773 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
778 void RadioImpl::checkReturnStatus(Return<void>& ret) {
779 ::checkReturnStatus(mSlotId, ret, true);
782 Return<void> RadioImpl::setResponseFunctions(
783 const ::android::sp<IRadioResponse>& radioResponseParam,
784 const ::android::sp<IRadioIndication>& radioIndicationParam) {
785 RLOGD("setResponseFunctions");
787 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
788 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
791 mRadioResponse = radioResponseParam;
792 mRadioIndication = radioIndicationParam;
793 mRadioResponseV1_1 = V1_1::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
794 mRadioIndicationV1_1 = V1_1::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
795 if (mRadioResponseV1_1 == nullptr || mRadioIndicationV1_1 == nullptr) {
796 mRadioResponseV1_1 = nullptr;
797 mRadioIndicationV1_1 = nullptr;
800 mCounterRadio[mSlotId]++;
802 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
805 // client is connected. Send initial indications.
806 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
811 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
813 RLOGD("getIccCardStatus: serial %d", serial);
815 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
819 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
820 const hidl_string& aid) {
822 RLOGD("supplyIccPinForApp: serial %d", serial);
824 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN, true,
825 2, pin.c_str(), aid.c_str());
829 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
830 const hidl_string& pin, const hidl_string& aid) {
832 RLOGD("supplyIccPukForApp: serial %d", serial);
834 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK, true,
835 3, puk.c_str(), pin.c_str(), aid.c_str());
839 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
840 const hidl_string& aid) {
842 RLOGD("supplyIccPin2ForApp: serial %d", serial);
844 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2, true,
845 2, pin2.c_str(), aid.c_str());
849 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
850 const hidl_string& pin2, const hidl_string& aid) {
852 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
854 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2, true,
855 3, puk2.c_str(), pin2.c_str(), aid.c_str());
859 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
860 const hidl_string& newPin, const hidl_string& aid) {
862 RLOGD("changeIccPinForApp: serial %d", serial);
864 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN, true,
865 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
869 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
870 const hidl_string& newPin2, const hidl_string& aid) {
872 RLOGD("changeIccPin2ForApp: serial %d", serial);
874 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2, true,
875 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
879 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
880 const hidl_string& netPin) {
882 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
884 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, true,
889 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
891 RLOGD("getCurrentCalls: serial %d", serial);
893 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
897 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
899 RLOGD("dial: serial %d", serial);
901 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
906 RIL_UUS_Info uusInfo = {};
907 int32_t sizeOfDial = sizeof(dial);
909 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
912 dial.clir = (int) dialInfo.clir;
914 if (dialInfo.uusInfo.size() != 0) {
915 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
916 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
918 if (dialInfo.uusInfo[0].uusData.size() == 0) {
919 uusInfo.uusData = NULL;
920 uusInfo.uusLength = 0;
922 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
923 memsetAndFreeStrings(1, dial.address);
926 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
929 dial.uusInfo = &uusInfo;
932 CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
934 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
939 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
941 RLOGD("getImsiForApp: serial %d", serial);
943 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI, false,
948 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
950 RLOGD("hangup: serial %d", serial);
952 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
956 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
958 RLOGD("hangupWaitingOrBackground: serial %d", serial);
960 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
964 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
966 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
968 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
972 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
974 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
976 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
980 Return<void> RadioImpl::conference(int32_t serial) {
982 RLOGD("conference: serial %d", serial);
984 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
988 Return<void> RadioImpl::rejectCall(int32_t serial) {
990 RLOGD("rejectCall: serial %d", serial);
992 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
996 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
998 RLOGD("getLastCallFailCause: serial %d", serial);
1000 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
1004 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
1006 RLOGD("getSignalStrength: serial %d", serial);
1008 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
1012 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
1014 RLOGD("getVoiceRegistrationState: serial %d", serial);
1016 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
1020 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
1022 RLOGD("getDataRegistrationState: serial %d", serial);
1024 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1028 Return<void> RadioImpl::getOperator(int32_t serial) {
1030 RLOGD("getOperator: serial %d", serial);
1032 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1036 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
1037 RLOGD("setRadioPower: serial %d on %d", serial, on);
1038 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1042 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1044 RLOGD("sendDtmf: serial %d", serial);
1046 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1050 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1052 RLOGD("sendSms: serial %d", serial);
1054 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, false,
1055 2, message.smscPdu.c_str(), message.pdu.c_str());
1059 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1061 RLOGD("sendSMSExpectMore: serial %d", serial);
1063 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, false,
1064 2, message.smscPdu.c_str(), message.pdu.c_str());
1068 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1070 case MvnoType::IMSI:
1071 str = (char *)"imsi";
1074 str = (char *)"gid";
1077 str = (char *)"spn";
1079 case MvnoType::NONE:
1086 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1087 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1088 bool roamingAllowed, bool isRoaming) {
1091 RLOGD("setupDataCall: serial %d", serial);
1094 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1095 const hidl_string &protocol =
1096 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1097 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 7,
1098 std::to_string((int) radioTechnology + 2).c_str(),
1099 std::to_string((int) dataProfileInfo.profileId).c_str(),
1100 dataProfileInfo.apn.c_str(),
1101 dataProfileInfo.user.c_str(),
1102 dataProfileInfo.password.c_str(),
1103 std::to_string((int) dataProfileInfo.authType).c_str(),
1105 } else if (s_vendorFunctions->version >= 15) {
1106 char *mvnoTypeStr = NULL;
1107 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1108 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1109 RIL_REQUEST_SETUP_DATA_CALL);
1111 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1115 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
1116 std::to_string((int) radioTechnology + 2).c_str(),
1117 std::to_string((int) dataProfileInfo.profileId).c_str(),
1118 dataProfileInfo.apn.c_str(),
1119 dataProfileInfo.user.c_str(),
1120 dataProfileInfo.password.c_str(),
1121 std::to_string((int) dataProfileInfo.authType).c_str(),
1122 dataProfileInfo.protocol.c_str(),
1123 dataProfileInfo.roamingProtocol.c_str(),
1124 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1125 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1126 modemCognitive ? "1" : "0",
1127 std::to_string(dataProfileInfo.mtu).c_str(),
1129 dataProfileInfo.mvnoMatchData.c_str(),
1130 roamingAllowed ? "1" : "0");
1132 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1133 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1134 RIL_REQUEST_SETUP_DATA_CALL);
1136 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1142 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1144 RLOGD("iccIOForApp: serial %d", serial);
1146 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1151 RIL_SIM_IO_v6 rilIccIo = {};
1152 rilIccIo.command = iccIo.command;
1153 rilIccIo.fileid = iccIo.fileId;
1154 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1158 rilIccIo.p1 = iccIo.p1;
1159 rilIccIo.p2 = iccIo.p2;
1160 rilIccIo.p3 = iccIo.p3;
1162 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1163 memsetAndFreeStrings(1, rilIccIo.path);
1167 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1168 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1172 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1173 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1177 CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1179 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1184 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1186 RLOGD("sendUssd: serial %d", serial);
1188 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1192 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1194 RLOGD("cancelPendingUssd: serial %d", serial);
1196 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1200 Return<void> RadioImpl::getClir(int32_t serial) {
1202 RLOGD("getClir: serial %d", serial);
1204 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1208 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1210 RLOGD("setClir: serial %d", serial);
1212 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1216 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1218 RLOGD("getCallForwardStatus: serial %d", serial);
1220 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1225 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1227 RLOGD("setCallForward: serial %d", serial);
1229 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1234 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1236 RLOGD("getCallWaiting: serial %d", serial);
1238 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1242 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1244 RLOGD("setCallWaiting: serial %d", serial);
1246 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1251 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1252 bool success, SmsAcknowledgeFailCause cause) {
1254 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1256 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1261 Return<void> RadioImpl::acceptCall(int32_t serial) {
1263 RLOGD("acceptCall: serial %d", serial);
1265 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1269 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1270 int32_t cid, bool reasonRadioShutDown) {
1272 RLOGD("deactivateDataCall: serial %d", serial);
1274 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, false,
1275 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1279 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1280 const hidl_string& password, int32_t serviceClass,
1281 const hidl_string& appId) {
1283 RLOGD("getFacilityLockForApp: serial %d", serial);
1285 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK, true,
1286 4, facility.c_str(), password.c_str(),
1287 (std::to_string(serviceClass)).c_str(), appId.c_str());
1291 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1292 bool lockState, const hidl_string& password,
1293 int32_t serviceClass, const hidl_string& appId) {
1295 RLOGD("setFacilityLockForApp: serial %d", serial);
1297 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK, true,
1298 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1299 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1303 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1304 const hidl_string& oldPassword,
1305 const hidl_string& newPassword) {
1307 RLOGD("setBarringPassword: serial %d", serial);
1309 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD, true,
1310 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1314 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1316 RLOGD("getNetworkSelectionMode: serial %d", serial);
1318 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1322 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1324 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1326 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1330 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1331 const hidl_string& operatorNumeric) {
1333 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1335 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1336 operatorNumeric.c_str());
1340 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1342 RLOGD("getAvailableNetworks: serial %d", serial);
1344 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1348 Return<void> RadioImpl::startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request) {
1350 RLOGD("startNetworkScan: serial %d", serial);
1353 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1358 if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
1359 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1363 RIL_NetworkScanRequest scan_request = {};
1365 scan_request.type = (RIL_ScanType) request.type;
1366 scan_request.interval = request.interval;
1367 scan_request.specifiers_length = request.specifiers.size();
1368 for (size_t i = 0; i < request.specifiers.size(); ++i) {
1369 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
1370 request.specifiers[i].utranBands.size() > MAX_BANDS ||
1371 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
1372 request.specifiers[i].channels.size() > MAX_CHANNELS) {
1373 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1376 const V1_1::RadioAccessSpecifier& ras_from =
1377 request.specifiers[i];
1378 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
1380 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
1381 ras_to.channels_length = ras_from.channels.size();
1383 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
1384 const std::vector<uint32_t> * bands = nullptr;
1385 switch (request.specifiers[i].radioAccessNetwork) {
1386 case V1_1::RadioAccessNetworks::GERAN:
1387 ras_to.bands_length = ras_from.geranBands.size();
1388 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
1390 case V1_1::RadioAccessNetworks::UTRAN:
1391 ras_to.bands_length = ras_from.utranBands.size();
1392 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
1394 case V1_1::RadioAccessNetworks::EUTRAN:
1395 ras_to.bands_length = ras_from.eutranBands.size();
1396 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
1399 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1402 // safe to copy to geran_bands because it's a union member
1403 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
1404 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
1408 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
1414 Return<void> RadioImpl::stopNetworkScan(int32_t serial) {
1416 RLOGD("stopNetworkScan: serial %d", serial);
1418 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1422 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1424 RLOGD("startDtmf: serial %d", serial);
1426 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1431 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1433 RLOGD("stopDtmf: serial %d", serial);
1435 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1439 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1441 RLOGD("getBasebandVersion: serial %d", serial);
1443 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1447 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1449 RLOGD("separateConnection: serial %d", serial);
1451 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1455 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1457 RLOGD("setMute: serial %d", serial);
1459 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1463 Return<void> RadioImpl::getMute(int32_t serial) {
1465 RLOGD("getMute: serial %d", serial);
1467 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1471 Return<void> RadioImpl::getClip(int32_t serial) {
1473 RLOGD("getClip: serial %d", serial);
1475 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1479 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1481 RLOGD("getDataCallList: serial %d", serial);
1483 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1487 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1489 RLOGD("setSuppServiceNotifications: serial %d", serial);
1491 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1492 BOOL_TO_INT(enable));
1496 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1498 RLOGD("writeSmsToSim: serial %d", serial);
1500 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1505 RIL_SMS_WriteArgs args;
1506 args.status = (int) smsWriteArgs.status;
1508 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1512 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1513 memsetAndFreeStrings(1, args.pdu);
1517 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
1519 memsetAndFreeStrings(2, args.smsc, args.pdu);
1524 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1526 RLOGD("deleteSmsOnSim: serial %d", serial);
1528 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1532 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1534 RLOGD("setBandMode: serial %d", serial);
1536 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1540 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1542 RLOGD("getAvailableBandModes: serial %d", serial);
1544 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1548 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1550 RLOGD("sendEnvelope: serial %d", serial);
1552 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1557 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1558 const hidl_string& commandResponse) {
1560 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1562 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1563 commandResponse.c_str());
1567 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1569 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1571 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1572 1, BOOL_TO_INT(accept));
1576 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1578 RLOGD("explicitCallTransfer: serial %d", serial);
1580 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1584 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1586 RLOGD("setPreferredNetworkType: serial %d", serial);
1588 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1592 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1594 RLOGD("getPreferredNetworkType: serial %d", serial);
1596 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1600 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1602 RLOGD("getNeighboringCids: serial %d", serial);
1604 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1608 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1610 RLOGD("setLocationUpdates: serial %d", serial);
1612 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1616 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1618 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1620 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1624 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1626 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1628 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1632 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1634 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1636 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1640 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1642 RLOGD("setTTYMode: serial %d", serial);
1644 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1648 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1650 RLOGD("getTTYMode: serial %d", serial);
1652 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1656 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1658 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1660 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1661 1, BOOL_TO_INT(enable));
1665 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1667 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1669 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1673 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1675 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1677 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1678 featureCode.c_str());
1682 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1685 RLOGD("sendBurstDtmf: serial %d", serial);
1687 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF, false,
1688 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1689 (std::to_string(off)).c_str());
1693 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1694 rcsm.uTeleserviceID = sms.teleserviceId;
1695 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1696 rcsm.uServicecategory = sms.serviceCategory;
1697 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1698 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1699 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1700 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1702 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1703 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1704 for (int i = 0; i < digitLimit; i++) {
1705 rcsm.sAddress.digits[i] = sms.address.digits[i];
1708 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1709 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1711 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1712 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1713 for (int i = 0; i < digitLimit; i++) {
1714 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1717 rcsm.uBearerDataLen = sms.bearerData.size();
1718 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1719 for (int i = 0; i < digitLimit; i++) {
1720 rcsm.aBearerData[i] = sms.bearerData[i];
1724 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1726 RLOGD("sendCdmaSms: serial %d", serial);
1728 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1733 RIL_CDMA_SMS_Message rcsm = {};
1734 constructCdmaSms(rcsm, sms);
1736 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
1740 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1742 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1744 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1749 RIL_CDMA_SMS_Ack rcsa = {};
1751 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1752 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1754 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
1758 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1760 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1762 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1766 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1767 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1770 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1772 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1773 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1778 int num = configInfo.size();
1779 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1780 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1782 for (int i = 0 ; i < num ; i++ ) {
1783 gsmBciPtrs[i] = &gsmBci[i];
1784 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1785 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1786 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1787 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1788 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1791 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs,
1792 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
1796 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1798 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1800 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1801 1, BOOL_TO_INT(!activate));
1805 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1807 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1809 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1813 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1814 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1817 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1819 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1820 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1825 int num = configInfo.size();
1826 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1827 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1829 for (int i = 0 ; i < num ; i++ ) {
1830 cdmaBciPtrs[i] = &cdmaBci[i];
1831 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1832 cdmaBci[i].language = configInfo[i].language;
1833 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1836 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs,
1837 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
1841 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1843 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1845 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1846 1, BOOL_TO_INT(!activate));
1850 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1852 RLOGD("getCDMASubscription: serial %d", serial);
1854 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1858 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1860 RLOGD("writeSmsToRuim: serial %d", serial);
1862 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1863 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1868 RIL_CDMA_SMS_WriteArgs rcsw = {};
1869 rcsw.status = (int) cdmaSms.status;
1870 constructCdmaSms(rcsw.message, cdmaSms.message);
1872 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
1876 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1878 RLOGD("deleteSmsOnRuim: serial %d", serial);
1880 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1884 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1886 RLOGD("getDeviceIdentity: serial %d", serial);
1888 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1892 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1894 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1896 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1900 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1902 RLOGD("getSmscAddress: serial %d", serial);
1904 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1908 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1910 RLOGD("setSmscAddress: serial %d", serial);
1912 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1917 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1919 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1921 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1922 BOOL_TO_INT(available));
1926 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1928 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1930 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1934 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1936 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1938 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1942 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1944 RLOGD("requestIsimAuthentication: serial %d", serial);
1946 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1951 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1952 const hidl_string& ackPdu) {
1954 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1956 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, false,
1957 2, success ? "1" : "0", ackPdu.c_str());
1961 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1963 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1965 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1970 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1972 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1974 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1978 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1980 RLOGD("getCellInfoList: serial %d", serial);
1982 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1986 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1988 RLOGD("setCellInfoListRate: serial %d", serial);
1990 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1994 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1995 bool modemCognitive, bool isRoaming) {
1997 RLOGD("setInitialAttachApn: serial %d", serial);
1999 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2000 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
2005 if (s_vendorFunctions->version <= 14) {
2006 RIL_InitialAttachApn iaa = {};
2008 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2012 const hidl_string &protocol =
2013 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
2015 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
2016 memsetAndFreeStrings(1, iaa.apn);
2019 iaa.authtype = (int) dataProfileInfo.authType;
2020 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2021 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2024 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2025 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
2029 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2031 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
2033 RIL_InitialAttachApn_v15 iaa = {};
2035 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2039 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
2040 memsetAndFreeStrings(1, iaa.apn);
2043 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
2044 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2047 iaa.authtype = (int) dataProfileInfo.authType;
2048 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2049 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
2052 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2053 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
2056 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
2057 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
2058 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
2059 iaa.mtu = dataProfileInfo.mtu;
2061 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
2062 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2063 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2068 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
2069 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2074 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2076 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2077 iaa.password, iaa.mvnoMatchData);
2083 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
2085 RLOGD("getImsRegistrationState: serial %d", serial);
2087 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2091 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2092 RIL_IMS_SMS_Message rism = {};
2094 int countStrings = 2;
2095 int dataLen = sizeof(char *) * countStrings;
2097 rism.tech = RADIO_TECH_3GPP;
2098 rism.retry = BOOL_TO_INT(message.retry);
2099 rism.messageRef = message.messageRef;
2101 if (message.gsmMessage.size() != 1) {
2102 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2103 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2107 pStrings = (char **)calloc(countStrings, sizeof(char *));
2108 if (pStrings == NULL) {
2109 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2110 requestToString(pRI->pCI->requestNumber));
2111 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2115 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2117 memset(pStrings, 0, dataLen);
2123 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2124 memsetAndFreeStrings(1, pStrings[0]);
2126 memset(pStrings, 0, dataLen);
2132 rism.message.gsmMessage = pStrings;
2133 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2134 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2136 for (int i = 0 ; i < countStrings ; i++) {
2137 memsetAndFreeStrings(1, pStrings[i]);
2141 memset(pStrings, 0, dataLen);
2149 RIL_IMS_SMS_Message imsSms;
2150 RIL_CDMA_SMS_Message cdmaSms;
2153 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2154 ImsCdmaSms temp = {};
2156 if (message.cdmaMessage.size() != 1) {
2157 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2158 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2162 temp.imsSms.tech = RADIO_TECH_3GPP2;
2163 temp.imsSms.retry = BOOL_TO_INT(message.retry);
2164 temp.imsSms.messageRef = message.messageRef;
2165 temp.imsSms.message.cdmaMessage = &temp.cdmaSms;
2167 constructCdmaSms(temp.cdmaSms, message.cdmaMessage[0]);
2169 // Vendor code expects payload length to include actual msg payload
2170 // (sizeof(RIL_CDMA_SMS_Message)) instead of (RIL_CDMA_SMS_Message *) + size of other fields in
2171 // RIL_IMS_SMS_Message
2172 int payloadLen = sizeof(RIL_RadioTechnologyFamily) + sizeof(uint8_t) + sizeof(int32_t)
2173 + sizeof(RIL_CDMA_SMS_Message);
2175 CALL_ONREQUEST(pRI->pCI->requestNumber, &temp.imsSms, payloadLen, pRI, pRI->socket_id);
2180 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2182 RLOGD("sendImsSms: serial %d", serial);
2184 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2189 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2191 if (RADIO_TECH_3GPP == format) {
2192 dispatchImsGsmSms(message, pRI);
2193 } else if (RADIO_TECH_3GPP2 == format) {
2194 dispatchImsCdmaSms(message, pRI);
2196 RLOGE("sendImsSms: Invalid radio tech %s",
2197 requestToString(pRI->pCI->requestNumber));
2198 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2203 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2205 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2207 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2211 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2213 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2215 if (s_vendorFunctions->version < 15) {
2216 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2218 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2223 RIL_OpenChannelParams params = {};
2227 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2231 CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId);
2233 memsetAndFreeStrings(1, params.aidPtr);
2238 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2240 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2242 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2246 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2248 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2250 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2254 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2256 RLOGD("nvReadItem: serial %d", serial);
2258 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2263 RIL_NV_ReadItem nvri = {};
2264 nvri.itemID = (RIL_NV_Item) itemId;
2266 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2270 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2272 RLOGD("nvWriteItem: serial %d", serial);
2274 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2279 RIL_NV_WriteItem nvwi = {};
2281 nvwi.itemID = (RIL_NV_Item) item.itemId;
2283 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2287 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2289 memsetAndFreeStrings(1, nvwi.value);
2293 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2295 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2297 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2301 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2302 int rilResetType = -1;
2304 RLOGD("nvResetConfig: serial %d", serial);
2306 /* Convert ResetNvType to RIL.h values
2307 * RIL_REQUEST_NV_RESET_CONFIG
2308 * 1 - reload all NV items
2309 * 2 - erase NV reset (SCRTN)
2310 * 3 - factory reset (RTN)
2313 case ResetNvType::RELOAD:
2316 case ResetNvType::ERASE:
2319 case ResetNvType::FACTORY_RESET:
2323 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2327 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2329 RLOGD("setUiccSubscription: serial %d", serial);
2331 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2332 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2337 RIL_SelectUiccSub rilUiccSub = {};
2339 rilUiccSub.slot = uiccSub.slot;
2340 rilUiccSub.app_index = uiccSub.appIndex;
2341 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2342 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2344 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2348 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2350 RLOGD("setDataAllowed: serial %d", serial);
2352 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2356 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2358 RLOGD("getHardwareConfig: serial %d", serial);
2360 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2364 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2365 const hidl_string& authData, const hidl_string& aid) {
2367 RLOGD("requestIccSimAuthentication: serial %d", serial);
2369 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2374 RIL_SimAuthentication pf = {};
2376 pf.authContext = authContext;
2378 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2382 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2383 memsetAndFreeStrings(1, pf.authData);
2387 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2389 memsetAndFreeStrings(2, pf.authData, pf.aid);
2394 * @param numProfiles number of data profile
2395 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2396 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2397 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2398 * @param numfields number of string-type member in the data profile structure
2399 * @param ... the variadic parameters are pointers to each string-type member
2401 template <typename T>
2402 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2403 int numfields, ...) {
2405 va_start(args, numfields);
2407 // Iterate through each string-type field that need to be free.
2408 for (int i = 0; i < numfields; i++) {
2409 // Iterate through each data profile and free that specific string-type field.
2410 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2411 char *T::*ptr = va_arg(args, char *T::*);
2412 for (int j = 0; j < numProfiles; j++) {
2413 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2420 memset(dataProfiles, 0, numProfiles * sizeof(T));
2421 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2424 free(dataProfilePtrs);
2427 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2430 RLOGD("setDataProfile: serial %d", serial);
2432 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2437 size_t num = profiles.size();
2438 bool success = false;
2440 if (s_vendorFunctions->version <= 14) {
2442 RIL_DataProfileInfo *dataProfiles =
2443 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2445 if (dataProfiles == NULL) {
2446 RLOGE("Memory allocation failed for request %s",
2447 requestToString(pRI->pCI->requestNumber));
2448 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2452 RIL_DataProfileInfo **dataProfilePtrs =
2453 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2454 if (dataProfilePtrs == NULL) {
2455 RLOGE("Memory allocation failed for request %s",
2456 requestToString(pRI->pCI->requestNumber));
2458 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2462 for (size_t i = 0; i < num; i++) {
2463 dataProfilePtrs[i] = &dataProfiles[i];
2465 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2467 const hidl_string &protocol =
2468 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2470 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI, true)) {
2474 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2478 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2484 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2485 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2486 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2490 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2491 dataProfiles[i].authType = (int) profiles[i].authType;
2492 dataProfiles[i].type = (int) profiles[i].type;
2493 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2494 dataProfiles[i].maxConns = profiles[i].maxConns;
2495 dataProfiles[i].waitTime = profiles[i].waitTime;
2496 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2499 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2500 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2502 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2503 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2504 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2506 RIL_DataProfileInfo_v15 *dataProfiles =
2507 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2509 if (dataProfiles == NULL) {
2510 RLOGE("Memory allocation failed for request %s",
2511 requestToString(pRI->pCI->requestNumber));
2512 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2516 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2517 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2518 if (dataProfilePtrs == NULL) {
2519 RLOGE("Memory allocation failed for request %s",
2520 requestToString(pRI->pCI->requestNumber));
2522 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2526 for (size_t i = 0; i < num; i++) {
2527 dataProfilePtrs[i] = &dataProfiles[i];
2529 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2530 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2534 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2535 profiles[i].roamingProtocol, pRI, true)) {
2538 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2542 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2546 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2547 profiles[i].mvnoMatchData, pRI, true)) {
2551 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2552 dataProfiles[i].mvnoType)) {
2553 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2558 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2559 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2560 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2561 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2565 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2566 dataProfiles[i].authType = (int) profiles[i].authType;
2567 dataProfiles[i].type = (int) profiles[i].type;
2568 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2569 dataProfiles[i].maxConns = profiles[i].maxConns;
2570 dataProfiles[i].waitTime = profiles[i].waitTime;
2571 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2572 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2573 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2574 dataProfiles[i].mtu = profiles[i].mtu;
2577 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2578 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
2580 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2581 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2582 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2583 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2589 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2591 RLOGD("requestShutdown: serial %d", serial);
2593 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2597 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2599 RLOGD("getRadioCapability: serial %d", serial);
2601 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2605 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2607 RLOGD("setRadioCapability: serial %d", serial);
2609 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2614 RIL_RadioCapability rilRc = {};
2616 // TODO : set rilRc.version using HIDL version ?
2617 rilRc.session = rc.session;
2618 rilRc.phase = (int) rc.phase;
2619 rilRc.rat = (int) rc.raf;
2620 rilRc.status = (int) rc.status;
2621 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2623 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
2628 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2630 RLOGD("startLceService: serial %d", serial);
2632 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2633 BOOL_TO_INT(pullMode));
2637 Return<void> RadioImpl::stopLceService(int32_t serial) {
2639 RLOGD("stopLceService: serial %d", serial);
2641 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2645 Return<void> RadioImpl::pullLceData(int32_t serial) {
2647 RLOGD("pullLceData: serial %d", serial);
2649 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2653 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2655 RLOGD("getModemActivityInfo: serial %d", serial);
2657 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2661 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2662 const CarrierRestrictions& carriers) {
2664 RLOGD("setAllowedCarriers: serial %d", serial);
2666 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2667 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2672 RIL_CarrierRestrictions cr = {};
2673 RIL_Carrier *allowedCarriers = NULL;
2674 RIL_Carrier *excludedCarriers = NULL;
2676 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2677 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2678 if (allowedCarriers == NULL) {
2679 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2680 requestToString(pRI->pCI->requestNumber));
2681 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2684 cr.allowed_carriers = allowedCarriers;
2686 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2687 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2688 if (excludedCarriers == NULL) {
2689 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2690 requestToString(pRI->pCI->requestNumber));
2691 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2693 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2695 free(allowedCarriers);
2698 cr.excluded_carriers = excludedCarriers;
2700 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2701 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2702 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2703 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2704 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2707 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2708 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2709 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2710 excludedCarriers[i].match_type =
2711 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2712 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2715 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
2718 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2719 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2721 free(allowedCarriers);
2722 free(excludedCarriers);
2726 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2728 RLOGD("getAllowedCarriers: serial %d", serial);
2730 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2734 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2737 RLOGD("sendDeviceState: serial %d", serial);
2739 if (s_vendorFunctions->version < 15) {
2740 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2741 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2742 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2744 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2745 RIL_REQUEST_SEND_DEVICE_STATE);
2746 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2750 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2751 BOOL_TO_INT(state));
2755 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2757 RLOGD("setIndicationFilter: serial %d", serial);
2759 if (s_vendorFunctions->version < 15) {
2760 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2761 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2762 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2765 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2769 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2771 RLOGD("setSimCardPower: serial %d", serial);
2773 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2777 Return<void> RadioImpl::setSimCardPower_1_1(int32_t serial, const V1_1::CardPowerState state) {
2779 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
2781 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
2785 Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial,
2786 const V1_1::ImsiEncryptionInfo& data) {
2788 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
2790 RequestInfo *pRI = android::addRequestToList(
2791 serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
2796 RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
2798 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
2801 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
2802 memsetAndFreeStrings(1, imsiEncryption.mnc);
2805 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
2806 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
2809 int32_t lSize = data.carrierKey.size();
2810 imsiEncryption.carrierKey = new uint8_t[lSize];
2811 memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), lSize);
2812 imsiEncryption.expirationTime = data.expirationTime;
2813 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
2814 sizeof(RIL_CarrierInfoForImsiEncryption), pRI, mSlotId);
2815 delete(imsiEncryption.carrierKey);
2819 Return<void> RadioImpl::startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive) {
2821 RLOGD("%s(): %d", __FUNCTION__, serial);
2823 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_KEEPALIVE);
2828 RIL_KeepaliveRequest kaReq = {};
2830 kaReq.type = static_cast<RIL_KeepaliveType>(keepalive.type);
2831 switch(kaReq.type) {
2833 if (keepalive.sourceAddress.size() != 4 ||
2834 keepalive.destinationAddress.size() != 4) {
2835 RLOGE("Invalid address for keepalive!");
2836 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2841 if (keepalive.sourceAddress.size() != 16 ||
2842 keepalive.destinationAddress.size() != 16) {
2843 RLOGE("Invalid address for keepalive!");
2844 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2849 RLOGE("Unknown packet keepalive type!");
2850 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2854 ::memcpy(kaReq.sourceAddress, keepalive.sourceAddress.data(), keepalive.sourceAddress.size());
2855 kaReq.sourcePort = keepalive.sourcePort;
2857 ::memcpy(kaReq.destinationAddress,
2858 keepalive.destinationAddress.data(), keepalive.destinationAddress.size());
2859 kaReq.destinationPort = keepalive.destinationPort;
2861 kaReq.maxKeepaliveIntervalMillis = keepalive.maxKeepaliveIntervalMillis;
2862 kaReq.cid = keepalive.cid; // This is the context ID of the data call
2864 CALL_ONREQUEST(pRI->pCI->requestNumber, &kaReq, sizeof(RIL_KeepaliveRequest), pRI, mSlotId);
2868 Return<void> RadioImpl::stopKeepalive(int32_t serial, int32_t sessionHandle) {
2870 RLOGD("%s(): %d", __FUNCTION__, serial);
2872 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_STOP_KEEPALIVE);
2877 CALL_ONREQUEST(pRI->pCI->requestNumber, &sessionHandle, sizeof(uint32_t), pRI, mSlotId);
2881 Return<void> RadioImpl::responseAcknowledgement() {
2882 android::releaseWakeLock();
2886 Return<void> OemHookImpl::setResponseFunctions(
2887 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2888 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2890 RLOGD("OemHookImpl::setResponseFunctions");
2893 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2894 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2897 mOemHookResponse = oemHookResponseParam;
2898 mOemHookIndication = oemHookIndicationParam;
2899 mCounterOemHook[mSlotId]++;
2901 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2907 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2909 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2911 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2915 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2916 const hidl_vec<hidl_string>& data) {
2918 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2920 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2924 /***************************************************************************************************
2925 * RESPONSE FUNCTIONS
2926 * Functions above are used for requests going from framework to vendor code. The ones below are
2927 * responses for those requests coming back from the vendor code.
2928 **************************************************************************************************/
2930 void radio::acknowledgeRequest(int slotId, int serial) {
2931 if (radioService[slotId]->mRadioResponse != NULL) {
2932 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2933 radioService[slotId]->checkReturnStatus(retStatus);
2935 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2939 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2941 responseInfo.serial = serial;
2942 switch (responseType) {
2943 case RESPONSE_SOLICITED:
2944 responseInfo.type = RadioResponseType::SOLICITED;
2946 case RESPONSE_SOLICITED_ACK_EXP:
2947 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2950 responseInfo.error = (RadioError) e;
2953 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2954 void *response, size_t responseLen) {
2955 populateResponseInfo(responseInfo, serial, responseType, e);
2958 if (response == NULL && responseLen == 0) {
2959 // Earlier RILs did not send a response for some cases although the interface
2960 // expected an integer as response. Do not return error if response is empty. Instead
2961 // Return -1 in those cases to maintain backward compatibility.
2962 } else if (response == NULL || responseLen != sizeof(int)) {
2963 RLOGE("responseIntOrEmpty: Invalid response");
2964 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2966 int *p_int = (int *) response;
2972 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2973 void *response, size_t responseLen) {
2974 populateResponseInfo(responseInfo, serial, responseType, e);
2977 if (response == NULL || responseLen != sizeof(int)) {
2978 RLOGE("responseInt: Invalid response");
2979 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2981 int *p_int = (int *) response;
2987 int radio::getIccCardStatusResponse(int slotId,
2988 int responseType, int serial, RIL_Errno e,
2989 void *response, size_t responseLen) {
2990 if (radioService[slotId]->mRadioResponse != NULL) {
2991 RadioResponseInfo responseInfo = {};
2992 populateResponseInfo(responseInfo, serial, responseType, e);
2993 CardStatus cardStatus = {};
2994 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2995 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)
2996 || p_cur->gsm_umts_subscription_app_index >= p_cur->num_applications
2997 || p_cur->cdma_subscription_app_index >= p_cur->num_applications
2998 || p_cur->ims_subscription_app_index >= p_cur->num_applications) {
2999 RLOGE("getIccCardStatusResponse: Invalid response");
3000 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3002 cardStatus.cardState = (CardState) p_cur->card_state;
3003 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
3004 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
3005 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
3006 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
3008 RIL_AppStatus *rilAppStatus = p_cur->applications;
3009 cardStatus.applications.resize(p_cur->num_applications);
3010 AppStatus *appStatus = cardStatus.applications.data();
3012 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
3014 for (int i = 0; i < p_cur->num_applications; i++) {
3015 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
3016 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
3017 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
3018 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
3019 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
3020 rilAppStatus[i].app_label_ptr);
3021 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
3022 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
3023 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
3027 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3028 getIccCardStatusResponse(responseInfo, cardStatus);
3029 radioService[slotId]->checkReturnStatus(retStatus);
3031 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3037 int radio::supplyIccPinForAppResponse(int slotId,
3038 int responseType, int serial, RIL_Errno e,
3039 void *response, size_t responseLen) {
3041 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
3044 if (radioService[slotId]->mRadioResponse != NULL) {
3045 RadioResponseInfo responseInfo = {};
3046 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3047 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3048 supplyIccPinForAppResponse(responseInfo, ret);
3049 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
3050 radioService[slotId]->checkReturnStatus(retStatus);
3052 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3059 int radio::supplyIccPukForAppResponse(int slotId,
3060 int responseType, int serial, RIL_Errno e,
3061 void *response, size_t responseLen) {
3063 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
3066 if (radioService[slotId]->mRadioResponse != NULL) {
3067 RadioResponseInfo responseInfo = {};
3068 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3069 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
3071 radioService[slotId]->checkReturnStatus(retStatus);
3073 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
3080 int radio::supplyIccPin2ForAppResponse(int slotId,
3081 int responseType, int serial, RIL_Errno e,
3082 void *response, size_t responseLen) {
3084 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
3087 if (radioService[slotId]->mRadioResponse != NULL) {
3088 RadioResponseInfo responseInfo = {};
3089 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3090 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3091 supplyIccPin2ForAppResponse(responseInfo, ret);
3092 radioService[slotId]->checkReturnStatus(retStatus);
3094 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3101 int radio::supplyIccPuk2ForAppResponse(int slotId,
3102 int responseType, int serial, RIL_Errno e,
3103 void *response, size_t responseLen) {
3105 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
3108 if (radioService[slotId]->mRadioResponse != NULL) {
3109 RadioResponseInfo responseInfo = {};
3110 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3111 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3112 supplyIccPuk2ForAppResponse(responseInfo, ret);
3113 radioService[slotId]->checkReturnStatus(retStatus);
3115 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3122 int radio::changeIccPinForAppResponse(int slotId,
3123 int responseType, int serial, RIL_Errno e,
3124 void *response, size_t responseLen) {
3126 RLOGD("changeIccPinForAppResponse: serial %d", serial);
3129 if (radioService[slotId]->mRadioResponse != NULL) {
3130 RadioResponseInfo responseInfo = {};
3131 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3132 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3133 changeIccPinForAppResponse(responseInfo, ret);
3134 radioService[slotId]->checkReturnStatus(retStatus);
3136 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3143 int radio::changeIccPin2ForAppResponse(int slotId,
3144 int responseType, int serial, RIL_Errno e,
3145 void *response, size_t responseLen) {
3147 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
3150 if (radioService[slotId]->mRadioResponse != NULL) {
3151 RadioResponseInfo responseInfo = {};
3152 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3153 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3154 changeIccPin2ForAppResponse(responseInfo, ret);
3155 radioService[slotId]->checkReturnStatus(retStatus);
3157 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3164 int radio::supplyNetworkDepersonalizationResponse(int slotId,
3165 int responseType, int serial, RIL_Errno e,
3166 void *response, size_t responseLen) {
3168 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
3171 if (radioService[slotId]->mRadioResponse != NULL) {
3172 RadioResponseInfo responseInfo = {};
3173 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3174 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3175 supplyNetworkDepersonalizationResponse(responseInfo, ret);
3176 radioService[slotId]->checkReturnStatus(retStatus);
3178 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
3185 int radio::getCurrentCallsResponse(int slotId,
3186 int responseType, int serial, RIL_Errno e,
3187 void *response, size_t responseLen) {
3189 RLOGD("getCurrentCallsResponse: serial %d", serial);
3192 if (radioService[slotId]->mRadioResponse != NULL) {
3193 RadioResponseInfo responseInfo = {};
3194 populateResponseInfo(responseInfo, serial, responseType, e);
3196 hidl_vec<Call> calls;
3197 if ((response == NULL && responseLen != 0)
3198 || (responseLen % sizeof(RIL_Call *)) != 0) {
3199 RLOGE("getCurrentCallsResponse: Invalid response");
3200 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3202 int num = responseLen / sizeof(RIL_Call *);
3205 for (int i = 0 ; i < num ; i++) {
3206 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3207 /* each call info */
3208 calls[i].state = (CallState) p_cur->state;
3209 calls[i].index = p_cur->index;
3210 calls[i].toa = p_cur->toa;
3211 calls[i].isMpty = p_cur->isMpty;
3212 calls[i].isMT = p_cur->isMT;
3213 calls[i].als = p_cur->als;
3214 calls[i].isVoice = p_cur->isVoice;
3215 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3216 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3217 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3218 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3219 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3220 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3221 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3222 calls[i].uusInfo.resize(1);
3223 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3224 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3225 // convert uusInfo->uusData to a null-terminated string
3226 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3227 calls[i].uusInfo[0].uusData = nullTermStr;
3233 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3234 getCurrentCallsResponse(responseInfo, calls);
3235 radioService[slotId]->checkReturnStatus(retStatus);
3237 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3243 int radio::dialResponse(int slotId,
3244 int responseType, int serial, RIL_Errno e, void *response,
3245 size_t responseLen) {
3247 RLOGD("dialResponse: serial %d", serial);
3250 if (radioService[slotId]->mRadioResponse != NULL) {
3251 RadioResponseInfo responseInfo = {};
3252 populateResponseInfo(responseInfo, serial, responseType, e);
3253 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3254 radioService[slotId]->checkReturnStatus(retStatus);
3256 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3262 int radio::getIMSIForAppResponse(int slotId,
3263 int responseType, int serial, RIL_Errno e, void *response,
3264 size_t responseLen) {
3266 RLOGD("getIMSIForAppResponse: serial %d", serial);
3269 if (radioService[slotId]->mRadioResponse != NULL) {
3270 RadioResponseInfo responseInfo = {};
3271 populateResponseInfo(responseInfo, serial, responseType, e);
3272 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3273 responseInfo, convertCharPtrToHidlString((char *) response));
3274 radioService[slotId]->checkReturnStatus(retStatus);
3276 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3283 int radio::hangupConnectionResponse(int slotId,
3284 int responseType, int serial, RIL_Errno e,
3285 void *response, size_t responseLen) {
3287 RLOGD("hangupConnectionResponse: serial %d", serial);
3290 if (radioService[slotId]->mRadioResponse != NULL) {
3291 RadioResponseInfo responseInfo = {};
3292 populateResponseInfo(responseInfo, serial, responseType, e);
3293 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3295 radioService[slotId]->checkReturnStatus(retStatus);
3297 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3304 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3305 int responseType, int serial, RIL_Errno e,
3306 void *response, size_t responseLen) {
3308 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3311 if (radioService[slotId]->mRadioResponse != NULL) {
3312 RadioResponseInfo responseInfo = {};
3313 populateResponseInfo(responseInfo, serial, responseType, e);
3314 Return<void> retStatus =
3315 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3317 radioService[slotId]->checkReturnStatus(retStatus);
3319 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3326 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3327 RIL_Errno e, void *response,
3328 size_t responseLen) {
3330 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3333 if (radioService[slotId]->mRadioResponse != NULL) {
3334 RadioResponseInfo responseInfo = {};
3335 populateResponseInfo(responseInfo, serial, responseType, e);
3336 Return<void> retStatus =
3337 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3339 radioService[slotId]->checkReturnStatus(retStatus);
3341 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3348 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3349 RIL_Errno e, void *response,
3350 size_t responseLen) {
3352 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3355 if (radioService[slotId]->mRadioResponse != NULL) {
3356 RadioResponseInfo responseInfo = {};
3357 populateResponseInfo(responseInfo, serial, responseType, e);
3358 Return<void> retStatus =
3359 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3361 radioService[slotId]->checkReturnStatus(retStatus);
3363 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3370 int radio::conferenceResponse(int slotId, int responseType,
3371 int serial, RIL_Errno e, void *response, size_t responseLen) {
3373 RLOGD("conferenceResponse: serial %d", serial);
3376 if (radioService[slotId]->mRadioResponse != NULL) {
3377 RadioResponseInfo responseInfo = {};
3378 populateResponseInfo(responseInfo, serial, responseType, e);
3379 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3381 radioService[slotId]->checkReturnStatus(retStatus);
3383 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3390 int radio::rejectCallResponse(int slotId, int responseType,
3391 int serial, RIL_Errno e, void *response, size_t responseLen) {
3393 RLOGD("rejectCallResponse: serial %d", serial);
3396 if (radioService[slotId]->mRadioResponse != NULL) {
3397 RadioResponseInfo responseInfo = {};
3398 populateResponseInfo(responseInfo, serial, responseType, e);
3399 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3401 radioService[slotId]->checkReturnStatus(retStatus);
3403 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3410 int radio::getLastCallFailCauseResponse(int slotId,
3411 int responseType, int serial, RIL_Errno e, void *response,
3412 size_t responseLen) {
3414 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3417 if (radioService[slotId]->mRadioResponse != NULL) {
3418 RadioResponseInfo responseInfo = {};
3419 populateResponseInfo(responseInfo, serial, responseType, e);
3421 LastCallFailCauseInfo info = {};
3422 info.vendorCause = hidl_string();
3423 if (response == NULL) {
3424 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3425 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3426 } else if (responseLen == sizeof(int)) {
3427 int *pInt = (int *) response;
3428 info.causeCode = (LastCallFailCause) pInt[0];
3429 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3430 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3431 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3432 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3434 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3435 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3438 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3439 responseInfo, info);
3440 radioService[slotId]->checkReturnStatus(retStatus);
3442 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3449 int radio::getSignalStrengthResponse(int slotId,
3450 int responseType, int serial, RIL_Errno e,
3451 void *response, size_t responseLen) {
3453 RLOGD("getSignalStrengthResponse: serial %d", serial);
3456 if (radioService[slotId]->mRadioResponse != NULL) {
3457 RadioResponseInfo responseInfo = {};
3458 populateResponseInfo(responseInfo, serial, responseType, e);
3459 SignalStrength signalStrength = {};
3460 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3461 RLOGE("getSignalStrengthResponse: Invalid response");
3462 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3464 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3467 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3468 responseInfo, signalStrength);
3469 radioService[slotId]->checkReturnStatus(retStatus);
3471 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3478 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3480 return RIL_CELL_INFO_TYPE_NONE;
3483 int radioTech = atoi(rat);
3487 case RADIO_TECH_GPRS:
3488 case RADIO_TECH_EDGE:
3489 case RADIO_TECH_GSM: {
3490 return RIL_CELL_INFO_TYPE_GSM;
3493 case RADIO_TECH_UMTS:
3494 case RADIO_TECH_HSDPA:
3495 case RADIO_TECH_HSUPA:
3496 case RADIO_TECH_HSPA:
3497 case RADIO_TECH_HSPAP: {
3498 return RIL_CELL_INFO_TYPE_WCDMA;
3501 case RADIO_TECH_IS95A:
3502 case RADIO_TECH_IS95B:
3503 case RADIO_TECH_1xRTT:
3504 case RADIO_TECH_EVDO_0:
3505 case RADIO_TECH_EVDO_A:
3506 case RADIO_TECH_EVDO_B:
3507 case RADIO_TECH_EHRPD: {
3508 return RIL_CELL_INFO_TYPE_CDMA;
3511 case RADIO_TECH_LTE:
3512 case RADIO_TECH_LTE_CA: {
3513 return RIL_CELL_INFO_TYPE_LTE;
3516 case RADIO_TECH_TD_SCDMA: {
3517 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3525 return RIL_CELL_INFO_TYPE_NONE;
3529 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3531 cellIdentity.cellIdentityGsm.resize(0);
3532 cellIdentity.cellIdentityWcdma.resize(0);
3533 cellIdentity.cellIdentityCdma.resize(0);
3534 cellIdentity.cellIdentityTdscdma.resize(0);
3535 cellIdentity.cellIdentityLte.resize(0);
3536 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3537 switch(rilCellIdentity.cellInfoType) {
3539 case RIL_CELL_INFO_TYPE_GSM: {
3540 cellIdentity.cellIdentityGsm.resize(1);
3541 cellIdentity.cellIdentityGsm[0].mcc =
3542 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3543 cellIdentity.cellIdentityGsm[0].mnc =
3544 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3545 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3546 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3547 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3548 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3552 case RIL_CELL_INFO_TYPE_WCDMA: {
3553 cellIdentity.cellIdentityWcdma.resize(1);
3554 cellIdentity.cellIdentityWcdma[0].mcc =
3555 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3556 cellIdentity.cellIdentityWcdma[0].mnc =
3557 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3558 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3559 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3560 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3561 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3565 case RIL_CELL_INFO_TYPE_CDMA: {
3566 cellIdentity.cellIdentityCdma.resize(1);
3567 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3568 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3569 cellIdentity.cellIdentityCdma[0].baseStationId =
3570 rilCellIdentity.cellIdentityCdma.basestationId;
3571 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3572 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3576 case RIL_CELL_INFO_TYPE_LTE: {
3577 cellIdentity.cellIdentityLte.resize(1);
3578 cellIdentity.cellIdentityLte[0].mcc =
3579 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3580 cellIdentity.cellIdentityLte[0].mnc =
3581 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3582 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3583 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3584 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3585 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3589 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3590 cellIdentity.cellIdentityTdscdma.resize(1);
3591 cellIdentity.cellIdentityTdscdma[0].mcc =
3592 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3593 cellIdentity.cellIdentityTdscdma[0].mnc =
3594 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3595 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3596 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3597 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3607 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3608 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3609 return atoi(response[index]);
3615 int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
3616 const int hexBase = 16;
3617 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3618 return strtol(response[index], NULL, hexBase);
3624 /* Fill Cell Identity info from Voice Registration State Response.
3625 * This fucntion is applicable only for RIL Version < 15.
3626 * Response is a "char **".
3627 * First and Second entries are in hex string format
3628 * and rest are integers represented in ascii format. */
3629 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3630 int numStrings, char** response) {
3632 RIL_CellIdentity_v16 rilCellIdentity;
3633 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3635 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3636 switch(rilCellIdentity.cellInfoType) {
3638 case RIL_CELL_INFO_TYPE_GSM: {
3639 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3640 rilCellIdentity.cellIdentityGsm.lac =
3641 convertResponseHexStringEntryToInt(response, 1, numStrings);
3643 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3644 rilCellIdentity.cellIdentityGsm.cid =
3645 convertResponseHexStringEntryToInt(response, 2, numStrings);
3649 case RIL_CELL_INFO_TYPE_WCDMA: {
3650 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3651 rilCellIdentity.cellIdentityWcdma.lac =
3652 convertResponseHexStringEntryToInt(response, 1, numStrings);
3654 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3655 rilCellIdentity.cellIdentityWcdma.cid =
3656 convertResponseHexStringEntryToInt(response, 2, numStrings);
3657 rilCellIdentity.cellIdentityWcdma.psc =
3658 convertResponseStringEntryToInt(response, 14, numStrings);
3662 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3663 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3664 rilCellIdentity.cellIdentityTdscdma.lac =
3665 convertResponseHexStringEntryToInt(response, 1, numStrings);
3667 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3668 rilCellIdentity.cellIdentityTdscdma.cid =
3669 convertResponseHexStringEntryToInt(response, 2, numStrings);
3673 case RIL_CELL_INFO_TYPE_CDMA:{
3674 rilCellIdentity.cellIdentityCdma.basestationId =
3675 convertResponseStringEntryToInt(response, 4, numStrings);
3676 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
3677 rilCellIdentity.cellIdentityCdma.latitude =
3678 convertResponseStringEntryToInt(response, 5, numStrings);
3679 rilCellIdentity.cellIdentityCdma.longitude =
3680 convertResponseStringEntryToInt(response, 6, numStrings);
3681 rilCellIdentity.cellIdentityCdma.systemId =
3682 convertResponseStringEntryToInt(response, 8, numStrings);
3683 rilCellIdentity.cellIdentityCdma.networkId =
3684 convertResponseStringEntryToInt(response, 9, numStrings);
3688 case RIL_CELL_INFO_TYPE_LTE:{
3689 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
3690 rilCellIdentity.cellIdentityLte.tac =
3691 convertResponseHexStringEntryToInt(response, 1, numStrings);
3693 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3694 rilCellIdentity.cellIdentityLte.ci =
3695 convertResponseHexStringEntryToInt(response, 2, numStrings);
3704 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3707 /* Fill Cell Identity info from Data Registration State Response.
3708 * This fucntion is applicable only for RIL Version < 15.
3709 * Response is a "char **".
3710 * First and Second entries are in hex string format
3711 * and rest are integers represented in ascii format. */
3712 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3713 int numStrings, char** response) {
3715 RIL_CellIdentity_v16 rilCellIdentity;
3716 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3718 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3719 switch(rilCellIdentity.cellInfoType) {
3720 case RIL_CELL_INFO_TYPE_GSM: {
3721 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3722 rilCellIdentity.cellIdentityGsm.lac =
3723 convertResponseHexStringEntryToInt(response, 1, numStrings);
3725 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3726 rilCellIdentity.cellIdentityGsm.cid =
3727 convertResponseHexStringEntryToInt(response, 2, numStrings);
3730 case RIL_CELL_INFO_TYPE_WCDMA: {
3731 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3732 rilCellIdentity.cellIdentityWcdma.lac =
3733 convertResponseHexStringEntryToInt(response, 1, numStrings);
3735 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3736 rilCellIdentity.cellIdentityWcdma.cid =
3737 convertResponseHexStringEntryToInt(response, 2, numStrings);
3740 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3741 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3742 rilCellIdentity.cellIdentityTdscdma.lac =
3743 convertResponseHexStringEntryToInt(response, 1, numStrings);
3745 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3746 rilCellIdentity.cellIdentityTdscdma.cid =
3747 convertResponseHexStringEntryToInt(response, 2, numStrings);
3750 case RIL_CELL_INFO_TYPE_LTE: {
3751 rilCellIdentity.cellIdentityLte.tac =
3752 convertResponseStringEntryToInt(response, 6, numStrings);
3753 rilCellIdentity.cellIdentityLte.pci =
3754 convertResponseStringEntryToInt(response, 7, numStrings);
3755 rilCellIdentity.cellIdentityLte.ci =
3756 convertResponseStringEntryToInt(response, 8, numStrings);
3764 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3767 int radio::getVoiceRegistrationStateResponse(int slotId,
3768 int responseType, int serial, RIL_Errno e,
3769 void *response, size_t responseLen) {
3771 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3774 if (radioService[slotId]->mRadioResponse != NULL) {
3775 RadioResponseInfo responseInfo = {};
3776 populateResponseInfo(responseInfo, serial, responseType, e);
3778 VoiceRegStateResult voiceRegResponse = {};
3779 int numStrings = responseLen / sizeof(char *);
3780 if (response == NULL) {
3781 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3782 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3783 } else if (s_vendorFunctions->version <= 14) {
3784 if (numStrings != 15) {
3785 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3786 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3788 char **resp = (char **) response;
3789 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3790 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3791 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3792 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3793 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3794 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3795 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3796 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3800 RIL_VoiceRegistrationStateResponse *voiceRegState =
3801 (RIL_VoiceRegistrationStateResponse *)response;
3803 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3804 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3805 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3807 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3808 voiceRegResponse.rat = voiceRegState->rat;;
3809 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3810 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3811 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3812 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3813 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3814 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3815 voiceRegState->cellIdentity);
3819 Return<void> retStatus =
3820 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3821 responseInfo, voiceRegResponse);
3822 radioService[slotId]->checkReturnStatus(retStatus);
3824 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3831 int radio::getDataRegistrationStateResponse(int slotId,
3832 int responseType, int serial, RIL_Errno e,
3833 void *response, size_t responseLen) {
3835 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3838 if (radioService[slotId]->mRadioResponse != NULL) {
3839 RadioResponseInfo responseInfo = {};
3840 populateResponseInfo(responseInfo, serial, responseType, e);
3841 DataRegStateResult dataRegResponse = {};
3842 if (response == NULL) {
3843 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3844 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3845 } else if (s_vendorFunctions->version <= 14) {
3846 int numStrings = responseLen / sizeof(char *);
3847 if ((numStrings != 6) && (numStrings != 11)) {
3848 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3849 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3851 char **resp = (char **) response;
3852 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3853 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3854 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3855 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3856 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3860 RIL_DataRegistrationStateResponse *dataRegState =
3861 (RIL_DataRegistrationStateResponse *)response;
3863 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3864 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3865 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3867 dataRegResponse.regState = (RegState) dataRegState->regState;
3868 dataRegResponse.rat = dataRegState->rat;;
3869 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3870 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3871 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3875 Return<void> retStatus =
3876 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3878 radioService[slotId]->checkReturnStatus(retStatus);
3880 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3887 int radio::getOperatorResponse(int slotId,
3888 int responseType, int serial, RIL_Errno e, void *response,
3889 size_t responseLen) {
3891 RLOGD("getOperatorResponse: serial %d", serial);
3894 if (radioService[slotId]->mRadioResponse != NULL) {
3895 RadioResponseInfo responseInfo = {};
3896 populateResponseInfo(responseInfo, serial, responseType, e);
3897 hidl_string longName;
3898 hidl_string shortName;
3899 hidl_string numeric;
3900 int numStrings = responseLen / sizeof(char *);
3901 if (response == NULL || numStrings != 3) {
3902 RLOGE("getOperatorResponse Invalid response: NULL");
3903 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3906 char **resp = (char **) response;
3907 longName = convertCharPtrToHidlString(resp[0]);
3908 shortName = convertCharPtrToHidlString(resp[1]);
3909 numeric = convertCharPtrToHidlString(resp[2]);
3911 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3912 responseInfo, longName, shortName, numeric);
3913 radioService[slotId]->checkReturnStatus(retStatus);
3915 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3922 int radio::setRadioPowerResponse(int slotId,
3923 int responseType, int serial, RIL_Errno e, void *response,
3924 size_t responseLen) {
3925 RLOGD("setRadioPowerResponse: serial %d", serial);
3927 if (radioService[slotId]->mRadioResponse != NULL) {
3928 RadioResponseInfo responseInfo = {};
3929 populateResponseInfo(responseInfo, serial, responseType, e);
3930 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3932 radioService[slotId]->checkReturnStatus(retStatus);
3934 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3941 int radio::sendDtmfResponse(int slotId,
3942 int responseType, int serial, RIL_Errno e, void *response,
3943 size_t responseLen) {
3945 RLOGD("sendDtmfResponse: serial %d", serial);
3948 if (radioService[slotId]->mRadioResponse != NULL) {
3949 RadioResponseInfo responseInfo = {};
3950 populateResponseInfo(responseInfo, serial, responseType, e);
3951 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3953 radioService[slotId]->checkReturnStatus(retStatus);
3955 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3962 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3963 RIL_Errno e, void *response, size_t responseLen) {
3964 populateResponseInfo(responseInfo, serial, responseType, e);
3965 SendSmsResult result = {};
3967 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3968 RLOGE("Invalid response: NULL");
3969 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3970 result.ackPDU = hidl_string();
3972 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3973 result.messageRef = resp->messageRef;
3974 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3975 result.errorCode = resp->errorCode;
3980 int radio::sendSmsResponse(int slotId,
3981 int responseType, int serial, RIL_Errno e, void *response,
3982 size_t responseLen) {
3984 RLOGD("sendSmsResponse: serial %d", serial);
3987 if (radioService[slotId]->mRadioResponse != NULL) {
3988 RadioResponseInfo responseInfo = {};
3989 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3992 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3994 radioService[slotId]->checkReturnStatus(retStatus);
3996 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4002 int radio::sendSMSExpectMoreResponse(int slotId,
4003 int responseType, int serial, RIL_Errno e, void *response,
4004 size_t responseLen) {
4006 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
4009 if (radioService[slotId]->mRadioResponse != NULL) {
4010 RadioResponseInfo responseInfo = {};
4011 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4014 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
4015 responseInfo, result);
4016 radioService[slotId]->checkReturnStatus(retStatus);
4018 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4024 int radio::setupDataCallResponse(int slotId,
4025 int responseType, int serial, RIL_Errno e, void *response,
4026 size_t responseLen) {
4028 RLOGD("setupDataCallResponse: serial %d", serial);
4031 if (radioService[slotId]->mRadioResponse != NULL) {
4032 RadioResponseInfo responseInfo = {};
4033 populateResponseInfo(responseInfo, serial, responseType, e);
4035 SetupDataCallResult result = {};
4036 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
4037 if (response != NULL) {
4038 RLOGE("setupDataCallResponse: Invalid response");
4039 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4041 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
4042 result.type = hidl_string();
4043 result.ifname = hidl_string();
4044 result.addresses = hidl_string();
4045 result.dnses = hidl_string();
4046 result.gateways = hidl_string();
4047 result.pcscf = hidl_string();
4049 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
4052 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
4053 responseInfo, result);
4054 radioService[slotId]->checkReturnStatus(retStatus);
4056 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4062 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
4063 RIL_Errno e, void *response, size_t responseLen) {
4064 populateResponseInfo(responseInfo, serial, responseType, e);
4065 IccIoResult result = {};
4067 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
4068 RLOGE("Invalid response: NULL");
4069 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4070 result.simResponse = hidl_string();
4072 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
4073 result.sw1 = resp->sw1;
4074 result.sw2 = resp->sw2;
4075 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
4080 int radio::iccIOForAppResponse(int slotId,
4081 int responseType, int serial, RIL_Errno e, void *response,
4082 size_t responseLen) {
4084 RLOGD("iccIOForAppResponse: serial %d", serial);
4087 if (radioService[slotId]->mRadioResponse != NULL) {
4088 RadioResponseInfo responseInfo = {};
4089 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
4092 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
4093 responseInfo, result);
4094 radioService[slotId]->checkReturnStatus(retStatus);
4096 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4102 int radio::sendUssdResponse(int slotId,
4103 int responseType, int serial, RIL_Errno e, void *response,
4104 size_t responseLen) {
4106 RLOGD("sendUssdResponse: serial %d", serial);
4109 if (radioService[slotId]->mRadioResponse != NULL) {
4110 RadioResponseInfo responseInfo = {};
4111 populateResponseInfo(responseInfo, serial, responseType, e);
4112 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
4114 radioService[slotId]->checkReturnStatus(retStatus);
4116 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
4123 int radio::cancelPendingUssdResponse(int slotId,
4124 int responseType, int serial, RIL_Errno e, void *response,
4125 size_t responseLen) {
4127 RLOGD("cancelPendingUssdResponse: serial %d", serial);
4130 if (radioService[slotId]->mRadioResponse != NULL) {
4131 RadioResponseInfo responseInfo = {};
4132 populateResponseInfo(responseInfo, serial, responseType, e);
4133 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
4135 radioService[slotId]->checkReturnStatus(retStatus);
4137 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
4144 int radio::getClirResponse(int slotId,
4145 int responseType, int serial, RIL_Errno e, void *response,
4146 size_t responseLen) {
4148 RLOGD("getClirResponse: serial %d", serial);
4151 if (radioService[slotId]->mRadioResponse != NULL) {
4152 RadioResponseInfo responseInfo = {};
4153 populateResponseInfo(responseInfo, serial, responseType, e);
4155 int numInts = responseLen / sizeof(int);
4156 if (response == NULL || numInts != 2) {
4157 RLOGE("getClirResponse Invalid response: NULL");
4158 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4160 int *pInt = (int *) response;
4164 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
4166 radioService[slotId]->checkReturnStatus(retStatus);
4168 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4174 int radio::setClirResponse(int slotId,
4175 int responseType, int serial, RIL_Errno e, void *response,
4176 size_t responseLen) {
4178 RLOGD("setClirResponse: serial %d", serial);
4181 if (radioService[slotId]->mRadioResponse != NULL) {
4182 RadioResponseInfo responseInfo = {};
4183 populateResponseInfo(responseInfo, serial, responseType, e);
4184 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
4186 radioService[slotId]->checkReturnStatus(retStatus);
4188 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4194 int radio::getCallForwardStatusResponse(int slotId,
4195 int responseType, int serial, RIL_Errno e,
4196 void *response, size_t responseLen) {
4198 RLOGD("getCallForwardStatusResponse: serial %d", serial);
4201 if (radioService[slotId]->mRadioResponse != NULL) {
4202 RadioResponseInfo responseInfo = {};
4203 populateResponseInfo(responseInfo, serial, responseType, e);
4204 hidl_vec<CallForwardInfo> callForwardInfos;
4206 if ((response == NULL && responseLen != 0)
4207 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4208 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4209 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4211 int num = responseLen / sizeof(RIL_CallForwardInfo *);
4212 callForwardInfos.resize(num);
4213 for (int i = 0 ; i < num; i++) {
4214 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4215 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4216 callForwardInfos[i].reason = resp->reason;
4217 callForwardInfos[i].serviceClass = resp->serviceClass;
4218 callForwardInfos[i].toa = resp->toa;
4219 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4220 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4224 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4225 responseInfo, callForwardInfos);
4226 radioService[slotId]->checkReturnStatus(retStatus);
4228 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4235 int radio::setCallForwardResponse(int slotId,
4236 int responseType, int serial, RIL_Errno e, void *response,
4237 size_t responseLen) {
4239 RLOGD("setCallForwardResponse: serial %d", serial);
4242 if (radioService[slotId]->mRadioResponse != NULL) {
4243 RadioResponseInfo responseInfo = {};
4244 populateResponseInfo(responseInfo, serial, responseType, e);
4245 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4247 radioService[slotId]->checkReturnStatus(retStatus);
4249 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4255 int radio::getCallWaitingResponse(int slotId,
4256 int responseType, int serial, RIL_Errno e, void *response,
4257 size_t responseLen) {
4259 RLOGD("getCallWaitingResponse: serial %d", serial);
4262 if (radioService[slotId]->mRadioResponse != NULL) {
4263 RadioResponseInfo responseInfo = {};
4264 populateResponseInfo(responseInfo, serial, responseType, e);
4265 bool enable = false;
4266 int serviceClass = -1;
4267 int numInts = responseLen / sizeof(int);
4268 if (response == NULL || numInts != 2) {
4269 RLOGE("getCallWaitingResponse Invalid response: NULL");
4270 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4272 int *pInt = (int *) response;
4273 enable = pInt[0] == 1 ? true : false;
4274 serviceClass = pInt[1];
4276 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4277 responseInfo, enable, serviceClass);
4278 radioService[slotId]->checkReturnStatus(retStatus);
4280 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4286 int radio::setCallWaitingResponse(int slotId,
4287 int responseType, int serial, RIL_Errno e, void *response,
4288 size_t responseLen) {
4290 RLOGD("setCallWaitingResponse: serial %d", serial);
4293 if (radioService[slotId]->mRadioResponse != NULL) {
4294 RadioResponseInfo responseInfo = {};
4295 populateResponseInfo(responseInfo, serial, responseType, e);
4296 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4298 radioService[slotId]->checkReturnStatus(retStatus);
4300 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4306 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4307 int responseType, int serial, RIL_Errno e,
4308 void *response, size_t responseLen) {
4310 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4313 if (radioService[slotId]->mRadioResponse != NULL) {
4314 RadioResponseInfo responseInfo = {};
4315 populateResponseInfo(responseInfo, serial, responseType, e);
4316 Return<void> retStatus =
4317 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4319 radioService[slotId]->checkReturnStatus(retStatus);
4321 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4328 int radio::acceptCallResponse(int slotId,
4329 int responseType, int serial, RIL_Errno e,
4330 void *response, size_t responseLen) {
4332 RLOGD("acceptCallResponse: serial %d", serial);
4335 if (radioService[slotId]->mRadioResponse != NULL) {
4336 RadioResponseInfo responseInfo = {};
4337 populateResponseInfo(responseInfo, serial, responseType, e);
4338 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4340 radioService[slotId]->checkReturnStatus(retStatus);
4342 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4349 int radio::deactivateDataCallResponse(int slotId,
4350 int responseType, int serial, RIL_Errno e,
4351 void *response, size_t responseLen) {
4353 RLOGD("deactivateDataCallResponse: serial %d", serial);
4356 if (radioService[slotId]->mRadioResponse != NULL) {
4357 RadioResponseInfo responseInfo = {};
4358 populateResponseInfo(responseInfo, serial, responseType, e);
4359 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4361 radioService[slotId]->checkReturnStatus(retStatus);
4363 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4370 int radio::getFacilityLockForAppResponse(int slotId,
4371 int responseType, int serial, RIL_Errno e,
4372 void *response, size_t responseLen) {
4374 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4377 if (radioService[slotId]->mRadioResponse != NULL) {
4378 RadioResponseInfo responseInfo = {};
4379 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4380 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4381 getFacilityLockForAppResponse(responseInfo, ret);
4382 radioService[slotId]->checkReturnStatus(retStatus);
4384 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4391 int radio::setFacilityLockForAppResponse(int slotId,
4392 int responseType, int serial, RIL_Errno e,
4393 void *response, size_t responseLen) {
4395 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4398 if (radioService[slotId]->mRadioResponse != NULL) {
4399 RadioResponseInfo responseInfo = {};
4400 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4401 Return<void> retStatus
4402 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4404 radioService[slotId]->checkReturnStatus(retStatus);
4406 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4413 int radio::setBarringPasswordResponse(int slotId,
4414 int responseType, int serial, RIL_Errno e,
4415 void *response, size_t responseLen) {
4417 RLOGD("acceptCallResponse: serial %d", serial);
4420 if (radioService[slotId]->mRadioResponse != NULL) {
4421 RadioResponseInfo responseInfo = {};
4422 populateResponseInfo(responseInfo, serial, responseType, e);
4423 Return<void> retStatus
4424 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4425 radioService[slotId]->checkReturnStatus(retStatus);
4427 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4434 int radio::getNetworkSelectionModeResponse(int slotId,
4435 int responseType, int serial, RIL_Errno e, void *response,
4436 size_t responseLen) {
4438 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4441 if (radioService[slotId]->mRadioResponse != NULL) {
4442 RadioResponseInfo responseInfo = {};
4443 populateResponseInfo(responseInfo, serial, responseType, e);
4444 bool manual = false;
4445 if (response == NULL || responseLen != sizeof(int)) {
4446 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4447 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4449 int *pInt = (int *) response;
4450 manual = pInt[0] == 1 ? true : false;
4452 Return<void> retStatus
4453 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4456 radioService[slotId]->checkReturnStatus(retStatus);
4458 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4465 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4466 RIL_Errno e, void *response,
4467 size_t responseLen) {
4469 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4472 if (radioService[slotId]->mRadioResponse != NULL) {
4473 RadioResponseInfo responseInfo = {};
4474 populateResponseInfo(responseInfo, serial, responseType, e);
4475 Return<void> retStatus
4476 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4478 radioService[slotId]->checkReturnStatus(retStatus);
4480 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4487 int radio::setNetworkSelectionModeManualResponse(int slotId,
4488 int responseType, int serial, RIL_Errno e,
4489 void *response, size_t responseLen) {
4491 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4494 if (radioService[slotId]->mRadioResponse != NULL) {
4495 RadioResponseInfo responseInfo = {};
4496 populateResponseInfo(responseInfo, serial, responseType, e);
4497 Return<void> retStatus
4498 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4500 radioService[slotId]->checkReturnStatus(retStatus);
4502 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4509 int convertOperatorStatusToInt(const char *str) {
4510 if (strncmp("unknown", str, 9) == 0) {
4511 return (int) OperatorStatus::UNKNOWN;
4512 } else if (strncmp("available", str, 9) == 0) {
4513 return (int) OperatorStatus::AVAILABLE;
4514 } else if (strncmp("current", str, 9) == 0) {
4515 return (int) OperatorStatus::CURRENT;
4516 } else if (strncmp("forbidden", str, 9) == 0) {
4517 return (int) OperatorStatus::FORBIDDEN;
4523 int radio::getAvailableNetworksResponse(int slotId,
4524 int responseType, int serial, RIL_Errno e, void *response,
4525 size_t responseLen) {
4527 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4530 if (radioService[slotId]->mRadioResponse != NULL) {
4531 RadioResponseInfo responseInfo = {};
4532 populateResponseInfo(responseInfo, serial, responseType, e);
4533 hidl_vec<OperatorInfo> networks;
4534 if ((response == NULL && responseLen != 0)
4535 || responseLen % (4 * sizeof(char *))!= 0) {
4536 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4537 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4539 char **resp = (char **) response;
4540 int numStrings = responseLen / sizeof(char *);
4541 networks.resize(numStrings/4);
4542 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4543 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4544 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4545 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4546 int status = convertOperatorStatusToInt(resp[i + 3]);
4548 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4550 networks[j].status = (OperatorStatus) status;
4554 Return<void> retStatus
4555 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4557 radioService[slotId]->checkReturnStatus(retStatus);
4559 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4566 int radio::startDtmfResponse(int slotId,
4567 int responseType, int serial, RIL_Errno e,
4568 void *response, size_t responseLen) {
4570 RLOGD("startDtmfResponse: serial %d", serial);
4573 if (radioService[slotId]->mRadioResponse != NULL) {
4574 RadioResponseInfo responseInfo = {};
4575 populateResponseInfo(responseInfo, serial, responseType, e);
4576 Return<void> retStatus
4577 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4578 radioService[slotId]->checkReturnStatus(retStatus);
4580 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4586 int radio::stopDtmfResponse(int slotId,
4587 int responseType, int serial, RIL_Errno e,
4588 void *response, size_t responseLen) {
4590 RLOGD("stopDtmfResponse: serial %d", serial);
4593 if (radioService[slotId]->mRadioResponse != NULL) {
4594 RadioResponseInfo responseInfo = {};
4595 populateResponseInfo(responseInfo, serial, responseType, e);
4596 Return<void> retStatus
4597 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4598 radioService[slotId]->checkReturnStatus(retStatus);
4600 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4606 int radio::getBasebandVersionResponse(int slotId,
4607 int responseType, int serial, RIL_Errno e,
4608 void *response, size_t responseLen) {
4610 RLOGD("getBasebandVersionResponse: serial %d", serial);
4613 if (radioService[slotId]->mRadioResponse != NULL) {
4614 RadioResponseInfo responseInfo = {};
4615 populateResponseInfo(responseInfo, serial, responseType, e);
4616 Return<void> retStatus
4617 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4618 convertCharPtrToHidlString((char *) response));
4619 radioService[slotId]->checkReturnStatus(retStatus);
4621 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4627 int radio::separateConnectionResponse(int slotId,
4628 int responseType, int serial, RIL_Errno e,
4629 void *response, size_t responseLen) {
4631 RLOGD("separateConnectionResponse: serial %d", serial);
4634 if (radioService[slotId]->mRadioResponse != NULL) {
4635 RadioResponseInfo responseInfo = {};
4636 populateResponseInfo(responseInfo, serial, responseType, e);
4637 Return<void> retStatus
4638 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4639 radioService[slotId]->checkReturnStatus(retStatus);
4641 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4648 int radio::setMuteResponse(int slotId,
4649 int responseType, int serial, RIL_Errno e,
4650 void *response, size_t responseLen) {
4652 RLOGD("setMuteResponse: serial %d", serial);
4655 if (radioService[slotId]->mRadioResponse != NULL) {
4656 RadioResponseInfo responseInfo = {};
4657 populateResponseInfo(responseInfo, serial, responseType, e);
4658 Return<void> retStatus
4659 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4660 radioService[slotId]->checkReturnStatus(retStatus);
4662 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4668 int radio::getMuteResponse(int slotId,
4669 int responseType, int serial, RIL_Errno e, void *response,
4670 size_t responseLen) {
4672 RLOGD("getMuteResponse: serial %d", serial);
4675 if (radioService[slotId]->mRadioResponse != NULL) {
4676 RadioResponseInfo responseInfo = {};
4677 populateResponseInfo(responseInfo, serial, responseType, e);
4678 bool enable = false;
4679 if (response == NULL || responseLen != sizeof(int)) {
4680 RLOGE("getMuteResponse Invalid response: NULL");
4681 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4683 int *pInt = (int *) response;
4684 enable = pInt[0] == 1 ? true : false;
4686 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4688 radioService[slotId]->checkReturnStatus(retStatus);
4690 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4696 int radio::getClipResponse(int slotId,
4697 int responseType, int serial, RIL_Errno e,
4698 void *response, size_t responseLen) {
4700 RLOGD("getClipResponse: serial %d", serial);
4703 if (radioService[slotId]->mRadioResponse != NULL) {
4704 RadioResponseInfo responseInfo = {};
4705 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4706 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4708 radioService[slotId]->checkReturnStatus(retStatus);
4710 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4716 int radio::getDataCallListResponse(int slotId,
4717 int responseType, int serial, RIL_Errno e,
4718 void *response, size_t responseLen) {
4720 RLOGD("getDataCallListResponse: serial %d", serial);
4723 if (radioService[slotId]->mRadioResponse != NULL) {
4724 RadioResponseInfo responseInfo = {};
4725 populateResponseInfo(responseInfo, serial, responseType, e);
4727 hidl_vec<SetupDataCallResult> ret;
4728 if ((response == NULL && responseLen != 0)
4729 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4730 RLOGE("getDataCallListResponse: invalid response");
4731 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4733 convertRilDataCallListToHal(response, responseLen, ret);
4736 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4738 radioService[slotId]->checkReturnStatus(retStatus);
4740 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4746 int radio::setSuppServiceNotificationsResponse(int slotId,
4747 int responseType, int serial, RIL_Errno e,
4748 void *response, size_t responseLen) {
4750 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4753 if (radioService[slotId]->mRadioResponse != NULL) {
4754 RadioResponseInfo responseInfo = {};
4755 populateResponseInfo(responseInfo, serial, responseType, e);
4756 Return<void> retStatus
4757 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4759 radioService[slotId]->checkReturnStatus(retStatus);
4761 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4768 int radio::deleteSmsOnSimResponse(int slotId,
4769 int responseType, int serial, RIL_Errno e,
4770 void *response, size_t responseLen) {
4772 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4775 if (radioService[slotId]->mRadioResponse != NULL) {
4776 RadioResponseInfo responseInfo = {};
4777 populateResponseInfo(responseInfo, serial, responseType, e);
4778 Return<void> retStatus
4779 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4780 radioService[slotId]->checkReturnStatus(retStatus);
4782 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4788 int radio::setBandModeResponse(int slotId,
4789 int responseType, int serial, RIL_Errno e,
4790 void *response, size_t responseLen) {
4792 RLOGD("setBandModeResponse: serial %d", serial);
4795 if (radioService[slotId]->mRadioResponse != NULL) {
4796 RadioResponseInfo responseInfo = {};
4797 populateResponseInfo(responseInfo, serial, responseType, e);
4798 Return<void> retStatus
4799 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4800 radioService[slotId]->checkReturnStatus(retStatus);
4802 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4808 int radio::writeSmsToSimResponse(int slotId,
4809 int responseType, int serial, RIL_Errno e,
4810 void *response, size_t responseLen) {
4812 RLOGD("writeSmsToSimResponse: serial %d", serial);
4815 if (radioService[slotId]->mRadioResponse != NULL) {
4816 RadioResponseInfo responseInfo = {};
4817 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4818 Return<void> retStatus
4819 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4820 radioService[slotId]->checkReturnStatus(retStatus);
4822 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4828 int radio::getAvailableBandModesResponse(int slotId,
4829 int responseType, int serial, RIL_Errno e, void *response,
4830 size_t responseLen) {
4832 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4835 if (radioService[slotId]->mRadioResponse != NULL) {
4836 RadioResponseInfo responseInfo = {};
4837 populateResponseInfo(responseInfo, serial, responseType, e);
4838 hidl_vec<RadioBandMode> modes;
4839 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
4840 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4841 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4843 int *pInt = (int *) response;
4844 int numInts = responseLen / sizeof(int);
4845 modes.resize(numInts);
4846 for (int i = 0; i < numInts; i++) {
4847 modes[i] = (RadioBandMode) pInt[i];
4850 Return<void> retStatus
4851 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4853 radioService[slotId]->checkReturnStatus(retStatus);
4855 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4862 int radio::sendEnvelopeResponse(int slotId,
4863 int responseType, int serial, RIL_Errno e,
4864 void *response, size_t responseLen) {
4866 RLOGD("sendEnvelopeResponse: serial %d", serial);
4869 if (radioService[slotId]->mRadioResponse != NULL) {
4870 RadioResponseInfo responseInfo = {};
4871 populateResponseInfo(responseInfo, serial, responseType, e);
4872 Return<void> retStatus
4873 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4874 convertCharPtrToHidlString((char *) response));
4875 radioService[slotId]->checkReturnStatus(retStatus);
4877 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4883 int radio::sendTerminalResponseToSimResponse(int slotId,
4884 int responseType, int serial, RIL_Errno e,
4885 void *response, size_t responseLen) {
4887 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4890 if (radioService[slotId]->mRadioResponse != NULL) {
4891 RadioResponseInfo responseInfo = {};
4892 populateResponseInfo(responseInfo, serial, responseType, e);
4893 Return<void> retStatus
4894 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4896 radioService[slotId]->checkReturnStatus(retStatus);
4898 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4905 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4906 int responseType, int serial,
4907 RIL_Errno e, void *response,
4908 size_t responseLen) {
4910 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4913 if (radioService[slotId]->mRadioResponse != NULL) {
4914 RadioResponseInfo responseInfo = {};
4915 populateResponseInfo(responseInfo, serial, responseType, e);
4916 Return<void> retStatus
4917 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4919 radioService[slotId]->checkReturnStatus(retStatus);
4921 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4928 int radio::explicitCallTransferResponse(int slotId,
4929 int responseType, int serial, RIL_Errno e,
4930 void *response, size_t responseLen) {
4932 RLOGD("explicitCallTransferResponse: serial %d", serial);
4935 if (radioService[slotId]->mRadioResponse != NULL) {
4936 RadioResponseInfo responseInfo = {};
4937 populateResponseInfo(responseInfo, serial, responseType, e);
4938 Return<void> retStatus
4939 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4940 radioService[slotId]->checkReturnStatus(retStatus);
4942 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4949 int radio::setPreferredNetworkTypeResponse(int slotId,
4950 int responseType, int serial, RIL_Errno e,
4951 void *response, size_t responseLen) {
4953 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4956 if (radioService[slotId]->mRadioResponse != NULL) {
4957 RadioResponseInfo responseInfo = {};
4958 populateResponseInfo(responseInfo, serial, responseType, e);
4959 Return<void> retStatus
4960 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4962 radioService[slotId]->checkReturnStatus(retStatus);
4964 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4972 int radio::getPreferredNetworkTypeResponse(int slotId,
4973 int responseType, int serial, RIL_Errno e,
4974 void *response, size_t responseLen) {
4976 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4979 if (radioService[slotId]->mRadioResponse != NULL) {
4980 RadioResponseInfo responseInfo = {};
4981 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4982 Return<void> retStatus
4983 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4984 responseInfo, (PreferredNetworkType) ret);
4985 radioService[slotId]->checkReturnStatus(retStatus);
4987 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4994 int radio::getNeighboringCidsResponse(int slotId,
4995 int responseType, int serial, RIL_Errno e,
4996 void *response, size_t responseLen) {
4998 RLOGD("getNeighboringCidsResponse: serial %d", serial);
5001 if (radioService[slotId]->mRadioResponse != NULL) {
5002 RadioResponseInfo responseInfo = {};
5003 populateResponseInfo(responseInfo, serial, responseType, e);
5004 hidl_vec<NeighboringCell> cells;
5006 if ((response == NULL && responseLen != 0)
5007 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
5008 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
5009 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5011 int num = responseLen / sizeof(RIL_NeighboringCell *);
5013 for (int i = 0 ; i < num; i++) {
5014 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
5015 cells[i].cid = convertCharPtrToHidlString(resp->cid);
5016 cells[i].rssi = resp->rssi;
5020 Return<void> retStatus
5021 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
5023 radioService[slotId]->checkReturnStatus(retStatus);
5025 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
5032 int radio::setLocationUpdatesResponse(int slotId,
5033 int responseType, int serial, RIL_Errno e,
5034 void *response, size_t responseLen) {
5036 RLOGD("setLocationUpdatesResponse: serial %d", serial);
5039 if (radioService[slotId]->mRadioResponse != NULL) {
5040 RadioResponseInfo responseInfo = {};
5041 populateResponseInfo(responseInfo, serial, responseType, e);
5042 Return<void> retStatus
5043 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
5044 radioService[slotId]->checkReturnStatus(retStatus);
5046 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
5053 int radio::setCdmaSubscriptionSourceResponse(int slotId,
5054 int responseType, int serial, RIL_Errno e,
5055 void *response, size_t responseLen) {
5057 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
5060 if (radioService[slotId]->mRadioResponse != NULL) {
5061 RadioResponseInfo responseInfo = {};
5062 populateResponseInfo(responseInfo, serial, responseType, e);
5063 Return<void> retStatus
5064 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
5066 radioService[slotId]->checkReturnStatus(retStatus);
5068 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5075 int radio::setCdmaRoamingPreferenceResponse(int slotId,
5076 int responseType, int serial, RIL_Errno e,
5077 void *response, size_t responseLen) {
5079 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
5082 if (radioService[slotId]->mRadioResponse != NULL) {
5083 RadioResponseInfo responseInfo = {};
5084 populateResponseInfo(responseInfo, serial, responseType, e);
5085 Return<void> retStatus
5086 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
5088 radioService[slotId]->checkReturnStatus(retStatus);
5090 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5097 int radio::getCdmaRoamingPreferenceResponse(int slotId,
5098 int responseType, int serial, RIL_Errno e,
5099 void *response, size_t responseLen) {
5101 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
5104 if (radioService[slotId]->mRadioResponse != NULL) {
5105 RadioResponseInfo responseInfo = {};
5106 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5107 Return<void> retStatus
5108 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
5109 responseInfo, (CdmaRoamingType) ret);
5110 radioService[slotId]->checkReturnStatus(retStatus);
5112 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5119 int radio::setTTYModeResponse(int slotId,
5120 int responseType, int serial, RIL_Errno e,
5121 void *response, size_t responseLen) {
5123 RLOGD("setTTYModeResponse: serial %d", serial);
5126 if (radioService[slotId]->mRadioResponse != NULL) {
5127 RadioResponseInfo responseInfo = {};
5128 populateResponseInfo(responseInfo, serial, responseType, e);
5129 Return<void> retStatus
5130 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
5131 radioService[slotId]->checkReturnStatus(retStatus);
5133 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5139 int radio::getTTYModeResponse(int slotId,
5140 int responseType, int serial, RIL_Errno e,
5141 void *response, size_t responseLen) {
5143 RLOGD("getTTYModeResponse: serial %d", serial);
5146 if (radioService[slotId]->mRadioResponse != NULL) {
5147 RadioResponseInfo responseInfo = {};
5148 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5149 Return<void> retStatus
5150 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
5152 radioService[slotId]->checkReturnStatus(retStatus);
5154 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5160 int radio::setPreferredVoicePrivacyResponse(int slotId,
5161 int responseType, int serial, RIL_Errno e,
5162 void *response, size_t responseLen) {
5164 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
5167 if (radioService[slotId]->mRadioResponse != NULL) {
5168 RadioResponseInfo responseInfo = {};
5169 populateResponseInfo(responseInfo, serial, responseType, e);
5170 Return<void> retStatus
5171 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
5173 radioService[slotId]->checkReturnStatus(retStatus);
5175 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5182 int radio::getPreferredVoicePrivacyResponse(int slotId,
5183 int responseType, int serial, RIL_Errno e,
5184 void *response, size_t responseLen) {
5186 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
5189 if (radioService[slotId]->mRadioResponse != NULL) {
5190 RadioResponseInfo responseInfo = {};
5191 populateResponseInfo(responseInfo, serial, responseType, e);
5192 bool enable = false;
5193 int numInts = responseLen / sizeof(int);
5194 if (response == NULL || numInts != 1) {
5195 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
5196 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5198 int *pInt = (int *) response;
5199 enable = pInt[0] == 1 ? true : false;
5201 Return<void> retStatus
5202 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5203 responseInfo, enable);
5204 radioService[slotId]->checkReturnStatus(retStatus);
5206 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5213 int radio::sendCDMAFeatureCodeResponse(int slotId,
5214 int responseType, int serial, RIL_Errno e,
5215 void *response, size_t responseLen) {
5217 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5220 if (radioService[slotId]->mRadioResponse != NULL) {
5221 RadioResponseInfo responseInfo = {};
5222 populateResponseInfo(responseInfo, serial, responseType, e);
5223 Return<void> retStatus
5224 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5225 radioService[slotId]->checkReturnStatus(retStatus);
5227 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5234 int radio::sendBurstDtmfResponse(int slotId,
5235 int responseType, int serial, RIL_Errno e,
5236 void *response, size_t responseLen) {
5238 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5241 if (radioService[slotId]->mRadioResponse != NULL) {
5242 RadioResponseInfo responseInfo = {};
5243 populateResponseInfo(responseInfo, serial, responseType, e);
5244 Return<void> retStatus
5245 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5246 radioService[slotId]->checkReturnStatus(retStatus);
5248 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5254 int radio::sendCdmaSmsResponse(int slotId,
5255 int responseType, int serial, RIL_Errno e, void *response,
5256 size_t responseLen) {
5258 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5261 if (radioService[slotId]->mRadioResponse != NULL) {
5262 RadioResponseInfo responseInfo = {};
5263 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5266 Return<void> retStatus
5267 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5268 radioService[slotId]->checkReturnStatus(retStatus);
5270 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5276 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5277 int responseType, int serial, RIL_Errno e,
5278 void *response, size_t responseLen) {
5280 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5283 if (radioService[slotId]->mRadioResponse != NULL) {
5284 RadioResponseInfo responseInfo = {};
5285 populateResponseInfo(responseInfo, serial, responseType, e);
5286 Return<void> retStatus
5287 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5289 radioService[slotId]->checkReturnStatus(retStatus);
5291 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5298 int radio::getGsmBroadcastConfigResponse(int slotId,
5299 int responseType, int serial, RIL_Errno e,
5300 void *response, size_t responseLen) {
5302 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5305 if (radioService[slotId]->mRadioResponse != NULL) {
5306 RadioResponseInfo responseInfo = {};
5307 populateResponseInfo(responseInfo, serial, responseType, e);
5308 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5310 if ((response == NULL && responseLen != 0)
5311 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5312 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5313 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5315 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5316 configs.resize(num);
5317 for (int i = 0 ; i < num; i++) {
5318 RIL_GSM_BroadcastSmsConfigInfo *resp =
5319 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5320 configs[i].fromServiceId = resp->fromServiceId;
5321 configs[i].toServiceId = resp->toServiceId;
5322 configs[i].fromCodeScheme = resp->fromCodeScheme;
5323 configs[i].toCodeScheme = resp->toCodeScheme;
5324 configs[i].selected = resp->selected == 1 ? true : false;
5328 Return<void> retStatus
5329 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5331 radioService[slotId]->checkReturnStatus(retStatus);
5333 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5340 int radio::setGsmBroadcastConfigResponse(int slotId,
5341 int responseType, int serial, RIL_Errno e,
5342 void *response, size_t responseLen) {
5344 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5347 if (radioService[slotId]->mRadioResponse != NULL) {
5348 RadioResponseInfo responseInfo = {};
5349 populateResponseInfo(responseInfo, serial, responseType, e);
5350 Return<void> retStatus
5351 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5352 radioService[slotId]->checkReturnStatus(retStatus);
5354 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5361 int radio::setGsmBroadcastActivationResponse(int slotId,
5362 int responseType, int serial, RIL_Errno e,
5363 void *response, size_t responseLen) {
5365 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5368 if (radioService[slotId]->mRadioResponse != NULL) {
5369 RadioResponseInfo responseInfo = {};
5370 populateResponseInfo(responseInfo, serial, responseType, e);
5371 Return<void> retStatus
5372 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5374 radioService[slotId]->checkReturnStatus(retStatus);
5376 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5383 int radio::getCdmaBroadcastConfigResponse(int slotId,
5384 int responseType, int serial, RIL_Errno e,
5385 void *response, size_t responseLen) {
5387 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5390 if (radioService[slotId]->mRadioResponse != NULL) {
5391 RadioResponseInfo responseInfo = {};
5392 populateResponseInfo(responseInfo, serial, responseType, e);
5393 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5395 if ((response == NULL && responseLen != 0)
5396 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5397 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5398 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5400 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5401 configs.resize(num);
5402 for (int i = 0 ; i < num; i++) {
5403 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5404 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5405 configs[i].serviceCategory = resp->service_category;
5406 configs[i].language = resp->language;
5407 configs[i].selected = resp->selected == 1 ? true : false;
5411 Return<void> retStatus
5412 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5414 radioService[slotId]->checkReturnStatus(retStatus);
5416 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5423 int radio::setCdmaBroadcastConfigResponse(int slotId,
5424 int responseType, int serial, RIL_Errno e,
5425 void *response, size_t responseLen) {
5427 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5430 if (radioService[slotId]->mRadioResponse != NULL) {
5431 RadioResponseInfo responseInfo = {};
5432 populateResponseInfo(responseInfo, serial, responseType, e);
5433 Return<void> retStatus
5434 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5436 radioService[slotId]->checkReturnStatus(retStatus);
5438 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5445 int radio::setCdmaBroadcastActivationResponse(int slotId,
5446 int responseType, int serial, RIL_Errno e,
5447 void *response, size_t responseLen) {
5449 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5452 if (radioService[slotId]->mRadioResponse != NULL) {
5453 RadioResponseInfo responseInfo = {};
5454 populateResponseInfo(responseInfo, serial, responseType, e);
5455 Return<void> retStatus
5456 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5458 radioService[slotId]->checkReturnStatus(retStatus);
5460 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5467 int radio::getCDMASubscriptionResponse(int slotId,
5468 int responseType, int serial, RIL_Errno e, void *response,
5469 size_t responseLen) {
5471 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5474 if (radioService[slotId]->mRadioResponse != NULL) {
5475 RadioResponseInfo responseInfo = {};
5476 populateResponseInfo(responseInfo, serial, responseType, e);
5478 int numStrings = responseLen / sizeof(char *);
5479 hidl_string emptyString;
5480 if (response == NULL || numStrings != 5) {
5481 RLOGE("getOperatorResponse Invalid response: NULL");
5482 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5483 Return<void> retStatus
5484 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5485 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5486 radioService[slotId]->checkReturnStatus(retStatus);
5488 char **resp = (char **) response;
5489 Return<void> retStatus
5490 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5492 convertCharPtrToHidlString(resp[0]),
5493 convertCharPtrToHidlString(resp[1]),
5494 convertCharPtrToHidlString(resp[2]),
5495 convertCharPtrToHidlString(resp[3]),
5496 convertCharPtrToHidlString(resp[4]));
5497 radioService[slotId]->checkReturnStatus(retStatus);
5500 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5507 int radio::writeSmsToRuimResponse(int slotId,
5508 int responseType, int serial, RIL_Errno e,
5509 void *response, size_t responseLen) {
5511 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5514 if (radioService[slotId]->mRadioResponse != NULL) {
5515 RadioResponseInfo responseInfo = {};
5516 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5517 Return<void> retStatus
5518 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5519 radioService[slotId]->checkReturnStatus(retStatus);
5521 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5527 int radio::deleteSmsOnRuimResponse(int slotId,
5528 int responseType, int serial, RIL_Errno e,
5529 void *response, size_t responseLen) {
5531 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5534 if (radioService[slotId]->mRadioResponse != NULL) {
5535 RadioResponseInfo responseInfo = {};
5536 populateResponseInfo(responseInfo, serial, responseType, e);
5537 Return<void> retStatus
5538 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5539 radioService[slotId]->checkReturnStatus(retStatus);
5541 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5547 int radio::getDeviceIdentityResponse(int slotId,
5548 int responseType, int serial, RIL_Errno e, void *response,
5549 size_t responseLen) {
5551 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5554 if (radioService[slotId]->mRadioResponse != NULL) {
5555 RadioResponseInfo responseInfo = {};
5556 populateResponseInfo(responseInfo, serial, responseType, e);
5558 int numStrings = responseLen / sizeof(char *);
5559 hidl_string emptyString;
5560 if (response == NULL || numStrings != 4) {
5561 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5562 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5563 Return<void> retStatus
5564 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5565 emptyString, emptyString, emptyString, emptyString);
5566 radioService[slotId]->checkReturnStatus(retStatus);
5568 char **resp = (char **) response;
5569 Return<void> retStatus
5570 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5571 convertCharPtrToHidlString(resp[0]),
5572 convertCharPtrToHidlString(resp[1]),
5573 convertCharPtrToHidlString(resp[2]),
5574 convertCharPtrToHidlString(resp[3]));
5575 radioService[slotId]->checkReturnStatus(retStatus);
5578 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5585 int radio::exitEmergencyCallbackModeResponse(int slotId,
5586 int responseType, int serial, RIL_Errno e,
5587 void *response, size_t responseLen) {
5589 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5592 if (radioService[slotId]->mRadioResponse != NULL) {
5593 RadioResponseInfo responseInfo = {};
5594 populateResponseInfo(responseInfo, serial, responseType, e);
5595 Return<void> retStatus
5596 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5598 radioService[slotId]->checkReturnStatus(retStatus);
5600 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5607 int radio::getSmscAddressResponse(int slotId,
5608 int responseType, int serial, RIL_Errno e,
5609 void *response, size_t responseLen) {
5611 RLOGD("getSmscAddressResponse: serial %d", serial);
5614 if (radioService[slotId]->mRadioResponse != NULL) {
5615 RadioResponseInfo responseInfo = {};
5616 populateResponseInfo(responseInfo, serial, responseType, e);
5617 Return<void> retStatus
5618 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5619 convertCharPtrToHidlString((char *) response));
5620 radioService[slotId]->checkReturnStatus(retStatus);
5622 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5628 int radio::setSmscAddressResponse(int slotId,
5629 int responseType, int serial, RIL_Errno e,
5630 void *response, size_t responseLen) {
5632 RLOGD("setSmscAddressResponse: serial %d", serial);
5635 if (radioService[slotId]->mRadioResponse != NULL) {
5636 RadioResponseInfo responseInfo = {};
5637 populateResponseInfo(responseInfo, serial, responseType, e);
5638 Return<void> retStatus
5639 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5640 radioService[slotId]->checkReturnStatus(retStatus);
5642 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5648 int radio::reportSmsMemoryStatusResponse(int slotId,
5649 int responseType, int serial, RIL_Errno e,
5650 void *response, size_t responseLen) {
5652 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5655 if (radioService[slotId]->mRadioResponse != NULL) {
5656 RadioResponseInfo responseInfo = {};
5657 populateResponseInfo(responseInfo, serial, responseType, e);
5658 Return<void> retStatus
5659 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5660 radioService[slotId]->checkReturnStatus(retStatus);
5662 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5669 int radio::reportStkServiceIsRunningResponse(int slotId,
5670 int responseType, int serial, RIL_Errno e,
5671 void *response, size_t responseLen) {
5673 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5676 if (radioService[slotId]->mRadioResponse != NULL) {
5677 RadioResponseInfo responseInfo = {};
5678 populateResponseInfo(responseInfo, serial, responseType, e);
5679 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5680 reportStkServiceIsRunningResponse(responseInfo);
5681 radioService[slotId]->checkReturnStatus(retStatus);
5683 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5690 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5691 int responseType, int serial, RIL_Errno e,
5692 void *response, size_t responseLen) {
5694 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5697 if (radioService[slotId]->mRadioResponse != NULL) {
5698 RadioResponseInfo responseInfo = {};
5699 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5700 Return<void> retStatus
5701 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5702 responseInfo, (CdmaSubscriptionSource) ret);
5703 radioService[slotId]->checkReturnStatus(retStatus);
5705 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5712 int radio::requestIsimAuthenticationResponse(int slotId,
5713 int responseType, int serial, RIL_Errno e,
5714 void *response, size_t responseLen) {
5716 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5719 if (radioService[slotId]->mRadioResponse != NULL) {
5720 RadioResponseInfo responseInfo = {};
5721 populateResponseInfo(responseInfo, serial, responseType, e);
5722 Return<void> retStatus
5723 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5725 convertCharPtrToHidlString((char *) response));
5726 radioService[slotId]->checkReturnStatus(retStatus);
5728 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5735 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5737 int serial, RIL_Errno e, void *response,
5738 size_t responseLen) {
5740 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5743 if (radioService[slotId]->mRadioResponse != NULL) {
5744 RadioResponseInfo responseInfo = {};
5745 populateResponseInfo(responseInfo, serial, responseType, e);
5746 Return<void> retStatus
5747 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5749 radioService[slotId]->checkReturnStatus(retStatus);
5751 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5758 int radio::sendEnvelopeWithStatusResponse(int slotId,
5759 int responseType, int serial, RIL_Errno e, void *response,
5760 size_t responseLen) {
5762 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5765 if (radioService[slotId]->mRadioResponse != NULL) {
5766 RadioResponseInfo responseInfo = {};
5767 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5768 response, responseLen);
5770 Return<void> retStatus
5771 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5773 radioService[slotId]->checkReturnStatus(retStatus);
5775 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5782 int radio::getVoiceRadioTechnologyResponse(int slotId,
5783 int responseType, int serial, RIL_Errno e,
5784 void *response, size_t responseLen) {
5786 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5789 if (radioService[slotId]->mRadioResponse != NULL) {
5790 RadioResponseInfo responseInfo = {};
5791 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5792 Return<void> retStatus
5793 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5794 responseInfo, (RadioTechnology) ret);
5795 radioService[slotId]->checkReturnStatus(retStatus);
5797 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5804 int radio::getCellInfoListResponse(int slotId,
5806 int serial, RIL_Errno e, void *response,
5807 size_t responseLen) {
5809 RLOGD("getCellInfoListResponse: serial %d", serial);
5812 if (radioService[slotId]->mRadioResponse != NULL) {
5813 RadioResponseInfo responseInfo = {};
5814 populateResponseInfo(responseInfo, serial, responseType, e);
5816 hidl_vec<CellInfo> ret;
5817 if ((response == NULL && responseLen != 0)
5818 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5819 RLOGE("getCellInfoListResponse: Invalid response");
5820 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5822 convertRilCellInfoListToHal(response, responseLen, ret);
5825 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5827 radioService[slotId]->checkReturnStatus(retStatus);
5829 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5835 int radio::setCellInfoListRateResponse(int slotId,
5837 int serial, RIL_Errno e, void *response,
5838 size_t responseLen) {
5840 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5843 if (radioService[slotId]->mRadioResponse != NULL) {
5844 RadioResponseInfo responseInfo = {};
5845 populateResponseInfo(responseInfo, serial, responseType, e);
5846 Return<void> retStatus
5847 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5848 radioService[slotId]->checkReturnStatus(retStatus);
5850 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5857 int radio::setInitialAttachApnResponse(int slotId,
5858 int responseType, int serial, RIL_Errno e,
5859 void *response, size_t responseLen) {
5861 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5864 if (radioService[slotId]->mRadioResponse != NULL) {
5865 RadioResponseInfo responseInfo = {};
5866 populateResponseInfo(responseInfo, serial, responseType, e);
5867 Return<void> retStatus
5868 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5869 radioService[slotId]->checkReturnStatus(retStatus);
5871 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5878 int radio::getImsRegistrationStateResponse(int slotId,
5879 int responseType, int serial, RIL_Errno e,
5880 void *response, size_t responseLen) {
5882 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5885 if (radioService[slotId]->mRadioResponse != NULL) {
5886 RadioResponseInfo responseInfo = {};
5887 populateResponseInfo(responseInfo, serial, responseType, e);
5888 bool isRegistered = false;
5890 int numInts = responseLen / sizeof(int);
5891 if (response == NULL || numInts != 2) {
5892 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5893 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5895 int *pInt = (int *) response;
5896 isRegistered = pInt[0] == 1 ? true : false;
5897 ratFamily = pInt[1];
5899 Return<void> retStatus
5900 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5901 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5902 radioService[slotId]->checkReturnStatus(retStatus);
5904 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5911 int radio::sendImsSmsResponse(int slotId,
5912 int responseType, int serial, RIL_Errno e, void *response,
5913 size_t responseLen) {
5915 RLOGD("sendImsSmsResponse: serial %d", serial);
5918 if (radioService[slotId]->mRadioResponse != NULL) {
5919 RadioResponseInfo responseInfo = {};
5920 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5923 Return<void> retStatus
5924 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5925 radioService[slotId]->checkReturnStatus(retStatus);
5927 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5933 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5934 int responseType, int serial, RIL_Errno e,
5935 void *response, size_t responseLen) {
5937 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5940 if (radioService[slotId]->mRadioResponse != NULL) {
5941 RadioResponseInfo responseInfo = {};
5942 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5945 Return<void> retStatus
5946 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5947 responseInfo, result);
5948 radioService[slotId]->checkReturnStatus(retStatus);
5950 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5957 int radio::iccOpenLogicalChannelResponse(int slotId,
5958 int responseType, int serial, RIL_Errno e, void *response,
5959 size_t responseLen) {
5961 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5964 if (radioService[slotId]->mRadioResponse != NULL) {
5965 RadioResponseInfo responseInfo = {};
5966 populateResponseInfo(responseInfo, serial, responseType, e);
5968 hidl_vec<int8_t> selectResponse;
5969 int numInts = responseLen / sizeof(int);
5970 if (response == NULL || responseLen % sizeof(int) != 0) {
5971 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5972 if (response != NULL) {
5973 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5976 int *pInt = (int *) response;
5977 channelId = pInt[0];
5978 selectResponse.resize(numInts - 1);
5979 for (int i = 1; i < numInts; i++) {
5980 selectResponse[i - 1] = (int8_t) pInt[i];
5983 Return<void> retStatus
5984 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5985 channelId, selectResponse);
5986 radioService[slotId]->checkReturnStatus(retStatus);
5988 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5995 int radio::iccCloseLogicalChannelResponse(int slotId,
5996 int responseType, int serial, RIL_Errno e,
5997 void *response, size_t responseLen) {
5999 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
6002 if (radioService[slotId]->mRadioResponse != NULL) {
6003 RadioResponseInfo responseInfo = {};
6004 populateResponseInfo(responseInfo, serial, responseType, e);
6005 Return<void> retStatus
6006 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
6008 radioService[slotId]->checkReturnStatus(retStatus);
6010 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
6017 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
6018 int responseType, int serial, RIL_Errno e,
6019 void *response, size_t responseLen) {
6021 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
6024 if (radioService[slotId]->mRadioResponse != NULL) {
6025 RadioResponseInfo responseInfo = {};
6026 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6029 Return<void> retStatus
6030 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
6031 responseInfo, result);
6032 radioService[slotId]->checkReturnStatus(retStatus);
6034 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
6041 int radio::nvReadItemResponse(int slotId,
6042 int responseType, int serial, RIL_Errno e,
6043 void *response, size_t responseLen) {
6045 RLOGD("nvReadItemResponse: serial %d", serial);
6048 if (radioService[slotId]->mRadioResponse != NULL) {
6049 RadioResponseInfo responseInfo = {};
6050 populateResponseInfo(responseInfo, serial, responseType, e);
6051 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
6053 convertCharPtrToHidlString((char *) response));
6054 radioService[slotId]->checkReturnStatus(retStatus);
6056 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6062 int radio::nvWriteItemResponse(int slotId,
6063 int responseType, int serial, RIL_Errno e,
6064 void *response, size_t responseLen) {
6066 RLOGD("nvWriteItemResponse: serial %d", serial);
6069 if (radioService[slotId]->mRadioResponse != NULL) {
6070 RadioResponseInfo responseInfo = {};
6071 populateResponseInfo(responseInfo, serial, responseType, e);
6072 Return<void> retStatus
6073 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
6074 radioService[slotId]->checkReturnStatus(retStatus);
6076 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6082 int radio::nvWriteCdmaPrlResponse(int slotId,
6083 int responseType, int serial, RIL_Errno e,
6084 void *response, size_t responseLen) {
6086 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
6089 if (radioService[slotId]->mRadioResponse != NULL) {
6090 RadioResponseInfo responseInfo = {};
6091 populateResponseInfo(responseInfo, serial, responseType, e);
6092 Return<void> retStatus
6093 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
6094 radioService[slotId]->checkReturnStatus(retStatus);
6096 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6102 int radio::nvResetConfigResponse(int slotId,
6103 int responseType, int serial, RIL_Errno e,
6104 void *response, size_t responseLen) {
6106 RLOGD("nvResetConfigResponse: serial %d", serial);
6109 if (radioService[slotId]->mRadioResponse != NULL) {
6110 RadioResponseInfo responseInfo = {};
6111 populateResponseInfo(responseInfo, serial, responseType, e);
6112 Return<void> retStatus
6113 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
6114 radioService[slotId]->checkReturnStatus(retStatus);
6116 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6122 int radio::setUiccSubscriptionResponse(int slotId,
6123 int responseType, int serial, RIL_Errno e,
6124 void *response, size_t responseLen) {
6126 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
6129 if (radioService[slotId]->mRadioResponse != NULL) {
6130 RadioResponseInfo responseInfo = {};
6131 populateResponseInfo(responseInfo, serial, responseType, e);
6132 Return<void> retStatus
6133 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
6134 radioService[slotId]->checkReturnStatus(retStatus);
6136 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
6143 int radio::setDataAllowedResponse(int slotId,
6144 int responseType, int serial, RIL_Errno e,
6145 void *response, size_t responseLen) {
6147 RLOGD("setDataAllowedResponse: serial %d", serial);
6150 if (radioService[slotId]->mRadioResponse != NULL) {
6151 RadioResponseInfo responseInfo = {};
6152 populateResponseInfo(responseInfo, serial, responseType, e);
6153 Return<void> retStatus
6154 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
6155 radioService[slotId]->checkReturnStatus(retStatus);
6157 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6163 int radio::getHardwareConfigResponse(int slotId,
6164 int responseType, int serial, RIL_Errno e,
6165 void *response, size_t responseLen) {
6167 RLOGD("getHardwareConfigResponse: serial %d", serial);
6170 if (radioService[slotId]->mRadioResponse != NULL) {
6171 RadioResponseInfo responseInfo = {};
6172 populateResponseInfo(responseInfo, serial, responseType, e);
6174 hidl_vec<HardwareConfig> result;
6175 if ((response == NULL && responseLen != 0)
6176 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
6177 RLOGE("hardwareConfigChangedInd: invalid response");
6178 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6180 convertRilHardwareConfigListToHal(response, responseLen, result);
6183 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
6184 responseInfo, result);
6185 radioService[slotId]->checkReturnStatus(retStatus);
6187 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6193 int radio::requestIccSimAuthenticationResponse(int slotId,
6194 int responseType, int serial, RIL_Errno e,
6195 void *response, size_t responseLen) {
6197 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6200 if (radioService[slotId]->mRadioResponse != NULL) {
6201 RadioResponseInfo responseInfo = {};
6202 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6205 Return<void> retStatus
6206 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6207 responseInfo, result);
6208 radioService[slotId]->checkReturnStatus(retStatus);
6210 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6217 int radio::setDataProfileResponse(int slotId,
6218 int responseType, int serial, RIL_Errno e,
6219 void *response, size_t responseLen) {
6221 RLOGD("setDataProfileResponse: serial %d", serial);
6224 if (radioService[slotId]->mRadioResponse != NULL) {
6225 RadioResponseInfo responseInfo = {};
6226 populateResponseInfo(responseInfo, serial, responseType, e);
6227 Return<void> retStatus
6228 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6229 radioService[slotId]->checkReturnStatus(retStatus);
6231 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6237 int radio::requestShutdownResponse(int slotId,
6238 int responseType, int serial, RIL_Errno e,
6239 void *response, size_t responseLen) {
6241 RLOGD("requestShutdownResponse: serial %d", serial);
6244 if (radioService[slotId]->mRadioResponse != NULL) {
6245 RadioResponseInfo responseInfo = {};
6246 populateResponseInfo(responseInfo, serial, responseType, e);
6247 Return<void> retStatus
6248 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6249 radioService[slotId]->checkReturnStatus(retStatus);
6251 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6257 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6258 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6259 populateResponseInfo(responseInfo, serial, responseType, e);
6261 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6262 RLOGE("responseRadioCapability: Invalid response");
6263 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6264 rc.logicalModemUuid = hidl_string();
6266 convertRilRadioCapabilityToHal(response, responseLen, rc);
6270 int radio::getRadioCapabilityResponse(int slotId,
6271 int responseType, int serial, RIL_Errno e,
6272 void *response, size_t responseLen) {
6274 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6277 if (radioService[slotId]->mRadioResponse != NULL) {
6278 RadioResponseInfo responseInfo = {};
6279 RadioCapability result = {};
6280 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6282 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6283 responseInfo, result);
6284 radioService[slotId]->checkReturnStatus(retStatus);
6286 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6292 int radio::setRadioCapabilityResponse(int slotId,
6293 int responseType, int serial, RIL_Errno e,
6294 void *response, size_t responseLen) {
6296 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6299 if (radioService[slotId]->mRadioResponse != NULL) {
6300 RadioResponseInfo responseInfo = {};
6301 RadioCapability result = {};
6302 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6304 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6305 responseInfo, result);
6306 radioService[slotId]->checkReturnStatus(retStatus);
6308 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6314 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6315 RIL_Errno e, void *response, size_t responseLen) {
6316 populateResponseInfo(responseInfo, serial, responseType, e);
6317 LceStatusInfo result = {};
6319 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6320 RLOGE("Invalid response: NULL");
6321 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6323 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6324 result.lceStatus = (LceStatus) resp->lce_status;
6325 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6330 int radio::startLceServiceResponse(int slotId,
6331 int responseType, int serial, RIL_Errno e,
6332 void *response, size_t responseLen) {
6334 RLOGD("startLceServiceResponse: serial %d", serial);
6337 if (radioService[slotId]->mRadioResponse != NULL) {
6338 RadioResponseInfo responseInfo = {};
6339 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6340 response, responseLen);
6342 Return<void> retStatus
6343 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6345 radioService[slotId]->checkReturnStatus(retStatus);
6347 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6353 int radio::stopLceServiceResponse(int slotId,
6354 int responseType, int serial, RIL_Errno e,
6355 void *response, size_t responseLen) {
6357 RLOGD("stopLceServiceResponse: serial %d", serial);
6360 if (radioService[slotId]->mRadioResponse != NULL) {
6361 RadioResponseInfo responseInfo = {};
6362 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6363 response, responseLen);
6365 Return<void> retStatus
6366 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6368 radioService[slotId]->checkReturnStatus(retStatus);
6370 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6376 int radio::pullLceDataResponse(int slotId,
6377 int responseType, int serial, RIL_Errno e,
6378 void *response, size_t responseLen) {
6380 RLOGD("pullLceDataResponse: serial %d", serial);
6383 if (radioService[slotId]->mRadioResponse != NULL) {
6384 RadioResponseInfo responseInfo = {};
6385 populateResponseInfo(responseInfo, serial, responseType, e);
6387 LceDataInfo result = {};
6388 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6389 RLOGE("pullLceDataResponse: Invalid response");
6390 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6392 convertRilLceDataInfoToHal(response, responseLen, result);
6395 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6396 responseInfo, result);
6397 radioService[slotId]->checkReturnStatus(retStatus);
6399 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6405 int radio::getModemActivityInfoResponse(int slotId,
6406 int responseType, int serial, RIL_Errno e,
6407 void *response, size_t responseLen) {
6409 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6412 if (radioService[slotId]->mRadioResponse != NULL) {
6413 RadioResponseInfo responseInfo = {};
6414 populateResponseInfo(responseInfo, serial, responseType, e);
6415 ActivityStatsInfo info;
6416 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6417 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6418 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6420 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6421 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6422 info.idleModeTimeMs = resp->idle_mode_time_ms;
6423 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6424 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6426 info.rxModeTimeMs = resp->rx_mode_time_ms;
6429 Return<void> retStatus
6430 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6432 radioService[slotId]->checkReturnStatus(retStatus);
6434 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6441 int radio::setAllowedCarriersResponse(int slotId,
6442 int responseType, int serial, RIL_Errno e,
6443 void *response, size_t responseLen) {
6445 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6448 if (radioService[slotId]->mRadioResponse != NULL) {
6449 RadioResponseInfo responseInfo = {};
6450 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6451 Return<void> retStatus
6452 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6454 radioService[slotId]->checkReturnStatus(retStatus);
6456 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6463 int radio::getAllowedCarriersResponse(int slotId,
6464 int responseType, int serial, RIL_Errno e,
6465 void *response, size_t responseLen) {
6467 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6470 if (radioService[slotId]->mRadioResponse != NULL) {
6471 RadioResponseInfo responseInfo = {};
6472 populateResponseInfo(responseInfo, serial, responseType, e);
6473 CarrierRestrictions carrierInfo = {};
6474 bool allAllowed = true;
6475 if (response == NULL) {
6477 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6479 carrierInfo.allowedCarriers.resize(0);
6480 carrierInfo.excludedCarriers.resize(0);
6481 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6482 RLOGE("getAllowedCarriersResponse Invalid response");
6483 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6485 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6486 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6490 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6491 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6492 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6493 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6494 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6495 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6496 carrierInfo.allowedCarriers[i].matchData =
6497 convertCharPtrToHidlString(carrier->match_data);
6500 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6501 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6502 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6503 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6504 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6505 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6506 carrierInfo.excludedCarriers[i].matchData =
6507 convertCharPtrToHidlString(carrier->match_data);
6511 Return<void> retStatus
6512 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6513 allAllowed, carrierInfo);
6514 radioService[slotId]->checkReturnStatus(retStatus);
6516 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6523 int radio::sendDeviceStateResponse(int slotId,
6524 int responseType, int serial, RIL_Errno e,
6525 void *response, size_t responselen) {
6527 RLOGD("sendDeviceStateResponse: serial %d", serial);
6530 if (radioService[slotId]->mRadioResponse != NULL) {
6531 RadioResponseInfo responseInfo = {};
6532 populateResponseInfo(responseInfo, serial, responseType, e);
6533 Return<void> retStatus
6534 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6535 radioService[slotId]->checkReturnStatus(retStatus);
6537 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6543 int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
6544 int responseType, int serial, RIL_Errno e,
6545 void *response, size_t responseLen) {
6546 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
6547 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6548 RadioResponseInfo responseInfo = {};
6549 populateResponseInfo(responseInfo, serial, responseType, e);
6550 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6551 setCarrierInfoForImsiEncryptionResponse(responseInfo);
6552 radioService[slotId]->checkReturnStatus(retStatus);
6554 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponseV1_1 == "
6560 int radio::setIndicationFilterResponse(int slotId,
6561 int responseType, int serial, RIL_Errno e,
6562 void *response, size_t responselen) {
6564 RLOGD("setIndicationFilterResponse: serial %d", serial);
6567 if (radioService[slotId]->mRadioResponse != NULL) {
6568 RadioResponseInfo responseInfo = {};
6569 populateResponseInfo(responseInfo, serial, responseType, e);
6570 Return<void> retStatus
6571 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6572 radioService[slotId]->checkReturnStatus(retStatus);
6574 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6581 int radio::setSimCardPowerResponse(int slotId,
6582 int responseType, int serial, RIL_Errno e,
6583 void *response, size_t responseLen) {
6585 RLOGD("setSimCardPowerResponse: serial %d", serial);
6588 if (radioService[slotId]->mRadioResponse != NULL
6589 || radioService[slotId]->mRadioResponseV1_1 != NULL) {
6590 RadioResponseInfo responseInfo = {};
6591 populateResponseInfo(responseInfo, serial, responseType, e);
6592 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6593 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6594 setSimCardPowerResponse_1_1(responseInfo);
6595 radioService[slotId]->checkReturnStatus(retStatus);
6597 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_1 == NULL",
6599 Return<void> retStatus
6600 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6601 radioService[slotId]->checkReturnStatus(retStatus);
6604 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL && "
6605 "radioService[%d]->mRadioResponseV1_1 == NULL", slotId, slotId);
6610 int radio::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6611 void *response, size_t responseLen) {
6613 RLOGD("startNetworkScanResponse: serial %d", serial);
6616 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6617 RadioResponseInfo responseInfo = {};
6618 populateResponseInfo(responseInfo, serial, responseType, e);
6619 Return<void> retStatus
6620 = radioService[slotId]->mRadioResponseV1_1->startNetworkScanResponse(responseInfo);
6621 radioService[slotId]->checkReturnStatus(retStatus);
6623 RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6629 int radio::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6630 void *response, size_t responseLen) {
6632 RLOGD("stopNetworkScanResponse: serial %d", serial);
6635 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6636 RadioResponseInfo responseInfo = {};
6637 populateResponseInfo(responseInfo, serial, responseType, e);
6638 Return<void> retStatus
6639 = radioService[slotId]->mRadioResponseV1_1->stopNetworkScanResponse(responseInfo);
6640 radioService[slotId]->checkReturnStatus(retStatus);
6642 RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6648 void convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus *rilStatus,
6649 V1_1::KeepaliveStatus& halStatus) {
6650 halStatus.sessionHandle = rilStatus->sessionHandle;
6651 halStatus.code = static_cast<V1_1::KeepaliveStatusCode>(rilStatus->code);
6654 int radio::startKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
6655 void *response, size_t responseLen) {
6657 RLOGD("%s(): %d", __FUNCTION__, serial);
6659 RadioResponseInfo responseInfo = {};
6660 populateResponseInfo(responseInfo, serial, responseType, e);
6662 // If we don't have a radio service, there's nothing we can do
6663 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
6664 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
6668 V1_1::KeepaliveStatus ks = {};
6669 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
6670 RLOGE("%s: invalid response - %d", __FUNCTION__, static_cast<int>(e));
6671 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6673 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
6676 Return<void> retStatus =
6677 radioService[slotId]->mRadioResponseV1_1->startKeepaliveResponse(responseInfo, ks);
6678 radioService[slotId]->checkReturnStatus(retStatus);
6682 int radio::stopKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
6683 void *response, size_t responseLen) {
6685 RLOGD("%s(): %d", __FUNCTION__, serial);
6687 RadioResponseInfo responseInfo = {};
6688 populateResponseInfo(responseInfo, serial, responseType, e);
6690 // If we don't have a radio service, there's nothing we can do
6691 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
6692 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
6696 Return<void> retStatus =
6697 radioService[slotId]->mRadioResponseV1_1->stopKeepaliveResponse(responseInfo);
6698 radioService[slotId]->checkReturnStatus(retStatus);
6702 int radio::sendRequestRawResponse(int slotId,
6703 int responseType, int serial, RIL_Errno e,
6704 void *response, size_t responseLen) {
6706 RLOGD("sendRequestRawResponse: serial %d", serial);
6709 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6710 RadioResponseInfo responseInfo = {};
6711 populateResponseInfo(responseInfo, serial, responseType, e);
6712 hidl_vec<uint8_t> data;
6714 if (response == NULL) {
6715 RLOGE("sendRequestRawResponse: Invalid response");
6716 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6718 data.setToExternal((uint8_t *) response, responseLen);
6720 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6721 sendRequestRawResponse(responseInfo, data);
6722 checkReturnStatus(slotId, retStatus, false);
6724 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6731 int radio::sendRequestStringsResponse(int slotId,
6732 int responseType, int serial, RIL_Errno e,
6733 void *response, size_t responseLen) {
6735 RLOGD("sendRequestStringsResponse: serial %d", serial);
6738 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6739 RadioResponseInfo responseInfo = {};
6740 populateResponseInfo(responseInfo, serial, responseType, e);
6741 hidl_vec<hidl_string> data;
6743 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
6744 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6745 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6747 char **resp = (char **) response;
6748 int numStrings = responseLen / sizeof(char *);
6749 data.resize(numStrings);
6750 for (int i = 0; i < numStrings; i++) {
6751 data[i] = convertCharPtrToHidlString(resp[i]);
6754 Return<void> retStatus
6755 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6756 responseInfo, data);
6757 checkReturnStatus(slotId, retStatus, false);
6759 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6766 /***************************************************************************************************
6767 * INDICATION FUNCTIONS
6768 * The below function handle unsolicited messages coming from the Radio
6769 * (messages for which there is no pending request)
6770 **************************************************************************************************/
6772 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6773 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6774 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6777 int radio::radioStateChangedInd(int slotId,
6778 int indicationType, int token, RIL_Errno e, void *response,
6779 size_t responseLen) {
6780 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6781 RadioState radioState =
6782 (RadioState) CALL_ONSTATEREQUEST(slotId);
6783 RLOGD("radioStateChangedInd: radioState %d", radioState);
6784 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6785 convertIntToRadioIndicationType(indicationType), radioState);
6786 radioService[slotId]->checkReturnStatus(retStatus);
6788 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6794 int radio::callStateChangedInd(int slotId,
6795 int indicationType, int token, RIL_Errno e, void *response,
6796 size_t responseLen) {
6797 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6799 RLOGD("callStateChangedInd");
6801 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6802 convertIntToRadioIndicationType(indicationType));
6803 radioService[slotId]->checkReturnStatus(retStatus);
6805 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6811 int radio::networkStateChangedInd(int slotId,
6812 int indicationType, int token, RIL_Errno e, void *response,
6813 size_t responseLen) {
6814 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6816 RLOGD("networkStateChangedInd");
6818 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6819 convertIntToRadioIndicationType(indicationType));
6820 radioService[slotId]->checkReturnStatus(retStatus);
6822 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6829 uint8_t hexCharToInt(uint8_t c) {
6830 if (c >= '0' && c <= '9') return (c - '0');
6831 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6832 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6834 return INVALID_HEX_CHAR;
6837 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6838 if (responseLen % 2 != 0) {
6842 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6843 if (bytes == NULL) {
6844 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6847 uint8_t *hexString = (uint8_t *)response;
6849 for (size_t i = 0; i < responseLen; i += 2) {
6850 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6851 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6853 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6854 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6855 hexString[i], hexString[i + 1]);
6859 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6865 int radio::newSmsInd(int slotId, int indicationType,
6866 int token, RIL_Errno e, void *response, size_t responseLen) {
6867 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6868 if (response == NULL || responseLen == 0) {
6869 RLOGE("newSmsInd: invalid response");
6873 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6874 if (bytes == NULL) {
6875 RLOGE("newSmsInd: convertHexStringToBytes failed");
6879 hidl_vec<uint8_t> pdu;
6880 pdu.setToExternal(bytes, responseLen/2);
6884 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6885 convertIntToRadioIndicationType(indicationType), pdu);
6886 radioService[slotId]->checkReturnStatus(retStatus);
6889 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6895 int radio::newSmsStatusReportInd(int slotId,
6896 int indicationType, int token, RIL_Errno e, void *response,
6897 size_t responseLen) {
6898 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6899 if (response == NULL || responseLen == 0) {
6900 RLOGE("newSmsStatusReportInd: invalid response");
6904 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6905 if (bytes == NULL) {
6906 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6910 hidl_vec<uint8_t> pdu;
6911 pdu.setToExternal(bytes, responseLen/2);
6913 RLOGD("newSmsStatusReportInd");
6915 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6916 convertIntToRadioIndicationType(indicationType), pdu);
6917 radioService[slotId]->checkReturnStatus(retStatus);
6920 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6926 int radio::newSmsOnSimInd(int slotId, int indicationType,
6927 int token, RIL_Errno e, void *response, size_t responseLen) {
6928 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6929 if (response == NULL || responseLen != sizeof(int)) {
6930 RLOGE("newSmsOnSimInd: invalid response");
6933 int32_t recordNumber = ((int32_t *) response)[0];
6935 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6937 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6938 convertIntToRadioIndicationType(indicationType), recordNumber);
6939 radioService[slotId]->checkReturnStatus(retStatus);
6941 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6947 int radio::onUssdInd(int slotId, int indicationType,
6948 int token, RIL_Errno e, void *response, size_t responseLen) {
6949 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6950 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6951 RLOGE("onUssdInd: invalid response");
6954 char **strings = (char **) response;
6955 char *mode = strings[0];
6956 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6957 UssdModeType modeType = (UssdModeType) atoi(mode);
6959 RLOGD("onUssdInd: mode %s", mode);
6961 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6962 convertIntToRadioIndicationType(indicationType), modeType, msg);
6963 radioService[slotId]->checkReturnStatus(retStatus);
6965 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6971 int radio::nitzTimeReceivedInd(int slotId,
6972 int indicationType, int token, RIL_Errno e, void *response,
6973 size_t responseLen) {
6974 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6975 if (response == NULL || responseLen == 0) {
6976 RLOGE("nitzTimeReceivedInd: invalid response");
6979 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6980 int64_t timeReceived = android::elapsedRealtime();
6982 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6985 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6986 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6987 radioService[slotId]->checkReturnStatus(retStatus);
6989 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6996 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6997 SignalStrength& signalStrength) {
6998 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
7000 // Fixup LTE for backwards compatibility
7001 // signalStrength: -1 -> 99
7002 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
7003 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
7005 // rsrp: -1 -> INT_MAX all other negative value to positive.
7007 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
7008 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
7009 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
7010 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
7012 // rsrq: -1 -> INT_MAX
7013 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
7014 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
7016 // Not remapping rssnr is already using INT_MAX
7017 // cqi: -1 -> INT_MAX
7018 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
7019 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
7022 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
7023 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
7024 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
7025 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
7026 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
7027 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
7028 signalStrength.evdo.signalNoiseRatio =
7029 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
7030 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
7031 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
7032 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
7033 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
7034 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
7035 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
7036 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
7039 int radio::currentSignalStrengthInd(int slotId,
7040 int indicationType, int token, RIL_Errno e,
7041 void *response, size_t responseLen) {
7042 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7043 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
7044 RLOGE("currentSignalStrengthInd: invalid response");
7048 SignalStrength signalStrength = {};
7049 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
7052 RLOGD("currentSignalStrengthInd");
7054 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
7055 convertIntToRadioIndicationType(indicationType), signalStrength);
7056 radioService[slotId]->checkReturnStatus(retStatus);
7058 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
7065 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
7066 SetupDataCallResult& dcResult) {
7067 dcResult.status = (DataCallFailCause) dcResponse->status;
7068 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
7069 dcResult.cid = dcResponse->cid;
7070 dcResult.active = dcResponse->active;
7071 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
7072 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
7073 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
7074 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
7075 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
7076 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
7077 dcResult.mtu = dcResponse->mtu;
7080 void convertRilDataCallListToHal(void *response, size_t responseLen,
7081 hidl_vec<SetupDataCallResult>& dcResultList) {
7082 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
7084 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
7085 dcResultList.resize(num);
7086 for (int i = 0; i < num; i++) {
7087 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
7091 int radio::dataCallListChangedInd(int slotId,
7092 int indicationType, int token, RIL_Errno e, void *response,
7093 size_t responseLen) {
7094 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7095 if ((response == NULL && responseLen != 0)
7096 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
7097 RLOGE("dataCallListChangedInd: invalid response");
7100 hidl_vec<SetupDataCallResult> dcList;
7101 convertRilDataCallListToHal(response, responseLen, dcList);
7103 RLOGD("dataCallListChangedInd");
7105 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
7106 convertIntToRadioIndicationType(indicationType), dcList);
7107 radioService[slotId]->checkReturnStatus(retStatus);
7109 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7115 int radio::suppSvcNotifyInd(int slotId, int indicationType,
7116 int token, RIL_Errno e, void *response, size_t responseLen) {
7117 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7118 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
7119 RLOGE("suppSvcNotifyInd: invalid response");
7123 SuppSvcNotification suppSvc = {};
7124 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
7125 suppSvc.isMT = ssn->notificationType;
7126 suppSvc.code = ssn->code;
7127 suppSvc.index = ssn->index;
7128 suppSvc.type = ssn->type;
7129 suppSvc.number = convertCharPtrToHidlString(ssn->number);
7132 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
7133 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
7135 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
7136 convertIntToRadioIndicationType(indicationType), suppSvc);
7137 radioService[slotId]->checkReturnStatus(retStatus);
7139 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7145 int radio::stkSessionEndInd(int slotId, int indicationType,
7146 int token, RIL_Errno e, void *response, size_t responseLen) {
7147 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7149 RLOGD("stkSessionEndInd");
7151 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
7152 convertIntToRadioIndicationType(indicationType));
7153 radioService[slotId]->checkReturnStatus(retStatus);
7155 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
7161 int radio::stkProactiveCommandInd(int slotId,
7162 int indicationType, int token, RIL_Errno e, void *response,
7163 size_t responseLen) {
7164 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7165 if (response == NULL || responseLen == 0) {
7166 RLOGE("stkProactiveCommandInd: invalid response");
7170 RLOGD("stkProactiveCommandInd");
7172 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
7173 convertIntToRadioIndicationType(indicationType),
7174 convertCharPtrToHidlString((char *) response));
7175 radioService[slotId]->checkReturnStatus(retStatus);
7177 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
7183 int radio::stkEventNotifyInd(int slotId, int indicationType,
7184 int token, RIL_Errno e, void *response, size_t responseLen) {
7185 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7186 if (response == NULL || responseLen == 0) {
7187 RLOGE("stkEventNotifyInd: invalid response");
7191 RLOGD("stkEventNotifyInd");
7193 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
7194 convertIntToRadioIndicationType(indicationType),
7195 convertCharPtrToHidlString((char *) response));
7196 radioService[slotId]->checkReturnStatus(retStatus);
7198 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7204 int radio::stkCallSetupInd(int slotId, int indicationType,
7205 int token, RIL_Errno e, void *response, size_t responseLen) {
7206 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7207 if (response == NULL || responseLen != sizeof(int)) {
7208 RLOGE("stkCallSetupInd: invalid response");
7211 int32_t timeout = ((int32_t *) response)[0];
7213 RLOGD("stkCallSetupInd: timeout %d", timeout);
7215 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
7216 convertIntToRadioIndicationType(indicationType), timeout);
7217 radioService[slotId]->checkReturnStatus(retStatus);
7219 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
7225 int radio::simSmsStorageFullInd(int slotId,
7226 int indicationType, int token, RIL_Errno e, void *response,
7227 size_t responseLen) {
7228 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7230 RLOGD("simSmsStorageFullInd");
7232 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
7233 convertIntToRadioIndicationType(indicationType));
7234 radioService[slotId]->checkReturnStatus(retStatus);
7236 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
7242 int radio::simRefreshInd(int slotId, int indicationType,
7243 int token, RIL_Errno e, void *response, size_t responseLen) {
7244 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7245 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
7246 RLOGE("simRefreshInd: invalid response");
7250 SimRefreshResult refreshResult = {};
7251 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
7252 refreshResult.type =
7253 (V1_0::SimRefreshType) simRefreshResponse->result;
7254 refreshResult.efId = simRefreshResponse->ef_id;
7255 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
7258 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
7260 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
7261 convertIntToRadioIndicationType(indicationType), refreshResult);
7262 radioService[slotId]->checkReturnStatus(retStatus);
7264 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
7270 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
7271 CdmaSignalInfoRecord& record) {
7272 record.isPresent = signalInfoRecord->isPresent;
7273 record.signalType = signalInfoRecord->signalType;
7274 record.alertPitch = signalInfoRecord->alertPitch;
7275 record.signal = signalInfoRecord->signal;
7278 int radio::callRingInd(int slotId, int indicationType,
7279 int token, RIL_Errno e, void *response, size_t responseLen) {
7280 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7282 CdmaSignalInfoRecord record = {};
7283 if (response == NULL || responseLen == 0) {
7287 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
7288 RLOGE("callRingInd: invalid response");
7291 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
7295 RLOGD("callRingInd: isGsm %d", isGsm);
7297 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
7298 convertIntToRadioIndicationType(indicationType), isGsm, record);
7299 radioService[slotId]->checkReturnStatus(retStatus);
7301 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7307 int radio::simStatusChangedInd(int slotId,
7308 int indicationType, int token, RIL_Errno e, void *response,
7309 size_t responseLen) {
7310 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7312 RLOGD("simStatusChangedInd");
7314 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7315 convertIntToRadioIndicationType(indicationType));
7316 radioService[slotId]->checkReturnStatus(retStatus);
7318 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7324 int radio::cdmaNewSmsInd(int slotId, int indicationType,
7325 int token, RIL_Errno e, void *response, size_t responseLen) {
7326 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7327 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7328 RLOGE("cdmaNewSmsInd: invalid response");
7332 CdmaSmsMessage msg = {};
7333 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7334 msg.teleserviceId = rilMsg->uTeleserviceID;
7335 msg.isServicePresent = rilMsg->bIsServicePresent;
7336 msg.serviceCategory = rilMsg->uServicecategory;
7337 msg.address.digitMode =
7338 (V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7339 msg.address.numberMode =
7340 (V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7341 msg.address.numberType =
7342 (V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7343 msg.address.numberPlan =
7344 (V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7346 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7347 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7349 msg.subAddress.subaddressType = (V1_0::CdmaSmsSubaddressType)
7350 rilMsg->sSubAddress.subaddressType;
7351 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7353 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7354 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7356 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7357 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7360 RLOGD("cdmaNewSmsInd");
7362 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7363 convertIntToRadioIndicationType(indicationType), msg);
7364 radioService[slotId]->checkReturnStatus(retStatus);
7366 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7372 int radio::newBroadcastSmsInd(int slotId,
7373 int indicationType, int token, RIL_Errno e, void *response,
7374 size_t responseLen) {
7375 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7376 if (response == NULL || responseLen == 0) {
7377 RLOGE("newBroadcastSmsInd: invalid response");
7381 hidl_vec<uint8_t> data;
7382 data.setToExternal((uint8_t *) response, responseLen);
7384 RLOGD("newBroadcastSmsInd");
7386 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7387 convertIntToRadioIndicationType(indicationType), data);
7388 radioService[slotId]->checkReturnStatus(retStatus);
7390 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7396 int radio::cdmaRuimSmsStorageFullInd(int slotId,
7397 int indicationType, int token, RIL_Errno e, void *response,
7398 size_t responseLen) {
7399 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7401 RLOGD("cdmaRuimSmsStorageFullInd");
7403 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7404 convertIntToRadioIndicationType(indicationType));
7405 radioService[slotId]->checkReturnStatus(retStatus);
7407 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7414 int radio::restrictedStateChangedInd(int slotId,
7415 int indicationType, int token, RIL_Errno e, void *response,
7416 size_t responseLen) {
7417 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7418 if (response == NULL || responseLen != sizeof(int)) {
7419 RLOGE("restrictedStateChangedInd: invalid response");
7422 int32_t state = ((int32_t *) response)[0];
7424 RLOGD("restrictedStateChangedInd: state %d", state);
7426 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7427 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7428 radioService[slotId]->checkReturnStatus(retStatus);
7430 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7437 int radio::enterEmergencyCallbackModeInd(int slotId,
7438 int indicationType, int token, RIL_Errno e, void *response,
7439 size_t responseLen) {
7440 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7442 RLOGD("enterEmergencyCallbackModeInd");
7444 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7445 convertIntToRadioIndicationType(indicationType));
7446 radioService[slotId]->checkReturnStatus(retStatus);
7448 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7455 int radio::cdmaCallWaitingInd(int slotId,
7456 int indicationType, int token, RIL_Errno e, void *response,
7457 size_t responseLen) {
7458 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7459 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7460 RLOGE("cdmaCallWaitingInd: invalid response");
7464 CdmaCallWaiting callWaitingRecord = {};
7465 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7466 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7467 callWaitingRecord.numberPresentation =
7468 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7469 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7470 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7471 callWaitingRecord.signalInfoRecord);
7472 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7473 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7476 RLOGD("cdmaCallWaitingInd");
7478 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7479 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7480 radioService[slotId]->checkReturnStatus(retStatus);
7482 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7488 int radio::cdmaOtaProvisionStatusInd(int slotId,
7489 int indicationType, int token, RIL_Errno e, void *response,
7490 size_t responseLen) {
7491 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7492 if (response == NULL || responseLen != sizeof(int)) {
7493 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7496 int32_t status = ((int32_t *) response)[0];
7498 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7500 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7501 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7502 radioService[slotId]->checkReturnStatus(retStatus);
7504 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7511 int radio::cdmaInfoRecInd(int slotId,
7512 int indicationType, int token, RIL_Errno e, void *response,
7513 size_t responseLen) {
7514 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7515 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7516 RLOGE("cdmaInfoRecInd: invalid response");
7520 CdmaInformationRecords records = {};
7521 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7523 char* string8 = NULL;
7524 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7525 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7526 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7527 "additional ones", recordsRil->numberOfInfoRecs,
7528 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7530 records.infoRec.resize(num);
7531 for (int i = 0 ; i < num ; i++) {
7532 CdmaInformationRecord *record = &records.infoRec[i];
7533 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7534 record->name = (CdmaInfoRecName) infoRec->name;
7535 // All vectors should be size 0 except one which will be size 1. Set everything to
7536 // size 0 initially.
7537 record->display.resize(0);
7538 record->number.resize(0);
7539 record->signal.resize(0);
7540 record->redir.resize(0);
7541 record->lineCtrl.resize(0);
7542 record->clir.resize(0);
7543 record->audioCtrl.resize(0);
7544 switch (infoRec->name) {
7545 case RIL_CDMA_DISPLAY_INFO_REC:
7546 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7547 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7548 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7549 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7550 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7553 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7554 if (string8 == NULL) {
7555 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7556 "responseCdmaInformationRecords");
7559 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7560 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7562 record->display.resize(1);
7563 record->display[0].alphaBuf = string8;
7569 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7570 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7571 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7572 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7573 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7574 "expected not more than %d", (int) infoRec->rec.number.len,
7575 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7578 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7579 if (string8 == NULL) {
7580 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7581 "responseCdmaInformationRecords");
7584 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7585 string8[(int)infoRec->rec.number.len] = '\0';
7587 record->number.resize(1);
7588 record->number[0].number = string8;
7591 record->number[0].numberType = infoRec->rec.number.number_type;
7592 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7593 record->number[0].pi = infoRec->rec.number.pi;
7594 record->number[0].si = infoRec->rec.number.si;
7598 case RIL_CDMA_SIGNAL_INFO_REC: {
7599 record->signal.resize(1);
7600 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7601 record->signal[0].signalType = infoRec->rec.signal.signalType;
7602 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7603 record->signal[0].signal = infoRec->rec.signal.signal;
7607 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7608 if (infoRec->rec.redir.redirectingNumber.len >
7609 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7610 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7611 "expected not more than %d\n",
7612 (int)infoRec->rec.redir.redirectingNumber.len,
7613 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7616 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7618 if (string8 == NULL) {
7619 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7620 "responseCdmaInformationRecords");
7623 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7624 infoRec->rec.redir.redirectingNumber.len);
7625 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7627 record->redir.resize(1);
7628 record->redir[0].redirectingNumber.number = string8;
7631 record->redir[0].redirectingNumber.numberType =
7632 infoRec->rec.redir.redirectingNumber.number_type;
7633 record->redir[0].redirectingNumber.numberPlan =
7634 infoRec->rec.redir.redirectingNumber.number_plan;
7635 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7636 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7637 record->redir[0].redirectingReason =
7638 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7642 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7643 record->lineCtrl.resize(1);
7644 record->lineCtrl[0].lineCtrlPolarityIncluded =
7645 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7646 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7647 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7648 record->lineCtrl[0].lineCtrlPowerDenial =
7649 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7653 case RIL_CDMA_T53_CLIR_INFO_REC: {
7654 record->clir.resize(1);
7655 record->clir[0].cause = infoRec->rec.clir.cause;
7659 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7660 record->audioCtrl.resize(1);
7661 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7662 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7666 case RIL_CDMA_T53_RELEASE_INFO_REC:
7667 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7671 RLOGE("cdmaInfoRecInd: Incorrect name value");
7677 RLOGD("cdmaInfoRecInd");
7679 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7680 convertIntToRadioIndicationType(indicationType), records);
7681 radioService[slotId]->checkReturnStatus(retStatus);
7683 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7689 int radio::indicateRingbackToneInd(int slotId,
7690 int indicationType, int token, RIL_Errno e, void *response,
7691 size_t responseLen) {
7692 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7693 if (response == NULL || responseLen != sizeof(int)) {
7694 RLOGE("indicateRingbackToneInd: invalid response");
7697 bool start = ((int32_t *) response)[0];
7699 RLOGD("indicateRingbackToneInd: start %d", start);
7701 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7702 convertIntToRadioIndicationType(indicationType), start);
7703 radioService[slotId]->checkReturnStatus(retStatus);
7705 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7711 int radio::resendIncallMuteInd(int slotId,
7712 int indicationType, int token, RIL_Errno e, void *response,
7713 size_t responseLen) {
7714 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7716 RLOGD("resendIncallMuteInd");
7718 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7719 convertIntToRadioIndicationType(indicationType));
7720 radioService[slotId]->checkReturnStatus(retStatus);
7722 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7728 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7729 int indicationType, int token, RIL_Errno e,
7730 void *response, size_t responseLen) {
7731 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7732 if (response == NULL || responseLen != sizeof(int)) {
7733 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7736 int32_t cdmaSource = ((int32_t *) response)[0];
7738 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7740 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7741 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7742 (CdmaSubscriptionSource) cdmaSource);
7743 radioService[slotId]->checkReturnStatus(retStatus);
7745 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7752 int radio::cdmaPrlChangedInd(int slotId,
7753 int indicationType, int token, RIL_Errno e, void *response,
7754 size_t responseLen) {
7755 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7756 if (response == NULL || responseLen != sizeof(int)) {
7757 RLOGE("cdmaPrlChangedInd: invalid response");
7760 int32_t version = ((int32_t *) response)[0];
7762 RLOGD("cdmaPrlChangedInd: version %d", version);
7764 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7765 convertIntToRadioIndicationType(indicationType), version);
7766 radioService[slotId]->checkReturnStatus(retStatus);
7768 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7774 int radio::exitEmergencyCallbackModeInd(int slotId,
7775 int indicationType, int token, RIL_Errno e, void *response,
7776 size_t responseLen) {
7777 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7779 RLOGD("exitEmergencyCallbackModeInd");
7781 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7782 convertIntToRadioIndicationType(indicationType));
7783 radioService[slotId]->checkReturnStatus(retStatus);
7785 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7792 int radio::rilConnectedInd(int slotId,
7793 int indicationType, int token, RIL_Errno e, void *response,
7794 size_t responseLen) {
7795 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7796 RLOGD("rilConnectedInd");
7797 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7798 convertIntToRadioIndicationType(indicationType));
7799 radioService[slotId]->checkReturnStatus(retStatus);
7801 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7807 int radio::voiceRadioTechChangedInd(int slotId,
7808 int indicationType, int token, RIL_Errno e, void *response,
7809 size_t responseLen) {
7810 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7811 if (response == NULL || responseLen != sizeof(int)) {
7812 RLOGE("voiceRadioTechChangedInd: invalid response");
7815 int32_t rat = ((int32_t *) response)[0];
7817 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7819 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7820 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7821 radioService[slotId]->checkReturnStatus(retStatus);
7823 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7830 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7831 int num = responseLen / sizeof(RIL_CellInfo_v12);
7832 records.resize(num);
7834 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7835 for (int i = 0; i < num; i++) {
7836 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7837 records[i].registered = rillCellInfo->registered;
7838 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7839 records[i].timeStamp = rillCellInfo->timeStamp;
7840 // All vectors should be size 0 except one which will be size 1. Set everything to
7841 // size 0 initially.
7842 records[i].gsm.resize(0);
7843 records[i].wcdma.resize(0);
7844 records[i].cdma.resize(0);
7845 records[i].lte.resize(0);
7846 records[i].tdscdma.resize(0);
7847 switch(rillCellInfo->cellInfoType) {
7848 case RIL_CELL_INFO_TYPE_GSM: {
7849 records[i].gsm.resize(1);
7850 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7851 cellInfoGsm->cellIdentityGsm.mcc =
7852 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7853 cellInfoGsm->cellIdentityGsm.mnc =
7854 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7855 cellInfoGsm->cellIdentityGsm.lac =
7856 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7857 cellInfoGsm->cellIdentityGsm.cid =
7858 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7859 cellInfoGsm->cellIdentityGsm.arfcn =
7860 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7861 cellInfoGsm->cellIdentityGsm.bsic =
7862 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7863 cellInfoGsm->signalStrengthGsm.signalStrength =
7864 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7865 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7866 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7867 cellInfoGsm->signalStrengthGsm.timingAdvance =
7868 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7872 case RIL_CELL_INFO_TYPE_WCDMA: {
7873 records[i].wcdma.resize(1);
7874 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7875 cellInfoWcdma->cellIdentityWcdma.mcc =
7876 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7877 cellInfoWcdma->cellIdentityWcdma.mnc =
7878 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7879 cellInfoWcdma->cellIdentityWcdma.lac =
7880 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7881 cellInfoWcdma->cellIdentityWcdma.cid =
7882 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7883 cellInfoWcdma->cellIdentityWcdma.psc =
7884 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7885 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7886 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7887 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7888 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7889 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7890 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7894 case RIL_CELL_INFO_TYPE_CDMA: {
7895 records[i].cdma.resize(1);
7896 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7897 cellInfoCdma->cellIdentityCdma.networkId =
7898 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7899 cellInfoCdma->cellIdentityCdma.systemId =
7900 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7901 cellInfoCdma->cellIdentityCdma.baseStationId =
7902 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7903 cellInfoCdma->cellIdentityCdma.longitude =
7904 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7905 cellInfoCdma->cellIdentityCdma.latitude =
7906 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7907 cellInfoCdma->signalStrengthCdma.dbm =
7908 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7909 cellInfoCdma->signalStrengthCdma.ecio =
7910 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7911 cellInfoCdma->signalStrengthEvdo.dbm =
7912 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7913 cellInfoCdma->signalStrengthEvdo.ecio =
7914 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7915 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7916 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7920 case RIL_CELL_INFO_TYPE_LTE: {
7921 records[i].lte.resize(1);
7922 CellInfoLte *cellInfoLte = &records[i].lte[0];
7923 cellInfoLte->cellIdentityLte.mcc =
7924 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7925 cellInfoLte->cellIdentityLte.mnc =
7926 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7927 cellInfoLte->cellIdentityLte.ci =
7928 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7929 cellInfoLte->cellIdentityLte.pci =
7930 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7931 cellInfoLte->cellIdentityLte.tac =
7932 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7933 cellInfoLte->cellIdentityLte.earfcn =
7934 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7935 cellInfoLte->signalStrengthLte.signalStrength =
7936 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7937 cellInfoLte->signalStrengthLte.rsrp =
7938 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7939 cellInfoLte->signalStrengthLte.rsrq =
7940 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7941 cellInfoLte->signalStrengthLte.rssnr =
7942 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7943 cellInfoLte->signalStrengthLte.cqi =
7944 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7945 cellInfoLte->signalStrengthLte.timingAdvance =
7946 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7950 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7951 records[i].tdscdma.resize(1);
7952 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7953 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7954 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7955 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7956 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7957 cellInfoTdscdma->cellIdentityTdscdma.lac =
7958 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7959 cellInfoTdscdma->cellIdentityTdscdma.cid =
7960 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7961 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7962 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7963 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7964 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7975 int radio::cellInfoListInd(int slotId,
7976 int indicationType, int token, RIL_Errno e, void *response,
7977 size_t responseLen) {
7978 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7979 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7980 RLOGE("cellInfoListInd: invalid response");
7984 hidl_vec<CellInfo> records;
7985 convertRilCellInfoListToHal(response, responseLen, records);
7988 RLOGD("cellInfoListInd");
7990 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7991 convertIntToRadioIndicationType(indicationType), records);
7992 radioService[slotId]->checkReturnStatus(retStatus);
7994 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
8000 int radio::imsNetworkStateChangedInd(int slotId,
8001 int indicationType, int token, RIL_Errno e, void *response,
8002 size_t responseLen) {
8003 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8005 RLOGD("imsNetworkStateChangedInd");
8007 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
8008 convertIntToRadioIndicationType(indicationType));
8009 radioService[slotId]->checkReturnStatus(retStatus);
8011 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
8018 int radio::subscriptionStatusChangedInd(int slotId,
8019 int indicationType, int token, RIL_Errno e, void *response,
8020 size_t responseLen) {
8021 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8022 if (response == NULL || responseLen != sizeof(int)) {
8023 RLOGE("subscriptionStatusChangedInd: invalid response");
8026 bool activate = ((int32_t *) response)[0];
8028 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
8030 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
8031 convertIntToRadioIndicationType(indicationType), activate);
8032 radioService[slotId]->checkReturnStatus(retStatus);
8034 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
8041 int radio::srvccStateNotifyInd(int slotId,
8042 int indicationType, int token, RIL_Errno e, void *response,
8043 size_t responseLen) {
8044 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8045 if (response == NULL || responseLen != sizeof(int)) {
8046 RLOGE("srvccStateNotifyInd: invalid response");
8049 int32_t state = ((int32_t *) response)[0];
8051 RLOGD("srvccStateNotifyInd: rat %d", state);
8053 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
8054 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
8055 radioService[slotId]->checkReturnStatus(retStatus);
8057 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
8063 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
8064 hidl_vec<HardwareConfig>& records) {
8065 int num = responseLen / sizeof(RIL_HardwareConfig);
8066 records.resize(num);
8068 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
8069 for (int i = 0; i < num; i++) {
8070 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
8071 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
8072 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
8073 switch (rilHardwareConfig[i].type) {
8074 case RIL_HARDWARE_CONFIG_MODEM: {
8075 records[i].modem.resize(1);
8076 records[i].sim.resize(0);
8077 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
8078 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
8079 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
8080 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
8081 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
8085 case RIL_HARDWARE_CONFIG_SIM: {
8086 records[i].sim.resize(1);
8087 records[i].modem.resize(0);
8088 records[i].sim[0].modemUuid =
8089 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
8096 int radio::hardwareConfigChangedInd(int slotId,
8097 int indicationType, int token, RIL_Errno e, void *response,
8098 size_t responseLen) {
8099 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8100 if ((response == NULL && responseLen != 0)
8101 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
8102 RLOGE("hardwareConfigChangedInd: invalid response");
8106 hidl_vec<HardwareConfig> configs;
8107 convertRilHardwareConfigListToHal(response, responseLen, configs);
8110 RLOGD("hardwareConfigChangedInd");
8112 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
8113 convertIntToRadioIndicationType(indicationType), configs);
8114 radioService[slotId]->checkReturnStatus(retStatus);
8116 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
8123 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
8124 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
8125 rc.session = rilRadioCapability->session;
8126 rc.phase = (V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
8127 rc.raf = rilRadioCapability->rat;
8128 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
8129 rc.status = (V1_0::RadioCapabilityStatus) rilRadioCapability->status;
8132 int radio::radioCapabilityIndicationInd(int slotId,
8133 int indicationType, int token, RIL_Errno e, void *response,
8134 size_t responseLen) {
8135 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8136 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
8137 RLOGE("radioCapabilityIndicationInd: invalid response");
8141 RadioCapability rc = {};
8142 convertRilRadioCapabilityToHal(response, responseLen, rc);
8145 RLOGD("radioCapabilityIndicationInd");
8147 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
8148 convertIntToRadioIndicationType(indicationType), rc);
8149 radioService[slotId]->checkReturnStatus(retStatus);
8151 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
8158 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
8159 if ((reqType == SS_INTERROGATION) &&
8160 (serType == SS_CFU ||
8161 serType == SS_CF_BUSY ||
8162 serType == SS_CF_NO_REPLY ||
8163 serType == SS_CF_NOT_REACHABLE ||
8164 serType == SS_CF_ALL ||
8165 serType == SS_CF_ALL_CONDITIONAL)) {
8171 int radio::onSupplementaryServiceIndicationInd(int slotId,
8172 int indicationType, int token, RIL_Errno e,
8173 void *response, size_t responseLen) {
8174 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8175 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
8176 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
8180 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
8181 StkCcUnsolSsResult ss = {};
8182 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
8183 ss.requestType = (SsRequestType) rilSsResponse->requestType;
8184 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
8185 ss.serviceClass = rilSsResponse->serviceClass;
8186 ss.result = (RadioError) rilSsResponse->result;
8188 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
8190 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
8191 rilSsResponse->cfData.numValidIndexes);
8193 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
8194 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
8195 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
8196 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
8199 ss.cfData.resize(1);
8200 ss.ssInfo.resize(0);
8202 /* number of call info's */
8203 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
8205 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
8206 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
8207 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
8209 cfInfo->status = (CallForwardInfoStatus) cf.status;
8210 cfInfo->reason = cf.reason;
8211 cfInfo->serviceClass = cf.serviceClass;
8212 cfInfo->toa = cf.toa;
8213 cfInfo->number = convertCharPtrToHidlString(cf.number);
8214 cfInfo->timeSeconds = cf.timeSeconds;
8216 RLOGD("onSupplementaryServiceIndicationInd: "
8217 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
8218 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
8222 ss.ssInfo.resize(1);
8223 ss.cfData.resize(0);
8226 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
8227 for (int i = 0; i < SS_INFO_MAX; i++) {
8229 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
8230 rilSsResponse->ssInfo[i]);
8232 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
8237 RLOGD("onSupplementaryServiceIndicationInd");
8239 Return<void> retStatus = radioService[slotId]->mRadioIndication->
8240 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
8242 radioService[slotId]->checkReturnStatus(retStatus);
8244 RLOGE("onSupplementaryServiceIndicationInd: "
8245 "radioService[%d]->mRadioIndication == NULL", slotId);
8251 int radio::stkCallControlAlphaNotifyInd(int slotId,
8252 int indicationType, int token, RIL_Errno e, void *response,
8253 size_t responseLen) {
8254 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8255 if (response == NULL || responseLen == 0) {
8256 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
8260 RLOGD("stkCallControlAlphaNotifyInd");
8262 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
8263 convertIntToRadioIndicationType(indicationType),
8264 convertCharPtrToHidlString((char *) response));
8265 radioService[slotId]->checkReturnStatus(retStatus);
8267 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
8274 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
8275 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
8276 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
8277 lce.confidenceLevel = rilLceDataInfo->confidence_level;
8278 lce.lceSuspended = rilLceDataInfo->lce_suspended;
8281 int radio::lceDataInd(int slotId,
8282 int indicationType, int token, RIL_Errno e, void *response,
8283 size_t responseLen) {
8284 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8285 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
8286 RLOGE("lceDataInd: invalid response");
8290 LceDataInfo lce = {};
8291 convertRilLceDataInfoToHal(response, responseLen, lce);
8293 RLOGD("lceDataInd");
8295 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
8296 convertIntToRadioIndicationType(indicationType), lce);
8297 radioService[slotId]->checkReturnStatus(retStatus);
8299 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8305 int radio::pcoDataInd(int slotId,
8306 int indicationType, int token, RIL_Errno e, void *response,
8307 size_t responseLen) {
8308 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8309 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8310 RLOGE("pcoDataInd: invalid response");
8314 PcoDataInfo pco = {};
8315 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8316 pco.cid = rilPcoData->cid;
8317 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8318 pco.pcoId = rilPcoData->pco_id;
8319 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8322 RLOGD("pcoDataInd");
8324 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8325 convertIntToRadioIndicationType(indicationType), pco);
8326 radioService[slotId]->checkReturnStatus(retStatus);
8328 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8334 int radio::modemResetInd(int slotId,
8335 int indicationType, int token, RIL_Errno e, void *response,
8336 size_t responseLen) {
8337 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8338 if (response == NULL || responseLen == 0) {
8339 RLOGE("modemResetInd: invalid response");
8343 RLOGD("modemResetInd");
8345 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8346 convertIntToRadioIndicationType(indicationType),
8347 convertCharPtrToHidlString((char *) response));
8348 radioService[slotId]->checkReturnStatus(retStatus);
8350 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8356 int radio::networkScanResultInd(int slotId,
8357 int indicationType, int token, RIL_Errno e, void *response,
8358 size_t responseLen) {
8360 RLOGD("networkScanResultInd");
8362 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8363 if (response == NULL || responseLen == 0) {
8364 RLOGE("networkScanResultInd: invalid response");
8367 RLOGD("networkScanResultInd");
8370 RLOGD("networkScanResultInd");
8373 RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
8375 V1_1::NetworkScanResult result;
8376 result.status = (V1_1::ScanStatus) networkScanResult->status;
8377 result.error = (RadioError) e;
8378 convertRilCellInfoListToHal(
8379 networkScanResult->network_infos,
8380 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
8381 result.networkInfos);
8383 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->networkScanResult(
8384 convertIntToRadioIndicationType(indicationType), result);
8385 radioService[slotId]->checkReturnStatus(retStatus);
8387 RLOGE("networkScanResultInd: radioService[%d]->mRadioIndicationV1_1 == NULL", slotId);
8392 int radio::carrierInfoForImsiEncryption(int slotId,
8393 int indicationType, int token, RIL_Errno e, void *response,
8394 size_t responseLen) {
8395 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8396 if (response == NULL || responseLen == 0) {
8397 RLOGE("carrierInfoForImsiEncryption: invalid response");
8400 RLOGD("carrierInfoForImsiEncryption");
8401 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->
8402 carrierInfoForImsiEncryption(convertIntToRadioIndicationType(indicationType));
8403 radioService[slotId]->checkReturnStatus(retStatus);
8405 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndicationV1_1 == NULL",
8412 int radio::keepaliveStatusInd(int slotId,
8413 int indicationType, int token, RIL_Errno e, void *response,
8414 size_t responseLen) {
8416 RLOGD("%s(): token=%d", __FUNCTION__, token);
8418 if (radioService[slotId] == NULL || radioService[slotId]->mRadioIndication == NULL) {
8419 RLOGE("%s: radioService[%d]->mRadioIndication == NULL", __FUNCTION__, slotId);
8423 auto ret = V1_1::IRadioIndication::castFrom(
8424 radioService[slotId]->mRadioIndication);
8426 RLOGE("%s: ret.isOk() == false for radioService[%d]", __FUNCTION__, slotId);
8429 sp<V1_1::IRadioIndication> radioIndicationV1_1 = ret;
8431 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
8432 RLOGE("%s: invalid response", __FUNCTION__);
8436 V1_1::KeepaliveStatus ks;
8437 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
8439 Return<void> retStatus = radioIndicationV1_1->keepaliveStatus(
8440 convertIntToRadioIndicationType(indicationType), ks);
8441 radioService[slotId]->checkReturnStatus(retStatus);
8445 int radio::oemHookRawInd(int slotId,
8446 int indicationType, int token, RIL_Errno e, void *response,
8447 size_t responseLen) {
8448 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8449 if (response == NULL || responseLen == 0) {
8450 RLOGE("oemHookRawInd: invalid response");
8454 hidl_vec<uint8_t> data;
8455 data.setToExternal((uint8_t *) response, responseLen);
8457 RLOGD("oemHookRawInd");
8459 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8460 convertIntToRadioIndicationType(indicationType), data);
8461 checkReturnStatus(slotId, retStatus, false);
8463 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8469 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8470 using namespace android::hardware;
8472 const char *serviceNames[] = {
8473 android::RIL_getServiceName()
8474 #if (SIM_COUNT >= 2)
8476 #if (SIM_COUNT >= 3)
8478 #if (SIM_COUNT >= 4)
8485 #if (SIM_COUNT >= 2)
8486 simCount = SIM_COUNT;
8489 configureRpcThreadpool(1, true /* callerWillJoin */);
8490 for (int i = 0; i < simCount; i++) {
8491 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8492 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8495 radioService[i] = new RadioImpl;
8496 radioService[i]->mSlotId = i;
8497 oemHookService[i] = new OemHookImpl;
8498 oemHookService[i]->mSlotId = i;
8499 RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
8501 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8502 status = oemHookService[i]->registerAsService(serviceNames[i]);
8504 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8508 s_vendorFunctions = callbacks;
8509 s_commands = commands;
8512 void rilc_thread_pool() {
8513 joinRpcThreadpool();
8516 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8517 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8519 #if (SIM_COUNT >= 2)
8520 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8521 #if (SIM_COUNT >= 3)
8522 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8523 #if (SIM_COUNT >= 4)
8524 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8529 return radioServiceRwlockPtr;