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 s_vendorFunctions->onRequest(pRI->pCI->requestNumber, &imsiEncryption, sizeof(RIL_CarrierInfoForImsiEncryption), pRI);
2868 delete(imsiEncryption.carrierKey);
2872 Return<void> RadioImpl::startKeepalive(int32_t serial, const KeepaliveRequest& keepalive) {
2873 RLOGD("startKeepalive: serial %d", serial);
2877 Return<void> RadioImpl::stopKeepalive(int32_t serial, int32_t sessionHandle) {
2878 RLOGD("stopKeepalive: serial %d", serial);
2883 /***************************************************************************************************
2884 * RESPONSE FUNCTIONS
2885 * Functions above are used for requests going from framework to vendor code. The ones below are
2886 * responses for those requests coming back from the vendor code.
2887 **************************************************************************************************/
2889 void radio::acknowledgeRequest(int slotId, int serial) {
2890 if (radioService[slotId]->mRadioResponse != NULL) {
2891 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2892 radioService[slotId]->checkReturnStatus(retStatus);
2894 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2898 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2900 responseInfo.serial = serial;
2901 switch (responseType) {
2902 case RESPONSE_SOLICITED:
2903 responseInfo.type = RadioResponseType::SOLICITED;
2905 case RESPONSE_SOLICITED_ACK_EXP:
2906 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2909 responseInfo.error = (RadioError) e;
2912 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2913 void *response, size_t responseLen) {
2914 populateResponseInfo(responseInfo, serial, responseType, e);
2917 if (response == NULL && responseLen == 0) {
2918 // Earlier RILs did not send a response for some cases although the interface
2919 // expected an integer as response. Do not return error if response is empty. Instead
2920 // Return -1 in those cases to maintain backward compatibility.
2921 } else if (response == NULL || responseLen != sizeof(int)) {
2922 RLOGE("responseIntOrEmpty: Invalid response");
2923 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2925 int *p_int = (int *) response;
2931 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2932 void *response, size_t responseLen) {
2933 populateResponseInfo(responseInfo, serial, responseType, e);
2936 if (response == NULL || responseLen != sizeof(int)) {
2937 RLOGE("responseInt: Invalid response");
2938 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2940 int *p_int = (int *) response;
2946 int radio::getIccCardStatusResponse(int slotId,
2947 int responseType, int serial, RIL_Errno e,
2948 void *response, size_t responseLen) {
2949 if (radioService[slotId]->mRadioResponse != NULL) {
2950 RadioResponseInfo responseInfo = {};
2951 populateResponseInfo(responseInfo, serial, responseType, e);
2952 CardStatus cardStatus = {};
2953 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)) {
2954 RLOGE("getIccCardStatusResponse: Invalid response");
2955 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2957 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
2958 cardStatus.cardState = (CardState) p_cur->card_state;
2959 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
2960 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
2961 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
2962 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
2964 RIL_AppStatus *rilAppStatus = p_cur->applications;
2965 cardStatus.applications.resize(p_cur->num_applications);
2966 AppStatus *appStatus = cardStatus.applications.data();
2968 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
2970 for (int i = 0; i < p_cur->num_applications; i++) {
2971 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
2972 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
2973 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
2974 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
2975 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
2976 rilAppStatus[i].app_label_ptr);
2977 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
2978 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
2979 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
2983 Return<void> retStatus = radioService[slotId]->mRadioResponse->
2984 getIccCardStatusResponse(responseInfo, cardStatus);
2985 radioService[slotId]->checkReturnStatus(retStatus);
2987 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
2993 int radio::supplyIccPinForAppResponse(int slotId,
2994 int responseType, int serial, RIL_Errno e,
2995 void *response, size_t responseLen) {
2997 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
3000 if (radioService[slotId]->mRadioResponse != NULL) {
3001 RadioResponseInfo responseInfo = {};
3002 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3003 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3004 supplyIccPinForAppResponse(responseInfo, ret);
3005 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
3006 radioService[slotId]->checkReturnStatus(retStatus);
3008 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3015 int radio::supplyIccPukForAppResponse(int slotId,
3016 int responseType, int serial, RIL_Errno e,
3017 void *response, size_t responseLen) {
3019 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
3022 if (radioService[slotId]->mRadioResponse != NULL) {
3023 RadioResponseInfo responseInfo = {};
3024 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3025 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
3027 radioService[slotId]->checkReturnStatus(retStatus);
3029 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
3036 int radio::supplyIccPin2ForAppResponse(int slotId,
3037 int responseType, int serial, RIL_Errno e,
3038 void *response, size_t responseLen) {
3040 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
3043 if (radioService[slotId]->mRadioResponse != NULL) {
3044 RadioResponseInfo responseInfo = {};
3045 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3046 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3047 supplyIccPin2ForAppResponse(responseInfo, ret);
3048 radioService[slotId]->checkReturnStatus(retStatus);
3050 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3057 int radio::supplyIccPuk2ForAppResponse(int slotId,
3058 int responseType, int serial, RIL_Errno e,
3059 void *response, size_t responseLen) {
3061 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
3064 if (radioService[slotId]->mRadioResponse != NULL) {
3065 RadioResponseInfo responseInfo = {};
3066 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3067 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3068 supplyIccPuk2ForAppResponse(responseInfo, ret);
3069 radioService[slotId]->checkReturnStatus(retStatus);
3071 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3078 int radio::changeIccPinForAppResponse(int slotId,
3079 int responseType, int serial, RIL_Errno e,
3080 void *response, size_t responseLen) {
3082 RLOGD("changeIccPinForAppResponse: serial %d", serial);
3085 if (radioService[slotId]->mRadioResponse != NULL) {
3086 RadioResponseInfo responseInfo = {};
3087 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3088 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3089 changeIccPinForAppResponse(responseInfo, ret);
3090 radioService[slotId]->checkReturnStatus(retStatus);
3092 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3099 int radio::changeIccPin2ForAppResponse(int slotId,
3100 int responseType, int serial, RIL_Errno e,
3101 void *response, size_t responseLen) {
3103 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
3106 if (radioService[slotId]->mRadioResponse != NULL) {
3107 RadioResponseInfo responseInfo = {};
3108 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3109 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3110 changeIccPin2ForAppResponse(responseInfo, ret);
3111 radioService[slotId]->checkReturnStatus(retStatus);
3113 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3120 int radio::supplyNetworkDepersonalizationResponse(int slotId,
3121 int responseType, int serial, RIL_Errno e,
3122 void *response, size_t responseLen) {
3124 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
3127 if (radioService[slotId]->mRadioResponse != NULL) {
3128 RadioResponseInfo responseInfo = {};
3129 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3130 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3131 supplyNetworkDepersonalizationResponse(responseInfo, ret);
3132 radioService[slotId]->checkReturnStatus(retStatus);
3134 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
3141 int radio::getCurrentCallsResponse(int slotId,
3142 int responseType, int serial, RIL_Errno e,
3143 void *response, size_t responseLen) {
3145 RLOGD("getCurrentCallsResponse: serial %d", serial);
3148 if (radioService[slotId]->mRadioResponse != NULL) {
3149 RadioResponseInfo responseInfo = {};
3150 populateResponseInfo(responseInfo, serial, responseType, e);
3152 hidl_vec<Call> calls;
3153 if ((response == NULL && responseLen != 0)
3154 || (responseLen % sizeof(RIL_Call *)) != 0) {
3155 RLOGE("getCurrentCallsResponse: Invalid response");
3156 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3158 int num = responseLen / sizeof(RIL_Call *);
3161 for (int i = 0 ; i < num ; i++) {
3162 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3163 /* each call info */
3164 calls[i].state = (CallState) p_cur->state;
3165 calls[i].index = p_cur->index;
3166 calls[i].toa = p_cur->toa;
3167 calls[i].isMpty = p_cur->isMpty;
3168 calls[i].isMT = p_cur->isMT;
3169 calls[i].als = p_cur->als;
3170 calls[i].isVoice = p_cur->isVoice;
3171 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3172 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3173 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3174 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3175 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3176 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3177 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3178 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3179 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3180 // convert uusInfo->uusData to a null-terminated string
3181 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3182 calls[i].uusInfo[0].uusData = nullTermStr;
3188 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3189 getCurrentCallsResponse(responseInfo, calls);
3190 radioService[slotId]->checkReturnStatus(retStatus);
3192 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3198 int radio::dialResponse(int slotId,
3199 int responseType, int serial, RIL_Errno e, void *response,
3200 size_t responseLen) {
3202 RLOGD("dialResponse: serial %d", serial);
3205 if (radioService[slotId]->mRadioResponse != NULL) {
3206 RadioResponseInfo responseInfo = {};
3207 populateResponseInfo(responseInfo, serial, responseType, e);
3208 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3209 radioService[slotId]->checkReturnStatus(retStatus);
3211 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3217 int radio::getIMSIForAppResponse(int slotId,
3218 int responseType, int serial, RIL_Errno e, void *response,
3219 size_t responseLen) {
3221 RLOGD("getIMSIForAppResponse: serial %d", serial);
3224 if (radioService[slotId]->mRadioResponse != NULL) {
3225 RadioResponseInfo responseInfo = {};
3226 populateResponseInfo(responseInfo, serial, responseType, e);
3227 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3228 responseInfo, convertCharPtrToHidlString((char *) response));
3229 radioService[slotId]->checkReturnStatus(retStatus);
3231 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3238 int radio::hangupConnectionResponse(int slotId,
3239 int responseType, int serial, RIL_Errno e,
3240 void *response, size_t responseLen) {
3242 RLOGD("hangupConnectionResponse: serial %d", serial);
3245 if (radioService[slotId]->mRadioResponse != NULL) {
3246 RadioResponseInfo responseInfo = {};
3247 populateResponseInfo(responseInfo, serial, responseType, e);
3248 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3250 radioService[slotId]->checkReturnStatus(retStatus);
3252 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3259 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3260 int responseType, int serial, RIL_Errno e,
3261 void *response, size_t responseLen) {
3263 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3266 if (radioService[slotId]->mRadioResponse != NULL) {
3267 RadioResponseInfo responseInfo = {};
3268 populateResponseInfo(responseInfo, serial, responseType, e);
3269 Return<void> retStatus =
3270 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3272 radioService[slotId]->checkReturnStatus(retStatus);
3274 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3281 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3282 RIL_Errno e, void *response,
3283 size_t responseLen) {
3285 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3288 if (radioService[slotId]->mRadioResponse != NULL) {
3289 RadioResponseInfo responseInfo = {};
3290 populateResponseInfo(responseInfo, serial, responseType, e);
3291 Return<void> retStatus =
3292 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3294 radioService[slotId]->checkReturnStatus(retStatus);
3296 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3303 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3304 RIL_Errno e, void *response,
3305 size_t responseLen) {
3307 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3310 if (radioService[slotId]->mRadioResponse != NULL) {
3311 RadioResponseInfo responseInfo = {};
3312 populateResponseInfo(responseInfo, serial, responseType, e);
3313 Return<void> retStatus =
3314 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3316 radioService[slotId]->checkReturnStatus(retStatus);
3318 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3325 int radio::conferenceResponse(int slotId, int responseType,
3326 int serial, RIL_Errno e, void *response, size_t responseLen) {
3328 RLOGD("conferenceResponse: serial %d", serial);
3331 if (radioService[slotId]->mRadioResponse != NULL) {
3332 RadioResponseInfo responseInfo = {};
3333 populateResponseInfo(responseInfo, serial, responseType, e);
3334 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3336 radioService[slotId]->checkReturnStatus(retStatus);
3338 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3345 int radio::rejectCallResponse(int slotId, int responseType,
3346 int serial, RIL_Errno e, void *response, size_t responseLen) {
3348 RLOGD("rejectCallResponse: serial %d", serial);
3351 if (radioService[slotId]->mRadioResponse != NULL) {
3352 RadioResponseInfo responseInfo = {};
3353 populateResponseInfo(responseInfo, serial, responseType, e);
3354 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3356 radioService[slotId]->checkReturnStatus(retStatus);
3358 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3365 int radio::getLastCallFailCauseResponse(int slotId,
3366 int responseType, int serial, RIL_Errno e, void *response,
3367 size_t responseLen) {
3369 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3372 if (radioService[slotId]->mRadioResponse != NULL) {
3373 RadioResponseInfo responseInfo = {};
3374 populateResponseInfo(responseInfo, serial, responseType, e);
3376 LastCallFailCauseInfo info = {};
3377 info.vendorCause = hidl_string();
3378 if (response == NULL) {
3379 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3380 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3381 } else if (responseLen == sizeof(int)) {
3382 int *pInt = (int *) response;
3383 info.causeCode = (LastCallFailCause) pInt[0];
3384 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3385 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3386 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3387 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3389 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3390 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3393 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3394 responseInfo, info);
3395 radioService[slotId]->checkReturnStatus(retStatus);
3397 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3404 int radio::getSignalStrengthResponse(int slotId,
3405 int responseType, int serial, RIL_Errno e,
3406 void *response, size_t responseLen) {
3408 RLOGD("getSignalStrengthResponse: serial %d", serial);
3411 if (radioService[slotId]->mRadioResponse != NULL) {
3412 RadioResponseInfo responseInfo = {};
3413 populateResponseInfo(responseInfo, serial, responseType, e);
3414 SignalStrength signalStrength = {};
3415 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3416 RLOGE("getSignalStrengthResponse: Invalid response");
3417 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3419 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3422 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3423 responseInfo, signalStrength);
3424 radioService[slotId]->checkReturnStatus(retStatus);
3426 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3433 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3435 return RIL_CELL_INFO_TYPE_NONE;
3438 int radioTech = atoi(rat);
3442 case RADIO_TECH_GPRS:
3443 case RADIO_TECH_EDGE:
3444 case RADIO_TECH_GSM: {
3445 return RIL_CELL_INFO_TYPE_GSM;
3448 case RADIO_TECH_UMTS:
3449 case RADIO_TECH_HSDPA:
3450 case RADIO_TECH_HSUPA:
3451 case RADIO_TECH_HSPA:
3452 case RADIO_TECH_HSPAP: {
3453 return RIL_CELL_INFO_TYPE_WCDMA;
3456 case RADIO_TECH_IS95A:
3457 case RADIO_TECH_IS95B:
3458 case RADIO_TECH_1xRTT:
3459 case RADIO_TECH_EVDO_0:
3460 case RADIO_TECH_EVDO_A:
3461 case RADIO_TECH_EVDO_B:
3462 case RADIO_TECH_EHRPD: {
3463 return RIL_CELL_INFO_TYPE_CDMA;
3466 case RADIO_TECH_LTE:
3467 case RADIO_TECH_LTE_CA: {
3468 return RIL_CELL_INFO_TYPE_LTE;
3471 case RADIO_TECH_TD_SCDMA: {
3472 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3480 return RIL_CELL_INFO_TYPE_NONE;
3484 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3486 cellIdentity.cellIdentityGsm.resize(0);
3487 cellIdentity.cellIdentityWcdma.resize(0);
3488 cellIdentity.cellIdentityCdma.resize(0);
3489 cellIdentity.cellIdentityTdscdma.resize(0);
3490 cellIdentity.cellIdentityLte.resize(0);
3491 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3492 switch(rilCellIdentity.cellInfoType) {
3494 case RIL_CELL_INFO_TYPE_GSM: {
3495 cellIdentity.cellIdentityGsm.resize(1);
3496 cellIdentity.cellIdentityGsm[0].mcc =
3497 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3498 cellIdentity.cellIdentityGsm[0].mnc =
3499 std::to_string(rilCellIdentity.cellIdentityGsm.mnc);
3500 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3501 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3502 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3503 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3507 case RIL_CELL_INFO_TYPE_WCDMA: {
3508 cellIdentity.cellIdentityWcdma.resize(1);
3509 cellIdentity.cellIdentityWcdma[0].mcc =
3510 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3511 cellIdentity.cellIdentityWcdma[0].mnc =
3512 std::to_string(rilCellIdentity.cellIdentityWcdma.mnc);
3513 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3514 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3515 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3516 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3520 case RIL_CELL_INFO_TYPE_CDMA: {
3521 cellIdentity.cellIdentityCdma.resize(1);
3522 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3523 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3524 cellIdentity.cellIdentityCdma[0].baseStationId =
3525 rilCellIdentity.cellIdentityCdma.basestationId;
3526 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3527 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3531 case RIL_CELL_INFO_TYPE_LTE: {
3532 cellIdentity.cellIdentityLte.resize(1);
3533 cellIdentity.cellIdentityLte[0].mcc =
3534 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3535 cellIdentity.cellIdentityLte[0].mnc =
3536 std::to_string(rilCellIdentity.cellIdentityLte.mnc);
3537 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3538 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3539 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3540 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3544 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3545 cellIdentity.cellIdentityTdscdma.resize(1);
3546 cellIdentity.cellIdentityTdscdma[0].mcc =
3547 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3548 cellIdentity.cellIdentityTdscdma[0].mnc =
3549 std::to_string(rilCellIdentity.cellIdentityTdscdma.mnc);
3550 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3551 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3552 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3562 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3563 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3564 return atoi(response[index]);
3570 int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
3571 const int hexBase = 16;
3572 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3573 return strtol(response[index], NULL, hexBase);
3579 /* Fill Cell Identity info from Voice Registration State Response.
3580 * This fucntion is applicable only for RIL Version < 15.
3581 * Response is a "char **".
3582 * First and Second entries are in hex string format
3583 * and rest are integers represented in ascii format. */
3584 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3585 int numStrings, char** response) {
3587 RIL_CellIdentity_v16 rilCellIdentity;
3588 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3590 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3591 switch(rilCellIdentity.cellInfoType) {
3593 case RIL_CELL_INFO_TYPE_GSM: {
3594 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3595 rilCellIdentity.cellIdentityGsm.lac =
3596 convertResponseHexStringEntryToInt(response, 1, numStrings);
3598 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3599 rilCellIdentity.cellIdentityGsm.cid =
3600 convertResponseHexStringEntryToInt(response, 2, numStrings);
3604 case RIL_CELL_INFO_TYPE_WCDMA: {
3605 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3606 rilCellIdentity.cellIdentityWcdma.lac =
3607 convertResponseHexStringEntryToInt(response, 1, numStrings);
3609 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3610 rilCellIdentity.cellIdentityWcdma.cid =
3611 convertResponseHexStringEntryToInt(response, 2, numStrings);
3612 rilCellIdentity.cellIdentityWcdma.psc =
3613 convertResponseStringEntryToInt(response, 14, numStrings);
3617 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3618 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3619 rilCellIdentity.cellIdentityTdscdma.lac =
3620 convertResponseHexStringEntryToInt(response, 1, numStrings);
3622 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3623 rilCellIdentity.cellIdentityTdscdma.cid =
3624 convertResponseHexStringEntryToInt(response, 2, numStrings);
3628 case RIL_CELL_INFO_TYPE_CDMA:{
3629 rilCellIdentity.cellIdentityCdma.basestationId =
3630 convertResponseStringEntryToInt(response, 4, numStrings);
3631 rilCellIdentity.cellIdentityCdma.longitude =
3632 convertResponseStringEntryToInt(response, 5, numStrings);
3633 rilCellIdentity.cellIdentityCdma.latitude =
3634 convertResponseStringEntryToInt(response, 6, numStrings);
3635 rilCellIdentity.cellIdentityCdma.systemId =
3636 convertResponseStringEntryToInt(response, 8, numStrings);
3637 rilCellIdentity.cellIdentityCdma.networkId =
3638 convertResponseStringEntryToInt(response, 9, numStrings);
3642 case RIL_CELL_INFO_TYPE_LTE:{
3643 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
3644 rilCellIdentity.cellIdentityLte.tac =
3645 convertResponseHexStringEntryToInt(response, 1, numStrings);
3647 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3648 rilCellIdentity.cellIdentityLte.ci =
3649 convertResponseHexStringEntryToInt(response, 2, numStrings);
3658 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3661 /* Fill Cell Identity info from Data Registration State Response.
3662 * This fucntion is applicable only for RIL Version < 15.
3663 * Response is a "char **".
3664 * First and Second entries are in hex string format
3665 * and rest are integers represented in ascii format. */
3666 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3667 int numStrings, char** response) {
3669 RIL_CellIdentity_v16 rilCellIdentity;
3670 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3672 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3673 switch(rilCellIdentity.cellInfoType) {
3674 case RIL_CELL_INFO_TYPE_GSM: {
3675 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3676 rilCellIdentity.cellIdentityGsm.lac =
3677 convertResponseHexStringEntryToInt(response, 1, numStrings);
3679 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3680 rilCellIdentity.cellIdentityGsm.cid =
3681 convertResponseHexStringEntryToInt(response, 2, numStrings);
3684 case RIL_CELL_INFO_TYPE_WCDMA: {
3685 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3686 rilCellIdentity.cellIdentityWcdma.lac =
3687 convertResponseHexStringEntryToInt(response, 1, numStrings);
3689 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3690 rilCellIdentity.cellIdentityWcdma.cid =
3691 convertResponseHexStringEntryToInt(response, 2, numStrings);
3694 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3695 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3696 rilCellIdentity.cellIdentityTdscdma.lac =
3697 convertResponseHexStringEntryToInt(response, 1, numStrings);
3699 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3700 rilCellIdentity.cellIdentityTdscdma.cid =
3701 convertResponseHexStringEntryToInt(response, 2, numStrings);
3704 case RIL_CELL_INFO_TYPE_LTE: {
3705 rilCellIdentity.cellIdentityLte.tac =
3706 convertResponseStringEntryToInt(response, 6, numStrings);
3707 rilCellIdentity.cellIdentityLte.pci =
3708 convertResponseStringEntryToInt(response, 7, numStrings);
3709 rilCellIdentity.cellIdentityLte.ci =
3710 convertResponseStringEntryToInt(response, 8, numStrings);
3718 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3721 int radio::getVoiceRegistrationStateResponse(int slotId,
3722 int responseType, int serial, RIL_Errno e,
3723 void *response, size_t responseLen) {
3725 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3728 if (radioService[slotId]->mRadioResponse != NULL) {
3729 RadioResponseInfo responseInfo = {};
3730 populateResponseInfo(responseInfo, serial, responseType, e);
3732 VoiceRegStateResult voiceRegResponse = {};
3733 int numStrings = responseLen / sizeof(char *);
3734 if (response == NULL) {
3735 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3736 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3737 } else if (s_vendorFunctions->version <= 14) {
3738 if (numStrings != 15) {
3739 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3740 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3742 char **resp = (char **) response;
3743 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3744 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3745 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3746 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3747 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3748 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3749 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3750 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3754 RIL_VoiceRegistrationStateResponse *voiceRegState =
3755 (RIL_VoiceRegistrationStateResponse *)response;
3757 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3758 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3759 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3761 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3762 voiceRegResponse.rat = voiceRegState->rat;;
3763 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3764 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3765 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3766 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3767 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3768 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3769 voiceRegState->cellIdentity);
3773 Return<void> retStatus =
3774 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3775 responseInfo, voiceRegResponse);
3776 radioService[slotId]->checkReturnStatus(retStatus);
3778 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3785 int radio::getDataRegistrationStateResponse(int slotId,
3786 int responseType, int serial, RIL_Errno e,
3787 void *response, size_t responseLen) {
3789 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3792 if (radioService[slotId]->mRadioResponse != NULL) {
3793 RadioResponseInfo responseInfo = {};
3794 populateResponseInfo(responseInfo, serial, responseType, e);
3795 DataRegStateResult dataRegResponse = {};
3796 if (response == NULL) {
3797 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3798 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3799 } else if (s_vendorFunctions->version <= 14) {
3800 int numStrings = responseLen / sizeof(char *);
3801 if ((numStrings != 6) && (numStrings != 11)) {
3802 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3803 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3805 char **resp = (char **) response;
3806 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3807 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3808 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3809 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3810 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3814 RIL_DataRegistrationStateResponse *dataRegState =
3815 (RIL_DataRegistrationStateResponse *)response;
3817 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3818 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3819 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3821 dataRegResponse.regState = (RegState) dataRegState->regState;
3822 dataRegResponse.rat = dataRegState->rat;;
3823 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3824 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3825 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3829 Return<void> retStatus =
3830 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3832 radioService[slotId]->checkReturnStatus(retStatus);
3834 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3841 int radio::getOperatorResponse(int slotId,
3842 int responseType, int serial, RIL_Errno e, void *response,
3843 size_t responseLen) {
3845 RLOGD("getOperatorResponse: serial %d", serial);
3848 if (radioService[slotId]->mRadioResponse != NULL) {
3849 RadioResponseInfo responseInfo = {};
3850 populateResponseInfo(responseInfo, serial, responseType, e);
3851 hidl_string longName;
3852 hidl_string shortName;
3853 hidl_string numeric;
3854 int numStrings = responseLen / sizeof(char *);
3855 if (response == NULL || numStrings != 3) {
3856 RLOGE("getOperatorResponse Invalid response: NULL");
3857 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3860 char **resp = (char **) response;
3861 longName = convertCharPtrToHidlString(resp[0]);
3862 shortName = convertCharPtrToHidlString(resp[1]);
3863 numeric = convertCharPtrToHidlString(resp[2]);
3865 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3866 responseInfo, longName, shortName, numeric);
3867 radioService[slotId]->checkReturnStatus(retStatus);
3869 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3876 int radio::setRadioPowerResponse(int slotId,
3877 int responseType, int serial, RIL_Errno e, void *response,
3878 size_t responseLen) {
3879 RLOGD("setRadioPowerResponse: serial %d", serial);
3881 if (radioService[slotId]->mRadioResponse != NULL) {
3882 RadioResponseInfo responseInfo = {};
3883 populateResponseInfo(responseInfo, serial, responseType, e);
3884 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3886 radioService[slotId]->checkReturnStatus(retStatus);
3888 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3895 int radio::sendDtmfResponse(int slotId,
3896 int responseType, int serial, RIL_Errno e, void *response,
3897 size_t responseLen) {
3899 RLOGD("sendDtmfResponse: serial %d", serial);
3902 if (radioService[slotId]->mRadioResponse != NULL) {
3903 RadioResponseInfo responseInfo = {};
3904 populateResponseInfo(responseInfo, serial, responseType, e);
3905 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3907 radioService[slotId]->checkReturnStatus(retStatus);
3909 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3916 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3917 RIL_Errno e, void *response, size_t responseLen) {
3918 populateResponseInfo(responseInfo, serial, responseType, e);
3919 SendSmsResult result = {};
3921 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3922 RLOGE("Invalid response: NULL");
3923 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3924 result.ackPDU = hidl_string();
3926 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3927 result.messageRef = resp->messageRef;
3928 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3929 result.errorCode = resp->errorCode;
3934 int radio::sendSmsResponse(int slotId,
3935 int responseType, int serial, RIL_Errno e, void *response,
3936 size_t responseLen) {
3938 RLOGD("sendSmsResponse: serial %d", serial);
3941 if (radioService[slotId]->mRadioResponse != NULL) {
3942 RadioResponseInfo responseInfo = {};
3943 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3946 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
3948 radioService[slotId]->checkReturnStatus(retStatus);
3950 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3956 int radio::sendSMSExpectMoreResponse(int slotId,
3957 int responseType, int serial, RIL_Errno e, void *response,
3958 size_t responseLen) {
3960 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
3963 if (radioService[slotId]->mRadioResponse != NULL) {
3964 RadioResponseInfo responseInfo = {};
3965 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
3968 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
3969 responseInfo, result);
3970 radioService[slotId]->checkReturnStatus(retStatus);
3972 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3978 int radio::setupDataCallResponse(int slotId,
3979 int responseType, int serial, RIL_Errno e, void *response,
3980 size_t responseLen) {
3982 RLOGD("setupDataCallResponse: serial %d", serial);
3985 if (radioService[slotId]->mRadioResponse != NULL) {
3986 RadioResponseInfo responseInfo = {};
3987 populateResponseInfo(responseInfo, serial, responseType, e);
3989 SetupDataCallResult result = {};
3990 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
3991 if (response != NULL) {
3992 RLOGE("setupDataCallResponse: Invalid response");
3993 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3995 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
3996 result.type = hidl_string();
3997 result.ifname = hidl_string();
3998 result.addresses = hidl_string();
3999 result.dnses = hidl_string();
4000 result.gateways = hidl_string();
4001 result.pcscf = hidl_string();
4003 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
4006 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
4007 responseInfo, result);
4008 radioService[slotId]->checkReturnStatus(retStatus);
4010 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4016 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
4017 RIL_Errno e, void *response, size_t responseLen) {
4018 populateResponseInfo(responseInfo, serial, responseType, e);
4019 IccIoResult result = {};
4021 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
4022 RLOGE("Invalid response: NULL");
4023 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4024 result.simResponse = hidl_string();
4026 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
4027 result.sw1 = resp->sw1;
4028 result.sw2 = resp->sw2;
4029 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
4034 int radio::iccIOForAppResponse(int slotId,
4035 int responseType, int serial, RIL_Errno e, void *response,
4036 size_t responseLen) {
4038 RLOGD("iccIOForAppResponse: serial %d", serial);
4041 if (radioService[slotId]->mRadioResponse != NULL) {
4042 RadioResponseInfo responseInfo = {};
4043 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
4046 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
4047 responseInfo, result);
4048 radioService[slotId]->checkReturnStatus(retStatus);
4050 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4056 int radio::sendUssdResponse(int slotId,
4057 int responseType, int serial, RIL_Errno e, void *response,
4058 size_t responseLen) {
4060 RLOGD("sendUssdResponse: serial %d", serial);
4063 if (radioService[slotId]->mRadioResponse != NULL) {
4064 RadioResponseInfo responseInfo = {};
4065 populateResponseInfo(responseInfo, serial, responseType, e);
4066 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
4068 radioService[slotId]->checkReturnStatus(retStatus);
4070 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
4077 int radio::cancelPendingUssdResponse(int slotId,
4078 int responseType, int serial, RIL_Errno e, void *response,
4079 size_t responseLen) {
4081 RLOGD("cancelPendingUssdResponse: serial %d", serial);
4084 if (radioService[slotId]->mRadioResponse != NULL) {
4085 RadioResponseInfo responseInfo = {};
4086 populateResponseInfo(responseInfo, serial, responseType, e);
4087 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
4089 radioService[slotId]->checkReturnStatus(retStatus);
4091 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
4098 int radio::getClirResponse(int slotId,
4099 int responseType, int serial, RIL_Errno e, void *response,
4100 size_t responseLen) {
4102 RLOGD("getClirResponse: serial %d", serial);
4105 if (radioService[slotId]->mRadioResponse != NULL) {
4106 RadioResponseInfo responseInfo = {};
4107 populateResponseInfo(responseInfo, serial, responseType, e);
4109 int numInts = responseLen / sizeof(int);
4110 if (response == NULL || numInts != 2) {
4111 RLOGE("getClirResponse Invalid response: NULL");
4112 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4114 int *pInt = (int *) response;
4118 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
4120 radioService[slotId]->checkReturnStatus(retStatus);
4122 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4128 int radio::setClirResponse(int slotId,
4129 int responseType, int serial, RIL_Errno e, void *response,
4130 size_t responseLen) {
4132 RLOGD("setClirResponse: serial %d", serial);
4135 if (radioService[slotId]->mRadioResponse != NULL) {
4136 RadioResponseInfo responseInfo = {};
4137 populateResponseInfo(responseInfo, serial, responseType, e);
4138 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
4140 radioService[slotId]->checkReturnStatus(retStatus);
4142 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4148 int radio::getCallForwardStatusResponse(int slotId,
4149 int responseType, int serial, RIL_Errno e,
4150 void *response, size_t responseLen) {
4152 RLOGD("getCallForwardStatusResponse: serial %d", serial);
4155 if (radioService[slotId]->mRadioResponse != NULL) {
4156 RadioResponseInfo responseInfo = {};
4157 populateResponseInfo(responseInfo, serial, responseType, e);
4158 hidl_vec<CallForwardInfo> callForwardInfos;
4160 if ((response == NULL && responseLen != 0)
4161 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4162 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4163 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4165 int num = responseLen / sizeof(RIL_CallForwardInfo *);
4166 callForwardInfos.resize(num);
4167 for (int i = 0 ; i < num; i++) {
4168 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4169 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4170 callForwardInfos[i].reason = resp->reason;
4171 callForwardInfos[i].serviceClass = resp->serviceClass;
4172 callForwardInfos[i].toa = resp->toa;
4173 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4174 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4178 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4179 responseInfo, callForwardInfos);
4180 radioService[slotId]->checkReturnStatus(retStatus);
4182 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4189 int radio::setCallForwardResponse(int slotId,
4190 int responseType, int serial, RIL_Errno e, void *response,
4191 size_t responseLen) {
4193 RLOGD("setCallForwardResponse: serial %d", serial);
4196 if (radioService[slotId]->mRadioResponse != NULL) {
4197 RadioResponseInfo responseInfo = {};
4198 populateResponseInfo(responseInfo, serial, responseType, e);
4199 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4201 radioService[slotId]->checkReturnStatus(retStatus);
4203 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4209 int radio::getCallWaitingResponse(int slotId,
4210 int responseType, int serial, RIL_Errno e, void *response,
4211 size_t responseLen) {
4213 RLOGD("getCallWaitingResponse: serial %d", serial);
4216 if (radioService[slotId]->mRadioResponse != NULL) {
4217 RadioResponseInfo responseInfo = {};
4218 populateResponseInfo(responseInfo, serial, responseType, e);
4219 bool enable = false;
4220 int serviceClass = -1;
4221 int numInts = responseLen / sizeof(int);
4222 if (response == NULL || numInts != 2) {
4223 RLOGE("getCallWaitingResponse Invalid response: NULL");
4224 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4226 int *pInt = (int *) response;
4227 enable = pInt[0] == 1 ? true : false;
4228 serviceClass = pInt[1];
4230 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4231 responseInfo, enable, serviceClass);
4232 radioService[slotId]->checkReturnStatus(retStatus);
4234 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4240 int radio::setCallWaitingResponse(int slotId,
4241 int responseType, int serial, RIL_Errno e, void *response,
4242 size_t responseLen) {
4244 RLOGD("setCallWaitingResponse: serial %d", serial);
4247 if (radioService[slotId]->mRadioResponse != NULL) {
4248 RadioResponseInfo responseInfo = {};
4249 populateResponseInfo(responseInfo, serial, responseType, e);
4250 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4252 radioService[slotId]->checkReturnStatus(retStatus);
4254 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4260 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4261 int responseType, int serial, RIL_Errno e,
4262 void *response, size_t responseLen) {
4264 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4267 if (radioService[slotId]->mRadioResponse != NULL) {
4268 RadioResponseInfo responseInfo = {};
4269 populateResponseInfo(responseInfo, serial, responseType, e);
4270 Return<void> retStatus =
4271 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4273 radioService[slotId]->checkReturnStatus(retStatus);
4275 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4282 int radio::acceptCallResponse(int slotId,
4283 int responseType, int serial, RIL_Errno e,
4284 void *response, size_t responseLen) {
4286 RLOGD("acceptCallResponse: serial %d", serial);
4289 if (radioService[slotId]->mRadioResponse != NULL) {
4290 RadioResponseInfo responseInfo = {};
4291 populateResponseInfo(responseInfo, serial, responseType, e);
4292 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4294 radioService[slotId]->checkReturnStatus(retStatus);
4296 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4303 int radio::deactivateDataCallResponse(int slotId,
4304 int responseType, int serial, RIL_Errno e,
4305 void *response, size_t responseLen) {
4307 RLOGD("deactivateDataCallResponse: serial %d", serial);
4310 if (radioService[slotId]->mRadioResponse != NULL) {
4311 RadioResponseInfo responseInfo = {};
4312 populateResponseInfo(responseInfo, serial, responseType, e);
4313 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4315 radioService[slotId]->checkReturnStatus(retStatus);
4317 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4324 int radio::getFacilityLockForAppResponse(int slotId,
4325 int responseType, int serial, RIL_Errno e,
4326 void *response, size_t responseLen) {
4328 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4331 if (radioService[slotId]->mRadioResponse != NULL) {
4332 RadioResponseInfo responseInfo = {};
4333 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4334 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4335 getFacilityLockForAppResponse(responseInfo, ret);
4336 radioService[slotId]->checkReturnStatus(retStatus);
4338 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4345 int radio::setFacilityLockForAppResponse(int slotId,
4346 int responseType, int serial, RIL_Errno e,
4347 void *response, size_t responseLen) {
4349 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4352 if (radioService[slotId]->mRadioResponse != NULL) {
4353 RadioResponseInfo responseInfo = {};
4354 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4355 Return<void> retStatus
4356 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4358 radioService[slotId]->checkReturnStatus(retStatus);
4360 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4367 int radio::setBarringPasswordResponse(int slotId,
4368 int responseType, int serial, RIL_Errno e,
4369 void *response, size_t responseLen) {
4371 RLOGD("acceptCallResponse: serial %d", serial);
4374 if (radioService[slotId]->mRadioResponse != NULL) {
4375 RadioResponseInfo responseInfo = {};
4376 populateResponseInfo(responseInfo, serial, responseType, e);
4377 Return<void> retStatus
4378 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4379 radioService[slotId]->checkReturnStatus(retStatus);
4381 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4388 int radio::getNetworkSelectionModeResponse(int slotId,
4389 int responseType, int serial, RIL_Errno e, void *response,
4390 size_t responseLen) {
4392 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4395 if (radioService[slotId]->mRadioResponse != NULL) {
4396 RadioResponseInfo responseInfo = {};
4397 populateResponseInfo(responseInfo, serial, responseType, e);
4398 bool manual = false;
4399 if (response == NULL || responseLen != sizeof(int)) {
4400 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4401 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4403 int *pInt = (int *) response;
4404 manual = pInt[0] == 1 ? true : false;
4406 Return<void> retStatus
4407 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4410 radioService[slotId]->checkReturnStatus(retStatus);
4412 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4419 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4420 RIL_Errno e, void *response,
4421 size_t responseLen) {
4423 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4426 if (radioService[slotId]->mRadioResponse != NULL) {
4427 RadioResponseInfo responseInfo = {};
4428 populateResponseInfo(responseInfo, serial, responseType, e);
4429 Return<void> retStatus
4430 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4432 radioService[slotId]->checkReturnStatus(retStatus);
4434 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4441 int radio::setNetworkSelectionModeManualResponse(int slotId,
4442 int responseType, int serial, RIL_Errno e,
4443 void *response, size_t responseLen) {
4445 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4448 if (radioService[slotId]->mRadioResponse != NULL) {
4449 RadioResponseInfo responseInfo = {};
4450 populateResponseInfo(responseInfo, serial, responseType, e);
4451 Return<void> retStatus
4452 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4454 radioService[slotId]->checkReturnStatus(retStatus);
4456 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4463 int convertOperatorStatusToInt(const char *str) {
4464 if (strncmp("unknown", str, 9) == 0) {
4465 return (int) OperatorStatus::UNKNOWN;
4466 } else if (strncmp("available", str, 9) == 0) {
4467 return (int) OperatorStatus::AVAILABLE;
4468 } else if (strncmp("current", str, 9) == 0) {
4469 return (int) OperatorStatus::CURRENT;
4470 } else if (strncmp("forbidden", str, 9) == 0) {
4471 return (int) OperatorStatus::FORBIDDEN;
4477 int radio::getAvailableNetworksResponse(int slotId,
4478 int responseType, int serial, RIL_Errno e, void *response,
4479 size_t responseLen) {
4481 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4484 if (radioService[slotId]->mRadioResponse != NULL) {
4485 RadioResponseInfo responseInfo = {};
4486 populateResponseInfo(responseInfo, serial, responseType, e);
4487 hidl_vec<OperatorInfo> networks;
4488 if ((response == NULL && responseLen != 0)
4489 || responseLen % (4 * sizeof(char *))!= 0) {
4490 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4491 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4493 char **resp = (char **) response;
4494 int numStrings = responseLen / sizeof(char *);
4495 networks.resize(numStrings/4);
4496 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4497 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4498 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4499 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4500 int status = convertOperatorStatusToInt(resp[i + 3]);
4502 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4504 networks[j].status = (OperatorStatus) status;
4508 Return<void> retStatus
4509 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4511 radioService[slotId]->checkReturnStatus(retStatus);
4513 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4520 int radio::startDtmfResponse(int slotId,
4521 int responseType, int serial, RIL_Errno e,
4522 void *response, size_t responseLen) {
4524 RLOGD("startDtmfResponse: serial %d", serial);
4527 if (radioService[slotId]->mRadioResponse != NULL) {
4528 RadioResponseInfo responseInfo = {};
4529 populateResponseInfo(responseInfo, serial, responseType, e);
4530 Return<void> retStatus
4531 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4532 radioService[slotId]->checkReturnStatus(retStatus);
4534 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4540 int radio::stopDtmfResponse(int slotId,
4541 int responseType, int serial, RIL_Errno e,
4542 void *response, size_t responseLen) {
4544 RLOGD("stopDtmfResponse: serial %d", serial);
4547 if (radioService[slotId]->mRadioResponse != NULL) {
4548 RadioResponseInfo responseInfo = {};
4549 populateResponseInfo(responseInfo, serial, responseType, e);
4550 Return<void> retStatus
4551 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4552 radioService[slotId]->checkReturnStatus(retStatus);
4554 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4560 int radio::getBasebandVersionResponse(int slotId,
4561 int responseType, int serial, RIL_Errno e,
4562 void *response, size_t responseLen) {
4564 RLOGD("getBasebandVersionResponse: serial %d", serial);
4567 if (radioService[slotId]->mRadioResponse != NULL) {
4568 RadioResponseInfo responseInfo = {};
4569 populateResponseInfo(responseInfo, serial, responseType, e);
4570 Return<void> retStatus
4571 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4572 convertCharPtrToHidlString((char *) response));
4573 radioService[slotId]->checkReturnStatus(retStatus);
4575 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4581 int radio::separateConnectionResponse(int slotId,
4582 int responseType, int serial, RIL_Errno e,
4583 void *response, size_t responseLen) {
4585 RLOGD("separateConnectionResponse: serial %d", serial);
4588 if (radioService[slotId]->mRadioResponse != NULL) {
4589 RadioResponseInfo responseInfo = {};
4590 populateResponseInfo(responseInfo, serial, responseType, e);
4591 Return<void> retStatus
4592 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4593 radioService[slotId]->checkReturnStatus(retStatus);
4595 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4602 int radio::setMuteResponse(int slotId,
4603 int responseType, int serial, RIL_Errno e,
4604 void *response, size_t responseLen) {
4606 RLOGD("setMuteResponse: serial %d", serial);
4609 if (radioService[slotId]->mRadioResponse != NULL) {
4610 RadioResponseInfo responseInfo = {};
4611 populateResponseInfo(responseInfo, serial, responseType, e);
4612 Return<void> retStatus
4613 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4614 radioService[slotId]->checkReturnStatus(retStatus);
4616 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4622 int radio::getMuteResponse(int slotId,
4623 int responseType, int serial, RIL_Errno e, void *response,
4624 size_t responseLen) {
4626 RLOGD("getMuteResponse: serial %d", serial);
4629 if (radioService[slotId]->mRadioResponse != NULL) {
4630 RadioResponseInfo responseInfo = {};
4631 populateResponseInfo(responseInfo, serial, responseType, e);
4632 bool enable = false;
4633 if (response == NULL || responseLen != sizeof(int)) {
4634 RLOGE("getMuteResponse Invalid response: NULL");
4635 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4637 int *pInt = (int *) response;
4638 enable = pInt[0] == 1 ? true : false;
4640 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4642 radioService[slotId]->checkReturnStatus(retStatus);
4644 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4650 int radio::getClipResponse(int slotId,
4651 int responseType, int serial, RIL_Errno e,
4652 void *response, size_t responseLen) {
4654 RLOGD("getClipResponse: serial %d", serial);
4657 if (radioService[slotId]->mRadioResponse != NULL) {
4658 RadioResponseInfo responseInfo = {};
4659 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4660 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4662 radioService[slotId]->checkReturnStatus(retStatus);
4664 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4670 int radio::getDataCallListResponse(int slotId,
4671 int responseType, int serial, RIL_Errno e,
4672 void *response, size_t responseLen) {
4674 RLOGD("getDataCallListResponse: serial %d", serial);
4677 if (radioService[slotId]->mRadioResponse != NULL) {
4678 RadioResponseInfo responseInfo = {};
4679 populateResponseInfo(responseInfo, serial, responseType, e);
4681 hidl_vec<SetupDataCallResult> ret;
4682 if ((response == NULL && responseLen != 0)
4683 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4684 RLOGE("getDataCallListResponse: invalid response");
4685 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4687 convertRilDataCallListToHal(response, responseLen, ret);
4690 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4692 radioService[slotId]->checkReturnStatus(retStatus);
4694 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4700 int radio::setSuppServiceNotificationsResponse(int slotId,
4701 int responseType, int serial, RIL_Errno e,
4702 void *response, size_t responseLen) {
4704 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4707 if (radioService[slotId]->mRadioResponse != NULL) {
4708 RadioResponseInfo responseInfo = {};
4709 populateResponseInfo(responseInfo, serial, responseType, e);
4710 Return<void> retStatus
4711 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4713 radioService[slotId]->checkReturnStatus(retStatus);
4715 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4722 int radio::deleteSmsOnSimResponse(int slotId,
4723 int responseType, int serial, RIL_Errno e,
4724 void *response, size_t responseLen) {
4726 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4729 if (radioService[slotId]->mRadioResponse != NULL) {
4730 RadioResponseInfo responseInfo = {};
4731 populateResponseInfo(responseInfo, serial, responseType, e);
4732 Return<void> retStatus
4733 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4734 radioService[slotId]->checkReturnStatus(retStatus);
4736 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4742 int radio::setBandModeResponse(int slotId,
4743 int responseType, int serial, RIL_Errno e,
4744 void *response, size_t responseLen) {
4746 RLOGD("setBandModeResponse: serial %d", serial);
4749 if (radioService[slotId]->mRadioResponse != NULL) {
4750 RadioResponseInfo responseInfo = {};
4751 populateResponseInfo(responseInfo, serial, responseType, e);
4752 Return<void> retStatus
4753 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4754 radioService[slotId]->checkReturnStatus(retStatus);
4756 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4762 int radio::writeSmsToSimResponse(int slotId,
4763 int responseType, int serial, RIL_Errno e,
4764 void *response, size_t responseLen) {
4766 RLOGD("writeSmsToSimResponse: serial %d", serial);
4769 if (radioService[slotId]->mRadioResponse != NULL) {
4770 RadioResponseInfo responseInfo = {};
4771 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4772 Return<void> retStatus
4773 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4774 radioService[slotId]->checkReturnStatus(retStatus);
4776 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4782 int radio::getAvailableBandModesResponse(int slotId,
4783 int responseType, int serial, RIL_Errno e, void *response,
4784 size_t responseLen) {
4786 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4789 if (radioService[slotId]->mRadioResponse != NULL) {
4790 RadioResponseInfo responseInfo = {};
4791 populateResponseInfo(responseInfo, serial, responseType, e);
4792 hidl_vec<RadioBandMode> modes;
4793 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
4794 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4795 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4797 int *pInt = (int *) response;
4798 int numInts = responseLen / sizeof(int);
4799 modes.resize(numInts);
4800 for (int i = 0; i < numInts; i++) {
4801 modes[i] = (RadioBandMode) pInt[i];
4804 Return<void> retStatus
4805 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4807 radioService[slotId]->checkReturnStatus(retStatus);
4809 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4816 int radio::sendEnvelopeResponse(int slotId,
4817 int responseType, int serial, RIL_Errno e,
4818 void *response, size_t responseLen) {
4820 RLOGD("sendEnvelopeResponse: serial %d", serial);
4823 if (radioService[slotId]->mRadioResponse != NULL) {
4824 RadioResponseInfo responseInfo = {};
4825 populateResponseInfo(responseInfo, serial, responseType, e);
4826 Return<void> retStatus
4827 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4828 convertCharPtrToHidlString((char *) response));
4829 radioService[slotId]->checkReturnStatus(retStatus);
4831 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4837 int radio::sendTerminalResponseToSimResponse(int slotId,
4838 int responseType, int serial, RIL_Errno e,
4839 void *response, size_t responseLen) {
4841 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4844 if (radioService[slotId]->mRadioResponse != NULL) {
4845 RadioResponseInfo responseInfo = {};
4846 populateResponseInfo(responseInfo, serial, responseType, e);
4847 Return<void> retStatus
4848 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4850 radioService[slotId]->checkReturnStatus(retStatus);
4852 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4859 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4860 int responseType, int serial,
4861 RIL_Errno e, void *response,
4862 size_t responseLen) {
4864 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4867 if (radioService[slotId]->mRadioResponse != NULL) {
4868 RadioResponseInfo responseInfo = {};
4869 populateResponseInfo(responseInfo, serial, responseType, e);
4870 Return<void> retStatus
4871 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4873 radioService[slotId]->checkReturnStatus(retStatus);
4875 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4882 int radio::explicitCallTransferResponse(int slotId,
4883 int responseType, int serial, RIL_Errno e,
4884 void *response, size_t responseLen) {
4886 RLOGD("explicitCallTransferResponse: serial %d", serial);
4889 if (radioService[slotId]->mRadioResponse != NULL) {
4890 RadioResponseInfo responseInfo = {};
4891 populateResponseInfo(responseInfo, serial, responseType, e);
4892 Return<void> retStatus
4893 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4894 radioService[slotId]->checkReturnStatus(retStatus);
4896 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4903 int radio::setPreferredNetworkTypeResponse(int slotId,
4904 int responseType, int serial, RIL_Errno e,
4905 void *response, size_t responseLen) {
4907 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4910 if (radioService[slotId]->mRadioResponse != NULL) {
4911 RadioResponseInfo responseInfo = {};
4912 populateResponseInfo(responseInfo, serial, responseType, e);
4913 Return<void> retStatus
4914 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4916 radioService[slotId]->checkReturnStatus(retStatus);
4918 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4926 int radio::getPreferredNetworkTypeResponse(int slotId,
4927 int responseType, int serial, RIL_Errno e,
4928 void *response, size_t responseLen) {
4930 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4933 if (radioService[slotId]->mRadioResponse != NULL) {
4934 RadioResponseInfo responseInfo = {};
4935 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4936 Return<void> retStatus
4937 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4938 responseInfo, (PreferredNetworkType) ret);
4939 radioService[slotId]->checkReturnStatus(retStatus);
4941 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4948 int radio::getNeighboringCidsResponse(int slotId,
4949 int responseType, int serial, RIL_Errno e,
4950 void *response, size_t responseLen) {
4952 RLOGD("getNeighboringCidsResponse: serial %d", serial);
4955 if (radioService[slotId]->mRadioResponse != NULL) {
4956 RadioResponseInfo responseInfo = {};
4957 populateResponseInfo(responseInfo, serial, responseType, e);
4958 hidl_vec<NeighboringCell> cells;
4960 if ((response == NULL && responseLen != 0)
4961 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
4962 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
4963 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4965 int num = responseLen / sizeof(RIL_NeighboringCell *);
4967 for (int i = 0 ; i < num; i++) {
4968 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
4969 cells[i].cid = convertCharPtrToHidlString(resp->cid);
4970 cells[i].rssi = resp->rssi;
4974 Return<void> retStatus
4975 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
4977 radioService[slotId]->checkReturnStatus(retStatus);
4979 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
4986 int radio::setLocationUpdatesResponse(int slotId,
4987 int responseType, int serial, RIL_Errno e,
4988 void *response, size_t responseLen) {
4990 RLOGD("setLocationUpdatesResponse: serial %d", serial);
4993 if (radioService[slotId]->mRadioResponse != NULL) {
4994 RadioResponseInfo responseInfo = {};
4995 populateResponseInfo(responseInfo, serial, responseType, e);
4996 Return<void> retStatus
4997 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
4998 radioService[slotId]->checkReturnStatus(retStatus);
5000 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
5007 int radio::setCdmaSubscriptionSourceResponse(int slotId,
5008 int responseType, int serial, RIL_Errno e,
5009 void *response, size_t responseLen) {
5011 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
5014 if (radioService[slotId]->mRadioResponse != NULL) {
5015 RadioResponseInfo responseInfo = {};
5016 populateResponseInfo(responseInfo, serial, responseType, e);
5017 Return<void> retStatus
5018 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
5020 radioService[slotId]->checkReturnStatus(retStatus);
5022 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5029 int radio::setCdmaRoamingPreferenceResponse(int slotId,
5030 int responseType, int serial, RIL_Errno e,
5031 void *response, size_t responseLen) {
5033 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
5036 if (radioService[slotId]->mRadioResponse != NULL) {
5037 RadioResponseInfo responseInfo = {};
5038 populateResponseInfo(responseInfo, serial, responseType, e);
5039 Return<void> retStatus
5040 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
5042 radioService[slotId]->checkReturnStatus(retStatus);
5044 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5051 int radio::getCdmaRoamingPreferenceResponse(int slotId,
5052 int responseType, int serial, RIL_Errno e,
5053 void *response, size_t responseLen) {
5055 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
5058 if (radioService[slotId]->mRadioResponse != NULL) {
5059 RadioResponseInfo responseInfo = {};
5060 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5061 Return<void> retStatus
5062 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
5063 responseInfo, (CdmaRoamingType) ret);
5064 radioService[slotId]->checkReturnStatus(retStatus);
5066 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5073 int radio::setTTYModeResponse(int slotId,
5074 int responseType, int serial, RIL_Errno e,
5075 void *response, size_t responseLen) {
5077 RLOGD("setTTYModeResponse: serial %d", serial);
5080 if (radioService[slotId]->mRadioResponse != NULL) {
5081 RadioResponseInfo responseInfo = {};
5082 populateResponseInfo(responseInfo, serial, responseType, e);
5083 Return<void> retStatus
5084 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
5085 radioService[slotId]->checkReturnStatus(retStatus);
5087 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5093 int radio::getTTYModeResponse(int slotId,
5094 int responseType, int serial, RIL_Errno e,
5095 void *response, size_t responseLen) {
5097 RLOGD("getTTYModeResponse: serial %d", serial);
5100 if (radioService[slotId]->mRadioResponse != NULL) {
5101 RadioResponseInfo responseInfo = {};
5102 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5103 Return<void> retStatus
5104 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
5106 radioService[slotId]->checkReturnStatus(retStatus);
5108 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5114 int radio::setPreferredVoicePrivacyResponse(int slotId,
5115 int responseType, int serial, RIL_Errno e,
5116 void *response, size_t responseLen) {
5118 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
5121 if (radioService[slotId]->mRadioResponse != NULL) {
5122 RadioResponseInfo responseInfo = {};
5123 populateResponseInfo(responseInfo, serial, responseType, e);
5124 Return<void> retStatus
5125 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
5127 radioService[slotId]->checkReturnStatus(retStatus);
5129 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5136 int radio::getPreferredVoicePrivacyResponse(int slotId,
5137 int responseType, int serial, RIL_Errno e,
5138 void *response, size_t responseLen) {
5140 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
5143 if (radioService[slotId]->mRadioResponse != NULL) {
5144 RadioResponseInfo responseInfo = {};
5145 populateResponseInfo(responseInfo, serial, responseType, e);
5146 bool enable = false;
5147 int numInts = responseLen / sizeof(int);
5148 if (response == NULL || numInts != 1) {
5149 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
5150 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5152 int *pInt = (int *) response;
5153 enable = pInt[0] == 1 ? true : false;
5155 Return<void> retStatus
5156 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5157 responseInfo, enable);
5158 radioService[slotId]->checkReturnStatus(retStatus);
5160 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5167 int radio::sendCDMAFeatureCodeResponse(int slotId,
5168 int responseType, int serial, RIL_Errno e,
5169 void *response, size_t responseLen) {
5171 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5174 if (radioService[slotId]->mRadioResponse != NULL) {
5175 RadioResponseInfo responseInfo = {};
5176 populateResponseInfo(responseInfo, serial, responseType, e);
5177 Return<void> retStatus
5178 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5179 radioService[slotId]->checkReturnStatus(retStatus);
5181 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5188 int radio::sendBurstDtmfResponse(int slotId,
5189 int responseType, int serial, RIL_Errno e,
5190 void *response, size_t responseLen) {
5192 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5195 if (radioService[slotId]->mRadioResponse != NULL) {
5196 RadioResponseInfo responseInfo = {};
5197 populateResponseInfo(responseInfo, serial, responseType, e);
5198 Return<void> retStatus
5199 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5200 radioService[slotId]->checkReturnStatus(retStatus);
5202 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5208 int radio::sendCdmaSmsResponse(int slotId,
5209 int responseType, int serial, RIL_Errno e, void *response,
5210 size_t responseLen) {
5212 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5215 if (radioService[slotId]->mRadioResponse != NULL) {
5216 RadioResponseInfo responseInfo = {};
5217 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5220 Return<void> retStatus
5221 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5222 radioService[slotId]->checkReturnStatus(retStatus);
5224 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5230 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5231 int responseType, int serial, RIL_Errno e,
5232 void *response, size_t responseLen) {
5234 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5237 if (radioService[slotId]->mRadioResponse != NULL) {
5238 RadioResponseInfo responseInfo = {};
5239 populateResponseInfo(responseInfo, serial, responseType, e);
5240 Return<void> retStatus
5241 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5243 radioService[slotId]->checkReturnStatus(retStatus);
5245 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5252 int radio::getGsmBroadcastConfigResponse(int slotId,
5253 int responseType, int serial, RIL_Errno e,
5254 void *response, size_t responseLen) {
5256 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5259 if (radioService[slotId]->mRadioResponse != NULL) {
5260 RadioResponseInfo responseInfo = {};
5261 populateResponseInfo(responseInfo, serial, responseType, e);
5262 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5264 if ((response == NULL && responseLen != 0)
5265 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5266 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5267 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5269 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5270 configs.resize(num);
5271 for (int i = 0 ; i < num; i++) {
5272 RIL_GSM_BroadcastSmsConfigInfo *resp =
5273 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5274 configs[i].fromServiceId = resp->fromServiceId;
5275 configs[i].toServiceId = resp->toServiceId;
5276 configs[i].fromCodeScheme = resp->fromCodeScheme;
5277 configs[i].toCodeScheme = resp->toCodeScheme;
5278 configs[i].selected = resp->selected == 1 ? true : false;
5282 Return<void> retStatus
5283 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5285 radioService[slotId]->checkReturnStatus(retStatus);
5287 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5294 int radio::setGsmBroadcastConfigResponse(int slotId,
5295 int responseType, int serial, RIL_Errno e,
5296 void *response, size_t responseLen) {
5298 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5301 if (radioService[slotId]->mRadioResponse != NULL) {
5302 RadioResponseInfo responseInfo = {};
5303 populateResponseInfo(responseInfo, serial, responseType, e);
5304 Return<void> retStatus
5305 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5306 radioService[slotId]->checkReturnStatus(retStatus);
5308 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5315 int radio::setGsmBroadcastActivationResponse(int slotId,
5316 int responseType, int serial, RIL_Errno e,
5317 void *response, size_t responseLen) {
5319 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5322 if (radioService[slotId]->mRadioResponse != NULL) {
5323 RadioResponseInfo responseInfo = {};
5324 populateResponseInfo(responseInfo, serial, responseType, e);
5325 Return<void> retStatus
5326 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5328 radioService[slotId]->checkReturnStatus(retStatus);
5330 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5337 int radio::getCdmaBroadcastConfigResponse(int slotId,
5338 int responseType, int serial, RIL_Errno e,
5339 void *response, size_t responseLen) {
5341 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5344 if (radioService[slotId]->mRadioResponse != NULL) {
5345 RadioResponseInfo responseInfo = {};
5346 populateResponseInfo(responseInfo, serial, responseType, e);
5347 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5349 if ((response == NULL && responseLen != 0)
5350 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5351 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5352 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5354 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5355 configs.resize(num);
5356 for (int i = 0 ; i < num; i++) {
5357 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5358 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5359 configs[i].serviceCategory = resp->service_category;
5360 configs[i].language = resp->language;
5361 configs[i].selected = resp->selected == 1 ? true : false;
5365 Return<void> retStatus
5366 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5368 radioService[slotId]->checkReturnStatus(retStatus);
5370 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5377 int radio::setCdmaBroadcastConfigResponse(int slotId,
5378 int responseType, int serial, RIL_Errno e,
5379 void *response, size_t responseLen) {
5381 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5384 if (radioService[slotId]->mRadioResponse != NULL) {
5385 RadioResponseInfo responseInfo = {};
5386 populateResponseInfo(responseInfo, serial, responseType, e);
5387 Return<void> retStatus
5388 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5390 radioService[slotId]->checkReturnStatus(retStatus);
5392 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5399 int radio::setCdmaBroadcastActivationResponse(int slotId,
5400 int responseType, int serial, RIL_Errno e,
5401 void *response, size_t responseLen) {
5403 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5406 if (radioService[slotId]->mRadioResponse != NULL) {
5407 RadioResponseInfo responseInfo = {};
5408 populateResponseInfo(responseInfo, serial, responseType, e);
5409 Return<void> retStatus
5410 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5412 radioService[slotId]->checkReturnStatus(retStatus);
5414 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5421 int radio::getCDMASubscriptionResponse(int slotId,
5422 int responseType, int serial, RIL_Errno e, void *response,
5423 size_t responseLen) {
5425 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5428 if (radioService[slotId]->mRadioResponse != NULL) {
5429 RadioResponseInfo responseInfo = {};
5430 populateResponseInfo(responseInfo, serial, responseType, e);
5432 int numStrings = responseLen / sizeof(char *);
5433 hidl_string emptyString;
5434 if (response == NULL || numStrings != 5) {
5435 RLOGE("getOperatorResponse Invalid response: NULL");
5436 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5437 Return<void> retStatus
5438 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5439 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5440 radioService[slotId]->checkReturnStatus(retStatus);
5442 char **resp = (char **) response;
5443 Return<void> retStatus
5444 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5446 convertCharPtrToHidlString(resp[0]),
5447 convertCharPtrToHidlString(resp[1]),
5448 convertCharPtrToHidlString(resp[2]),
5449 convertCharPtrToHidlString(resp[3]),
5450 convertCharPtrToHidlString(resp[4]));
5451 radioService[slotId]->checkReturnStatus(retStatus);
5454 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5461 int radio::writeSmsToRuimResponse(int slotId,
5462 int responseType, int serial, RIL_Errno e,
5463 void *response, size_t responseLen) {
5465 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5468 if (radioService[slotId]->mRadioResponse != NULL) {
5469 RadioResponseInfo responseInfo = {};
5470 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5471 Return<void> retStatus
5472 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5473 radioService[slotId]->checkReturnStatus(retStatus);
5475 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5481 int radio::deleteSmsOnRuimResponse(int slotId,
5482 int responseType, int serial, RIL_Errno e,
5483 void *response, size_t responseLen) {
5485 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5488 if (radioService[slotId]->mRadioResponse != NULL) {
5489 RadioResponseInfo responseInfo = {};
5490 populateResponseInfo(responseInfo, serial, responseType, e);
5491 Return<void> retStatus
5492 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5493 radioService[slotId]->checkReturnStatus(retStatus);
5495 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5501 int radio::getDeviceIdentityResponse(int slotId,
5502 int responseType, int serial, RIL_Errno e, void *response,
5503 size_t responseLen) {
5505 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5508 if (radioService[slotId]->mRadioResponse != NULL) {
5509 RadioResponseInfo responseInfo = {};
5510 populateResponseInfo(responseInfo, serial, responseType, e);
5512 int numStrings = responseLen / sizeof(char *);
5513 hidl_string emptyString;
5514 if (response == NULL || numStrings != 4) {
5515 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5516 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5517 Return<void> retStatus
5518 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5519 emptyString, emptyString, emptyString, emptyString);
5520 radioService[slotId]->checkReturnStatus(retStatus);
5522 char **resp = (char **) response;
5523 Return<void> retStatus
5524 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5525 convertCharPtrToHidlString(resp[0]),
5526 convertCharPtrToHidlString(resp[1]),
5527 convertCharPtrToHidlString(resp[2]),
5528 convertCharPtrToHidlString(resp[3]));
5529 radioService[slotId]->checkReturnStatus(retStatus);
5532 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5539 int radio::exitEmergencyCallbackModeResponse(int slotId,
5540 int responseType, int serial, RIL_Errno e,
5541 void *response, size_t responseLen) {
5543 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5546 if (radioService[slotId]->mRadioResponse != NULL) {
5547 RadioResponseInfo responseInfo = {};
5548 populateResponseInfo(responseInfo, serial, responseType, e);
5549 Return<void> retStatus
5550 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5552 radioService[slotId]->checkReturnStatus(retStatus);
5554 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5561 int radio::getSmscAddressResponse(int slotId,
5562 int responseType, int serial, RIL_Errno e,
5563 void *response, size_t responseLen) {
5565 RLOGD("getSmscAddressResponse: serial %d", serial);
5568 if (radioService[slotId]->mRadioResponse != NULL) {
5569 RadioResponseInfo responseInfo = {};
5570 populateResponseInfo(responseInfo, serial, responseType, e);
5571 Return<void> retStatus
5572 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5573 convertCharPtrToHidlString((char *) response));
5574 radioService[slotId]->checkReturnStatus(retStatus);
5576 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5582 int radio::setSmscAddressResponse(int slotId,
5583 int responseType, int serial, RIL_Errno e,
5584 void *response, size_t responseLen) {
5586 RLOGD("setSmscAddressResponse: serial %d", serial);
5589 if (radioService[slotId]->mRadioResponse != NULL) {
5590 RadioResponseInfo responseInfo = {};
5591 populateResponseInfo(responseInfo, serial, responseType, e);
5592 Return<void> retStatus
5593 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5594 radioService[slotId]->checkReturnStatus(retStatus);
5596 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5602 int radio::reportSmsMemoryStatusResponse(int slotId,
5603 int responseType, int serial, RIL_Errno e,
5604 void *response, size_t responseLen) {
5606 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5609 if (radioService[slotId]->mRadioResponse != NULL) {
5610 RadioResponseInfo responseInfo = {};
5611 populateResponseInfo(responseInfo, serial, responseType, e);
5612 Return<void> retStatus
5613 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5614 radioService[slotId]->checkReturnStatus(retStatus);
5616 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5623 int radio::reportStkServiceIsRunningResponse(int slotId,
5624 int responseType, int serial, RIL_Errno e,
5625 void *response, size_t responseLen) {
5627 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5630 if (radioService[slotId]->mRadioResponse != NULL) {
5631 RadioResponseInfo responseInfo = {};
5632 populateResponseInfo(responseInfo, serial, responseType, e);
5633 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5634 reportStkServiceIsRunningResponse(responseInfo);
5635 radioService[slotId]->checkReturnStatus(retStatus);
5637 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5644 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5645 int responseType, int serial, RIL_Errno e,
5646 void *response, size_t responseLen) {
5648 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5651 if (radioService[slotId]->mRadioResponse != NULL) {
5652 RadioResponseInfo responseInfo = {};
5653 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5654 Return<void> retStatus
5655 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5656 responseInfo, (CdmaSubscriptionSource) ret);
5657 radioService[slotId]->checkReturnStatus(retStatus);
5659 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5666 int radio::requestIsimAuthenticationResponse(int slotId,
5667 int responseType, int serial, RIL_Errno e,
5668 void *response, size_t responseLen) {
5670 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5673 if (radioService[slotId]->mRadioResponse != NULL) {
5674 RadioResponseInfo responseInfo = {};
5675 populateResponseInfo(responseInfo, serial, responseType, e);
5676 Return<void> retStatus
5677 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5679 convertCharPtrToHidlString((char *) response));
5680 radioService[slotId]->checkReturnStatus(retStatus);
5682 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5689 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5691 int serial, RIL_Errno e, void *response,
5692 size_t responseLen) {
5694 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5697 if (radioService[slotId]->mRadioResponse != NULL) {
5698 RadioResponseInfo responseInfo = {};
5699 populateResponseInfo(responseInfo, serial, responseType, e);
5700 Return<void> retStatus
5701 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5703 radioService[slotId]->checkReturnStatus(retStatus);
5705 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5712 int radio::sendEnvelopeWithStatusResponse(int slotId,
5713 int responseType, int serial, RIL_Errno e, void *response,
5714 size_t responseLen) {
5716 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5719 if (radioService[slotId]->mRadioResponse != NULL) {
5720 RadioResponseInfo responseInfo = {};
5721 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5722 response, responseLen);
5724 Return<void> retStatus
5725 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5727 radioService[slotId]->checkReturnStatus(retStatus);
5729 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5736 int radio::getVoiceRadioTechnologyResponse(int slotId,
5737 int responseType, int serial, RIL_Errno e,
5738 void *response, size_t responseLen) {
5740 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5743 if (radioService[slotId]->mRadioResponse != NULL) {
5744 RadioResponseInfo responseInfo = {};
5745 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5746 Return<void> retStatus
5747 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5748 responseInfo, (RadioTechnology) ret);
5749 radioService[slotId]->checkReturnStatus(retStatus);
5751 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5758 int radio::getCellInfoListResponse(int slotId,
5760 int serial, RIL_Errno e, void *response,
5761 size_t responseLen) {
5763 RLOGD("getCellInfoListResponse: serial %d", serial);
5766 if (radioService[slotId]->mRadioResponse != NULL) {
5767 RadioResponseInfo responseInfo = {};
5768 populateResponseInfo(responseInfo, serial, responseType, e);
5770 hidl_vec<CellInfo> ret;
5771 if ((response == NULL && responseLen != 0)
5772 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5773 RLOGE("getCellInfoListResponse: Invalid response");
5774 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5776 convertRilCellInfoListToHal(response, responseLen, ret);
5779 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5781 radioService[slotId]->checkReturnStatus(retStatus);
5783 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5789 int radio::setCellInfoListRateResponse(int slotId,
5791 int serial, RIL_Errno e, void *response,
5792 size_t responseLen) {
5794 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5797 if (radioService[slotId]->mRadioResponse != NULL) {
5798 RadioResponseInfo responseInfo = {};
5799 populateResponseInfo(responseInfo, serial, responseType, e);
5800 Return<void> retStatus
5801 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5802 radioService[slotId]->checkReturnStatus(retStatus);
5804 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5811 int radio::setInitialAttachApnResponse(int slotId,
5812 int responseType, int serial, RIL_Errno e,
5813 void *response, size_t responseLen) {
5815 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5818 if (radioService[slotId]->mRadioResponse != NULL) {
5819 RadioResponseInfo responseInfo = {};
5820 populateResponseInfo(responseInfo, serial, responseType, e);
5821 Return<void> retStatus
5822 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5823 radioService[slotId]->checkReturnStatus(retStatus);
5825 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5832 int radio::getImsRegistrationStateResponse(int slotId,
5833 int responseType, int serial, RIL_Errno e,
5834 void *response, size_t responseLen) {
5836 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5839 if (radioService[slotId]->mRadioResponse != NULL) {
5840 RadioResponseInfo responseInfo = {};
5841 populateResponseInfo(responseInfo, serial, responseType, e);
5842 bool isRegistered = false;
5844 int numInts = responseLen / sizeof(int);
5845 if (response == NULL || numInts != 2) {
5846 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5847 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5849 int *pInt = (int *) response;
5850 isRegistered = pInt[0] == 1 ? true : false;
5851 ratFamily = pInt[1];
5853 Return<void> retStatus
5854 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5855 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5856 radioService[slotId]->checkReturnStatus(retStatus);
5858 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5865 int radio::sendImsSmsResponse(int slotId,
5866 int responseType, int serial, RIL_Errno e, void *response,
5867 size_t responseLen) {
5869 RLOGD("sendImsSmsResponse: serial %d", serial);
5872 if (radioService[slotId]->mRadioResponse != NULL) {
5873 RadioResponseInfo responseInfo = {};
5874 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5877 Return<void> retStatus
5878 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5879 radioService[slotId]->checkReturnStatus(retStatus);
5881 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5887 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5888 int responseType, int serial, RIL_Errno e,
5889 void *response, size_t responseLen) {
5891 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5894 if (radioService[slotId]->mRadioResponse != NULL) {
5895 RadioResponseInfo responseInfo = {};
5896 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5899 Return<void> retStatus
5900 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5901 responseInfo, result);
5902 radioService[slotId]->checkReturnStatus(retStatus);
5904 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5911 int radio::iccOpenLogicalChannelResponse(int slotId,
5912 int responseType, int serial, RIL_Errno e, void *response,
5913 size_t responseLen) {
5915 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5918 if (radioService[slotId]->mRadioResponse != NULL) {
5919 RadioResponseInfo responseInfo = {};
5920 populateResponseInfo(responseInfo, serial, responseType, e);
5922 hidl_vec<int8_t> selectResponse;
5923 int numInts = responseLen / sizeof(int);
5924 if (response == NULL || responseLen % sizeof(int) != 0) {
5925 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5926 if (response != NULL) {
5927 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5930 int *pInt = (int *) response;
5931 channelId = pInt[0];
5932 selectResponse.resize(numInts - 1);
5933 for (int i = 1; i < numInts; i++) {
5934 selectResponse[i - 1] = (int8_t) pInt[i];
5937 Return<void> retStatus
5938 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5939 channelId, selectResponse);
5940 radioService[slotId]->checkReturnStatus(retStatus);
5942 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5949 int radio::iccCloseLogicalChannelResponse(int slotId,
5950 int responseType, int serial, RIL_Errno e,
5951 void *response, size_t responseLen) {
5953 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
5956 if (radioService[slotId]->mRadioResponse != NULL) {
5957 RadioResponseInfo responseInfo = {};
5958 populateResponseInfo(responseInfo, serial, responseType, e);
5959 Return<void> retStatus
5960 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
5962 radioService[slotId]->checkReturnStatus(retStatus);
5964 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
5971 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
5972 int responseType, int serial, RIL_Errno e,
5973 void *response, size_t responseLen) {
5975 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
5978 if (radioService[slotId]->mRadioResponse != NULL) {
5979 RadioResponseInfo responseInfo = {};
5980 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5983 Return<void> retStatus
5984 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
5985 responseInfo, result);
5986 radioService[slotId]->checkReturnStatus(retStatus);
5988 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
5995 int radio::nvReadItemResponse(int slotId,
5996 int responseType, int serial, RIL_Errno e,
5997 void *response, size_t responseLen) {
5999 RLOGD("nvReadItemResponse: serial %d", serial);
6002 if (radioService[slotId]->mRadioResponse != NULL) {
6003 RadioResponseInfo responseInfo = {};
6004 populateResponseInfo(responseInfo, serial, responseType, e);
6005 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
6007 convertCharPtrToHidlString((char *) response));
6008 radioService[slotId]->checkReturnStatus(retStatus);
6010 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6016 int radio::nvWriteItemResponse(int slotId,
6017 int responseType, int serial, RIL_Errno e,
6018 void *response, size_t responseLen) {
6020 RLOGD("nvWriteItemResponse: serial %d", serial);
6023 if (radioService[slotId]->mRadioResponse != NULL) {
6024 RadioResponseInfo responseInfo = {};
6025 populateResponseInfo(responseInfo, serial, responseType, e);
6026 Return<void> retStatus
6027 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
6028 radioService[slotId]->checkReturnStatus(retStatus);
6030 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6036 int radio::nvWriteCdmaPrlResponse(int slotId,
6037 int responseType, int serial, RIL_Errno e,
6038 void *response, size_t responseLen) {
6040 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
6043 if (radioService[slotId]->mRadioResponse != NULL) {
6044 RadioResponseInfo responseInfo = {};
6045 populateResponseInfo(responseInfo, serial, responseType, e);
6046 Return<void> retStatus
6047 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
6048 radioService[slotId]->checkReturnStatus(retStatus);
6050 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6056 int radio::nvResetConfigResponse(int slotId,
6057 int responseType, int serial, RIL_Errno e,
6058 void *response, size_t responseLen) {
6060 RLOGD("nvResetConfigResponse: serial %d", serial);
6063 if (radioService[slotId]->mRadioResponse != NULL) {
6064 RadioResponseInfo responseInfo = {};
6065 populateResponseInfo(responseInfo, serial, responseType, e);
6066 Return<void> retStatus
6067 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
6068 radioService[slotId]->checkReturnStatus(retStatus);
6070 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6076 int radio::setUiccSubscriptionResponse(int slotId,
6077 int responseType, int serial, RIL_Errno e,
6078 void *response, size_t responseLen) {
6080 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
6083 if (radioService[slotId]->mRadioResponse != NULL) {
6084 RadioResponseInfo responseInfo = {};
6085 populateResponseInfo(responseInfo, serial, responseType, e);
6086 Return<void> retStatus
6087 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
6088 radioService[slotId]->checkReturnStatus(retStatus);
6090 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
6097 int radio::setDataAllowedResponse(int slotId,
6098 int responseType, int serial, RIL_Errno e,
6099 void *response, size_t responseLen) {
6101 RLOGD("setDataAllowedResponse: serial %d", serial);
6104 if (radioService[slotId]->mRadioResponse != NULL) {
6105 RadioResponseInfo responseInfo = {};
6106 populateResponseInfo(responseInfo, serial, responseType, e);
6107 Return<void> retStatus
6108 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
6109 radioService[slotId]->checkReturnStatus(retStatus);
6111 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6117 int radio::getHardwareConfigResponse(int slotId,
6118 int responseType, int serial, RIL_Errno e,
6119 void *response, size_t responseLen) {
6121 RLOGD("getHardwareConfigResponse: serial %d", serial);
6124 if (radioService[slotId]->mRadioResponse != NULL) {
6125 RadioResponseInfo responseInfo = {};
6126 populateResponseInfo(responseInfo, serial, responseType, e);
6128 hidl_vec<HardwareConfig> result;
6129 if ((response == NULL && responseLen != 0)
6130 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
6131 RLOGE("hardwareConfigChangedInd: invalid response");
6132 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6134 convertRilHardwareConfigListToHal(response, responseLen, result);
6137 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
6138 responseInfo, result);
6139 radioService[slotId]->checkReturnStatus(retStatus);
6141 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6147 int radio::requestIccSimAuthenticationResponse(int slotId,
6148 int responseType, int serial, RIL_Errno e,
6149 void *response, size_t responseLen) {
6151 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6154 if (radioService[slotId]->mRadioResponse != NULL) {
6155 RadioResponseInfo responseInfo = {};
6156 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6159 Return<void> retStatus
6160 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6161 responseInfo, result);
6162 radioService[slotId]->checkReturnStatus(retStatus);
6164 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6171 int radio::setDataProfileResponse(int slotId,
6172 int responseType, int serial, RIL_Errno e,
6173 void *response, size_t responseLen) {
6175 RLOGD("setDataProfileResponse: serial %d", serial);
6178 if (radioService[slotId]->mRadioResponse != NULL) {
6179 RadioResponseInfo responseInfo = {};
6180 populateResponseInfo(responseInfo, serial, responseType, e);
6181 Return<void> retStatus
6182 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6183 radioService[slotId]->checkReturnStatus(retStatus);
6185 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6191 int radio::requestShutdownResponse(int slotId,
6192 int responseType, int serial, RIL_Errno e,
6193 void *response, size_t responseLen) {
6195 RLOGD("requestShutdownResponse: serial %d", serial);
6198 if (radioService[slotId]->mRadioResponse != NULL) {
6199 RadioResponseInfo responseInfo = {};
6200 populateResponseInfo(responseInfo, serial, responseType, e);
6201 Return<void> retStatus
6202 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6203 radioService[slotId]->checkReturnStatus(retStatus);
6205 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6211 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6212 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6213 populateResponseInfo(responseInfo, serial, responseType, e);
6215 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6216 RLOGE("responseRadioCapability: Invalid response");
6217 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6218 rc.logicalModemUuid = hidl_string();
6220 convertRilRadioCapabilityToHal(response, responseLen, rc);
6224 int radio::getRadioCapabilityResponse(int slotId,
6225 int responseType, int serial, RIL_Errno e,
6226 void *response, size_t responseLen) {
6228 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6231 if (radioService[slotId]->mRadioResponse != NULL) {
6232 RadioResponseInfo responseInfo = {};
6233 RadioCapability result = {};
6234 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6236 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6237 responseInfo, result);
6238 radioService[slotId]->checkReturnStatus(retStatus);
6240 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6246 int radio::setRadioCapabilityResponse(int slotId,
6247 int responseType, int serial, RIL_Errno e,
6248 void *response, size_t responseLen) {
6250 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6253 if (radioService[slotId]->mRadioResponse != NULL) {
6254 RadioResponseInfo responseInfo = {};
6255 RadioCapability result = {};
6256 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6258 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6259 responseInfo, result);
6260 radioService[slotId]->checkReturnStatus(retStatus);
6262 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6268 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6269 RIL_Errno e, void *response, size_t responseLen) {
6270 populateResponseInfo(responseInfo, serial, responseType, e);
6271 LceStatusInfo result = {};
6273 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6274 RLOGE("Invalid response: NULL");
6275 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6277 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6278 result.lceStatus = (LceStatus) resp->lce_status;
6279 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6284 int radio::startLceServiceResponse(int slotId,
6285 int responseType, int serial, RIL_Errno e,
6286 void *response, size_t responseLen) {
6288 RLOGD("startLceServiceResponse: serial %d", serial);
6291 if (radioService[slotId]->mRadioResponse != NULL) {
6292 RadioResponseInfo responseInfo = {};
6293 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6294 response, responseLen);
6296 Return<void> retStatus
6297 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6299 radioService[slotId]->checkReturnStatus(retStatus);
6301 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6307 int radio::stopLceServiceResponse(int slotId,
6308 int responseType, int serial, RIL_Errno e,
6309 void *response, size_t responseLen) {
6311 RLOGD("stopLceServiceResponse: serial %d", serial);
6314 if (radioService[slotId]->mRadioResponse != NULL) {
6315 RadioResponseInfo responseInfo = {};
6316 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6317 response, responseLen);
6319 Return<void> retStatus
6320 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6322 radioService[slotId]->checkReturnStatus(retStatus);
6324 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6330 int radio::pullLceDataResponse(int slotId,
6331 int responseType, int serial, RIL_Errno e,
6332 void *response, size_t responseLen) {
6334 RLOGD("pullLceDataResponse: serial %d", serial);
6337 if (radioService[slotId]->mRadioResponse != NULL) {
6338 RadioResponseInfo responseInfo = {};
6339 populateResponseInfo(responseInfo, serial, responseType, e);
6341 LceDataInfo result = {};
6342 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6343 RLOGE("pullLceDataResponse: Invalid response");
6344 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6346 convertRilLceDataInfoToHal(response, responseLen, result);
6349 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6350 responseInfo, result);
6351 radioService[slotId]->checkReturnStatus(retStatus);
6353 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6359 int radio::getModemActivityInfoResponse(int slotId,
6360 int responseType, int serial, RIL_Errno e,
6361 void *response, size_t responseLen) {
6363 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6366 if (radioService[slotId]->mRadioResponse != NULL) {
6367 RadioResponseInfo responseInfo = {};
6368 populateResponseInfo(responseInfo, serial, responseType, e);
6369 ActivityStatsInfo info;
6370 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6371 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6372 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6374 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6375 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6376 info.idleModeTimeMs = resp->idle_mode_time_ms;
6377 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6378 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6380 info.rxModeTimeMs = resp->rx_mode_time_ms;
6383 Return<void> retStatus
6384 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6386 radioService[slotId]->checkReturnStatus(retStatus);
6388 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6395 int radio::setAllowedCarriersResponse(int slotId,
6396 int responseType, int serial, RIL_Errno e,
6397 void *response, size_t responseLen) {
6399 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6402 if (radioService[slotId]->mRadioResponse != NULL) {
6403 RadioResponseInfo responseInfo = {};
6404 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6405 Return<void> retStatus
6406 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6408 radioService[slotId]->checkReturnStatus(retStatus);
6410 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6417 int radio::getAllowedCarriersResponse(int slotId,
6418 int responseType, int serial, RIL_Errno e,
6419 void *response, size_t responseLen) {
6421 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6424 if (radioService[slotId]->mRadioResponse != NULL) {
6425 RadioResponseInfo responseInfo = {};
6426 populateResponseInfo(responseInfo, serial, responseType, e);
6427 CarrierRestrictions carrierInfo = {};
6428 bool allAllowed = true;
6429 if (response == NULL) {
6431 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6433 carrierInfo.allowedCarriers.resize(0);
6434 carrierInfo.excludedCarriers.resize(0);
6435 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6436 RLOGE("getAllowedCarriersResponse Invalid response");
6437 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6439 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6440 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6444 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6445 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6446 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6447 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6448 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6449 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6450 carrierInfo.allowedCarriers[i].matchData =
6451 convertCharPtrToHidlString(carrier->match_data);
6454 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6455 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6456 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6457 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6458 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6459 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6460 carrierInfo.excludedCarriers[i].matchData =
6461 convertCharPtrToHidlString(carrier->match_data);
6465 Return<void> retStatus
6466 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6467 allAllowed, carrierInfo);
6468 radioService[slotId]->checkReturnStatus(retStatus);
6470 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6477 int radio::sendDeviceStateResponse(int slotId,
6478 int responseType, int serial, RIL_Errno e,
6479 void *response, size_t responselen) {
6481 RLOGD("sendDeviceStateResponse: serial %d", serial);
6484 if (radioService[slotId]->mRadioResponse != NULL) {
6485 RadioResponseInfo responseInfo = {};
6486 populateResponseInfo(responseInfo, serial, responseType, e);
6487 Return<void> retStatus
6488 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6489 radioService[slotId]->checkReturnStatus(retStatus);
6491 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6497 int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
6498 int responseType, int serial, RIL_Errno e,
6499 void *response, size_t responseLen) {
6500 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
6501 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6502 RadioResponseInfo responseInfo = {};
6503 populateResponseInfo(responseInfo, serial, responseType, e);
6504 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6505 setCarrierInfoForImsiEncryptionResponse(responseInfo);
6506 radioService[slotId]->checkReturnStatus(retStatus);
6508 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponseV1_1 == "
6514 int radio::setIndicationFilterResponse(int slotId,
6515 int responseType, int serial, RIL_Errno e,
6516 void *response, size_t responselen) {
6518 RLOGD("setIndicationFilterResponse: serial %d", serial);
6521 if (radioService[slotId]->mRadioResponse != NULL) {
6522 RadioResponseInfo responseInfo = {};
6523 populateResponseInfo(responseInfo, serial, responseType, e);
6524 Return<void> retStatus
6525 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6526 radioService[slotId]->checkReturnStatus(retStatus);
6528 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6535 int radio::setSimCardPowerResponse(int slotId,
6536 int responseType, int serial, RIL_Errno e,
6537 void *response, size_t responseLen) {
6539 RLOGD("setSimCardPowerResponse: serial %d", serial);
6542 if (radioService[slotId]->mRadioResponse != NULL
6543 || radioService[slotId]->mRadioResponseV1_1 != NULL) {
6544 RadioResponseInfo responseInfo = {};
6545 populateResponseInfo(responseInfo, serial, responseType, e);
6546 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6547 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6548 setSimCardPowerResponse_1_1(responseInfo);
6549 radioService[slotId]->checkReturnStatus(retStatus);
6551 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_1 == NULL",
6553 Return<void> retStatus
6554 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6555 radioService[slotId]->checkReturnStatus(retStatus);
6558 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL && "
6559 "radioService[%d]->mRadioResponseV1_1 == NULL", slotId, slotId);
6564 int radio::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6565 void *response, size_t responseLen) {
6567 RLOGD("startNetworkScanResponse: serial %d", serial);
6570 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6571 RadioResponseInfo responseInfo = {};
6572 populateResponseInfo(responseInfo, serial, responseType, e);
6573 Return<void> retStatus
6574 = radioService[slotId]->mRadioResponseV1_1->startNetworkScanResponse(responseInfo);
6575 radioService[slotId]->checkReturnStatus(retStatus);
6577 RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6583 int radio::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6584 void *response, size_t responseLen) {
6586 RLOGD("stopNetworkScanResponse: serial %d", serial);
6589 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6590 RadioResponseInfo responseInfo = {};
6591 populateResponseInfo(responseInfo, serial, responseType, e);
6592 Return<void> retStatus
6593 = radioService[slotId]->mRadioResponseV1_1->stopNetworkScanResponse(responseInfo);
6594 radioService[slotId]->checkReturnStatus(retStatus);
6596 RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6602 int radio::sendRequestRawResponse(int slotId,
6603 int responseType, int serial, RIL_Errno e,
6604 void *response, size_t responseLen) {
6606 RLOGD("sendRequestRawResponse: serial %d", serial);
6609 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6610 RadioResponseInfo responseInfo = {};
6611 populateResponseInfo(responseInfo, serial, responseType, e);
6612 hidl_vec<uint8_t> data;
6614 if (response == NULL) {
6615 RLOGE("sendRequestRawResponse: Invalid response");
6616 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6618 data.setToExternal((uint8_t *) response, responseLen);
6620 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6621 sendRequestRawResponse(responseInfo, data);
6622 checkReturnStatus(slotId, retStatus, false);
6624 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6631 int radio::sendRequestStringsResponse(int slotId,
6632 int responseType, int serial, RIL_Errno e,
6633 void *response, size_t responseLen) {
6635 RLOGD("sendRequestStringsResponse: serial %d", serial);
6638 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6639 RadioResponseInfo responseInfo = {};
6640 populateResponseInfo(responseInfo, serial, responseType, e);
6641 hidl_vec<hidl_string> data;
6643 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
6644 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6645 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6647 char **resp = (char **) response;
6648 int numStrings = responseLen / sizeof(char *);
6649 data.resize(numStrings);
6650 for (int i = 0; i < numStrings; i++) {
6651 data[i] = convertCharPtrToHidlString(resp[i]);
6654 Return<void> retStatus
6655 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6656 responseInfo, data);
6657 checkReturnStatus(slotId, retStatus, false);
6659 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6666 // Radio Indication functions
6668 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6669 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6670 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6673 int radio::radioStateChangedInd(int slotId,
6674 int indicationType, int token, RIL_Errno e, void *response,
6675 size_t responseLen) {
6676 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6677 RadioState radioState =
6678 (RadioState) CALL_ONSTATEREQUEST(slotId);
6679 RLOGD("radioStateChangedInd: radioState %d", radioState);
6680 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6681 convertIntToRadioIndicationType(indicationType), radioState);
6682 radioService[slotId]->checkReturnStatus(retStatus);
6684 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6690 int radio::callStateChangedInd(int slotId,
6691 int indicationType, int token, RIL_Errno e, void *response,
6692 size_t responseLen) {
6693 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6695 RLOGD("callStateChangedInd");
6697 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6698 convertIntToRadioIndicationType(indicationType));
6699 radioService[slotId]->checkReturnStatus(retStatus);
6701 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6707 int radio::networkStateChangedInd(int slotId,
6708 int indicationType, int token, RIL_Errno e, void *response,
6709 size_t responseLen) {
6710 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6712 RLOGD("networkStateChangedInd");
6714 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6715 convertIntToRadioIndicationType(indicationType));
6716 radioService[slotId]->checkReturnStatus(retStatus);
6718 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6725 uint8_t hexCharToInt(uint8_t c) {
6726 if (c >= '0' && c <= '9') return (c - '0');
6727 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6728 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6730 return INVALID_HEX_CHAR;
6733 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6734 if (responseLen % 2 != 0) {
6738 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6739 if (bytes == NULL) {
6740 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6743 uint8_t *hexString = (uint8_t *)response;
6745 for (size_t i = 0; i < responseLen; i += 2) {
6746 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6747 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6749 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6750 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6751 hexString[i], hexString[i + 1]);
6755 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6761 int radio::newSmsInd(int slotId, int indicationType,
6762 int token, RIL_Errno e, void *response, size_t responseLen) {
6763 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6764 if (response == NULL || responseLen == 0) {
6765 RLOGE("newSmsInd: invalid response");
6769 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6770 if (bytes == NULL) {
6771 RLOGE("newSmsInd: convertHexStringToBytes failed");
6775 hidl_vec<uint8_t> pdu;
6776 pdu.setToExternal(bytes, responseLen/2);
6780 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6781 convertIntToRadioIndicationType(indicationType), pdu);
6782 radioService[slotId]->checkReturnStatus(retStatus);
6785 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6791 int radio::newSmsStatusReportInd(int slotId,
6792 int indicationType, int token, RIL_Errno e, void *response,
6793 size_t responseLen) {
6794 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6795 if (response == NULL || responseLen == 0) {
6796 RLOGE("newSmsStatusReportInd: invalid response");
6800 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6801 if (bytes == NULL) {
6802 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6806 hidl_vec<uint8_t> pdu;
6807 pdu.setToExternal(bytes, responseLen/2);
6809 RLOGD("newSmsStatusReportInd");
6811 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6812 convertIntToRadioIndicationType(indicationType), pdu);
6813 radioService[slotId]->checkReturnStatus(retStatus);
6816 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6822 int radio::newSmsOnSimInd(int slotId, int indicationType,
6823 int token, RIL_Errno e, void *response, size_t responseLen) {
6824 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6825 if (response == NULL || responseLen != sizeof(int)) {
6826 RLOGE("newSmsOnSimInd: invalid response");
6829 int32_t recordNumber = ((int32_t *) response)[0];
6831 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6833 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6834 convertIntToRadioIndicationType(indicationType), recordNumber);
6835 radioService[slotId]->checkReturnStatus(retStatus);
6837 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6843 int radio::onUssdInd(int slotId, int indicationType,
6844 int token, RIL_Errno e, void *response, size_t responseLen) {
6845 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6846 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6847 RLOGE("onUssdInd: invalid response");
6850 char **strings = (char **) response;
6851 char *mode = strings[0];
6852 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6853 UssdModeType modeType = (UssdModeType) atoi(mode);
6855 RLOGD("onUssdInd: mode %s", mode);
6857 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6858 convertIntToRadioIndicationType(indicationType), modeType, msg);
6859 radioService[slotId]->checkReturnStatus(retStatus);
6861 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6867 int radio::nitzTimeReceivedInd(int slotId,
6868 int indicationType, int token, RIL_Errno e, void *response,
6869 size_t responseLen) {
6870 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6871 if (response == NULL || responseLen == 0) {
6872 RLOGE("nitzTimeReceivedInd: invalid response");
6875 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6876 int64_t timeReceived = android::elapsedRealtime();
6878 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6881 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6882 convertIntToRadioIndicationType(indicationType), nitzTime, timeReceived);
6883 radioService[slotId]->checkReturnStatus(retStatus);
6885 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6892 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
6893 SignalStrength& signalStrength) {
6894 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
6896 // Fixup LTE for backwards compatibility
6897 // signalStrength: -1 -> 99
6898 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
6899 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
6901 // rsrp: -1 -> INT_MAX all other negative value to positive.
6903 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
6904 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
6905 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
6906 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
6908 // rsrq: -1 -> INT_MAX
6909 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
6910 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
6912 // Not remapping rssnr is already using INT_MAX
6913 // cqi: -1 -> INT_MAX
6914 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
6915 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
6918 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
6919 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
6920 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
6921 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
6922 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
6923 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
6924 signalStrength.evdo.signalNoiseRatio =
6925 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
6926 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
6927 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
6928 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
6929 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
6930 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
6931 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
6932 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
6935 int radio::currentSignalStrengthInd(int slotId,
6936 int indicationType, int token, RIL_Errno e,
6937 void *response, size_t responseLen) {
6938 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6939 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
6940 RLOGE("currentSignalStrengthInd: invalid response");
6944 SignalStrength signalStrength = {};
6945 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
6948 RLOGD("currentSignalStrengthInd");
6950 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
6951 convertIntToRadioIndicationType(indicationType), signalStrength);
6952 radioService[slotId]->checkReturnStatus(retStatus);
6954 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
6961 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
6962 SetupDataCallResult& dcResult) {
6963 dcResult.status = (DataCallFailCause) dcResponse->status;
6964 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
6965 dcResult.cid = dcResponse->cid;
6966 dcResult.active = dcResponse->active;
6967 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
6968 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
6969 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
6970 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
6971 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
6972 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
6973 dcResult.mtu = dcResponse->mtu;
6976 void convertRilDataCallListToHal(void *response, size_t responseLen,
6977 hidl_vec<SetupDataCallResult>& dcResultList) {
6978 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
6980 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
6981 dcResultList.resize(num);
6982 for (int i = 0; i < num; i++) {
6983 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
6987 int radio::dataCallListChangedInd(int slotId,
6988 int indicationType, int token, RIL_Errno e, void *response,
6989 size_t responseLen) {
6990 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6991 if ((response == NULL && responseLen != 0)
6992 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
6993 RLOGE("dataCallListChangedInd: invalid response");
6996 hidl_vec<SetupDataCallResult> dcList;
6997 convertRilDataCallListToHal(response, responseLen, dcList);
6999 RLOGD("dataCallListChangedInd");
7001 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
7002 convertIntToRadioIndicationType(indicationType), dcList);
7003 radioService[slotId]->checkReturnStatus(retStatus);
7005 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7011 int radio::suppSvcNotifyInd(int slotId, int indicationType,
7012 int token, RIL_Errno e, void *response, size_t responseLen) {
7013 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7014 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
7015 RLOGE("suppSvcNotifyInd: invalid response");
7019 SuppSvcNotification suppSvc = {};
7020 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
7021 suppSvc.isMT = ssn->notificationType;
7022 suppSvc.code = ssn->code;
7023 suppSvc.index = ssn->index;
7024 suppSvc.type = ssn->type;
7025 suppSvc.number = convertCharPtrToHidlString(ssn->number);
7028 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
7029 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
7031 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
7032 convertIntToRadioIndicationType(indicationType), suppSvc);
7033 radioService[slotId]->checkReturnStatus(retStatus);
7035 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7041 int radio::stkSessionEndInd(int slotId, int indicationType,
7042 int token, RIL_Errno e, void *response, size_t responseLen) {
7043 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7045 RLOGD("stkSessionEndInd");
7047 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
7048 convertIntToRadioIndicationType(indicationType));
7049 radioService[slotId]->checkReturnStatus(retStatus);
7051 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
7057 int radio::stkProactiveCommandInd(int slotId,
7058 int indicationType, int token, RIL_Errno e, void *response,
7059 size_t responseLen) {
7060 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7061 if (response == NULL || responseLen == 0) {
7062 RLOGE("stkProactiveCommandInd: invalid response");
7066 RLOGD("stkProactiveCommandInd");
7068 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
7069 convertIntToRadioIndicationType(indicationType),
7070 convertCharPtrToHidlString((char *) response));
7071 radioService[slotId]->checkReturnStatus(retStatus);
7073 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
7079 int radio::stkEventNotifyInd(int slotId, int indicationType,
7080 int token, RIL_Errno e, void *response, size_t responseLen) {
7081 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7082 if (response == NULL || responseLen == 0) {
7083 RLOGE("stkEventNotifyInd: invalid response");
7087 RLOGD("stkEventNotifyInd");
7089 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
7090 convertIntToRadioIndicationType(indicationType),
7091 convertCharPtrToHidlString((char *) response));
7092 radioService[slotId]->checkReturnStatus(retStatus);
7094 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7100 int radio::stkCallSetupInd(int slotId, int indicationType,
7101 int token, RIL_Errno e, void *response, size_t responseLen) {
7102 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7103 if (response == NULL || responseLen != sizeof(int)) {
7104 RLOGE("stkCallSetupInd: invalid response");
7107 int32_t timeout = ((int32_t *) response)[0];
7109 RLOGD("stkCallSetupInd: timeout %d", timeout);
7111 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
7112 convertIntToRadioIndicationType(indicationType), timeout);
7113 radioService[slotId]->checkReturnStatus(retStatus);
7115 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
7121 int radio::simSmsStorageFullInd(int slotId,
7122 int indicationType, int token, RIL_Errno e, void *response,
7123 size_t responseLen) {
7124 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7126 RLOGD("simSmsStorageFullInd");
7128 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
7129 convertIntToRadioIndicationType(indicationType));
7130 radioService[slotId]->checkReturnStatus(retStatus);
7132 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
7138 int radio::simRefreshInd(int slotId, int indicationType,
7139 int token, RIL_Errno e, void *response, size_t responseLen) {
7140 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7141 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
7142 RLOGE("simRefreshInd: invalid response");
7146 SimRefreshResult refreshResult = {};
7147 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
7148 refreshResult.type =
7149 (V1_0::SimRefreshType) simRefreshResponse->result;
7150 refreshResult.efId = simRefreshResponse->ef_id;
7151 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
7154 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
7156 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
7157 convertIntToRadioIndicationType(indicationType), refreshResult);
7158 radioService[slotId]->checkReturnStatus(retStatus);
7160 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
7166 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
7167 CdmaSignalInfoRecord& record) {
7168 record.isPresent = signalInfoRecord->isPresent;
7169 record.signalType = signalInfoRecord->signalType;
7170 record.alertPitch = signalInfoRecord->alertPitch;
7171 record.signal = signalInfoRecord->signal;
7174 int radio::callRingInd(int slotId, int indicationType,
7175 int token, RIL_Errno e, void *response, size_t responseLen) {
7176 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7178 CdmaSignalInfoRecord record = {};
7179 if (response == NULL || responseLen == 0) {
7183 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
7184 RLOGE("callRingInd: invalid response");
7187 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
7191 RLOGD("callRingInd: isGsm %d", isGsm);
7193 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
7194 convertIntToRadioIndicationType(indicationType), isGsm, record);
7195 radioService[slotId]->checkReturnStatus(retStatus);
7197 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7203 int radio::simStatusChangedInd(int slotId,
7204 int indicationType, int token, RIL_Errno e, void *response,
7205 size_t responseLen) {
7206 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7208 RLOGD("simStatusChangedInd");
7210 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7211 convertIntToRadioIndicationType(indicationType));
7212 radioService[slotId]->checkReturnStatus(retStatus);
7214 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7220 int radio::cdmaNewSmsInd(int slotId, int indicationType,
7221 int token, RIL_Errno e, void *response, size_t responseLen) {
7222 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7223 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7224 RLOGE("cdmaNewSmsInd: invalid response");
7228 CdmaSmsMessage msg = {};
7229 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7230 msg.teleserviceId = rilMsg->uTeleserviceID;
7231 msg.isServicePresent = rilMsg->bIsServicePresent;
7232 msg.serviceCategory = rilMsg->uServicecategory;
7233 msg.address.digitMode =
7234 (V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7235 msg.address.numberMode =
7236 (V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7237 msg.address.numberType =
7238 (V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7239 msg.address.numberPlan =
7240 (V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7242 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7243 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7245 msg.subAddress.subaddressType = (V1_0::CdmaSmsSubaddressType)
7246 rilMsg->sSubAddress.subaddressType;
7247 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7249 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7250 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7252 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7253 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7256 RLOGD("cdmaNewSmsInd");
7258 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7259 convertIntToRadioIndicationType(indicationType), msg);
7260 radioService[slotId]->checkReturnStatus(retStatus);
7262 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7268 int radio::newBroadcastSmsInd(int slotId,
7269 int indicationType, int token, RIL_Errno e, void *response,
7270 size_t responseLen) {
7271 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7272 if (response == NULL || responseLen == 0) {
7273 RLOGE("newBroadcastSmsInd: invalid response");
7277 hidl_vec<uint8_t> data;
7278 data.setToExternal((uint8_t *) response, responseLen);
7280 RLOGD("newBroadcastSmsInd");
7282 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7283 convertIntToRadioIndicationType(indicationType), data);
7284 radioService[slotId]->checkReturnStatus(retStatus);
7286 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7292 int radio::cdmaRuimSmsStorageFullInd(int slotId,
7293 int indicationType, int token, RIL_Errno e, void *response,
7294 size_t responseLen) {
7295 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7297 RLOGD("cdmaRuimSmsStorageFullInd");
7299 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7300 convertIntToRadioIndicationType(indicationType));
7301 radioService[slotId]->checkReturnStatus(retStatus);
7303 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7310 int radio::restrictedStateChangedInd(int slotId,
7311 int indicationType, int token, RIL_Errno e, void *response,
7312 size_t responseLen) {
7313 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7314 if (response == NULL || responseLen != sizeof(int)) {
7315 RLOGE("restrictedStateChangedInd: invalid response");
7318 int32_t state = ((int32_t *) response)[0];
7320 RLOGD("restrictedStateChangedInd: state %d", state);
7322 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7323 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7324 radioService[slotId]->checkReturnStatus(retStatus);
7326 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7333 int radio::enterEmergencyCallbackModeInd(int slotId,
7334 int indicationType, int token, RIL_Errno e, void *response,
7335 size_t responseLen) {
7336 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7338 RLOGD("enterEmergencyCallbackModeInd");
7340 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7341 convertIntToRadioIndicationType(indicationType));
7342 radioService[slotId]->checkReturnStatus(retStatus);
7344 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7351 int radio::cdmaCallWaitingInd(int slotId,
7352 int indicationType, int token, RIL_Errno e, void *response,
7353 size_t responseLen) {
7354 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7355 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7356 RLOGE("cdmaCallWaitingInd: invalid response");
7360 CdmaCallWaiting callWaitingRecord = {};
7361 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7362 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7363 callWaitingRecord.numberPresentation =
7364 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7365 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7366 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7367 callWaitingRecord.signalInfoRecord);
7368 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7369 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7372 RLOGD("cdmaCallWaitingInd");
7374 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7375 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7376 radioService[slotId]->checkReturnStatus(retStatus);
7378 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7384 int radio::cdmaOtaProvisionStatusInd(int slotId,
7385 int indicationType, int token, RIL_Errno e, void *response,
7386 size_t responseLen) {
7387 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7388 if (response == NULL || responseLen != sizeof(int)) {
7389 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7392 int32_t status = ((int32_t *) response)[0];
7394 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7396 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7397 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7398 radioService[slotId]->checkReturnStatus(retStatus);
7400 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7407 int radio::cdmaInfoRecInd(int slotId,
7408 int indicationType, int token, RIL_Errno e, void *response,
7409 size_t responseLen) {
7410 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7411 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7412 RLOGE("cdmaInfoRecInd: invalid response");
7416 CdmaInformationRecords records = {};
7417 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7419 char* string8 = NULL;
7420 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7421 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7422 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7423 "additional ones", recordsRil->numberOfInfoRecs,
7424 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7426 records.infoRec.resize(num);
7427 for (int i = 0 ; i < num ; i++) {
7428 CdmaInformationRecord *record = &records.infoRec[i];
7429 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7430 record->name = (CdmaInfoRecName) infoRec->name;
7431 // All vectors should be size 0 except one which will be size 1. Set everything to
7432 // size 0 initially.
7433 record->display.resize(0);
7434 record->number.resize(0);
7435 record->signal.resize(0);
7436 record->redir.resize(0);
7437 record->lineCtrl.resize(0);
7438 record->clir.resize(0);
7439 record->audioCtrl.resize(0);
7440 switch (infoRec->name) {
7441 case RIL_CDMA_DISPLAY_INFO_REC:
7442 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7443 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7444 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7445 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7446 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7449 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7450 if (string8 == NULL) {
7451 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7452 "responseCdmaInformationRecords");
7455 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7456 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7458 record->display.resize(1);
7459 record->display[0].alphaBuf = string8;
7465 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7466 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7467 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7468 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7469 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7470 "expected not more than %d", (int) infoRec->rec.number.len,
7471 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7474 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7475 if (string8 == NULL) {
7476 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7477 "responseCdmaInformationRecords");
7480 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7481 string8[(int)infoRec->rec.number.len] = '\0';
7483 record->number.resize(1);
7484 record->number[0].number = string8;
7487 record->number[0].numberType = infoRec->rec.number.number_type;
7488 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7489 record->number[0].pi = infoRec->rec.number.pi;
7490 record->number[0].si = infoRec->rec.number.si;
7494 case RIL_CDMA_SIGNAL_INFO_REC: {
7495 record->signal.resize(1);
7496 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7497 record->signal[0].signalType = infoRec->rec.signal.signalType;
7498 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7499 record->signal[0].signal = infoRec->rec.signal.signal;
7503 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7504 if (infoRec->rec.redir.redirectingNumber.len >
7505 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7506 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7507 "expected not more than %d\n",
7508 (int)infoRec->rec.redir.redirectingNumber.len,
7509 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7512 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7514 if (string8 == NULL) {
7515 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7516 "responseCdmaInformationRecords");
7519 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7520 infoRec->rec.redir.redirectingNumber.len);
7521 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7523 record->redir.resize(1);
7524 record->redir[0].redirectingNumber.number = string8;
7527 record->redir[0].redirectingNumber.numberType =
7528 infoRec->rec.redir.redirectingNumber.number_type;
7529 record->redir[0].redirectingNumber.numberPlan =
7530 infoRec->rec.redir.redirectingNumber.number_plan;
7531 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7532 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7533 record->redir[0].redirectingReason =
7534 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7538 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7539 record->lineCtrl.resize(1);
7540 record->lineCtrl[0].lineCtrlPolarityIncluded =
7541 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7542 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7543 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7544 record->lineCtrl[0].lineCtrlPowerDenial =
7545 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7549 case RIL_CDMA_T53_CLIR_INFO_REC: {
7550 record->clir.resize(1);
7551 record->clir[0].cause = infoRec->rec.clir.cause;
7555 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7556 record->audioCtrl.resize(1);
7557 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7558 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7562 case RIL_CDMA_T53_RELEASE_INFO_REC:
7563 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7567 RLOGE("cdmaInfoRecInd: Incorrect name value");
7573 RLOGD("cdmaInfoRecInd");
7575 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7576 convertIntToRadioIndicationType(indicationType), records);
7577 radioService[slotId]->checkReturnStatus(retStatus);
7579 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7585 int radio::indicateRingbackToneInd(int slotId,
7586 int indicationType, int token, RIL_Errno e, void *response,
7587 size_t responseLen) {
7588 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7589 if (response == NULL || responseLen != sizeof(int)) {
7590 RLOGE("indicateRingbackToneInd: invalid response");
7593 bool start = ((int32_t *) response)[0];
7595 RLOGD("indicateRingbackToneInd: start %d", start);
7597 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7598 convertIntToRadioIndicationType(indicationType), start);
7599 radioService[slotId]->checkReturnStatus(retStatus);
7601 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7607 int radio::resendIncallMuteInd(int slotId,
7608 int indicationType, int token, RIL_Errno e, void *response,
7609 size_t responseLen) {
7610 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7612 RLOGD("resendIncallMuteInd");
7614 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7615 convertIntToRadioIndicationType(indicationType));
7616 radioService[slotId]->checkReturnStatus(retStatus);
7618 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7624 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7625 int indicationType, int token, RIL_Errno e,
7626 void *response, size_t responseLen) {
7627 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7628 if (response == NULL || responseLen != sizeof(int)) {
7629 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7632 int32_t cdmaSource = ((int32_t *) response)[0];
7634 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7636 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7637 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7638 (CdmaSubscriptionSource) cdmaSource);
7639 radioService[slotId]->checkReturnStatus(retStatus);
7641 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7648 int radio::cdmaPrlChangedInd(int slotId,
7649 int indicationType, int token, RIL_Errno e, void *response,
7650 size_t responseLen) {
7651 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7652 if (response == NULL || responseLen != sizeof(int)) {
7653 RLOGE("cdmaPrlChangedInd: invalid response");
7656 int32_t version = ((int32_t *) response)[0];
7658 RLOGD("cdmaPrlChangedInd: version %d", version);
7660 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7661 convertIntToRadioIndicationType(indicationType), version);
7662 radioService[slotId]->checkReturnStatus(retStatus);
7664 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7670 int radio::exitEmergencyCallbackModeInd(int slotId,
7671 int indicationType, int token, RIL_Errno e, void *response,
7672 size_t responseLen) {
7673 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7675 RLOGD("exitEmergencyCallbackModeInd");
7677 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7678 convertIntToRadioIndicationType(indicationType));
7679 radioService[slotId]->checkReturnStatus(retStatus);
7681 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7688 int radio::rilConnectedInd(int slotId,
7689 int indicationType, int token, RIL_Errno e, void *response,
7690 size_t responseLen) {
7691 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7692 RLOGD("rilConnectedInd");
7693 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7694 convertIntToRadioIndicationType(indicationType));
7695 radioService[slotId]->checkReturnStatus(retStatus);
7697 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7703 int radio::voiceRadioTechChangedInd(int slotId,
7704 int indicationType, int token, RIL_Errno e, void *response,
7705 size_t responseLen) {
7706 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7707 if (response == NULL || responseLen != sizeof(int)) {
7708 RLOGE("voiceRadioTechChangedInd: invalid response");
7711 int32_t rat = ((int32_t *) response)[0];
7713 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7715 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7716 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7717 radioService[slotId]->checkReturnStatus(retStatus);
7719 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7726 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7727 int num = responseLen / sizeof(RIL_CellInfo_v12);
7728 records.resize(num);
7730 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7731 for (int i = 0; i < num; i++) {
7732 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7733 records[i].registered = rillCellInfo->registered;
7734 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7735 records[i].timeStamp = rillCellInfo->timeStamp;
7736 // All vectors should be size 0 except one which will be size 1. Set everything to
7737 // size 0 initially.
7738 records[i].gsm.resize(0);
7739 records[i].wcdma.resize(0);
7740 records[i].cdma.resize(0);
7741 records[i].lte.resize(0);
7742 records[i].tdscdma.resize(0);
7743 switch(rillCellInfo->cellInfoType) {
7744 case RIL_CELL_INFO_TYPE_GSM: {
7745 records[i].gsm.resize(1);
7746 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7747 cellInfoGsm->cellIdentityGsm.mcc =
7748 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7749 cellInfoGsm->cellIdentityGsm.mnc =
7750 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7751 cellInfoGsm->cellIdentityGsm.lac =
7752 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7753 cellInfoGsm->cellIdentityGsm.cid =
7754 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7755 cellInfoGsm->cellIdentityGsm.arfcn =
7756 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7757 cellInfoGsm->cellIdentityGsm.bsic =
7758 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7759 cellInfoGsm->signalStrengthGsm.signalStrength =
7760 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7761 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7762 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7763 cellInfoGsm->signalStrengthGsm.timingAdvance =
7764 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7768 case RIL_CELL_INFO_TYPE_WCDMA: {
7769 records[i].wcdma.resize(1);
7770 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7771 cellInfoWcdma->cellIdentityWcdma.mcc =
7772 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7773 cellInfoWcdma->cellIdentityWcdma.mnc =
7774 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7775 cellInfoWcdma->cellIdentityWcdma.lac =
7776 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7777 cellInfoWcdma->cellIdentityWcdma.cid =
7778 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7779 cellInfoWcdma->cellIdentityWcdma.psc =
7780 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7781 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7782 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7783 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7784 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7785 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7786 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7790 case RIL_CELL_INFO_TYPE_CDMA: {
7791 records[i].cdma.resize(1);
7792 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7793 cellInfoCdma->cellIdentityCdma.networkId =
7794 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7795 cellInfoCdma->cellIdentityCdma.systemId =
7796 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7797 cellInfoCdma->cellIdentityCdma.baseStationId =
7798 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7799 cellInfoCdma->cellIdentityCdma.longitude =
7800 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7801 cellInfoCdma->cellIdentityCdma.latitude =
7802 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7803 cellInfoCdma->signalStrengthCdma.dbm =
7804 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7805 cellInfoCdma->signalStrengthCdma.ecio =
7806 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7807 cellInfoCdma->signalStrengthEvdo.dbm =
7808 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7809 cellInfoCdma->signalStrengthEvdo.ecio =
7810 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7811 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7812 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7816 case RIL_CELL_INFO_TYPE_LTE: {
7817 records[i].lte.resize(1);
7818 CellInfoLte *cellInfoLte = &records[i].lte[0];
7819 cellInfoLte->cellIdentityLte.mcc =
7820 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7821 cellInfoLte->cellIdentityLte.mnc =
7822 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7823 cellInfoLte->cellIdentityLte.ci =
7824 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7825 cellInfoLte->cellIdentityLte.pci =
7826 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7827 cellInfoLte->cellIdentityLte.tac =
7828 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7829 cellInfoLte->cellIdentityLte.earfcn =
7830 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7831 cellInfoLte->signalStrengthLte.signalStrength =
7832 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7833 cellInfoLte->signalStrengthLte.rsrp =
7834 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7835 cellInfoLte->signalStrengthLte.rsrq =
7836 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7837 cellInfoLte->signalStrengthLte.rssnr =
7838 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7839 cellInfoLte->signalStrengthLte.cqi =
7840 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7841 cellInfoLte->signalStrengthLte.timingAdvance =
7842 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7846 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7847 records[i].tdscdma.resize(1);
7848 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7849 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7850 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7851 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7852 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7853 cellInfoTdscdma->cellIdentityTdscdma.lac =
7854 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7855 cellInfoTdscdma->cellIdentityTdscdma.cid =
7856 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7857 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7858 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7859 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7860 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7871 int radio::cellInfoListInd(int slotId,
7872 int indicationType, int token, RIL_Errno e, void *response,
7873 size_t responseLen) {
7874 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7875 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7876 RLOGE("cellInfoListInd: invalid response");
7880 hidl_vec<CellInfo> records;
7881 convertRilCellInfoListToHal(response, responseLen, records);
7884 RLOGD("cellInfoListInd");
7886 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
7887 convertIntToRadioIndicationType(indicationType), records);
7888 radioService[slotId]->checkReturnStatus(retStatus);
7890 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
7896 int radio::imsNetworkStateChangedInd(int slotId,
7897 int indicationType, int token, RIL_Errno e, void *response,
7898 size_t responseLen) {
7899 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7901 RLOGD("imsNetworkStateChangedInd");
7903 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
7904 convertIntToRadioIndicationType(indicationType));
7905 radioService[slotId]->checkReturnStatus(retStatus);
7907 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7914 int radio::subscriptionStatusChangedInd(int slotId,
7915 int indicationType, int token, RIL_Errno e, void *response,
7916 size_t responseLen) {
7917 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7918 if (response == NULL || responseLen != sizeof(int)) {
7919 RLOGE("subscriptionStatusChangedInd: invalid response");
7922 bool activate = ((int32_t *) response)[0];
7924 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
7926 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
7927 convertIntToRadioIndicationType(indicationType), activate);
7928 radioService[slotId]->checkReturnStatus(retStatus);
7930 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
7937 int radio::srvccStateNotifyInd(int slotId,
7938 int indicationType, int token, RIL_Errno e, void *response,
7939 size_t responseLen) {
7940 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7941 if (response == NULL || responseLen != sizeof(int)) {
7942 RLOGE("srvccStateNotifyInd: invalid response");
7945 int32_t state = ((int32_t *) response)[0];
7947 RLOGD("srvccStateNotifyInd: rat %d", state);
7949 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
7950 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
7951 radioService[slotId]->checkReturnStatus(retStatus);
7953 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7959 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
7960 hidl_vec<HardwareConfig>& records) {
7961 int num = responseLen / sizeof(RIL_HardwareConfig);
7962 records.resize(num);
7964 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
7965 for (int i = 0; i < num; i++) {
7966 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
7967 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
7968 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
7969 switch (rilHardwareConfig[i].type) {
7970 case RIL_HARDWARE_CONFIG_MODEM: {
7971 records[i].modem.resize(1);
7972 records[i].sim.resize(0);
7973 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
7974 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
7975 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
7976 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
7977 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
7981 case RIL_HARDWARE_CONFIG_SIM: {
7982 records[i].sim.resize(1);
7983 records[i].modem.resize(0);
7984 records[i].sim[0].modemUuid =
7985 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
7992 int radio::hardwareConfigChangedInd(int slotId,
7993 int indicationType, int token, RIL_Errno e, void *response,
7994 size_t responseLen) {
7995 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7996 if ((response == NULL && responseLen != 0)
7997 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
7998 RLOGE("hardwareConfigChangedInd: invalid response");
8002 hidl_vec<HardwareConfig> configs;
8003 convertRilHardwareConfigListToHal(response, responseLen, configs);
8006 RLOGD("hardwareConfigChangedInd");
8008 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
8009 convertIntToRadioIndicationType(indicationType), configs);
8010 radioService[slotId]->checkReturnStatus(retStatus);
8012 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
8019 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
8020 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
8021 rc.session = rilRadioCapability->session;
8022 rc.phase = (V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
8023 rc.raf = rilRadioCapability->rat;
8024 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
8025 rc.status = (V1_0::RadioCapabilityStatus) rilRadioCapability->status;
8028 int radio::radioCapabilityIndicationInd(int slotId,
8029 int indicationType, int token, RIL_Errno e, void *response,
8030 size_t responseLen) {
8031 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8032 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
8033 RLOGE("radioCapabilityIndicationInd: invalid response");
8037 RadioCapability rc = {};
8038 convertRilRadioCapabilityToHal(response, responseLen, rc);
8041 RLOGD("radioCapabilityIndicationInd");
8043 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
8044 convertIntToRadioIndicationType(indicationType), rc);
8045 radioService[slotId]->checkReturnStatus(retStatus);
8047 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
8054 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
8055 if ((reqType == SS_INTERROGATION) &&
8056 (serType == SS_CFU ||
8057 serType == SS_CF_BUSY ||
8058 serType == SS_CF_NO_REPLY ||
8059 serType == SS_CF_NOT_REACHABLE ||
8060 serType == SS_CF_ALL ||
8061 serType == SS_CF_ALL_CONDITIONAL)) {
8067 int radio::onSupplementaryServiceIndicationInd(int slotId,
8068 int indicationType, int token, RIL_Errno e,
8069 void *response, size_t responseLen) {
8070 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8071 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
8072 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
8076 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
8077 StkCcUnsolSsResult ss = {};
8078 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
8079 ss.requestType = (SsRequestType) rilSsResponse->requestType;
8080 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
8081 ss.serviceClass = rilSsResponse->serviceClass;
8082 ss.result = (RadioError) rilSsResponse->result;
8084 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
8086 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
8087 rilSsResponse->cfData.numValidIndexes);
8089 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
8090 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
8091 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
8092 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
8095 ss.cfData.resize(1);
8096 ss.ssInfo.resize(0);
8098 /* number of call info's */
8099 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
8101 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
8102 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
8103 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
8105 cfInfo->status = (CallForwardInfoStatus) cf.status;
8106 cfInfo->reason = cf.reason;
8107 cfInfo->serviceClass = cf.serviceClass;
8108 cfInfo->toa = cf.toa;
8109 cfInfo->number = convertCharPtrToHidlString(cf.number);
8110 cfInfo->timeSeconds = cf.timeSeconds;
8112 RLOGD("onSupplementaryServiceIndicationInd: "
8113 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
8114 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
8118 ss.ssInfo.resize(1);
8119 ss.cfData.resize(0);
8122 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
8123 for (int i = 0; i < SS_INFO_MAX; i++) {
8125 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
8126 rilSsResponse->ssInfo[i]);
8128 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
8133 RLOGD("onSupplementaryServiceIndicationInd");
8135 Return<void> retStatus = radioService[slotId]->mRadioIndication->
8136 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
8138 radioService[slotId]->checkReturnStatus(retStatus);
8140 RLOGE("onSupplementaryServiceIndicationInd: "
8141 "radioService[%d]->mRadioIndication == NULL", slotId);
8147 int radio::stkCallControlAlphaNotifyInd(int slotId,
8148 int indicationType, int token, RIL_Errno e, void *response,
8149 size_t responseLen) {
8150 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8151 if (response == NULL || responseLen == 0) {
8152 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
8156 RLOGD("stkCallControlAlphaNotifyInd");
8158 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
8159 convertIntToRadioIndicationType(indicationType),
8160 convertCharPtrToHidlString((char *) response));
8161 radioService[slotId]->checkReturnStatus(retStatus);
8163 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
8170 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
8171 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
8172 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
8173 lce.confidenceLevel = rilLceDataInfo->confidence_level;
8174 lce.lceSuspended = rilLceDataInfo->lce_suspended;
8177 int radio::lceDataInd(int slotId,
8178 int indicationType, int token, RIL_Errno e, void *response,
8179 size_t responseLen) {
8180 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8181 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
8182 RLOGE("lceDataInd: invalid response");
8186 LceDataInfo lce = {};
8187 convertRilLceDataInfoToHal(response, responseLen, lce);
8189 RLOGD("lceDataInd");
8191 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
8192 convertIntToRadioIndicationType(indicationType), lce);
8193 radioService[slotId]->checkReturnStatus(retStatus);
8195 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8201 int radio::pcoDataInd(int slotId,
8202 int indicationType, int token, RIL_Errno e, void *response,
8203 size_t responseLen) {
8204 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8205 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8206 RLOGE("pcoDataInd: invalid response");
8210 PcoDataInfo pco = {};
8211 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8212 pco.cid = rilPcoData->cid;
8213 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8214 pco.pcoId = rilPcoData->pco_id;
8215 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8218 RLOGD("pcoDataInd");
8220 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8221 convertIntToRadioIndicationType(indicationType), pco);
8222 radioService[slotId]->checkReturnStatus(retStatus);
8224 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8230 int radio::modemResetInd(int slotId,
8231 int indicationType, int token, RIL_Errno e, void *response,
8232 size_t responseLen) {
8233 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8234 if (response == NULL || responseLen == 0) {
8235 RLOGE("modemResetInd: invalid response");
8239 RLOGD("modemResetInd");
8241 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8242 convertIntToRadioIndicationType(indicationType),
8243 convertCharPtrToHidlString((char *) response));
8244 radioService[slotId]->checkReturnStatus(retStatus);
8246 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8252 int radio::networkScanResultInd(int slotId,
8253 int indicationType, int token, RIL_Errno e, void *response,
8254 size_t responseLen) {
8256 RLOGD("networkScanResultInd");
8258 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8259 if (response == NULL || responseLen == 0) {
8260 RLOGE("networkScanResultInd: invalid response");
8263 RLOGD("networkScanResultInd");
8266 RLOGD("networkScanResultInd");
8269 RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
8271 V1_1::NetworkScanResult result;
8272 result.status = (V1_1::ScanStatus) networkScanResult->status;
8273 result.error = (RadioError) e;
8274 convertRilCellInfoListToHal(
8275 networkScanResult->network_infos,
8276 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
8277 result.networkInfos);
8279 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->networkScanResult(
8280 convertIntToRadioIndicationType(indicationType), result);
8281 radioService[slotId]->checkReturnStatus(retStatus);
8283 RLOGE("networkScanResultInd: radioService[%d]->mRadioIndicationV1_1 == NULL", slotId);
8288 int radio::carrierInfoForImsiEncryption(int slotId,
8289 int indicationType, int token, RIL_Errno e, void *response,
8290 size_t responseLen) {
8291 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8292 if (response == NULL || responseLen == 0) {
8293 RLOGE("carrierInfoForImsiEncryption: invalid response");
8296 RLOGD("carrierInfoForImsiEncryption");
8297 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->
8298 carrierInfoForImsiEncryption(convertIntToRadioIndicationType(indicationType));
8299 radioService[slotId]->checkReturnStatus(retStatus);
8301 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndicationV1_1 == NULL",
8308 int radio::oemHookRawInd(int slotId,
8309 int indicationType, int token, RIL_Errno e, void *response,
8310 size_t responseLen) {
8311 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8312 if (response == NULL || responseLen == 0) {
8313 RLOGE("oemHookRawInd: invalid response");
8317 hidl_vec<uint8_t> data;
8318 data.setToExternal((uint8_t *) response, responseLen);
8320 RLOGD("oemHookRawInd");
8322 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8323 convertIntToRadioIndicationType(indicationType), data);
8324 checkReturnStatus(slotId, retStatus, false);
8326 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8332 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8333 using namespace android::hardware;
8335 const char *serviceNames[] = {
8336 android::RIL_getServiceName()
8337 #if (SIM_COUNT >= 2)
8339 #if (SIM_COUNT >= 3)
8341 #if (SIM_COUNT >= 4)
8348 #if (SIM_COUNT >= 2)
8349 simCount = SIM_COUNT;
8352 configureRpcThreadpool(1, true /* callerWillJoin */);
8353 for (int i = 0; i < simCount; i++) {
8354 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8355 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8358 radioService[i] = new RadioImpl;
8359 radioService[i]->mSlotId = i;
8360 oemHookService[i] = new OemHookImpl;
8361 oemHookService[i]->mSlotId = i;
8362 RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
8364 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8365 status = oemHookService[i]->registerAsService(serviceNames[i]);
8367 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8371 s_vendorFunctions = callbacks;
8372 s_commands = commands;
8375 void rilc_thread_pool() {
8376 joinRpcThreadpool();
8379 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8380 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8382 #if (SIM_COUNT >= 2)
8383 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8384 #if (SIM_COUNT >= 3)
8385 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8386 #if (SIM_COUNT >= 4)
8387 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8392 return radioServiceRwlockPtr;