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::radio::V1_1::NetworkScanRequest;
45 using ::android::hardware::radio::V1_1::KeepaliveRequest;
46 using ::android::hardware::Void;
47 using android::CommandInfo;
48 using android::RequestInfo;
49 using android::requestToString;
52 #define BOOL_TO_INT(x) (x ? 1 : 0)
53 #define ATOI_NULL_HANDLED(x) (x ? atoi(x) : -1)
54 #define ATOI_NULL_HANDLED_DEF(x, defaultVal) (x ? atoi(x) : defaultVal)
56 #if defined(ANDROID_MULTI_SIM)
57 #define CALL_ONREQUEST(a, b, c, d, e) \
58 s_vendorFunctions->onRequest((a), (b), (c), (d), ((RIL_SOCKET_ID)(e)))
59 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest((RIL_SOCKET_ID)(a))
61 #define CALL_ONREQUEST(a, b, c, d, e) s_vendorFunctions->onRequest((a), (b), (c), (d))
62 #define CALL_ONSTATEREQUEST(a) s_vendorFunctions->onStateRequest()
65 RIL_RadioFunctions *s_vendorFunctions = NULL;
66 static CommandInfo *s_commands;
72 sp<RadioImpl> radioService[SIM_COUNT];
73 sp<OemHookImpl> oemHookService[SIM_COUNT];
74 // counter used for synchronization. It is incremented every time response callbacks are updated.
75 volatile int32_t mCounterRadio[SIM_COUNT];
76 volatile int32_t mCounterOemHook[SIM_COUNT];
78 sp<RadioImpl> radioService[1];
79 sp<OemHookImpl> oemHookService[1];
80 // counter used for synchronization. It is incremented every time response callbacks are updated.
81 volatile int32_t mCounterRadio[1];
82 volatile int32_t mCounterOemHook[1];
85 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
88 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
90 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
92 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
97 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
98 hidl_vec<HardwareConfig>& records);
100 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
102 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
104 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
105 SignalStrength& signalStrength);
107 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
108 SetupDataCallResult& dcResult);
110 void convertRilDataCallListToHal(void *response, size_t responseLen,
111 hidl_vec<SetupDataCallResult>& dcResultList);
113 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
115 struct RadioImpl : public V1_1::IRadio {
117 sp<IRadioResponse> mRadioResponse;
118 sp<IRadioIndication> mRadioIndication;
119 sp<V1_1::IRadioResponse> mRadioResponseV1_1;
120 sp<V1_1::IRadioIndication> mRadioIndicationV1_1;
122 Return<void> setResponseFunctions(
123 const ::android::sp<IRadioResponse>& radioResponse,
124 const ::android::sp<IRadioIndication>& radioIndication);
126 Return<void> getIccCardStatus(int32_t serial);
128 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
129 const hidl_string& aid);
131 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
132 const hidl_string& pin, const hidl_string& aid);
134 Return<void> supplyIccPin2ForApp(int32_t serial,
135 const hidl_string& pin2,
136 const hidl_string& aid);
138 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
139 const hidl_string& pin2, const hidl_string& aid);
141 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
142 const hidl_string& newPin, const hidl_string& aid);
144 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
145 const hidl_string& newPin2, const hidl_string& aid);
147 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
149 Return<void> getCurrentCalls(int32_t serial);
151 Return<void> dial(int32_t serial, const Dial& dialInfo);
153 Return<void> getImsiForApp(int32_t serial,
154 const ::android::hardware::hidl_string& aid);
156 Return<void> hangup(int32_t serial, int32_t gsmIndex);
158 Return<void> hangupWaitingOrBackground(int32_t serial);
160 Return<void> hangupForegroundResumeBackground(int32_t serial);
162 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
164 Return<void> conference(int32_t serial);
166 Return<void> rejectCall(int32_t serial);
168 Return<void> getLastCallFailCause(int32_t serial);
170 Return<void> getSignalStrength(int32_t serial);
172 Return<void> getVoiceRegistrationState(int32_t serial);
174 Return<void> getDataRegistrationState(int32_t serial);
176 Return<void> getOperator(int32_t serial);
178 Return<void> setRadioPower(int32_t serial, bool on);
180 Return<void> sendDtmf(int32_t serial,
181 const ::android::hardware::hidl_string& s);
183 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
185 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
187 Return<void> setupDataCall(int32_t serial,
188 RadioTechnology radioTechnology,
189 const DataProfileInfo& profileInfo,
194 Return<void> iccIOForApp(int32_t serial,
197 Return<void> sendUssd(int32_t serial,
198 const ::android::hardware::hidl_string& ussd);
200 Return<void> cancelPendingUssd(int32_t serial);
202 Return<void> getClir(int32_t serial);
204 Return<void> setClir(int32_t serial, int32_t status);
206 Return<void> getCallForwardStatus(int32_t serial,
207 const CallForwardInfo& callInfo);
209 Return<void> setCallForward(int32_t serial,
210 const CallForwardInfo& callInfo);
212 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
214 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
216 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
217 bool success, SmsAcknowledgeFailCause cause);
219 Return<void> acceptCall(int32_t serial);
221 Return<void> deactivateDataCall(int32_t serial,
222 int32_t cid, bool reasonRadioShutDown);
224 Return<void> getFacilityLockForApp(int32_t serial,
225 const ::android::hardware::hidl_string& facility,
226 const ::android::hardware::hidl_string& password,
227 int32_t serviceClass,
228 const ::android::hardware::hidl_string& appId);
230 Return<void> setFacilityLockForApp(int32_t serial,
231 const ::android::hardware::hidl_string& facility,
233 const ::android::hardware::hidl_string& password,
234 int32_t serviceClass,
235 const ::android::hardware::hidl_string& appId);
237 Return<void> setBarringPassword(int32_t serial,
238 const ::android::hardware::hidl_string& facility,
239 const ::android::hardware::hidl_string& oldPassword,
240 const ::android::hardware::hidl_string& newPassword);
242 Return<void> getNetworkSelectionMode(int32_t serial);
244 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
246 Return<void> setNetworkSelectionModeManual(int32_t serial,
247 const ::android::hardware::hidl_string& operatorNumeric);
249 Return<void> getAvailableNetworks(int32_t serial);
251 Return<void> startNetworkScan(int32_t serial, const NetworkScanRequest& request);
253 Return<void> stopNetworkScan(int32_t serial);
255 Return<void> startDtmf(int32_t serial,
256 const ::android::hardware::hidl_string& s);
258 Return<void> stopDtmf(int32_t serial);
260 Return<void> getBasebandVersion(int32_t serial);
262 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
264 Return<void> setMute(int32_t serial, bool enable);
266 Return<void> getMute(int32_t serial);
268 Return<void> getClip(int32_t serial);
270 Return<void> getDataCallList(int32_t serial);
272 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
274 Return<void> writeSmsToSim(int32_t serial,
275 const SmsWriteArgs& smsWriteArgs);
277 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
279 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
281 Return<void> getAvailableBandModes(int32_t serial);
283 Return<void> sendEnvelope(int32_t serial,
284 const ::android::hardware::hidl_string& command);
286 Return<void> sendTerminalResponseToSim(int32_t serial,
287 const ::android::hardware::hidl_string& commandResponse);
289 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
291 Return<void> explicitCallTransfer(int32_t serial);
293 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
295 Return<void> getPreferredNetworkType(int32_t serial);
297 Return<void> getNeighboringCids(int32_t serial);
299 Return<void> setLocationUpdates(int32_t serial, bool enable);
301 Return<void> setCdmaSubscriptionSource(int32_t serial,
302 CdmaSubscriptionSource cdmaSub);
304 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
306 Return<void> getCdmaRoamingPreference(int32_t serial);
308 Return<void> setTTYMode(int32_t serial, TtyMode mode);
310 Return<void> getTTYMode(int32_t serial);
312 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
314 Return<void> getPreferredVoicePrivacy(int32_t serial);
316 Return<void> sendCDMAFeatureCode(int32_t serial,
317 const ::android::hardware::hidl_string& featureCode);
319 Return<void> sendBurstDtmf(int32_t serial,
320 const ::android::hardware::hidl_string& dtmf,
324 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
326 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
327 const CdmaSmsAck& smsAck);
329 Return<void> getGsmBroadcastConfig(int32_t serial);
331 Return<void> setGsmBroadcastConfig(int32_t serial,
332 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
334 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
336 Return<void> getCdmaBroadcastConfig(int32_t serial);
338 Return<void> setCdmaBroadcastConfig(int32_t serial,
339 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
341 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
343 Return<void> getCDMASubscription(int32_t serial);
345 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
347 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
349 Return<void> getDeviceIdentity(int32_t serial);
351 Return<void> exitEmergencyCallbackMode(int32_t serial);
353 Return<void> getSmscAddress(int32_t serial);
355 Return<void> setSmscAddress(int32_t serial,
356 const ::android::hardware::hidl_string& smsc);
358 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
360 Return<void> reportStkServiceIsRunning(int32_t serial);
362 Return<void> getCdmaSubscriptionSource(int32_t serial);
364 Return<void> requestIsimAuthentication(int32_t serial,
365 const ::android::hardware::hidl_string& challenge);
367 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
369 const ::android::hardware::hidl_string& ackPdu);
371 Return<void> sendEnvelopeWithStatus(int32_t serial,
372 const ::android::hardware::hidl_string& contents);
374 Return<void> getVoiceRadioTechnology(int32_t serial);
376 Return<void> getCellInfoList(int32_t serial);
378 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
380 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
381 bool modemCognitive, bool isRoaming);
383 Return<void> getImsRegistrationState(int32_t serial);
385 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
387 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
389 Return<void> iccOpenLogicalChannel(int32_t serial,
390 const ::android::hardware::hidl_string& aid, int32_t p2);
392 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
394 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
396 Return<void> nvReadItem(int32_t serial, NvItem itemId);
398 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
400 Return<void> nvWriteCdmaPrl(int32_t serial,
401 const ::android::hardware::hidl_vec<uint8_t>& prl);
403 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
405 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
407 Return<void> setDataAllowed(int32_t serial, bool allow);
409 Return<void> getHardwareConfig(int32_t serial);
411 Return<void> requestIccSimAuthentication(int32_t serial,
413 const ::android::hardware::hidl_string& authData,
414 const ::android::hardware::hidl_string& aid);
416 Return<void> setDataProfile(int32_t serial,
417 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
419 Return<void> requestShutdown(int32_t serial);
421 Return<void> getRadioCapability(int32_t serial);
423 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
425 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
427 Return<void> stopLceService(int32_t serial);
429 Return<void> pullLceData(int32_t serial);
431 Return<void> getModemActivityInfo(int32_t serial);
433 Return<void> setAllowedCarriers(int32_t serial,
435 const CarrierRestrictions& carriers);
437 Return<void> getAllowedCarriers(int32_t serial);
439 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
441 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
443 Return<void> startKeepalive(int32_t serial, const KeepaliveRequest& keepalive);
445 Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
447 Return<void> setSimCardPower(int32_t serial, bool powerUp);
448 Return<void> setSimCardPower_1_1(int32_t serial,
449 const V1_1::CardPowerState state);
451 Return<void> responseAcknowledgement();
453 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
454 const ::android::hardware::radio::V1_1::ImsiEncryptionInfo& message);
456 void checkReturnStatus(Return<void>& ret);
459 struct OemHookImpl : public IOemHook {
461 sp<IOemHookResponse> mOemHookResponse;
462 sp<IOemHookIndication> mOemHookIndication;
464 Return<void> setResponseFunctions(
465 const ::android::sp<IOemHookResponse>& oemHookResponse,
466 const ::android::sp<IOemHookIndication>& oemHookIndication);
468 Return<void> sendRequestRaw(int32_t serial,
469 const ::android::hardware::hidl_vec<uint8_t>& data);
471 Return<void> sendRequestStrings(int32_t serial,
472 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
475 void memsetAndFreeStrings(int numPointers, ...) {
477 va_start(ap, numPointers);
478 for (int i = 0; i < numPointers; i++) {
479 char *ptr = va_arg(ap, char *);
482 #define MAX_STRING_LENGTH 4096
483 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
491 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
492 pRI->pCI->responseFunction((int) pRI->socket_id,
493 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
497 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
498 * request with error RIL_E_NO_MEMORY.
499 * Returns true on success, and false on failure.
501 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
502 size_t len = src.size();
507 *dest = (char *) calloc(len + 1, sizeof(char));
509 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
510 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
513 strncpy(*dest, src.c_str(), len + 1);
517 hidl_string convertCharPtrToHidlString(const char *ptr) {
520 // TODO: replace this with strnlen
521 ret.setToExternal(ptr, strlen(ptr));
526 bool dispatchVoid(int serial, int slotId, int request) {
527 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
531 CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
535 bool dispatchString(int serial, int slotId, int request, const char * str) {
536 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
542 if (!copyHidlStringToRil(&pString, str, pRI)) {
546 CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
548 memsetAndFreeStrings(1, pString);
552 bool dispatchStrings(int serial, int slotId, int request, int countStrings, ...) {
553 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
559 pStrings = (char **)calloc(countStrings, sizeof(char *));
560 if (pStrings == NULL) {
561 RLOGE("Memory allocation failed for request %s", requestToString(request));
562 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
566 va_start(ap, countStrings);
567 for (int i = 0; i < countStrings; i++) {
568 const char* str = va_arg(ap, const char *);
569 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI)) {
571 for (int j = 0; j < i; j++) {
572 memsetAndFreeStrings(1, pStrings[j]);
580 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
582 if (pStrings != NULL) {
583 for (int i = 0 ; i < countStrings ; i++) {
584 memsetAndFreeStrings(1, pStrings[i]);
588 memset(pStrings, 0, countStrings * sizeof(char *));
595 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
596 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
601 int countStrings = data.size();
603 pStrings = (char **)calloc(countStrings, sizeof(char *));
604 if (pStrings == NULL) {
605 RLOGE("Memory allocation failed for request %s", requestToString(request));
606 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
610 for (int i = 0; i < countStrings; i++) {
611 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
612 for (int j = 0; j < i; j++) {
613 memsetAndFreeStrings(1, pStrings[j]);
620 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
622 if (pStrings != NULL) {
623 for (int i = 0 ; i < countStrings ; i++) {
624 memsetAndFreeStrings(1, pStrings[i]);
628 memset(pStrings, 0, countStrings * sizeof(char *));
635 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
636 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
641 int *pInts = (int *)calloc(countInts, sizeof(int));
644 RLOGE("Memory allocation failed for request %s", requestToString(request));
645 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
649 va_start(ap, countInts);
650 for (int i = 0; i < countInts; i++) {
651 pInts[i] = va_arg(ap, int);
655 CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
659 memset(pInts, 0, countInts * sizeof(int));
666 bool dispatchCallForwardStatus(int serial, int slotId, int request,
667 const CallForwardInfo& callInfo) {
668 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
673 RIL_CallForwardInfo cf;
674 cf.status = (int) callInfo.status;
675 cf.reason = callInfo.reason;
676 cf.serviceClass = callInfo.serviceClass;
677 cf.toa = callInfo.toa;
678 cf.timeSeconds = callInfo.timeSeconds;
680 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
684 CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
686 memsetAndFreeStrings(1, cf.number);
691 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
692 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
697 const uint8_t *uData = rawBytes.data();
699 CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
704 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
705 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
710 RIL_SIM_APDU apdu = {};
712 apdu.sessionid = message.sessionId;
713 apdu.cla = message.cla;
714 apdu.instruction = message.instruction;
715 apdu.p1 = message.p1;
716 apdu.p2 = message.p2;
717 apdu.p3 = message.p3;
719 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
723 CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
725 memsetAndFreeStrings(1, apdu.data);
730 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
731 if (ret.isOk() == false) {
732 RLOGE("checkReturnStatus: unable to call response/indication callback");
733 // Remote process hosting the callbacks must be dead. Reset the callback objects;
734 // there's no other recovery to be done here. When the client process is back up, it will
735 // call setResponseFunctions()
737 // Caller should already hold rdlock, release that first
738 // note the current counter to avoid overwriting updates made by another thread before
739 // write lock is acquired.
740 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
741 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
742 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
746 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
749 // make sure the counter value has not changed
750 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
751 if (isRadioService) {
752 radioService[slotId]->mRadioResponse = NULL;
753 radioService[slotId]->mRadioIndication = NULL;
754 radioService[slotId]->mRadioResponseV1_1 = NULL;
755 radioService[slotId]->mRadioIndicationV1_1 = NULL;
757 oemHookService[slotId]->mOemHookResponse = NULL;
758 oemHookService[slotId]->mOemHookIndication = NULL;
760 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
762 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
763 "got updated on another thread");
767 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
771 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
776 void RadioImpl::checkReturnStatus(Return<void>& ret) {
777 ::checkReturnStatus(mSlotId, ret, true);
780 Return<void> RadioImpl::setResponseFunctions(
781 const ::android::sp<IRadioResponse>& radioResponseParam,
782 const ::android::sp<IRadioIndication>& radioIndicationParam) {
783 RLOGD("setResponseFunctions");
785 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
786 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
789 mRadioResponse = radioResponseParam;
790 mRadioIndication = radioIndicationParam;
791 mRadioResponseV1_1 = V1_1::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
792 mRadioIndicationV1_1 = V1_1::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
793 if (mRadioResponseV1_1 == nullptr || mRadioIndicationV1_1 == nullptr) {
794 mRadioResponseV1_1 = nullptr;
795 mRadioIndicationV1_1 = nullptr;
798 mCounterRadio[mSlotId]++;
800 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
803 // client is connected. Send initial indications.
804 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
809 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
811 RLOGD("getIccCardStatus: serial %d", serial);
813 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
817 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
818 const hidl_string& aid) {
820 RLOGD("supplyIccPinForApp: serial %d", serial);
822 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN,
823 2, pin.c_str(), aid.c_str());
827 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
828 const hidl_string& pin, const hidl_string& aid) {
830 RLOGD("supplyIccPukForApp: serial %d", serial);
832 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK,
833 3, puk.c_str(), pin.c_str(), aid.c_str());
837 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
838 const hidl_string& aid) {
840 RLOGD("supplyIccPin2ForApp: serial %d", serial);
842 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2,
843 2, pin2.c_str(), aid.c_str());
847 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
848 const hidl_string& pin2, const hidl_string& aid) {
850 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
852 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2,
853 3, puk2.c_str(), pin2.c_str(), aid.c_str());
857 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
858 const hidl_string& newPin, const hidl_string& aid) {
860 RLOGD("changeIccPinForApp: serial %d", serial);
862 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN,
863 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
867 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
868 const hidl_string& newPin2, const hidl_string& aid) {
870 RLOGD("changeIccPin2ForApp: serial %d", serial);
872 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2,
873 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
877 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
878 const hidl_string& netPin) {
880 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
882 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION,
887 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
889 RLOGD("getCurrentCalls: serial %d", serial);
891 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
895 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
897 RLOGD("dial: serial %d", serial);
899 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
904 RIL_UUS_Info uusInfo = {};
905 int32_t sizeOfDial = sizeof(dial);
907 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
910 dial.clir = (int) dialInfo.clir;
912 if (dialInfo.uusInfo.size() != 0) {
913 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
914 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
916 if (dialInfo.uusInfo[0].uusData.size() == 0) {
917 uusInfo.uusData = NULL;
918 uusInfo.uusLength = 0;
920 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
921 memsetAndFreeStrings(1, dial.address);
924 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
927 dial.uusInfo = &uusInfo;
930 CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
932 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
937 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
939 RLOGD("getImsiForApp: serial %d", serial);
941 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI,
946 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
948 RLOGD("hangup: serial %d", serial);
950 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
954 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
956 RLOGD("hangupWaitingOrBackground: serial %d", serial);
958 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
962 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
964 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
966 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
970 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
972 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
974 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
978 Return<void> RadioImpl::conference(int32_t serial) {
980 RLOGD("conference: serial %d", serial);
982 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
986 Return<void> RadioImpl::rejectCall(int32_t serial) {
988 RLOGD("rejectCall: serial %d", serial);
990 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
994 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
996 RLOGD("getLastCallFailCause: serial %d", serial);
998 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
1002 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
1004 RLOGD("getSignalStrength: serial %d", serial);
1006 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
1010 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
1012 RLOGD("getVoiceRegistrationState: serial %d", serial);
1014 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
1018 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
1020 RLOGD("getDataRegistrationState: serial %d", serial);
1022 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1026 Return<void> RadioImpl::getOperator(int32_t serial) {
1028 RLOGD("getOperator: serial %d", serial);
1030 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1034 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
1035 RLOGD("setRadioPower: serial %d on %d", serial, on);
1036 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1040 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1042 RLOGD("sendDtmf: serial %d", serial);
1044 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1048 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1050 RLOGD("sendSms: serial %d", serial);
1052 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS,
1053 2, message.smscPdu.c_str(), message.pdu.c_str());
1057 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1059 RLOGD("sendSMSExpectMore: serial %d", serial);
1061 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE,
1062 2, message.smscPdu.c_str(), message.pdu.c_str());
1066 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1068 case MvnoType::IMSI:
1069 str = (char *)"imsi";
1072 str = (char *)"gid";
1075 str = (char *)"spn";
1077 case MvnoType::NONE:
1084 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1085 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1086 bool roamingAllowed, bool isRoaming) {
1089 RLOGD("setupDataCall: serial %d", serial);
1092 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1093 const hidl_string &protocol =
1094 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1095 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 7,
1096 std::to_string((int) radioTechnology + 2).c_str(),
1097 std::to_string((int) dataProfileInfo.profileId).c_str(),
1098 dataProfileInfo.apn.c_str(),
1099 dataProfileInfo.user.c_str(),
1100 dataProfileInfo.password.c_str(),
1101 std::to_string((int) dataProfileInfo.authType).c_str(),
1103 } else if (s_vendorFunctions->version >= 15) {
1104 char *mvnoTypeStr = NULL;
1105 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1106 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1107 RIL_REQUEST_SETUP_DATA_CALL);
1109 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1113 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, 15,
1114 std::to_string((int) radioTechnology + 2).c_str(),
1115 std::to_string((int) dataProfileInfo.profileId).c_str(),
1116 dataProfileInfo.apn.c_str(),
1117 dataProfileInfo.user.c_str(),
1118 dataProfileInfo.password.c_str(),
1119 std::to_string((int) dataProfileInfo.authType).c_str(),
1120 dataProfileInfo.protocol.c_str(),
1121 dataProfileInfo.roamingProtocol.c_str(),
1122 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1123 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1124 modemCognitive ? "1" : "0",
1125 std::to_string(dataProfileInfo.mtu).c_str(),
1127 dataProfileInfo.mvnoMatchData.c_str(),
1128 roamingAllowed ? "1" : "0");
1130 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1131 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1132 RIL_REQUEST_SETUP_DATA_CALL);
1134 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1140 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1142 RLOGD("iccIOForApp: serial %d", serial);
1144 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1149 RIL_SIM_IO_v6 rilIccIo = {};
1150 rilIccIo.command = iccIo.command;
1151 rilIccIo.fileid = iccIo.fileId;
1152 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1156 rilIccIo.p1 = iccIo.p1;
1157 rilIccIo.p2 = iccIo.p2;
1158 rilIccIo.p3 = iccIo.p3;
1160 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1161 memsetAndFreeStrings(1, rilIccIo.path);
1165 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1166 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1170 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1171 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1175 CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1177 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1182 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1184 RLOGD("sendUssd: serial %d", serial);
1186 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1190 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1192 RLOGD("cancelPendingUssd: serial %d", serial);
1194 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1198 Return<void> RadioImpl::getClir(int32_t serial) {
1200 RLOGD("getClir: serial %d", serial);
1202 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1206 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1208 RLOGD("setClir: serial %d", serial);
1210 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1214 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1216 RLOGD("getCallForwardStatus: serial %d", serial);
1218 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1223 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1225 RLOGD("setCallForward: serial %d", serial);
1227 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1232 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1234 RLOGD("getCallWaiting: serial %d", serial);
1236 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1240 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1242 RLOGD("setCallWaiting: serial %d", serial);
1244 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1249 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1250 bool success, SmsAcknowledgeFailCause cause) {
1252 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1254 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1259 Return<void> RadioImpl::acceptCall(int32_t serial) {
1261 RLOGD("acceptCall: serial %d", serial);
1263 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1267 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1268 int32_t cid, bool reasonRadioShutDown) {
1270 RLOGD("deactivateDataCall: serial %d", serial);
1272 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL,
1273 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1277 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1278 const hidl_string& password, int32_t serviceClass,
1279 const hidl_string& appId) {
1281 RLOGD("getFacilityLockForApp: serial %d", serial);
1283 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK,
1284 4, facility.c_str(), password.c_str(),
1285 (std::to_string(serviceClass)).c_str(), appId.c_str());
1289 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1290 bool lockState, const hidl_string& password,
1291 int32_t serviceClass, const hidl_string& appId) {
1293 RLOGD("setFacilityLockForApp: serial %d", serial);
1295 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK,
1296 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1297 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1301 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1302 const hidl_string& oldPassword,
1303 const hidl_string& newPassword) {
1305 RLOGD("setBarringPassword: serial %d", serial);
1307 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD,
1308 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1312 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1314 RLOGD("getNetworkSelectionMode: serial %d", serial);
1316 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1320 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1322 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1324 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1328 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1329 const hidl_string& operatorNumeric) {
1331 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1333 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1334 operatorNumeric.c_str());
1338 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1340 RLOGD("getAvailableNetworks: serial %d", serial);
1342 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1346 Return<void> RadioImpl::startNetworkScan(int32_t serial, const NetworkScanRequest& request) {
1348 RLOGD("startNetworkScan: serial %d", serial);
1351 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1356 if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
1357 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1361 RIL_NetworkScanRequest scan_request = {};
1363 scan_request.type = (RIL_ScanType) request.type;
1364 scan_request.interval = request.interval;
1365 scan_request.specifiers_length = request.specifiers.size();
1366 for (size_t i = 0; i < request.specifiers.size(); ++i) {
1367 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
1368 request.specifiers[i].utranBands.size() > MAX_BANDS ||
1369 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
1370 request.specifiers[i].channels.size() > MAX_CHANNELS) {
1371 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1374 const V1_1::RadioAccessSpecifier& ras_from =
1375 request.specifiers[i];
1376 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
1378 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
1379 ras_to.channels_length = ras_from.channels.size();
1381 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
1382 const std::vector<uint32_t> * bands = nullptr;
1383 switch (request.specifiers[i].radioAccessNetwork) {
1384 case V1_1::RadioAccessNetworks::GERAN:
1385 ras_to.bands_length = ras_from.geranBands.size();
1386 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
1388 case V1_1::RadioAccessNetworks::UTRAN:
1389 ras_to.bands_length = ras_from.utranBands.size();
1390 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
1392 case V1_1::RadioAccessNetworks::EUTRAN:
1393 ras_to.bands_length = ras_from.eutranBands.size();
1394 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
1397 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1400 // safe to copy to geran_bands because it's a union member
1401 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
1402 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
1406 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
1412 Return<void> RadioImpl::stopNetworkScan(int32_t serial) {
1414 RLOGD("stopNetworkScan: serial %d", serial);
1416 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1420 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1422 RLOGD("startDtmf: serial %d", serial);
1424 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1429 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1431 RLOGD("stopDtmf: serial %d", serial);
1433 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1437 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1439 RLOGD("getBasebandVersion: serial %d", serial);
1441 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1445 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1447 RLOGD("separateConnection: serial %d", serial);
1449 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1453 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1455 RLOGD("setMute: serial %d", serial);
1457 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1461 Return<void> RadioImpl::getMute(int32_t serial) {
1463 RLOGD("getMute: serial %d", serial);
1465 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1469 Return<void> RadioImpl::getClip(int32_t serial) {
1471 RLOGD("getClip: serial %d", serial);
1473 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1477 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1479 RLOGD("getDataCallList: serial %d", serial);
1481 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1485 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1487 RLOGD("setSuppServiceNotifications: serial %d", serial);
1489 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1490 BOOL_TO_INT(enable));
1494 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1496 RLOGD("writeSmsToSim: serial %d", serial);
1498 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1503 RIL_SMS_WriteArgs args;
1504 args.status = (int) smsWriteArgs.status;
1506 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1510 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1511 memsetAndFreeStrings(1, args.pdu);
1515 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
1517 memsetAndFreeStrings(2, args.smsc, args.pdu);
1522 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1524 RLOGD("deleteSmsOnSim: serial %d", serial);
1526 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1530 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1532 RLOGD("setBandMode: serial %d", serial);
1534 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1538 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1540 RLOGD("getAvailableBandModes: serial %d", serial);
1542 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1546 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1548 RLOGD("sendEnvelope: serial %d", serial);
1550 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1555 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1556 const hidl_string& commandResponse) {
1558 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1560 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1561 commandResponse.c_str());
1565 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1567 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1569 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1570 1, BOOL_TO_INT(accept));
1574 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1576 RLOGD("explicitCallTransfer: serial %d", serial);
1578 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1582 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1584 RLOGD("setPreferredNetworkType: serial %d", serial);
1586 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1590 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1592 RLOGD("getPreferredNetworkType: serial %d", serial);
1594 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1598 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1600 RLOGD("getNeighboringCids: serial %d", serial);
1602 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1606 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1608 RLOGD("setLocationUpdates: serial %d", serial);
1610 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1614 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1616 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1618 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1622 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1624 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1626 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1630 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1632 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1634 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1638 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1640 RLOGD("setTTYMode: serial %d", serial);
1642 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1646 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1648 RLOGD("getTTYMode: serial %d", serial);
1650 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1654 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1656 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1658 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1659 1, BOOL_TO_INT(enable));
1663 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1665 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1667 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1671 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1673 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1675 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1676 featureCode.c_str());
1680 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1683 RLOGD("sendBurstDtmf: serial %d", serial);
1685 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF,
1686 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1687 (std::to_string(off)).c_str());
1691 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1692 rcsm.uTeleserviceID = sms.teleserviceId;
1693 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1694 rcsm.uServicecategory = sms.serviceCategory;
1695 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1696 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1697 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1698 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1700 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1701 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1702 for (int i = 0; i < digitLimit; i++) {
1703 rcsm.sAddress.digits[i] = sms.address.digits[i];
1706 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1707 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1709 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1710 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1711 for (int i = 0; i < digitLimit; i++) {
1712 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1715 rcsm.uBearerDataLen = sms.bearerData.size();
1716 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1717 for (int i = 0; i < digitLimit; i++) {
1718 rcsm.aBearerData[i] = sms.bearerData[i];
1722 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1724 RLOGD("sendCdmaSms: serial %d", serial);
1726 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1731 RIL_CDMA_SMS_Message rcsm = {};
1732 constructCdmaSms(rcsm, sms);
1734 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
1738 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1740 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1742 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1747 RIL_CDMA_SMS_Ack rcsa = {};
1749 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1750 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1752 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
1756 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1758 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1760 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1764 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1765 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1768 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1770 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1771 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1776 int num = configInfo.size();
1777 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1778 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1780 for (int i = 0 ; i < num ; i++ ) {
1781 gsmBciPtrs[i] = &gsmBci[i];
1782 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1783 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1784 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1785 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1786 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1789 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs,
1790 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
1794 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1796 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1798 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1799 1, BOOL_TO_INT(!activate));
1803 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1805 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1807 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1811 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1812 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1815 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1817 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1818 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1823 int num = configInfo.size();
1824 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1825 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1827 for (int i = 0 ; i < num ; i++ ) {
1828 cdmaBciPtrs[i] = &cdmaBci[i];
1829 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1830 cdmaBci[i].language = configInfo[i].language;
1831 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1834 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs,
1835 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
1839 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1841 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1843 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1844 1, BOOL_TO_INT(!activate));
1848 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1850 RLOGD("getCDMASubscription: serial %d", serial);
1852 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1856 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1858 RLOGD("writeSmsToRuim: serial %d", serial);
1860 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1861 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1866 RIL_CDMA_SMS_WriteArgs rcsw = {};
1867 rcsw.status = (int) cdmaSms.status;
1868 constructCdmaSms(rcsw.message, cdmaSms.message);
1870 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
1874 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1876 RLOGD("deleteSmsOnRuim: serial %d", serial);
1878 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1882 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1884 RLOGD("getDeviceIdentity: serial %d", serial);
1886 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1890 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1892 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1894 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1898 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1900 RLOGD("getSmscAddress: serial %d", serial);
1902 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1906 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1908 RLOGD("setSmscAddress: serial %d", serial);
1910 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1915 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1917 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1919 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1920 BOOL_TO_INT(available));
1924 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1926 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1928 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1932 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1934 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1936 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1940 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1942 RLOGD("requestIsimAuthentication: serial %d", serial);
1944 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1949 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1950 const hidl_string& ackPdu) {
1952 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1954 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU,
1955 2, success ? "1" : "0", ackPdu.c_str());
1959 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1961 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1963 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1968 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1970 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1972 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1976 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1978 RLOGD("getCellInfoList: serial %d", serial);
1980 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1984 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1986 RLOGD("setCellInfoListRate: serial %d", serial);
1988 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
1992 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
1993 bool modemCognitive, bool isRoaming) {
1995 RLOGD("setInitialAttachApn: serial %d", serial);
1997 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1998 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
2003 if (s_vendorFunctions->version <= 14) {
2004 RIL_InitialAttachApn iaa = {};
2006 if (dataProfileInfo.apn.size() == 0) {
2007 iaa.apn = (char *) calloc(1, sizeof(char));
2008 if (iaa.apn == NULL) {
2009 RLOGE("Memory allocation failed for request %s",
2010 requestToString(pRI->pCI->requestNumber));
2011 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2016 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
2021 const hidl_string &protocol =
2022 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
2024 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
2025 memsetAndFreeStrings(1, iaa.apn);
2028 iaa.authtype = (int) dataProfileInfo.authType;
2029 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2030 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2033 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2034 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
2038 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2040 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
2042 RIL_InitialAttachApn_v15 iaa = {};
2044 if (dataProfileInfo.apn.size() == 0) {
2045 iaa.apn = (char *) calloc(1, sizeof(char));
2046 if (iaa.apn == NULL) {
2047 RLOGE("Memory allocation failed for request %s",
2048 requestToString(pRI->pCI->requestNumber));
2049 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2054 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI)) {
2059 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
2060 memsetAndFreeStrings(1, iaa.apn);
2063 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
2064 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2067 iaa.authtype = (int) dataProfileInfo.authType;
2068 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2069 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
2072 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2073 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
2076 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
2077 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
2078 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
2079 iaa.mtu = dataProfileInfo.mtu;
2081 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
2082 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2083 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2088 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
2089 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2094 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2096 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2097 iaa.password, iaa.mvnoMatchData);
2103 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
2105 RLOGD("getImsRegistrationState: serial %d", serial);
2107 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2111 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2112 RIL_IMS_SMS_Message rism = {};
2114 int countStrings = 2;
2115 int dataLen = sizeof(char *) * countStrings;
2117 rism.tech = RADIO_TECH_3GPP;
2118 rism.retry = BOOL_TO_INT(message.retry);
2119 rism.messageRef = message.messageRef;
2121 if (message.gsmMessage.size() != 1) {
2122 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2123 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2127 pStrings = (char **)calloc(countStrings, sizeof(char *));
2128 if (pStrings == NULL) {
2129 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2130 requestToString(pRI->pCI->requestNumber));
2131 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2135 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2137 memset(pStrings, 0, dataLen);
2143 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2144 memsetAndFreeStrings(1, pStrings[0]);
2146 memset(pStrings, 0, dataLen);
2152 rism.message.gsmMessage = pStrings;
2153 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2154 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2156 for (int i = 0 ; i < countStrings ; i++) {
2157 memsetAndFreeStrings(1, pStrings[i]);
2161 memset(pStrings, 0, dataLen);
2169 RIL_IMS_SMS_Message imsSms;
2170 RIL_CDMA_SMS_Message cdmaSms;
2173 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2174 ImsCdmaSms temp = {};
2176 if (message.cdmaMessage.size() != 1) {
2177 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2178 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2182 temp.imsSms.tech = RADIO_TECH_3GPP2;
2183 temp.imsSms.retry = BOOL_TO_INT(message.retry);
2184 temp.imsSms.messageRef = message.messageRef;
2185 temp.imsSms.message.cdmaMessage = &temp.cdmaSms;
2187 constructCdmaSms(temp.cdmaSms, message.cdmaMessage[0]);
2189 // Vendor code expects payload length to include actual msg payload
2190 // (sizeof(RIL_CDMA_SMS_Message)) instead of (RIL_CDMA_SMS_Message *) + size of other fields in
2191 // RIL_IMS_SMS_Message
2192 int payloadLen = sizeof(RIL_RadioTechnologyFamily) + sizeof(uint8_t) + sizeof(int32_t)
2193 + sizeof(RIL_CDMA_SMS_Message);
2195 CALL_ONREQUEST(pRI->pCI->requestNumber, &temp.imsSms, payloadLen, pRI, pRI->socket_id);
2200 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2202 RLOGD("sendImsSms: serial %d", serial);
2204 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2209 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2211 if (RADIO_TECH_3GPP == format) {
2212 dispatchImsGsmSms(message, pRI);
2213 } else if (RADIO_TECH_3GPP2 == format) {
2214 dispatchImsCdmaSms(message, pRI);
2216 RLOGE("sendImsSms: Invalid radio tech %s",
2217 requestToString(pRI->pCI->requestNumber));
2218 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2223 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2225 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2227 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2231 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2233 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2235 if (s_vendorFunctions->version < 15) {
2236 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2238 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2243 RIL_OpenChannelParams params = {};
2247 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2251 CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId);
2253 memsetAndFreeStrings(1, params.aidPtr);
2258 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2260 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2262 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2266 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2268 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2270 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2274 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2276 RLOGD("nvReadItem: serial %d", serial);
2278 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2283 RIL_NV_ReadItem nvri = {};
2284 nvri.itemID = (RIL_NV_Item) itemId;
2286 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2290 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2292 RLOGD("nvWriteItem: serial %d", serial);
2294 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2299 RIL_NV_WriteItem nvwi = {};
2301 nvwi.itemID = (RIL_NV_Item) item.itemId;
2303 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2307 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2309 memsetAndFreeStrings(1, nvwi.value);
2313 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2315 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2317 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2321 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2322 int rilResetType = -1;
2324 RLOGD("nvResetConfig: serial %d", serial);
2326 /* Convert ResetNvType to RIL.h values
2327 * RIL_REQUEST_NV_RESET_CONFIG
2328 * 1 - reload all NV items
2329 * 2 - erase NV reset (SCRTN)
2330 * 3 - factory reset (RTN)
2333 case ResetNvType::RELOAD:
2336 case ResetNvType::ERASE:
2339 case ResetNvType::FACTORY_RESET:
2343 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2347 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2349 RLOGD("setUiccSubscription: serial %d", serial);
2351 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2352 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2357 RIL_SelectUiccSub rilUiccSub = {};
2359 rilUiccSub.slot = uiccSub.slot;
2360 rilUiccSub.app_index = uiccSub.appIndex;
2361 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2362 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2364 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2368 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2370 RLOGD("setDataAllowed: serial %d", serial);
2372 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2376 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2378 RLOGD("getHardwareConfig: serial %d", serial);
2380 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2384 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2385 const hidl_string& authData, const hidl_string& aid) {
2387 RLOGD("requestIccSimAuthentication: serial %d", serial);
2389 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2394 RIL_SimAuthentication pf = {};
2396 pf.authContext = authContext;
2398 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2402 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2403 memsetAndFreeStrings(1, pf.authData);
2407 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2409 memsetAndFreeStrings(2, pf.authData, pf.aid);
2414 * @param numProfiles number of data profile
2415 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2416 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2417 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2418 * @param numfields number of string-type member in the data profile structure
2419 * @param ... the variadic parameters are pointers to each string-type member
2421 template <typename T>
2422 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2423 int numfields, ...) {
2425 va_start(args, numfields);
2427 // Iterate through each string-type field that need to be free.
2428 for (int i = 0; i < numfields; i++) {
2429 // Iterate through each data profile and free that specific string-type field.
2430 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2431 char *T::*ptr = va_arg(args, char *T::*);
2432 for (int j = 0; j < numProfiles; j++) {
2433 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2440 memset(dataProfiles, 0, numProfiles * sizeof(T));
2441 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2444 free(dataProfilePtrs);
2447 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2450 RLOGD("setDataProfile: serial %d", serial);
2452 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2457 size_t num = profiles.size();
2458 bool success = false;
2460 if (s_vendorFunctions->version <= 14) {
2462 RIL_DataProfileInfo *dataProfiles =
2463 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2465 if (dataProfiles == NULL) {
2466 RLOGE("Memory allocation failed for request %s",
2467 requestToString(pRI->pCI->requestNumber));
2468 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2472 RIL_DataProfileInfo **dataProfilePtrs =
2473 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2474 if (dataProfilePtrs == NULL) {
2475 RLOGE("Memory allocation failed for request %s",
2476 requestToString(pRI->pCI->requestNumber));
2478 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2482 for (size_t i = 0; i < num; i++) {
2483 dataProfilePtrs[i] = &dataProfiles[i];
2485 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2487 const hidl_string &protocol =
2488 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2490 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI)) {
2494 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2497 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2503 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2504 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2505 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2509 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2510 dataProfiles[i].authType = (int) profiles[i].authType;
2511 dataProfiles[i].type = (int) profiles[i].type;
2512 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2513 dataProfiles[i].maxConns = profiles[i].maxConns;
2514 dataProfiles[i].waitTime = profiles[i].waitTime;
2515 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2518 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2519 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2521 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2522 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2523 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2525 RIL_DataProfileInfo_v15 *dataProfiles =
2526 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2528 if (dataProfiles == NULL) {
2529 RLOGE("Memory allocation failed for request %s",
2530 requestToString(pRI->pCI->requestNumber));
2531 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2535 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2536 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2537 if (dataProfilePtrs == NULL) {
2538 RLOGE("Memory allocation failed for request %s",
2539 requestToString(pRI->pCI->requestNumber));
2541 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2545 for (size_t i = 0; i < num; i++) {
2546 dataProfilePtrs[i] = &dataProfiles[i];
2548 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI);
2549 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2553 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2554 profiles[i].roamingProtocol, pRI)) {
2557 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI)) {
2560 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2564 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2565 profiles[i].mvnoMatchData, pRI)) {
2569 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2570 dataProfiles[i].mvnoType)) {
2571 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2576 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2577 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2578 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2579 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2583 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2584 dataProfiles[i].authType = (int) profiles[i].authType;
2585 dataProfiles[i].type = (int) profiles[i].type;
2586 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2587 dataProfiles[i].maxConns = profiles[i].maxConns;
2588 dataProfiles[i].waitTime = profiles[i].waitTime;
2589 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2590 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2591 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2592 dataProfiles[i].mtu = profiles[i].mtu;
2595 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2596 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
2598 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2599 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2600 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2601 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2607 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2609 RLOGD("requestShutdown: serial %d", serial);
2611 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2615 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2617 RLOGD("getRadioCapability: serial %d", serial);
2619 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2623 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2625 RLOGD("setRadioCapability: serial %d", serial);
2627 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2632 RIL_RadioCapability rilRc = {};
2634 // TODO : set rilRc.version using HIDL version ?
2635 rilRc.session = rc.session;
2636 rilRc.phase = (int) rc.phase;
2637 rilRc.rat = (int) rc.raf;
2638 rilRc.status = (int) rc.status;
2639 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2641 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
2646 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2648 RLOGD("startLceService: serial %d", serial);
2650 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2651 BOOL_TO_INT(pullMode));
2655 Return<void> RadioImpl::stopLceService(int32_t serial) {
2657 RLOGD("stopLceService: serial %d", serial);
2659 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2663 Return<void> RadioImpl::pullLceData(int32_t serial) {
2665 RLOGD("pullLceData: serial %d", serial);
2667 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2671 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2673 RLOGD("getModemActivityInfo: serial %d", serial);
2675 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2679 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2680 const CarrierRestrictions& carriers) {
2682 RLOGD("setAllowedCarriers: serial %d", serial);
2684 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2685 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2690 RIL_CarrierRestrictions cr = {};
2691 RIL_Carrier *allowedCarriers = NULL;
2692 RIL_Carrier *excludedCarriers = NULL;
2694 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2695 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2696 if (allowedCarriers == NULL) {
2697 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2698 requestToString(pRI->pCI->requestNumber));
2699 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2702 cr.allowed_carriers = allowedCarriers;
2704 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2705 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2706 if (excludedCarriers == NULL) {
2707 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2708 requestToString(pRI->pCI->requestNumber));
2709 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2711 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2713 free(allowedCarriers);
2716 cr.excluded_carriers = excludedCarriers;
2718 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2719 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2720 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2721 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2722 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2725 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2726 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2727 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2728 excludedCarriers[i].match_type =
2729 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2730 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2733 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
2736 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2737 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2739 free(allowedCarriers);
2740 free(excludedCarriers);
2744 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2746 RLOGD("getAllowedCarriers: serial %d", serial);
2748 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2752 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2755 RLOGD("sendDeviceState: serial %d", serial);
2757 if (s_vendorFunctions->version < 15) {
2758 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2759 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2760 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2762 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2763 RIL_REQUEST_SEND_DEVICE_STATE);
2764 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2768 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2769 BOOL_TO_INT(state));
2773 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2775 RLOGD("setIndicationFilter: serial %d", serial);
2777 if (s_vendorFunctions->version < 15) {
2778 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2779 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2780 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2783 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2787 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2789 RLOGD("setSimCardPower: serial %d", serial);
2791 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2795 Return<void> RadioImpl::setSimCardPower_1_1(int32_t serial, const V1_1::CardPowerState state) {
2797 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
2799 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
2803 Return<void> RadioImpl::responseAcknowledgement() {
2804 android::releaseWakeLock();
2808 Return<void> OemHookImpl::setResponseFunctions(
2809 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2810 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2812 RLOGD("OemHookImpl::setResponseFunctions");
2815 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2816 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2819 mOemHookResponse = oemHookResponseParam;
2820 mOemHookIndication = oemHookIndicationParam;
2821 mCounterOemHook[mSlotId]++;
2823 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2829 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2831 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2833 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2837 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2838 const hidl_vec<hidl_string>& data) {
2840 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2842 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2846 Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial,
2847 const ::android::hardware::radio::V1_1::ImsiEncryptionInfo& data) {
2848 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
2849 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
2850 RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
2852 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
2855 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
2856 memsetAndFreeStrings(1, imsiEncryption.mnc);
2859 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
2860 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
2863 int32_t lSize = data.carrierKey.size();
2864 imsiEncryption.carrierKey = new uint8_t[lSize];
2865 memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), lSize);
2866 imsiEncryption.expirationTime = data.expirationTime;
2867 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
2868 sizeof(RIL_CarrierInfoForImsiEncryption), pRI, mSlotId);
2869 delete(imsiEncryption.carrierKey);
2873 Return<void> RadioImpl::startKeepalive(int32_t serial, const KeepaliveRequest& keepalive) {
2874 RLOGD("startKeepalive: serial %d", serial);
2878 Return<void> RadioImpl::stopKeepalive(int32_t serial, int32_t sessionHandle) {
2879 RLOGD("stopKeepalive: serial %d", serial);
2884 /***************************************************************************************************
2885 * RESPONSE FUNCTIONS
2886 * Functions above are used for requests going from framework to vendor code. The ones below are
2887 * responses for those requests coming back from the vendor code.
2888 **************************************************************************************************/
2890 void radio::acknowledgeRequest(int slotId, int serial) {
2891 if (radioService[slotId]->mRadioResponse != NULL) {
2892 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2893 radioService[slotId]->checkReturnStatus(retStatus);
2895 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2899 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2901 responseInfo.serial = serial;
2902 switch (responseType) {
2903 case RESPONSE_SOLICITED:
2904 responseInfo.type = RadioResponseType::SOLICITED;
2906 case RESPONSE_SOLICITED_ACK_EXP:
2907 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2910 responseInfo.error = (RadioError) e;
2913 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2914 void *response, size_t responseLen) {
2915 populateResponseInfo(responseInfo, serial, responseType, e);
2918 if (response == NULL && responseLen == 0) {
2919 // Earlier RILs did not send a response for some cases although the interface
2920 // expected an integer as response. Do not return error if response is empty. Instead
2921 // Return -1 in those cases to maintain backward compatibility.
2922 } else if (response == NULL || responseLen != sizeof(int)) {
2923 RLOGE("responseIntOrEmpty: Invalid response");
2924 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2926 int *p_int = (int *) response;
2932 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2933 void *response, size_t responseLen) {
2934 populateResponseInfo(responseInfo, serial, responseType, e);
2937 if (response == NULL || responseLen != sizeof(int)) {
2938 RLOGE("responseInt: Invalid response");
2939 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2941 int *p_int = (int *) response;
2947 int radio::getIccCardStatusResponse(int slotId,
2948 int responseType, int serial, RIL_Errno e,
2949 void *response, size_t responseLen) {
2950 if (radioService[slotId]->mRadioResponse != NULL) {
2951 RadioResponseInfo responseInfo = {};
2952 populateResponseInfo(responseInfo, serial, responseType, e);
2953 CardStatus cardStatus = {};
2954 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2955 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)
2956 || p_cur->gsm_umts_subscription_app_index >= p_cur->num_applications
2957 || p_cur->cdma_subscription_app_index >= p_cur->num_applications
2958 || p_cur->ims_subscription_app_index >= p_cur->num_applications) {
2959 RLOGE("getIccCardStatusResponse: Invalid response");
2960 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2962 cardStatus.cardState = (CardState) p_cur->card_state;
2963 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2964 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2965 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2966 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2968 RIL_AppStatus *rilAppStatus = p_cur->applications;
2969 cardStatus.applications.resize(p_cur->num_applications);
2970 AppStatus *appStatus = cardStatus.applications.data();
2972 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2974 for (int i = 0; i < p_cur->num_applications; i++) {
2975 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2976 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2977 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2978 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2979 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2980 rilAppStatus[i].app_label_ptr);
2981 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2982 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2983 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2987 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2988 getIccCardStatusResponse(responseInfo, cardStatus);
2989 radioService[slotId]->checkReturnStatus(retStatus);
2991 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2997 int radio::supplyIccPinForAppResponse(int slotId,
2998 int responseType, int serial, RIL_Errno e,
2999 void *response, size_t responseLen) {
3001 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
3004 if (radioService[slotId]->mRadioResponse != NULL) {
3005 RadioResponseInfo responseInfo = {};
3006 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3007 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3008 supplyIccPinForAppResponse(responseInfo, ret);
3009 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
3010 radioService[slotId]->checkReturnStatus(retStatus);
3012 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3019 int radio::supplyIccPukForAppResponse(int slotId,
3020 int responseType, int serial, RIL_Errno e,
3021 void *response, size_t responseLen) {
3023 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
3026 if (radioService[slotId]->mRadioResponse != NULL) {
3027 RadioResponseInfo responseInfo = {};
3028 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3029 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
3031 radioService[slotId]->checkReturnStatus(retStatus);
3033 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
3040 int radio::supplyIccPin2ForAppResponse(int slotId,
3041 int responseType, int serial, RIL_Errno e,
3042 void *response, size_t responseLen) {
3044 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
3047 if (radioService[slotId]->mRadioResponse != NULL) {
3048 RadioResponseInfo responseInfo = {};
3049 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3050 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3051 supplyIccPin2ForAppResponse(responseInfo, ret);
3052 radioService[slotId]->checkReturnStatus(retStatus);
3054 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3061 int radio::supplyIccPuk2ForAppResponse(int slotId,
3062 int responseType, int serial, RIL_Errno e,
3063 void *response, size_t responseLen) {
3065 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
3068 if (radioService[slotId]->mRadioResponse != NULL) {
3069 RadioResponseInfo responseInfo = {};
3070 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3071 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3072 supplyIccPuk2ForAppResponse(responseInfo, ret);
3073 radioService[slotId]->checkReturnStatus(retStatus);
3075 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3082 int radio::changeIccPinForAppResponse(int slotId,
3083 int responseType, int serial, RIL_Errno e,
3084 void *response, size_t responseLen) {
3086 RLOGD("changeIccPinForAppResponse: serial %d", serial);
3089 if (radioService[slotId]->mRadioResponse != NULL) {
3090 RadioResponseInfo responseInfo = {};
3091 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3092 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3093 changeIccPinForAppResponse(responseInfo, ret);
3094 radioService[slotId]->checkReturnStatus(retStatus);
3096 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3103 int radio::changeIccPin2ForAppResponse(int slotId,
3104 int responseType, int serial, RIL_Errno e,
3105 void *response, size_t responseLen) {
3107 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
3110 if (radioService[slotId]->mRadioResponse != NULL) {
3111 RadioResponseInfo responseInfo = {};
3112 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3113 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3114 changeIccPin2ForAppResponse(responseInfo, ret);
3115 radioService[slotId]->checkReturnStatus(retStatus);
3117 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3124 int radio::supplyNetworkDepersonalizationResponse(int slotId,
3125 int responseType, int serial, RIL_Errno e,
3126 void *response, size_t responseLen) {
3128 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
3131 if (radioService[slotId]->mRadioResponse != NULL) {
3132 RadioResponseInfo responseInfo = {};
3133 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3134 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3135 supplyNetworkDepersonalizationResponse(responseInfo, ret);
3136 radioService[slotId]->checkReturnStatus(retStatus);
3138 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
3145 int radio::getCurrentCallsResponse(int slotId,
3146 int responseType, int serial, RIL_Errno e,
3147 void *response, size_t responseLen) {
3149 RLOGD("getCurrentCallsResponse: serial %d", serial);
3152 if (radioService[slotId]->mRadioResponse != NULL) {
3153 RadioResponseInfo responseInfo = {};
3154 populateResponseInfo(responseInfo, serial, responseType, e);
3156 hidl_vec<Call> calls;
3157 if ((response == NULL && responseLen != 0)
3158 || (responseLen % sizeof(RIL_Call *)) != 0) {
3159 RLOGE("getCurrentCallsResponse: Invalid response");
3160 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3162 int num = responseLen / sizeof(RIL_Call *);
3165 for (int i = 0 ; i < num ; i++) {
3166 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3167 /* each call info */
3168 calls[i].state = (CallState) p_cur->state;
3169 calls[i].index = p_cur->index;
3170 calls[i].toa = p_cur->toa;
3171 calls[i].isMpty = p_cur->isMpty;
3172 calls[i].isMT = p_cur->isMT;
3173 calls[i].als = p_cur->als;
3174 calls[i].isVoice = p_cur->isVoice;
3175 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3176 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3177 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3178 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3179 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3180 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3181 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3182 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3183 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3184 // convert uusInfo->uusData to a null-terminated string
3185 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3186 calls[i].uusInfo[0].uusData = nullTermStr;
3192 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3193 getCurrentCallsResponse(responseInfo, calls);
3194 radioService[slotId]->checkReturnStatus(retStatus);
3196 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3202 int radio::dialResponse(int slotId,
3203 int responseType, int serial, RIL_Errno e, void *response,
3204 size_t responseLen) {
3206 RLOGD("dialResponse: serial %d", serial);
3209 if (radioService[slotId]->mRadioResponse != NULL) {
3210 RadioResponseInfo responseInfo = {};
3211 populateResponseInfo(responseInfo, serial, responseType, e);
3212 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3213 radioService[slotId]->checkReturnStatus(retStatus);
3215 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3221 int radio::getIMSIForAppResponse(int slotId,
3222 int responseType, int serial, RIL_Errno e, void *response,
3223 size_t responseLen) {
3225 RLOGD("getIMSIForAppResponse: serial %d", serial);
3228 if (radioService[slotId]->mRadioResponse != NULL) {
3229 RadioResponseInfo responseInfo = {};
3230 populateResponseInfo(responseInfo, serial, responseType, e);
3231 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3232 responseInfo, convertCharPtrToHidlString((char *) response));
3233 radioService[slotId]->checkReturnStatus(retStatus);
3235 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3242 int radio::hangupConnectionResponse(int slotId,
3243 int responseType, int serial, RIL_Errno e,
3244 void *response, size_t responseLen) {
3246 RLOGD("hangupConnectionResponse: serial %d", serial);
3249 if (radioService[slotId]->mRadioResponse != NULL) {
3250 RadioResponseInfo responseInfo = {};
3251 populateResponseInfo(responseInfo, serial, responseType, e);
3252 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3254 radioService[slotId]->checkReturnStatus(retStatus);
3256 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3263 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3264 int responseType, int serial, RIL_Errno e,
3265 void *response, size_t responseLen) {
3267 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3270 if (radioService[slotId]->mRadioResponse != NULL) {
3271 RadioResponseInfo responseInfo = {};
3272 populateResponseInfo(responseInfo, serial, responseType, e);
3273 Return<void> retStatus =
3274 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3276 radioService[slotId]->checkReturnStatus(retStatus);
3278 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3285 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3286 RIL_Errno e, void *response,
3287 size_t responseLen) {
3289 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3292 if (radioService[slotId]->mRadioResponse != NULL) {
3293 RadioResponseInfo responseInfo = {};
3294 populateResponseInfo(responseInfo, serial, responseType, e);
3295 Return<void> retStatus =
3296 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3298 radioService[slotId]->checkReturnStatus(retStatus);
3300 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3307 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3308 RIL_Errno e, void *response,
3309 size_t responseLen) {
3311 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3314 if (radioService[slotId]->mRadioResponse != NULL) {
3315 RadioResponseInfo responseInfo = {};
3316 populateResponseInfo(responseInfo, serial, responseType, e);
3317 Return<void> retStatus =
3318 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3320 radioService[slotId]->checkReturnStatus(retStatus);
3322 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3329 int radio::conferenceResponse(int slotId, int responseType,
3330 int serial, RIL_Errno e, void *response, size_t responseLen) {
3332 RLOGD("conferenceResponse: serial %d", serial);
3335 if (radioService[slotId]->mRadioResponse != NULL) {
3336 RadioResponseInfo responseInfo = {};
3337 populateResponseInfo(responseInfo, serial, responseType, e);
3338 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3340 radioService[slotId]->checkReturnStatus(retStatus);
3342 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3349 int radio::rejectCallResponse(int slotId, int responseType,
3350 int serial, RIL_Errno e, void *response, size_t responseLen) {
3352 RLOGD("rejectCallResponse: serial %d", serial);
3355 if (radioService[slotId]->mRadioResponse != NULL) {
3356 RadioResponseInfo responseInfo = {};
3357 populateResponseInfo(responseInfo, serial, responseType, e);
3358 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3360 radioService[slotId]->checkReturnStatus(retStatus);
3362 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3369 int radio::getLastCallFailCauseResponse(int slotId,
3370 int responseType, int serial, RIL_Errno e, void *response,
3371 size_t responseLen) {
3373 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3376 if (radioService[slotId]->mRadioResponse != NULL) {
3377 RadioResponseInfo responseInfo = {};
3378 populateResponseInfo(responseInfo, serial, responseType, e);
3380 LastCallFailCauseInfo info = {};
3381 info.vendorCause = hidl_string();
3382 if (response == NULL) {
3383 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3384 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3385 } else if (responseLen == sizeof(int)) {
3386 int *pInt = (int *) response;
3387 info.causeCode = (LastCallFailCause) pInt[0];
3388 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3389 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3390 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3391 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3393 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3394 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3397 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3398 responseInfo, info);
3399 radioService[slotId]->checkReturnStatus(retStatus);
3401 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3408 int radio::getSignalStrengthResponse(int slotId,
3409 int responseType, int serial, RIL_Errno e,
3410 void *response, size_t responseLen) {
3412 RLOGD("getSignalStrengthResponse: serial %d", serial);
3415 if (radioService[slotId]->mRadioResponse != NULL) {
3416 RadioResponseInfo responseInfo = {};
3417 populateResponseInfo(responseInfo, serial, responseType, e);
3418 SignalStrength signalStrength = {};
3419 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3420 RLOGE("getSignalStrengthResponse: Invalid response");
3421 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3423 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3426 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3427 responseInfo, signalStrength);
3428 radioService[slotId]->checkReturnStatus(retStatus);
3430 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3437 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3439 return RIL_CELL_INFO_TYPE_NONE;
3442 int radioTech = atoi(rat);
3446 case RADIO_TECH_GPRS:
3447 case RADIO_TECH_EDGE:
3448 case RADIO_TECH_GSM: {
3449 return RIL_CELL_INFO_TYPE_GSM;
3452 case RADIO_TECH_UMTS:
3453 case RADIO_TECH_HSDPA:
3454 case RADIO_TECH_HSUPA:
3455 case RADIO_TECH_HSPA:
3456 case RADIO_TECH_HSPAP: {
3457 return RIL_CELL_INFO_TYPE_WCDMA;
3460 case RADIO_TECH_IS95A:
3461 case RADIO_TECH_IS95B:
3462 case RADIO_TECH_1xRTT:
3463 case RADIO_TECH_EVDO_0:
3464 case RADIO_TECH_EVDO_A:
3465 case RADIO_TECH_EVDO_B:
3466 case RADIO_TECH_EHRPD: {
3467 return RIL_CELL_INFO_TYPE_CDMA;
3470 case RADIO_TECH_LTE:
3471 case RADIO_TECH_LTE_CA: {
3472 return RIL_CELL_INFO_TYPE_LTE;
3475 case RADIO_TECH_TD_SCDMA: {
3476 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3484 return RIL_CELL_INFO_TYPE_NONE;
3488 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3490 cellIdentity.cellIdentityGsm.resize(0);
3491 cellIdentity.cellIdentityWcdma.resize(0);
3492 cellIdentity.cellIdentityCdma.resize(0);
3493 cellIdentity.cellIdentityTdscdma.resize(0);
3494 cellIdentity.cellIdentityLte.resize(0);
3495 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3496 switch(rilCellIdentity.cellInfoType) {
3498 case RIL_CELL_INFO_TYPE_GSM: {
3499 cellIdentity.cellIdentityGsm.resize(1);
3500 cellIdentity.cellIdentityGsm[0].mcc =
3501 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3502 cellIdentity.cellIdentityGsm[0].mnc =
3503 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3504 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3505 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3506 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3507 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3511 case RIL_CELL_INFO_TYPE_WCDMA: {
3512 cellIdentity.cellIdentityWcdma.resize(1);
3513 cellIdentity.cellIdentityWcdma[0].mcc =
3514 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3515 cellIdentity.cellIdentityWcdma[0].mnc =
3516 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3517 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3518 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3519 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3520 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3524 case RIL_CELL_INFO_TYPE_CDMA: {
3525 cellIdentity.cellIdentityCdma.resize(1);
3526 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3527 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3528 cellIdentity.cellIdentityCdma[0].baseStationId =
3529 rilCellIdentity.cellIdentityCdma.basestationId;
3530 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3531 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3535 case RIL_CELL_INFO_TYPE_LTE: {
3536 cellIdentity.cellIdentityLte.resize(1);
3537 cellIdentity.cellIdentityLte[0].mcc =
3538 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3539 cellIdentity.cellIdentityLte[0].mnc =
3540 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3541 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3542 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3543 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3544 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3548 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3549 cellIdentity.cellIdentityTdscdma.resize(1);
3550 cellIdentity.cellIdentityTdscdma[0].mcc =
3551 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3552 cellIdentity.cellIdentityTdscdma[0].mnc =
3553 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3554 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3555 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3556 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3566 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3567 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3568 return atoi(response[index]);
3574 int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
3575 const int hexBase = 16;
3576 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3577 return strtol(response[index], NULL, hexBase);
3583 /* Fill Cell Identity info from Voice Registration State Response.
3584 * This fucntion is applicable only for RIL Version < 15.
3585 * Response is a "char **".
3586 * First and Second entries are in hex string format
3587 * and rest are integers represented in ascii format. */
3588 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3589 int numStrings, char** response) {
3591 RIL_CellIdentity_v16 rilCellIdentity;
3592 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3594 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3595 switch(rilCellIdentity.cellInfoType) {
3597 case RIL_CELL_INFO_TYPE_GSM: {
3598 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3599 rilCellIdentity.cellIdentityGsm.lac =
3600 convertResponseHexStringEntryToInt(response, 1, numStrings);
3602 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3603 rilCellIdentity.cellIdentityGsm.cid =
3604 convertResponseHexStringEntryToInt(response, 2, numStrings);
3608 case RIL_CELL_INFO_TYPE_WCDMA: {
3609 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3610 rilCellIdentity.cellIdentityWcdma.lac =
3611 convertResponseHexStringEntryToInt(response, 1, numStrings);
3613 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3614 rilCellIdentity.cellIdentityWcdma.cid =
3615 convertResponseHexStringEntryToInt(response, 2, numStrings);
3616 rilCellIdentity.cellIdentityWcdma.psc =
3617 convertResponseStringEntryToInt(response, 14, numStrings);
3621 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3622 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3623 rilCellIdentity.cellIdentityTdscdma.lac =
3624 convertResponseHexStringEntryToInt(response, 1, numStrings);
3626 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3627 rilCellIdentity.cellIdentityTdscdma.cid =
3628 convertResponseHexStringEntryToInt(response, 2, numStrings);
3632 case RIL_CELL_INFO_TYPE_CDMA:{
3633 rilCellIdentity.cellIdentityCdma.basestationId =
3634 convertResponseStringEntryToInt(response, 4, numStrings);
3635 rilCellIdentity.cellIdentityCdma.longitude =
3636 convertResponseStringEntryToInt(response, 5, numStrings);
3637 rilCellIdentity.cellIdentityCdma.latitude =
3638 convertResponseStringEntryToInt(response, 6, numStrings);
3639 rilCellIdentity.cellIdentityCdma.systemId =
3640 convertResponseStringEntryToInt(response, 8, numStrings);
3641 rilCellIdentity.cellIdentityCdma.networkId =
3642 convertResponseStringEntryToInt(response, 9, numStrings);
3646 case RIL_CELL_INFO_TYPE_LTE:{
3647 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
3648 rilCellIdentity.cellIdentityLte.tac =
3649 convertResponseHexStringEntryToInt(response, 1, numStrings);
3651 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3652 rilCellIdentity.cellIdentityLte.ci =
3653 convertResponseHexStringEntryToInt(response, 2, numStrings);
3662 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3665 /* Fill Cell Identity info from Data Registration State Response.
3666 * This fucntion is applicable only for RIL Version < 15.
3667 * Response is a "char **".
3668 * First and Second entries are in hex string format
3669 * and rest are integers represented in ascii format. */
3670 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3671 int numStrings, char** response) {
3673 RIL_CellIdentity_v16 rilCellIdentity;
3674 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3676 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3677 switch(rilCellIdentity.cellInfoType) {
3678 case RIL_CELL_INFO_TYPE_GSM: {
3679 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3680 rilCellIdentity.cellIdentityGsm.lac =
3681 convertResponseHexStringEntryToInt(response, 1, numStrings);
3683 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3684 rilCellIdentity.cellIdentityGsm.cid =
3685 convertResponseHexStringEntryToInt(response, 2, numStrings);
3688 case RIL_CELL_INFO_TYPE_WCDMA: {
3689 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3690 rilCellIdentity.cellIdentityWcdma.lac =
3691 convertResponseHexStringEntryToInt(response, 1, numStrings);
3693 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3694 rilCellIdentity.cellIdentityWcdma.cid =
3695 convertResponseHexStringEntryToInt(response, 2, numStrings);
3698 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3699 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3700 rilCellIdentity.cellIdentityTdscdma.lac =
3701 convertResponseHexStringEntryToInt(response, 1, numStrings);
3703 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3704 rilCellIdentity.cellIdentityTdscdma.cid =
3705 convertResponseHexStringEntryToInt(response, 2, numStrings);
3708 case RIL_CELL_INFO_TYPE_LTE: {
3709 rilCellIdentity.cellIdentityLte.tac =
3710 convertResponseStringEntryToInt(response, 6, numStrings);
3711 rilCellIdentity.cellIdentityLte.pci =
3712 convertResponseStringEntryToInt(response, 7, numStrings);
3713 rilCellIdentity.cellIdentityLte.ci =
3714 convertResponseStringEntryToInt(response, 8, numStrings);
3722 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3725 int radio::getVoiceRegistrationStateResponse(int slotId,
3726 int responseType, int serial, RIL_Errno e,
3727 void *response, size_t responseLen) {
3729 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3732 if (radioService[slotId]->mRadioResponse != NULL) {
3733 RadioResponseInfo responseInfo = {};
3734 populateResponseInfo(responseInfo, serial, responseType, e);
3736 VoiceRegStateResult voiceRegResponse = {};
3737 int numStrings = responseLen / sizeof(char *);
3738 if (response == NULL) {
3739 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3740 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3741 } else if (s_vendorFunctions->version <= 14) {
3742 if (numStrings != 15) {
3743 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3744 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3746 char **resp = (char **) response;
3747 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3748 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3749 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3750 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3751 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3752 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3753 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3754 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3758 RIL_VoiceRegistrationStateResponse *voiceRegState =
3759 (RIL_VoiceRegistrationStateResponse *)response;
3761 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3762 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3763 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3765 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3766 voiceRegResponse.rat = voiceRegState->rat;;
3767 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3768 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3769 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3770 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3771 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3772 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3773 voiceRegState->cellIdentity);
3777 Return<void> retStatus =
3778 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3779 responseInfo, voiceRegResponse);
3780 radioService[slotId]->checkReturnStatus(retStatus);
3782 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3789 int radio::getDataRegistrationStateResponse(int slotId,
3790 int responseType, int serial, RIL_Errno e,
3791 void *response, size_t responseLen) {
3793 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3796 if (radioService[slotId]->mRadioResponse != NULL) {
3797 RadioResponseInfo responseInfo = {};
3798 populateResponseInfo(responseInfo, serial, responseType, e);
3799 DataRegStateResult dataRegResponse = {};
3800 if (response == NULL) {
3801 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3802 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3803 } else if (s_vendorFunctions->version <= 14) {
3804 int numStrings = responseLen / sizeof(char *);
3805 if ((numStrings != 6) && (numStrings != 11)) {
3806 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3807 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3809 char **resp = (char **) response;
3810 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3811 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3812 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3813 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3814 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3818 RIL_DataRegistrationStateResponse *dataRegState =
3819 (RIL_DataRegistrationStateResponse *)response;
3821 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3822 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3823 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3825 dataRegResponse.regState = (RegState) dataRegState->regState;
3826 dataRegResponse.rat = dataRegState->rat;;
3827 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3828 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3829 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3833 Return<void> retStatus =
3834 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3836 radioService[slotId]->checkReturnStatus(retStatus);
3838 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3845 int radio::getOperatorResponse(int slotId,
3846 int responseType, int serial, RIL_Errno e, void *response,
3847 size_t responseLen) {
3849 RLOGD("getOperatorResponse: serial %d", serial);
3852 if (radioService[slotId]->mRadioResponse != NULL) {
3853 RadioResponseInfo responseInfo = {};
3854 populateResponseInfo(responseInfo, serial, responseType, e);
3855 hidl_string longName;
3856 hidl_string shortName;
3857 hidl_string numeric;
3858 int numStrings = responseLen / sizeof(char *);
3859 if (response == NULL || numStrings != 3) {
3860 RLOGE("getOperatorResponse Invalid response: NULL");
3861 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3864 char **resp = (char **) response;
3865 longName = convertCharPtrToHidlString(resp[0]);
3866 shortName = convertCharPtrToHidlString(resp[1]);
3867 numeric = convertCharPtrToHidlString(resp[2]);
3869 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3870 responseInfo, longName, shortName, numeric);
3871 radioService[slotId]->checkReturnStatus(retStatus);
3873 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3880 int radio::setRadioPowerResponse(int slotId,
3881 int responseType, int serial, RIL_Errno e, void *response,
3882 size_t responseLen) {
3883 RLOGD("setRadioPowerResponse: serial %d", serial);
3885 if (radioService[slotId]->mRadioResponse != NULL) {
3886 RadioResponseInfo responseInfo = {};
3887 populateResponseInfo(responseInfo, serial, responseType, e);
3888 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3890 radioService[slotId]->checkReturnStatus(retStatus);
3892 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3899 int radio::sendDtmfResponse(int slotId,
3900 int responseType, int serial, RIL_Errno e, void *response,
3901 size_t responseLen) {
3903 RLOGD("sendDtmfResponse: serial %d", serial);
3906 if (radioService[slotId]->mRadioResponse != NULL) {
3907 RadioResponseInfo responseInfo = {};
3908 populateResponseInfo(responseInfo, serial, responseType, e);
3909 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3911 radioService[slotId]->checkReturnStatus(retStatus);
3913 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3920 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3921 RIL_Errno e, void *response, size_t responseLen) {
3922 populateResponseInfo(responseInfo, serial, responseType, e);
3923 SendSmsResult result = {};
3925 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3926 RLOGE("Invalid response: NULL");
3927 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3928 result.ackPDU = hidl_string();
3930 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3931 result.messageRef = resp->messageRef;
3932 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3933 result.errorCode = resp->errorCode;
3938 int radio::sendSmsResponse(int slotId,
3939 int responseType, int serial, RIL_Errno e, void *response,
3940 size_t responseLen) {
3942 RLOGD("sendSmsResponse: serial %d", serial);
3945 if (radioService[slotId]->mRadioResponse != NULL) {
3946 RadioResponseInfo responseInfo = {};
3947 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3950 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3952 radioService[slotId]->checkReturnStatus(retStatus);
3954 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3960 int radio::sendSMSExpectMoreResponse(int slotId,
3961 int responseType, int serial, RIL_Errno e, void *response,
3962 size_t responseLen) {
3964 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3967 if (radioService[slotId]->mRadioResponse != NULL) {
3968 RadioResponseInfo responseInfo = {};
3969 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3972 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3973 responseInfo, result);
3974 radioService[slotId]->checkReturnStatus(retStatus);
3976 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3982 int radio::setupDataCallResponse(int slotId,
3983 int responseType, int serial, RIL_Errno e, void *response,
3984 size_t responseLen) {
3986 RLOGD("setupDataCallResponse: serial %d", serial);
3989 if (radioService[slotId]->mRadioResponse != NULL) {
3990 RadioResponseInfo responseInfo = {};
3991 populateResponseInfo(responseInfo, serial, responseType, e);
3993 SetupDataCallResult result = {};
3994 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
3995 if (response != NULL) {
3996 RLOGE("setupDataCallResponse: Invalid response");
3997 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3999 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
4000 result.type = hidl_string();
4001 result.ifname = hidl_string();
4002 result.addresses = hidl_string();
4003 result.dnses = hidl_string();
4004 result.gateways = hidl_string();
4005 result.pcscf = hidl_string();
4007 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
4010 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
4011 responseInfo, result);
4012 radioService[slotId]->checkReturnStatus(retStatus);
4014 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4020 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
4021 RIL_Errno e, void *response, size_t responseLen) {
4022 populateResponseInfo(responseInfo, serial, responseType, e);
4023 IccIoResult result = {};
4025 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
4026 RLOGE("Invalid response: NULL");
4027 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4028 result.simResponse = hidl_string();
4030 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
4031 result.sw1 = resp->sw1;
4032 result.sw2 = resp->sw2;
4033 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
4038 int radio::iccIOForAppResponse(int slotId,
4039 int responseType, int serial, RIL_Errno e, void *response,
4040 size_t responseLen) {
4042 RLOGD("iccIOForAppResponse: serial %d", serial);
4045 if (radioService[slotId]->mRadioResponse != NULL) {
4046 RadioResponseInfo responseInfo = {};
4047 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
4050 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
4051 responseInfo, result);
4052 radioService[slotId]->checkReturnStatus(retStatus);
4054 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4060 int radio::sendUssdResponse(int slotId,
4061 int responseType, int serial, RIL_Errno e, void *response,
4062 size_t responseLen) {
4064 RLOGD("sendUssdResponse: serial %d", serial);
4067 if (radioService[slotId]->mRadioResponse != NULL) {
4068 RadioResponseInfo responseInfo = {};
4069 populateResponseInfo(responseInfo, serial, responseType, e);
4070 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
4072 radioService[slotId]->checkReturnStatus(retStatus);
4074 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
4081 int radio::cancelPendingUssdResponse(int slotId,
4082 int responseType, int serial, RIL_Errno e, void *response,
4083 size_t responseLen) {
4085 RLOGD("cancelPendingUssdResponse: serial %d", serial);
4088 if (radioService[slotId]->mRadioResponse != NULL) {
4089 RadioResponseInfo responseInfo = {};
4090 populateResponseInfo(responseInfo, serial, responseType, e);
4091 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
4093 radioService[slotId]->checkReturnStatus(retStatus);
4095 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
4102 int radio::getClirResponse(int slotId,
4103 int responseType, int serial, RIL_Errno e, void *response,
4104 size_t responseLen) {
4106 RLOGD("getClirResponse: serial %d", serial);
4109 if (radioService[slotId]->mRadioResponse != NULL) {
4110 RadioResponseInfo responseInfo = {};
4111 populateResponseInfo(responseInfo, serial, responseType, e);
4113 int numInts = responseLen / sizeof(int);
4114 if (response == NULL || numInts != 2) {
4115 RLOGE("getClirResponse Invalid response: NULL");
4116 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4118 int *pInt = (int *) response;
4122 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
4124 radioService[slotId]->checkReturnStatus(retStatus);
4126 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4132 int radio::setClirResponse(int slotId,
4133 int responseType, int serial, RIL_Errno e, void *response,
4134 size_t responseLen) {
4136 RLOGD("setClirResponse: serial %d", serial);
4139 if (radioService[slotId]->mRadioResponse != NULL) {
4140 RadioResponseInfo responseInfo = {};
4141 populateResponseInfo(responseInfo, serial, responseType, e);
4142 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
4144 radioService[slotId]->checkReturnStatus(retStatus);
4146 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4152 int radio::getCallForwardStatusResponse(int slotId,
4153 int responseType, int serial, RIL_Errno e,
4154 void *response, size_t responseLen) {
4156 RLOGD("getCallForwardStatusResponse: serial %d", serial);
4159 if (radioService[slotId]->mRadioResponse != NULL) {
4160 RadioResponseInfo responseInfo = {};
4161 populateResponseInfo(responseInfo, serial, responseType, e);
4162 hidl_vec<CallForwardInfo> callForwardInfos;
4164 if ((response == NULL && responseLen != 0)
4165 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4166 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4167 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4169 int num = responseLen / sizeof(RIL_CallForwardInfo *);
4170 callForwardInfos.resize(num);
4171 for (int i = 0 ; i < num; i++) {
4172 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4173 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4174 callForwardInfos[i].reason = resp->reason;
4175 callForwardInfos[i].serviceClass = resp->serviceClass;
4176 callForwardInfos[i].toa = resp->toa;
4177 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4178 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4182 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4183 responseInfo, callForwardInfos);
4184 radioService[slotId]->checkReturnStatus(retStatus);
4186 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4193 int radio::setCallForwardResponse(int slotId,
4194 int responseType, int serial, RIL_Errno e, void *response,
4195 size_t responseLen) {
4197 RLOGD("setCallForwardResponse: serial %d", serial);
4200 if (radioService[slotId]->mRadioResponse != NULL) {
4201 RadioResponseInfo responseInfo = {};
4202 populateResponseInfo(responseInfo, serial, responseType, e);
4203 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4205 radioService[slotId]->checkReturnStatus(retStatus);
4207 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4213 int radio::getCallWaitingResponse(int slotId,
4214 int responseType, int serial, RIL_Errno e, void *response,
4215 size_t responseLen) {
4217 RLOGD("getCallWaitingResponse: serial %d", serial);
4220 if (radioService[slotId]->mRadioResponse != NULL) {
4221 RadioResponseInfo responseInfo = {};
4222 populateResponseInfo(responseInfo, serial, responseType, e);
4223 bool enable = false;
4224 int serviceClass = -1;
4225 int numInts = responseLen / sizeof(int);
4226 if (response == NULL || numInts != 2) {
4227 RLOGE("getCallWaitingResponse Invalid response: NULL");
4228 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4230 int *pInt = (int *) response;
4231 enable = pInt[0] == 1 ? true : false;
4232 serviceClass = pInt[1];
4234 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4235 responseInfo, enable, serviceClass);
4236 radioService[slotId]->checkReturnStatus(retStatus);
4238 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4244 int radio::setCallWaitingResponse(int slotId,
4245 int responseType, int serial, RIL_Errno e, void *response,
4246 size_t responseLen) {
4248 RLOGD("setCallWaitingResponse: serial %d", serial);
4251 if (radioService[slotId]->mRadioResponse != NULL) {
4252 RadioResponseInfo responseInfo = {};
4253 populateResponseInfo(responseInfo, serial, responseType, e);
4254 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4256 radioService[slotId]->checkReturnStatus(retStatus);
4258 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4264 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4265 int responseType, int serial, RIL_Errno e,
4266 void *response, size_t responseLen) {
4268 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4271 if (radioService[slotId]->mRadioResponse != NULL) {
4272 RadioResponseInfo responseInfo = {};
4273 populateResponseInfo(responseInfo, serial, responseType, e);
4274 Return<void> retStatus =
4275 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4277 radioService[slotId]->checkReturnStatus(retStatus);
4279 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4286 int radio::acceptCallResponse(int slotId,
4287 int responseType, int serial, RIL_Errno e,
4288 void *response, size_t responseLen) {
4290 RLOGD("acceptCallResponse: 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->acceptCallResponse(
4298 radioService[slotId]->checkReturnStatus(retStatus);
4300 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4307 int radio::deactivateDataCallResponse(int slotId,
4308 int responseType, int serial, RIL_Errno e,
4309 void *response, size_t responseLen) {
4311 RLOGD("deactivateDataCallResponse: serial %d", serial);
4314 if (radioService[slotId]->mRadioResponse != NULL) {
4315 RadioResponseInfo responseInfo = {};
4316 populateResponseInfo(responseInfo, serial, responseType, e);
4317 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4319 radioService[slotId]->checkReturnStatus(retStatus);
4321 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4328 int radio::getFacilityLockForAppResponse(int slotId,
4329 int responseType, int serial, RIL_Errno e,
4330 void *response, size_t responseLen) {
4332 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4335 if (radioService[slotId]->mRadioResponse != NULL) {
4336 RadioResponseInfo responseInfo = {};
4337 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4338 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4339 getFacilityLockForAppResponse(responseInfo, ret);
4340 radioService[slotId]->checkReturnStatus(retStatus);
4342 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4349 int radio::setFacilityLockForAppResponse(int slotId,
4350 int responseType, int serial, RIL_Errno e,
4351 void *response, size_t responseLen) {
4353 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4356 if (radioService[slotId]->mRadioResponse != NULL) {
4357 RadioResponseInfo responseInfo = {};
4358 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4359 Return<void> retStatus
4360 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4362 radioService[slotId]->checkReturnStatus(retStatus);
4364 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4371 int radio::setBarringPasswordResponse(int slotId,
4372 int responseType, int serial, RIL_Errno e,
4373 void *response, size_t responseLen) {
4375 RLOGD("acceptCallResponse: serial %d", serial);
4378 if (radioService[slotId]->mRadioResponse != NULL) {
4379 RadioResponseInfo responseInfo = {};
4380 populateResponseInfo(responseInfo, serial, responseType, e);
4381 Return<void> retStatus
4382 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4383 radioService[slotId]->checkReturnStatus(retStatus);
4385 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4392 int radio::getNetworkSelectionModeResponse(int slotId,
4393 int responseType, int serial, RIL_Errno e, void *response,
4394 size_t responseLen) {
4396 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4399 if (radioService[slotId]->mRadioResponse != NULL) {
4400 RadioResponseInfo responseInfo = {};
4401 populateResponseInfo(responseInfo, serial, responseType, e);
4402 bool manual = false;
4403 if (response == NULL || responseLen != sizeof(int)) {
4404 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4405 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4407 int *pInt = (int *) response;
4408 manual = pInt[0] == 1 ? true : false;
4410 Return<void> retStatus
4411 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4414 radioService[slotId]->checkReturnStatus(retStatus);
4416 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4423 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4424 RIL_Errno e, void *response,
4425 size_t responseLen) {
4427 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4430 if (radioService[slotId]->mRadioResponse != NULL) {
4431 RadioResponseInfo responseInfo = {};
4432 populateResponseInfo(responseInfo, serial, responseType, e);
4433 Return<void> retStatus
4434 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4436 radioService[slotId]->checkReturnStatus(retStatus);
4438 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4445 int radio::setNetworkSelectionModeManualResponse(int slotId,
4446 int responseType, int serial, RIL_Errno e,
4447 void *response, size_t responseLen) {
4449 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4452 if (radioService[slotId]->mRadioResponse != NULL) {
4453 RadioResponseInfo responseInfo = {};
4454 populateResponseInfo(responseInfo, serial, responseType, e);
4455 Return<void> retStatus
4456 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4458 radioService[slotId]->checkReturnStatus(retStatus);
4460 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4467 int convertOperatorStatusToInt(const char *str) {
4468 if (strncmp("unknown", str, 9) == 0) {
4469 return (int) OperatorStatus::UNKNOWN;
4470 } else if (strncmp("available", str, 9) == 0) {
4471 return (int) OperatorStatus::AVAILABLE;
4472 } else if (strncmp("current", str, 9) == 0) {
4473 return (int) OperatorStatus::CURRENT;
4474 } else if (strncmp("forbidden", str, 9) == 0) {
4475 return (int) OperatorStatus::FORBIDDEN;
4481 int radio::getAvailableNetworksResponse(int slotId,
4482 int responseType, int serial, RIL_Errno e, void *response,
4483 size_t responseLen) {
4485 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4488 if (radioService[slotId]->mRadioResponse != NULL) {
4489 RadioResponseInfo responseInfo = {};
4490 populateResponseInfo(responseInfo, serial, responseType, e);
4491 hidl_vec<OperatorInfo> networks;
4492 if ((response == NULL && responseLen != 0)
4493 || responseLen % (4 * sizeof(char *))!= 0) {
4494 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4495 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4497 char **resp = (char **) response;
4498 int numStrings = responseLen / sizeof(char *);
4499 networks.resize(numStrings/4);
4500 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4501 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4502 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4503 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4504 int status = convertOperatorStatusToInt(resp[i + 3]);
4506 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4508 networks[j].status = (OperatorStatus) status;
4512 Return<void> retStatus
4513 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4515 radioService[slotId]->checkReturnStatus(retStatus);
4517 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4524 int radio::startDtmfResponse(int slotId,
4525 int responseType, int serial, RIL_Errno e,
4526 void *response, size_t responseLen) {
4528 RLOGD("startDtmfResponse: serial %d", serial);
4531 if (radioService[slotId]->mRadioResponse != NULL) {
4532 RadioResponseInfo responseInfo = {};
4533 populateResponseInfo(responseInfo, serial, responseType, e);
4534 Return<void> retStatus
4535 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4536 radioService[slotId]->checkReturnStatus(retStatus);
4538 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4544 int radio::stopDtmfResponse(int slotId,
4545 int responseType, int serial, RIL_Errno e,
4546 void *response, size_t responseLen) {
4548 RLOGD("stopDtmfResponse: serial %d", serial);
4551 if (radioService[slotId]->mRadioResponse != NULL) {
4552 RadioResponseInfo responseInfo = {};
4553 populateResponseInfo(responseInfo, serial, responseType, e);
4554 Return<void> retStatus
4555 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4556 radioService[slotId]->checkReturnStatus(retStatus);
4558 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4564 int radio::getBasebandVersionResponse(int slotId,
4565 int responseType, int serial, RIL_Errno e,
4566 void *response, size_t responseLen) {
4568 RLOGD("getBasebandVersionResponse: serial %d", serial);
4571 if (radioService[slotId]->mRadioResponse != NULL) {
4572 RadioResponseInfo responseInfo = {};
4573 populateResponseInfo(responseInfo, serial, responseType, e);
4574 Return<void> retStatus
4575 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4576 convertCharPtrToHidlString((char *) response));
4577 radioService[slotId]->checkReturnStatus(retStatus);
4579 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4585 int radio::separateConnectionResponse(int slotId,
4586 int responseType, int serial, RIL_Errno e,
4587 void *response, size_t responseLen) {
4589 RLOGD("separateConnectionResponse: serial %d", serial);
4592 if (radioService[slotId]->mRadioResponse != NULL) {
4593 RadioResponseInfo responseInfo = {};
4594 populateResponseInfo(responseInfo, serial, responseType, e);
4595 Return<void> retStatus
4596 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4597 radioService[slotId]->checkReturnStatus(retStatus);
4599 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4606 int radio::setMuteResponse(int slotId,
4607 int responseType, int serial, RIL_Errno e,
4608 void *response, size_t responseLen) {
4610 RLOGD("setMuteResponse: 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->setMuteResponse(responseInfo);
4618 radioService[slotId]->checkReturnStatus(retStatus);
4620 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4626 int radio::getMuteResponse(int slotId,
4627 int responseType, int serial, RIL_Errno e, void *response,
4628 size_t responseLen) {
4630 RLOGD("getMuteResponse: serial %d", serial);
4633 if (radioService[slotId]->mRadioResponse != NULL) {
4634 RadioResponseInfo responseInfo = {};
4635 populateResponseInfo(responseInfo, serial, responseType, e);
4636 bool enable = false;
4637 if (response == NULL || responseLen != sizeof(int)) {
4638 RLOGE("getMuteResponse Invalid response: NULL");
4639 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4641 int *pInt = (int *) response;
4642 enable = pInt[0] == 1 ? true : false;
4644 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4646 radioService[slotId]->checkReturnStatus(retStatus);
4648 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4654 int radio::getClipResponse(int slotId,
4655 int responseType, int serial, RIL_Errno e,
4656 void *response, size_t responseLen) {
4658 RLOGD("getClipResponse: serial %d", serial);
4661 if (radioService[slotId]->mRadioResponse != NULL) {
4662 RadioResponseInfo responseInfo = {};
4663 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4664 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4666 radioService[slotId]->checkReturnStatus(retStatus);
4668 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4674 int radio::getDataCallListResponse(int slotId,
4675 int responseType, int serial, RIL_Errno e,
4676 void *response, size_t responseLen) {
4678 RLOGD("getDataCallListResponse: serial %d", serial);
4681 if (radioService[slotId]->mRadioResponse != NULL) {
4682 RadioResponseInfo responseInfo = {};
4683 populateResponseInfo(responseInfo, serial, responseType, e);
4685 hidl_vec<SetupDataCallResult> ret;
4686 if ((response == NULL && responseLen != 0)
4687 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4688 RLOGE("getDataCallListResponse: invalid response");
4689 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4691 convertRilDataCallListToHal(response, responseLen, ret);
4694 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4696 radioService[slotId]->checkReturnStatus(retStatus);
4698 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4704 int radio::setSuppServiceNotificationsResponse(int slotId,
4705 int responseType, int serial, RIL_Errno e,
4706 void *response, size_t responseLen) {
4708 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4711 if (radioService[slotId]->mRadioResponse != NULL) {
4712 RadioResponseInfo responseInfo = {};
4713 populateResponseInfo(responseInfo, serial, responseType, e);
4714 Return<void> retStatus
4715 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4717 radioService[slotId]->checkReturnStatus(retStatus);
4719 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4726 int radio::deleteSmsOnSimResponse(int slotId,
4727 int responseType, int serial, RIL_Errno e,
4728 void *response, size_t responseLen) {
4730 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4733 if (radioService[slotId]->mRadioResponse != NULL) {
4734 RadioResponseInfo responseInfo = {};
4735 populateResponseInfo(responseInfo, serial, responseType, e);
4736 Return<void> retStatus
4737 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4738 radioService[slotId]->checkReturnStatus(retStatus);
4740 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4746 int radio::setBandModeResponse(int slotId,
4747 int responseType, int serial, RIL_Errno e,
4748 void *response, size_t responseLen) {
4750 RLOGD("setBandModeResponse: 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->setBandModeResponse(responseInfo);
4758 radioService[slotId]->checkReturnStatus(retStatus);
4760 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4766 int radio::writeSmsToSimResponse(int slotId,
4767 int responseType, int serial, RIL_Errno e,
4768 void *response, size_t responseLen) {
4770 RLOGD("writeSmsToSimResponse: serial %d", serial);
4773 if (radioService[slotId]->mRadioResponse != NULL) {
4774 RadioResponseInfo responseInfo = {};
4775 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4776 Return<void> retStatus
4777 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4778 radioService[slotId]->checkReturnStatus(retStatus);
4780 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4786 int radio::getAvailableBandModesResponse(int slotId,
4787 int responseType, int serial, RIL_Errno e, void *response,
4788 size_t responseLen) {
4790 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4793 if (radioService[slotId]->mRadioResponse != NULL) {
4794 RadioResponseInfo responseInfo = {};
4795 populateResponseInfo(responseInfo, serial, responseType, e);
4796 hidl_vec<RadioBandMode> modes;
4797 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
4798 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4799 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4801 int *pInt = (int *) response;
4802 int numInts = responseLen / sizeof(int);
4803 modes.resize(numInts);
4804 for (int i = 0; i < numInts; i++) {
4805 modes[i] = (RadioBandMode) pInt[i];
4808 Return<void> retStatus
4809 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4811 radioService[slotId]->checkReturnStatus(retStatus);
4813 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4820 int radio::sendEnvelopeResponse(int slotId,
4821 int responseType, int serial, RIL_Errno e,
4822 void *response, size_t responseLen) {
4824 RLOGD("sendEnvelopeResponse: serial %d", serial);
4827 if (radioService[slotId]->mRadioResponse != NULL) {
4828 RadioResponseInfo responseInfo = {};
4829 populateResponseInfo(responseInfo, serial, responseType, e);
4830 Return<void> retStatus
4831 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4832 convertCharPtrToHidlString((char *) response));
4833 radioService[slotId]->checkReturnStatus(retStatus);
4835 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4841 int radio::sendTerminalResponseToSimResponse(int slotId,
4842 int responseType, int serial, RIL_Errno e,
4843 void *response, size_t responseLen) {
4845 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4848 if (radioService[slotId]->mRadioResponse != NULL) {
4849 RadioResponseInfo responseInfo = {};
4850 populateResponseInfo(responseInfo, serial, responseType, e);
4851 Return<void> retStatus
4852 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4854 radioService[slotId]->checkReturnStatus(retStatus);
4856 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4863 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4864 int responseType, int serial,
4865 RIL_Errno e, void *response,
4866 size_t responseLen) {
4868 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4871 if (radioService[slotId]->mRadioResponse != NULL) {
4872 RadioResponseInfo responseInfo = {};
4873 populateResponseInfo(responseInfo, serial, responseType, e);
4874 Return<void> retStatus
4875 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4877 radioService[slotId]->checkReturnStatus(retStatus);
4879 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4886 int radio::explicitCallTransferResponse(int slotId,
4887 int responseType, int serial, RIL_Errno e,
4888 void *response, size_t responseLen) {
4890 RLOGD("explicitCallTransferResponse: serial %d", serial);
4893 if (radioService[slotId]->mRadioResponse != NULL) {
4894 RadioResponseInfo responseInfo = {};
4895 populateResponseInfo(responseInfo, serial, responseType, e);
4896 Return<void> retStatus
4897 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4898 radioService[slotId]->checkReturnStatus(retStatus);
4900 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4907 int radio::setPreferredNetworkTypeResponse(int slotId,
4908 int responseType, int serial, RIL_Errno e,
4909 void *response, size_t responseLen) {
4911 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4914 if (radioService[slotId]->mRadioResponse != NULL) {
4915 RadioResponseInfo responseInfo = {};
4916 populateResponseInfo(responseInfo, serial, responseType, e);
4917 Return<void> retStatus
4918 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4920 radioService[slotId]->checkReturnStatus(retStatus);
4922 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4930 int radio::getPreferredNetworkTypeResponse(int slotId,
4931 int responseType, int serial, RIL_Errno e,
4932 void *response, size_t responseLen) {
4934 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4937 if (radioService[slotId]->mRadioResponse != NULL) {
4938 RadioResponseInfo responseInfo = {};
4939 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4940 Return<void> retStatus
4941 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4942 responseInfo, (PreferredNetworkType) ret);
4943 radioService[slotId]->checkReturnStatus(retStatus);
4945 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4952 int radio::getNeighboringCidsResponse(int slotId,
4953 int responseType, int serial, RIL_Errno e,
4954 void *response, size_t responseLen) {
4956 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4959 if (radioService[slotId]->mRadioResponse != NULL) {
4960 RadioResponseInfo responseInfo = {};
4961 populateResponseInfo(responseInfo, serial, responseType, e);
4962 hidl_vec<NeighboringCell> cells;
4964 if ((response == NULL && responseLen != 0)
4965 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4966 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4967 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4969 int num = responseLen / sizeof(RIL_NeighboringCell *);
4971 for (int i = 0 ; i < num; i++) {
4972 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4973 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4974 cells[i].rssi = resp->rssi;
4978 Return<void> retStatus
4979 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4981 radioService[slotId]->checkReturnStatus(retStatus);
4983 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4990 int radio::setLocationUpdatesResponse(int slotId,
4991 int responseType, int serial, RIL_Errno e,
4992 void *response, size_t responseLen) {
4994 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4997 if (radioService[slotId]->mRadioResponse != NULL) {
4998 RadioResponseInfo responseInfo = {};
4999 populateResponseInfo(responseInfo, serial, responseType, e);
5000 Return<void> retStatus
5001 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
5002 radioService[slotId]->checkReturnStatus(retStatus);
5004 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
5011 int radio::setCdmaSubscriptionSourceResponse(int slotId,
5012 int responseType, int serial, RIL_Errno e,
5013 void *response, size_t responseLen) {
5015 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
5018 if (radioService[slotId]->mRadioResponse != NULL) {
5019 RadioResponseInfo responseInfo = {};
5020 populateResponseInfo(responseInfo, serial, responseType, e);
5021 Return<void> retStatus
5022 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
5024 radioService[slotId]->checkReturnStatus(retStatus);
5026 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5033 int radio::setCdmaRoamingPreferenceResponse(int slotId,
5034 int responseType, int serial, RIL_Errno e,
5035 void *response, size_t responseLen) {
5037 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
5040 if (radioService[slotId]->mRadioResponse != NULL) {
5041 RadioResponseInfo responseInfo = {};
5042 populateResponseInfo(responseInfo, serial, responseType, e);
5043 Return<void> retStatus
5044 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
5046 radioService[slotId]->checkReturnStatus(retStatus);
5048 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5055 int radio::getCdmaRoamingPreferenceResponse(int slotId,
5056 int responseType, int serial, RIL_Errno e,
5057 void *response, size_t responseLen) {
5059 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
5062 if (radioService[slotId]->mRadioResponse != NULL) {
5063 RadioResponseInfo responseInfo = {};
5064 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5065 Return<void> retStatus
5066 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
5067 responseInfo, (CdmaRoamingType) ret);
5068 radioService[slotId]->checkReturnStatus(retStatus);
5070 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5077 int radio::setTTYModeResponse(int slotId,
5078 int responseType, int serial, RIL_Errno e,
5079 void *response, size_t responseLen) {
5081 RLOGD("setTTYModeResponse: serial %d", serial);
5084 if (radioService[slotId]->mRadioResponse != NULL) {
5085 RadioResponseInfo responseInfo = {};
5086 populateResponseInfo(responseInfo, serial, responseType, e);
5087 Return<void> retStatus
5088 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
5089 radioService[slotId]->checkReturnStatus(retStatus);
5091 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5097 int radio::getTTYModeResponse(int slotId,
5098 int responseType, int serial, RIL_Errno e,
5099 void *response, size_t responseLen) {
5101 RLOGD("getTTYModeResponse: 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->getTTYModeResponse(responseInfo,
5110 radioService[slotId]->checkReturnStatus(retStatus);
5112 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5118 int radio::setPreferredVoicePrivacyResponse(int slotId,
5119 int responseType, int serial, RIL_Errno e,
5120 void *response, size_t responseLen) {
5122 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
5125 if (radioService[slotId]->mRadioResponse != NULL) {
5126 RadioResponseInfo responseInfo = {};
5127 populateResponseInfo(responseInfo, serial, responseType, e);
5128 Return<void> retStatus
5129 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
5131 radioService[slotId]->checkReturnStatus(retStatus);
5133 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5140 int radio::getPreferredVoicePrivacyResponse(int slotId,
5141 int responseType, int serial, RIL_Errno e,
5142 void *response, size_t responseLen) {
5144 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
5147 if (radioService[slotId]->mRadioResponse != NULL) {
5148 RadioResponseInfo responseInfo = {};
5149 populateResponseInfo(responseInfo, serial, responseType, e);
5150 bool enable = false;
5151 int numInts = responseLen / sizeof(int);
5152 if (response == NULL || numInts != 1) {
5153 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
5154 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5156 int *pInt = (int *) response;
5157 enable = pInt[0] == 1 ? true : false;
5159 Return<void> retStatus
5160 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5161 responseInfo, enable);
5162 radioService[slotId]->checkReturnStatus(retStatus);
5164 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5171 int radio::sendCDMAFeatureCodeResponse(int slotId,
5172 int responseType, int serial, RIL_Errno e,
5173 void *response, size_t responseLen) {
5175 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5178 if (radioService[slotId]->mRadioResponse != NULL) {
5179 RadioResponseInfo responseInfo = {};
5180 populateResponseInfo(responseInfo, serial, responseType, e);
5181 Return<void> retStatus
5182 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5183 radioService[slotId]->checkReturnStatus(retStatus);
5185 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5192 int radio::sendBurstDtmfResponse(int slotId,
5193 int responseType, int serial, RIL_Errno e,
5194 void *response, size_t responseLen) {
5196 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5199 if (radioService[slotId]->mRadioResponse != NULL) {
5200 RadioResponseInfo responseInfo = {};
5201 populateResponseInfo(responseInfo, serial, responseType, e);
5202 Return<void> retStatus
5203 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5204 radioService[slotId]->checkReturnStatus(retStatus);
5206 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5212 int radio::sendCdmaSmsResponse(int slotId,
5213 int responseType, int serial, RIL_Errno e, void *response,
5214 size_t responseLen) {
5216 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5219 if (radioService[slotId]->mRadioResponse != NULL) {
5220 RadioResponseInfo responseInfo = {};
5221 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5224 Return<void> retStatus
5225 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5226 radioService[slotId]->checkReturnStatus(retStatus);
5228 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5234 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5235 int responseType, int serial, RIL_Errno e,
5236 void *response, size_t responseLen) {
5238 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: 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->acknowledgeLastIncomingCdmaSmsResponse(
5247 radioService[slotId]->checkReturnStatus(retStatus);
5249 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5256 int radio::getGsmBroadcastConfigResponse(int slotId,
5257 int responseType, int serial, RIL_Errno e,
5258 void *response, size_t responseLen) {
5260 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5263 if (radioService[slotId]->mRadioResponse != NULL) {
5264 RadioResponseInfo responseInfo = {};
5265 populateResponseInfo(responseInfo, serial, responseType, e);
5266 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5268 if ((response == NULL && responseLen != 0)
5269 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5270 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5271 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5273 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5274 configs.resize(num);
5275 for (int i = 0 ; i < num; i++) {
5276 RIL_GSM_BroadcastSmsConfigInfo *resp =
5277 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5278 configs[i].fromServiceId = resp->fromServiceId;
5279 configs[i].toServiceId = resp->toServiceId;
5280 configs[i].fromCodeScheme = resp->fromCodeScheme;
5281 configs[i].toCodeScheme = resp->toCodeScheme;
5282 configs[i].selected = resp->selected == 1 ? true : false;
5286 Return<void> retStatus
5287 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5289 radioService[slotId]->checkReturnStatus(retStatus);
5291 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5298 int radio::setGsmBroadcastConfigResponse(int slotId,
5299 int responseType, int serial, RIL_Errno e,
5300 void *response, size_t responseLen) {
5302 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5305 if (radioService[slotId]->mRadioResponse != NULL) {
5306 RadioResponseInfo responseInfo = {};
5307 populateResponseInfo(responseInfo, serial, responseType, e);
5308 Return<void> retStatus
5309 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5310 radioService[slotId]->checkReturnStatus(retStatus);
5312 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5319 int radio::setGsmBroadcastActivationResponse(int slotId,
5320 int responseType, int serial, RIL_Errno e,
5321 void *response, size_t responseLen) {
5323 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5326 if (radioService[slotId]->mRadioResponse != NULL) {
5327 RadioResponseInfo responseInfo = {};
5328 populateResponseInfo(responseInfo, serial, responseType, e);
5329 Return<void> retStatus
5330 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5332 radioService[slotId]->checkReturnStatus(retStatus);
5334 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5341 int radio::getCdmaBroadcastConfigResponse(int slotId,
5342 int responseType, int serial, RIL_Errno e,
5343 void *response, size_t responseLen) {
5345 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5348 if (radioService[slotId]->mRadioResponse != NULL) {
5349 RadioResponseInfo responseInfo = {};
5350 populateResponseInfo(responseInfo, serial, responseType, e);
5351 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5353 if ((response == NULL && responseLen != 0)
5354 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5355 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5356 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5358 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5359 configs.resize(num);
5360 for (int i = 0 ; i < num; i++) {
5361 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5362 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5363 configs[i].serviceCategory = resp->service_category;
5364 configs[i].language = resp->language;
5365 configs[i].selected = resp->selected == 1 ? true : false;
5369 Return<void> retStatus
5370 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5372 radioService[slotId]->checkReturnStatus(retStatus);
5374 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5381 int radio::setCdmaBroadcastConfigResponse(int slotId,
5382 int responseType, int serial, RIL_Errno e,
5383 void *response, size_t responseLen) {
5385 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5388 if (radioService[slotId]->mRadioResponse != NULL) {
5389 RadioResponseInfo responseInfo = {};
5390 populateResponseInfo(responseInfo, serial, responseType, e);
5391 Return<void> retStatus
5392 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5394 radioService[slotId]->checkReturnStatus(retStatus);
5396 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5403 int radio::setCdmaBroadcastActivationResponse(int slotId,
5404 int responseType, int serial, RIL_Errno e,
5405 void *response, size_t responseLen) {
5407 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5410 if (radioService[slotId]->mRadioResponse != NULL) {
5411 RadioResponseInfo responseInfo = {};
5412 populateResponseInfo(responseInfo, serial, responseType, e);
5413 Return<void> retStatus
5414 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5416 radioService[slotId]->checkReturnStatus(retStatus);
5418 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5425 int radio::getCDMASubscriptionResponse(int slotId,
5426 int responseType, int serial, RIL_Errno e, void *response,
5427 size_t responseLen) {
5429 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5432 if (radioService[slotId]->mRadioResponse != NULL) {
5433 RadioResponseInfo responseInfo = {};
5434 populateResponseInfo(responseInfo, serial, responseType, e);
5436 int numStrings = responseLen / sizeof(char *);
5437 hidl_string emptyString;
5438 if (response == NULL || numStrings != 5) {
5439 RLOGE("getOperatorResponse Invalid response: NULL");
5440 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5441 Return<void> retStatus
5442 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5443 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5444 radioService[slotId]->checkReturnStatus(retStatus);
5446 char **resp = (char **) response;
5447 Return<void> retStatus
5448 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5450 convertCharPtrToHidlString(resp[0]),
5451 convertCharPtrToHidlString(resp[1]),
5452 convertCharPtrToHidlString(resp[2]),
5453 convertCharPtrToHidlString(resp[3]),
5454 convertCharPtrToHidlString(resp[4]));
5455 radioService[slotId]->checkReturnStatus(retStatus);
5458 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5465 int radio::writeSmsToRuimResponse(int slotId,
5466 int responseType, int serial, RIL_Errno e,
5467 void *response, size_t responseLen) {
5469 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5472 if (radioService[slotId]->mRadioResponse != NULL) {
5473 RadioResponseInfo responseInfo = {};
5474 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5475 Return<void> retStatus
5476 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5477 radioService[slotId]->checkReturnStatus(retStatus);
5479 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5485 int radio::deleteSmsOnRuimResponse(int slotId,
5486 int responseType, int serial, RIL_Errno e,
5487 void *response, size_t responseLen) {
5489 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5492 if (radioService[slotId]->mRadioResponse != NULL) {
5493 RadioResponseInfo responseInfo = {};
5494 populateResponseInfo(responseInfo, serial, responseType, e);
5495 Return<void> retStatus
5496 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5497 radioService[slotId]->checkReturnStatus(retStatus);
5499 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5505 int radio::getDeviceIdentityResponse(int slotId,
5506 int responseType, int serial, RIL_Errno e, void *response,
5507 size_t responseLen) {
5509 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5512 if (radioService[slotId]->mRadioResponse != NULL) {
5513 RadioResponseInfo responseInfo = {};
5514 populateResponseInfo(responseInfo, serial, responseType, e);
5516 int numStrings = responseLen / sizeof(char *);
5517 hidl_string emptyString;
5518 if (response == NULL || numStrings != 4) {
5519 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5520 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5521 Return<void> retStatus
5522 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5523 emptyString, emptyString, emptyString, emptyString);
5524 radioService[slotId]->checkReturnStatus(retStatus);
5526 char **resp = (char **) response;
5527 Return<void> retStatus
5528 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5529 convertCharPtrToHidlString(resp[0]),
5530 convertCharPtrToHidlString(resp[1]),
5531 convertCharPtrToHidlString(resp[2]),
5532 convertCharPtrToHidlString(resp[3]));
5533 radioService[slotId]->checkReturnStatus(retStatus);
5536 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5543 int radio::exitEmergencyCallbackModeResponse(int slotId,
5544 int responseType, int serial, RIL_Errno e,
5545 void *response, size_t responseLen) {
5547 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5550 if (radioService[slotId]->mRadioResponse != NULL) {
5551 RadioResponseInfo responseInfo = {};
5552 populateResponseInfo(responseInfo, serial, responseType, e);
5553 Return<void> retStatus
5554 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5556 radioService[slotId]->checkReturnStatus(retStatus);
5558 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5565 int radio::getSmscAddressResponse(int slotId,
5566 int responseType, int serial, RIL_Errno e,
5567 void *response, size_t responseLen) {
5569 RLOGD("getSmscAddressResponse: serial %d", serial);
5572 if (radioService[slotId]->mRadioResponse != NULL) {
5573 RadioResponseInfo responseInfo = {};
5574 populateResponseInfo(responseInfo, serial, responseType, e);
5575 Return<void> retStatus
5576 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5577 convertCharPtrToHidlString((char *) response));
5578 radioService[slotId]->checkReturnStatus(retStatus);
5580 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5586 int radio::setSmscAddressResponse(int slotId,
5587 int responseType, int serial, RIL_Errno e,
5588 void *response, size_t responseLen) {
5590 RLOGD("setSmscAddressResponse: serial %d", serial);
5593 if (radioService[slotId]->mRadioResponse != NULL) {
5594 RadioResponseInfo responseInfo = {};
5595 populateResponseInfo(responseInfo, serial, responseType, e);
5596 Return<void> retStatus
5597 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5598 radioService[slotId]->checkReturnStatus(retStatus);
5600 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5606 int radio::reportSmsMemoryStatusResponse(int slotId,
5607 int responseType, int serial, RIL_Errno e,
5608 void *response, size_t responseLen) {
5610 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5613 if (radioService[slotId]->mRadioResponse != NULL) {
5614 RadioResponseInfo responseInfo = {};
5615 populateResponseInfo(responseInfo, serial, responseType, e);
5616 Return<void> retStatus
5617 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5618 radioService[slotId]->checkReturnStatus(retStatus);
5620 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5627 int radio::reportStkServiceIsRunningResponse(int slotId,
5628 int responseType, int serial, RIL_Errno e,
5629 void *response, size_t responseLen) {
5631 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5634 if (radioService[slotId]->mRadioResponse != NULL) {
5635 RadioResponseInfo responseInfo = {};
5636 populateResponseInfo(responseInfo, serial, responseType, e);
5637 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5638 reportStkServiceIsRunningResponse(responseInfo);
5639 radioService[slotId]->checkReturnStatus(retStatus);
5641 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5648 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5649 int responseType, int serial, RIL_Errno e,
5650 void *response, size_t responseLen) {
5652 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5655 if (radioService[slotId]->mRadioResponse != NULL) {
5656 RadioResponseInfo responseInfo = {};
5657 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5658 Return<void> retStatus
5659 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5660 responseInfo, (CdmaSubscriptionSource) ret);
5661 radioService[slotId]->checkReturnStatus(retStatus);
5663 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5670 int radio::requestIsimAuthenticationResponse(int slotId,
5671 int responseType, int serial, RIL_Errno e,
5672 void *response, size_t responseLen) {
5674 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5677 if (radioService[slotId]->mRadioResponse != NULL) {
5678 RadioResponseInfo responseInfo = {};
5679 populateResponseInfo(responseInfo, serial, responseType, e);
5680 Return<void> retStatus
5681 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5683 convertCharPtrToHidlString((char *) response));
5684 radioService[slotId]->checkReturnStatus(retStatus);
5686 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5693 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5695 int serial, RIL_Errno e, void *response,
5696 size_t responseLen) {
5698 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5701 if (radioService[slotId]->mRadioResponse != NULL) {
5702 RadioResponseInfo responseInfo = {};
5703 populateResponseInfo(responseInfo, serial, responseType, e);
5704 Return<void> retStatus
5705 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5707 radioService[slotId]->checkReturnStatus(retStatus);
5709 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5716 int radio::sendEnvelopeWithStatusResponse(int slotId,
5717 int responseType, int serial, RIL_Errno e, void *response,
5718 size_t responseLen) {
5720 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5723 if (radioService[slotId]->mRadioResponse != NULL) {
5724 RadioResponseInfo responseInfo = {};
5725 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5726 response, responseLen);
5728 Return<void> retStatus
5729 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5731 radioService[slotId]->checkReturnStatus(retStatus);
5733 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5740 int radio::getVoiceRadioTechnologyResponse(int slotId,
5741 int responseType, int serial, RIL_Errno e,
5742 void *response, size_t responseLen) {
5744 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5747 if (radioService[slotId]->mRadioResponse != NULL) {
5748 RadioResponseInfo responseInfo = {};
5749 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5750 Return<void> retStatus
5751 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5752 responseInfo, (RadioTechnology) ret);
5753 radioService[slotId]->checkReturnStatus(retStatus);
5755 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5762 int radio::getCellInfoListResponse(int slotId,
5764 int serial, RIL_Errno e, void *response,
5765 size_t responseLen) {
5767 RLOGD("getCellInfoListResponse: serial %d", serial);
5770 if (radioService[slotId]->mRadioResponse != NULL) {
5771 RadioResponseInfo responseInfo = {};
5772 populateResponseInfo(responseInfo, serial, responseType, e);
5774 hidl_vec<CellInfo> ret;
5775 if ((response == NULL && responseLen != 0)
5776 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5777 RLOGE("getCellInfoListResponse: Invalid response");
5778 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5780 convertRilCellInfoListToHal(response, responseLen, ret);
5783 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5785 radioService[slotId]->checkReturnStatus(retStatus);
5787 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5793 int radio::setCellInfoListRateResponse(int slotId,
5795 int serial, RIL_Errno e, void *response,
5796 size_t responseLen) {
5798 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5801 if (radioService[slotId]->mRadioResponse != NULL) {
5802 RadioResponseInfo responseInfo = {};
5803 populateResponseInfo(responseInfo, serial, responseType, e);
5804 Return<void> retStatus
5805 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5806 radioService[slotId]->checkReturnStatus(retStatus);
5808 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5815 int radio::setInitialAttachApnResponse(int slotId,
5816 int responseType, int serial, RIL_Errno e,
5817 void *response, size_t responseLen) {
5819 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5822 if (radioService[slotId]->mRadioResponse != NULL) {
5823 RadioResponseInfo responseInfo = {};
5824 populateResponseInfo(responseInfo, serial, responseType, e);
5825 Return<void> retStatus
5826 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5827 radioService[slotId]->checkReturnStatus(retStatus);
5829 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5836 int radio::getImsRegistrationStateResponse(int slotId,
5837 int responseType, int serial, RIL_Errno e,
5838 void *response, size_t responseLen) {
5840 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5843 if (radioService[slotId]->mRadioResponse != NULL) {
5844 RadioResponseInfo responseInfo = {};
5845 populateResponseInfo(responseInfo, serial, responseType, e);
5846 bool isRegistered = false;
5848 int numInts = responseLen / sizeof(int);
5849 if (response == NULL || numInts != 2) {
5850 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5851 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5853 int *pInt = (int *) response;
5854 isRegistered = pInt[0] == 1 ? true : false;
5855 ratFamily = pInt[1];
5857 Return<void> retStatus
5858 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5859 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5860 radioService[slotId]->checkReturnStatus(retStatus);
5862 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5869 int radio::sendImsSmsResponse(int slotId,
5870 int responseType, int serial, RIL_Errno e, void *response,
5871 size_t responseLen) {
5873 RLOGD("sendImsSmsResponse: serial %d", serial);
5876 if (radioService[slotId]->mRadioResponse != NULL) {
5877 RadioResponseInfo responseInfo = {};
5878 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5881 Return<void> retStatus
5882 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5883 radioService[slotId]->checkReturnStatus(retStatus);
5885 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5891 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5892 int responseType, int serial, RIL_Errno e,
5893 void *response, size_t responseLen) {
5895 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5898 if (radioService[slotId]->mRadioResponse != NULL) {
5899 RadioResponseInfo responseInfo = {};
5900 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5903 Return<void> retStatus
5904 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5905 responseInfo, result);
5906 radioService[slotId]->checkReturnStatus(retStatus);
5908 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5915 int radio::iccOpenLogicalChannelResponse(int slotId,
5916 int responseType, int serial, RIL_Errno e, void *response,
5917 size_t responseLen) {
5919 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5922 if (radioService[slotId]->mRadioResponse != NULL) {
5923 RadioResponseInfo responseInfo = {};
5924 populateResponseInfo(responseInfo, serial, responseType, e);
5926 hidl_vec<int8_t> selectResponse;
5927 int numInts = responseLen / sizeof(int);
5928 if (response == NULL || responseLen % sizeof(int) != 0) {
5929 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5930 if (response != NULL) {
5931 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5934 int *pInt = (int *) response;
5935 channelId = pInt[0];
5936 selectResponse.resize(numInts - 1);
5937 for (int i = 1; i < numInts; i++) {
5938 selectResponse[i - 1] = (int8_t) pInt[i];
5941 Return<void> retStatus
5942 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5943 channelId, selectResponse);
5944 radioService[slotId]->checkReturnStatus(retStatus);
5946 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5953 int radio::iccCloseLogicalChannelResponse(int slotId,
5954 int responseType, int serial, RIL_Errno e,
5955 void *response, size_t responseLen) {
5957 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5960 if (radioService[slotId]->mRadioResponse != NULL) {
5961 RadioResponseInfo responseInfo = {};
5962 populateResponseInfo(responseInfo, serial, responseType, e);
5963 Return<void> retStatus
5964 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5966 radioService[slotId]->checkReturnStatus(retStatus);
5968 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5975 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5976 int responseType, int serial, RIL_Errno e,
5977 void *response, size_t responseLen) {
5979 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5982 if (radioService[slotId]->mRadioResponse != NULL) {
5983 RadioResponseInfo responseInfo = {};
5984 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5987 Return<void> retStatus
5988 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5989 responseInfo, result);
5990 radioService[slotId]->checkReturnStatus(retStatus);
5992 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5999 int radio::nvReadItemResponse(int slotId,
6000 int responseType, int serial, RIL_Errno e,
6001 void *response, size_t responseLen) {
6003 RLOGD("nvReadItemResponse: serial %d", serial);
6006 if (radioService[slotId]->mRadioResponse != NULL) {
6007 RadioResponseInfo responseInfo = {};
6008 populateResponseInfo(responseInfo, serial, responseType, e);
6009 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
6011 convertCharPtrToHidlString((char *) response));
6012 radioService[slotId]->checkReturnStatus(retStatus);
6014 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6020 int radio::nvWriteItemResponse(int slotId,
6021 int responseType, int serial, RIL_Errno e,
6022 void *response, size_t responseLen) {
6024 RLOGD("nvWriteItemResponse: serial %d", serial);
6027 if (radioService[slotId]->mRadioResponse != NULL) {
6028 RadioResponseInfo responseInfo = {};
6029 populateResponseInfo(responseInfo, serial, responseType, e);
6030 Return<void> retStatus
6031 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
6032 radioService[slotId]->checkReturnStatus(retStatus);
6034 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6040 int radio::nvWriteCdmaPrlResponse(int slotId,
6041 int responseType, int serial, RIL_Errno e,
6042 void *response, size_t responseLen) {
6044 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
6047 if (radioService[slotId]->mRadioResponse != NULL) {
6048 RadioResponseInfo responseInfo = {};
6049 populateResponseInfo(responseInfo, serial, responseType, e);
6050 Return<void> retStatus
6051 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
6052 radioService[slotId]->checkReturnStatus(retStatus);
6054 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6060 int radio::nvResetConfigResponse(int slotId,
6061 int responseType, int serial, RIL_Errno e,
6062 void *response, size_t responseLen) {
6064 RLOGD("nvResetConfigResponse: serial %d", serial);
6067 if (radioService[slotId]->mRadioResponse != NULL) {
6068 RadioResponseInfo responseInfo = {};
6069 populateResponseInfo(responseInfo, serial, responseType, e);
6070 Return<void> retStatus
6071 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
6072 radioService[slotId]->checkReturnStatus(retStatus);
6074 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6080 int radio::setUiccSubscriptionResponse(int slotId,
6081 int responseType, int serial, RIL_Errno e,
6082 void *response, size_t responseLen) {
6084 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
6087 if (radioService[slotId]->mRadioResponse != NULL) {
6088 RadioResponseInfo responseInfo = {};
6089 populateResponseInfo(responseInfo, serial, responseType, e);
6090 Return<void> retStatus
6091 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
6092 radioService[slotId]->checkReturnStatus(retStatus);
6094 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
6101 int radio::setDataAllowedResponse(int slotId,
6102 int responseType, int serial, RIL_Errno e,
6103 void *response, size_t responseLen) {
6105 RLOGD("setDataAllowedResponse: serial %d", serial);
6108 if (radioService[slotId]->mRadioResponse != NULL) {
6109 RadioResponseInfo responseInfo = {};
6110 populateResponseInfo(responseInfo, serial, responseType, e);
6111 Return<void> retStatus
6112 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
6113 radioService[slotId]->checkReturnStatus(retStatus);
6115 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6121 int radio::getHardwareConfigResponse(int slotId,
6122 int responseType, int serial, RIL_Errno e,
6123 void *response, size_t responseLen) {
6125 RLOGD("getHardwareConfigResponse: serial %d", serial);
6128 if (radioService[slotId]->mRadioResponse != NULL) {
6129 RadioResponseInfo responseInfo = {};
6130 populateResponseInfo(responseInfo, serial, responseType, e);
6132 hidl_vec<HardwareConfig> result;
6133 if ((response == NULL && responseLen != 0)
6134 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
6135 RLOGE("hardwareConfigChangedInd: invalid response");
6136 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6138 convertRilHardwareConfigListToHal(response, responseLen, result);
6141 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
6142 responseInfo, result);
6143 radioService[slotId]->checkReturnStatus(retStatus);
6145 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6151 int radio::requestIccSimAuthenticationResponse(int slotId,
6152 int responseType, int serial, RIL_Errno e,
6153 void *response, size_t responseLen) {
6155 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6158 if (radioService[slotId]->mRadioResponse != NULL) {
6159 RadioResponseInfo responseInfo = {};
6160 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6163 Return<void> retStatus
6164 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6165 responseInfo, result);
6166 radioService[slotId]->checkReturnStatus(retStatus);
6168 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6175 int radio::setDataProfileResponse(int slotId,
6176 int responseType, int serial, RIL_Errno e,
6177 void *response, size_t responseLen) {
6179 RLOGD("setDataProfileResponse: serial %d", serial);
6182 if (radioService[slotId]->mRadioResponse != NULL) {
6183 RadioResponseInfo responseInfo = {};
6184 populateResponseInfo(responseInfo, serial, responseType, e);
6185 Return<void> retStatus
6186 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6187 radioService[slotId]->checkReturnStatus(retStatus);
6189 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6195 int radio::requestShutdownResponse(int slotId,
6196 int responseType, int serial, RIL_Errno e,
6197 void *response, size_t responseLen) {
6199 RLOGD("requestShutdownResponse: serial %d", serial);
6202 if (radioService[slotId]->mRadioResponse != NULL) {
6203 RadioResponseInfo responseInfo = {};
6204 populateResponseInfo(responseInfo, serial, responseType, e);
6205 Return<void> retStatus
6206 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6207 radioService[slotId]->checkReturnStatus(retStatus);
6209 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6215 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6216 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6217 populateResponseInfo(responseInfo, serial, responseType, e);
6219 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6220 RLOGE("responseRadioCapability: Invalid response");
6221 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6222 rc.logicalModemUuid = hidl_string();
6224 convertRilRadioCapabilityToHal(response, responseLen, rc);
6228 int radio::getRadioCapabilityResponse(int slotId,
6229 int responseType, int serial, RIL_Errno e,
6230 void *response, size_t responseLen) {
6232 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6235 if (radioService[slotId]->mRadioResponse != NULL) {
6236 RadioResponseInfo responseInfo = {};
6237 RadioCapability result = {};
6238 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6240 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6241 responseInfo, result);
6242 radioService[slotId]->checkReturnStatus(retStatus);
6244 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6250 int radio::setRadioCapabilityResponse(int slotId,
6251 int responseType, int serial, RIL_Errno e,
6252 void *response, size_t responseLen) {
6254 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6257 if (radioService[slotId]->mRadioResponse != NULL) {
6258 RadioResponseInfo responseInfo = {};
6259 RadioCapability result = {};
6260 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6262 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6263 responseInfo, result);
6264 radioService[slotId]->checkReturnStatus(retStatus);
6266 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6272 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6273 RIL_Errno e, void *response, size_t responseLen) {
6274 populateResponseInfo(responseInfo, serial, responseType, e);
6275 LceStatusInfo result = {};
6277 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6278 RLOGE("Invalid response: NULL");
6279 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6281 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6282 result.lceStatus = (LceStatus) resp->lce_status;
6283 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6288 int radio::startLceServiceResponse(int slotId,
6289 int responseType, int serial, RIL_Errno e,
6290 void *response, size_t responseLen) {
6292 RLOGD("startLceServiceResponse: serial %d", serial);
6295 if (radioService[slotId]->mRadioResponse != NULL) {
6296 RadioResponseInfo responseInfo = {};
6297 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6298 response, responseLen);
6300 Return<void> retStatus
6301 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6303 radioService[slotId]->checkReturnStatus(retStatus);
6305 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6311 int radio::stopLceServiceResponse(int slotId,
6312 int responseType, int serial, RIL_Errno e,
6313 void *response, size_t responseLen) {
6315 RLOGD("stopLceServiceResponse: serial %d", serial);
6318 if (radioService[slotId]->mRadioResponse != NULL) {
6319 RadioResponseInfo responseInfo = {};
6320 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6321 response, responseLen);
6323 Return<void> retStatus
6324 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6326 radioService[slotId]->checkReturnStatus(retStatus);
6328 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6334 int radio::pullLceDataResponse(int slotId,
6335 int responseType, int serial, RIL_Errno e,
6336 void *response, size_t responseLen) {
6338 RLOGD("pullLceDataResponse: serial %d", serial);
6341 if (radioService[slotId]->mRadioResponse != NULL) {
6342 RadioResponseInfo responseInfo = {};
6343 populateResponseInfo(responseInfo, serial, responseType, e);
6345 LceDataInfo result = {};
6346 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6347 RLOGE("pullLceDataResponse: Invalid response");
6348 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6350 convertRilLceDataInfoToHal(response, responseLen, result);
6353 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6354 responseInfo, result);
6355 radioService[slotId]->checkReturnStatus(retStatus);
6357 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6363 int radio::getModemActivityInfoResponse(int slotId,
6364 int responseType, int serial, RIL_Errno e,
6365 void *response, size_t responseLen) {
6367 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6370 if (radioService[slotId]->mRadioResponse != NULL) {
6371 RadioResponseInfo responseInfo = {};
6372 populateResponseInfo(responseInfo, serial, responseType, e);
6373 ActivityStatsInfo info;
6374 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6375 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6376 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6378 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6379 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6380 info.idleModeTimeMs = resp->idle_mode_time_ms;
6381 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6382 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6384 info.rxModeTimeMs = resp->rx_mode_time_ms;
6387 Return<void> retStatus
6388 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6390 radioService[slotId]->checkReturnStatus(retStatus);
6392 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6399 int radio::setAllowedCarriersResponse(int slotId,
6400 int responseType, int serial, RIL_Errno e,
6401 void *response, size_t responseLen) {
6403 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6406 if (radioService[slotId]->mRadioResponse != NULL) {
6407 RadioResponseInfo responseInfo = {};
6408 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6409 Return<void> retStatus
6410 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6412 radioService[slotId]->checkReturnStatus(retStatus);
6414 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6421 int radio::getAllowedCarriersResponse(int slotId,
6422 int responseType, int serial, RIL_Errno e,
6423 void *response, size_t responseLen) {
6425 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6428 if (radioService[slotId]->mRadioResponse != NULL) {
6429 RadioResponseInfo responseInfo = {};
6430 populateResponseInfo(responseInfo, serial, responseType, e);
6431 CarrierRestrictions carrierInfo = {};
6432 bool allAllowed = true;
6433 if (response == NULL) {
6435 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6437 carrierInfo.allowedCarriers.resize(0);
6438 carrierInfo.excludedCarriers.resize(0);
6439 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6440 RLOGE("getAllowedCarriersResponse Invalid response");
6441 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6443 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6444 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6448 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6449 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6450 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6451 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6452 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6453 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6454 carrierInfo.allowedCarriers[i].matchData =
6455 convertCharPtrToHidlString(carrier->match_data);
6458 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6459 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6460 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6461 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6462 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6463 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6464 carrierInfo.excludedCarriers[i].matchData =
6465 convertCharPtrToHidlString(carrier->match_data);
6469 Return<void> retStatus
6470 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6471 allAllowed, carrierInfo);
6472 radioService[slotId]->checkReturnStatus(retStatus);
6474 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6481 int radio::sendDeviceStateResponse(int slotId,
6482 int responseType, int serial, RIL_Errno e,
6483 void *response, size_t responselen) {
6485 RLOGD("sendDeviceStateResponse: serial %d", serial);
6488 if (radioService[slotId]->mRadioResponse != NULL) {
6489 RadioResponseInfo responseInfo = {};
6490 populateResponseInfo(responseInfo, serial, responseType, e);
6491 Return<void> retStatus
6492 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6493 radioService[slotId]->checkReturnStatus(retStatus);
6495 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6501 int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
6502 int responseType, int serial, RIL_Errno e,
6503 void *response, size_t responseLen) {
6504 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
6505 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6506 RadioResponseInfo responseInfo = {};
6507 populateResponseInfo(responseInfo, serial, responseType, e);
6508 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6509 setCarrierInfoForImsiEncryptionResponse(responseInfo);
6510 radioService[slotId]->checkReturnStatus(retStatus);
6512 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponseV1_1 == "
6518 int radio::setIndicationFilterResponse(int slotId,
6519 int responseType, int serial, RIL_Errno e,
6520 void *response, size_t responselen) {
6522 RLOGD("setIndicationFilterResponse: serial %d", serial);
6525 if (radioService[slotId]->mRadioResponse != NULL) {
6526 RadioResponseInfo responseInfo = {};
6527 populateResponseInfo(responseInfo, serial, responseType, e);
6528 Return<void> retStatus
6529 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6530 radioService[slotId]->checkReturnStatus(retStatus);
6532 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6539 int radio::setSimCardPowerResponse(int slotId,
6540 int responseType, int serial, RIL_Errno e,
6541 void *response, size_t responseLen) {
6543 RLOGD("setSimCardPowerResponse: serial %d", serial);
6546 if (radioService[slotId]->mRadioResponse != NULL
6547 || radioService[slotId]->mRadioResponseV1_1 != NULL) {
6548 RadioResponseInfo responseInfo = {};
6549 populateResponseInfo(responseInfo, serial, responseType, e);
6550 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6551 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6552 setSimCardPowerResponse_1_1(responseInfo);
6553 radioService[slotId]->checkReturnStatus(retStatus);
6555 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_1 == NULL",
6557 Return<void> retStatus
6558 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6559 radioService[slotId]->checkReturnStatus(retStatus);
6562 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL && "
6563 "radioService[%d]->mRadioResponseV1_1 == NULL", slotId, slotId);
6568 int radio::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6569 void *response, size_t responseLen) {
6571 RLOGD("startNetworkScanResponse: serial %d", serial);
6574 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6575 RadioResponseInfo responseInfo = {};
6576 populateResponseInfo(responseInfo, serial, responseType, e);
6577 Return<void> retStatus
6578 = radioService[slotId]->mRadioResponseV1_1->startNetworkScanResponse(responseInfo);
6579 radioService[slotId]->checkReturnStatus(retStatus);
6581 RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6587 int radio::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6588 void *response, size_t responseLen) {
6590 RLOGD("stopNetworkScanResponse: serial %d", serial);
6593 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6594 RadioResponseInfo responseInfo = {};
6595 populateResponseInfo(responseInfo, serial, responseType, e);
6596 Return<void> retStatus
6597 = radioService[slotId]->mRadioResponseV1_1->stopNetworkScanResponse(responseInfo);
6598 radioService[slotId]->checkReturnStatus(retStatus);
6600 RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6606 int radio::sendRequestRawResponse(int slotId,
6607 int responseType, int serial, RIL_Errno e,
6608 void *response, size_t responseLen) {
6610 RLOGD("sendRequestRawResponse: serial %d", serial);
6613 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6614 RadioResponseInfo responseInfo = {};
6615 populateResponseInfo(responseInfo, serial, responseType, e);
6616 hidl_vec<uint8_t> data;
6618 if (response == NULL) {
6619 RLOGE("sendRequestRawResponse: Invalid response");
6620 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6622 data.setToExternal((uint8_t *) response, responseLen);
6624 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6625 sendRequestRawResponse(responseInfo, data);
6626 checkReturnStatus(slotId, retStatus, false);
6628 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6635 int radio::sendRequestStringsResponse(int slotId,
6636 int responseType, int serial, RIL_Errno e,
6637 void *response, size_t responseLen) {
6639 RLOGD("sendRequestStringsResponse: serial %d", serial);
6642 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6643 RadioResponseInfo responseInfo = {};
6644 populateResponseInfo(responseInfo, serial, responseType, e);
6645 hidl_vec<hidl_string> data;
6647 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
6648 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6649 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6651 char **resp = (char **) response;
6652 int numStrings = responseLen / sizeof(char *);
6653 data.resize(numStrings);
6654 for (int i = 0; i < numStrings; i++) {
6655 data[i] = convertCharPtrToHidlString(resp[i]);
6658 Return<void> retStatus
6659 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6660 responseInfo, data);
6661 checkReturnStatus(slotId, retStatus, false);
6663 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6670 // Radio Indication functions
6672 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6673 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6674 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6677 int radio::radioStateChangedInd(int slotId,
6678 int indicationType, int token, RIL_Errno e, void *response,
6679 size_t responseLen) {
6680 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6681 RadioState radioState =
6682 (RadioState) CALL_ONSTATEREQUEST(slotId);
6683 RLOGD("radioStateChangedInd: radioState %d", radioState);
6684 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6685 convertIntToRadioIndicationType(indicationType), radioState);
6686 radioService[slotId]->checkReturnStatus(retStatus);
6688 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6694 int radio::callStateChangedInd(int slotId,
6695 int indicationType, int token, RIL_Errno e, void *response,
6696 size_t responseLen) {
6697 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6699 RLOGD("callStateChangedInd");
6701 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6702 convertIntToRadioIndicationType(indicationType));
6703 radioService[slotId]->checkReturnStatus(retStatus);
6705 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6711 int radio::networkStateChangedInd(int slotId,
6712 int indicationType, int token, RIL_Errno e, void *response,
6713 size_t responseLen) {
6714 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6716 RLOGD("networkStateChangedInd");
6718 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6719 convertIntToRadioIndicationType(indicationType));
6720 radioService[slotId]->checkReturnStatus(retStatus);
6722 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6729 uint8_t hexCharToInt(uint8_t c) {
6730 if (c >= '0' && c <= '9') return (c - '0');
6731 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6732 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6734 return INVALID_HEX_CHAR;
6737 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6738 if (responseLen % 2 != 0) {
6742 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6743 if (bytes == NULL) {
6744 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6747 uint8_t *hexString = (uint8_t *)response;
6749 for (size_t i = 0; i < responseLen; i += 2) {
6750 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6751 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6753 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6754 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6755 hexString[i], hexString[i + 1]);
6759 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6765 int radio::newSmsInd(int slotId, int indicationType,
6766 int token, RIL_Errno e, void *response, size_t responseLen) {
6767 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6768 if (response == NULL || responseLen == 0) {
6769 RLOGE("newSmsInd: invalid response");
6773 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6774 if (bytes == NULL) {
6775 RLOGE("newSmsInd: convertHexStringToBytes failed");
6779 hidl_vec<uint8_t> pdu;
6780 pdu.setToExternal(bytes, responseLen/2);
6784 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6785 convertIntToRadioIndicationType(indicationType), pdu);
6786 radioService[slotId]->checkReturnStatus(retStatus);
6789 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6795 int radio::newSmsStatusReportInd(int slotId,
6796 int indicationType, int token, RIL_Errno e, void *response,
6797 size_t responseLen) {
6798 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6799 if (response == NULL || responseLen == 0) {
6800 RLOGE("newSmsStatusReportInd: invalid response");
6804 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6805 if (bytes == NULL) {
6806 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6810 hidl_vec<uint8_t> pdu;
6811 pdu.setToExternal(bytes, responseLen/2);
6813 RLOGD("newSmsStatusReportInd");
6815 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6816 convertIntToRadioIndicationType(indicationType), pdu);
6817 radioService[slotId]->checkReturnStatus(retStatus);
6820 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6826 int radio::newSmsOnSimInd(int slotId, int indicationType,
6827 int token, RIL_Errno e, void *response, size_t responseLen) {
6828 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6829 if (response == NULL || responseLen != sizeof(int)) {
6830 RLOGE("newSmsOnSimInd: invalid response");
6833 int32_t recordNumber = ((int32_t *) response)[0];
6835 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6837 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6838 convertIntToRadioIndicationType(indicationType), recordNumber);
6839 radioService[slotId]->checkReturnStatus(retStatus);
6841 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6847 int radio::onUssdInd(int slotId, int indicationType,
6848 int token, RIL_Errno e, void *response, size_t responseLen) {
6849 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6850 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6851 RLOGE("onUssdInd: invalid response");
6854 char **strings = (char **) response;
6855 char *mode = strings[0];
6856 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6857 UssdModeType modeType = (UssdModeType) atoi(mode);
6859 RLOGD("onUssdInd: mode %s", mode);
6861 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6862 convertIntToRadioIndicationType(indicationType), modeType, msg);
6863 radioService[slotId]->checkReturnStatus(retStatus);
6865 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6871 int radio::nitzTimeReceivedInd(int slotId,
6872 int indicationType, int token, RIL_Errno e, void *response,
6873 size_t responseLen) {
6874 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6875 if (response == NULL || responseLen == 0) {
6876 RLOGE("nitzTimeReceivedInd: invalid response");
6879 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6880 int64_t timeReceived = android::elapsedRealtime();
6882 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6885 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6886 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6887 radioService[slotId]->checkReturnStatus(retStatus);
6889 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6896 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6897 SignalStrength& signalStrength) {
6898 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6900 // Fixup LTE for backwards compatibility
6901 // signalStrength: -1 -> 99
6902 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6903 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6905 // rsrp: -1 -> INT_MAX all other negative value to positive.
6907 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6908 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6909 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6910 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6912 // rsrq: -1 -> INT_MAX
6913 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6914 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6916 // Not remapping rssnr is already using INT_MAX
6917 // cqi: -1 -> INT_MAX
6918 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6919 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6922 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6923 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6924 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6925 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6926 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6927 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6928 signalStrength.evdo.signalNoiseRatio =
6929 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6930 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6931 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6932 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6933 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6934 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6935 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6936 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6939 int radio::currentSignalStrengthInd(int slotId,
6940 int indicationType, int token, RIL_Errno e,
6941 void *response, size_t responseLen) {
6942 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6943 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
6944 RLOGE("currentSignalStrengthInd: invalid response");
6948 SignalStrength signalStrength = {};
6949 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6952 RLOGD("currentSignalStrengthInd");
6954 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6955 convertIntToRadioIndicationType(indicationType), signalStrength);
6956 radioService[slotId]->checkReturnStatus(retStatus);
6958 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6965 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6966 SetupDataCallResult& dcResult) {
6967 dcResult.status = (DataCallFailCause) dcResponse->status;
6968 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6969 dcResult.cid = dcResponse->cid;
6970 dcResult.active = dcResponse->active;
6971 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6972 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6973 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6974 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6975 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6976 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6977 dcResult.mtu = dcResponse->mtu;
6980 void convertRilDataCallListToHal(void *response, size_t responseLen,
6981 hidl_vec<SetupDataCallResult>& dcResultList) {
6982 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6984 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6985 dcResultList.resize(num);
6986 for (int i = 0; i < num; i++) {
6987 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6991 int radio::dataCallListChangedInd(int slotId,
6992 int indicationType, int token, RIL_Errno e, void *response,
6993 size_t responseLen) {
6994 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6995 if ((response == NULL && responseLen != 0)
6996 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
6997 RLOGE("dataCallListChangedInd: invalid response");
7000 hidl_vec<SetupDataCallResult> dcList;
7001 convertRilDataCallListToHal(response, responseLen, dcList);
7003 RLOGD("dataCallListChangedInd");
7005 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
7006 convertIntToRadioIndicationType(indicationType), dcList);
7007 radioService[slotId]->checkReturnStatus(retStatus);
7009 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7015 int radio::suppSvcNotifyInd(int slotId, int indicationType,
7016 int token, RIL_Errno e, void *response, size_t responseLen) {
7017 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7018 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
7019 RLOGE("suppSvcNotifyInd: invalid response");
7023 SuppSvcNotification suppSvc = {};
7024 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
7025 suppSvc.isMT = ssn->notificationType;
7026 suppSvc.code = ssn->code;
7027 suppSvc.index = ssn->index;
7028 suppSvc.type = ssn->type;
7029 suppSvc.number = convertCharPtrToHidlString(ssn->number);
7032 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
7033 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
7035 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
7036 convertIntToRadioIndicationType(indicationType), suppSvc);
7037 radioService[slotId]->checkReturnStatus(retStatus);
7039 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7045 int radio::stkSessionEndInd(int slotId, int indicationType,
7046 int token, RIL_Errno e, void *response, size_t responseLen) {
7047 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7049 RLOGD("stkSessionEndInd");
7051 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
7052 convertIntToRadioIndicationType(indicationType));
7053 radioService[slotId]->checkReturnStatus(retStatus);
7055 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
7061 int radio::stkProactiveCommandInd(int slotId,
7062 int indicationType, int token, RIL_Errno e, void *response,
7063 size_t responseLen) {
7064 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7065 if (response == NULL || responseLen == 0) {
7066 RLOGE("stkProactiveCommandInd: invalid response");
7070 RLOGD("stkProactiveCommandInd");
7072 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
7073 convertIntToRadioIndicationType(indicationType),
7074 convertCharPtrToHidlString((char *) response));
7075 radioService[slotId]->checkReturnStatus(retStatus);
7077 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
7083 int radio::stkEventNotifyInd(int slotId, int indicationType,
7084 int token, RIL_Errno e, void *response, size_t responseLen) {
7085 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7086 if (response == NULL || responseLen == 0) {
7087 RLOGE("stkEventNotifyInd: invalid response");
7091 RLOGD("stkEventNotifyInd");
7093 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
7094 convertIntToRadioIndicationType(indicationType),
7095 convertCharPtrToHidlString((char *) response));
7096 radioService[slotId]->checkReturnStatus(retStatus);
7098 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7104 int radio::stkCallSetupInd(int slotId, int indicationType,
7105 int token, RIL_Errno e, void *response, size_t responseLen) {
7106 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7107 if (response == NULL || responseLen != sizeof(int)) {
7108 RLOGE("stkCallSetupInd: invalid response");
7111 int32_t timeout = ((int32_t *) response)[0];
7113 RLOGD("stkCallSetupInd: timeout %d", timeout);
7115 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
7116 convertIntToRadioIndicationType(indicationType), timeout);
7117 radioService[slotId]->checkReturnStatus(retStatus);
7119 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
7125 int radio::simSmsStorageFullInd(int slotId,
7126 int indicationType, int token, RIL_Errno e, void *response,
7127 size_t responseLen) {
7128 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7130 RLOGD("simSmsStorageFullInd");
7132 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
7133 convertIntToRadioIndicationType(indicationType));
7134 radioService[slotId]->checkReturnStatus(retStatus);
7136 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
7142 int radio::simRefreshInd(int slotId, int indicationType,
7143 int token, RIL_Errno e, void *response, size_t responseLen) {
7144 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7145 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
7146 RLOGE("simRefreshInd: invalid response");
7150 SimRefreshResult refreshResult = {};
7151 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
7152 refreshResult.type =
7153 (V1_0::SimRefreshType) simRefreshResponse->result;
7154 refreshResult.efId = simRefreshResponse->ef_id;
7155 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
7158 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
7160 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
7161 convertIntToRadioIndicationType(indicationType), refreshResult);
7162 radioService[slotId]->checkReturnStatus(retStatus);
7164 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
7170 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
7171 CdmaSignalInfoRecord& record) {
7172 record.isPresent = signalInfoRecord->isPresent;
7173 record.signalType = signalInfoRecord->signalType;
7174 record.alertPitch = signalInfoRecord->alertPitch;
7175 record.signal = signalInfoRecord->signal;
7178 int radio::callRingInd(int slotId, int indicationType,
7179 int token, RIL_Errno e, void *response, size_t responseLen) {
7180 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7182 CdmaSignalInfoRecord record = {};
7183 if (response == NULL || responseLen == 0) {
7187 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
7188 RLOGE("callRingInd: invalid response");
7191 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
7195 RLOGD("callRingInd: isGsm %d", isGsm);
7197 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
7198 convertIntToRadioIndicationType(indicationType), isGsm, record);
7199 radioService[slotId]->checkReturnStatus(retStatus);
7201 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7207 int radio::simStatusChangedInd(int slotId,
7208 int indicationType, int token, RIL_Errno e, void *response,
7209 size_t responseLen) {
7210 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7212 RLOGD("simStatusChangedInd");
7214 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7215 convertIntToRadioIndicationType(indicationType));
7216 radioService[slotId]->checkReturnStatus(retStatus);
7218 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7224 int radio::cdmaNewSmsInd(int slotId, int indicationType,
7225 int token, RIL_Errno e, void *response, size_t responseLen) {
7226 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7227 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7228 RLOGE("cdmaNewSmsInd: invalid response");
7232 CdmaSmsMessage msg = {};
7233 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7234 msg.teleserviceId = rilMsg->uTeleserviceID;
7235 msg.isServicePresent = rilMsg->bIsServicePresent;
7236 msg.serviceCategory = rilMsg->uServicecategory;
7237 msg.address.digitMode =
7238 (V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7239 msg.address.numberMode =
7240 (V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7241 msg.address.numberType =
7242 (V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7243 msg.address.numberPlan =
7244 (V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7246 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7247 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7249 msg.subAddress.subaddressType = (V1_0::CdmaSmsSubaddressType)
7250 rilMsg->sSubAddress.subaddressType;
7251 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7253 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7254 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7256 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7257 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7260 RLOGD("cdmaNewSmsInd");
7262 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7263 convertIntToRadioIndicationType(indicationType), msg);
7264 radioService[slotId]->checkReturnStatus(retStatus);
7266 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7272 int radio::newBroadcastSmsInd(int slotId,
7273 int indicationType, int token, RIL_Errno e, void *response,
7274 size_t responseLen) {
7275 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7276 if (response == NULL || responseLen == 0) {
7277 RLOGE("newBroadcastSmsInd: invalid response");
7281 hidl_vec<uint8_t> data;
7282 data.setToExternal((uint8_t *) response, responseLen);
7284 RLOGD("newBroadcastSmsInd");
7286 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7287 convertIntToRadioIndicationType(indicationType), data);
7288 radioService[slotId]->checkReturnStatus(retStatus);
7290 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7296 int radio::cdmaRuimSmsStorageFullInd(int slotId,
7297 int indicationType, int token, RIL_Errno e, void *response,
7298 size_t responseLen) {
7299 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7301 RLOGD("cdmaRuimSmsStorageFullInd");
7303 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7304 convertIntToRadioIndicationType(indicationType));
7305 radioService[slotId]->checkReturnStatus(retStatus);
7307 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7314 int radio::restrictedStateChangedInd(int slotId,
7315 int indicationType, int token, RIL_Errno e, void *response,
7316 size_t responseLen) {
7317 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7318 if (response == NULL || responseLen != sizeof(int)) {
7319 RLOGE("restrictedStateChangedInd: invalid response");
7322 int32_t state = ((int32_t *) response)[0];
7324 RLOGD("restrictedStateChangedInd: state %d", state);
7326 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7327 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7328 radioService[slotId]->checkReturnStatus(retStatus);
7330 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7337 int radio::enterEmergencyCallbackModeInd(int slotId,
7338 int indicationType, int token, RIL_Errno e, void *response,
7339 size_t responseLen) {
7340 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7342 RLOGD("enterEmergencyCallbackModeInd");
7344 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7345 convertIntToRadioIndicationType(indicationType));
7346 radioService[slotId]->checkReturnStatus(retStatus);
7348 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7355 int radio::cdmaCallWaitingInd(int slotId,
7356 int indicationType, int token, RIL_Errno e, void *response,
7357 size_t responseLen) {
7358 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7359 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7360 RLOGE("cdmaCallWaitingInd: invalid response");
7364 CdmaCallWaiting callWaitingRecord = {};
7365 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7366 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7367 callWaitingRecord.numberPresentation =
7368 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7369 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7370 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7371 callWaitingRecord.signalInfoRecord);
7372 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7373 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7376 RLOGD("cdmaCallWaitingInd");
7378 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7379 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7380 radioService[slotId]->checkReturnStatus(retStatus);
7382 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7388 int radio::cdmaOtaProvisionStatusInd(int slotId,
7389 int indicationType, int token, RIL_Errno e, void *response,
7390 size_t responseLen) {
7391 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7392 if (response == NULL || responseLen != sizeof(int)) {
7393 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7396 int32_t status = ((int32_t *) response)[0];
7398 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7400 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7401 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7402 radioService[slotId]->checkReturnStatus(retStatus);
7404 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7411 int radio::cdmaInfoRecInd(int slotId,
7412 int indicationType, int token, RIL_Errno e, void *response,
7413 size_t responseLen) {
7414 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7415 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7416 RLOGE("cdmaInfoRecInd: invalid response");
7420 CdmaInformationRecords records = {};
7421 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7423 char* string8 = NULL;
7424 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7425 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7426 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7427 "additional ones", recordsRil->numberOfInfoRecs,
7428 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7430 records.infoRec.resize(num);
7431 for (int i = 0 ; i < num ; i++) {
7432 CdmaInformationRecord *record = &records.infoRec[i];
7433 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7434 record->name = (CdmaInfoRecName) infoRec->name;
7435 // All vectors should be size 0 except one which will be size 1. Set everything to
7436 // size 0 initially.
7437 record->display.resize(0);
7438 record->number.resize(0);
7439 record->signal.resize(0);
7440 record->redir.resize(0);
7441 record->lineCtrl.resize(0);
7442 record->clir.resize(0);
7443 record->audioCtrl.resize(0);
7444 switch (infoRec->name) {
7445 case RIL_CDMA_DISPLAY_INFO_REC:
7446 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7447 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7448 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7449 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7450 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7453 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7454 if (string8 == NULL) {
7455 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7456 "responseCdmaInformationRecords");
7459 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7460 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7462 record->display.resize(1);
7463 record->display[0].alphaBuf = string8;
7469 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7470 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7471 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7472 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7473 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7474 "expected not more than %d", (int) infoRec->rec.number.len,
7475 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7478 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7479 if (string8 == NULL) {
7480 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7481 "responseCdmaInformationRecords");
7484 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7485 string8[(int)infoRec->rec.number.len] = '\0';
7487 record->number.resize(1);
7488 record->number[0].number = string8;
7491 record->number[0].numberType = infoRec->rec.number.number_type;
7492 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7493 record->number[0].pi = infoRec->rec.number.pi;
7494 record->number[0].si = infoRec->rec.number.si;
7498 case RIL_CDMA_SIGNAL_INFO_REC: {
7499 record->signal.resize(1);
7500 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7501 record->signal[0].signalType = infoRec->rec.signal.signalType;
7502 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7503 record->signal[0].signal = infoRec->rec.signal.signal;
7507 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7508 if (infoRec->rec.redir.redirectingNumber.len >
7509 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7510 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7511 "expected not more than %d\n",
7512 (int)infoRec->rec.redir.redirectingNumber.len,
7513 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7516 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7518 if (string8 == NULL) {
7519 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7520 "responseCdmaInformationRecords");
7523 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7524 infoRec->rec.redir.redirectingNumber.len);
7525 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7527 record->redir.resize(1);
7528 record->redir[0].redirectingNumber.number = string8;
7531 record->redir[0].redirectingNumber.numberType =
7532 infoRec->rec.redir.redirectingNumber.number_type;
7533 record->redir[0].redirectingNumber.numberPlan =
7534 infoRec->rec.redir.redirectingNumber.number_plan;
7535 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7536 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7537 record->redir[0].redirectingReason =
7538 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7542 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7543 record->lineCtrl.resize(1);
7544 record->lineCtrl[0].lineCtrlPolarityIncluded =
7545 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7546 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7547 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7548 record->lineCtrl[0].lineCtrlPowerDenial =
7549 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7553 case RIL_CDMA_T53_CLIR_INFO_REC: {
7554 record->clir.resize(1);
7555 record->clir[0].cause = infoRec->rec.clir.cause;
7559 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7560 record->audioCtrl.resize(1);
7561 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7562 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7566 case RIL_CDMA_T53_RELEASE_INFO_REC:
7567 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7571 RLOGE("cdmaInfoRecInd: Incorrect name value");
7577 RLOGD("cdmaInfoRecInd");
7579 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7580 convertIntToRadioIndicationType(indicationType), records);
7581 radioService[slotId]->checkReturnStatus(retStatus);
7583 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7589 int radio::indicateRingbackToneInd(int slotId,
7590 int indicationType, int token, RIL_Errno e, void *response,
7591 size_t responseLen) {
7592 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7593 if (response == NULL || responseLen != sizeof(int)) {
7594 RLOGE("indicateRingbackToneInd: invalid response");
7597 bool start = ((int32_t *) response)[0];
7599 RLOGD("indicateRingbackToneInd: start %d", start);
7601 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7602 convertIntToRadioIndicationType(indicationType), start);
7603 radioService[slotId]->checkReturnStatus(retStatus);
7605 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7611 int radio::resendIncallMuteInd(int slotId,
7612 int indicationType, int token, RIL_Errno e, void *response,
7613 size_t responseLen) {
7614 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7616 RLOGD("resendIncallMuteInd");
7618 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7619 convertIntToRadioIndicationType(indicationType));
7620 radioService[slotId]->checkReturnStatus(retStatus);
7622 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7628 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7629 int indicationType, int token, RIL_Errno e,
7630 void *response, size_t responseLen) {
7631 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7632 if (response == NULL || responseLen != sizeof(int)) {
7633 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7636 int32_t cdmaSource = ((int32_t *) response)[0];
7638 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7640 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7641 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7642 (CdmaSubscriptionSource) cdmaSource);
7643 radioService[slotId]->checkReturnStatus(retStatus);
7645 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7652 int radio::cdmaPrlChangedInd(int slotId,
7653 int indicationType, int token, RIL_Errno e, void *response,
7654 size_t responseLen) {
7655 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7656 if (response == NULL || responseLen != sizeof(int)) {
7657 RLOGE("cdmaPrlChangedInd: invalid response");
7660 int32_t version = ((int32_t *) response)[0];
7662 RLOGD("cdmaPrlChangedInd: version %d", version);
7664 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7665 convertIntToRadioIndicationType(indicationType), version);
7666 radioService[slotId]->checkReturnStatus(retStatus);
7668 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7674 int radio::exitEmergencyCallbackModeInd(int slotId,
7675 int indicationType, int token, RIL_Errno e, void *response,
7676 size_t responseLen) {
7677 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7679 RLOGD("exitEmergencyCallbackModeInd");
7681 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7682 convertIntToRadioIndicationType(indicationType));
7683 radioService[slotId]->checkReturnStatus(retStatus);
7685 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7692 int radio::rilConnectedInd(int slotId,
7693 int indicationType, int token, RIL_Errno e, void *response,
7694 size_t responseLen) {
7695 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7696 RLOGD("rilConnectedInd");
7697 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7698 convertIntToRadioIndicationType(indicationType));
7699 radioService[slotId]->checkReturnStatus(retStatus);
7701 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7707 int radio::voiceRadioTechChangedInd(int slotId,
7708 int indicationType, int token, RIL_Errno e, void *response,
7709 size_t responseLen) {
7710 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7711 if (response == NULL || responseLen != sizeof(int)) {
7712 RLOGE("voiceRadioTechChangedInd: invalid response");
7715 int32_t rat = ((int32_t *) response)[0];
7717 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7719 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7720 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7721 radioService[slotId]->checkReturnStatus(retStatus);
7723 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7730 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7731 int num = responseLen / sizeof(RIL_CellInfo_v12);
7732 records.resize(num);
7734 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7735 for (int i = 0; i < num; i++) {
7736 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7737 records[i].registered = rillCellInfo->registered;
7738 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7739 records[i].timeStamp = rillCellInfo->timeStamp;
7740 // All vectors should be size 0 except one which will be size 1. Set everything to
7741 // size 0 initially.
7742 records[i].gsm.resize(0);
7743 records[i].wcdma.resize(0);
7744 records[i].cdma.resize(0);
7745 records[i].lte.resize(0);
7746 records[i].tdscdma.resize(0);
7747 switch(rillCellInfo->cellInfoType) {
7748 case RIL_CELL_INFO_TYPE_GSM: {
7749 records[i].gsm.resize(1);
7750 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7751 cellInfoGsm->cellIdentityGsm.mcc =
7752 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7753 cellInfoGsm->cellIdentityGsm.mnc =
7754 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7755 cellInfoGsm->cellIdentityGsm.lac =
7756 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7757 cellInfoGsm->cellIdentityGsm.cid =
7758 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7759 cellInfoGsm->cellIdentityGsm.arfcn =
7760 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7761 cellInfoGsm->cellIdentityGsm.bsic =
7762 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7763 cellInfoGsm->signalStrengthGsm.signalStrength =
7764 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7765 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7766 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7767 cellInfoGsm->signalStrengthGsm.timingAdvance =
7768 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7772 case RIL_CELL_INFO_TYPE_WCDMA: {
7773 records[i].wcdma.resize(1);
7774 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7775 cellInfoWcdma->cellIdentityWcdma.mcc =
7776 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7777 cellInfoWcdma->cellIdentityWcdma.mnc =
7778 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7779 cellInfoWcdma->cellIdentityWcdma.lac =
7780 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7781 cellInfoWcdma->cellIdentityWcdma.cid =
7782 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7783 cellInfoWcdma->cellIdentityWcdma.psc =
7784 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7785 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7786 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7787 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7788 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7789 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7790 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7794 case RIL_CELL_INFO_TYPE_CDMA: {
7795 records[i].cdma.resize(1);
7796 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7797 cellInfoCdma->cellIdentityCdma.networkId =
7798 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7799 cellInfoCdma->cellIdentityCdma.systemId =
7800 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7801 cellInfoCdma->cellIdentityCdma.baseStationId =
7802 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7803 cellInfoCdma->cellIdentityCdma.longitude =
7804 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7805 cellInfoCdma->cellIdentityCdma.latitude =
7806 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7807 cellInfoCdma->signalStrengthCdma.dbm =
7808 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7809 cellInfoCdma->signalStrengthCdma.ecio =
7810 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7811 cellInfoCdma->signalStrengthEvdo.dbm =
7812 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7813 cellInfoCdma->signalStrengthEvdo.ecio =
7814 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7815 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7816 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7820 case RIL_CELL_INFO_TYPE_LTE: {
7821 records[i].lte.resize(1);
7822 CellInfoLte *cellInfoLte = &records[i].lte[0];
7823 cellInfoLte->cellIdentityLte.mcc =
7824 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7825 cellInfoLte->cellIdentityLte.mnc =
7826 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7827 cellInfoLte->cellIdentityLte.ci =
7828 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7829 cellInfoLte->cellIdentityLte.pci =
7830 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7831 cellInfoLte->cellIdentityLte.tac =
7832 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7833 cellInfoLte->cellIdentityLte.earfcn =
7834 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7835 cellInfoLte->signalStrengthLte.signalStrength =
7836 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7837 cellInfoLte->signalStrengthLte.rsrp =
7838 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7839 cellInfoLte->signalStrengthLte.rsrq =
7840 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7841 cellInfoLte->signalStrengthLte.rssnr =
7842 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7843 cellInfoLte->signalStrengthLte.cqi =
7844 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7845 cellInfoLte->signalStrengthLte.timingAdvance =
7846 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7850 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7851 records[i].tdscdma.resize(1);
7852 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7853 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7854 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7855 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7856 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7857 cellInfoTdscdma->cellIdentityTdscdma.lac =
7858 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7859 cellInfoTdscdma->cellIdentityTdscdma.cid =
7860 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7861 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7862 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7863 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7864 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7875 int radio::cellInfoListInd(int slotId,
7876 int indicationType, int token, RIL_Errno e, void *response,
7877 size_t responseLen) {
7878 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7879 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7880 RLOGE("cellInfoListInd: invalid response");
7884 hidl_vec<CellInfo> records;
7885 convertRilCellInfoListToHal(response, responseLen, records);
7888 RLOGD("cellInfoListInd");
7890 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7891 convertIntToRadioIndicationType(indicationType), records);
7892 radioService[slotId]->checkReturnStatus(retStatus);
7894 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7900 int radio::imsNetworkStateChangedInd(int slotId,
7901 int indicationType, int token, RIL_Errno e, void *response,
7902 size_t responseLen) {
7903 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7905 RLOGD("imsNetworkStateChangedInd");
7907 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7908 convertIntToRadioIndicationType(indicationType));
7909 radioService[slotId]->checkReturnStatus(retStatus);
7911 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7918 int radio::subscriptionStatusChangedInd(int slotId,
7919 int indicationType, int token, RIL_Errno e, void *response,
7920 size_t responseLen) {
7921 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7922 if (response == NULL || responseLen != sizeof(int)) {
7923 RLOGE("subscriptionStatusChangedInd: invalid response");
7926 bool activate = ((int32_t *) response)[0];
7928 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7930 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
7931 convertIntToRadioIndicationType(indicationType), activate);
7932 radioService[slotId]->checkReturnStatus(retStatus);
7934 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
7941 int radio::srvccStateNotifyInd(int slotId,
7942 int indicationType, int token, RIL_Errno e, void *response,
7943 size_t responseLen) {
7944 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7945 if (response == NULL || responseLen != sizeof(int)) {
7946 RLOGE("srvccStateNotifyInd: invalid response");
7949 int32_t state = ((int32_t *) response)[0];
7951 RLOGD("srvccStateNotifyInd: rat %d", state);
7953 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
7954 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
7955 radioService[slotId]->checkReturnStatus(retStatus);
7957 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7963 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7964 hidl_vec<HardwareConfig>& records) {
7965 int num = responseLen / sizeof(RIL_HardwareConfig);
7966 records.resize(num);
7968 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7969 for (int i = 0; i < num; i++) {
7970 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7971 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7972 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7973 switch (rilHardwareConfig[i].type) {
7974 case RIL_HARDWARE_CONFIG_MODEM: {
7975 records[i].modem.resize(1);
7976 records[i].sim.resize(0);
7977 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7978 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7979 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7980 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7981 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7985 case RIL_HARDWARE_CONFIG_SIM: {
7986 records[i].sim.resize(1);
7987 records[i].modem.resize(0);
7988 records[i].sim[0].modemUuid =
7989 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7996 int radio::hardwareConfigChangedInd(int slotId,
7997 int indicationType, int token, RIL_Errno e, void *response,
7998 size_t responseLen) {
7999 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8000 if ((response == NULL && responseLen != 0)
8001 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
8002 RLOGE("hardwareConfigChangedInd: invalid response");
8006 hidl_vec<HardwareConfig> configs;
8007 convertRilHardwareConfigListToHal(response, responseLen, configs);
8010 RLOGD("hardwareConfigChangedInd");
8012 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
8013 convertIntToRadioIndicationType(indicationType), configs);
8014 radioService[slotId]->checkReturnStatus(retStatus);
8016 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
8023 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
8024 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
8025 rc.session = rilRadioCapability->session;
8026 rc.phase = (V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
8027 rc.raf = rilRadioCapability->rat;
8028 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
8029 rc.status = (V1_0::RadioCapabilityStatus) rilRadioCapability->status;
8032 int radio::radioCapabilityIndicationInd(int slotId,
8033 int indicationType, int token, RIL_Errno e, void *response,
8034 size_t responseLen) {
8035 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8036 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
8037 RLOGE("radioCapabilityIndicationInd: invalid response");
8041 RadioCapability rc = {};
8042 convertRilRadioCapabilityToHal(response, responseLen, rc);
8045 RLOGD("radioCapabilityIndicationInd");
8047 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
8048 convertIntToRadioIndicationType(indicationType), rc);
8049 radioService[slotId]->checkReturnStatus(retStatus);
8051 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
8058 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
8059 if ((reqType == SS_INTERROGATION) &&
8060 (serType == SS_CFU ||
8061 serType == SS_CF_BUSY ||
8062 serType == SS_CF_NO_REPLY ||
8063 serType == SS_CF_NOT_REACHABLE ||
8064 serType == SS_CF_ALL ||
8065 serType == SS_CF_ALL_CONDITIONAL)) {
8071 int radio::onSupplementaryServiceIndicationInd(int slotId,
8072 int indicationType, int token, RIL_Errno e,
8073 void *response, size_t responseLen) {
8074 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8075 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
8076 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
8080 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
8081 StkCcUnsolSsResult ss = {};
8082 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
8083 ss.requestType = (SsRequestType) rilSsResponse->requestType;
8084 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
8085 ss.serviceClass = rilSsResponse->serviceClass;
8086 ss.result = (RadioError) rilSsResponse->result;
8088 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
8090 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
8091 rilSsResponse->cfData.numValidIndexes);
8093 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
8094 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
8095 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
8096 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
8099 ss.cfData.resize(1);
8100 ss.ssInfo.resize(0);
8102 /* number of call info's */
8103 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
8105 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
8106 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
8107 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
8109 cfInfo->status = (CallForwardInfoStatus) cf.status;
8110 cfInfo->reason = cf.reason;
8111 cfInfo->serviceClass = cf.serviceClass;
8112 cfInfo->toa = cf.toa;
8113 cfInfo->number = convertCharPtrToHidlString(cf.number);
8114 cfInfo->timeSeconds = cf.timeSeconds;
8116 RLOGD("onSupplementaryServiceIndicationInd: "
8117 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
8118 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
8122 ss.ssInfo.resize(1);
8123 ss.cfData.resize(0);
8126 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
8127 for (int i = 0; i < SS_INFO_MAX; i++) {
8129 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
8130 rilSsResponse->ssInfo[i]);
8132 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
8137 RLOGD("onSupplementaryServiceIndicationInd");
8139 Return<void> retStatus = radioService[slotId]->mRadioIndication->
8140 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
8142 radioService[slotId]->checkReturnStatus(retStatus);
8144 RLOGE("onSupplementaryServiceIndicationInd: "
8145 "radioService[%d]->mRadioIndication == NULL", slotId);
8151 int radio::stkCallControlAlphaNotifyInd(int slotId,
8152 int indicationType, int token, RIL_Errno e, void *response,
8153 size_t responseLen) {
8154 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8155 if (response == NULL || responseLen == 0) {
8156 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
8160 RLOGD("stkCallControlAlphaNotifyInd");
8162 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
8163 convertIntToRadioIndicationType(indicationType),
8164 convertCharPtrToHidlString((char *) response));
8165 radioService[slotId]->checkReturnStatus(retStatus);
8167 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
8174 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
8175 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
8176 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
8177 lce.confidenceLevel = rilLceDataInfo->confidence_level;
8178 lce.lceSuspended = rilLceDataInfo->lce_suspended;
8181 int radio::lceDataInd(int slotId,
8182 int indicationType, int token, RIL_Errno e, void *response,
8183 size_t responseLen) {
8184 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8185 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
8186 RLOGE("lceDataInd: invalid response");
8190 LceDataInfo lce = {};
8191 convertRilLceDataInfoToHal(response, responseLen, lce);
8193 RLOGD("lceDataInd");
8195 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
8196 convertIntToRadioIndicationType(indicationType), lce);
8197 radioService[slotId]->checkReturnStatus(retStatus);
8199 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8205 int radio::pcoDataInd(int slotId,
8206 int indicationType, int token, RIL_Errno e, void *response,
8207 size_t responseLen) {
8208 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8209 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8210 RLOGE("pcoDataInd: invalid response");
8214 PcoDataInfo pco = {};
8215 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8216 pco.cid = rilPcoData->cid;
8217 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8218 pco.pcoId = rilPcoData->pco_id;
8219 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8222 RLOGD("pcoDataInd");
8224 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8225 convertIntToRadioIndicationType(indicationType), pco);
8226 radioService[slotId]->checkReturnStatus(retStatus);
8228 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8234 int radio::modemResetInd(int slotId,
8235 int indicationType, int token, RIL_Errno e, void *response,
8236 size_t responseLen) {
8237 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8238 if (response == NULL || responseLen == 0) {
8239 RLOGE("modemResetInd: invalid response");
8243 RLOGD("modemResetInd");
8245 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8246 convertIntToRadioIndicationType(indicationType),
8247 convertCharPtrToHidlString((char *) response));
8248 radioService[slotId]->checkReturnStatus(retStatus);
8250 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8256 int radio::networkScanResultInd(int slotId,
8257 int indicationType, int token, RIL_Errno e, void *response,
8258 size_t responseLen) {
8260 RLOGD("networkScanResultInd");
8262 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8263 if (response == NULL || responseLen == 0) {
8264 RLOGE("networkScanResultInd: invalid response");
8267 RLOGD("networkScanResultInd");
8270 RLOGD("networkScanResultInd");
8273 RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
8275 V1_1::NetworkScanResult result;
8276 result.status = (V1_1::ScanStatus) networkScanResult->status;
8277 result.error = (RadioError) e;
8278 convertRilCellInfoListToHal(
8279 networkScanResult->network_infos,
8280 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
8281 result.networkInfos);
8283 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->networkScanResult(
8284 convertIntToRadioIndicationType(indicationType), result);
8285 radioService[slotId]->checkReturnStatus(retStatus);
8287 RLOGE("networkScanResultInd: radioService[%d]->mRadioIndicationV1_1 == NULL", slotId);
8292 int radio::carrierInfoForImsiEncryption(int slotId,
8293 int indicationType, int token, RIL_Errno e, void *response,
8294 size_t responseLen) {
8295 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8296 if (response == NULL || responseLen == 0) {
8297 RLOGE("carrierInfoForImsiEncryption: invalid response");
8300 RLOGD("carrierInfoForImsiEncryption");
8301 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->
8302 carrierInfoForImsiEncryption(convertIntToRadioIndicationType(indicationType));
8303 radioService[slotId]->checkReturnStatus(retStatus);
8305 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndicationV1_1 == NULL",
8312 int radio::oemHookRawInd(int slotId,
8313 int indicationType, int token, RIL_Errno e, void *response,
8314 size_t responseLen) {
8315 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8316 if (response == NULL || responseLen == 0) {
8317 RLOGE("oemHookRawInd: invalid response");
8321 hidl_vec<uint8_t> data;
8322 data.setToExternal((uint8_t *) response, responseLen);
8324 RLOGD("oemHookRawInd");
8326 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8327 convertIntToRadioIndicationType(indicationType), data);
8328 checkReturnStatus(slotId, retStatus, false);
8330 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8336 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8337 using namespace android::hardware;
8339 const char *serviceNames[] = {
8340 android::RIL_getServiceName()
8341 #if (SIM_COUNT >= 2)
8343 #if (SIM_COUNT >= 3)
8345 #if (SIM_COUNT >= 4)
8352 #if (SIM_COUNT >= 2)
8353 simCount = SIM_COUNT;
8356 configureRpcThreadpool(1, true /* callerWillJoin */);
8357 for (int i = 0; i < simCount; i++) {
8358 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8359 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8362 radioService[i] = new RadioImpl;
8363 radioService[i]->mSlotId = i;
8364 oemHookService[i] = new OemHookImpl;
8365 oemHookService[i]->mSlotId = i;
8366 RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
8368 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8369 status = oemHookService[i]->registerAsService(serviceNames[i]);
8371 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8375 s_vendorFunctions = callbacks;
8376 s_commands = commands;
8379 void rilc_thread_pool() {
8380 joinRpcThreadpool();
8383 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8384 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8386 #if (SIM_COUNT >= 2)
8387 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8388 #if (SIM_COUNT >= 3)
8389 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8390 #if (SIM_COUNT >= 4)
8391 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8396 return radioServiceRwlockPtr;