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 <telephony/ril.h>
29 #include <telephony/ril_mnc.h>
30 #include <ril_service.h>
31 #include <hidl/HidlTransportSupport.h>
32 #include <utils/SystemClock.h>
35 #define INVALID_HEX_CHAR 16
37 using namespace android::hardware::radio;
38 using namespace android::hardware::radio::V1_0;
39 using namespace android::hardware::radio::deprecated::V1_0;
40 using ::android::hardware::configureRpcThreadpool;
41 using ::android::hardware::joinRpcThreadpool;
42 using ::android::hardware::Return;
43 using ::android::hardware::hidl_string;
44 using ::android::hardware::hidl_vec;
45 using ::android::hardware::hidl_array;
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 #ifdef OEM_HOOK_DISABLED
66 constexpr bool kOemHookEnabled = false;
68 constexpr bool kOemHookEnabled = true;
71 RIL_RadioFunctions *s_vendorFunctions = NULL;
72 static CommandInfo *s_commands;
78 sp<RadioImpl> radioService[SIM_COUNT];
79 sp<OemHookImpl> oemHookService[SIM_COUNT];
80 int64_t nitzTimeReceived[SIM_COUNT];
81 // counter used for synchronization. It is incremented every time response callbacks are updated.
82 volatile int32_t mCounterRadio[SIM_COUNT];
83 volatile int32_t mCounterOemHook[SIM_COUNT];
85 sp<RadioImpl> radioService[1];
86 sp<OemHookImpl> oemHookService[1];
87 int64_t nitzTimeReceived[1];
88 // counter used for synchronization. It is incremented every time response callbacks are updated.
89 volatile int32_t mCounterRadio[1];
90 volatile int32_t mCounterOemHook[1];
93 static pthread_rwlock_t radioServiceRwlock = PTHREAD_RWLOCK_INITIALIZER;
96 static pthread_rwlock_t radioServiceRwlock2 = PTHREAD_RWLOCK_INITIALIZER;
98 static pthread_rwlock_t radioServiceRwlock3 = PTHREAD_RWLOCK_INITIALIZER;
100 static pthread_rwlock_t radioServiceRwlock4 = PTHREAD_RWLOCK_INITIALIZER;
105 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
106 hidl_vec<HardwareConfig>& records);
108 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc);
110 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce);
112 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
113 SignalStrength& signalStrength);
115 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
116 SetupDataCallResult& dcResult);
118 void convertRilDataCallListToHal(void *response, size_t responseLen,
119 hidl_vec<SetupDataCallResult>& dcResultList);
121 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records);
123 struct RadioImpl : public V1_1::IRadio {
125 sp<IRadioResponse> mRadioResponse;
126 sp<IRadioIndication> mRadioIndication;
127 sp<V1_1::IRadioResponse> mRadioResponseV1_1;
128 sp<V1_1::IRadioIndication> mRadioIndicationV1_1;
130 Return<void> setResponseFunctions(
131 const ::android::sp<IRadioResponse>& radioResponse,
132 const ::android::sp<IRadioIndication>& radioIndication);
134 Return<void> getIccCardStatus(int32_t serial);
136 Return<void> supplyIccPinForApp(int32_t serial, const hidl_string& pin,
137 const hidl_string& aid);
139 Return<void> supplyIccPukForApp(int32_t serial, const hidl_string& puk,
140 const hidl_string& pin, const hidl_string& aid);
142 Return<void> supplyIccPin2ForApp(int32_t serial,
143 const hidl_string& pin2,
144 const hidl_string& aid);
146 Return<void> supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
147 const hidl_string& pin2, const hidl_string& aid);
149 Return<void> changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
150 const hidl_string& newPin, const hidl_string& aid);
152 Return<void> changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
153 const hidl_string& newPin2, const hidl_string& aid);
155 Return<void> supplyNetworkDepersonalization(int32_t serial, const hidl_string& netPin);
157 Return<void> getCurrentCalls(int32_t serial);
159 Return<void> dial(int32_t serial, const Dial& dialInfo);
161 Return<void> getImsiForApp(int32_t serial,
162 const ::android::hardware::hidl_string& aid);
164 Return<void> hangup(int32_t serial, int32_t gsmIndex);
166 Return<void> hangupWaitingOrBackground(int32_t serial);
168 Return<void> hangupForegroundResumeBackground(int32_t serial);
170 Return<void> switchWaitingOrHoldingAndActive(int32_t serial);
172 Return<void> conference(int32_t serial);
174 Return<void> rejectCall(int32_t serial);
176 Return<void> getLastCallFailCause(int32_t serial);
178 Return<void> getSignalStrength(int32_t serial);
180 Return<void> getVoiceRegistrationState(int32_t serial);
182 Return<void> getDataRegistrationState(int32_t serial);
184 Return<void> getOperator(int32_t serial);
186 Return<void> setRadioPower(int32_t serial, bool on);
188 Return<void> sendDtmf(int32_t serial,
189 const ::android::hardware::hidl_string& s);
191 Return<void> sendSms(int32_t serial, const GsmSmsMessage& message);
193 Return<void> sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message);
195 Return<void> setupDataCall(int32_t serial,
196 RadioTechnology radioTechnology,
197 const DataProfileInfo& profileInfo,
202 Return<void> iccIOForApp(int32_t serial,
205 Return<void> sendUssd(int32_t serial,
206 const ::android::hardware::hidl_string& ussd);
208 Return<void> cancelPendingUssd(int32_t serial);
210 Return<void> getClir(int32_t serial);
212 Return<void> setClir(int32_t serial, int32_t status);
214 Return<void> getCallForwardStatus(int32_t serial,
215 const CallForwardInfo& callInfo);
217 Return<void> setCallForward(int32_t serial,
218 const CallForwardInfo& callInfo);
220 Return<void> getCallWaiting(int32_t serial, int32_t serviceClass);
222 Return<void> setCallWaiting(int32_t serial, bool enable, int32_t serviceClass);
224 Return<void> acknowledgeLastIncomingGsmSms(int32_t serial,
225 bool success, SmsAcknowledgeFailCause cause);
227 Return<void> acceptCall(int32_t serial);
229 Return<void> deactivateDataCall(int32_t serial,
230 int32_t cid, bool reasonRadioShutDown);
232 Return<void> getFacilityLockForApp(int32_t serial,
233 const ::android::hardware::hidl_string& facility,
234 const ::android::hardware::hidl_string& password,
235 int32_t serviceClass,
236 const ::android::hardware::hidl_string& appId);
238 Return<void> setFacilityLockForApp(int32_t serial,
239 const ::android::hardware::hidl_string& facility,
241 const ::android::hardware::hidl_string& password,
242 int32_t serviceClass,
243 const ::android::hardware::hidl_string& appId);
245 Return<void> setBarringPassword(int32_t serial,
246 const ::android::hardware::hidl_string& facility,
247 const ::android::hardware::hidl_string& oldPassword,
248 const ::android::hardware::hidl_string& newPassword);
250 Return<void> getNetworkSelectionMode(int32_t serial);
252 Return<void> setNetworkSelectionModeAutomatic(int32_t serial);
254 Return<void> setNetworkSelectionModeManual(int32_t serial,
255 const ::android::hardware::hidl_string& operatorNumeric);
257 Return<void> getAvailableNetworks(int32_t serial);
259 Return<void> startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request);
261 Return<void> stopNetworkScan(int32_t serial);
263 Return<void> startDtmf(int32_t serial,
264 const ::android::hardware::hidl_string& s);
266 Return<void> stopDtmf(int32_t serial);
268 Return<void> getBasebandVersion(int32_t serial);
270 Return<void> separateConnection(int32_t serial, int32_t gsmIndex);
272 Return<void> setMute(int32_t serial, bool enable);
274 Return<void> getMute(int32_t serial);
276 Return<void> getClip(int32_t serial);
278 Return<void> getDataCallList(int32_t serial);
280 Return<void> setSuppServiceNotifications(int32_t serial, bool enable);
282 Return<void> writeSmsToSim(int32_t serial,
283 const SmsWriteArgs& smsWriteArgs);
285 Return<void> deleteSmsOnSim(int32_t serial, int32_t index);
287 Return<void> setBandMode(int32_t serial, RadioBandMode mode);
289 Return<void> getAvailableBandModes(int32_t serial);
291 Return<void> sendEnvelope(int32_t serial,
292 const ::android::hardware::hidl_string& command);
294 Return<void> sendTerminalResponseToSim(int32_t serial,
295 const ::android::hardware::hidl_string& commandResponse);
297 Return<void> handleStkCallSetupRequestFromSim(int32_t serial, bool accept);
299 Return<void> explicitCallTransfer(int32_t serial);
301 Return<void> setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType);
303 Return<void> getPreferredNetworkType(int32_t serial);
305 Return<void> getNeighboringCids(int32_t serial);
307 Return<void> setLocationUpdates(int32_t serial, bool enable);
309 Return<void> setCdmaSubscriptionSource(int32_t serial,
310 CdmaSubscriptionSource cdmaSub);
312 Return<void> setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type);
314 Return<void> getCdmaRoamingPreference(int32_t serial);
316 Return<void> setTTYMode(int32_t serial, TtyMode mode);
318 Return<void> getTTYMode(int32_t serial);
320 Return<void> setPreferredVoicePrivacy(int32_t serial, bool enable);
322 Return<void> getPreferredVoicePrivacy(int32_t serial);
324 Return<void> sendCDMAFeatureCode(int32_t serial,
325 const ::android::hardware::hidl_string& featureCode);
327 Return<void> sendBurstDtmf(int32_t serial,
328 const ::android::hardware::hidl_string& dtmf,
332 Return<void> sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms);
334 Return<void> acknowledgeLastIncomingCdmaSms(int32_t serial,
335 const CdmaSmsAck& smsAck);
337 Return<void> getGsmBroadcastConfig(int32_t serial);
339 Return<void> setGsmBroadcastConfig(int32_t serial,
340 const hidl_vec<GsmBroadcastSmsConfigInfo>& configInfo);
342 Return<void> setGsmBroadcastActivation(int32_t serial, bool activate);
344 Return<void> getCdmaBroadcastConfig(int32_t serial);
346 Return<void> setCdmaBroadcastConfig(int32_t serial,
347 const hidl_vec<CdmaBroadcastSmsConfigInfo>& configInfo);
349 Return<void> setCdmaBroadcastActivation(int32_t serial, bool activate);
351 Return<void> getCDMASubscription(int32_t serial);
353 Return<void> writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms);
355 Return<void> deleteSmsOnRuim(int32_t serial, int32_t index);
357 Return<void> getDeviceIdentity(int32_t serial);
359 Return<void> exitEmergencyCallbackMode(int32_t serial);
361 Return<void> getSmscAddress(int32_t serial);
363 Return<void> setSmscAddress(int32_t serial,
364 const ::android::hardware::hidl_string& smsc);
366 Return<void> reportSmsMemoryStatus(int32_t serial, bool available);
368 Return<void> reportStkServiceIsRunning(int32_t serial);
370 Return<void> getCdmaSubscriptionSource(int32_t serial);
372 Return<void> requestIsimAuthentication(int32_t serial,
373 const ::android::hardware::hidl_string& challenge);
375 Return<void> acknowledgeIncomingGsmSmsWithPdu(int32_t serial,
377 const ::android::hardware::hidl_string& ackPdu);
379 Return<void> sendEnvelopeWithStatus(int32_t serial,
380 const ::android::hardware::hidl_string& contents);
382 Return<void> getVoiceRadioTechnology(int32_t serial);
384 Return<void> getCellInfoList(int32_t serial);
386 Return<void> setCellInfoListRate(int32_t serial, int32_t rate);
388 Return<void> setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
389 bool modemCognitive, bool isRoaming);
391 Return<void> getImsRegistrationState(int32_t serial);
393 Return<void> sendImsSms(int32_t serial, const ImsSmsMessage& message);
395 Return<void> iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message);
397 Return<void> iccOpenLogicalChannel(int32_t serial,
398 const ::android::hardware::hidl_string& aid, int32_t p2);
400 Return<void> iccCloseLogicalChannel(int32_t serial, int32_t channelId);
402 Return<void> iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message);
404 Return<void> nvReadItem(int32_t serial, NvItem itemId);
406 Return<void> nvWriteItem(int32_t serial, const NvWriteItem& item);
408 Return<void> nvWriteCdmaPrl(int32_t serial,
409 const ::android::hardware::hidl_vec<uint8_t>& prl);
411 Return<void> nvResetConfig(int32_t serial, ResetNvType resetType);
413 Return<void> setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub);
415 Return<void> setDataAllowed(int32_t serial, bool allow);
417 Return<void> getHardwareConfig(int32_t serial);
419 Return<void> requestIccSimAuthentication(int32_t serial,
421 const ::android::hardware::hidl_string& authData,
422 const ::android::hardware::hidl_string& aid);
424 Return<void> setDataProfile(int32_t serial,
425 const ::android::hardware::hidl_vec<DataProfileInfo>& profiles, bool isRoaming);
427 Return<void> requestShutdown(int32_t serial);
429 Return<void> getRadioCapability(int32_t serial);
431 Return<void> setRadioCapability(int32_t serial, const RadioCapability& rc);
433 Return<void> startLceService(int32_t serial, int32_t reportInterval, bool pullMode);
435 Return<void> stopLceService(int32_t serial);
437 Return<void> pullLceData(int32_t serial);
439 Return<void> getModemActivityInfo(int32_t serial);
441 Return<void> setAllowedCarriers(int32_t serial,
443 const CarrierRestrictions& carriers);
445 Return<void> getAllowedCarriers(int32_t serial);
447 Return<void> sendDeviceState(int32_t serial, DeviceStateType deviceStateType, bool state);
449 Return<void> setIndicationFilter(int32_t serial, int32_t indicationFilter);
451 Return<void> startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive);
453 Return<void> stopKeepalive(int32_t serial, int32_t sessionHandle);
455 Return<void> setSimCardPower(int32_t serial, bool powerUp);
456 Return<void> setSimCardPower_1_1(int32_t serial,
457 const V1_1::CardPowerState state);
459 Return<void> responseAcknowledgement();
461 Return<void> setCarrierInfoForImsiEncryption(int32_t serial,
462 const V1_1::ImsiEncryptionInfo& message);
464 void checkReturnStatus(Return<void>& ret);
467 struct OemHookImpl : public IOemHook {
469 sp<IOemHookResponse> mOemHookResponse;
470 sp<IOemHookIndication> mOemHookIndication;
472 Return<void> setResponseFunctions(
473 const ::android::sp<IOemHookResponse>& oemHookResponse,
474 const ::android::sp<IOemHookIndication>& oemHookIndication);
476 Return<void> sendRequestRaw(int32_t serial,
477 const ::android::hardware::hidl_vec<uint8_t>& data);
479 Return<void> sendRequestStrings(int32_t serial,
480 const ::android::hardware::hidl_vec<::android::hardware::hidl_string>& data);
483 void memsetAndFreeStrings(int numPointers, ...) {
485 va_start(ap, numPointers);
486 for (int i = 0; i < numPointers; i++) {
487 char *ptr = va_arg(ap, char *);
490 #define MAX_STRING_LENGTH 4096
491 memset(ptr, 0, strnlen(ptr, MAX_STRING_LENGTH));
499 void sendErrorResponse(RequestInfo *pRI, RIL_Errno err) {
500 pRI->pCI->responseFunction((int) pRI->socket_id,
501 (int) RadioResponseType::SOLICITED, pRI->token, err, NULL, 0);
505 * Copies over src to dest. If memory allocation fails, responseFunction() is called for the
506 * request with error RIL_E_NO_MEMORY.
507 * Returns true on success, and false on failure.
509 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI, bool allowEmpty) {
510 size_t len = src.size();
511 if (len == 0 && !allowEmpty) {
515 *dest = (char *) calloc(len + 1, sizeof(char));
517 RLOGE("Memory allocation failed for request %s", requestToString(pRI->pCI->requestNumber));
518 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
521 strncpy(*dest, src.c_str(), len + 1);
525 bool copyHidlStringToRil(char **dest, const hidl_string &src, RequestInfo *pRI) {
526 return copyHidlStringToRil(dest, src, pRI, false);
529 hidl_string convertCharPtrToHidlString(const char *ptr) {
532 // TODO: replace this with strnlen
533 ret.setToExternal(ptr, strlen(ptr));
538 bool dispatchVoid(int serial, int slotId, int request) {
539 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
543 CALL_ONREQUEST(request, NULL, 0, pRI, slotId);
547 bool dispatchString(int serial, int slotId, int request, const char * str) {
548 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
554 if (!copyHidlStringToRil(&pString, str, pRI)) {
558 CALL_ONREQUEST(request, pString, sizeof(char *), pRI, slotId);
560 memsetAndFreeStrings(1, pString);
564 bool dispatchStrings(int serial, int slotId, int request, bool allowEmpty, int countStrings, ...) {
565 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
571 pStrings = (char **)calloc(countStrings, sizeof(char *));
572 if (pStrings == NULL) {
573 RLOGE("Memory allocation failed for request %s", requestToString(request));
574 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
578 va_start(ap, countStrings);
579 for (int i = 0; i < countStrings; i++) {
580 const char* str = va_arg(ap, const char *);
581 if (!copyHidlStringToRil(&pStrings[i], hidl_string(str), pRI, allowEmpty)) {
583 for (int j = 0; j < i; j++) {
584 memsetAndFreeStrings(1, pStrings[j]);
592 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
594 if (pStrings != NULL) {
595 for (int i = 0 ; i < countStrings ; i++) {
596 memsetAndFreeStrings(1, pStrings[i]);
600 memset(pStrings, 0, countStrings * sizeof(char *));
607 bool dispatchStrings(int serial, int slotId, int request, const hidl_vec<hidl_string>& data) {
608 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
613 int countStrings = data.size();
615 pStrings = (char **)calloc(countStrings, sizeof(char *));
616 if (pStrings == NULL) {
617 RLOGE("Memory allocation failed for request %s", requestToString(request));
618 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
622 for (int i = 0; i < countStrings; i++) {
623 if (!copyHidlStringToRil(&pStrings[i], data[i], pRI)) {
624 for (int j = 0; j < i; j++) {
625 memsetAndFreeStrings(1, pStrings[j]);
632 CALL_ONREQUEST(request, pStrings, countStrings * sizeof(char *), pRI, slotId);
634 if (pStrings != NULL) {
635 for (int i = 0 ; i < countStrings ; i++) {
636 memsetAndFreeStrings(1, pStrings[i]);
640 memset(pStrings, 0, countStrings * sizeof(char *));
647 bool dispatchInts(int serial, int slotId, int request, int countInts, ...) {
648 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
653 int *pInts = (int *)calloc(countInts, sizeof(int));
656 RLOGE("Memory allocation failed for request %s", requestToString(request));
657 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
661 va_start(ap, countInts);
662 for (int i = 0; i < countInts; i++) {
663 pInts[i] = va_arg(ap, int);
667 CALL_ONREQUEST(request, pInts, countInts * sizeof(int), pRI, slotId);
671 memset(pInts, 0, countInts * sizeof(int));
678 bool dispatchCallForwardStatus(int serial, int slotId, int request,
679 const CallForwardInfo& callInfo) {
680 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
685 RIL_CallForwardInfo cf;
686 cf.status = (int) callInfo.status;
687 cf.reason = callInfo.reason;
688 cf.serviceClass = callInfo.serviceClass;
689 cf.toa = callInfo.toa;
690 cf.timeSeconds = callInfo.timeSeconds;
692 if (!copyHidlStringToRil(&cf.number, callInfo.number, pRI)) {
696 CALL_ONREQUEST(request, &cf, sizeof(cf), pRI, slotId);
698 memsetAndFreeStrings(1, cf.number);
703 bool dispatchRaw(int serial, int slotId, int request, const hidl_vec<uint8_t>& rawBytes) {
704 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
709 const uint8_t *uData = rawBytes.data();
711 CALL_ONREQUEST(request, (void *) uData, rawBytes.size(), pRI, slotId);
716 bool dispatchIccApdu(int serial, int slotId, int request, const SimApdu& message) {
717 RequestInfo *pRI = android::addRequestToList(serial, slotId, request);
722 RIL_SIM_APDU apdu = {};
724 apdu.sessionid = message.sessionId;
725 apdu.cla = message.cla;
726 apdu.instruction = message.instruction;
727 apdu.p1 = message.p1;
728 apdu.p2 = message.p2;
729 apdu.p3 = message.p3;
731 if (!copyHidlStringToRil(&apdu.data, message.data, pRI)) {
735 CALL_ONREQUEST(request, &apdu, sizeof(apdu), pRI, slotId);
737 memsetAndFreeStrings(1, apdu.data);
742 void checkReturnStatus(int32_t slotId, Return<void>& ret, bool isRadioService) {
743 if (ret.isOk() == false) {
744 RLOGE("checkReturnStatus: unable to call response/indication callback");
745 // Remote process hosting the callbacks must be dead. Reset the callback objects;
746 // there's no other recovery to be done here. When the client process is back up, it will
747 // call setResponseFunctions()
749 // Caller should already hold rdlock, release that first
750 // note the current counter to avoid overwriting updates made by another thread before
751 // write lock is acquired.
752 int counter = isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId];
753 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(slotId);
754 int ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
758 ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
761 // make sure the counter value has not changed
762 if (counter == (isRadioService ? mCounterRadio[slotId] : mCounterOemHook[slotId])) {
763 if (isRadioService) {
764 radioService[slotId]->mRadioResponse = NULL;
765 radioService[slotId]->mRadioIndication = NULL;
766 radioService[slotId]->mRadioResponseV1_1 = NULL;
767 radioService[slotId]->mRadioIndicationV1_1 = NULL;
769 oemHookService[slotId]->mOemHookResponse = NULL;
770 oemHookService[slotId]->mOemHookIndication = NULL;
772 isRadioService ? mCounterRadio[slotId]++ : mCounterOemHook[slotId]++;
774 RLOGE("checkReturnStatus: not resetting responseFunctions as they likely "
775 "got updated on another thread");
779 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
783 ret = pthread_rwlock_rdlock(radioServiceRwlockPtr);
788 void RadioImpl::checkReturnStatus(Return<void>& ret) {
789 ::checkReturnStatus(mSlotId, ret, true);
792 Return<void> RadioImpl::setResponseFunctions(
793 const ::android::sp<IRadioResponse>& radioResponseParam,
794 const ::android::sp<IRadioIndication>& radioIndicationParam) {
795 RLOGD("setResponseFunctions");
797 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
798 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
801 mRadioResponse = radioResponseParam;
802 mRadioIndication = radioIndicationParam;
803 mRadioResponseV1_1 = V1_1::IRadioResponse::castFrom(mRadioResponse).withDefault(nullptr);
804 mRadioIndicationV1_1 = V1_1::IRadioIndication::castFrom(mRadioIndication).withDefault(nullptr);
805 if (mRadioResponseV1_1 == nullptr || mRadioIndicationV1_1 == nullptr) {
806 mRadioResponseV1_1 = nullptr;
807 mRadioIndicationV1_1 = nullptr;
810 mCounterRadio[mSlotId]++;
812 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
815 // client is connected. Send initial indications.
816 android::onNewCommandConnect((RIL_SOCKET_ID) mSlotId);
821 Return<void> RadioImpl::getIccCardStatus(int32_t serial) {
823 RLOGD("getIccCardStatus: serial %d", serial);
825 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SIM_STATUS);
829 Return<void> RadioImpl::supplyIccPinForApp(int32_t serial, const hidl_string& pin,
830 const hidl_string& aid) {
832 RLOGD("supplyIccPinForApp: serial %d", serial);
834 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN, true,
835 2, pin.c_str(), aid.c_str());
839 Return<void> RadioImpl::supplyIccPukForApp(int32_t serial, const hidl_string& puk,
840 const hidl_string& pin, const hidl_string& aid) {
842 RLOGD("supplyIccPukForApp: serial %d", serial);
844 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK, true,
845 3, puk.c_str(), pin.c_str(), aid.c_str());
849 Return<void> RadioImpl::supplyIccPin2ForApp(int32_t serial, const hidl_string& pin2,
850 const hidl_string& aid) {
852 RLOGD("supplyIccPin2ForApp: serial %d", serial);
854 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PIN2, true,
855 2, pin2.c_str(), aid.c_str());
859 Return<void> RadioImpl::supplyIccPuk2ForApp(int32_t serial, const hidl_string& puk2,
860 const hidl_string& pin2, const hidl_string& aid) {
862 RLOGD("supplyIccPuk2ForApp: serial %d", serial);
864 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_SIM_PUK2, true,
865 3, puk2.c_str(), pin2.c_str(), aid.c_str());
869 Return<void> RadioImpl::changeIccPinForApp(int32_t serial, const hidl_string& oldPin,
870 const hidl_string& newPin, const hidl_string& aid) {
872 RLOGD("changeIccPinForApp: serial %d", serial);
874 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN, true,
875 3, oldPin.c_str(), newPin.c_str(), aid.c_str());
879 Return<void> RadioImpl::changeIccPin2ForApp(int32_t serial, const hidl_string& oldPin2,
880 const hidl_string& newPin2, const hidl_string& aid) {
882 RLOGD("changeIccPin2ForApp: serial %d", serial);
884 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_SIM_PIN2, true,
885 3, oldPin2.c_str(), newPin2.c_str(), aid.c_str());
889 Return<void> RadioImpl::supplyNetworkDepersonalization(int32_t serial,
890 const hidl_string& netPin) {
892 RLOGD("supplyNetworkDepersonalization: serial %d", serial);
894 dispatchStrings(serial, mSlotId, RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, true,
899 Return<void> RadioImpl::getCurrentCalls(int32_t serial) {
901 RLOGD("getCurrentCalls: serial %d", serial);
903 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CURRENT_CALLS);
907 Return<void> RadioImpl::dial(int32_t serial, const Dial& dialInfo) {
909 RLOGD("dial: serial %d", serial);
911 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_DIAL);
916 RIL_UUS_Info uusInfo = {};
917 int32_t sizeOfDial = sizeof(dial);
919 if (!copyHidlStringToRil(&dial.address, dialInfo.address, pRI)) {
922 dial.clir = (int) dialInfo.clir;
924 if (dialInfo.uusInfo.size() != 0) {
925 uusInfo.uusType = (RIL_UUS_Type) dialInfo.uusInfo[0].uusType;
926 uusInfo.uusDcs = (RIL_UUS_DCS) dialInfo.uusInfo[0].uusDcs;
928 if (dialInfo.uusInfo[0].uusData.size() == 0) {
929 uusInfo.uusData = NULL;
930 uusInfo.uusLength = 0;
932 if (!copyHidlStringToRil(&uusInfo.uusData, dialInfo.uusInfo[0].uusData, pRI)) {
933 memsetAndFreeStrings(1, dial.address);
936 uusInfo.uusLength = dialInfo.uusInfo[0].uusData.size();
939 dial.uusInfo = &uusInfo;
942 CALL_ONREQUEST(RIL_REQUEST_DIAL, &dial, sizeOfDial, pRI, mSlotId);
944 memsetAndFreeStrings(2, dial.address, uusInfo.uusData);
949 Return<void> RadioImpl::getImsiForApp(int32_t serial, const hidl_string& aid) {
951 RLOGD("getImsiForApp: serial %d", serial);
953 dispatchStrings(serial, mSlotId, RIL_REQUEST_GET_IMSI, false,
958 Return<void> RadioImpl::hangup(int32_t serial, int32_t gsmIndex) {
960 RLOGD("hangup: serial %d", serial);
962 dispatchInts(serial, mSlotId, RIL_REQUEST_HANGUP, 1, gsmIndex);
966 Return<void> RadioImpl::hangupWaitingOrBackground(int32_t serial) {
968 RLOGD("hangupWaitingOrBackground: serial %d", serial);
970 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND);
974 Return<void> RadioImpl::hangupForegroundResumeBackground(int32_t serial) {
976 RLOGD("hangupForegroundResumeBackground: serial %d", serial);
978 dispatchVoid(serial, mSlotId, RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND);
982 Return<void> RadioImpl::switchWaitingOrHoldingAndActive(int32_t serial) {
984 RLOGD("switchWaitingOrHoldingAndActive: serial %d", serial);
986 dispatchVoid(serial, mSlotId, RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE);
990 Return<void> RadioImpl::conference(int32_t serial) {
992 RLOGD("conference: serial %d", serial);
994 dispatchVoid(serial, mSlotId, RIL_REQUEST_CONFERENCE);
998 Return<void> RadioImpl::rejectCall(int32_t serial) {
1000 RLOGD("rejectCall: serial %d", serial);
1002 dispatchVoid(serial, mSlotId, RIL_REQUEST_UDUB);
1006 Return<void> RadioImpl::getLastCallFailCause(int32_t serial) {
1008 RLOGD("getLastCallFailCause: serial %d", serial);
1010 dispatchVoid(serial, mSlotId, RIL_REQUEST_LAST_CALL_FAIL_CAUSE);
1014 Return<void> RadioImpl::getSignalStrength(int32_t serial) {
1016 RLOGD("getSignalStrength: serial %d", serial);
1018 dispatchVoid(serial, mSlotId, RIL_REQUEST_SIGNAL_STRENGTH);
1022 Return<void> RadioImpl::getVoiceRegistrationState(int32_t serial) {
1024 RLOGD("getVoiceRegistrationState: serial %d", serial);
1026 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_REGISTRATION_STATE);
1030 Return<void> RadioImpl::getDataRegistrationState(int32_t serial) {
1032 RLOGD("getDataRegistrationState: serial %d", serial);
1034 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_REGISTRATION_STATE);
1038 Return<void> RadioImpl::getOperator(int32_t serial) {
1040 RLOGD("getOperator: serial %d", serial);
1042 dispatchVoid(serial, mSlotId, RIL_REQUEST_OPERATOR);
1046 Return<void> RadioImpl::setRadioPower(int32_t serial, bool on) {
1047 RLOGD("setRadioPower: serial %d on %d", serial, on);
1048 dispatchInts(serial, mSlotId, RIL_REQUEST_RADIO_POWER, 1, BOOL_TO_INT(on));
1052 Return<void> RadioImpl::sendDtmf(int32_t serial, const hidl_string& s) {
1054 RLOGD("sendDtmf: serial %d", serial);
1056 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF, s.c_str());
1060 Return<void> RadioImpl::sendSms(int32_t serial, const GsmSmsMessage& message) {
1062 RLOGD("sendSms: serial %d", serial);
1064 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS, false,
1065 2, message.smscPdu.c_str(), message.pdu.c_str());
1069 Return<void> RadioImpl::sendSMSExpectMore(int32_t serial, const GsmSmsMessage& message) {
1071 RLOGD("sendSMSExpectMore: serial %d", serial);
1073 dispatchStrings(serial, mSlotId, RIL_REQUEST_SEND_SMS_EXPECT_MORE, false,
1074 2, message.smscPdu.c_str(), message.pdu.c_str());
1078 static bool convertMvnoTypeToString(MvnoType type, char *&str) {
1080 case MvnoType::IMSI:
1081 str = (char *)"imsi";
1084 str = (char *)"gid";
1087 str = (char *)"spn";
1089 case MvnoType::NONE:
1096 Return<void> RadioImpl::setupDataCall(int32_t serial, RadioTechnology radioTechnology,
1097 const DataProfileInfo& dataProfileInfo, bool modemCognitive,
1098 bool roamingAllowed, bool isRoaming) {
1101 RLOGD("setupDataCall: serial %d", serial);
1104 if (s_vendorFunctions->version >= 4 && s_vendorFunctions->version <= 14) {
1105 const hidl_string &protocol =
1106 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
1107 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 7,
1108 std::to_string((int) radioTechnology + 2).c_str(),
1109 std::to_string((int) dataProfileInfo.profileId).c_str(),
1110 dataProfileInfo.apn.c_str(),
1111 dataProfileInfo.user.c_str(),
1112 dataProfileInfo.password.c_str(),
1113 std::to_string((int) dataProfileInfo.authType).c_str(),
1115 } else if (s_vendorFunctions->version >= 15) {
1116 char *mvnoTypeStr = NULL;
1117 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, mvnoTypeStr)) {
1118 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1119 RIL_REQUEST_SETUP_DATA_CALL);
1121 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1125 dispatchStrings(serial, mSlotId, RIL_REQUEST_SETUP_DATA_CALL, true, 15,
1126 std::to_string((int) radioTechnology + 2).c_str(),
1127 std::to_string((int) dataProfileInfo.profileId).c_str(),
1128 dataProfileInfo.apn.c_str(),
1129 dataProfileInfo.user.c_str(),
1130 dataProfileInfo.password.c_str(),
1131 std::to_string((int) dataProfileInfo.authType).c_str(),
1132 dataProfileInfo.protocol.c_str(),
1133 dataProfileInfo.roamingProtocol.c_str(),
1134 std::to_string(dataProfileInfo.supportedApnTypesBitmap).c_str(),
1135 std::to_string(dataProfileInfo.bearerBitmap).c_str(),
1136 modemCognitive ? "1" : "0",
1137 std::to_string(dataProfileInfo.mtu).c_str(),
1139 dataProfileInfo.mvnoMatchData.c_str(),
1140 roamingAllowed ? "1" : "0");
1142 RLOGE("Unsupported RIL version %d, min version expected 4", s_vendorFunctions->version);
1143 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1144 RIL_REQUEST_SETUP_DATA_CALL);
1146 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
1152 Return<void> RadioImpl::iccIOForApp(int32_t serial, const IccIo& iccIo) {
1154 RLOGD("iccIOForApp: serial %d", serial);
1156 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_IO);
1161 RIL_SIM_IO_v6 rilIccIo = {};
1162 rilIccIo.command = iccIo.command;
1163 rilIccIo.fileid = iccIo.fileId;
1164 if (!copyHidlStringToRil(&rilIccIo.path, iccIo.path, pRI)) {
1168 rilIccIo.p1 = iccIo.p1;
1169 rilIccIo.p2 = iccIo.p2;
1170 rilIccIo.p3 = iccIo.p3;
1172 if (!copyHidlStringToRil(&rilIccIo.data, iccIo.data, pRI)) {
1173 memsetAndFreeStrings(1, rilIccIo.path);
1177 if (!copyHidlStringToRil(&rilIccIo.pin2, iccIo.pin2, pRI)) {
1178 memsetAndFreeStrings(2, rilIccIo.path, rilIccIo.data);
1182 if (!copyHidlStringToRil(&rilIccIo.aidPtr, iccIo.aid, pRI)) {
1183 memsetAndFreeStrings(3, rilIccIo.path, rilIccIo.data, rilIccIo.pin2);
1187 CALL_ONREQUEST(RIL_REQUEST_SIM_IO, &rilIccIo, sizeof(rilIccIo), pRI, mSlotId);
1189 memsetAndFreeStrings(4, rilIccIo.path, rilIccIo.data, rilIccIo.pin2, rilIccIo.aidPtr);
1194 Return<void> RadioImpl::sendUssd(int32_t serial, const hidl_string& ussd) {
1196 RLOGD("sendUssd: serial %d", serial);
1198 dispatchString(serial, mSlotId, RIL_REQUEST_SEND_USSD, ussd.c_str());
1202 Return<void> RadioImpl::cancelPendingUssd(int32_t serial) {
1204 RLOGD("cancelPendingUssd: serial %d", serial);
1206 dispatchVoid(serial, mSlotId, RIL_REQUEST_CANCEL_USSD);
1210 Return<void> RadioImpl::getClir(int32_t serial) {
1212 RLOGD("getClir: serial %d", serial);
1214 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CLIR);
1218 Return<void> RadioImpl::setClir(int32_t serial, int32_t status) {
1220 RLOGD("setClir: serial %d", serial);
1222 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CLIR, 1, status);
1226 Return<void> RadioImpl::getCallForwardStatus(int32_t serial, const CallForwardInfo& callInfo) {
1228 RLOGD("getCallForwardStatus: serial %d", serial);
1230 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
1235 Return<void> RadioImpl::setCallForward(int32_t serial, const CallForwardInfo& callInfo) {
1237 RLOGD("setCallForward: serial %d", serial);
1239 dispatchCallForwardStatus(serial, mSlotId, RIL_REQUEST_SET_CALL_FORWARD,
1244 Return<void> RadioImpl::getCallWaiting(int32_t serial, int32_t serviceClass) {
1246 RLOGD("getCallWaiting: serial %d", serial);
1248 dispatchInts(serial, mSlotId, RIL_REQUEST_QUERY_CALL_WAITING, 1, serviceClass);
1252 Return<void> RadioImpl::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
1254 RLOGD("setCallWaiting: serial %d", serial);
1256 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_CALL_WAITING, 2, BOOL_TO_INT(enable),
1261 Return<void> RadioImpl::acknowledgeLastIncomingGsmSms(int32_t serial,
1262 bool success, SmsAcknowledgeFailCause cause) {
1264 RLOGD("acknowledgeLastIncomingGsmSms: serial %d", serial);
1266 dispatchInts(serial, mSlotId, RIL_REQUEST_SMS_ACKNOWLEDGE, 2, BOOL_TO_INT(success),
1271 Return<void> RadioImpl::acceptCall(int32_t serial) {
1273 RLOGD("acceptCall: serial %d", serial);
1275 dispatchVoid(serial, mSlotId, RIL_REQUEST_ANSWER);
1279 Return<void> RadioImpl::deactivateDataCall(int32_t serial,
1280 int32_t cid, bool reasonRadioShutDown) {
1282 RLOGD("deactivateDataCall: serial %d", serial);
1284 dispatchStrings(serial, mSlotId, RIL_REQUEST_DEACTIVATE_DATA_CALL, false,
1285 2, (std::to_string(cid)).c_str(), reasonRadioShutDown ? "1" : "0");
1289 Return<void> RadioImpl::getFacilityLockForApp(int32_t serial, const hidl_string& facility,
1290 const hidl_string& password, int32_t serviceClass,
1291 const hidl_string& appId) {
1293 RLOGD("getFacilityLockForApp: serial %d", serial);
1295 dispatchStrings(serial, mSlotId, RIL_REQUEST_QUERY_FACILITY_LOCK, true,
1296 4, facility.c_str(), password.c_str(),
1297 (std::to_string(serviceClass)).c_str(), appId.c_str());
1301 Return<void> RadioImpl::setFacilityLockForApp(int32_t serial, const hidl_string& facility,
1302 bool lockState, const hidl_string& password,
1303 int32_t serviceClass, const hidl_string& appId) {
1305 RLOGD("setFacilityLockForApp: serial %d", serial);
1307 dispatchStrings(serial, mSlotId, RIL_REQUEST_SET_FACILITY_LOCK, true,
1308 5, facility.c_str(), lockState ? "1" : "0", password.c_str(),
1309 (std::to_string(serviceClass)).c_str(), appId.c_str() );
1313 Return<void> RadioImpl::setBarringPassword(int32_t serial, const hidl_string& facility,
1314 const hidl_string& oldPassword,
1315 const hidl_string& newPassword) {
1317 RLOGD("setBarringPassword: serial %d", serial);
1319 dispatchStrings(serial, mSlotId, RIL_REQUEST_CHANGE_BARRING_PASSWORD, true,
1320 3, facility.c_str(), oldPassword.c_str(), newPassword.c_str());
1324 Return<void> RadioImpl::getNetworkSelectionMode(int32_t serial) {
1326 RLOGD("getNetworkSelectionMode: serial %d", serial);
1328 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE);
1332 Return<void> RadioImpl::setNetworkSelectionModeAutomatic(int32_t serial) {
1334 RLOGD("setNetworkSelectionModeAutomatic: serial %d", serial);
1336 dispatchVoid(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC);
1340 Return<void> RadioImpl::setNetworkSelectionModeManual(int32_t serial,
1341 const hidl_string& operatorNumeric) {
1343 RLOGD("setNetworkSelectionModeManual: serial %d", serial);
1345 dispatchString(serial, mSlotId, RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
1346 operatorNumeric.c_str());
1350 Return<void> RadioImpl::getAvailableNetworks(int32_t serial) {
1352 RLOGD("getAvailableNetworks: serial %d", serial);
1354 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_NETWORKS);
1358 Return<void> RadioImpl::startNetworkScan(int32_t serial, const V1_1::NetworkScanRequest& request) {
1360 RLOGD("startNetworkScan: serial %d", serial);
1363 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_NETWORK_SCAN);
1368 if (request.specifiers.size() > MAX_RADIO_ACCESS_NETWORKS) {
1369 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1373 RIL_NetworkScanRequest scan_request = {};
1375 scan_request.type = (RIL_ScanType) request.type;
1376 scan_request.interval = request.interval;
1377 scan_request.specifiers_length = request.specifiers.size();
1378 for (size_t i = 0; i < request.specifiers.size(); ++i) {
1379 if (request.specifiers[i].geranBands.size() > MAX_BANDS ||
1380 request.specifiers[i].utranBands.size() > MAX_BANDS ||
1381 request.specifiers[i].eutranBands.size() > MAX_BANDS ||
1382 request.specifiers[i].channels.size() > MAX_CHANNELS) {
1383 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1386 const V1_1::RadioAccessSpecifier& ras_from =
1387 request.specifiers[i];
1388 RIL_RadioAccessSpecifier& ras_to = scan_request.specifiers[i];
1390 ras_to.radio_access_network = (RIL_RadioAccessNetworks) ras_from.radioAccessNetwork;
1391 ras_to.channels_length = ras_from.channels.size();
1393 std::copy(ras_from.channels.begin(), ras_from.channels.end(), ras_to.channels);
1394 const std::vector<uint32_t> * bands = nullptr;
1395 switch (request.specifiers[i].radioAccessNetwork) {
1396 case V1_1::RadioAccessNetworks::GERAN:
1397 ras_to.bands_length = ras_from.geranBands.size();
1398 bands = (std::vector<uint32_t> *) &ras_from.geranBands;
1400 case V1_1::RadioAccessNetworks::UTRAN:
1401 ras_to.bands_length = ras_from.utranBands.size();
1402 bands = (std::vector<uint32_t> *) &ras_from.utranBands;
1404 case V1_1::RadioAccessNetworks::EUTRAN:
1405 ras_to.bands_length = ras_from.eutranBands.size();
1406 bands = (std::vector<uint32_t> *) &ras_from.eutranBands;
1409 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
1412 // safe to copy to geran_bands because it's a union member
1413 for (size_t idx = 0; idx < ras_to.bands_length; ++idx) {
1414 ras_to.bands.geran_bands[idx] = (RIL_GeranBands) (*bands)[idx];
1418 CALL_ONREQUEST(RIL_REQUEST_START_NETWORK_SCAN, &scan_request, sizeof(scan_request), pRI,
1424 Return<void> RadioImpl::stopNetworkScan(int32_t serial) {
1426 RLOGD("stopNetworkScan: serial %d", serial);
1428 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_NETWORK_SCAN);
1432 Return<void> RadioImpl::startDtmf(int32_t serial, const hidl_string& s) {
1434 RLOGD("startDtmf: serial %d", serial);
1436 dispatchString(serial, mSlotId, RIL_REQUEST_DTMF_START,
1441 Return<void> RadioImpl::stopDtmf(int32_t serial) {
1443 RLOGD("stopDtmf: serial %d", serial);
1445 dispatchVoid(serial, mSlotId, RIL_REQUEST_DTMF_STOP);
1449 Return<void> RadioImpl::getBasebandVersion(int32_t serial) {
1451 RLOGD("getBasebandVersion: serial %d", serial);
1453 dispatchVoid(serial, mSlotId, RIL_REQUEST_BASEBAND_VERSION);
1457 Return<void> RadioImpl::separateConnection(int32_t serial, int32_t gsmIndex) {
1459 RLOGD("separateConnection: serial %d", serial);
1461 dispatchInts(serial, mSlotId, RIL_REQUEST_SEPARATE_CONNECTION, 1, gsmIndex);
1465 Return<void> RadioImpl::setMute(int32_t serial, bool enable) {
1467 RLOGD("setMute: serial %d", serial);
1469 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_MUTE, 1, BOOL_TO_INT(enable));
1473 Return<void> RadioImpl::getMute(int32_t serial) {
1475 RLOGD("getMute: serial %d", serial);
1477 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_MUTE);
1481 Return<void> RadioImpl::getClip(int32_t serial) {
1483 RLOGD("getClip: serial %d", serial);
1485 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_CLIP);
1489 Return<void> RadioImpl::getDataCallList(int32_t serial) {
1491 RLOGD("getDataCallList: serial %d", serial);
1493 dispatchVoid(serial, mSlotId, RIL_REQUEST_DATA_CALL_LIST);
1497 Return<void> RadioImpl::setSuppServiceNotifications(int32_t serial, bool enable) {
1499 RLOGD("setSuppServiceNotifications: serial %d", serial);
1501 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION, 1,
1502 BOOL_TO_INT(enable));
1506 Return<void> RadioImpl::writeSmsToSim(int32_t serial, const SmsWriteArgs& smsWriteArgs) {
1508 RLOGD("writeSmsToSim: serial %d", serial);
1510 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_WRITE_SMS_TO_SIM);
1515 RIL_SMS_WriteArgs args;
1516 args.status = (int) smsWriteArgs.status;
1518 if (!copyHidlStringToRil(&args.pdu, smsWriteArgs.pdu, pRI)) {
1522 if (!copyHidlStringToRil(&args.smsc, smsWriteArgs.smsc, pRI)) {
1523 memsetAndFreeStrings(1, args.pdu);
1527 CALL_ONREQUEST(RIL_REQUEST_WRITE_SMS_TO_SIM, &args, sizeof(args), pRI, mSlotId);
1529 memsetAndFreeStrings(2, args.smsc, args.pdu);
1534 Return<void> RadioImpl::deleteSmsOnSim(int32_t serial, int32_t index) {
1536 RLOGD("deleteSmsOnSim: serial %d", serial);
1538 dispatchInts(serial, mSlotId, RIL_REQUEST_DELETE_SMS_ON_SIM, 1, index);
1542 Return<void> RadioImpl::setBandMode(int32_t serial, RadioBandMode mode) {
1544 RLOGD("setBandMode: serial %d", serial);
1546 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_BAND_MODE, 1, mode);
1550 Return<void> RadioImpl::getAvailableBandModes(int32_t serial) {
1552 RLOGD("getAvailableBandModes: serial %d", serial);
1554 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
1558 Return<void> RadioImpl::sendEnvelope(int32_t serial, const hidl_string& command) {
1560 RLOGD("sendEnvelope: serial %d", serial);
1562 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
1567 Return<void> RadioImpl::sendTerminalResponseToSim(int32_t serial,
1568 const hidl_string& commandResponse) {
1570 RLOGD("sendTerminalResponseToSim: serial %d", serial);
1572 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
1573 commandResponse.c_str());
1577 Return<void> RadioImpl::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
1579 RLOGD("handleStkCallSetupRequestFromSim: serial %d", serial);
1581 dispatchInts(serial, mSlotId, RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM,
1582 1, BOOL_TO_INT(accept));
1586 Return<void> RadioImpl::explicitCallTransfer(int32_t serial) {
1588 RLOGD("explicitCallTransfer: serial %d", serial);
1590 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXPLICIT_CALL_TRANSFER);
1594 Return<void> RadioImpl::setPreferredNetworkType(int32_t serial, PreferredNetworkType nwType) {
1596 RLOGD("setPreferredNetworkType: serial %d", serial);
1598 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, 1, nwType);
1602 Return<void> RadioImpl::getPreferredNetworkType(int32_t serial) {
1604 RLOGD("getPreferredNetworkType: serial %d", serial);
1606 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE);
1610 Return<void> RadioImpl::getNeighboringCids(int32_t serial) {
1612 RLOGD("getNeighboringCids: serial %d", serial);
1614 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_NEIGHBORING_CELL_IDS);
1618 Return<void> RadioImpl::setLocationUpdates(int32_t serial, bool enable) {
1620 RLOGD("setLocationUpdates: serial %d", serial);
1622 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_LOCATION_UPDATES, 1, BOOL_TO_INT(enable));
1626 Return<void> RadioImpl::setCdmaSubscriptionSource(int32_t serial, CdmaSubscriptionSource cdmaSub) {
1628 RLOGD("setCdmaSubscriptionSource: serial %d", serial);
1630 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE, 1, cdmaSub);
1634 Return<void> RadioImpl::setCdmaRoamingPreference(int32_t serial, CdmaRoamingType type) {
1636 RLOGD("setCdmaRoamingPreference: serial %d", serial);
1638 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE, 1, type);
1642 Return<void> RadioImpl::getCdmaRoamingPreference(int32_t serial) {
1644 RLOGD("getCdmaRoamingPreference: serial %d", serial);
1646 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE);
1650 Return<void> RadioImpl::setTTYMode(int32_t serial, TtyMode mode) {
1652 RLOGD("setTTYMode: serial %d", serial);
1654 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_TTY_MODE, 1, mode);
1658 Return<void> RadioImpl::getTTYMode(int32_t serial) {
1660 RLOGD("getTTYMode: serial %d", serial);
1662 dispatchVoid(serial, mSlotId, RIL_REQUEST_QUERY_TTY_MODE);
1666 Return<void> RadioImpl::setPreferredVoicePrivacy(int32_t serial, bool enable) {
1668 RLOGD("setPreferredVoicePrivacy: serial %d", serial);
1670 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE,
1671 1, BOOL_TO_INT(enable));
1675 Return<void> RadioImpl::getPreferredVoicePrivacy(int32_t serial) {
1677 RLOGD("getPreferredVoicePrivacy: serial %d", serial);
1679 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
1683 Return<void> RadioImpl::sendCDMAFeatureCode(int32_t serial, const hidl_string& featureCode) {
1685 RLOGD("sendCDMAFeatureCode: serial %d", serial);
1687 dispatchString(serial, mSlotId, RIL_REQUEST_CDMA_FLASH,
1688 featureCode.c_str());
1692 Return<void> RadioImpl::sendBurstDtmf(int32_t serial, const hidl_string& dtmf, int32_t on,
1695 RLOGD("sendBurstDtmf: serial %d", serial);
1697 dispatchStrings(serial, mSlotId, RIL_REQUEST_CDMA_BURST_DTMF, false,
1698 3, dtmf.c_str(), (std::to_string(on)).c_str(),
1699 (std::to_string(off)).c_str());
1703 void constructCdmaSms(RIL_CDMA_SMS_Message &rcsm, const CdmaSmsMessage& sms) {
1704 rcsm.uTeleserviceID = sms.teleserviceId;
1705 rcsm.bIsServicePresent = BOOL_TO_INT(sms.isServicePresent);
1706 rcsm.uServicecategory = sms.serviceCategory;
1707 rcsm.sAddress.digit_mode = (RIL_CDMA_SMS_DigitMode) sms.address.digitMode;
1708 rcsm.sAddress.number_mode = (RIL_CDMA_SMS_NumberMode) sms.address.numberMode;
1709 rcsm.sAddress.number_type = (RIL_CDMA_SMS_NumberType) sms.address.numberType;
1710 rcsm.sAddress.number_plan = (RIL_CDMA_SMS_NumberPlan) sms.address.numberPlan;
1712 rcsm.sAddress.number_of_digits = sms.address.digits.size();
1713 int digitLimit= MIN((rcsm.sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
1714 for (int i = 0; i < digitLimit; i++) {
1715 rcsm.sAddress.digits[i] = sms.address.digits[i];
1718 rcsm.sSubAddress.subaddressType = (RIL_CDMA_SMS_SubaddressType) sms.subAddress.subaddressType;
1719 rcsm.sSubAddress.odd = BOOL_TO_INT(sms.subAddress.odd);
1721 rcsm.sSubAddress.number_of_digits = sms.subAddress.digits.size();
1722 digitLimit= MIN((rcsm.sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
1723 for (int i = 0; i < digitLimit; i++) {
1724 rcsm.sSubAddress.digits[i] = sms.subAddress.digits[i];
1727 rcsm.uBearerDataLen = sms.bearerData.size();
1728 digitLimit= MIN((rcsm.uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
1729 for (int i = 0; i < digitLimit; i++) {
1730 rcsm.aBearerData[i] = sms.bearerData[i];
1734 Return<void> RadioImpl::sendCdmaSms(int32_t serial, const CdmaSmsMessage& sms) {
1736 RLOGD("sendCdmaSms: serial %d", serial);
1738 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SEND_SMS);
1743 RIL_CDMA_SMS_Message rcsm = {};
1744 constructCdmaSms(rcsm, sms);
1746 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsm, sizeof(rcsm), pRI, mSlotId);
1750 Return<void> RadioImpl::acknowledgeLastIncomingCdmaSms(int32_t serial, const CdmaSmsAck& smsAck) {
1752 RLOGD("acknowledgeLastIncomingCdmaSms: serial %d", serial);
1754 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE);
1759 RIL_CDMA_SMS_Ack rcsa = {};
1761 rcsa.uErrorClass = (RIL_CDMA_SMS_ErrorClass) smsAck.errorClass;
1762 rcsa.uSMSCauseCode = smsAck.smsCauseCode;
1764 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsa, sizeof(rcsa), pRI, mSlotId);
1768 Return<void> RadioImpl::getGsmBroadcastConfig(int32_t serial) {
1770 RLOGD("getGsmBroadcastConfig: serial %d", serial);
1772 dispatchVoid(serial, mSlotId, RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG);
1776 Return<void> RadioImpl::setGsmBroadcastConfig(int32_t serial,
1777 const hidl_vec<GsmBroadcastSmsConfigInfo>&
1780 RLOGD("setGsmBroadcastConfig: serial %d", serial);
1782 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1783 RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG);
1788 int num = configInfo.size();
1789 RIL_GSM_BroadcastSmsConfigInfo gsmBci[num];
1790 RIL_GSM_BroadcastSmsConfigInfo *gsmBciPtrs[num];
1792 for (int i = 0 ; i < num ; i++ ) {
1793 gsmBciPtrs[i] = &gsmBci[i];
1794 gsmBci[i].fromServiceId = configInfo[i].fromServiceId;
1795 gsmBci[i].toServiceId = configInfo[i].toServiceId;
1796 gsmBci[i].fromCodeScheme = configInfo[i].fromCodeScheme;
1797 gsmBci[i].toCodeScheme = configInfo[i].toCodeScheme;
1798 gsmBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1801 CALL_ONREQUEST(pRI->pCI->requestNumber, gsmBciPtrs,
1802 num * sizeof(RIL_GSM_BroadcastSmsConfigInfo *), pRI, mSlotId);
1806 Return<void> RadioImpl::setGsmBroadcastActivation(int32_t serial, bool activate) {
1808 RLOGD("setGsmBroadcastActivation: serial %d", serial);
1810 dispatchInts(serial, mSlotId, RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
1811 1, BOOL_TO_INT(!activate));
1815 Return<void> RadioImpl::getCdmaBroadcastConfig(int32_t serial) {
1817 RLOGD("getCdmaBroadcastConfig: serial %d", serial);
1819 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_BROADCAST_SMS_CONFIG);
1823 Return<void> RadioImpl::setCdmaBroadcastConfig(int32_t serial,
1824 const hidl_vec<CdmaBroadcastSmsConfigInfo>&
1827 RLOGD("setCdmaBroadcastConfig: serial %d", serial);
1829 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1830 RIL_REQUEST_CDMA_SET_BROADCAST_SMS_CONFIG);
1835 int num = configInfo.size();
1836 RIL_CDMA_BroadcastSmsConfigInfo cdmaBci[num];
1837 RIL_CDMA_BroadcastSmsConfigInfo *cdmaBciPtrs[num];
1839 for (int i = 0 ; i < num ; i++ ) {
1840 cdmaBciPtrs[i] = &cdmaBci[i];
1841 cdmaBci[i].service_category = configInfo[i].serviceCategory;
1842 cdmaBci[i].language = configInfo[i].language;
1843 cdmaBci[i].selected = BOOL_TO_INT(configInfo[i].selected);
1846 CALL_ONREQUEST(pRI->pCI->requestNumber, cdmaBciPtrs,
1847 num * sizeof(RIL_CDMA_BroadcastSmsConfigInfo *), pRI, mSlotId);
1851 Return<void> RadioImpl::setCdmaBroadcastActivation(int32_t serial, bool activate) {
1853 RLOGD("setCdmaBroadcastActivation: serial %d", serial);
1855 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_SMS_BROADCAST_ACTIVATION,
1856 1, BOOL_TO_INT(!activate));
1860 Return<void> RadioImpl::getCDMASubscription(int32_t serial) {
1862 RLOGD("getCDMASubscription: serial %d", serial);
1864 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_SUBSCRIPTION);
1868 Return<void> RadioImpl::writeSmsToRuim(int32_t serial, const CdmaSmsWriteArgs& cdmaSms) {
1870 RLOGD("writeSmsToRuim: serial %d", serial);
1872 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
1873 RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM);
1878 RIL_CDMA_SMS_WriteArgs rcsw = {};
1879 rcsw.status = (int) cdmaSms.status;
1880 constructCdmaSms(rcsw.message, cdmaSms.message);
1882 CALL_ONREQUEST(pRI->pCI->requestNumber, &rcsw, sizeof(rcsw), pRI, mSlotId);
1886 Return<void> RadioImpl::deleteSmsOnRuim(int32_t serial, int32_t index) {
1888 RLOGD("deleteSmsOnRuim: serial %d", serial);
1890 dispatchInts(serial, mSlotId, RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM, 1, index);
1894 Return<void> RadioImpl::getDeviceIdentity(int32_t serial) {
1896 RLOGD("getDeviceIdentity: serial %d", serial);
1898 dispatchVoid(serial, mSlotId, RIL_REQUEST_DEVICE_IDENTITY);
1902 Return<void> RadioImpl::exitEmergencyCallbackMode(int32_t serial) {
1904 RLOGD("exitEmergencyCallbackMode: serial %d", serial);
1906 dispatchVoid(serial, mSlotId, RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE);
1910 Return<void> RadioImpl::getSmscAddress(int32_t serial) {
1912 RLOGD("getSmscAddress: serial %d", serial);
1914 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_SMSC_ADDRESS);
1918 Return<void> RadioImpl::setSmscAddress(int32_t serial, const hidl_string& smsc) {
1920 RLOGD("setSmscAddress: serial %d", serial);
1922 dispatchString(serial, mSlotId, RIL_REQUEST_SET_SMSC_ADDRESS,
1927 Return<void> RadioImpl::reportSmsMemoryStatus(int32_t serial, bool available) {
1929 RLOGD("reportSmsMemoryStatus: serial %d", serial);
1931 dispatchInts(serial, mSlotId, RIL_REQUEST_REPORT_SMS_MEMORY_STATUS, 1,
1932 BOOL_TO_INT(available));
1936 Return<void> RadioImpl::reportStkServiceIsRunning(int32_t serial) {
1938 RLOGD("reportStkServiceIsRunning: serial %d", serial);
1940 dispatchVoid(serial, mSlotId, RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
1944 Return<void> RadioImpl::getCdmaSubscriptionSource(int32_t serial) {
1946 RLOGD("getCdmaSubscriptionSource: serial %d", serial);
1948 dispatchVoid(serial, mSlotId, RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE);
1952 Return<void> RadioImpl::requestIsimAuthentication(int32_t serial, const hidl_string& challenge) {
1954 RLOGD("requestIsimAuthentication: serial %d", serial);
1956 dispatchString(serial, mSlotId, RIL_REQUEST_ISIM_AUTHENTICATION,
1961 Return<void> RadioImpl::acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
1962 const hidl_string& ackPdu) {
1964 RLOGD("acknowledgeIncomingGsmSmsWithPdu: serial %d", serial);
1966 dispatchStrings(serial, mSlotId, RIL_REQUEST_ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU, false,
1967 2, success ? "1" : "0", ackPdu.c_str());
1971 Return<void> RadioImpl::sendEnvelopeWithStatus(int32_t serial, const hidl_string& contents) {
1973 RLOGD("sendEnvelopeWithStatus: serial %d", serial);
1975 dispatchString(serial, mSlotId, RIL_REQUEST_STK_SEND_ENVELOPE_WITH_STATUS,
1980 Return<void> RadioImpl::getVoiceRadioTechnology(int32_t serial) {
1982 RLOGD("getVoiceRadioTechnology: serial %d", serial);
1984 dispatchVoid(serial, mSlotId, RIL_REQUEST_VOICE_RADIO_TECH);
1988 Return<void> RadioImpl::getCellInfoList(int32_t serial) {
1990 RLOGD("getCellInfoList: serial %d", serial);
1992 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CELL_INFO_LIST);
1996 Return<void> RadioImpl::setCellInfoListRate(int32_t serial, int32_t rate) {
1998 RLOGD("setCellInfoListRate: serial %d", serial);
2000 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE, 1, rate);
2004 Return<void> RadioImpl::setInitialAttachApn(int32_t serial, const DataProfileInfo& dataProfileInfo,
2005 bool modemCognitive, bool isRoaming) {
2007 RLOGD("setInitialAttachApn: serial %d", serial);
2009 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2010 RIL_REQUEST_SET_INITIAL_ATTACH_APN);
2015 if (s_vendorFunctions->version <= 14) {
2016 RIL_InitialAttachApn iaa = {};
2018 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2022 const hidl_string &protocol =
2023 (isRoaming ? dataProfileInfo.roamingProtocol : dataProfileInfo.protocol);
2025 if (!copyHidlStringToRil(&iaa.protocol, protocol, pRI)) {
2026 memsetAndFreeStrings(1, iaa.apn);
2029 iaa.authtype = (int) dataProfileInfo.authType;
2030 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2031 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2034 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2035 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.username);
2039 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2041 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.username, iaa.password);
2043 RIL_InitialAttachApn_v15 iaa = {};
2045 if (!copyHidlStringToRil(&iaa.apn, dataProfileInfo.apn, pRI, true)) {
2049 if (!copyHidlStringToRil(&iaa.protocol, dataProfileInfo.protocol, pRI)) {
2050 memsetAndFreeStrings(1, iaa.apn);
2053 if (!copyHidlStringToRil(&iaa.roamingProtocol, dataProfileInfo.roamingProtocol, pRI)) {
2054 memsetAndFreeStrings(2, iaa.apn, iaa.protocol);
2057 iaa.authtype = (int) dataProfileInfo.authType;
2058 if (!copyHidlStringToRil(&iaa.username, dataProfileInfo.user, pRI)) {
2059 memsetAndFreeStrings(3, iaa.apn, iaa.protocol, iaa.roamingProtocol);
2062 if (!copyHidlStringToRil(&iaa.password, dataProfileInfo.password, pRI)) {
2063 memsetAndFreeStrings(4, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username);
2066 iaa.supportedTypesBitmask = dataProfileInfo.supportedApnTypesBitmap;
2067 iaa.bearerBitmask = dataProfileInfo.bearerBitmap;
2068 iaa.modemCognitive = BOOL_TO_INT(modemCognitive);
2069 iaa.mtu = dataProfileInfo.mtu;
2071 if (!convertMvnoTypeToString(dataProfileInfo.mvnoType, iaa.mvnoType)) {
2072 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2073 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2078 if (!copyHidlStringToRil(&iaa.mvnoMatchData, dataProfileInfo.mvnoMatchData, pRI)) {
2079 memsetAndFreeStrings(5, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2084 CALL_ONREQUEST(RIL_REQUEST_SET_INITIAL_ATTACH_APN, &iaa, sizeof(iaa), pRI, mSlotId);
2086 memsetAndFreeStrings(6, iaa.apn, iaa.protocol, iaa.roamingProtocol, iaa.username,
2087 iaa.password, iaa.mvnoMatchData);
2093 Return<void> RadioImpl::getImsRegistrationState(int32_t serial) {
2095 RLOGD("getImsRegistrationState: serial %d", serial);
2097 dispatchVoid(serial, mSlotId, RIL_REQUEST_IMS_REGISTRATION_STATE);
2101 bool dispatchImsGsmSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2102 RIL_IMS_SMS_Message rism = {};
2104 int countStrings = 2;
2105 int dataLen = sizeof(char *) * countStrings;
2107 rism.tech = RADIO_TECH_3GPP;
2108 rism.retry = BOOL_TO_INT(message.retry);
2109 rism.messageRef = message.messageRef;
2111 if (message.gsmMessage.size() != 1) {
2112 RLOGE("dispatchImsGsmSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2113 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2117 pStrings = (char **)calloc(countStrings, sizeof(char *));
2118 if (pStrings == NULL) {
2119 RLOGE("dispatchImsGsmSms: Memory allocation failed for request %s",
2120 requestToString(pRI->pCI->requestNumber));
2121 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2125 if (!copyHidlStringToRil(&pStrings[0], message.gsmMessage[0].smscPdu, pRI)) {
2127 memset(pStrings, 0, dataLen);
2133 if (!copyHidlStringToRil(&pStrings[1], message.gsmMessage[0].pdu, pRI)) {
2134 memsetAndFreeStrings(1, pStrings[0]);
2136 memset(pStrings, 0, dataLen);
2142 rism.message.gsmMessage = pStrings;
2143 CALL_ONREQUEST(pRI->pCI->requestNumber, &rism, sizeof(RIL_RadioTechnologyFamily) +
2144 sizeof(uint8_t) + sizeof(int32_t) + dataLen, pRI, pRI->socket_id);
2146 for (int i = 0 ; i < countStrings ; i++) {
2147 memsetAndFreeStrings(1, pStrings[i]);
2151 memset(pStrings, 0, dataLen);
2159 RIL_IMS_SMS_Message imsSms;
2160 RIL_CDMA_SMS_Message cdmaSms;
2163 bool dispatchImsCdmaSms(const ImsSmsMessage& message, RequestInfo *pRI) {
2164 ImsCdmaSms temp = {};
2166 if (message.cdmaMessage.size() != 1) {
2167 RLOGE("dispatchImsCdmaSms: Invalid len %s", requestToString(pRI->pCI->requestNumber));
2168 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2172 temp.imsSms.tech = RADIO_TECH_3GPP2;
2173 temp.imsSms.retry = BOOL_TO_INT(message.retry);
2174 temp.imsSms.messageRef = message.messageRef;
2175 temp.imsSms.message.cdmaMessage = &temp.cdmaSms;
2177 constructCdmaSms(temp.cdmaSms, message.cdmaMessage[0]);
2179 // Vendor code expects payload length to include actual msg payload
2180 // (sizeof(RIL_CDMA_SMS_Message)) instead of (RIL_CDMA_SMS_Message *) + size of other fields in
2181 // RIL_IMS_SMS_Message
2182 int payloadLen = sizeof(RIL_RadioTechnologyFamily) + sizeof(uint8_t) + sizeof(int32_t)
2183 + sizeof(RIL_CDMA_SMS_Message);
2185 CALL_ONREQUEST(pRI->pCI->requestNumber, &temp.imsSms, payloadLen, pRI, pRI->socket_id);
2190 Return<void> RadioImpl::sendImsSms(int32_t serial, const ImsSmsMessage& message) {
2192 RLOGD("sendImsSms: serial %d", serial);
2194 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_IMS_SEND_SMS);
2199 RIL_RadioTechnologyFamily format = (RIL_RadioTechnologyFamily) message.tech;
2201 if (RADIO_TECH_3GPP == format) {
2202 dispatchImsGsmSms(message, pRI);
2203 } else if (RADIO_TECH_3GPP2 == format) {
2204 dispatchImsCdmaSms(message, pRI);
2206 RLOGE("sendImsSms: Invalid radio tech %s",
2207 requestToString(pRI->pCI->requestNumber));
2208 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2213 Return<void> RadioImpl::iccTransmitApduBasicChannel(int32_t serial, const SimApdu& message) {
2215 RLOGD("iccTransmitApduBasicChannel: serial %d", serial);
2217 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC, message);
2221 Return<void> RadioImpl::iccOpenLogicalChannel(int32_t serial, const hidl_string& aid, int32_t p2) {
2223 RLOGD("iccOpenLogicalChannel: serial %d", serial);
2225 if (s_vendorFunctions->version < 15) {
2226 dispatchString(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL, aid.c_str());
2228 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_OPEN_CHANNEL);
2233 RIL_OpenChannelParams params = {};
2237 if (!copyHidlStringToRil(¶ms.aidPtr, aid, pRI)) {
2241 CALL_ONREQUEST(pRI->pCI->requestNumber, ¶ms, sizeof(params), pRI, mSlotId);
2243 memsetAndFreeStrings(1, params.aidPtr);
2248 Return<void> RadioImpl::iccCloseLogicalChannel(int32_t serial, int32_t channelId) {
2250 RLOGD("iccCloseLogicalChannel: serial %d", serial);
2252 dispatchInts(serial, mSlotId, RIL_REQUEST_SIM_CLOSE_CHANNEL, 1, channelId);
2256 Return<void> RadioImpl::iccTransmitApduLogicalChannel(int32_t serial, const SimApdu& message) {
2258 RLOGD("iccTransmitApduLogicalChannel: serial %d", serial);
2260 dispatchIccApdu(serial, mSlotId, RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL, message);
2264 Return<void> RadioImpl::nvReadItem(int32_t serial, NvItem itemId) {
2266 RLOGD("nvReadItem: serial %d", serial);
2268 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_READ_ITEM);
2273 RIL_NV_ReadItem nvri = {};
2274 nvri.itemID = (RIL_NV_Item) itemId;
2276 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvri, sizeof(nvri), pRI, mSlotId);
2280 Return<void> RadioImpl::nvWriteItem(int32_t serial, const NvWriteItem& item) {
2282 RLOGD("nvWriteItem: serial %d", serial);
2284 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_NV_WRITE_ITEM);
2289 RIL_NV_WriteItem nvwi = {};
2291 nvwi.itemID = (RIL_NV_Item) item.itemId;
2293 if (!copyHidlStringToRil(&nvwi.value, item.value, pRI)) {
2297 CALL_ONREQUEST(pRI->pCI->requestNumber, &nvwi, sizeof(nvwi), pRI, mSlotId);
2299 memsetAndFreeStrings(1, nvwi.value);
2303 Return<void> RadioImpl::nvWriteCdmaPrl(int32_t serial, const hidl_vec<uint8_t>& prl) {
2305 RLOGD("nvWriteCdmaPrl: serial %d", serial);
2307 dispatchRaw(serial, mSlotId, RIL_REQUEST_NV_WRITE_CDMA_PRL, prl);
2311 Return<void> RadioImpl::nvResetConfig(int32_t serial, ResetNvType resetType) {
2312 int rilResetType = -1;
2314 RLOGD("nvResetConfig: serial %d", serial);
2316 /* Convert ResetNvType to RIL.h values
2317 * RIL_REQUEST_NV_RESET_CONFIG
2318 * 1 - reload all NV items
2319 * 2 - erase NV reset (SCRTN)
2320 * 3 - factory reset (RTN)
2323 case ResetNvType::RELOAD:
2326 case ResetNvType::ERASE:
2329 case ResetNvType::FACTORY_RESET:
2333 dispatchInts(serial, mSlotId, RIL_REQUEST_NV_RESET_CONFIG, 1, rilResetType);
2337 Return<void> RadioImpl::setUiccSubscription(int32_t serial, const SelectUiccSub& uiccSub) {
2339 RLOGD("setUiccSubscription: serial %d", serial);
2341 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2342 RIL_REQUEST_SET_UICC_SUBSCRIPTION);
2347 RIL_SelectUiccSub rilUiccSub = {};
2349 rilUiccSub.slot = uiccSub.slot;
2350 rilUiccSub.app_index = uiccSub.appIndex;
2351 rilUiccSub.sub_type = (RIL_SubscriptionType) uiccSub.subType;
2352 rilUiccSub.act_status = (RIL_UiccSubActStatus) uiccSub.actStatus;
2354 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilUiccSub, sizeof(rilUiccSub), pRI, mSlotId);
2358 Return<void> RadioImpl::setDataAllowed(int32_t serial, bool allow) {
2360 RLOGD("setDataAllowed: serial %d", serial);
2362 dispatchInts(serial, mSlotId, RIL_REQUEST_ALLOW_DATA, 1, BOOL_TO_INT(allow));
2366 Return<void> RadioImpl::getHardwareConfig(int32_t serial) {
2368 RLOGD("getHardwareConfig: serial %d", serial);
2370 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_HARDWARE_CONFIG);
2374 Return<void> RadioImpl::requestIccSimAuthentication(int32_t serial, int32_t authContext,
2375 const hidl_string& authData, const hidl_string& aid) {
2377 RLOGD("requestIccSimAuthentication: serial %d", serial);
2379 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SIM_AUTHENTICATION);
2384 RIL_SimAuthentication pf = {};
2386 pf.authContext = authContext;
2388 if (!copyHidlStringToRil(&pf.authData, authData, pRI)) {
2392 if (!copyHidlStringToRil(&pf.aid, aid, pRI)) {
2393 memsetAndFreeStrings(1, pf.authData);
2397 CALL_ONREQUEST(pRI->pCI->requestNumber, &pf, sizeof(pf), pRI, mSlotId);
2399 memsetAndFreeStrings(2, pf.authData, pf.aid);
2404 * @param numProfiles number of data profile
2405 * @param dataProfiles the pointer to the actual data profiles. The acceptable type is
2406 RIL_DataProfileInfo or RIL_DataProfileInfo_v15.
2407 * @param dataProfilePtrs the pointer to the pointers that point to each data profile structure
2408 * @param numfields number of string-type member in the data profile structure
2409 * @param ... the variadic parameters are pointers to each string-type member
2411 template <typename T>
2412 void freeSetDataProfileData(int numProfiles, T *dataProfiles, T **dataProfilePtrs,
2413 int numfields, ...) {
2415 va_start(args, numfields);
2417 // Iterate through each string-type field that need to be free.
2418 for (int i = 0; i < numfields; i++) {
2419 // Iterate through each data profile and free that specific string-type field.
2420 // The type 'char *T::*' is a type of pointer to a 'char *' member inside T structure.
2421 char *T::*ptr = va_arg(args, char *T::*);
2422 for (int j = 0; j < numProfiles; j++) {
2423 memsetAndFreeStrings(1, dataProfiles[j].*ptr);
2430 memset(dataProfiles, 0, numProfiles * sizeof(T));
2431 memset(dataProfilePtrs, 0, numProfiles * sizeof(T *));
2434 free(dataProfilePtrs);
2437 Return<void> RadioImpl::setDataProfile(int32_t serial, const hidl_vec<DataProfileInfo>& profiles,
2440 RLOGD("setDataProfile: serial %d", serial);
2442 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_DATA_PROFILE);
2447 size_t num = profiles.size();
2448 bool success = false;
2450 if (s_vendorFunctions->version <= 14) {
2452 RIL_DataProfileInfo *dataProfiles =
2453 (RIL_DataProfileInfo *) calloc(num, sizeof(RIL_DataProfileInfo));
2455 if (dataProfiles == NULL) {
2456 RLOGE("Memory allocation failed for request %s",
2457 requestToString(pRI->pCI->requestNumber));
2458 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2462 RIL_DataProfileInfo **dataProfilePtrs =
2463 (RIL_DataProfileInfo **) calloc(num, sizeof(RIL_DataProfileInfo *));
2464 if (dataProfilePtrs == NULL) {
2465 RLOGE("Memory allocation failed for request %s",
2466 requestToString(pRI->pCI->requestNumber));
2468 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2472 for (size_t i = 0; i < num; i++) {
2473 dataProfilePtrs[i] = &dataProfiles[i];
2475 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2477 const hidl_string &protocol =
2478 (isRoaming ? profiles[i].roamingProtocol : profiles[i].protocol);
2480 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, protocol, pRI, true)) {
2484 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2488 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2494 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2495 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2496 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2500 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2501 dataProfiles[i].authType = (int) profiles[i].authType;
2502 dataProfiles[i].type = (int) profiles[i].type;
2503 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2504 dataProfiles[i].maxConns = profiles[i].maxConns;
2505 dataProfiles[i].waitTime = profiles[i].waitTime;
2506 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2509 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2510 num * sizeof(RIL_DataProfileInfo *), pRI, mSlotId);
2512 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 4,
2513 &RIL_DataProfileInfo::apn, &RIL_DataProfileInfo::protocol,
2514 &RIL_DataProfileInfo::user, &RIL_DataProfileInfo::password);
2516 RIL_DataProfileInfo_v15 *dataProfiles =
2517 (RIL_DataProfileInfo_v15 *) calloc(num, sizeof(RIL_DataProfileInfo_v15));
2519 if (dataProfiles == NULL) {
2520 RLOGE("Memory allocation failed for request %s",
2521 requestToString(pRI->pCI->requestNumber));
2522 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2526 RIL_DataProfileInfo_v15 **dataProfilePtrs =
2527 (RIL_DataProfileInfo_v15 **) calloc(num, sizeof(RIL_DataProfileInfo_v15 *));
2528 if (dataProfilePtrs == NULL) {
2529 RLOGE("Memory allocation failed for request %s",
2530 requestToString(pRI->pCI->requestNumber));
2532 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2536 for (size_t i = 0; i < num; i++) {
2537 dataProfilePtrs[i] = &dataProfiles[i];
2539 success = copyHidlStringToRil(&dataProfiles[i].apn, profiles[i].apn, pRI, true);
2540 if (success && !copyHidlStringToRil(&dataProfiles[i].protocol, profiles[i].protocol,
2544 if (success && !copyHidlStringToRil(&dataProfiles[i].roamingProtocol,
2545 profiles[i].roamingProtocol, pRI, true)) {
2548 if (success && !copyHidlStringToRil(&dataProfiles[i].user, profiles[i].user, pRI,
2552 if (success && !copyHidlStringToRil(&dataProfiles[i].password, profiles[i].password,
2556 if (success && !copyHidlStringToRil(&dataProfiles[i].mvnoMatchData,
2557 profiles[i].mvnoMatchData, pRI, true)) {
2561 if (success && !convertMvnoTypeToString(profiles[i].mvnoType,
2562 dataProfiles[i].mvnoType)) {
2563 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2568 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2569 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2570 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2571 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2575 dataProfiles[i].profileId = (RIL_DataProfile) profiles[i].profileId;
2576 dataProfiles[i].authType = (int) profiles[i].authType;
2577 dataProfiles[i].type = (int) profiles[i].type;
2578 dataProfiles[i].maxConnsTime = profiles[i].maxConnsTime;
2579 dataProfiles[i].maxConns = profiles[i].maxConns;
2580 dataProfiles[i].waitTime = profiles[i].waitTime;
2581 dataProfiles[i].enabled = BOOL_TO_INT(profiles[i].enabled);
2582 dataProfiles[i].supportedTypesBitmask = profiles[i].supportedApnTypesBitmap;
2583 dataProfiles[i].bearerBitmask = profiles[i].bearerBitmap;
2584 dataProfiles[i].mtu = profiles[i].mtu;
2587 CALL_ONREQUEST(RIL_REQUEST_SET_DATA_PROFILE, dataProfilePtrs,
2588 num * sizeof(RIL_DataProfileInfo_v15 *), pRI, mSlotId);
2590 freeSetDataProfileData(num, dataProfiles, dataProfilePtrs, 6,
2591 &RIL_DataProfileInfo_v15::apn, &RIL_DataProfileInfo_v15::protocol,
2592 &RIL_DataProfileInfo_v15::roamingProtocol, &RIL_DataProfileInfo_v15::user,
2593 &RIL_DataProfileInfo_v15::password, &RIL_DataProfileInfo_v15::mvnoMatchData);
2599 Return<void> RadioImpl::requestShutdown(int32_t serial) {
2601 RLOGD("requestShutdown: serial %d", serial);
2603 dispatchVoid(serial, mSlotId, RIL_REQUEST_SHUTDOWN);
2607 Return<void> RadioImpl::getRadioCapability(int32_t serial) {
2609 RLOGD("getRadioCapability: serial %d", serial);
2611 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_RADIO_CAPABILITY);
2615 Return<void> RadioImpl::setRadioCapability(int32_t serial, const RadioCapability& rc) {
2617 RLOGD("setRadioCapability: serial %d", serial);
2619 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_SET_RADIO_CAPABILITY);
2624 RIL_RadioCapability rilRc = {};
2626 // TODO : set rilRc.version using HIDL version ?
2627 rilRc.session = rc.session;
2628 rilRc.phase = (int) rc.phase;
2629 rilRc.rat = (int) rc.raf;
2630 rilRc.status = (int) rc.status;
2631 strncpy(rilRc.logicalModemUuid, rc.logicalModemUuid.c_str(), MAX_UUID_LENGTH);
2633 CALL_ONREQUEST(pRI->pCI->requestNumber, &rilRc, sizeof(rilRc), pRI, mSlotId);
2638 Return<void> RadioImpl::startLceService(int32_t serial, int32_t reportInterval, bool pullMode) {
2640 RLOGD("startLceService: serial %d", serial);
2642 dispatchInts(serial, mSlotId, RIL_REQUEST_START_LCE, 2, reportInterval,
2643 BOOL_TO_INT(pullMode));
2647 Return<void> RadioImpl::stopLceService(int32_t serial) {
2649 RLOGD("stopLceService: serial %d", serial);
2651 dispatchVoid(serial, mSlotId, RIL_REQUEST_STOP_LCE);
2655 Return<void> RadioImpl::pullLceData(int32_t serial) {
2657 RLOGD("pullLceData: serial %d", serial);
2659 dispatchVoid(serial, mSlotId, RIL_REQUEST_PULL_LCEDATA);
2663 Return<void> RadioImpl::getModemActivityInfo(int32_t serial) {
2665 RLOGD("getModemActivityInfo: serial %d", serial);
2667 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_ACTIVITY_INFO);
2671 Return<void> RadioImpl::setAllowedCarriers(int32_t serial, bool allAllowed,
2672 const CarrierRestrictions& carriers) {
2674 RLOGD("setAllowedCarriers: serial %d", serial);
2676 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2677 RIL_REQUEST_SET_CARRIER_RESTRICTIONS);
2682 RIL_CarrierRestrictions cr = {};
2683 RIL_Carrier *allowedCarriers = NULL;
2684 RIL_Carrier *excludedCarriers = NULL;
2686 cr.len_allowed_carriers = carriers.allowedCarriers.size();
2687 allowedCarriers = (RIL_Carrier *)calloc(cr.len_allowed_carriers, sizeof(RIL_Carrier));
2688 if (allowedCarriers == NULL) {
2689 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2690 requestToString(pRI->pCI->requestNumber));
2691 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2694 cr.allowed_carriers = allowedCarriers;
2696 cr.len_excluded_carriers = carriers.excludedCarriers.size();
2697 excludedCarriers = (RIL_Carrier *)calloc(cr.len_excluded_carriers, sizeof(RIL_Carrier));
2698 if (excludedCarriers == NULL) {
2699 RLOGE("setAllowedCarriers: Memory allocation failed for request %s",
2700 requestToString(pRI->pCI->requestNumber));
2701 sendErrorResponse(pRI, RIL_E_NO_MEMORY);
2703 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2705 free(allowedCarriers);
2708 cr.excluded_carriers = excludedCarriers;
2710 for (int i = 0; i < cr.len_allowed_carriers; i++) {
2711 allowedCarriers[i].mcc = carriers.allowedCarriers[i].mcc.c_str();
2712 allowedCarriers[i].mnc = carriers.allowedCarriers[i].mnc.c_str();
2713 allowedCarriers[i].match_type = (RIL_CarrierMatchType) carriers.allowedCarriers[i].matchType;
2714 allowedCarriers[i].match_data = carriers.allowedCarriers[i].matchData.c_str();
2717 for (int i = 0; i < cr.len_excluded_carriers; i++) {
2718 excludedCarriers[i].mcc = carriers.excludedCarriers[i].mcc.c_str();
2719 excludedCarriers[i].mnc = carriers.excludedCarriers[i].mnc.c_str();
2720 excludedCarriers[i].match_type =
2721 (RIL_CarrierMatchType) carriers.excludedCarriers[i].matchType;
2722 excludedCarriers[i].match_data = carriers.excludedCarriers[i].matchData.c_str();
2725 CALL_ONREQUEST(pRI->pCI->requestNumber, &cr, sizeof(RIL_CarrierRestrictions), pRI, mSlotId);
2728 memset(allowedCarriers, 0, cr.len_allowed_carriers * sizeof(RIL_Carrier));
2729 memset(excludedCarriers, 0, cr.len_excluded_carriers * sizeof(RIL_Carrier));
2731 free(allowedCarriers);
2732 free(excludedCarriers);
2736 Return<void> RadioImpl::getAllowedCarriers(int32_t serial) {
2738 RLOGD("getAllowedCarriers: serial %d", serial);
2740 dispatchVoid(serial, mSlotId, RIL_REQUEST_GET_CARRIER_RESTRICTIONS);
2744 Return<void> RadioImpl::sendDeviceState(int32_t serial, DeviceStateType deviceStateType,
2747 RLOGD("sendDeviceState: serial %d", serial);
2749 if (s_vendorFunctions->version < 15) {
2750 if (deviceStateType == DeviceStateType::LOW_DATA_EXPECTED) {
2751 RLOGD("sendDeviceState: calling screen state %d", BOOL_TO_INT(!state));
2752 dispatchInts(serial, mSlotId, RIL_REQUEST_SCREEN_STATE, 1, BOOL_TO_INT(!state));
2754 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2755 RIL_REQUEST_SEND_DEVICE_STATE);
2756 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2760 dispatchInts(serial, mSlotId, RIL_REQUEST_SEND_DEVICE_STATE, 2, (int) deviceStateType,
2761 BOOL_TO_INT(state));
2765 Return<void> RadioImpl::setIndicationFilter(int32_t serial, int32_t indicationFilter) {
2767 RLOGD("setIndicationFilter: serial %d", serial);
2769 if (s_vendorFunctions->version < 15) {
2770 RequestInfo *pRI = android::addRequestToList(serial, mSlotId,
2771 RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER);
2772 sendErrorResponse(pRI, RIL_E_REQUEST_NOT_SUPPORTED);
2775 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_UNSOLICITED_RESPONSE_FILTER, 1, indicationFilter);
2779 Return<void> RadioImpl::setSimCardPower(int32_t serial, bool powerUp) {
2781 RLOGD("setSimCardPower: serial %d", serial);
2783 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, BOOL_TO_INT(powerUp));
2787 Return<void> RadioImpl::setSimCardPower_1_1(int32_t serial, const V1_1::CardPowerState state) {
2789 RLOGD("setSimCardPower_1_1: serial %d state %d", serial, state);
2791 dispatchInts(serial, mSlotId, RIL_REQUEST_SET_SIM_CARD_POWER, 1, state);
2795 Return<void> RadioImpl::setCarrierInfoForImsiEncryption(int32_t serial,
2796 const V1_1::ImsiEncryptionInfo& data) {
2798 RLOGD("setCarrierInfoForImsiEncryption: serial %d", serial);
2800 RequestInfo *pRI = android::addRequestToList(
2801 serial, mSlotId, RIL_REQUEST_SET_CARRIER_INFO_IMSI_ENCRYPTION);
2806 RIL_CarrierInfoForImsiEncryption imsiEncryption = {};
2808 if (!copyHidlStringToRil(&imsiEncryption.mnc, data.mnc, pRI)) {
2811 if (!copyHidlStringToRil(&imsiEncryption.mcc, data.mcc, pRI)) {
2812 memsetAndFreeStrings(1, imsiEncryption.mnc);
2815 if (!copyHidlStringToRil(&imsiEncryption.keyIdentifier, data.keyIdentifier, pRI)) {
2816 memsetAndFreeStrings(2, imsiEncryption.mnc, imsiEncryption.mcc);
2819 imsiEncryption.carrierKeyLength = data.carrierKey.size();
2820 imsiEncryption.carrierKey = new uint8_t[imsiEncryption.carrierKeyLength];
2821 memcpy(imsiEncryption.carrierKey, data.carrierKey.data(), imsiEncryption.carrierKeyLength);
2822 imsiEncryption.expirationTime = data.expirationTime;
2823 CALL_ONREQUEST(pRI->pCI->requestNumber, &imsiEncryption,
2824 sizeof(RIL_CarrierInfoForImsiEncryption), pRI, mSlotId);
2825 delete(imsiEncryption.carrierKey);
2829 Return<void> RadioImpl::startKeepalive(int32_t serial, const V1_1::KeepaliveRequest& keepalive) {
2831 RLOGD("%s(): %d", __FUNCTION__, serial);
2833 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_START_KEEPALIVE);
2838 RIL_KeepaliveRequest kaReq = {};
2840 kaReq.type = static_cast<RIL_KeepaliveType>(keepalive.type);
2841 switch(kaReq.type) {
2843 if (keepalive.sourceAddress.size() != 4 ||
2844 keepalive.destinationAddress.size() != 4) {
2845 RLOGE("Invalid address for keepalive!");
2846 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2851 if (keepalive.sourceAddress.size() != 16 ||
2852 keepalive.destinationAddress.size() != 16) {
2853 RLOGE("Invalid address for keepalive!");
2854 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2859 RLOGE("Unknown packet keepalive type!");
2860 sendErrorResponse(pRI, RIL_E_INVALID_ARGUMENTS);
2864 ::memcpy(kaReq.sourceAddress, keepalive.sourceAddress.data(), keepalive.sourceAddress.size());
2865 kaReq.sourcePort = keepalive.sourcePort;
2867 ::memcpy(kaReq.destinationAddress,
2868 keepalive.destinationAddress.data(), keepalive.destinationAddress.size());
2869 kaReq.destinationPort = keepalive.destinationPort;
2871 kaReq.maxKeepaliveIntervalMillis = keepalive.maxKeepaliveIntervalMillis;
2872 kaReq.cid = keepalive.cid; // This is the context ID of the data call
2874 CALL_ONREQUEST(pRI->pCI->requestNumber, &kaReq, sizeof(RIL_KeepaliveRequest), pRI, mSlotId);
2878 Return<void> RadioImpl::stopKeepalive(int32_t serial, int32_t sessionHandle) {
2880 RLOGD("%s(): %d", __FUNCTION__, serial);
2882 RequestInfo *pRI = android::addRequestToList(serial, mSlotId, RIL_REQUEST_STOP_KEEPALIVE);
2887 CALL_ONREQUEST(pRI->pCI->requestNumber, &sessionHandle, sizeof(uint32_t), pRI, mSlotId);
2891 Return<void> RadioImpl::responseAcknowledgement() {
2892 android::releaseWakeLock();
2896 Return<void> OemHookImpl::setResponseFunctions(
2897 const ::android::sp<IOemHookResponse>& oemHookResponseParam,
2898 const ::android::sp<IOemHookIndication>& oemHookIndicationParam) {
2900 RLOGD("OemHookImpl::setResponseFunctions");
2903 pthread_rwlock_t *radioServiceRwlockPtr = radio::getRadioServiceRwlock(mSlotId);
2904 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
2907 mOemHookResponse = oemHookResponseParam;
2908 mOemHookIndication = oemHookIndicationParam;
2909 mCounterOemHook[mSlotId]++;
2911 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
2917 Return<void> OemHookImpl::sendRequestRaw(int32_t serial, const hidl_vec<uint8_t>& data) {
2919 RLOGD("OemHookImpl::sendRequestRaw: serial %d", serial);
2921 dispatchRaw(serial, mSlotId, RIL_REQUEST_OEM_HOOK_RAW, data);
2925 Return<void> OemHookImpl::sendRequestStrings(int32_t serial,
2926 const hidl_vec<hidl_string>& data) {
2928 RLOGD("OemHookImpl::sendRequestStrings: serial %d", serial);
2930 dispatchStrings(serial, mSlotId, RIL_REQUEST_OEM_HOOK_STRINGS, data);
2934 /***************************************************************************************************
2935 * RESPONSE FUNCTIONS
2936 * Functions above are used for requests going from framework to vendor code. The ones below are
2937 * responses for those requests coming back from the vendor code.
2938 **************************************************************************************************/
2940 void radio::acknowledgeRequest(int slotId, int serial) {
2941 if (radioService[slotId]->mRadioResponse != NULL) {
2942 Return<void> retStatus = radioService[slotId]->mRadioResponse->acknowledgeRequest(serial);
2943 radioService[slotId]->checkReturnStatus(retStatus);
2945 RLOGE("acknowledgeRequest: radioService[%d]->mRadioResponse == NULL", slotId);
2949 void populateResponseInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
2951 responseInfo.serial = serial;
2952 switch (responseType) {
2953 case RESPONSE_SOLICITED:
2954 responseInfo.type = RadioResponseType::SOLICITED;
2956 case RESPONSE_SOLICITED_ACK_EXP:
2957 responseInfo.type = RadioResponseType::SOLICITED_ACK_EXP;
2960 responseInfo.error = (RadioError) e;
2963 int responseIntOrEmpty(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2964 void *response, size_t responseLen) {
2965 populateResponseInfo(responseInfo, serial, responseType, e);
2968 if (response == NULL && responseLen == 0) {
2969 // Earlier RILs did not send a response for some cases although the interface
2970 // expected an integer as response. Do not return error if response is empty. Instead
2971 // Return -1 in those cases to maintain backward compatibility.
2972 } else if (response == NULL || responseLen != sizeof(int)) {
2973 RLOGE("responseIntOrEmpty: Invalid response");
2974 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2976 int *p_int = (int *) response;
2982 int responseInt(RadioResponseInfo& responseInfo, int serial, int responseType, RIL_Errno e,
2983 void *response, size_t responseLen) {
2984 populateResponseInfo(responseInfo, serial, responseType, e);
2987 if (response == NULL || responseLen != sizeof(int)) {
2988 RLOGE("responseInt: Invalid response");
2989 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
2991 int *p_int = (int *) response;
2997 int radio::getIccCardStatusResponse(int slotId,
2998 int responseType, int serial, RIL_Errno e,
2999 void *response, size_t responseLen) {
3000 if (radioService[slotId]->mRadioResponse != NULL) {
3001 RadioResponseInfo responseInfo = {};
3002 populateResponseInfo(responseInfo, serial, responseType, e);
3003 CardStatus cardStatus = {};
3004 RIL_CardStatus_v6 *p_cur = ((RIL_CardStatus_v6 *) response);
3005 if (response == NULL || responseLen != sizeof(RIL_CardStatus_v6)
3006 || p_cur->gsm_umts_subscription_app_index >= p_cur->num_applications
3007 || p_cur->cdma_subscription_app_index >= p_cur->num_applications
3008 || p_cur->ims_subscription_app_index >= p_cur->num_applications) {
3009 RLOGE("getIccCardStatusResponse: Invalid response");
3010 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3012 cardStatus.cardState = (CardState) p_cur->card_state;
3013 cardStatus.universalPinState = (PinState) p_cur->universal_pin_state;
3014 cardStatus.gsmUmtsSubscriptionAppIndex = p_cur->gsm_umts_subscription_app_index;
3015 cardStatus.cdmaSubscriptionAppIndex = p_cur->cdma_subscription_app_index;
3016 cardStatus.imsSubscriptionAppIndex = p_cur->ims_subscription_app_index;
3018 RIL_AppStatus *rilAppStatus = p_cur->applications;
3019 cardStatus.applications.resize(p_cur->num_applications);
3020 AppStatus *appStatus = cardStatus.applications.data();
3022 RLOGD("getIccCardStatusResponse: num_applications %d", p_cur->num_applications);
3024 for (int i = 0; i < p_cur->num_applications; i++) {
3025 appStatus[i].appType = (AppType) rilAppStatus[i].app_type;
3026 appStatus[i].appState = (AppState) rilAppStatus[i].app_state;
3027 appStatus[i].persoSubstate = (PersoSubstate) rilAppStatus[i].perso_substate;
3028 appStatus[i].aidPtr = convertCharPtrToHidlString(rilAppStatus[i].aid_ptr);
3029 appStatus[i].appLabelPtr = convertCharPtrToHidlString(
3030 rilAppStatus[i].app_label_ptr);
3031 appStatus[i].pin1Replaced = rilAppStatus[i].pin1_replaced;
3032 appStatus[i].pin1 = (PinState) rilAppStatus[i].pin1;
3033 appStatus[i].pin2 = (PinState) rilAppStatus[i].pin2;
3037 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3038 getIccCardStatusResponse(responseInfo, cardStatus);
3039 radioService[slotId]->checkReturnStatus(retStatus);
3041 RLOGE("getIccCardStatusResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3047 int radio::supplyIccPinForAppResponse(int slotId,
3048 int responseType, int serial, RIL_Errno e,
3049 void *response, size_t responseLen) {
3051 RLOGD("supplyIccPinForAppResponse: serial %d", serial);
3054 if (radioService[slotId]->mRadioResponse != NULL) {
3055 RadioResponseInfo responseInfo = {};
3056 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3057 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3058 supplyIccPinForAppResponse(responseInfo, ret);
3059 RLOGE("supplyIccPinForAppResponse: amit ret %d", ret);
3060 radioService[slotId]->checkReturnStatus(retStatus);
3062 RLOGE("supplyIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3069 int radio::supplyIccPukForAppResponse(int slotId,
3070 int responseType, int serial, RIL_Errno e,
3071 void *response, size_t responseLen) {
3073 RLOGD("supplyIccPukForAppResponse: serial %d", serial);
3076 if (radioService[slotId]->mRadioResponse != NULL) {
3077 RadioResponseInfo responseInfo = {};
3078 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3079 Return<void> retStatus = radioService[slotId]->mRadioResponse->supplyIccPukForAppResponse(
3081 radioService[slotId]->checkReturnStatus(retStatus);
3083 RLOGE("supplyIccPukForAppResponse: radioService[%d]->mRadioResponse == NULL",
3090 int radio::supplyIccPin2ForAppResponse(int slotId,
3091 int responseType, int serial, RIL_Errno e,
3092 void *response, size_t responseLen) {
3094 RLOGD("supplyIccPin2ForAppResponse: serial %d", serial);
3097 if (radioService[slotId]->mRadioResponse != NULL) {
3098 RadioResponseInfo responseInfo = {};
3099 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3100 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3101 supplyIccPin2ForAppResponse(responseInfo, ret);
3102 radioService[slotId]->checkReturnStatus(retStatus);
3104 RLOGE("supplyIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3111 int radio::supplyIccPuk2ForAppResponse(int slotId,
3112 int responseType, int serial, RIL_Errno e,
3113 void *response, size_t responseLen) {
3115 RLOGD("supplyIccPuk2ForAppResponse: serial %d", serial);
3118 if (radioService[slotId]->mRadioResponse != NULL) {
3119 RadioResponseInfo responseInfo = {};
3120 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3121 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3122 supplyIccPuk2ForAppResponse(responseInfo, ret);
3123 radioService[slotId]->checkReturnStatus(retStatus);
3125 RLOGE("supplyIccPuk2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3132 int radio::changeIccPinForAppResponse(int slotId,
3133 int responseType, int serial, RIL_Errno e,
3134 void *response, size_t responseLen) {
3136 RLOGD("changeIccPinForAppResponse: serial %d", serial);
3139 if (radioService[slotId]->mRadioResponse != NULL) {
3140 RadioResponseInfo responseInfo = {};
3141 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3142 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3143 changeIccPinForAppResponse(responseInfo, ret);
3144 radioService[slotId]->checkReturnStatus(retStatus);
3146 RLOGE("changeIccPinForAppResponse: radioService[%d]->mRadioResponse == NULL",
3153 int radio::changeIccPin2ForAppResponse(int slotId,
3154 int responseType, int serial, RIL_Errno e,
3155 void *response, size_t responseLen) {
3157 RLOGD("changeIccPin2ForAppResponse: serial %d", serial);
3160 if (radioService[slotId]->mRadioResponse != NULL) {
3161 RadioResponseInfo responseInfo = {};
3162 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3163 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3164 changeIccPin2ForAppResponse(responseInfo, ret);
3165 radioService[slotId]->checkReturnStatus(retStatus);
3167 RLOGE("changeIccPin2ForAppResponse: radioService[%d]->mRadioResponse == NULL",
3174 int radio::supplyNetworkDepersonalizationResponse(int slotId,
3175 int responseType, int serial, RIL_Errno e,
3176 void *response, size_t responseLen) {
3178 RLOGD("supplyNetworkDepersonalizationResponse: serial %d", serial);
3181 if (radioService[slotId]->mRadioResponse != NULL) {
3182 RadioResponseInfo responseInfo = {};
3183 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
3184 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3185 supplyNetworkDepersonalizationResponse(responseInfo, ret);
3186 radioService[slotId]->checkReturnStatus(retStatus);
3188 RLOGE("supplyNetworkDepersonalizationResponse: radioService[%d]->mRadioResponse == "
3195 int radio::getCurrentCallsResponse(int slotId,
3196 int responseType, int serial, RIL_Errno e,
3197 void *response, size_t responseLen) {
3199 RLOGD("getCurrentCallsResponse: serial %d", serial);
3202 if (radioService[slotId]->mRadioResponse != NULL) {
3203 RadioResponseInfo responseInfo = {};
3204 populateResponseInfo(responseInfo, serial, responseType, e);
3206 hidl_vec<Call> calls;
3207 if ((response == NULL && responseLen != 0)
3208 || (responseLen % sizeof(RIL_Call *)) != 0) {
3209 RLOGE("getCurrentCallsResponse: Invalid response");
3210 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3212 int num = responseLen / sizeof(RIL_Call *);
3215 for (int i = 0 ; i < num ; i++) {
3216 RIL_Call *p_cur = ((RIL_Call **) response)[i];
3217 /* each call info */
3218 calls[i].state = (CallState) p_cur->state;
3219 calls[i].index = p_cur->index;
3220 calls[i].toa = p_cur->toa;
3221 calls[i].isMpty = p_cur->isMpty;
3222 calls[i].isMT = p_cur->isMT;
3223 calls[i].als = p_cur->als;
3224 calls[i].isVoice = p_cur->isVoice;
3225 calls[i].isVoicePrivacy = p_cur->isVoicePrivacy;
3226 calls[i].number = convertCharPtrToHidlString(p_cur->number);
3227 calls[i].numberPresentation = (CallPresentation) p_cur->numberPresentation;
3228 calls[i].name = convertCharPtrToHidlString(p_cur->name);
3229 calls[i].namePresentation = (CallPresentation) p_cur->namePresentation;
3230 if (p_cur->uusInfo != NULL && p_cur->uusInfo->uusData != NULL) {
3231 RIL_UUS_Info *uusInfo = p_cur->uusInfo;
3232 calls[i].uusInfo.resize(1);
3233 calls[i].uusInfo[0].uusType = (UusType) uusInfo->uusType;
3234 calls[i].uusInfo[0].uusDcs = (UusDcs) uusInfo->uusDcs;
3235 // convert uusInfo->uusData to a null-terminated string
3236 char *nullTermStr = strndup(uusInfo->uusData, uusInfo->uusLength);
3237 calls[i].uusInfo[0].uusData = nullTermStr;
3243 Return<void> retStatus = radioService[slotId]->mRadioResponse->
3244 getCurrentCallsResponse(responseInfo, calls);
3245 radioService[slotId]->checkReturnStatus(retStatus);
3247 RLOGE("getCurrentCallsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3253 int radio::dialResponse(int slotId,
3254 int responseType, int serial, RIL_Errno e, void *response,
3255 size_t responseLen) {
3257 RLOGD("dialResponse: serial %d", serial);
3260 if (radioService[slotId]->mRadioResponse != NULL) {
3261 RadioResponseInfo responseInfo = {};
3262 populateResponseInfo(responseInfo, serial, responseType, e);
3263 Return<void> retStatus = radioService[slotId]->mRadioResponse->dialResponse(responseInfo);
3264 radioService[slotId]->checkReturnStatus(retStatus);
3266 RLOGE("dialResponse: radioService[%d]->mRadioResponse == NULL", slotId);
3272 int radio::getIMSIForAppResponse(int slotId,
3273 int responseType, int serial, RIL_Errno e, void *response,
3274 size_t responseLen) {
3276 RLOGD("getIMSIForAppResponse: serial %d", serial);
3279 if (radioService[slotId]->mRadioResponse != NULL) {
3280 RadioResponseInfo responseInfo = {};
3281 populateResponseInfo(responseInfo, serial, responseType, e);
3282 Return<void> retStatus = radioService[slotId]->mRadioResponse->getIMSIForAppResponse(
3283 responseInfo, convertCharPtrToHidlString((char *) response));
3284 radioService[slotId]->checkReturnStatus(retStatus);
3286 RLOGE("getIMSIForAppResponse: radioService[%d]->mRadioResponse == NULL",
3293 int radio::hangupConnectionResponse(int slotId,
3294 int responseType, int serial, RIL_Errno e,
3295 void *response, size_t responseLen) {
3297 RLOGD("hangupConnectionResponse: serial %d", serial);
3300 if (radioService[slotId]->mRadioResponse != NULL) {
3301 RadioResponseInfo responseInfo = {};
3302 populateResponseInfo(responseInfo, serial, responseType, e);
3303 Return<void> retStatus = radioService[slotId]->mRadioResponse->hangupConnectionResponse(
3305 radioService[slotId]->checkReturnStatus(retStatus);
3307 RLOGE("hangupConnectionResponse: radioService[%d]->mRadioResponse == NULL",
3314 int radio::hangupWaitingOrBackgroundResponse(int slotId,
3315 int responseType, int serial, RIL_Errno e,
3316 void *response, size_t responseLen) {
3318 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3321 if (radioService[slotId]->mRadioResponse != NULL) {
3322 RadioResponseInfo responseInfo = {};
3323 populateResponseInfo(responseInfo, serial, responseType, e);
3324 Return<void> retStatus =
3325 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3327 radioService[slotId]->checkReturnStatus(retStatus);
3329 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3336 int radio::hangupForegroundResumeBackgroundResponse(int slotId, int responseType, int serial,
3337 RIL_Errno e, void *response,
3338 size_t responseLen) {
3340 RLOGD("hangupWaitingOrBackgroundResponse: serial %d", serial);
3343 if (radioService[slotId]->mRadioResponse != NULL) {
3344 RadioResponseInfo responseInfo = {};
3345 populateResponseInfo(responseInfo, serial, responseType, e);
3346 Return<void> retStatus =
3347 radioService[slotId]->mRadioResponse->hangupWaitingOrBackgroundResponse(
3349 radioService[slotId]->checkReturnStatus(retStatus);
3351 RLOGE("hangupWaitingOrBackgroundResponse: radioService[%d]->mRadioResponse == NULL",
3358 int radio::switchWaitingOrHoldingAndActiveResponse(int slotId, int responseType, int serial,
3359 RIL_Errno e, void *response,
3360 size_t responseLen) {
3362 RLOGD("switchWaitingOrHoldingAndActiveResponse: serial %d", serial);
3365 if (radioService[slotId]->mRadioResponse != NULL) {
3366 RadioResponseInfo responseInfo = {};
3367 populateResponseInfo(responseInfo, serial, responseType, e);
3368 Return<void> retStatus =
3369 radioService[slotId]->mRadioResponse->switchWaitingOrHoldingAndActiveResponse(
3371 radioService[slotId]->checkReturnStatus(retStatus);
3373 RLOGE("switchWaitingOrHoldingAndActiveResponse: radioService[%d]->mRadioResponse "
3380 int radio::conferenceResponse(int slotId, int responseType,
3381 int serial, RIL_Errno e, void *response, size_t responseLen) {
3383 RLOGD("conferenceResponse: serial %d", serial);
3386 if (radioService[slotId]->mRadioResponse != NULL) {
3387 RadioResponseInfo responseInfo = {};
3388 populateResponseInfo(responseInfo, serial, responseType, e);
3389 Return<void> retStatus = radioService[slotId]->mRadioResponse->conferenceResponse(
3391 radioService[slotId]->checkReturnStatus(retStatus);
3393 RLOGE("conferenceResponse: radioService[%d]->mRadioResponse == NULL",
3400 int radio::rejectCallResponse(int slotId, int responseType,
3401 int serial, RIL_Errno e, void *response, size_t responseLen) {
3403 RLOGD("rejectCallResponse: serial %d", serial);
3406 if (radioService[slotId]->mRadioResponse != NULL) {
3407 RadioResponseInfo responseInfo = {};
3408 populateResponseInfo(responseInfo, serial, responseType, e);
3409 Return<void> retStatus = radioService[slotId]->mRadioResponse->rejectCallResponse(
3411 radioService[slotId]->checkReturnStatus(retStatus);
3413 RLOGE("rejectCallResponse: radioService[%d]->mRadioResponse == NULL",
3420 int radio::getLastCallFailCauseResponse(int slotId,
3421 int responseType, int serial, RIL_Errno e, void *response,
3422 size_t responseLen) {
3424 RLOGD("getLastCallFailCauseResponse: serial %d", serial);
3427 if (radioService[slotId]->mRadioResponse != NULL) {
3428 RadioResponseInfo responseInfo = {};
3429 populateResponseInfo(responseInfo, serial, responseType, e);
3431 LastCallFailCauseInfo info = {};
3432 info.vendorCause = hidl_string();
3433 if (response == NULL) {
3434 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3435 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3436 } else if (responseLen == sizeof(int)) {
3437 int *pInt = (int *) response;
3438 info.causeCode = (LastCallFailCause) pInt[0];
3439 } else if (responseLen == sizeof(RIL_LastCallFailCauseInfo)) {
3440 RIL_LastCallFailCauseInfo *pFailCauseInfo = (RIL_LastCallFailCauseInfo *) response;
3441 info.causeCode = (LastCallFailCause) pFailCauseInfo->cause_code;
3442 info.vendorCause = convertCharPtrToHidlString(pFailCauseInfo->vendor_cause);
3444 RLOGE("getCurrentCallsResponse Invalid response: NULL");
3445 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3448 Return<void> retStatus = radioService[slotId]->mRadioResponse->getLastCallFailCauseResponse(
3449 responseInfo, info);
3450 radioService[slotId]->checkReturnStatus(retStatus);
3452 RLOGE("getLastCallFailCauseResponse: radioService[%d]->mRadioResponse == NULL",
3459 int radio::getSignalStrengthResponse(int slotId,
3460 int responseType, int serial, RIL_Errno e,
3461 void *response, size_t responseLen) {
3463 RLOGD("getSignalStrengthResponse: serial %d", serial);
3466 if (radioService[slotId]->mRadioResponse != NULL) {
3467 RadioResponseInfo responseInfo = {};
3468 populateResponseInfo(responseInfo, serial, responseType, e);
3469 SignalStrength signalStrength = {};
3470 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
3471 RLOGE("getSignalStrengthResponse: Invalid response");
3472 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3474 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
3477 Return<void> retStatus = radioService[slotId]->mRadioResponse->getSignalStrengthResponse(
3478 responseInfo, signalStrength);
3479 radioService[slotId]->checkReturnStatus(retStatus);
3481 RLOGE("getSignalStrengthResponse: radioService[%d]->mRadioResponse == NULL",
3488 RIL_CellInfoType getCellInfoTypeRadioTechnology(char *rat) {
3490 return RIL_CELL_INFO_TYPE_NONE;
3493 int radioTech = atoi(rat);
3497 case RADIO_TECH_GPRS:
3498 case RADIO_TECH_EDGE:
3499 case RADIO_TECH_GSM: {
3500 return RIL_CELL_INFO_TYPE_GSM;
3503 case RADIO_TECH_UMTS:
3504 case RADIO_TECH_HSDPA:
3505 case RADIO_TECH_HSUPA:
3506 case RADIO_TECH_HSPA:
3507 case RADIO_TECH_HSPAP: {
3508 return RIL_CELL_INFO_TYPE_WCDMA;
3511 case RADIO_TECH_IS95A:
3512 case RADIO_TECH_IS95B:
3513 case RADIO_TECH_1xRTT:
3514 case RADIO_TECH_EVDO_0:
3515 case RADIO_TECH_EVDO_A:
3516 case RADIO_TECH_EVDO_B:
3517 case RADIO_TECH_EHRPD: {
3518 return RIL_CELL_INFO_TYPE_CDMA;
3521 case RADIO_TECH_LTE:
3522 case RADIO_TECH_LTE_CA: {
3523 return RIL_CELL_INFO_TYPE_LTE;
3526 case RADIO_TECH_TD_SCDMA: {
3527 return RIL_CELL_INFO_TYPE_TD_SCDMA;
3535 return RIL_CELL_INFO_TYPE_NONE;
3539 void fillCellIdentityResponse(CellIdentity &cellIdentity, RIL_CellIdentity_v16 &rilCellIdentity) {
3541 cellIdentity.cellIdentityGsm.resize(0);
3542 cellIdentity.cellIdentityWcdma.resize(0);
3543 cellIdentity.cellIdentityCdma.resize(0);
3544 cellIdentity.cellIdentityTdscdma.resize(0);
3545 cellIdentity.cellIdentityLte.resize(0);
3546 cellIdentity.cellInfoType = (CellInfoType)rilCellIdentity.cellInfoType;
3547 switch(rilCellIdentity.cellInfoType) {
3549 case RIL_CELL_INFO_TYPE_GSM: {
3550 cellIdentity.cellIdentityGsm.resize(1);
3551 cellIdentity.cellIdentityGsm[0].mcc =
3552 std::to_string(rilCellIdentity.cellIdentityGsm.mcc);
3553 cellIdentity.cellIdentityGsm[0].mnc =
3554 ril::util::mnc::decode(rilCellIdentity.cellIdentityGsm.mnc);
3555 cellIdentity.cellIdentityGsm[0].lac = rilCellIdentity.cellIdentityGsm.lac;
3556 cellIdentity.cellIdentityGsm[0].cid = rilCellIdentity.cellIdentityGsm.cid;
3557 cellIdentity.cellIdentityGsm[0].arfcn = rilCellIdentity.cellIdentityGsm.arfcn;
3558 cellIdentity.cellIdentityGsm[0].bsic = rilCellIdentity.cellIdentityGsm.bsic;
3562 case RIL_CELL_INFO_TYPE_WCDMA: {
3563 cellIdentity.cellIdentityWcdma.resize(1);
3564 cellIdentity.cellIdentityWcdma[0].mcc =
3565 std::to_string(rilCellIdentity.cellIdentityWcdma.mcc);
3566 cellIdentity.cellIdentityWcdma[0].mnc =
3567 ril::util::mnc::decode(rilCellIdentity.cellIdentityWcdma.mnc);
3568 cellIdentity.cellIdentityWcdma[0].lac = rilCellIdentity.cellIdentityWcdma.lac;
3569 cellIdentity.cellIdentityWcdma[0].cid = rilCellIdentity.cellIdentityWcdma.cid;
3570 cellIdentity.cellIdentityWcdma[0].psc = rilCellIdentity.cellIdentityWcdma.psc;
3571 cellIdentity.cellIdentityWcdma[0].uarfcn = rilCellIdentity.cellIdentityWcdma.uarfcn;
3575 case RIL_CELL_INFO_TYPE_CDMA: {
3576 cellIdentity.cellIdentityCdma.resize(1);
3577 cellIdentity.cellIdentityCdma[0].networkId = rilCellIdentity.cellIdentityCdma.networkId;
3578 cellIdentity.cellIdentityCdma[0].systemId = rilCellIdentity.cellIdentityCdma.systemId;
3579 cellIdentity.cellIdentityCdma[0].baseStationId =
3580 rilCellIdentity.cellIdentityCdma.basestationId;
3581 cellIdentity.cellIdentityCdma[0].longitude = rilCellIdentity.cellIdentityCdma.longitude;
3582 cellIdentity.cellIdentityCdma[0].latitude = rilCellIdentity.cellIdentityCdma.latitude;
3586 case RIL_CELL_INFO_TYPE_LTE: {
3587 cellIdentity.cellIdentityLte.resize(1);
3588 cellIdentity.cellIdentityLte[0].mcc =
3589 std::to_string(rilCellIdentity.cellIdentityLte.mcc);
3590 cellIdentity.cellIdentityLte[0].mnc =
3591 ril::util::mnc::decode(rilCellIdentity.cellIdentityLte.mnc);
3592 cellIdentity.cellIdentityLte[0].ci = rilCellIdentity.cellIdentityLte.ci;
3593 cellIdentity.cellIdentityLte[0].pci = rilCellIdentity.cellIdentityLte.pci;
3594 cellIdentity.cellIdentityLte[0].tac = rilCellIdentity.cellIdentityLte.tac;
3595 cellIdentity.cellIdentityLte[0].earfcn = rilCellIdentity.cellIdentityLte.earfcn;
3599 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
3600 cellIdentity.cellIdentityTdscdma.resize(1);
3601 cellIdentity.cellIdentityTdscdma[0].mcc =
3602 std::to_string(rilCellIdentity.cellIdentityTdscdma.mcc);
3603 cellIdentity.cellIdentityTdscdma[0].mnc =
3604 ril::util::mnc::decode(rilCellIdentity.cellIdentityTdscdma.mnc);
3605 cellIdentity.cellIdentityTdscdma[0].lac = rilCellIdentity.cellIdentityTdscdma.lac;
3606 cellIdentity.cellIdentityTdscdma[0].cid = rilCellIdentity.cellIdentityTdscdma.cid;
3607 cellIdentity.cellIdentityTdscdma[0].cpid = rilCellIdentity.cellIdentityTdscdma.cpid;
3617 int convertResponseStringEntryToInt(char **response, int index, int numStrings) {
3618 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3619 return atoi(response[index]);
3625 int convertResponseHexStringEntryToInt(char **response, int index, int numStrings) {
3626 const int hexBase = 16;
3627 if ((response != NULL) && (numStrings > index) && (response[index] != NULL)) {
3628 return strtol(response[index], NULL, hexBase);
3634 /* Fill Cell Identity info from Voice Registration State Response.
3635 * This fucntion is applicable only for RIL Version < 15.
3636 * Response is a "char **".
3637 * First and Second entries are in hex string format
3638 * and rest are integers represented in ascii format. */
3639 void fillCellIdentityFromVoiceRegStateResponseString(CellIdentity &cellIdentity,
3640 int numStrings, char** response) {
3642 RIL_CellIdentity_v16 rilCellIdentity;
3643 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3645 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3646 switch(rilCellIdentity.cellInfoType) {
3648 case RIL_CELL_INFO_TYPE_GSM: {
3649 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3650 rilCellIdentity.cellIdentityGsm.lac =
3651 convertResponseHexStringEntryToInt(response, 1, numStrings);
3653 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3654 rilCellIdentity.cellIdentityGsm.cid =
3655 convertResponseHexStringEntryToInt(response, 2, numStrings);
3659 case RIL_CELL_INFO_TYPE_WCDMA: {
3660 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3661 rilCellIdentity.cellIdentityWcdma.lac =
3662 convertResponseHexStringEntryToInt(response, 1, numStrings);
3664 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3665 rilCellIdentity.cellIdentityWcdma.cid =
3666 convertResponseHexStringEntryToInt(response, 2, numStrings);
3667 rilCellIdentity.cellIdentityWcdma.psc =
3668 convertResponseStringEntryToInt(response, 14, numStrings);
3672 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3673 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3674 rilCellIdentity.cellIdentityTdscdma.lac =
3675 convertResponseHexStringEntryToInt(response, 1, numStrings);
3677 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3678 rilCellIdentity.cellIdentityTdscdma.cid =
3679 convertResponseHexStringEntryToInt(response, 2, numStrings);
3683 case RIL_CELL_INFO_TYPE_CDMA:{
3684 rilCellIdentity.cellIdentityCdma.basestationId =
3685 convertResponseStringEntryToInt(response, 4, numStrings);
3686 /* Order of Lat. and Long. swapped between RIL and HIDL interface versions. */
3687 rilCellIdentity.cellIdentityCdma.latitude =
3688 convertResponseStringEntryToInt(response, 5, numStrings);
3689 rilCellIdentity.cellIdentityCdma.longitude =
3690 convertResponseStringEntryToInt(response, 6, numStrings);
3691 rilCellIdentity.cellIdentityCdma.systemId =
3692 convertResponseStringEntryToInt(response, 8, numStrings);
3693 rilCellIdentity.cellIdentityCdma.networkId =
3694 convertResponseStringEntryToInt(response, 9, numStrings);
3698 case RIL_CELL_INFO_TYPE_LTE:{
3699 /* valid TAC are hexstrings in the range 0x0000 - 0xffff */
3700 rilCellIdentity.cellIdentityLte.tac =
3701 convertResponseHexStringEntryToInt(response, 1, numStrings);
3703 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3704 rilCellIdentity.cellIdentityLte.ci =
3705 convertResponseHexStringEntryToInt(response, 2, numStrings);
3714 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3717 /* Fill Cell Identity info from Data Registration State Response.
3718 * This fucntion is applicable only for RIL Version < 15.
3719 * Response is a "char **".
3720 * First and Second entries are in hex string format
3721 * and rest are integers represented in ascii format. */
3722 void fillCellIdentityFromDataRegStateResponseString(CellIdentity &cellIdentity,
3723 int numStrings, char** response) {
3725 RIL_CellIdentity_v16 rilCellIdentity;
3726 memset(&rilCellIdentity, -1, sizeof(RIL_CellIdentity_v16));
3728 rilCellIdentity.cellInfoType = getCellInfoTypeRadioTechnology(response[3]);
3729 switch(rilCellIdentity.cellInfoType) {
3730 case RIL_CELL_INFO_TYPE_GSM: {
3731 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3732 rilCellIdentity.cellIdentityGsm.lac =
3733 convertResponseHexStringEntryToInt(response, 1, numStrings);
3735 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3736 rilCellIdentity.cellIdentityGsm.cid =
3737 convertResponseHexStringEntryToInt(response, 2, numStrings);
3740 case RIL_CELL_INFO_TYPE_WCDMA: {
3741 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3742 rilCellIdentity.cellIdentityWcdma.lac =
3743 convertResponseHexStringEntryToInt(response, 1, numStrings);
3745 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3746 rilCellIdentity.cellIdentityWcdma.cid =
3747 convertResponseHexStringEntryToInt(response, 2, numStrings);
3750 case RIL_CELL_INFO_TYPE_TD_SCDMA:{
3751 /* valid LAC are hexstrings in the range 0x0000 - 0xffff */
3752 rilCellIdentity.cellIdentityTdscdma.lac =
3753 convertResponseHexStringEntryToInt(response, 1, numStrings);
3755 /* valid CID are hexstrings in the range 0x00000000 - 0xffffffff */
3756 rilCellIdentity.cellIdentityTdscdma.cid =
3757 convertResponseHexStringEntryToInt(response, 2, numStrings);
3760 case RIL_CELL_INFO_TYPE_LTE: {
3761 rilCellIdentity.cellIdentityLte.tac =
3762 convertResponseStringEntryToInt(response, 6, numStrings);
3763 rilCellIdentity.cellIdentityLte.pci =
3764 convertResponseStringEntryToInt(response, 7, numStrings);
3765 rilCellIdentity.cellIdentityLte.ci =
3766 convertResponseStringEntryToInt(response, 8, numStrings);
3774 fillCellIdentityResponse(cellIdentity, rilCellIdentity);
3777 int radio::getVoiceRegistrationStateResponse(int slotId,
3778 int responseType, int serial, RIL_Errno e,
3779 void *response, size_t responseLen) {
3781 RLOGD("getVoiceRegistrationStateResponse: serial %d", serial);
3784 if (radioService[slotId]->mRadioResponse != NULL) {
3785 RadioResponseInfo responseInfo = {};
3786 populateResponseInfo(responseInfo, serial, responseType, e);
3788 VoiceRegStateResult voiceRegResponse = {};
3789 int numStrings = responseLen / sizeof(char *);
3790 if (response == NULL) {
3791 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3792 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3793 } else if (s_vendorFunctions->version <= 14) {
3794 if (numStrings != 15) {
3795 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3796 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3798 char **resp = (char **) response;
3799 voiceRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3800 voiceRegResponse.rat = ATOI_NULL_HANDLED(resp[3]);
3801 voiceRegResponse.cssSupported = ATOI_NULL_HANDLED_DEF(resp[7], 0);
3802 voiceRegResponse.roamingIndicator = ATOI_NULL_HANDLED(resp[10]);
3803 voiceRegResponse.systemIsInPrl = ATOI_NULL_HANDLED_DEF(resp[11], 0);
3804 voiceRegResponse.defaultRoamingIndicator = ATOI_NULL_HANDLED_DEF(resp[12], 0);
3805 voiceRegResponse.reasonForDenial = ATOI_NULL_HANDLED_DEF(resp[13], 0);
3806 fillCellIdentityFromVoiceRegStateResponseString(voiceRegResponse.cellIdentity,
3810 RIL_VoiceRegistrationStateResponse *voiceRegState =
3811 (RIL_VoiceRegistrationStateResponse *)response;
3813 if (responseLen != sizeof(RIL_VoiceRegistrationStateResponse)) {
3814 RLOGE("getVoiceRegistrationStateResponse Invalid response: NULL");
3815 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3817 voiceRegResponse.regState = (RegState) voiceRegState->regState;
3818 voiceRegResponse.rat = voiceRegState->rat;;
3819 voiceRegResponse.cssSupported = voiceRegState->cssSupported;
3820 voiceRegResponse.roamingIndicator = voiceRegState->roamingIndicator;
3821 voiceRegResponse.systemIsInPrl = voiceRegState->systemIsInPrl;
3822 voiceRegResponse.defaultRoamingIndicator = voiceRegState->defaultRoamingIndicator;
3823 voiceRegResponse.reasonForDenial = voiceRegState->reasonForDenial;
3824 fillCellIdentityResponse(voiceRegResponse.cellIdentity,
3825 voiceRegState->cellIdentity);
3829 Return<void> retStatus =
3830 radioService[slotId]->mRadioResponse->getVoiceRegistrationStateResponse(
3831 responseInfo, voiceRegResponse);
3832 radioService[slotId]->checkReturnStatus(retStatus);
3834 RLOGE("getVoiceRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3841 int radio::getDataRegistrationStateResponse(int slotId,
3842 int responseType, int serial, RIL_Errno e,
3843 void *response, size_t responseLen) {
3845 RLOGD("getDataRegistrationStateResponse: serial %d", serial);
3848 if (radioService[slotId]->mRadioResponse != NULL) {
3849 RadioResponseInfo responseInfo = {};
3850 populateResponseInfo(responseInfo, serial, responseType, e);
3851 DataRegStateResult dataRegResponse = {};
3852 if (response == NULL) {
3853 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3854 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3855 } else if (s_vendorFunctions->version <= 14) {
3856 int numStrings = responseLen / sizeof(char *);
3857 if ((numStrings != 6) && (numStrings != 11)) {
3858 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3859 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3861 char **resp = (char **) response;
3862 dataRegResponse.regState = (RegState) ATOI_NULL_HANDLED_DEF(resp[0], 4);
3863 dataRegResponse.rat = ATOI_NULL_HANDLED_DEF(resp[3], 0);
3864 dataRegResponse.reasonDataDenied = ATOI_NULL_HANDLED(resp[4]);
3865 dataRegResponse.maxDataCalls = ATOI_NULL_HANDLED_DEF(resp[5], 1);
3866 fillCellIdentityFromDataRegStateResponseString(dataRegResponse.cellIdentity,
3870 RIL_DataRegistrationStateResponse *dataRegState =
3871 (RIL_DataRegistrationStateResponse *)response;
3873 if (responseLen != sizeof(RIL_DataRegistrationStateResponse)) {
3874 RLOGE("getDataRegistrationStateResponse Invalid response: NULL");
3875 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3877 dataRegResponse.regState = (RegState) dataRegState->regState;
3878 dataRegResponse.rat = dataRegState->rat;;
3879 dataRegResponse.reasonDataDenied = dataRegState->reasonDataDenied;
3880 dataRegResponse.maxDataCalls = dataRegState->maxDataCalls;
3881 fillCellIdentityResponse(dataRegResponse.cellIdentity, dataRegState->cellIdentity);
3885 Return<void> retStatus =
3886 radioService[slotId]->mRadioResponse->getDataRegistrationStateResponse(responseInfo,
3888 radioService[slotId]->checkReturnStatus(retStatus);
3890 RLOGE("getDataRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
3897 int radio::getOperatorResponse(int slotId,
3898 int responseType, int serial, RIL_Errno e, void *response,
3899 size_t responseLen) {
3901 RLOGD("getOperatorResponse: serial %d", serial);
3904 if (radioService[slotId]->mRadioResponse != NULL) {
3905 RadioResponseInfo responseInfo = {};
3906 populateResponseInfo(responseInfo, serial, responseType, e);
3907 hidl_string longName;
3908 hidl_string shortName;
3909 hidl_string numeric;
3910 int numStrings = responseLen / sizeof(char *);
3911 if (response == NULL || numStrings != 3) {
3912 RLOGE("getOperatorResponse Invalid response: NULL");
3913 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3916 char **resp = (char **) response;
3917 longName = convertCharPtrToHidlString(resp[0]);
3918 shortName = convertCharPtrToHidlString(resp[1]);
3919 numeric = convertCharPtrToHidlString(resp[2]);
3921 Return<void> retStatus = radioService[slotId]->mRadioResponse->getOperatorResponse(
3922 responseInfo, longName, shortName, numeric);
3923 radioService[slotId]->checkReturnStatus(retStatus);
3925 RLOGE("getOperatorResponse: radioService[%d]->mRadioResponse == NULL",
3932 int radio::setRadioPowerResponse(int slotId,
3933 int responseType, int serial, RIL_Errno e, void *response,
3934 size_t responseLen) {
3935 RLOGD("setRadioPowerResponse: serial %d", serial);
3937 if (radioService[slotId]->mRadioResponse != NULL) {
3938 RadioResponseInfo responseInfo = {};
3939 populateResponseInfo(responseInfo, serial, responseType, e);
3940 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioPowerResponse(
3942 radioService[slotId]->checkReturnStatus(retStatus);
3944 RLOGE("setRadioPowerResponse: radioService[%d]->mRadioResponse == NULL",
3951 int radio::sendDtmfResponse(int slotId,
3952 int responseType, int serial, RIL_Errno e, void *response,
3953 size_t responseLen) {
3955 RLOGD("sendDtmfResponse: serial %d", serial);
3958 if (radioService[slotId]->mRadioResponse != NULL) {
3959 RadioResponseInfo responseInfo = {};
3960 populateResponseInfo(responseInfo, serial, responseType, e);
3961 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendDtmfResponse(
3963 radioService[slotId]->checkReturnStatus(retStatus);
3965 RLOGE("sendDtmfResponse: radioService[%d]->mRadioResponse == NULL",
3972 SendSmsResult makeSendSmsResult(RadioResponseInfo& responseInfo, int serial, int responseType,
3973 RIL_Errno e, void *response, size_t responseLen) {
3974 populateResponseInfo(responseInfo, serial, responseType, e);
3975 SendSmsResult result = {};
3977 if (response == NULL || responseLen != sizeof(RIL_SMS_Response)) {
3978 RLOGE("Invalid response: NULL");
3979 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
3980 result.ackPDU = hidl_string();
3982 RIL_SMS_Response *resp = (RIL_SMS_Response *) response;
3983 result.messageRef = resp->messageRef;
3984 result.ackPDU = convertCharPtrToHidlString(resp->ackPDU);
3985 result.errorCode = resp->errorCode;
3990 int radio::sendSmsResponse(int slotId,
3991 int responseType, int serial, RIL_Errno e, void *response,
3992 size_t responseLen) {
3994 RLOGD("sendSmsResponse: serial %d", serial);
3997 if (radioService[slotId]->mRadioResponse != NULL) {
3998 RadioResponseInfo responseInfo = {};
3999 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4002 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSmsResponse(responseInfo,
4004 radioService[slotId]->checkReturnStatus(retStatus);
4006 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4012 int radio::sendSMSExpectMoreResponse(int slotId,
4013 int responseType, int serial, RIL_Errno e, void *response,
4014 size_t responseLen) {
4016 RLOGD("sendSMSExpectMoreResponse: serial %d", serial);
4019 if (radioService[slotId]->mRadioResponse != NULL) {
4020 RadioResponseInfo responseInfo = {};
4021 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
4024 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendSMSExpectMoreResponse(
4025 responseInfo, result);
4026 radioService[slotId]->checkReturnStatus(retStatus);
4028 RLOGE("sendSMSExpectMoreResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4034 int radio::setupDataCallResponse(int slotId,
4035 int responseType, int serial, RIL_Errno e, void *response,
4036 size_t responseLen) {
4038 RLOGD("setupDataCallResponse: serial %d", serial);
4041 if (radioService[slotId]->mRadioResponse != NULL) {
4042 RadioResponseInfo responseInfo = {};
4043 populateResponseInfo(responseInfo, serial, responseType, e);
4045 SetupDataCallResult result = {};
4046 if (response == NULL || (responseLen % sizeof(RIL_Data_Call_Response_v11)) != 0) {
4047 if (response != NULL) {
4048 RLOGE("setupDataCallResponse: Invalid response");
4049 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4051 result.status = DataCallFailCause::ERROR_UNSPECIFIED;
4052 result.type = hidl_string();
4053 result.ifname = hidl_string();
4054 result.addresses = hidl_string();
4055 result.dnses = hidl_string();
4056 result.gateways = hidl_string();
4057 result.pcscf = hidl_string();
4059 convertRilDataCallToHal((RIL_Data_Call_Response_v11 *) response, result);
4062 Return<void> retStatus = radioService[slotId]->mRadioResponse->setupDataCallResponse(
4063 responseInfo, result);
4064 radioService[slotId]->checkReturnStatus(retStatus);
4066 RLOGE("setupDataCallResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4072 IccIoResult responseIccIo(RadioResponseInfo& responseInfo, int serial, int responseType,
4073 RIL_Errno e, void *response, size_t responseLen) {
4074 populateResponseInfo(responseInfo, serial, responseType, e);
4075 IccIoResult result = {};
4077 if (response == NULL || responseLen != sizeof(RIL_SIM_IO_Response)) {
4078 RLOGE("Invalid response: NULL");
4079 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4080 result.simResponse = hidl_string();
4082 RIL_SIM_IO_Response *resp = (RIL_SIM_IO_Response *) response;
4083 result.sw1 = resp->sw1;
4084 result.sw2 = resp->sw2;
4085 result.simResponse = convertCharPtrToHidlString(resp->simResponse);
4090 int radio::iccIOForAppResponse(int slotId,
4091 int responseType, int serial, RIL_Errno e, void *response,
4092 size_t responseLen) {
4094 RLOGD("iccIOForAppResponse: serial %d", serial);
4097 if (radioService[slotId]->mRadioResponse != NULL) {
4098 RadioResponseInfo responseInfo = {};
4099 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
4102 Return<void> retStatus = radioService[slotId]->mRadioResponse->iccIOForAppResponse(
4103 responseInfo, result);
4104 radioService[slotId]->checkReturnStatus(retStatus);
4106 RLOGE("iccIOForAppResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4112 int radio::sendUssdResponse(int slotId,
4113 int responseType, int serial, RIL_Errno e, void *response,
4114 size_t responseLen) {
4116 RLOGD("sendUssdResponse: serial %d", serial);
4119 if (radioService[slotId]->mRadioResponse != NULL) {
4120 RadioResponseInfo responseInfo = {};
4121 populateResponseInfo(responseInfo, serial, responseType, e);
4122 Return<void> retStatus = radioService[slotId]->mRadioResponse->sendUssdResponse(
4124 radioService[slotId]->checkReturnStatus(retStatus);
4126 RLOGE("sendUssdResponse: radioService[%d]->mRadioResponse == NULL",
4133 int radio::cancelPendingUssdResponse(int slotId,
4134 int responseType, int serial, RIL_Errno e, void *response,
4135 size_t responseLen) {
4137 RLOGD("cancelPendingUssdResponse: serial %d", serial);
4140 if (radioService[slotId]->mRadioResponse != NULL) {
4141 RadioResponseInfo responseInfo = {};
4142 populateResponseInfo(responseInfo, serial, responseType, e);
4143 Return<void> retStatus = radioService[slotId]->mRadioResponse->cancelPendingUssdResponse(
4145 radioService[slotId]->checkReturnStatus(retStatus);
4147 RLOGE("cancelPendingUssdResponse: radioService[%d]->mRadioResponse == NULL",
4154 int radio::getClirResponse(int slotId,
4155 int responseType, int serial, RIL_Errno e, void *response,
4156 size_t responseLen) {
4158 RLOGD("getClirResponse: serial %d", serial);
4161 if (radioService[slotId]->mRadioResponse != NULL) {
4162 RadioResponseInfo responseInfo = {};
4163 populateResponseInfo(responseInfo, serial, responseType, e);
4165 int numInts = responseLen / sizeof(int);
4166 if (response == NULL || numInts != 2) {
4167 RLOGE("getClirResponse Invalid response: NULL");
4168 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4170 int *pInt = (int *) response;
4174 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClirResponse(responseInfo,
4176 radioService[slotId]->checkReturnStatus(retStatus);
4178 RLOGE("getClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4184 int radio::setClirResponse(int slotId,
4185 int responseType, int serial, RIL_Errno e, void *response,
4186 size_t responseLen) {
4188 RLOGD("setClirResponse: serial %d", serial);
4191 if (radioService[slotId]->mRadioResponse != NULL) {
4192 RadioResponseInfo responseInfo = {};
4193 populateResponseInfo(responseInfo, serial, responseType, e);
4194 Return<void> retStatus = radioService[slotId]->mRadioResponse->setClirResponse(
4196 radioService[slotId]->checkReturnStatus(retStatus);
4198 RLOGE("setClirResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4204 int radio::getCallForwardStatusResponse(int slotId,
4205 int responseType, int serial, RIL_Errno e,
4206 void *response, size_t responseLen) {
4208 RLOGD("getCallForwardStatusResponse: serial %d", serial);
4211 if (radioService[slotId]->mRadioResponse != NULL) {
4212 RadioResponseInfo responseInfo = {};
4213 populateResponseInfo(responseInfo, serial, responseType, e);
4214 hidl_vec<CallForwardInfo> callForwardInfos;
4216 if ((response == NULL && responseLen != 0)
4217 || responseLen % sizeof(RIL_CallForwardInfo *) != 0) {
4218 RLOGE("getCallForwardStatusResponse Invalid response: NULL");
4219 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4221 int num = responseLen / sizeof(RIL_CallForwardInfo *);
4222 callForwardInfos.resize(num);
4223 for (int i = 0 ; i < num; i++) {
4224 RIL_CallForwardInfo *resp = ((RIL_CallForwardInfo **) response)[i];
4225 callForwardInfos[i].status = (CallForwardInfoStatus) resp->status;
4226 callForwardInfos[i].reason = resp->reason;
4227 callForwardInfos[i].serviceClass = resp->serviceClass;
4228 callForwardInfos[i].toa = resp->toa;
4229 callForwardInfos[i].number = convertCharPtrToHidlString(resp->number);
4230 callForwardInfos[i].timeSeconds = resp->timeSeconds;
4234 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallForwardStatusResponse(
4235 responseInfo, callForwardInfos);
4236 radioService[slotId]->checkReturnStatus(retStatus);
4238 RLOGE("getCallForwardStatusResponse: radioService[%d]->mRadioResponse == NULL",
4245 int radio::setCallForwardResponse(int slotId,
4246 int responseType, int serial, RIL_Errno e, void *response,
4247 size_t responseLen) {
4249 RLOGD("setCallForwardResponse: serial %d", serial);
4252 if (radioService[slotId]->mRadioResponse != NULL) {
4253 RadioResponseInfo responseInfo = {};
4254 populateResponseInfo(responseInfo, serial, responseType, e);
4255 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallForwardResponse(
4257 radioService[slotId]->checkReturnStatus(retStatus);
4259 RLOGE("setCallForwardResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4265 int radio::getCallWaitingResponse(int slotId,
4266 int responseType, int serial, RIL_Errno e, void *response,
4267 size_t responseLen) {
4269 RLOGD("getCallWaitingResponse: serial %d", serial);
4272 if (radioService[slotId]->mRadioResponse != NULL) {
4273 RadioResponseInfo responseInfo = {};
4274 populateResponseInfo(responseInfo, serial, responseType, e);
4275 bool enable = false;
4276 int serviceClass = -1;
4277 int numInts = responseLen / sizeof(int);
4278 if (response == NULL || numInts != 2) {
4279 RLOGE("getCallWaitingResponse Invalid response: NULL");
4280 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4282 int *pInt = (int *) response;
4283 enable = pInt[0] == 1 ? true : false;
4284 serviceClass = pInt[1];
4286 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCallWaitingResponse(
4287 responseInfo, enable, serviceClass);
4288 radioService[slotId]->checkReturnStatus(retStatus);
4290 RLOGE("getCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4296 int radio::setCallWaitingResponse(int slotId,
4297 int responseType, int serial, RIL_Errno e, void *response,
4298 size_t responseLen) {
4300 RLOGD("setCallWaitingResponse: serial %d", serial);
4303 if (radioService[slotId]->mRadioResponse != NULL) {
4304 RadioResponseInfo responseInfo = {};
4305 populateResponseInfo(responseInfo, serial, responseType, e);
4306 Return<void> retStatus = radioService[slotId]->mRadioResponse->setCallWaitingResponse(
4308 radioService[slotId]->checkReturnStatus(retStatus);
4310 RLOGE("setCallWaitingResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4316 int radio::acknowledgeLastIncomingGsmSmsResponse(int slotId,
4317 int responseType, int serial, RIL_Errno e,
4318 void *response, size_t responseLen) {
4320 RLOGD("acknowledgeLastIncomingGsmSmsResponse: serial %d", serial);
4323 if (radioService[slotId]->mRadioResponse != NULL) {
4324 RadioResponseInfo responseInfo = {};
4325 populateResponseInfo(responseInfo, serial, responseType, e);
4326 Return<void> retStatus =
4327 radioService[slotId]->mRadioResponse->acknowledgeLastIncomingGsmSmsResponse(
4329 radioService[slotId]->checkReturnStatus(retStatus);
4331 RLOGE("acknowledgeLastIncomingGsmSmsResponse: radioService[%d]->mRadioResponse "
4338 int radio::acceptCallResponse(int slotId,
4339 int responseType, int serial, RIL_Errno e,
4340 void *response, size_t responseLen) {
4342 RLOGD("acceptCallResponse: serial %d", serial);
4345 if (radioService[slotId]->mRadioResponse != NULL) {
4346 RadioResponseInfo responseInfo = {};
4347 populateResponseInfo(responseInfo, serial, responseType, e);
4348 Return<void> retStatus = radioService[slotId]->mRadioResponse->acceptCallResponse(
4350 radioService[slotId]->checkReturnStatus(retStatus);
4352 RLOGE("acceptCallResponse: radioService[%d]->mRadioResponse == NULL",
4359 int radio::deactivateDataCallResponse(int slotId,
4360 int responseType, int serial, RIL_Errno e,
4361 void *response, size_t responseLen) {
4363 RLOGD("deactivateDataCallResponse: serial %d", serial);
4366 if (radioService[slotId]->mRadioResponse != NULL) {
4367 RadioResponseInfo responseInfo = {};
4368 populateResponseInfo(responseInfo, serial, responseType, e);
4369 Return<void> retStatus = radioService[slotId]->mRadioResponse->deactivateDataCallResponse(
4371 radioService[slotId]->checkReturnStatus(retStatus);
4373 RLOGE("deactivateDataCallResponse: radioService[%d]->mRadioResponse == NULL",
4380 int radio::getFacilityLockForAppResponse(int slotId,
4381 int responseType, int serial, RIL_Errno e,
4382 void *response, size_t responseLen) {
4384 RLOGD("getFacilityLockForAppResponse: serial %d", serial);
4387 if (radioService[slotId]->mRadioResponse != NULL) {
4388 RadioResponseInfo responseInfo = {};
4389 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4390 Return<void> retStatus = radioService[slotId]->mRadioResponse->
4391 getFacilityLockForAppResponse(responseInfo, ret);
4392 radioService[slotId]->checkReturnStatus(retStatus);
4394 RLOGE("getFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4401 int radio::setFacilityLockForAppResponse(int slotId,
4402 int responseType, int serial, RIL_Errno e,
4403 void *response, size_t responseLen) {
4405 RLOGD("setFacilityLockForAppResponse: serial %d", serial);
4408 if (radioService[slotId]->mRadioResponse != NULL) {
4409 RadioResponseInfo responseInfo = {};
4410 int ret = responseIntOrEmpty(responseInfo, serial, responseType, e, response, responseLen);
4411 Return<void> retStatus
4412 = radioService[slotId]->mRadioResponse->setFacilityLockForAppResponse(responseInfo,
4414 radioService[slotId]->checkReturnStatus(retStatus);
4416 RLOGE("setFacilityLockForAppResponse: radioService[%d]->mRadioResponse == NULL",
4423 int radio::setBarringPasswordResponse(int slotId,
4424 int responseType, int serial, RIL_Errno e,
4425 void *response, size_t responseLen) {
4427 RLOGD("acceptCallResponse: serial %d", serial);
4430 if (radioService[slotId]->mRadioResponse != NULL) {
4431 RadioResponseInfo responseInfo = {};
4432 populateResponseInfo(responseInfo, serial, responseType, e);
4433 Return<void> retStatus
4434 = radioService[slotId]->mRadioResponse->setBarringPasswordResponse(responseInfo);
4435 radioService[slotId]->checkReturnStatus(retStatus);
4437 RLOGE("setBarringPasswordResponse: radioService[%d]->mRadioResponse == NULL",
4444 int radio::getNetworkSelectionModeResponse(int slotId,
4445 int responseType, int serial, RIL_Errno e, void *response,
4446 size_t responseLen) {
4448 RLOGD("getNetworkSelectionModeResponse: serial %d", serial);
4451 if (radioService[slotId]->mRadioResponse != NULL) {
4452 RadioResponseInfo responseInfo = {};
4453 populateResponseInfo(responseInfo, serial, responseType, e);
4454 bool manual = false;
4455 if (response == NULL || responseLen != sizeof(int)) {
4456 RLOGE("getNetworkSelectionModeResponse Invalid response: NULL");
4457 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4459 int *pInt = (int *) response;
4460 manual = pInt[0] == 1 ? true : false;
4462 Return<void> retStatus
4463 = radioService[slotId]->mRadioResponse->getNetworkSelectionModeResponse(
4466 radioService[slotId]->checkReturnStatus(retStatus);
4468 RLOGE("getNetworkSelectionModeResponse: radioService[%d]->mRadioResponse == NULL",
4475 int radio::setNetworkSelectionModeAutomaticResponse(int slotId, int responseType, int serial,
4476 RIL_Errno e, void *response,
4477 size_t responseLen) {
4479 RLOGD("setNetworkSelectionModeAutomaticResponse: serial %d", serial);
4482 if (radioService[slotId]->mRadioResponse != NULL) {
4483 RadioResponseInfo responseInfo = {};
4484 populateResponseInfo(responseInfo, serial, responseType, e);
4485 Return<void> retStatus
4486 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeAutomaticResponse(
4488 radioService[slotId]->checkReturnStatus(retStatus);
4490 RLOGE("setNetworkSelectionModeAutomaticResponse: radioService[%d]->mRadioResponse "
4497 int radio::setNetworkSelectionModeManualResponse(int slotId,
4498 int responseType, int serial, RIL_Errno e,
4499 void *response, size_t responseLen) {
4501 RLOGD("setNetworkSelectionModeManualResponse: serial %d", serial);
4504 if (radioService[slotId]->mRadioResponse != NULL) {
4505 RadioResponseInfo responseInfo = {};
4506 populateResponseInfo(responseInfo, serial, responseType, e);
4507 Return<void> retStatus
4508 = radioService[slotId]->mRadioResponse->setNetworkSelectionModeManualResponse(
4510 radioService[slotId]->checkReturnStatus(retStatus);
4512 RLOGE("acceptCallResponse: radioService[%d]->setNetworkSelectionModeManualResponse "
4519 int convertOperatorStatusToInt(const char *str) {
4520 if (strncmp("unknown", str, 9) == 0) {
4521 return (int) OperatorStatus::UNKNOWN;
4522 } else if (strncmp("available", str, 9) == 0) {
4523 return (int) OperatorStatus::AVAILABLE;
4524 } else if (strncmp("current", str, 9) == 0) {
4525 return (int) OperatorStatus::CURRENT;
4526 } else if (strncmp("forbidden", str, 9) == 0) {
4527 return (int) OperatorStatus::FORBIDDEN;
4533 int radio::getAvailableNetworksResponse(int slotId,
4534 int responseType, int serial, RIL_Errno e, void *response,
4535 size_t responseLen) {
4537 RLOGD("getAvailableNetworksResponse: serial %d", serial);
4540 if (radioService[slotId]->mRadioResponse != NULL) {
4541 RadioResponseInfo responseInfo = {};
4542 populateResponseInfo(responseInfo, serial, responseType, e);
4543 hidl_vec<OperatorInfo> networks;
4544 if ((response == NULL && responseLen != 0)
4545 || responseLen % (4 * sizeof(char *))!= 0) {
4546 RLOGE("getAvailableNetworksResponse Invalid response: NULL");
4547 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4549 char **resp = (char **) response;
4550 int numStrings = responseLen / sizeof(char *);
4551 networks.resize(numStrings/4);
4552 for (int i = 0, j = 0; i < numStrings; i = i + 4, j++) {
4553 networks[j].alphaLong = convertCharPtrToHidlString(resp[i]);
4554 networks[j].alphaShort = convertCharPtrToHidlString(resp[i + 1]);
4555 networks[j].operatorNumeric = convertCharPtrToHidlString(resp[i + 2]);
4556 int status = convertOperatorStatusToInt(resp[i + 3]);
4558 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4560 networks[j].status = (OperatorStatus) status;
4564 Return<void> retStatus
4565 = radioService[slotId]->mRadioResponse->getAvailableNetworksResponse(responseInfo,
4567 radioService[slotId]->checkReturnStatus(retStatus);
4569 RLOGE("getAvailableNetworksResponse: radioService[%d]->mRadioResponse == NULL",
4576 int radio::startDtmfResponse(int slotId,
4577 int responseType, int serial, RIL_Errno e,
4578 void *response, size_t responseLen) {
4580 RLOGD("startDtmfResponse: serial %d", serial);
4583 if (radioService[slotId]->mRadioResponse != NULL) {
4584 RadioResponseInfo responseInfo = {};
4585 populateResponseInfo(responseInfo, serial, responseType, e);
4586 Return<void> retStatus
4587 = radioService[slotId]->mRadioResponse->startDtmfResponse(responseInfo);
4588 radioService[slotId]->checkReturnStatus(retStatus);
4590 RLOGE("startDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4596 int radio::stopDtmfResponse(int slotId,
4597 int responseType, int serial, RIL_Errno e,
4598 void *response, size_t responseLen) {
4600 RLOGD("stopDtmfResponse: serial %d", serial);
4603 if (radioService[slotId]->mRadioResponse != NULL) {
4604 RadioResponseInfo responseInfo = {};
4605 populateResponseInfo(responseInfo, serial, responseType, e);
4606 Return<void> retStatus
4607 = radioService[slotId]->mRadioResponse->stopDtmfResponse(responseInfo);
4608 radioService[slotId]->checkReturnStatus(retStatus);
4610 RLOGE("stopDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4616 int radio::getBasebandVersionResponse(int slotId,
4617 int responseType, int serial, RIL_Errno e,
4618 void *response, size_t responseLen) {
4620 RLOGD("getBasebandVersionResponse: serial %d", serial);
4623 if (radioService[slotId]->mRadioResponse != NULL) {
4624 RadioResponseInfo responseInfo = {};
4625 populateResponseInfo(responseInfo, serial, responseType, e);
4626 Return<void> retStatus
4627 = radioService[slotId]->mRadioResponse->getBasebandVersionResponse(responseInfo,
4628 convertCharPtrToHidlString((char *) response));
4629 radioService[slotId]->checkReturnStatus(retStatus);
4631 RLOGE("getBasebandVersionResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4637 int radio::separateConnectionResponse(int slotId,
4638 int responseType, int serial, RIL_Errno e,
4639 void *response, size_t responseLen) {
4641 RLOGD("separateConnectionResponse: serial %d", serial);
4644 if (radioService[slotId]->mRadioResponse != NULL) {
4645 RadioResponseInfo responseInfo = {};
4646 populateResponseInfo(responseInfo, serial, responseType, e);
4647 Return<void> retStatus
4648 = radioService[slotId]->mRadioResponse->separateConnectionResponse(responseInfo);
4649 radioService[slotId]->checkReturnStatus(retStatus);
4651 RLOGE("separateConnectionResponse: radioService[%d]->mRadioResponse == NULL",
4658 int radio::setMuteResponse(int slotId,
4659 int responseType, int serial, RIL_Errno e,
4660 void *response, size_t responseLen) {
4662 RLOGD("setMuteResponse: serial %d", serial);
4665 if (radioService[slotId]->mRadioResponse != NULL) {
4666 RadioResponseInfo responseInfo = {};
4667 populateResponseInfo(responseInfo, serial, responseType, e);
4668 Return<void> retStatus
4669 = radioService[slotId]->mRadioResponse->setMuteResponse(responseInfo);
4670 radioService[slotId]->checkReturnStatus(retStatus);
4672 RLOGE("setMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4678 int radio::getMuteResponse(int slotId,
4679 int responseType, int serial, RIL_Errno e, void *response,
4680 size_t responseLen) {
4682 RLOGD("getMuteResponse: serial %d", serial);
4685 if (radioService[slotId]->mRadioResponse != NULL) {
4686 RadioResponseInfo responseInfo = {};
4687 populateResponseInfo(responseInfo, serial, responseType, e);
4688 bool enable = false;
4689 if (response == NULL || responseLen != sizeof(int)) {
4690 RLOGE("getMuteResponse Invalid response: NULL");
4691 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4693 int *pInt = (int *) response;
4694 enable = pInt[0] == 1 ? true : false;
4696 Return<void> retStatus = radioService[slotId]->mRadioResponse->getMuteResponse(responseInfo,
4698 radioService[slotId]->checkReturnStatus(retStatus);
4700 RLOGE("getMuteResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4706 int radio::getClipResponse(int slotId,
4707 int responseType, int serial, RIL_Errno e,
4708 void *response, size_t responseLen) {
4710 RLOGD("getClipResponse: serial %d", serial);
4713 if (radioService[slotId]->mRadioResponse != NULL) {
4714 RadioResponseInfo responseInfo = {};
4715 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4716 Return<void> retStatus = radioService[slotId]->mRadioResponse->getClipResponse(responseInfo,
4718 radioService[slotId]->checkReturnStatus(retStatus);
4720 RLOGE("getClipResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4726 int radio::getDataCallListResponse(int slotId,
4727 int responseType, int serial, RIL_Errno e,
4728 void *response, size_t responseLen) {
4730 RLOGD("getDataCallListResponse: serial %d", serial);
4733 if (radioService[slotId]->mRadioResponse != NULL) {
4734 RadioResponseInfo responseInfo = {};
4735 populateResponseInfo(responseInfo, serial, responseType, e);
4737 hidl_vec<SetupDataCallResult> ret;
4738 if ((response == NULL && responseLen != 0)
4739 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
4740 RLOGE("getDataCallListResponse: invalid response");
4741 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4743 convertRilDataCallListToHal(response, responseLen, ret);
4746 Return<void> retStatus = radioService[slotId]->mRadioResponse->getDataCallListResponse(
4748 radioService[slotId]->checkReturnStatus(retStatus);
4750 RLOGE("getDataCallListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4756 int radio::setSuppServiceNotificationsResponse(int slotId,
4757 int responseType, int serial, RIL_Errno e,
4758 void *response, size_t responseLen) {
4760 RLOGD("setSuppServiceNotificationsResponse: serial %d", serial);
4763 if (radioService[slotId]->mRadioResponse != NULL) {
4764 RadioResponseInfo responseInfo = {};
4765 populateResponseInfo(responseInfo, serial, responseType, e);
4766 Return<void> retStatus
4767 = radioService[slotId]->mRadioResponse->setSuppServiceNotificationsResponse(
4769 radioService[slotId]->checkReturnStatus(retStatus);
4771 RLOGE("setSuppServiceNotificationsResponse: radioService[%d]->mRadioResponse "
4778 int radio::deleteSmsOnSimResponse(int slotId,
4779 int responseType, int serial, RIL_Errno e,
4780 void *response, size_t responseLen) {
4782 RLOGD("deleteSmsOnSimResponse: serial %d", serial);
4785 if (radioService[slotId]->mRadioResponse != NULL) {
4786 RadioResponseInfo responseInfo = {};
4787 populateResponseInfo(responseInfo, serial, responseType, e);
4788 Return<void> retStatus
4789 = radioService[slotId]->mRadioResponse->deleteSmsOnSimResponse(responseInfo);
4790 radioService[slotId]->checkReturnStatus(retStatus);
4792 RLOGE("deleteSmsOnSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4798 int radio::setBandModeResponse(int slotId,
4799 int responseType, int serial, RIL_Errno e,
4800 void *response, size_t responseLen) {
4802 RLOGD("setBandModeResponse: serial %d", serial);
4805 if (radioService[slotId]->mRadioResponse != NULL) {
4806 RadioResponseInfo responseInfo = {};
4807 populateResponseInfo(responseInfo, serial, responseType, e);
4808 Return<void> retStatus
4809 = radioService[slotId]->mRadioResponse->setBandModeResponse(responseInfo);
4810 radioService[slotId]->checkReturnStatus(retStatus);
4812 RLOGE("setBandModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4818 int radio::writeSmsToSimResponse(int slotId,
4819 int responseType, int serial, RIL_Errno e,
4820 void *response, size_t responseLen) {
4822 RLOGD("writeSmsToSimResponse: serial %d", serial);
4825 if (radioService[slotId]->mRadioResponse != NULL) {
4826 RadioResponseInfo responseInfo = {};
4827 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4828 Return<void> retStatus
4829 = radioService[slotId]->mRadioResponse->writeSmsToSimResponse(responseInfo, ret);
4830 radioService[slotId]->checkReturnStatus(retStatus);
4832 RLOGE("writeSmsToSimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4838 int radio::getAvailableBandModesResponse(int slotId,
4839 int responseType, int serial, RIL_Errno e, void *response,
4840 size_t responseLen) {
4842 RLOGD("getAvailableBandModesResponse: serial %d", serial);
4845 if (radioService[slotId]->mRadioResponse != NULL) {
4846 RadioResponseInfo responseInfo = {};
4847 populateResponseInfo(responseInfo, serial, responseType, e);
4848 hidl_vec<RadioBandMode> modes;
4849 if ((response == NULL && responseLen != 0)|| responseLen % sizeof(int) != 0) {
4850 RLOGE("getAvailableBandModesResponse Invalid response: NULL");
4851 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
4853 int *pInt = (int *) response;
4854 int numInts = responseLen / sizeof(int);
4855 modes.resize(numInts);
4856 for (int i = 0; i < numInts; i++) {
4857 modes[i] = (RadioBandMode) pInt[i];
4860 Return<void> retStatus
4861 = radioService[slotId]->mRadioResponse->getAvailableBandModesResponse(responseInfo,
4863 radioService[slotId]->checkReturnStatus(retStatus);
4865 RLOGE("getAvailableBandModesResponse: radioService[%d]->mRadioResponse == NULL",
4872 int radio::sendEnvelopeResponse(int slotId,
4873 int responseType, int serial, RIL_Errno e,
4874 void *response, size_t responseLen) {
4876 RLOGD("sendEnvelopeResponse: serial %d", serial);
4879 if (radioService[slotId]->mRadioResponse != NULL) {
4880 RadioResponseInfo responseInfo = {};
4881 populateResponseInfo(responseInfo, serial, responseType, e);
4882 Return<void> retStatus
4883 = radioService[slotId]->mRadioResponse->sendEnvelopeResponse(responseInfo,
4884 convertCharPtrToHidlString((char *) response));
4885 radioService[slotId]->checkReturnStatus(retStatus);
4887 RLOGE("sendEnvelopeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
4893 int radio::sendTerminalResponseToSimResponse(int slotId,
4894 int responseType, int serial, RIL_Errno e,
4895 void *response, size_t responseLen) {
4897 RLOGD("sendTerminalResponseToSimResponse: serial %d", serial);
4900 if (radioService[slotId]->mRadioResponse != NULL) {
4901 RadioResponseInfo responseInfo = {};
4902 populateResponseInfo(responseInfo, serial, responseType, e);
4903 Return<void> retStatus
4904 = radioService[slotId]->mRadioResponse->sendTerminalResponseToSimResponse(
4906 radioService[slotId]->checkReturnStatus(retStatus);
4908 RLOGE("sendTerminalResponseToSimResponse: radioService[%d]->mRadioResponse == NULL",
4915 int radio::handleStkCallSetupRequestFromSimResponse(int slotId,
4916 int responseType, int serial,
4917 RIL_Errno e, void *response,
4918 size_t responseLen) {
4920 RLOGD("handleStkCallSetupRequestFromSimResponse: serial %d", serial);
4923 if (radioService[slotId]->mRadioResponse != NULL) {
4924 RadioResponseInfo responseInfo = {};
4925 populateResponseInfo(responseInfo, serial, responseType, e);
4926 Return<void> retStatus
4927 = radioService[slotId]->mRadioResponse->handleStkCallSetupRequestFromSimResponse(
4929 radioService[slotId]->checkReturnStatus(retStatus);
4931 RLOGE("handleStkCallSetupRequestFromSimResponse: radioService[%d]->mRadioResponse "
4938 int radio::explicitCallTransferResponse(int slotId,
4939 int responseType, int serial, RIL_Errno e,
4940 void *response, size_t responseLen) {
4942 RLOGD("explicitCallTransferResponse: serial %d", serial);
4945 if (radioService[slotId]->mRadioResponse != NULL) {
4946 RadioResponseInfo responseInfo = {};
4947 populateResponseInfo(responseInfo, serial, responseType, e);
4948 Return<void> retStatus
4949 = radioService[slotId]->mRadioResponse->explicitCallTransferResponse(responseInfo);
4950 radioService[slotId]->checkReturnStatus(retStatus);
4952 RLOGE("explicitCallTransferResponse: radioService[%d]->mRadioResponse == NULL",
4959 int radio::setPreferredNetworkTypeResponse(int slotId,
4960 int responseType, int serial, RIL_Errno e,
4961 void *response, size_t responseLen) {
4963 RLOGD("setPreferredNetworkTypeResponse: serial %d", serial);
4966 if (radioService[slotId]->mRadioResponse != NULL) {
4967 RadioResponseInfo responseInfo = {};
4968 populateResponseInfo(responseInfo, serial, responseType, e);
4969 Return<void> retStatus
4970 = radioService[slotId]->mRadioResponse->setPreferredNetworkTypeResponse(
4972 radioService[slotId]->checkReturnStatus(retStatus);
4974 RLOGE("setPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
4982 int radio::getPreferredNetworkTypeResponse(int slotId,
4983 int responseType, int serial, RIL_Errno e,
4984 void *response, size_t responseLen) {
4986 RLOGD("getPreferredNetworkTypeResponse: serial %d", serial);
4989 if (radioService[slotId]->mRadioResponse != NULL) {
4990 RadioResponseInfo responseInfo = {};
4991 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
4992 Return<void> retStatus
4993 = radioService[slotId]->mRadioResponse->getPreferredNetworkTypeResponse(
4994 responseInfo, (PreferredNetworkType) ret);
4995 radioService[slotId]->checkReturnStatus(retStatus);
4997 RLOGE("getPreferredNetworkTypeResponse: radioService[%d]->mRadioResponse == NULL",
5004 int radio::getNeighboringCidsResponse(int slotId,
5005 int responseType, int serial, RIL_Errno e,
5006 void *response, size_t responseLen) {
5008 RLOGD("getNeighboringCidsResponse: serial %d", serial);
5011 if (radioService[slotId]->mRadioResponse != NULL) {
5012 RadioResponseInfo responseInfo = {};
5013 populateResponseInfo(responseInfo, serial, responseType, e);
5014 hidl_vec<NeighboringCell> cells;
5016 if ((response == NULL && responseLen != 0)
5017 || responseLen % sizeof(RIL_NeighboringCell *) != 0) {
5018 RLOGE("getNeighboringCidsResponse Invalid response: NULL");
5019 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5021 int num = responseLen / sizeof(RIL_NeighboringCell *);
5023 for (int i = 0 ; i < num; i++) {
5024 RIL_NeighboringCell *resp = ((RIL_NeighboringCell **) response)[i];
5025 cells[i].cid = convertCharPtrToHidlString(resp->cid);
5026 cells[i].rssi = resp->rssi;
5030 Return<void> retStatus
5031 = radioService[slotId]->mRadioResponse->getNeighboringCidsResponse(responseInfo,
5033 radioService[slotId]->checkReturnStatus(retStatus);
5035 RLOGE("getNeighboringCidsResponse: radioService[%d]->mRadioResponse == NULL",
5042 int radio::setLocationUpdatesResponse(int slotId,
5043 int responseType, int serial, RIL_Errno e,
5044 void *response, size_t responseLen) {
5046 RLOGD("setLocationUpdatesResponse: serial %d", serial);
5049 if (radioService[slotId]->mRadioResponse != NULL) {
5050 RadioResponseInfo responseInfo = {};
5051 populateResponseInfo(responseInfo, serial, responseType, e);
5052 Return<void> retStatus
5053 = radioService[slotId]->mRadioResponse->setLocationUpdatesResponse(responseInfo);
5054 radioService[slotId]->checkReturnStatus(retStatus);
5056 RLOGE("setLocationUpdatesResponse: radioService[%d]->mRadioResponse == NULL",
5063 int radio::setCdmaSubscriptionSourceResponse(int slotId,
5064 int responseType, int serial, RIL_Errno e,
5065 void *response, size_t responseLen) {
5067 RLOGD("setCdmaSubscriptionSourceResponse: serial %d", serial);
5070 if (radioService[slotId]->mRadioResponse != NULL) {
5071 RadioResponseInfo responseInfo = {};
5072 populateResponseInfo(responseInfo, serial, responseType, e);
5073 Return<void> retStatus
5074 = radioService[slotId]->mRadioResponse->setCdmaSubscriptionSourceResponse(
5076 radioService[slotId]->checkReturnStatus(retStatus);
5078 RLOGE("setCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5085 int radio::setCdmaRoamingPreferenceResponse(int slotId,
5086 int responseType, int serial, RIL_Errno e,
5087 void *response, size_t responseLen) {
5089 RLOGD("setCdmaRoamingPreferenceResponse: serial %d", serial);
5092 if (radioService[slotId]->mRadioResponse != NULL) {
5093 RadioResponseInfo responseInfo = {};
5094 populateResponseInfo(responseInfo, serial, responseType, e);
5095 Return<void> retStatus
5096 = radioService[slotId]->mRadioResponse->setCdmaRoamingPreferenceResponse(
5098 radioService[slotId]->checkReturnStatus(retStatus);
5100 RLOGE("setCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5107 int radio::getCdmaRoamingPreferenceResponse(int slotId,
5108 int responseType, int serial, RIL_Errno e,
5109 void *response, size_t responseLen) {
5111 RLOGD("getCdmaRoamingPreferenceResponse: serial %d", serial);
5114 if (radioService[slotId]->mRadioResponse != NULL) {
5115 RadioResponseInfo responseInfo = {};
5116 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5117 Return<void> retStatus
5118 = radioService[slotId]->mRadioResponse->getCdmaRoamingPreferenceResponse(
5119 responseInfo, (CdmaRoamingType) ret);
5120 radioService[slotId]->checkReturnStatus(retStatus);
5122 RLOGE("getCdmaRoamingPreferenceResponse: radioService[%d]->mRadioResponse == NULL",
5129 int radio::setTTYModeResponse(int slotId,
5130 int responseType, int serial, RIL_Errno e,
5131 void *response, size_t responseLen) {
5133 RLOGD("setTTYModeResponse: serial %d", serial);
5136 if (radioService[slotId]->mRadioResponse != NULL) {
5137 RadioResponseInfo responseInfo = {};
5138 populateResponseInfo(responseInfo, serial, responseType, e);
5139 Return<void> retStatus
5140 = radioService[slotId]->mRadioResponse->setTTYModeResponse(responseInfo);
5141 radioService[slotId]->checkReturnStatus(retStatus);
5143 RLOGE("setTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5149 int radio::getTTYModeResponse(int slotId,
5150 int responseType, int serial, RIL_Errno e,
5151 void *response, size_t responseLen) {
5153 RLOGD("getTTYModeResponse: serial %d", serial);
5156 if (radioService[slotId]->mRadioResponse != NULL) {
5157 RadioResponseInfo responseInfo = {};
5158 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5159 Return<void> retStatus
5160 = radioService[slotId]->mRadioResponse->getTTYModeResponse(responseInfo,
5162 radioService[slotId]->checkReturnStatus(retStatus);
5164 RLOGE("getTTYModeResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5170 int radio::setPreferredVoicePrivacyResponse(int slotId,
5171 int responseType, int serial, RIL_Errno e,
5172 void *response, size_t responseLen) {
5174 RLOGD("setPreferredVoicePrivacyResponse: serial %d", serial);
5177 if (radioService[slotId]->mRadioResponse != NULL) {
5178 RadioResponseInfo responseInfo = {};
5179 populateResponseInfo(responseInfo, serial, responseType, e);
5180 Return<void> retStatus
5181 = radioService[slotId]->mRadioResponse->setPreferredVoicePrivacyResponse(
5183 radioService[slotId]->checkReturnStatus(retStatus);
5185 RLOGE("setPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5192 int radio::getPreferredVoicePrivacyResponse(int slotId,
5193 int responseType, int serial, RIL_Errno e,
5194 void *response, size_t responseLen) {
5196 RLOGD("getPreferredVoicePrivacyResponse: serial %d", serial);
5199 if (radioService[slotId]->mRadioResponse != NULL) {
5200 RadioResponseInfo responseInfo = {};
5201 populateResponseInfo(responseInfo, serial, responseType, e);
5202 bool enable = false;
5203 int numInts = responseLen / sizeof(int);
5204 if (response == NULL || numInts != 1) {
5205 RLOGE("getPreferredVoicePrivacyResponse Invalid response: NULL");
5206 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5208 int *pInt = (int *) response;
5209 enable = pInt[0] == 1 ? true : false;
5211 Return<void> retStatus
5212 = radioService[slotId]->mRadioResponse->getPreferredVoicePrivacyResponse(
5213 responseInfo, enable);
5214 radioService[slotId]->checkReturnStatus(retStatus);
5216 RLOGE("getPreferredVoicePrivacyResponse: radioService[%d]->mRadioResponse == NULL",
5223 int radio::sendCDMAFeatureCodeResponse(int slotId,
5224 int responseType, int serial, RIL_Errno e,
5225 void *response, size_t responseLen) {
5227 RLOGD("sendCDMAFeatureCodeResponse: serial %d", serial);
5230 if (radioService[slotId]->mRadioResponse != NULL) {
5231 RadioResponseInfo responseInfo = {};
5232 populateResponseInfo(responseInfo, serial, responseType, e);
5233 Return<void> retStatus
5234 = radioService[slotId]->mRadioResponse->sendCDMAFeatureCodeResponse(responseInfo);
5235 radioService[slotId]->checkReturnStatus(retStatus);
5237 RLOGE("sendCDMAFeatureCodeResponse: radioService[%d]->mRadioResponse == NULL",
5244 int radio::sendBurstDtmfResponse(int slotId,
5245 int responseType, int serial, RIL_Errno e,
5246 void *response, size_t responseLen) {
5248 RLOGD("sendBurstDtmfResponse: serial %d", serial);
5251 if (radioService[slotId]->mRadioResponse != NULL) {
5252 RadioResponseInfo responseInfo = {};
5253 populateResponseInfo(responseInfo, serial, responseType, e);
5254 Return<void> retStatus
5255 = radioService[slotId]->mRadioResponse->sendBurstDtmfResponse(responseInfo);
5256 radioService[slotId]->checkReturnStatus(retStatus);
5258 RLOGE("sendBurstDtmfResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5264 int radio::sendCdmaSmsResponse(int slotId,
5265 int responseType, int serial, RIL_Errno e, void *response,
5266 size_t responseLen) {
5268 RLOGD("sendCdmaSmsResponse: serial %d", serial);
5271 if (radioService[slotId]->mRadioResponse != NULL) {
5272 RadioResponseInfo responseInfo = {};
5273 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5276 Return<void> retStatus
5277 = radioService[slotId]->mRadioResponse->sendCdmaSmsResponse(responseInfo, result);
5278 radioService[slotId]->checkReturnStatus(retStatus);
5280 RLOGE("sendCdmaSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5286 int radio::acknowledgeLastIncomingCdmaSmsResponse(int slotId,
5287 int responseType, int serial, RIL_Errno e,
5288 void *response, size_t responseLen) {
5290 RLOGD("acknowledgeLastIncomingCdmaSmsResponse: serial %d", serial);
5293 if (radioService[slotId]->mRadioResponse != NULL) {
5294 RadioResponseInfo responseInfo = {};
5295 populateResponseInfo(responseInfo, serial, responseType, e);
5296 Return<void> retStatus
5297 = radioService[slotId]->mRadioResponse->acknowledgeLastIncomingCdmaSmsResponse(
5299 radioService[slotId]->checkReturnStatus(retStatus);
5301 RLOGE("acknowledgeLastIncomingCdmaSmsResponse: radioService[%d]->mRadioResponse "
5308 int radio::getGsmBroadcastConfigResponse(int slotId,
5309 int responseType, int serial, RIL_Errno e,
5310 void *response, size_t responseLen) {
5312 RLOGD("getGsmBroadcastConfigResponse: serial %d", serial);
5315 if (radioService[slotId]->mRadioResponse != NULL) {
5316 RadioResponseInfo responseInfo = {};
5317 populateResponseInfo(responseInfo, serial, responseType, e);
5318 hidl_vec<GsmBroadcastSmsConfigInfo> configs;
5320 if ((response == NULL && responseLen != 0)
5321 || responseLen % sizeof(RIL_GSM_BroadcastSmsConfigInfo *) != 0) {
5322 RLOGE("getGsmBroadcastConfigResponse Invalid response: NULL");
5323 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5325 int num = responseLen / sizeof(RIL_GSM_BroadcastSmsConfigInfo *);
5326 configs.resize(num);
5327 for (int i = 0 ; i < num; i++) {
5328 RIL_GSM_BroadcastSmsConfigInfo *resp =
5329 ((RIL_GSM_BroadcastSmsConfigInfo **) response)[i];
5330 configs[i].fromServiceId = resp->fromServiceId;
5331 configs[i].toServiceId = resp->toServiceId;
5332 configs[i].fromCodeScheme = resp->fromCodeScheme;
5333 configs[i].toCodeScheme = resp->toCodeScheme;
5334 configs[i].selected = resp->selected == 1 ? true : false;
5338 Return<void> retStatus
5339 = radioService[slotId]->mRadioResponse->getGsmBroadcastConfigResponse(responseInfo,
5341 radioService[slotId]->checkReturnStatus(retStatus);
5343 RLOGE("getGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5350 int radio::setGsmBroadcastConfigResponse(int slotId,
5351 int responseType, int serial, RIL_Errno e,
5352 void *response, size_t responseLen) {
5354 RLOGD("setGsmBroadcastConfigResponse: serial %d", serial);
5357 if (radioService[slotId]->mRadioResponse != NULL) {
5358 RadioResponseInfo responseInfo = {};
5359 populateResponseInfo(responseInfo, serial, responseType, e);
5360 Return<void> retStatus
5361 = radioService[slotId]->mRadioResponse->setGsmBroadcastConfigResponse(responseInfo);
5362 radioService[slotId]->checkReturnStatus(retStatus);
5364 RLOGE("setGsmBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5371 int radio::setGsmBroadcastActivationResponse(int slotId,
5372 int responseType, int serial, RIL_Errno e,
5373 void *response, size_t responseLen) {
5375 RLOGD("setGsmBroadcastActivationResponse: serial %d", serial);
5378 if (radioService[slotId]->mRadioResponse != NULL) {
5379 RadioResponseInfo responseInfo = {};
5380 populateResponseInfo(responseInfo, serial, responseType, e);
5381 Return<void> retStatus
5382 = radioService[slotId]->mRadioResponse->setGsmBroadcastActivationResponse(
5384 radioService[slotId]->checkReturnStatus(retStatus);
5386 RLOGE("setGsmBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5393 int radio::getCdmaBroadcastConfigResponse(int slotId,
5394 int responseType, int serial, RIL_Errno e,
5395 void *response, size_t responseLen) {
5397 RLOGD("getCdmaBroadcastConfigResponse: serial %d", serial);
5400 if (radioService[slotId]->mRadioResponse != NULL) {
5401 RadioResponseInfo responseInfo = {};
5402 populateResponseInfo(responseInfo, serial, responseType, e);
5403 hidl_vec<CdmaBroadcastSmsConfigInfo> configs;
5405 if ((response == NULL && responseLen != 0)
5406 || responseLen % sizeof(RIL_CDMA_BroadcastSmsConfigInfo *) != 0) {
5407 RLOGE("getCdmaBroadcastConfigResponse Invalid response: NULL");
5408 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5410 int num = responseLen / sizeof(RIL_CDMA_BroadcastSmsConfigInfo *);
5411 configs.resize(num);
5412 for (int i = 0 ; i < num; i++) {
5413 RIL_CDMA_BroadcastSmsConfigInfo *resp =
5414 ((RIL_CDMA_BroadcastSmsConfigInfo **) response)[i];
5415 configs[i].serviceCategory = resp->service_category;
5416 configs[i].language = resp->language;
5417 configs[i].selected = resp->selected == 1 ? true : false;
5421 Return<void> retStatus
5422 = radioService[slotId]->mRadioResponse->getCdmaBroadcastConfigResponse(responseInfo,
5424 radioService[slotId]->checkReturnStatus(retStatus);
5426 RLOGE("getCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5433 int radio::setCdmaBroadcastConfigResponse(int slotId,
5434 int responseType, int serial, RIL_Errno e,
5435 void *response, size_t responseLen) {
5437 RLOGD("setCdmaBroadcastConfigResponse: serial %d", serial);
5440 if (radioService[slotId]->mRadioResponse != NULL) {
5441 RadioResponseInfo responseInfo = {};
5442 populateResponseInfo(responseInfo, serial, responseType, e);
5443 Return<void> retStatus
5444 = radioService[slotId]->mRadioResponse->setCdmaBroadcastConfigResponse(
5446 radioService[slotId]->checkReturnStatus(retStatus);
5448 RLOGE("setCdmaBroadcastConfigResponse: radioService[%d]->mRadioResponse == NULL",
5455 int radio::setCdmaBroadcastActivationResponse(int slotId,
5456 int responseType, int serial, RIL_Errno e,
5457 void *response, size_t responseLen) {
5459 RLOGD("setCdmaBroadcastActivationResponse: serial %d", serial);
5462 if (radioService[slotId]->mRadioResponse != NULL) {
5463 RadioResponseInfo responseInfo = {};
5464 populateResponseInfo(responseInfo, serial, responseType, e);
5465 Return<void> retStatus
5466 = radioService[slotId]->mRadioResponse->setCdmaBroadcastActivationResponse(
5468 radioService[slotId]->checkReturnStatus(retStatus);
5470 RLOGE("setCdmaBroadcastActivationResponse: radioService[%d]->mRadioResponse == NULL",
5477 int radio::getCDMASubscriptionResponse(int slotId,
5478 int responseType, int serial, RIL_Errno e, void *response,
5479 size_t responseLen) {
5481 RLOGD("getCDMASubscriptionResponse: serial %d", serial);
5484 if (radioService[slotId]->mRadioResponse != NULL) {
5485 RadioResponseInfo responseInfo = {};
5486 populateResponseInfo(responseInfo, serial, responseType, e);
5488 int numStrings = responseLen / sizeof(char *);
5489 hidl_string emptyString;
5490 if (response == NULL || numStrings != 5) {
5491 RLOGE("getOperatorResponse Invalid response: NULL");
5492 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5493 Return<void> retStatus
5494 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5495 responseInfo, emptyString, emptyString, emptyString, emptyString, emptyString);
5496 radioService[slotId]->checkReturnStatus(retStatus);
5498 char **resp = (char **) response;
5499 Return<void> retStatus
5500 = radioService[slotId]->mRadioResponse->getCDMASubscriptionResponse(
5502 convertCharPtrToHidlString(resp[0]),
5503 convertCharPtrToHidlString(resp[1]),
5504 convertCharPtrToHidlString(resp[2]),
5505 convertCharPtrToHidlString(resp[3]),
5506 convertCharPtrToHidlString(resp[4]));
5507 radioService[slotId]->checkReturnStatus(retStatus);
5510 RLOGE("getCDMASubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
5517 int radio::writeSmsToRuimResponse(int slotId,
5518 int responseType, int serial, RIL_Errno e,
5519 void *response, size_t responseLen) {
5521 RLOGD("writeSmsToRuimResponse: serial %d", serial);
5524 if (radioService[slotId]->mRadioResponse != NULL) {
5525 RadioResponseInfo responseInfo = {};
5526 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5527 Return<void> retStatus
5528 = radioService[slotId]->mRadioResponse->writeSmsToRuimResponse(responseInfo, ret);
5529 radioService[slotId]->checkReturnStatus(retStatus);
5531 RLOGE("writeSmsToRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5537 int radio::deleteSmsOnRuimResponse(int slotId,
5538 int responseType, int serial, RIL_Errno e,
5539 void *response, size_t responseLen) {
5541 RLOGD("deleteSmsOnRuimResponse: serial %d", serial);
5544 if (radioService[slotId]->mRadioResponse != NULL) {
5545 RadioResponseInfo responseInfo = {};
5546 populateResponseInfo(responseInfo, serial, responseType, e);
5547 Return<void> retStatus
5548 = radioService[slotId]->mRadioResponse->deleteSmsOnRuimResponse(responseInfo);
5549 radioService[slotId]->checkReturnStatus(retStatus);
5551 RLOGE("deleteSmsOnRuimResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5557 int radio::getDeviceIdentityResponse(int slotId,
5558 int responseType, int serial, RIL_Errno e, void *response,
5559 size_t responseLen) {
5561 RLOGD("getDeviceIdentityResponse: serial %d", serial);
5564 if (radioService[slotId]->mRadioResponse != NULL) {
5565 RadioResponseInfo responseInfo = {};
5566 populateResponseInfo(responseInfo, serial, responseType, e);
5568 int numStrings = responseLen / sizeof(char *);
5569 hidl_string emptyString;
5570 if (response == NULL || numStrings != 4) {
5571 RLOGE("getDeviceIdentityResponse Invalid response: NULL");
5572 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5573 Return<void> retStatus
5574 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5575 emptyString, emptyString, emptyString, emptyString);
5576 radioService[slotId]->checkReturnStatus(retStatus);
5578 char **resp = (char **) response;
5579 Return<void> retStatus
5580 = radioService[slotId]->mRadioResponse->getDeviceIdentityResponse(responseInfo,
5581 convertCharPtrToHidlString(resp[0]),
5582 convertCharPtrToHidlString(resp[1]),
5583 convertCharPtrToHidlString(resp[2]),
5584 convertCharPtrToHidlString(resp[3]));
5585 radioService[slotId]->checkReturnStatus(retStatus);
5588 RLOGE("getDeviceIdentityResponse: radioService[%d]->mRadioResponse == NULL",
5595 int radio::exitEmergencyCallbackModeResponse(int slotId,
5596 int responseType, int serial, RIL_Errno e,
5597 void *response, size_t responseLen) {
5599 RLOGD("exitEmergencyCallbackModeResponse: serial %d", serial);
5602 if (radioService[slotId]->mRadioResponse != NULL) {
5603 RadioResponseInfo responseInfo = {};
5604 populateResponseInfo(responseInfo, serial, responseType, e);
5605 Return<void> retStatus
5606 = radioService[slotId]->mRadioResponse->exitEmergencyCallbackModeResponse(
5608 radioService[slotId]->checkReturnStatus(retStatus);
5610 RLOGE("exitEmergencyCallbackModeResponse: radioService[%d]->mRadioResponse == NULL",
5617 int radio::getSmscAddressResponse(int slotId,
5618 int responseType, int serial, RIL_Errno e,
5619 void *response, size_t responseLen) {
5621 RLOGD("getSmscAddressResponse: serial %d", serial);
5624 if (radioService[slotId]->mRadioResponse != NULL) {
5625 RadioResponseInfo responseInfo = {};
5626 populateResponseInfo(responseInfo, serial, responseType, e);
5627 Return<void> retStatus
5628 = radioService[slotId]->mRadioResponse->getSmscAddressResponse(responseInfo,
5629 convertCharPtrToHidlString((char *) response));
5630 radioService[slotId]->checkReturnStatus(retStatus);
5632 RLOGE("getSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5638 int radio::setSmscAddressResponse(int slotId,
5639 int responseType, int serial, RIL_Errno e,
5640 void *response, size_t responseLen) {
5642 RLOGD("setSmscAddressResponse: serial %d", serial);
5645 if (radioService[slotId]->mRadioResponse != NULL) {
5646 RadioResponseInfo responseInfo = {};
5647 populateResponseInfo(responseInfo, serial, responseType, e);
5648 Return<void> retStatus
5649 = radioService[slotId]->mRadioResponse->setSmscAddressResponse(responseInfo);
5650 radioService[slotId]->checkReturnStatus(retStatus);
5652 RLOGE("setSmscAddressResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5658 int radio::reportSmsMemoryStatusResponse(int slotId,
5659 int responseType, int serial, RIL_Errno e,
5660 void *response, size_t responseLen) {
5662 RLOGD("reportSmsMemoryStatusResponse: serial %d", serial);
5665 if (radioService[slotId]->mRadioResponse != NULL) {
5666 RadioResponseInfo responseInfo = {};
5667 populateResponseInfo(responseInfo, serial, responseType, e);
5668 Return<void> retStatus
5669 = radioService[slotId]->mRadioResponse->reportSmsMemoryStatusResponse(responseInfo);
5670 radioService[slotId]->checkReturnStatus(retStatus);
5672 RLOGE("reportSmsMemoryStatusResponse: radioService[%d]->mRadioResponse == NULL",
5679 int radio::reportStkServiceIsRunningResponse(int slotId,
5680 int responseType, int serial, RIL_Errno e,
5681 void *response, size_t responseLen) {
5683 RLOGD("reportStkServiceIsRunningResponse: serial %d", serial);
5686 if (radioService[slotId]->mRadioResponse != NULL) {
5687 RadioResponseInfo responseInfo = {};
5688 populateResponseInfo(responseInfo, serial, responseType, e);
5689 Return<void> retStatus = radioService[slotId]->mRadioResponse->
5690 reportStkServiceIsRunningResponse(responseInfo);
5691 radioService[slotId]->checkReturnStatus(retStatus);
5693 RLOGE("reportStkServiceIsRunningResponse: radioService[%d]->mRadioResponse == NULL",
5700 int radio::getCdmaSubscriptionSourceResponse(int slotId,
5701 int responseType, int serial, RIL_Errno e,
5702 void *response, size_t responseLen) {
5704 RLOGD("getCdmaSubscriptionSourceResponse: serial %d", serial);
5707 if (radioService[slotId]->mRadioResponse != NULL) {
5708 RadioResponseInfo responseInfo = {};
5709 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5710 Return<void> retStatus
5711 = radioService[slotId]->mRadioResponse->getCdmaSubscriptionSourceResponse(
5712 responseInfo, (CdmaSubscriptionSource) ret);
5713 radioService[slotId]->checkReturnStatus(retStatus);
5715 RLOGE("getCdmaSubscriptionSourceResponse: radioService[%d]->mRadioResponse == NULL",
5722 int radio::requestIsimAuthenticationResponse(int slotId,
5723 int responseType, int serial, RIL_Errno e,
5724 void *response, size_t responseLen) {
5726 RLOGD("requestIsimAuthenticationResponse: serial %d", serial);
5729 if (radioService[slotId]->mRadioResponse != NULL) {
5730 RadioResponseInfo responseInfo = {};
5731 populateResponseInfo(responseInfo, serial, responseType, e);
5732 Return<void> retStatus
5733 = radioService[slotId]->mRadioResponse->requestIsimAuthenticationResponse(
5735 convertCharPtrToHidlString((char *) response));
5736 radioService[slotId]->checkReturnStatus(retStatus);
5738 RLOGE("requestIsimAuthenticationResponse: radioService[%d]->mRadioResponse == NULL",
5745 int radio::acknowledgeIncomingGsmSmsWithPduResponse(int slotId,
5747 int serial, RIL_Errno e, void *response,
5748 size_t responseLen) {
5750 RLOGD("acknowledgeIncomingGsmSmsWithPduResponse: serial %d", serial);
5753 if (radioService[slotId]->mRadioResponse != NULL) {
5754 RadioResponseInfo responseInfo = {};
5755 populateResponseInfo(responseInfo, serial, responseType, e);
5756 Return<void> retStatus
5757 = radioService[slotId]->mRadioResponse->acknowledgeIncomingGsmSmsWithPduResponse(
5759 radioService[slotId]->checkReturnStatus(retStatus);
5761 RLOGE("acknowledgeIncomingGsmSmsWithPduResponse: radioService[%d]->mRadioResponse "
5768 int radio::sendEnvelopeWithStatusResponse(int slotId,
5769 int responseType, int serial, RIL_Errno e, void *response,
5770 size_t responseLen) {
5772 RLOGD("sendEnvelopeWithStatusResponse: serial %d", serial);
5775 if (radioService[slotId]->mRadioResponse != NULL) {
5776 RadioResponseInfo responseInfo = {};
5777 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e,
5778 response, responseLen);
5780 Return<void> retStatus
5781 = radioService[slotId]->mRadioResponse->sendEnvelopeWithStatusResponse(responseInfo,
5783 radioService[slotId]->checkReturnStatus(retStatus);
5785 RLOGE("sendEnvelopeWithStatusResponse: radioService[%d]->mRadioResponse == NULL",
5792 int radio::getVoiceRadioTechnologyResponse(int slotId,
5793 int responseType, int serial, RIL_Errno e,
5794 void *response, size_t responseLen) {
5796 RLOGD("getVoiceRadioTechnologyResponse: serial %d", serial);
5799 if (radioService[slotId]->mRadioResponse != NULL) {
5800 RadioResponseInfo responseInfo = {};
5801 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
5802 Return<void> retStatus
5803 = radioService[slotId]->mRadioResponse->getVoiceRadioTechnologyResponse(
5804 responseInfo, (RadioTechnology) ret);
5805 radioService[slotId]->checkReturnStatus(retStatus);
5807 RLOGE("getVoiceRadioTechnologyResponse: radioService[%d]->mRadioResponse == NULL",
5814 int radio::getCellInfoListResponse(int slotId,
5816 int serial, RIL_Errno e, void *response,
5817 size_t responseLen) {
5819 RLOGD("getCellInfoListResponse: serial %d", serial);
5822 if (radioService[slotId]->mRadioResponse != NULL) {
5823 RadioResponseInfo responseInfo = {};
5824 populateResponseInfo(responseInfo, serial, responseType, e);
5826 hidl_vec<CellInfo> ret;
5827 if ((response == NULL && responseLen != 0)
5828 || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
5829 RLOGE("getCellInfoListResponse: Invalid response");
5830 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5832 convertRilCellInfoListToHal(response, responseLen, ret);
5835 Return<void> retStatus = radioService[slotId]->mRadioResponse->getCellInfoListResponse(
5837 radioService[slotId]->checkReturnStatus(retStatus);
5839 RLOGE("getCellInfoListResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5845 int radio::setCellInfoListRateResponse(int slotId,
5847 int serial, RIL_Errno e, void *response,
5848 size_t responseLen) {
5850 RLOGD("setCellInfoListRateResponse: serial %d", serial);
5853 if (radioService[slotId]->mRadioResponse != NULL) {
5854 RadioResponseInfo responseInfo = {};
5855 populateResponseInfo(responseInfo, serial, responseType, e);
5856 Return<void> retStatus
5857 = radioService[slotId]->mRadioResponse->setCellInfoListRateResponse(responseInfo);
5858 radioService[slotId]->checkReturnStatus(retStatus);
5860 RLOGE("setCellInfoListRateResponse: radioService[%d]->mRadioResponse == NULL",
5867 int radio::setInitialAttachApnResponse(int slotId,
5868 int responseType, int serial, RIL_Errno e,
5869 void *response, size_t responseLen) {
5871 RLOGD("setInitialAttachApnResponse: serial %d", serial);
5874 if (radioService[slotId]->mRadioResponse != NULL) {
5875 RadioResponseInfo responseInfo = {};
5876 populateResponseInfo(responseInfo, serial, responseType, e);
5877 Return<void> retStatus
5878 = radioService[slotId]->mRadioResponse->setInitialAttachApnResponse(responseInfo);
5879 radioService[slotId]->checkReturnStatus(retStatus);
5881 RLOGE("setInitialAttachApnResponse: radioService[%d]->mRadioResponse == NULL",
5888 int radio::getImsRegistrationStateResponse(int slotId,
5889 int responseType, int serial, RIL_Errno e,
5890 void *response, size_t responseLen) {
5892 RLOGD("getImsRegistrationStateResponse: serial %d", serial);
5895 if (radioService[slotId]->mRadioResponse != NULL) {
5896 RadioResponseInfo responseInfo = {};
5897 populateResponseInfo(responseInfo, serial, responseType, e);
5898 bool isRegistered = false;
5900 int numInts = responseLen / sizeof(int);
5901 if (response == NULL || numInts != 2) {
5902 RLOGE("getImsRegistrationStateResponse Invalid response: NULL");
5903 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5905 int *pInt = (int *) response;
5906 isRegistered = pInt[0] == 1 ? true : false;
5907 ratFamily = pInt[1];
5909 Return<void> retStatus
5910 = radioService[slotId]->mRadioResponse->getImsRegistrationStateResponse(
5911 responseInfo, isRegistered, (RadioTechnologyFamily) ratFamily);
5912 radioService[slotId]->checkReturnStatus(retStatus);
5914 RLOGE("getImsRegistrationStateResponse: radioService[%d]->mRadioResponse == NULL",
5921 int radio::sendImsSmsResponse(int slotId,
5922 int responseType, int serial, RIL_Errno e, void *response,
5923 size_t responseLen) {
5925 RLOGD("sendImsSmsResponse: serial %d", serial);
5928 if (radioService[slotId]->mRadioResponse != NULL) {
5929 RadioResponseInfo responseInfo = {};
5930 SendSmsResult result = makeSendSmsResult(responseInfo, serial, responseType, e, response,
5933 Return<void> retStatus
5934 = radioService[slotId]->mRadioResponse->sendImsSmsResponse(responseInfo, result);
5935 radioService[slotId]->checkReturnStatus(retStatus);
5937 RLOGE("sendSmsResponse: radioService[%d]->mRadioResponse == NULL", slotId);
5943 int radio::iccTransmitApduBasicChannelResponse(int slotId,
5944 int responseType, int serial, RIL_Errno e,
5945 void *response, size_t responseLen) {
5947 RLOGD("iccTransmitApduBasicChannelResponse: serial %d", serial);
5950 if (radioService[slotId]->mRadioResponse != NULL) {
5951 RadioResponseInfo responseInfo = {};
5952 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
5955 Return<void> retStatus
5956 = radioService[slotId]->mRadioResponse->iccTransmitApduBasicChannelResponse(
5957 responseInfo, result);
5958 radioService[slotId]->checkReturnStatus(retStatus);
5960 RLOGE("iccTransmitApduBasicChannelResponse: radioService[%d]->mRadioResponse "
5967 int radio::iccOpenLogicalChannelResponse(int slotId,
5968 int responseType, int serial, RIL_Errno e, void *response,
5969 size_t responseLen) {
5971 RLOGD("iccOpenLogicalChannelResponse: serial %d", serial);
5974 if (radioService[slotId]->mRadioResponse != NULL) {
5975 RadioResponseInfo responseInfo = {};
5976 populateResponseInfo(responseInfo, serial, responseType, e);
5978 hidl_vec<int8_t> selectResponse;
5979 int numInts = responseLen / sizeof(int);
5980 if (response == NULL || responseLen % sizeof(int) != 0) {
5981 RLOGE("iccOpenLogicalChannelResponse Invalid response: NULL");
5982 if (response != NULL) {
5983 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
5986 int *pInt = (int *) response;
5987 channelId = pInt[0];
5988 selectResponse.resize(numInts - 1);
5989 for (int i = 1; i < numInts; i++) {
5990 selectResponse[i - 1] = (int8_t) pInt[i];
5993 Return<void> retStatus
5994 = radioService[slotId]->mRadioResponse->iccOpenLogicalChannelResponse(responseInfo,
5995 channelId, selectResponse);
5996 radioService[slotId]->checkReturnStatus(retStatus);
5998 RLOGE("iccOpenLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
6005 int radio::iccCloseLogicalChannelResponse(int slotId,
6006 int responseType, int serial, RIL_Errno e,
6007 void *response, size_t responseLen) {
6009 RLOGD("iccCloseLogicalChannelResponse: serial %d", serial);
6012 if (radioService[slotId]->mRadioResponse != NULL) {
6013 RadioResponseInfo responseInfo = {};
6014 populateResponseInfo(responseInfo, serial, responseType, e);
6015 Return<void> retStatus
6016 = radioService[slotId]->mRadioResponse->iccCloseLogicalChannelResponse(
6018 radioService[slotId]->checkReturnStatus(retStatus);
6020 RLOGE("iccCloseLogicalChannelResponse: radioService[%d]->mRadioResponse == NULL",
6027 int radio::iccTransmitApduLogicalChannelResponse(int slotId,
6028 int responseType, int serial, RIL_Errno e,
6029 void *response, size_t responseLen) {
6031 RLOGD("iccTransmitApduLogicalChannelResponse: serial %d", serial);
6034 if (radioService[slotId]->mRadioResponse != NULL) {
6035 RadioResponseInfo responseInfo = {};
6036 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6039 Return<void> retStatus
6040 = radioService[slotId]->mRadioResponse->iccTransmitApduLogicalChannelResponse(
6041 responseInfo, result);
6042 radioService[slotId]->checkReturnStatus(retStatus);
6044 RLOGE("iccTransmitApduLogicalChannelResponse: radioService[%d]->mRadioResponse "
6051 int radio::nvReadItemResponse(int slotId,
6052 int responseType, int serial, RIL_Errno e,
6053 void *response, size_t responseLen) {
6055 RLOGD("nvReadItemResponse: serial %d", serial);
6058 if (radioService[slotId]->mRadioResponse != NULL) {
6059 RadioResponseInfo responseInfo = {};
6060 populateResponseInfo(responseInfo, serial, responseType, e);
6061 Return<void> retStatus = radioService[slotId]->mRadioResponse->nvReadItemResponse(
6063 convertCharPtrToHidlString((char *) response));
6064 radioService[slotId]->checkReturnStatus(retStatus);
6066 RLOGE("nvReadItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6072 int radio::nvWriteItemResponse(int slotId,
6073 int responseType, int serial, RIL_Errno e,
6074 void *response, size_t responseLen) {
6076 RLOGD("nvWriteItemResponse: serial %d", serial);
6079 if (radioService[slotId]->mRadioResponse != NULL) {
6080 RadioResponseInfo responseInfo = {};
6081 populateResponseInfo(responseInfo, serial, responseType, e);
6082 Return<void> retStatus
6083 = radioService[slotId]->mRadioResponse->nvWriteItemResponse(responseInfo);
6084 radioService[slotId]->checkReturnStatus(retStatus);
6086 RLOGE("nvWriteItemResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6092 int radio::nvWriteCdmaPrlResponse(int slotId,
6093 int responseType, int serial, RIL_Errno e,
6094 void *response, size_t responseLen) {
6096 RLOGD("nvWriteCdmaPrlResponse: serial %d", serial);
6099 if (radioService[slotId]->mRadioResponse != NULL) {
6100 RadioResponseInfo responseInfo = {};
6101 populateResponseInfo(responseInfo, serial, responseType, e);
6102 Return<void> retStatus
6103 = radioService[slotId]->mRadioResponse->nvWriteCdmaPrlResponse(responseInfo);
6104 radioService[slotId]->checkReturnStatus(retStatus);
6106 RLOGE("nvWriteCdmaPrlResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6112 int radio::nvResetConfigResponse(int slotId,
6113 int responseType, int serial, RIL_Errno e,
6114 void *response, size_t responseLen) {
6116 RLOGD("nvResetConfigResponse: serial %d", serial);
6119 if (radioService[slotId]->mRadioResponse != NULL) {
6120 RadioResponseInfo responseInfo = {};
6121 populateResponseInfo(responseInfo, serial, responseType, e);
6122 Return<void> retStatus
6123 = radioService[slotId]->mRadioResponse->nvResetConfigResponse(responseInfo);
6124 radioService[slotId]->checkReturnStatus(retStatus);
6126 RLOGE("nvResetConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6132 int radio::setUiccSubscriptionResponse(int slotId,
6133 int responseType, int serial, RIL_Errno e,
6134 void *response, size_t responseLen) {
6136 RLOGD("setUiccSubscriptionResponse: serial %d", serial);
6139 if (radioService[slotId]->mRadioResponse != NULL) {
6140 RadioResponseInfo responseInfo = {};
6141 populateResponseInfo(responseInfo, serial, responseType, e);
6142 Return<void> retStatus
6143 = radioService[slotId]->mRadioResponse->setUiccSubscriptionResponse(responseInfo);
6144 radioService[slotId]->checkReturnStatus(retStatus);
6146 RLOGE("setUiccSubscriptionResponse: radioService[%d]->mRadioResponse == NULL",
6153 int radio::setDataAllowedResponse(int slotId,
6154 int responseType, int serial, RIL_Errno e,
6155 void *response, size_t responseLen) {
6157 RLOGD("setDataAllowedResponse: serial %d", serial);
6160 if (radioService[slotId]->mRadioResponse != NULL) {
6161 RadioResponseInfo responseInfo = {};
6162 populateResponseInfo(responseInfo, serial, responseType, e);
6163 Return<void> retStatus
6164 = radioService[slotId]->mRadioResponse->setDataAllowedResponse(responseInfo);
6165 radioService[slotId]->checkReturnStatus(retStatus);
6167 RLOGE("setDataAllowedResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6173 int radio::getHardwareConfigResponse(int slotId,
6174 int responseType, int serial, RIL_Errno e,
6175 void *response, size_t responseLen) {
6177 RLOGD("getHardwareConfigResponse: serial %d", serial);
6180 if (radioService[slotId]->mRadioResponse != NULL) {
6181 RadioResponseInfo responseInfo = {};
6182 populateResponseInfo(responseInfo, serial, responseType, e);
6184 hidl_vec<HardwareConfig> result;
6185 if ((response == NULL && responseLen != 0)
6186 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
6187 RLOGE("hardwareConfigChangedInd: invalid response");
6188 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6190 convertRilHardwareConfigListToHal(response, responseLen, result);
6193 Return<void> retStatus = radioService[slotId]->mRadioResponse->getHardwareConfigResponse(
6194 responseInfo, result);
6195 radioService[slotId]->checkReturnStatus(retStatus);
6197 RLOGE("getHardwareConfigResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6203 int radio::requestIccSimAuthenticationResponse(int slotId,
6204 int responseType, int serial, RIL_Errno e,
6205 void *response, size_t responseLen) {
6207 RLOGD("requestIccSimAuthenticationResponse: serial %d", serial);
6210 if (radioService[slotId]->mRadioResponse != NULL) {
6211 RadioResponseInfo responseInfo = {};
6212 IccIoResult result = responseIccIo(responseInfo, serial, responseType, e, response,
6215 Return<void> retStatus
6216 = radioService[slotId]->mRadioResponse->requestIccSimAuthenticationResponse(
6217 responseInfo, result);
6218 radioService[slotId]->checkReturnStatus(retStatus);
6220 RLOGE("requestIccSimAuthenticationResponse: radioService[%d]->mRadioResponse "
6227 int radio::setDataProfileResponse(int slotId,
6228 int responseType, int serial, RIL_Errno e,
6229 void *response, size_t responseLen) {
6231 RLOGD("setDataProfileResponse: serial %d", serial);
6234 if (radioService[slotId]->mRadioResponse != NULL) {
6235 RadioResponseInfo responseInfo = {};
6236 populateResponseInfo(responseInfo, serial, responseType, e);
6237 Return<void> retStatus
6238 = radioService[slotId]->mRadioResponse->setDataProfileResponse(responseInfo);
6239 radioService[slotId]->checkReturnStatus(retStatus);
6241 RLOGE("setDataProfileResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6247 int radio::requestShutdownResponse(int slotId,
6248 int responseType, int serial, RIL_Errno e,
6249 void *response, size_t responseLen) {
6251 RLOGD("requestShutdownResponse: serial %d", serial);
6254 if (radioService[slotId]->mRadioResponse != NULL) {
6255 RadioResponseInfo responseInfo = {};
6256 populateResponseInfo(responseInfo, serial, responseType, e);
6257 Return<void> retStatus
6258 = radioService[slotId]->mRadioResponse->requestShutdownResponse(responseInfo);
6259 radioService[slotId]->checkReturnStatus(retStatus);
6261 RLOGE("requestShutdownResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6267 void responseRadioCapability(RadioResponseInfo& responseInfo, int serial,
6268 int responseType, RIL_Errno e, void *response, size_t responseLen, RadioCapability& rc) {
6269 populateResponseInfo(responseInfo, serial, responseType, e);
6271 if (response == NULL || responseLen != sizeof(RIL_RadioCapability)) {
6272 RLOGE("responseRadioCapability: Invalid response");
6273 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6274 rc.logicalModemUuid = hidl_string();
6276 convertRilRadioCapabilityToHal(response, responseLen, rc);
6280 int radio::getRadioCapabilityResponse(int slotId,
6281 int responseType, int serial, RIL_Errno e,
6282 void *response, size_t responseLen) {
6284 RLOGD("getRadioCapabilityResponse: serial %d", serial);
6287 if (radioService[slotId]->mRadioResponse != NULL) {
6288 RadioResponseInfo responseInfo = {};
6289 RadioCapability result = {};
6290 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6292 Return<void> retStatus = radioService[slotId]->mRadioResponse->getRadioCapabilityResponse(
6293 responseInfo, result);
6294 radioService[slotId]->checkReturnStatus(retStatus);
6296 RLOGE("getRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6302 int radio::setRadioCapabilityResponse(int slotId,
6303 int responseType, int serial, RIL_Errno e,
6304 void *response, size_t responseLen) {
6306 RLOGD("setRadioCapabilityResponse: serial %d", serial);
6309 if (radioService[slotId]->mRadioResponse != NULL) {
6310 RadioResponseInfo responseInfo = {};
6311 RadioCapability result = {};
6312 responseRadioCapability(responseInfo, serial, responseType, e, response, responseLen,
6314 Return<void> retStatus = radioService[slotId]->mRadioResponse->setRadioCapabilityResponse(
6315 responseInfo, result);
6316 radioService[slotId]->checkReturnStatus(retStatus);
6318 RLOGE("setRadioCapabilityResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6324 LceStatusInfo responseLceStatusInfo(RadioResponseInfo& responseInfo, int serial, int responseType,
6325 RIL_Errno e, void *response, size_t responseLen) {
6326 populateResponseInfo(responseInfo, serial, responseType, e);
6327 LceStatusInfo result = {};
6329 if (response == NULL || responseLen != sizeof(RIL_LceStatusInfo)) {
6330 RLOGE("Invalid response: NULL");
6331 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6333 RIL_LceStatusInfo *resp = (RIL_LceStatusInfo *) response;
6334 result.lceStatus = (LceStatus) resp->lce_status;
6335 result.actualIntervalMs = (uint8_t) resp->actual_interval_ms;
6340 int radio::startLceServiceResponse(int slotId,
6341 int responseType, int serial, RIL_Errno e,
6342 void *response, size_t responseLen) {
6344 RLOGD("startLceServiceResponse: serial %d", serial);
6347 if (radioService[slotId]->mRadioResponse != NULL) {
6348 RadioResponseInfo responseInfo = {};
6349 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6350 response, responseLen);
6352 Return<void> retStatus
6353 = radioService[slotId]->mRadioResponse->startLceServiceResponse(responseInfo,
6355 radioService[slotId]->checkReturnStatus(retStatus);
6357 RLOGE("startLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6363 int radio::stopLceServiceResponse(int slotId,
6364 int responseType, int serial, RIL_Errno e,
6365 void *response, size_t responseLen) {
6367 RLOGD("stopLceServiceResponse: serial %d", serial);
6370 if (radioService[slotId]->mRadioResponse != NULL) {
6371 RadioResponseInfo responseInfo = {};
6372 LceStatusInfo result = responseLceStatusInfo(responseInfo, serial, responseType, e,
6373 response, responseLen);
6375 Return<void> retStatus
6376 = radioService[slotId]->mRadioResponse->stopLceServiceResponse(responseInfo,
6378 radioService[slotId]->checkReturnStatus(retStatus);
6380 RLOGE("stopLceServiceResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6386 int radio::pullLceDataResponse(int slotId,
6387 int responseType, int serial, RIL_Errno e,
6388 void *response, size_t responseLen) {
6390 RLOGD("pullLceDataResponse: serial %d", serial);
6393 if (radioService[slotId]->mRadioResponse != NULL) {
6394 RadioResponseInfo responseInfo = {};
6395 populateResponseInfo(responseInfo, serial, responseType, e);
6397 LceDataInfo result = {};
6398 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
6399 RLOGE("pullLceDataResponse: Invalid response");
6400 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6402 convertRilLceDataInfoToHal(response, responseLen, result);
6405 Return<void> retStatus = radioService[slotId]->mRadioResponse->pullLceDataResponse(
6406 responseInfo, result);
6407 radioService[slotId]->checkReturnStatus(retStatus);
6409 RLOGE("pullLceDataResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6415 int radio::getModemActivityInfoResponse(int slotId,
6416 int responseType, int serial, RIL_Errno e,
6417 void *response, size_t responseLen) {
6419 RLOGD("getModemActivityInfoResponse: serial %d", serial);
6422 if (radioService[slotId]->mRadioResponse != NULL) {
6423 RadioResponseInfo responseInfo = {};
6424 populateResponseInfo(responseInfo, serial, responseType, e);
6425 ActivityStatsInfo info;
6426 if (response == NULL || responseLen != sizeof(RIL_ActivityStatsInfo)) {
6427 RLOGE("getModemActivityInfoResponse Invalid response: NULL");
6428 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6430 RIL_ActivityStatsInfo *resp = (RIL_ActivityStatsInfo *)response;
6431 info.sleepModeTimeMs = resp->sleep_mode_time_ms;
6432 info.idleModeTimeMs = resp->idle_mode_time_ms;
6433 for(int i = 0; i < RIL_NUM_TX_POWER_LEVELS; i++) {
6434 info.txmModetimeMs[i] = resp->tx_mode_time_ms[i];
6436 info.rxModeTimeMs = resp->rx_mode_time_ms;
6439 Return<void> retStatus
6440 = radioService[slotId]->mRadioResponse->getModemActivityInfoResponse(responseInfo,
6442 radioService[slotId]->checkReturnStatus(retStatus);
6444 RLOGE("getModemActivityInfoResponse: radioService[%d]->mRadioResponse == NULL",
6451 int radio::setAllowedCarriersResponse(int slotId,
6452 int responseType, int serial, RIL_Errno e,
6453 void *response, size_t responseLen) {
6455 RLOGD("setAllowedCarriersResponse: serial %d", serial);
6458 if (radioService[slotId]->mRadioResponse != NULL) {
6459 RadioResponseInfo responseInfo = {};
6460 int ret = responseInt(responseInfo, serial, responseType, e, response, responseLen);
6461 Return<void> retStatus
6462 = radioService[slotId]->mRadioResponse->setAllowedCarriersResponse(responseInfo,
6464 radioService[slotId]->checkReturnStatus(retStatus);
6466 RLOGE("setAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6473 int radio::getAllowedCarriersResponse(int slotId,
6474 int responseType, int serial, RIL_Errno e,
6475 void *response, size_t responseLen) {
6477 RLOGD("getAllowedCarriersResponse: serial %d", serial);
6480 if (radioService[slotId]->mRadioResponse != NULL) {
6481 RadioResponseInfo responseInfo = {};
6482 populateResponseInfo(responseInfo, serial, responseType, e);
6483 CarrierRestrictions carrierInfo = {};
6484 bool allAllowed = true;
6485 if (response == NULL) {
6487 RLOGD("getAllowedCarriersResponse response is NULL: all allowed");
6489 carrierInfo.allowedCarriers.resize(0);
6490 carrierInfo.excludedCarriers.resize(0);
6491 } else if (responseLen != sizeof(RIL_CarrierRestrictions)) {
6492 RLOGE("getAllowedCarriersResponse Invalid response");
6493 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6495 RIL_CarrierRestrictions *pCr = (RIL_CarrierRestrictions *)response;
6496 if (pCr->len_allowed_carriers > 0 || pCr->len_excluded_carriers > 0) {
6500 carrierInfo.allowedCarriers.resize(pCr->len_allowed_carriers);
6501 for(int i = 0; i < pCr->len_allowed_carriers; i++) {
6502 RIL_Carrier *carrier = pCr->allowed_carriers + i;
6503 carrierInfo.allowedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6504 carrierInfo.allowedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6505 carrierInfo.allowedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6506 carrierInfo.allowedCarriers[i].matchData =
6507 convertCharPtrToHidlString(carrier->match_data);
6510 carrierInfo.excludedCarriers.resize(pCr->len_excluded_carriers);
6511 for(int i = 0; i < pCr->len_excluded_carriers; i++) {
6512 RIL_Carrier *carrier = pCr->excluded_carriers + i;
6513 carrierInfo.excludedCarriers[i].mcc = convertCharPtrToHidlString(carrier->mcc);
6514 carrierInfo.excludedCarriers[i].mnc = convertCharPtrToHidlString(carrier->mnc);
6515 carrierInfo.excludedCarriers[i].matchType = (CarrierMatchType) carrier->match_type;
6516 carrierInfo.excludedCarriers[i].matchData =
6517 convertCharPtrToHidlString(carrier->match_data);
6521 Return<void> retStatus
6522 = radioService[slotId]->mRadioResponse->getAllowedCarriersResponse(responseInfo,
6523 allAllowed, carrierInfo);
6524 radioService[slotId]->checkReturnStatus(retStatus);
6526 RLOGE("getAllowedCarriersResponse: radioService[%d]->mRadioResponse == NULL",
6533 int radio::sendDeviceStateResponse(int slotId,
6534 int responseType, int serial, RIL_Errno e,
6535 void *response, size_t responselen) {
6537 RLOGD("sendDeviceStateResponse: serial %d", serial);
6540 if (radioService[slotId]->mRadioResponse != NULL) {
6541 RadioResponseInfo responseInfo = {};
6542 populateResponseInfo(responseInfo, serial, responseType, e);
6543 Return<void> retStatus
6544 = radioService[slotId]->mRadioResponse->sendDeviceStateResponse(responseInfo);
6545 radioService[slotId]->checkReturnStatus(retStatus);
6547 RLOGE("sendDeviceStateResponse: radioService[%d]->mRadioResponse == NULL", slotId);
6553 int radio::setCarrierInfoForImsiEncryptionResponse(int slotId,
6554 int responseType, int serial, RIL_Errno e,
6555 void *response, size_t responseLen) {
6556 RLOGD("setCarrierInfoForImsiEncryptionResponse: serial %d", serial);
6557 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6558 RadioResponseInfo responseInfo = {};
6559 populateResponseInfo(responseInfo, serial, responseType, e);
6560 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6561 setCarrierInfoForImsiEncryptionResponse(responseInfo);
6562 radioService[slotId]->checkReturnStatus(retStatus);
6564 RLOGE("setCarrierInfoForImsiEncryptionResponse: radioService[%d]->mRadioResponseV1_1 == "
6570 int radio::setIndicationFilterResponse(int slotId,
6571 int responseType, int serial, RIL_Errno e,
6572 void *response, size_t responselen) {
6574 RLOGD("setIndicationFilterResponse: serial %d", serial);
6577 if (radioService[slotId]->mRadioResponse != NULL) {
6578 RadioResponseInfo responseInfo = {};
6579 populateResponseInfo(responseInfo, serial, responseType, e);
6580 Return<void> retStatus
6581 = radioService[slotId]->mRadioResponse->setIndicationFilterResponse(responseInfo);
6582 radioService[slotId]->checkReturnStatus(retStatus);
6584 RLOGE("setIndicationFilterResponse: radioService[%d]->mRadioResponse == NULL",
6591 int radio::setSimCardPowerResponse(int slotId,
6592 int responseType, int serial, RIL_Errno e,
6593 void *response, size_t responseLen) {
6595 RLOGD("setSimCardPowerResponse: serial %d", serial);
6598 if (radioService[slotId]->mRadioResponse != NULL
6599 || radioService[slotId]->mRadioResponseV1_1 != NULL) {
6600 RadioResponseInfo responseInfo = {};
6601 populateResponseInfo(responseInfo, serial, responseType, e);
6602 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6603 Return<void> retStatus = radioService[slotId]->mRadioResponseV1_1->
6604 setSimCardPowerResponse_1_1(responseInfo);
6605 radioService[slotId]->checkReturnStatus(retStatus);
6607 RLOGD("setSimCardPowerResponse: radioService[%d]->mRadioResponseV1_1 == NULL",
6609 Return<void> retStatus
6610 = radioService[slotId]->mRadioResponse->setSimCardPowerResponse(responseInfo);
6611 radioService[slotId]->checkReturnStatus(retStatus);
6614 RLOGE("setSimCardPowerResponse: radioService[%d]->mRadioResponse == NULL && "
6615 "radioService[%d]->mRadioResponseV1_1 == NULL", slotId, slotId);
6620 int radio::startNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6621 void *response, size_t responseLen) {
6623 RLOGD("startNetworkScanResponse: serial %d", serial);
6626 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6627 RadioResponseInfo responseInfo = {};
6628 populateResponseInfo(responseInfo, serial, responseType, e);
6629 Return<void> retStatus
6630 = radioService[slotId]->mRadioResponseV1_1->startNetworkScanResponse(responseInfo);
6631 radioService[slotId]->checkReturnStatus(retStatus);
6633 RLOGE("startNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6639 int radio::stopNetworkScanResponse(int slotId, int responseType, int serial, RIL_Errno e,
6640 void *response, size_t responseLen) {
6642 RLOGD("stopNetworkScanResponse: serial %d", serial);
6645 if (radioService[slotId]->mRadioResponseV1_1 != NULL) {
6646 RadioResponseInfo responseInfo = {};
6647 populateResponseInfo(responseInfo, serial, responseType, e);
6648 Return<void> retStatus
6649 = radioService[slotId]->mRadioResponseV1_1->stopNetworkScanResponse(responseInfo);
6650 radioService[slotId]->checkReturnStatus(retStatus);
6652 RLOGE("stopNetworkScanResponse: radioService[%d]->mRadioResponseV1_1 == NULL", slotId);
6658 void convertRilKeepaliveStatusToHal(const RIL_KeepaliveStatus *rilStatus,
6659 V1_1::KeepaliveStatus& halStatus) {
6660 halStatus.sessionHandle = rilStatus->sessionHandle;
6661 halStatus.code = static_cast<V1_1::KeepaliveStatusCode>(rilStatus->code);
6664 int radio::startKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
6665 void *response, size_t responseLen) {
6667 RLOGD("%s(): %d", __FUNCTION__, serial);
6669 RadioResponseInfo responseInfo = {};
6670 populateResponseInfo(responseInfo, serial, responseType, e);
6672 // If we don't have a radio service, there's nothing we can do
6673 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
6674 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
6678 V1_1::KeepaliveStatus ks = {};
6679 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
6680 RLOGE("%s: invalid response - %d", __FUNCTION__, static_cast<int>(e));
6681 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6683 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
6686 Return<void> retStatus =
6687 radioService[slotId]->mRadioResponseV1_1->startKeepaliveResponse(responseInfo, ks);
6688 radioService[slotId]->checkReturnStatus(retStatus);
6692 int radio::stopKeepaliveResponse(int slotId, int responseType, int serial, RIL_Errno e,
6693 void *response, size_t responseLen) {
6695 RLOGD("%s(): %d", __FUNCTION__, serial);
6697 RadioResponseInfo responseInfo = {};
6698 populateResponseInfo(responseInfo, serial, responseType, e);
6700 // If we don't have a radio service, there's nothing we can do
6701 if (radioService[slotId]->mRadioResponseV1_1 == NULL) {
6702 RLOGE("%s: radioService[%d]->mRadioResponseV1_1 == NULL", __FUNCTION__, slotId);
6706 Return<void> retStatus =
6707 radioService[slotId]->mRadioResponseV1_1->stopKeepaliveResponse(responseInfo);
6708 radioService[slotId]->checkReturnStatus(retStatus);
6712 int radio::sendRequestRawResponse(int slotId,
6713 int responseType, int serial, RIL_Errno e,
6714 void *response, size_t responseLen) {
6716 RLOGD("sendRequestRawResponse: serial %d", serial);
6719 if (!kOemHookEnabled) return 0;
6721 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6722 RadioResponseInfo responseInfo = {};
6723 populateResponseInfo(responseInfo, serial, responseType, e);
6724 hidl_vec<uint8_t> data;
6726 if (response == NULL) {
6727 RLOGE("sendRequestRawResponse: Invalid response");
6728 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6730 data.setToExternal((uint8_t *) response, responseLen);
6732 Return<void> retStatus = oemHookService[slotId]->mOemHookResponse->
6733 sendRequestRawResponse(responseInfo, data);
6734 checkReturnStatus(slotId, retStatus, false);
6736 RLOGE("sendRequestRawResponse: oemHookService[%d]->mOemHookResponse == NULL",
6743 int radio::sendRequestStringsResponse(int slotId,
6744 int responseType, int serial, RIL_Errno e,
6745 void *response, size_t responseLen) {
6747 RLOGD("sendRequestStringsResponse: serial %d", serial);
6750 if (!kOemHookEnabled) return 0;
6752 if (oemHookService[slotId]->mOemHookResponse != NULL) {
6753 RadioResponseInfo responseInfo = {};
6754 populateResponseInfo(responseInfo, serial, responseType, e);
6755 hidl_vec<hidl_string> data;
6757 if ((response == NULL && responseLen != 0) || responseLen % sizeof(char *) != 0) {
6758 RLOGE("sendRequestStringsResponse Invalid response: NULL");
6759 if (e == RIL_E_SUCCESS) responseInfo.error = RadioError::INVALID_RESPONSE;
6761 char **resp = (char **) response;
6762 int numStrings = responseLen / sizeof(char *);
6763 data.resize(numStrings);
6764 for (int i = 0; i < numStrings; i++) {
6765 data[i] = convertCharPtrToHidlString(resp[i]);
6768 Return<void> retStatus
6769 = oemHookService[slotId]->mOemHookResponse->sendRequestStringsResponse(
6770 responseInfo, data);
6771 checkReturnStatus(slotId, retStatus, false);
6773 RLOGE("sendRequestStringsResponse: oemHookService[%d]->mOemHookResponse == "
6780 /***************************************************************************************************
6781 * INDICATION FUNCTIONS
6782 * The below function handle unsolicited messages coming from the Radio
6783 * (messages for which there is no pending request)
6784 **************************************************************************************************/
6786 RadioIndicationType convertIntToRadioIndicationType(int indicationType) {
6787 return indicationType == RESPONSE_UNSOLICITED ? (RadioIndicationType::UNSOLICITED) :
6788 (RadioIndicationType::UNSOLICITED_ACK_EXP);
6791 int radio::radioStateChangedInd(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 RadioState radioState =
6796 (RadioState) CALL_ONSTATEREQUEST(slotId);
6797 RLOGD("radioStateChangedInd: radioState %d", radioState);
6798 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioStateChanged(
6799 convertIntToRadioIndicationType(indicationType), radioState);
6800 radioService[slotId]->checkReturnStatus(retStatus);
6802 RLOGE("radioStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6808 int radio::callStateChangedInd(int slotId,
6809 int indicationType, int token, RIL_Errno e, void *response,
6810 size_t responseLen) {
6811 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6813 RLOGD("callStateChangedInd");
6815 Return<void> retStatus = radioService[slotId]->mRadioIndication->callStateChanged(
6816 convertIntToRadioIndicationType(indicationType));
6817 radioService[slotId]->checkReturnStatus(retStatus);
6819 RLOGE("callStateChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
6825 int radio::networkStateChangedInd(int slotId,
6826 int indicationType, int token, RIL_Errno e, void *response,
6827 size_t responseLen) {
6828 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6830 RLOGD("networkStateChangedInd");
6832 Return<void> retStatus = radioService[slotId]->mRadioIndication->networkStateChanged(
6833 convertIntToRadioIndicationType(indicationType));
6834 radioService[slotId]->checkReturnStatus(retStatus);
6836 RLOGE("networkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
6843 uint8_t hexCharToInt(uint8_t c) {
6844 if (c >= '0' && c <= '9') return (c - '0');
6845 if (c >= 'A' && c <= 'F') return (c - 'A' + 10);
6846 if (c >= 'a' && c <= 'f') return (c - 'a' + 10);
6848 return INVALID_HEX_CHAR;
6851 uint8_t * convertHexStringToBytes(void *response, size_t responseLen) {
6852 if (responseLen % 2 != 0) {
6856 uint8_t *bytes = (uint8_t *)calloc(responseLen/2, sizeof(uint8_t));
6857 if (bytes == NULL) {
6858 RLOGE("convertHexStringToBytes: cannot allocate memory for bytes string");
6861 uint8_t *hexString = (uint8_t *)response;
6863 for (size_t i = 0; i < responseLen; i += 2) {
6864 uint8_t hexChar1 = hexCharToInt(hexString[i]);
6865 uint8_t hexChar2 = hexCharToInt(hexString[i + 1]);
6867 if (hexChar1 == INVALID_HEX_CHAR || hexChar2 == INVALID_HEX_CHAR) {
6868 RLOGE("convertHexStringToBytes: invalid hex char %d %d",
6869 hexString[i], hexString[i + 1]);
6873 bytes[i/2] = ((hexChar1 << 4) | hexChar2);
6879 int radio::newSmsInd(int slotId, int indicationType,
6880 int token, RIL_Errno e, void *response, size_t responseLen) {
6881 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6882 if (response == NULL || responseLen == 0) {
6883 RLOGE("newSmsInd: invalid response");
6887 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6888 if (bytes == NULL) {
6889 RLOGE("newSmsInd: convertHexStringToBytes failed");
6893 hidl_vec<uint8_t> pdu;
6894 pdu.setToExternal(bytes, responseLen/2);
6898 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSms(
6899 convertIntToRadioIndicationType(indicationType), pdu);
6900 radioService[slotId]->checkReturnStatus(retStatus);
6903 RLOGE("newSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
6909 int radio::newSmsStatusReportInd(int slotId,
6910 int indicationType, int token, RIL_Errno e, void *response,
6911 size_t responseLen) {
6912 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6913 if (response == NULL || responseLen == 0) {
6914 RLOGE("newSmsStatusReportInd: invalid response");
6918 uint8_t *bytes = convertHexStringToBytes(response, responseLen);
6919 if (bytes == NULL) {
6920 RLOGE("newSmsStatusReportInd: convertHexStringToBytes failed");
6924 hidl_vec<uint8_t> pdu;
6925 pdu.setToExternal(bytes, responseLen/2);
6927 RLOGD("newSmsStatusReportInd");
6929 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsStatusReport(
6930 convertIntToRadioIndicationType(indicationType), pdu);
6931 radioService[slotId]->checkReturnStatus(retStatus);
6934 RLOGE("newSmsStatusReportInd: radioService[%d]->mRadioIndication == NULL", slotId);
6940 int radio::newSmsOnSimInd(int slotId, int indicationType,
6941 int token, RIL_Errno e, void *response, size_t responseLen) {
6942 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6943 if (response == NULL || responseLen != sizeof(int)) {
6944 RLOGE("newSmsOnSimInd: invalid response");
6947 int32_t recordNumber = ((int32_t *) response)[0];
6949 RLOGD("newSmsOnSimInd: slotIndex %d", recordNumber);
6951 Return<void> retStatus = radioService[slotId]->mRadioIndication->newSmsOnSim(
6952 convertIntToRadioIndicationType(indicationType), recordNumber);
6953 radioService[slotId]->checkReturnStatus(retStatus);
6955 RLOGE("newSmsOnSimInd: radioService[%d]->mRadioIndication == NULL", slotId);
6961 int radio::onUssdInd(int slotId, int indicationType,
6962 int token, RIL_Errno e, void *response, size_t responseLen) {
6963 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6964 if (response == NULL || responseLen != 2 * sizeof(char *)) {
6965 RLOGE("onUssdInd: invalid response");
6968 char **strings = (char **) response;
6969 char *mode = strings[0];
6970 hidl_string msg = convertCharPtrToHidlString(strings[1]);
6971 UssdModeType modeType = (UssdModeType) atoi(mode);
6973 RLOGD("onUssdInd: mode %s", mode);
6975 Return<void> retStatus = radioService[slotId]->mRadioIndication->onUssd(
6976 convertIntToRadioIndicationType(indicationType), modeType, msg);
6977 radioService[slotId]->checkReturnStatus(retStatus);
6979 RLOGE("onUssdInd: radioService[%d]->mRadioIndication == NULL", slotId);
6985 int radio::nitzTimeReceivedInd(int slotId,
6986 int indicationType, int token, RIL_Errno e, void *response,
6987 size_t responseLen) {
6988 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
6989 if (response == NULL || responseLen == 0) {
6990 RLOGE("nitzTimeReceivedInd: invalid response");
6993 hidl_string nitzTime = convertCharPtrToHidlString((char *) response);
6995 RLOGD("nitzTimeReceivedInd: nitzTime %s receivedTime %" PRId64, nitzTime.c_str(),
6996 nitzTimeReceived[slotId]);
6998 Return<void> retStatus = radioService[slotId]->mRadioIndication->nitzTimeReceived(
6999 convertIntToRadioIndicationType(indicationType), nitzTime,
7000 nitzTimeReceived[slotId]);
7001 radioService[slotId]->checkReturnStatus(retStatus);
7003 RLOGE("nitzTimeReceivedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7010 void convertRilSignalStrengthToHal(void *response, size_t responseLen,
7011 SignalStrength& signalStrength) {
7012 RIL_SignalStrength_v10 *rilSignalStrength = (RIL_SignalStrength_v10 *) response;
7014 // Fixup LTE for backwards compatibility
7015 // signalStrength: -1 -> 99
7016 if (rilSignalStrength->LTE_SignalStrength.signalStrength == -1) {
7017 rilSignalStrength->LTE_SignalStrength.signalStrength = 99;
7019 // rsrp: -1 -> INT_MAX all other negative value to positive.
7021 if (rilSignalStrength->LTE_SignalStrength.rsrp == -1) {
7022 rilSignalStrength->LTE_SignalStrength.rsrp = INT_MAX;
7023 } else if (rilSignalStrength->LTE_SignalStrength.rsrp < -1) {
7024 rilSignalStrength->LTE_SignalStrength.rsrp = -rilSignalStrength->LTE_SignalStrength.rsrp;
7026 // rsrq: -1 -> INT_MAX
7027 if (rilSignalStrength->LTE_SignalStrength.rsrq == -1) {
7028 rilSignalStrength->LTE_SignalStrength.rsrq = INT_MAX;
7030 // Not remapping rssnr is already using INT_MAX
7031 // cqi: -1 -> INT_MAX
7032 if (rilSignalStrength->LTE_SignalStrength.cqi == -1) {
7033 rilSignalStrength->LTE_SignalStrength.cqi = INT_MAX;
7036 signalStrength.gw.signalStrength = rilSignalStrength->GW_SignalStrength.signalStrength;
7037 signalStrength.gw.bitErrorRate = rilSignalStrength->GW_SignalStrength.bitErrorRate;
7038 signalStrength.cdma.dbm = rilSignalStrength->CDMA_SignalStrength.dbm;
7039 signalStrength.cdma.ecio = rilSignalStrength->CDMA_SignalStrength.ecio;
7040 signalStrength.evdo.dbm = rilSignalStrength->EVDO_SignalStrength.dbm;
7041 signalStrength.evdo.ecio = rilSignalStrength->EVDO_SignalStrength.ecio;
7042 signalStrength.evdo.signalNoiseRatio =
7043 rilSignalStrength->EVDO_SignalStrength.signalNoiseRatio;
7044 signalStrength.lte.signalStrength = rilSignalStrength->LTE_SignalStrength.signalStrength;
7045 signalStrength.lte.rsrp = rilSignalStrength->LTE_SignalStrength.rsrp;
7046 signalStrength.lte.rsrq = rilSignalStrength->LTE_SignalStrength.rsrq;
7047 signalStrength.lte.rssnr = rilSignalStrength->LTE_SignalStrength.rssnr;
7048 signalStrength.lte.cqi = rilSignalStrength->LTE_SignalStrength.cqi;
7049 signalStrength.lte.timingAdvance = rilSignalStrength->LTE_SignalStrength.timingAdvance;
7050 signalStrength.tdScdma.rscp = rilSignalStrength->TD_SCDMA_SignalStrength.rscp;
7053 int radio::currentSignalStrengthInd(int slotId,
7054 int indicationType, int token, RIL_Errno e,
7055 void *response, size_t responseLen) {
7056 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7057 if (response == NULL || responseLen != sizeof(RIL_SignalStrength_v10)) {
7058 RLOGE("currentSignalStrengthInd: invalid response");
7062 SignalStrength signalStrength = {};
7063 convertRilSignalStrengthToHal(response, responseLen, signalStrength);
7066 RLOGD("currentSignalStrengthInd");
7068 Return<void> retStatus = radioService[slotId]->mRadioIndication->currentSignalStrength(
7069 convertIntToRadioIndicationType(indicationType), signalStrength);
7070 radioService[slotId]->checkReturnStatus(retStatus);
7072 RLOGE("currentSignalStrengthInd: radioService[%d]->mRadioIndication == NULL",
7079 void convertRilDataCallToHal(RIL_Data_Call_Response_v11 *dcResponse,
7080 SetupDataCallResult& dcResult) {
7081 dcResult.status = (DataCallFailCause) dcResponse->status;
7082 dcResult.suggestedRetryTime = dcResponse->suggestedRetryTime;
7083 dcResult.cid = dcResponse->cid;
7084 dcResult.active = dcResponse->active;
7085 dcResult.type = convertCharPtrToHidlString(dcResponse->type);
7086 dcResult.ifname = convertCharPtrToHidlString(dcResponse->ifname);
7087 dcResult.addresses = convertCharPtrToHidlString(dcResponse->addresses);
7088 dcResult.dnses = convertCharPtrToHidlString(dcResponse->dnses);
7089 dcResult.gateways = convertCharPtrToHidlString(dcResponse->gateways);
7090 dcResult.pcscf = convertCharPtrToHidlString(dcResponse->pcscf);
7091 dcResult.mtu = dcResponse->mtu;
7094 void convertRilDataCallListToHal(void *response, size_t responseLen,
7095 hidl_vec<SetupDataCallResult>& dcResultList) {
7096 int num = responseLen / sizeof(RIL_Data_Call_Response_v11);
7098 RIL_Data_Call_Response_v11 *dcResponse = (RIL_Data_Call_Response_v11 *) response;
7099 dcResultList.resize(num);
7100 for (int i = 0; i < num; i++) {
7101 convertRilDataCallToHal(&dcResponse[i], dcResultList[i]);
7105 int radio::dataCallListChangedInd(int slotId,
7106 int indicationType, int token, RIL_Errno e, void *response,
7107 size_t responseLen) {
7108 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7109 if ((response == NULL && responseLen != 0)
7110 || responseLen % sizeof(RIL_Data_Call_Response_v11) != 0) {
7111 RLOGE("dataCallListChangedInd: invalid response");
7114 hidl_vec<SetupDataCallResult> dcList;
7115 convertRilDataCallListToHal(response, responseLen, dcList);
7117 RLOGD("dataCallListChangedInd");
7119 Return<void> retStatus = radioService[slotId]->mRadioIndication->dataCallListChanged(
7120 convertIntToRadioIndicationType(indicationType), dcList);
7121 radioService[slotId]->checkReturnStatus(retStatus);
7123 RLOGE("dataCallListChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7129 int radio::suppSvcNotifyInd(int slotId, int indicationType,
7130 int token, RIL_Errno e, void *response, size_t responseLen) {
7131 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7132 if (response == NULL || responseLen != sizeof(RIL_SuppSvcNotification)) {
7133 RLOGE("suppSvcNotifyInd: invalid response");
7137 SuppSvcNotification suppSvc = {};
7138 RIL_SuppSvcNotification *ssn = (RIL_SuppSvcNotification *) response;
7139 suppSvc.isMT = ssn->notificationType;
7140 suppSvc.code = ssn->code;
7141 suppSvc.index = ssn->index;
7142 suppSvc.type = ssn->type;
7143 suppSvc.number = convertCharPtrToHidlString(ssn->number);
7146 RLOGD("suppSvcNotifyInd: isMT %d code %d index %d type %d",
7147 suppSvc.isMT, suppSvc.code, suppSvc.index, suppSvc.type);
7149 Return<void> retStatus = radioService[slotId]->mRadioIndication->suppSvcNotify(
7150 convertIntToRadioIndicationType(indicationType), suppSvc);
7151 radioService[slotId]->checkReturnStatus(retStatus);
7153 RLOGE("suppSvcNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7159 int radio::stkSessionEndInd(int slotId, int indicationType,
7160 int token, RIL_Errno e, void *response, size_t responseLen) {
7161 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7163 RLOGD("stkSessionEndInd");
7165 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkSessionEnd(
7166 convertIntToRadioIndicationType(indicationType));
7167 radioService[slotId]->checkReturnStatus(retStatus);
7169 RLOGE("stkSessionEndInd: radioService[%d]->mRadioIndication == NULL", slotId);
7175 int radio::stkProactiveCommandInd(int slotId,
7176 int indicationType, int token, RIL_Errno e, void *response,
7177 size_t responseLen) {
7178 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7179 if (response == NULL || responseLen == 0) {
7180 RLOGE("stkProactiveCommandInd: invalid response");
7184 RLOGD("stkProactiveCommandInd");
7186 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkProactiveCommand(
7187 convertIntToRadioIndicationType(indicationType),
7188 convertCharPtrToHidlString((char *) response));
7189 radioService[slotId]->checkReturnStatus(retStatus);
7191 RLOGE("stkProactiveCommandInd: radioService[%d]->mRadioIndication == NULL", slotId);
7197 int radio::stkEventNotifyInd(int slotId, int indicationType,
7198 int token, RIL_Errno e, void *response, size_t responseLen) {
7199 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7200 if (response == NULL || responseLen == 0) {
7201 RLOGE("stkEventNotifyInd: invalid response");
7205 RLOGD("stkEventNotifyInd");
7207 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkEventNotify(
7208 convertIntToRadioIndicationType(indicationType),
7209 convertCharPtrToHidlString((char *) response));
7210 radioService[slotId]->checkReturnStatus(retStatus);
7212 RLOGE("stkEventNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
7218 int radio::stkCallSetupInd(int slotId, int indicationType,
7219 int token, RIL_Errno e, void *response, size_t responseLen) {
7220 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7221 if (response == NULL || responseLen != sizeof(int)) {
7222 RLOGE("stkCallSetupInd: invalid response");
7225 int32_t timeout = ((int32_t *) response)[0];
7227 RLOGD("stkCallSetupInd: timeout %d", timeout);
7229 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallSetup(
7230 convertIntToRadioIndicationType(indicationType), timeout);
7231 radioService[slotId]->checkReturnStatus(retStatus);
7233 RLOGE("stkCallSetupInd: radioService[%d]->mRadioIndication == NULL", slotId);
7239 int radio::simSmsStorageFullInd(int slotId,
7240 int indicationType, int token, RIL_Errno e, void *response,
7241 size_t responseLen) {
7242 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7244 RLOGD("simSmsStorageFullInd");
7246 Return<void> retStatus = radioService[slotId]->mRadioIndication->simSmsStorageFull(
7247 convertIntToRadioIndicationType(indicationType));
7248 radioService[slotId]->checkReturnStatus(retStatus);
7250 RLOGE("simSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL", slotId);
7256 int radio::simRefreshInd(int slotId, int indicationType,
7257 int token, RIL_Errno e, void *response, size_t responseLen) {
7258 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7259 if (response == NULL || responseLen != sizeof(RIL_SimRefreshResponse_v7)) {
7260 RLOGE("simRefreshInd: invalid response");
7264 SimRefreshResult refreshResult = {};
7265 RIL_SimRefreshResponse_v7 *simRefreshResponse = ((RIL_SimRefreshResponse_v7 *) response);
7266 refreshResult.type =
7267 (V1_0::SimRefreshType) simRefreshResponse->result;
7268 refreshResult.efId = simRefreshResponse->ef_id;
7269 refreshResult.aid = convertCharPtrToHidlString(simRefreshResponse->aid);
7272 RLOGD("simRefreshInd: type %d efId %d", refreshResult.type, refreshResult.efId);
7274 Return<void> retStatus = radioService[slotId]->mRadioIndication->simRefresh(
7275 convertIntToRadioIndicationType(indicationType), refreshResult);
7276 radioService[slotId]->checkReturnStatus(retStatus);
7278 RLOGE("simRefreshInd: radioService[%d]->mRadioIndication == NULL", slotId);
7284 void convertRilCdmaSignalInfoRecordToHal(RIL_CDMA_SignalInfoRecord *signalInfoRecord,
7285 CdmaSignalInfoRecord& record) {
7286 record.isPresent = signalInfoRecord->isPresent;
7287 record.signalType = signalInfoRecord->signalType;
7288 record.alertPitch = signalInfoRecord->alertPitch;
7289 record.signal = signalInfoRecord->signal;
7292 int radio::callRingInd(int slotId, int indicationType,
7293 int token, RIL_Errno e, void *response, size_t responseLen) {
7294 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7296 CdmaSignalInfoRecord record = {};
7297 if (response == NULL || responseLen == 0) {
7301 if (responseLen != sizeof (RIL_CDMA_SignalInfoRecord)) {
7302 RLOGE("callRingInd: invalid response");
7305 convertRilCdmaSignalInfoRecordToHal((RIL_CDMA_SignalInfoRecord *) response, record);
7309 RLOGD("callRingInd: isGsm %d", isGsm);
7311 Return<void> retStatus = radioService[slotId]->mRadioIndication->callRing(
7312 convertIntToRadioIndicationType(indicationType), isGsm, record);
7313 radioService[slotId]->checkReturnStatus(retStatus);
7315 RLOGE("callRingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7321 int radio::simStatusChangedInd(int slotId,
7322 int indicationType, int token, RIL_Errno e, void *response,
7323 size_t responseLen) {
7324 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7326 RLOGD("simStatusChangedInd");
7328 Return<void> retStatus = radioService[slotId]->mRadioIndication->simStatusChanged(
7329 convertIntToRadioIndicationType(indicationType));
7330 radioService[slotId]->checkReturnStatus(retStatus);
7332 RLOGE("simStatusChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7338 int radio::cdmaNewSmsInd(int slotId, int indicationType,
7339 int token, RIL_Errno e, void *response, size_t responseLen) {
7340 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7341 if (response == NULL || responseLen != sizeof(RIL_CDMA_SMS_Message)) {
7342 RLOGE("cdmaNewSmsInd: invalid response");
7346 CdmaSmsMessage msg = {};
7347 RIL_CDMA_SMS_Message *rilMsg = (RIL_CDMA_SMS_Message *) response;
7348 msg.teleserviceId = rilMsg->uTeleserviceID;
7349 msg.isServicePresent = rilMsg->bIsServicePresent;
7350 msg.serviceCategory = rilMsg->uServicecategory;
7351 msg.address.digitMode =
7352 (V1_0::CdmaSmsDigitMode) rilMsg->sAddress.digit_mode;
7353 msg.address.numberMode =
7354 (V1_0::CdmaSmsNumberMode) rilMsg->sAddress.number_mode;
7355 msg.address.numberType =
7356 (V1_0::CdmaSmsNumberType) rilMsg->sAddress.number_type;
7357 msg.address.numberPlan =
7358 (V1_0::CdmaSmsNumberPlan) rilMsg->sAddress.number_plan;
7360 int digitLimit = MIN((rilMsg->sAddress.number_of_digits), RIL_CDMA_SMS_ADDRESS_MAX);
7361 msg.address.digits.setToExternal(rilMsg->sAddress.digits, digitLimit);
7363 msg.subAddress.subaddressType = (V1_0::CdmaSmsSubaddressType)
7364 rilMsg->sSubAddress.subaddressType;
7365 msg.subAddress.odd = rilMsg->sSubAddress.odd;
7367 digitLimit= MIN((rilMsg->sSubAddress.number_of_digits), RIL_CDMA_SMS_SUBADDRESS_MAX);
7368 msg.subAddress.digits.setToExternal(rilMsg->sSubAddress.digits, digitLimit);
7370 digitLimit = MIN((rilMsg->uBearerDataLen), RIL_CDMA_SMS_BEARER_DATA_MAX);
7371 msg.bearerData.setToExternal(rilMsg->aBearerData, digitLimit);
7374 RLOGD("cdmaNewSmsInd");
7376 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaNewSms(
7377 convertIntToRadioIndicationType(indicationType), msg);
7378 radioService[slotId]->checkReturnStatus(retStatus);
7380 RLOGE("cdmaNewSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7386 int radio::newBroadcastSmsInd(int slotId,
7387 int indicationType, int token, RIL_Errno e, void *response,
7388 size_t responseLen) {
7389 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7390 if (response == NULL || responseLen == 0) {
7391 RLOGE("newBroadcastSmsInd: invalid response");
7395 hidl_vec<uint8_t> data;
7396 data.setToExternal((uint8_t *) response, responseLen);
7398 RLOGD("newBroadcastSmsInd");
7400 Return<void> retStatus = radioService[slotId]->mRadioIndication->newBroadcastSms(
7401 convertIntToRadioIndicationType(indicationType), data);
7402 radioService[slotId]->checkReturnStatus(retStatus);
7404 RLOGE("newBroadcastSmsInd: radioService[%d]->mRadioIndication == NULL", slotId);
7410 int radio::cdmaRuimSmsStorageFullInd(int slotId,
7411 int indicationType, int token, RIL_Errno e, void *response,
7412 size_t responseLen) {
7413 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7415 RLOGD("cdmaRuimSmsStorageFullInd");
7417 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaRuimSmsStorageFull(
7418 convertIntToRadioIndicationType(indicationType));
7419 radioService[slotId]->checkReturnStatus(retStatus);
7421 RLOGE("cdmaRuimSmsStorageFullInd: radioService[%d]->mRadioIndication == NULL",
7428 int radio::restrictedStateChangedInd(int slotId,
7429 int indicationType, int token, RIL_Errno e, void *response,
7430 size_t responseLen) {
7431 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7432 if (response == NULL || responseLen != sizeof(int)) {
7433 RLOGE("restrictedStateChangedInd: invalid response");
7436 int32_t state = ((int32_t *) response)[0];
7438 RLOGD("restrictedStateChangedInd: state %d", state);
7440 Return<void> retStatus = radioService[slotId]->mRadioIndication->restrictedStateChanged(
7441 convertIntToRadioIndicationType(indicationType), (PhoneRestrictedState) state);
7442 radioService[slotId]->checkReturnStatus(retStatus);
7444 RLOGE("restrictedStateChangedInd: radioService[%d]->mRadioIndication == NULL",
7451 int radio::enterEmergencyCallbackModeInd(int slotId,
7452 int indicationType, int token, RIL_Errno e, void *response,
7453 size_t responseLen) {
7454 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7456 RLOGD("enterEmergencyCallbackModeInd");
7458 Return<void> retStatus = radioService[slotId]->mRadioIndication->enterEmergencyCallbackMode(
7459 convertIntToRadioIndicationType(indicationType));
7460 radioService[slotId]->checkReturnStatus(retStatus);
7462 RLOGE("enterEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7469 int radio::cdmaCallWaitingInd(int slotId,
7470 int indicationType, int token, RIL_Errno e, void *response,
7471 size_t responseLen) {
7472 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7473 if (response == NULL || responseLen != sizeof(RIL_CDMA_CallWaiting_v6)) {
7474 RLOGE("cdmaCallWaitingInd: invalid response");
7478 CdmaCallWaiting callWaitingRecord = {};
7479 RIL_CDMA_CallWaiting_v6 *callWaitingRil = ((RIL_CDMA_CallWaiting_v6 *) response);
7480 callWaitingRecord.number = convertCharPtrToHidlString(callWaitingRil->number);
7481 callWaitingRecord.numberPresentation =
7482 (CdmaCallWaitingNumberPresentation) callWaitingRil->numberPresentation;
7483 callWaitingRecord.name = convertCharPtrToHidlString(callWaitingRil->name);
7484 convertRilCdmaSignalInfoRecordToHal(&callWaitingRil->signalInfoRecord,
7485 callWaitingRecord.signalInfoRecord);
7486 callWaitingRecord.numberType = (CdmaCallWaitingNumberType) callWaitingRil->number_type;
7487 callWaitingRecord.numberPlan = (CdmaCallWaitingNumberPlan) callWaitingRil->number_plan;
7490 RLOGD("cdmaCallWaitingInd");
7492 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaCallWaiting(
7493 convertIntToRadioIndicationType(indicationType), callWaitingRecord);
7494 radioService[slotId]->checkReturnStatus(retStatus);
7496 RLOGE("cdmaCallWaitingInd: radioService[%d]->mRadioIndication == NULL", slotId);
7502 int radio::cdmaOtaProvisionStatusInd(int slotId,
7503 int indicationType, int token, RIL_Errno e, void *response,
7504 size_t responseLen) {
7505 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7506 if (response == NULL || responseLen != sizeof(int)) {
7507 RLOGE("cdmaOtaProvisionStatusInd: invalid response");
7510 int32_t status = ((int32_t *) response)[0];
7512 RLOGD("cdmaOtaProvisionStatusInd: status %d", status);
7514 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaOtaProvisionStatus(
7515 convertIntToRadioIndicationType(indicationType), (CdmaOtaProvisionStatus) status);
7516 radioService[slotId]->checkReturnStatus(retStatus);
7518 RLOGE("cdmaOtaProvisionStatusInd: radioService[%d]->mRadioIndication == NULL",
7525 int radio::cdmaInfoRecInd(int slotId,
7526 int indicationType, int token, RIL_Errno e, void *response,
7527 size_t responseLen) {
7528 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7529 if (response == NULL || responseLen != sizeof(RIL_CDMA_InformationRecords)) {
7530 RLOGE("cdmaInfoRecInd: invalid response");
7534 CdmaInformationRecords records = {};
7535 RIL_CDMA_InformationRecords *recordsRil = (RIL_CDMA_InformationRecords *) response;
7537 char* string8 = NULL;
7538 int num = MIN(recordsRil->numberOfInfoRecs, RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7539 if (recordsRil->numberOfInfoRecs > RIL_CDMA_MAX_NUMBER_OF_INFO_RECS) {
7540 RLOGE("cdmaInfoRecInd: received %d recs which is more than %d, dropping "
7541 "additional ones", recordsRil->numberOfInfoRecs,
7542 RIL_CDMA_MAX_NUMBER_OF_INFO_RECS);
7544 records.infoRec.resize(num);
7545 for (int i = 0 ; i < num ; i++) {
7546 CdmaInformationRecord *record = &records.infoRec[i];
7547 RIL_CDMA_InformationRecord *infoRec = &recordsRil->infoRec[i];
7548 record->name = (CdmaInfoRecName) infoRec->name;
7549 // All vectors should be size 0 except one which will be size 1. Set everything to
7550 // size 0 initially.
7551 record->display.resize(0);
7552 record->number.resize(0);
7553 record->signal.resize(0);
7554 record->redir.resize(0);
7555 record->lineCtrl.resize(0);
7556 record->clir.resize(0);
7557 record->audioCtrl.resize(0);
7558 switch (infoRec->name) {
7559 case RIL_CDMA_DISPLAY_INFO_REC:
7560 case RIL_CDMA_EXTENDED_DISPLAY_INFO_REC: {
7561 if (infoRec->rec.display.alpha_len > CDMA_ALPHA_INFO_BUFFER_LENGTH) {
7562 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7563 "expected not more than %d", (int) infoRec->rec.display.alpha_len,
7564 CDMA_ALPHA_INFO_BUFFER_LENGTH);
7567 string8 = (char*) malloc((infoRec->rec.display.alpha_len + 1) * sizeof(char));
7568 if (string8 == NULL) {
7569 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7570 "responseCdmaInformationRecords");
7573 memcpy(string8, infoRec->rec.display.alpha_buf, infoRec->rec.display.alpha_len);
7574 string8[(int)infoRec->rec.display.alpha_len] = '\0';
7576 record->display.resize(1);
7577 record->display[0].alphaBuf = string8;
7583 case RIL_CDMA_CALLED_PARTY_NUMBER_INFO_REC:
7584 case RIL_CDMA_CALLING_PARTY_NUMBER_INFO_REC:
7585 case RIL_CDMA_CONNECTED_NUMBER_INFO_REC: {
7586 if (infoRec->rec.number.len > CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7587 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7588 "expected not more than %d", (int) infoRec->rec.number.len,
7589 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7592 string8 = (char*) malloc((infoRec->rec.number.len + 1) * sizeof(char));
7593 if (string8 == NULL) {
7594 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7595 "responseCdmaInformationRecords");
7598 memcpy(string8, infoRec->rec.number.buf, infoRec->rec.number.len);
7599 string8[(int)infoRec->rec.number.len] = '\0';
7601 record->number.resize(1);
7602 record->number[0].number = string8;
7605 record->number[0].numberType = infoRec->rec.number.number_type;
7606 record->number[0].numberPlan = infoRec->rec.number.number_plan;
7607 record->number[0].pi = infoRec->rec.number.pi;
7608 record->number[0].si = infoRec->rec.number.si;
7612 case RIL_CDMA_SIGNAL_INFO_REC: {
7613 record->signal.resize(1);
7614 record->signal[0].isPresent = infoRec->rec.signal.isPresent;
7615 record->signal[0].signalType = infoRec->rec.signal.signalType;
7616 record->signal[0].alertPitch = infoRec->rec.signal.alertPitch;
7617 record->signal[0].signal = infoRec->rec.signal.signal;
7621 case RIL_CDMA_REDIRECTING_NUMBER_INFO_REC: {
7622 if (infoRec->rec.redir.redirectingNumber.len >
7623 CDMA_NUMBER_INFO_BUFFER_LENGTH) {
7624 RLOGE("cdmaInfoRecInd: invalid display info response length %d "
7625 "expected not more than %d\n",
7626 (int)infoRec->rec.redir.redirectingNumber.len,
7627 CDMA_NUMBER_INFO_BUFFER_LENGTH);
7630 string8 = (char*) malloc((infoRec->rec.redir.redirectingNumber.len + 1) *
7632 if (string8 == NULL) {
7633 RLOGE("cdmaInfoRecInd: Memory allocation failed for "
7634 "responseCdmaInformationRecords");
7637 memcpy(string8, infoRec->rec.redir.redirectingNumber.buf,
7638 infoRec->rec.redir.redirectingNumber.len);
7639 string8[(int)infoRec->rec.redir.redirectingNumber.len] = '\0';
7641 record->redir.resize(1);
7642 record->redir[0].redirectingNumber.number = string8;
7645 record->redir[0].redirectingNumber.numberType =
7646 infoRec->rec.redir.redirectingNumber.number_type;
7647 record->redir[0].redirectingNumber.numberPlan =
7648 infoRec->rec.redir.redirectingNumber.number_plan;
7649 record->redir[0].redirectingNumber.pi = infoRec->rec.redir.redirectingNumber.pi;
7650 record->redir[0].redirectingNumber.si = infoRec->rec.redir.redirectingNumber.si;
7651 record->redir[0].redirectingReason =
7652 (CdmaRedirectingReason) infoRec->rec.redir.redirectingReason;
7656 case RIL_CDMA_LINE_CONTROL_INFO_REC: {
7657 record->lineCtrl.resize(1);
7658 record->lineCtrl[0].lineCtrlPolarityIncluded =
7659 infoRec->rec.lineCtrl.lineCtrlPolarityIncluded;
7660 record->lineCtrl[0].lineCtrlToggle = infoRec->rec.lineCtrl.lineCtrlToggle;
7661 record->lineCtrl[0].lineCtrlReverse = infoRec->rec.lineCtrl.lineCtrlReverse;
7662 record->lineCtrl[0].lineCtrlPowerDenial =
7663 infoRec->rec.lineCtrl.lineCtrlPowerDenial;
7667 case RIL_CDMA_T53_CLIR_INFO_REC: {
7668 record->clir.resize(1);
7669 record->clir[0].cause = infoRec->rec.clir.cause;
7673 case RIL_CDMA_T53_AUDIO_CONTROL_INFO_REC: {
7674 record->audioCtrl.resize(1);
7675 record->audioCtrl[0].upLink = infoRec->rec.audioCtrl.upLink;
7676 record->audioCtrl[0].downLink = infoRec->rec.audioCtrl.downLink;
7680 case RIL_CDMA_T53_RELEASE_INFO_REC:
7681 RLOGE("cdmaInfoRecInd: RIL_CDMA_T53_RELEASE_INFO_REC: INVALID");
7685 RLOGE("cdmaInfoRecInd: Incorrect name value");
7691 RLOGD("cdmaInfoRecInd");
7693 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaInfoRec(
7694 convertIntToRadioIndicationType(indicationType), records);
7695 radioService[slotId]->checkReturnStatus(retStatus);
7697 RLOGE("cdmaInfoRecInd: radioService[%d]->mRadioIndication == NULL", slotId);
7703 int radio::indicateRingbackToneInd(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("indicateRingbackToneInd: invalid response");
7711 bool start = ((int32_t *) response)[0];
7713 RLOGD("indicateRingbackToneInd: start %d", start);
7715 Return<void> retStatus = radioService[slotId]->mRadioIndication->indicateRingbackTone(
7716 convertIntToRadioIndicationType(indicationType), start);
7717 radioService[slotId]->checkReturnStatus(retStatus);
7719 RLOGE("indicateRingbackToneInd: radioService[%d]->mRadioIndication == NULL", slotId);
7725 int radio::resendIncallMuteInd(int slotId,
7726 int indicationType, int token, RIL_Errno e, void *response,
7727 size_t responseLen) {
7728 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7730 RLOGD("resendIncallMuteInd");
7732 Return<void> retStatus = radioService[slotId]->mRadioIndication->resendIncallMute(
7733 convertIntToRadioIndicationType(indicationType));
7734 radioService[slotId]->checkReturnStatus(retStatus);
7736 RLOGE("resendIncallMuteInd: radioService[%d]->mRadioIndication == NULL", slotId);
7742 int radio::cdmaSubscriptionSourceChangedInd(int slotId,
7743 int indicationType, int token, RIL_Errno e,
7744 void *response, size_t responseLen) {
7745 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7746 if (response == NULL || responseLen != sizeof(int)) {
7747 RLOGE("cdmaSubscriptionSourceChangedInd: invalid response");
7750 int32_t cdmaSource = ((int32_t *) response)[0];
7752 RLOGD("cdmaSubscriptionSourceChangedInd: cdmaSource %d", cdmaSource);
7754 Return<void> retStatus = radioService[slotId]->mRadioIndication->
7755 cdmaSubscriptionSourceChanged(convertIntToRadioIndicationType(indicationType),
7756 (CdmaSubscriptionSource) cdmaSource);
7757 radioService[slotId]->checkReturnStatus(retStatus);
7759 RLOGE("cdmaSubscriptionSourceChangedInd: radioService[%d]->mRadioIndication == NULL",
7766 int radio::cdmaPrlChangedInd(int slotId,
7767 int indicationType, int token, RIL_Errno e, void *response,
7768 size_t responseLen) {
7769 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7770 if (response == NULL || responseLen != sizeof(int)) {
7771 RLOGE("cdmaPrlChangedInd: invalid response");
7774 int32_t version = ((int32_t *) response)[0];
7776 RLOGD("cdmaPrlChangedInd: version %d", version);
7778 Return<void> retStatus = radioService[slotId]->mRadioIndication->cdmaPrlChanged(
7779 convertIntToRadioIndicationType(indicationType), version);
7780 radioService[slotId]->checkReturnStatus(retStatus);
7782 RLOGE("cdmaPrlChangedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7788 int radio::exitEmergencyCallbackModeInd(int slotId,
7789 int indicationType, int token, RIL_Errno e, void *response,
7790 size_t responseLen) {
7791 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7793 RLOGD("exitEmergencyCallbackModeInd");
7795 Return<void> retStatus = radioService[slotId]->mRadioIndication->exitEmergencyCallbackMode(
7796 convertIntToRadioIndicationType(indicationType));
7797 radioService[slotId]->checkReturnStatus(retStatus);
7799 RLOGE("exitEmergencyCallbackModeInd: radioService[%d]->mRadioIndication == NULL",
7806 int radio::rilConnectedInd(int slotId,
7807 int indicationType, int token, RIL_Errno e, void *response,
7808 size_t responseLen) {
7809 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7810 RLOGD("rilConnectedInd");
7811 Return<void> retStatus = radioService[slotId]->mRadioIndication->rilConnected(
7812 convertIntToRadioIndicationType(indicationType));
7813 radioService[slotId]->checkReturnStatus(retStatus);
7815 RLOGE("rilConnectedInd: radioService[%d]->mRadioIndication == NULL", slotId);
7821 int radio::voiceRadioTechChangedInd(int slotId,
7822 int indicationType, int token, RIL_Errno e, void *response,
7823 size_t responseLen) {
7824 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7825 if (response == NULL || responseLen != sizeof(int)) {
7826 RLOGE("voiceRadioTechChangedInd: invalid response");
7829 int32_t rat = ((int32_t *) response)[0];
7831 RLOGD("voiceRadioTechChangedInd: rat %d", rat);
7833 Return<void> retStatus = radioService[slotId]->mRadioIndication->voiceRadioTechChanged(
7834 convertIntToRadioIndicationType(indicationType), (RadioTechnology) rat);
7835 radioService[slotId]->checkReturnStatus(retStatus);
7837 RLOGE("voiceRadioTechChangedInd: radioService[%d]->mRadioIndication == NULL",
7844 void convertRilCellInfoListToHal(void *response, size_t responseLen, hidl_vec<CellInfo>& records) {
7845 int num = responseLen / sizeof(RIL_CellInfo_v12);
7846 records.resize(num);
7848 RIL_CellInfo_v12 *rillCellInfo = (RIL_CellInfo_v12 *) response;
7849 for (int i = 0; i < num; i++) {
7850 records[i].cellInfoType = (CellInfoType) rillCellInfo->cellInfoType;
7851 records[i].registered = rillCellInfo->registered;
7852 records[i].timeStampType = (TimeStampType) rillCellInfo->timeStampType;
7853 records[i].timeStamp = rillCellInfo->timeStamp;
7854 // All vectors should be size 0 except one which will be size 1. Set everything to
7855 // size 0 initially.
7856 records[i].gsm.resize(0);
7857 records[i].wcdma.resize(0);
7858 records[i].cdma.resize(0);
7859 records[i].lte.resize(0);
7860 records[i].tdscdma.resize(0);
7861 switch(rillCellInfo->cellInfoType) {
7862 case RIL_CELL_INFO_TYPE_GSM: {
7863 records[i].gsm.resize(1);
7864 CellInfoGsm *cellInfoGsm = &records[i].gsm[0];
7865 cellInfoGsm->cellIdentityGsm.mcc =
7866 std::to_string(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mcc);
7867 cellInfoGsm->cellIdentityGsm.mnc =
7868 ril::util::mnc::decode(rillCellInfo->CellInfo.gsm.cellIdentityGsm.mnc);
7869 cellInfoGsm->cellIdentityGsm.lac =
7870 rillCellInfo->CellInfo.gsm.cellIdentityGsm.lac;
7871 cellInfoGsm->cellIdentityGsm.cid =
7872 rillCellInfo->CellInfo.gsm.cellIdentityGsm.cid;
7873 cellInfoGsm->cellIdentityGsm.arfcn =
7874 rillCellInfo->CellInfo.gsm.cellIdentityGsm.arfcn;
7875 cellInfoGsm->cellIdentityGsm.bsic =
7876 rillCellInfo->CellInfo.gsm.cellIdentityGsm.bsic;
7877 cellInfoGsm->signalStrengthGsm.signalStrength =
7878 rillCellInfo->CellInfo.gsm.signalStrengthGsm.signalStrength;
7879 cellInfoGsm->signalStrengthGsm.bitErrorRate =
7880 rillCellInfo->CellInfo.gsm.signalStrengthGsm.bitErrorRate;
7881 cellInfoGsm->signalStrengthGsm.timingAdvance =
7882 rillCellInfo->CellInfo.gsm.signalStrengthGsm.timingAdvance;
7886 case RIL_CELL_INFO_TYPE_WCDMA: {
7887 records[i].wcdma.resize(1);
7888 CellInfoWcdma *cellInfoWcdma = &records[i].wcdma[0];
7889 cellInfoWcdma->cellIdentityWcdma.mcc =
7890 std::to_string(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mcc);
7891 cellInfoWcdma->cellIdentityWcdma.mnc =
7892 ril::util::mnc::decode(rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.mnc);
7893 cellInfoWcdma->cellIdentityWcdma.lac =
7894 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.lac;
7895 cellInfoWcdma->cellIdentityWcdma.cid =
7896 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.cid;
7897 cellInfoWcdma->cellIdentityWcdma.psc =
7898 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.psc;
7899 cellInfoWcdma->cellIdentityWcdma.uarfcn =
7900 rillCellInfo->CellInfo.wcdma.cellIdentityWcdma.uarfcn;
7901 cellInfoWcdma->signalStrengthWcdma.signalStrength =
7902 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.signalStrength;
7903 cellInfoWcdma->signalStrengthWcdma.bitErrorRate =
7904 rillCellInfo->CellInfo.wcdma.signalStrengthWcdma.bitErrorRate;
7908 case RIL_CELL_INFO_TYPE_CDMA: {
7909 records[i].cdma.resize(1);
7910 CellInfoCdma *cellInfoCdma = &records[i].cdma[0];
7911 cellInfoCdma->cellIdentityCdma.networkId =
7912 rillCellInfo->CellInfo.cdma.cellIdentityCdma.networkId;
7913 cellInfoCdma->cellIdentityCdma.systemId =
7914 rillCellInfo->CellInfo.cdma.cellIdentityCdma.systemId;
7915 cellInfoCdma->cellIdentityCdma.baseStationId =
7916 rillCellInfo->CellInfo.cdma.cellIdentityCdma.basestationId;
7917 cellInfoCdma->cellIdentityCdma.longitude =
7918 rillCellInfo->CellInfo.cdma.cellIdentityCdma.longitude;
7919 cellInfoCdma->cellIdentityCdma.latitude =
7920 rillCellInfo->CellInfo.cdma.cellIdentityCdma.latitude;
7921 cellInfoCdma->signalStrengthCdma.dbm =
7922 rillCellInfo->CellInfo.cdma.signalStrengthCdma.dbm;
7923 cellInfoCdma->signalStrengthCdma.ecio =
7924 rillCellInfo->CellInfo.cdma.signalStrengthCdma.ecio;
7925 cellInfoCdma->signalStrengthEvdo.dbm =
7926 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.dbm;
7927 cellInfoCdma->signalStrengthEvdo.ecio =
7928 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.ecio;
7929 cellInfoCdma->signalStrengthEvdo.signalNoiseRatio =
7930 rillCellInfo->CellInfo.cdma.signalStrengthEvdo.signalNoiseRatio;
7934 case RIL_CELL_INFO_TYPE_LTE: {
7935 records[i].lte.resize(1);
7936 CellInfoLte *cellInfoLte = &records[i].lte[0];
7937 cellInfoLte->cellIdentityLte.mcc =
7938 std::to_string(rillCellInfo->CellInfo.lte.cellIdentityLte.mcc);
7939 cellInfoLte->cellIdentityLte.mnc =
7940 ril::util::mnc::decode(rillCellInfo->CellInfo.lte.cellIdentityLte.mnc);
7941 cellInfoLte->cellIdentityLte.ci =
7942 rillCellInfo->CellInfo.lte.cellIdentityLte.ci;
7943 cellInfoLte->cellIdentityLte.pci =
7944 rillCellInfo->CellInfo.lte.cellIdentityLte.pci;
7945 cellInfoLte->cellIdentityLte.tac =
7946 rillCellInfo->CellInfo.lte.cellIdentityLte.tac;
7947 cellInfoLte->cellIdentityLte.earfcn =
7948 rillCellInfo->CellInfo.lte.cellIdentityLte.earfcn;
7949 cellInfoLte->signalStrengthLte.signalStrength =
7950 rillCellInfo->CellInfo.lte.signalStrengthLte.signalStrength;
7951 cellInfoLte->signalStrengthLte.rsrp =
7952 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrp;
7953 cellInfoLte->signalStrengthLte.rsrq =
7954 rillCellInfo->CellInfo.lte.signalStrengthLte.rsrq;
7955 cellInfoLte->signalStrengthLte.rssnr =
7956 rillCellInfo->CellInfo.lte.signalStrengthLte.rssnr;
7957 cellInfoLte->signalStrengthLte.cqi =
7958 rillCellInfo->CellInfo.lte.signalStrengthLte.cqi;
7959 cellInfoLte->signalStrengthLte.timingAdvance =
7960 rillCellInfo->CellInfo.lte.signalStrengthLte.timingAdvance;
7964 case RIL_CELL_INFO_TYPE_TD_SCDMA: {
7965 records[i].tdscdma.resize(1);
7966 CellInfoTdscdma *cellInfoTdscdma = &records[i].tdscdma[0];
7967 cellInfoTdscdma->cellIdentityTdscdma.mcc =
7968 std::to_string(rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mcc);
7969 cellInfoTdscdma->cellIdentityTdscdma.mnc =
7970 ril::util::mnc::decode(
7971 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.mnc);
7972 cellInfoTdscdma->cellIdentityTdscdma.lac =
7973 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.lac;
7974 cellInfoTdscdma->cellIdentityTdscdma.cid =
7975 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cid;
7976 cellInfoTdscdma->cellIdentityTdscdma.cpid =
7977 rillCellInfo->CellInfo.tdscdma.cellIdentityTdscdma.cpid;
7978 cellInfoTdscdma->signalStrengthTdscdma.rscp =
7979 rillCellInfo->CellInfo.tdscdma.signalStrengthTdscdma.rscp;
7990 int radio::cellInfoListInd(int slotId,
7991 int indicationType, int token, RIL_Errno e, void *response,
7992 size_t responseLen) {
7993 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
7994 if ((response == NULL && responseLen != 0) || responseLen % sizeof(RIL_CellInfo_v12) != 0) {
7995 RLOGE("cellInfoListInd: invalid response");
7999 hidl_vec<CellInfo> records;
8000 convertRilCellInfoListToHal(response, responseLen, records);
8003 RLOGD("cellInfoListInd");
8005 Return<void> retStatus = radioService[slotId]->mRadioIndication->cellInfoList(
8006 convertIntToRadioIndicationType(indicationType), records);
8007 radioService[slotId]->checkReturnStatus(retStatus);
8009 RLOGE("cellInfoListInd: radioService[%d]->mRadioIndication == NULL", slotId);
8015 int radio::imsNetworkStateChangedInd(int slotId,
8016 int indicationType, int token, RIL_Errno e, void *response,
8017 size_t responseLen) {
8018 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8020 RLOGD("imsNetworkStateChangedInd");
8022 Return<void> retStatus = radioService[slotId]->mRadioIndication->imsNetworkStateChanged(
8023 convertIntToRadioIndicationType(indicationType));
8024 radioService[slotId]->checkReturnStatus(retStatus);
8026 RLOGE("imsNetworkStateChangedInd: radioService[%d]->mRadioIndication == NULL",
8033 int radio::subscriptionStatusChangedInd(int slotId,
8034 int indicationType, int token, RIL_Errno e, void *response,
8035 size_t responseLen) {
8036 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8037 if (response == NULL || responseLen != sizeof(int)) {
8038 RLOGE("subscriptionStatusChangedInd: invalid response");
8041 bool activate = ((int32_t *) response)[0];
8043 RLOGD("subscriptionStatusChangedInd: activate %d", activate);
8045 Return<void> retStatus = radioService[slotId]->mRadioIndication->subscriptionStatusChanged(
8046 convertIntToRadioIndicationType(indicationType), activate);
8047 radioService[slotId]->checkReturnStatus(retStatus);
8049 RLOGE("subscriptionStatusChangedInd: radioService[%d]->mRadioIndication == NULL",
8056 int radio::srvccStateNotifyInd(int slotId,
8057 int indicationType, int token, RIL_Errno e, void *response,
8058 size_t responseLen) {
8059 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8060 if (response == NULL || responseLen != sizeof(int)) {
8061 RLOGE("srvccStateNotifyInd: invalid response");
8064 int32_t state = ((int32_t *) response)[0];
8066 RLOGD("srvccStateNotifyInd: rat %d", state);
8068 Return<void> retStatus = radioService[slotId]->mRadioIndication->srvccStateNotify(
8069 convertIntToRadioIndicationType(indicationType), (SrvccState) state);
8070 radioService[slotId]->checkReturnStatus(retStatus);
8072 RLOGE("srvccStateNotifyInd: radioService[%d]->mRadioIndication == NULL", slotId);
8078 void convertRilHardwareConfigListToHal(void *response, size_t responseLen,
8079 hidl_vec<HardwareConfig>& records) {
8080 int num = responseLen / sizeof(RIL_HardwareConfig);
8081 records.resize(num);
8083 RIL_HardwareConfig *rilHardwareConfig = (RIL_HardwareConfig *) response;
8084 for (int i = 0; i < num; i++) {
8085 records[i].type = (HardwareConfigType) rilHardwareConfig[i].type;
8086 records[i].uuid = convertCharPtrToHidlString(rilHardwareConfig[i].uuid);
8087 records[i].state = (HardwareConfigState) rilHardwareConfig[i].state;
8088 switch (rilHardwareConfig[i].type) {
8089 case RIL_HARDWARE_CONFIG_MODEM: {
8090 records[i].modem.resize(1);
8091 records[i].sim.resize(0);
8092 HardwareConfigModem *hwConfigModem = &records[i].modem[0];
8093 hwConfigModem->rat = rilHardwareConfig[i].cfg.modem.rat;
8094 hwConfigModem->maxVoice = rilHardwareConfig[i].cfg.modem.maxVoice;
8095 hwConfigModem->maxData = rilHardwareConfig[i].cfg.modem.maxData;
8096 hwConfigModem->maxStandby = rilHardwareConfig[i].cfg.modem.maxStandby;
8100 case RIL_HARDWARE_CONFIG_SIM: {
8101 records[i].sim.resize(1);
8102 records[i].modem.resize(0);
8103 records[i].sim[0].modemUuid =
8104 convertCharPtrToHidlString(rilHardwareConfig[i].cfg.sim.modemUuid);
8111 int radio::hardwareConfigChangedInd(int slotId,
8112 int indicationType, int token, RIL_Errno e, void *response,
8113 size_t responseLen) {
8114 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8115 if ((response == NULL && responseLen != 0)
8116 || responseLen % sizeof(RIL_HardwareConfig) != 0) {
8117 RLOGE("hardwareConfigChangedInd: invalid response");
8121 hidl_vec<HardwareConfig> configs;
8122 convertRilHardwareConfigListToHal(response, responseLen, configs);
8125 RLOGD("hardwareConfigChangedInd");
8127 Return<void> retStatus = radioService[slotId]->mRadioIndication->hardwareConfigChanged(
8128 convertIntToRadioIndicationType(indicationType), configs);
8129 radioService[slotId]->checkReturnStatus(retStatus);
8131 RLOGE("hardwareConfigChangedInd: radioService[%d]->mRadioIndication == NULL",
8138 void convertRilRadioCapabilityToHal(void *response, size_t responseLen, RadioCapability& rc) {
8139 RIL_RadioCapability *rilRadioCapability = (RIL_RadioCapability *) response;
8140 rc.session = rilRadioCapability->session;
8141 rc.phase = (V1_0::RadioCapabilityPhase) rilRadioCapability->phase;
8142 rc.raf = rilRadioCapability->rat;
8143 rc.logicalModemUuid = convertCharPtrToHidlString(rilRadioCapability->logicalModemUuid);
8144 rc.status = (V1_0::RadioCapabilityStatus) rilRadioCapability->status;
8147 int radio::radioCapabilityIndicationInd(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 != sizeof(RIL_RadioCapability)) {
8152 RLOGE("radioCapabilityIndicationInd: invalid response");
8156 RadioCapability rc = {};
8157 convertRilRadioCapabilityToHal(response, responseLen, rc);
8160 RLOGD("radioCapabilityIndicationInd");
8162 Return<void> retStatus = radioService[slotId]->mRadioIndication->radioCapabilityIndication(
8163 convertIntToRadioIndicationType(indicationType), rc);
8164 radioService[slotId]->checkReturnStatus(retStatus);
8166 RLOGE("radioCapabilityIndicationInd: radioService[%d]->mRadioIndication == NULL",
8173 bool isServiceTypeCfQuery(RIL_SsServiceType serType, RIL_SsRequestType reqType) {
8174 if ((reqType == SS_INTERROGATION) &&
8175 (serType == SS_CFU ||
8176 serType == SS_CF_BUSY ||
8177 serType == SS_CF_NO_REPLY ||
8178 serType == SS_CF_NOT_REACHABLE ||
8179 serType == SS_CF_ALL ||
8180 serType == SS_CF_ALL_CONDITIONAL)) {
8186 int radio::onSupplementaryServiceIndicationInd(int slotId,
8187 int indicationType, int token, RIL_Errno e,
8188 void *response, size_t responseLen) {
8189 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8190 if (response == NULL || responseLen != sizeof(RIL_StkCcUnsolSsResponse)) {
8191 RLOGE("onSupplementaryServiceIndicationInd: invalid response");
8195 RIL_StkCcUnsolSsResponse *rilSsResponse = (RIL_StkCcUnsolSsResponse *) response;
8196 StkCcUnsolSsResult ss = {};
8197 ss.serviceType = (SsServiceType) rilSsResponse->serviceType;
8198 ss.requestType = (SsRequestType) rilSsResponse->requestType;
8199 ss.teleserviceType = (SsTeleserviceType) rilSsResponse->teleserviceType;
8200 ss.serviceClass = rilSsResponse->serviceClass;
8201 ss.result = (RadioError) rilSsResponse->result;
8203 if (isServiceTypeCfQuery(rilSsResponse->serviceType, rilSsResponse->requestType)) {
8205 RLOGD("onSupplementaryServiceIndicationInd CF type, num of Cf elements %d",
8206 rilSsResponse->cfData.numValidIndexes);
8208 if (rilSsResponse->cfData.numValidIndexes > NUM_SERVICE_CLASSES) {
8209 RLOGE("onSupplementaryServiceIndicationInd numValidIndexes is greater than "
8210 "max value %d, truncating it to max value", NUM_SERVICE_CLASSES);
8211 rilSsResponse->cfData.numValidIndexes = NUM_SERVICE_CLASSES;
8214 ss.cfData.resize(1);
8215 ss.ssInfo.resize(0);
8217 /* number of call info's */
8218 ss.cfData[0].cfInfo.resize(rilSsResponse->cfData.numValidIndexes);
8220 for (int i = 0; i < rilSsResponse->cfData.numValidIndexes; i++) {
8221 RIL_CallForwardInfo cf = rilSsResponse->cfData.cfInfo[i];
8222 CallForwardInfo *cfInfo = &ss.cfData[0].cfInfo[i];
8224 cfInfo->status = (CallForwardInfoStatus) cf.status;
8225 cfInfo->reason = cf.reason;
8226 cfInfo->serviceClass = cf.serviceClass;
8227 cfInfo->toa = cf.toa;
8228 cfInfo->number = convertCharPtrToHidlString(cf.number);
8229 cfInfo->timeSeconds = cf.timeSeconds;
8231 RLOGD("onSupplementaryServiceIndicationInd: "
8232 "Data: %d,reason=%d,cls=%d,toa=%d,num=%s,tout=%d],", cf.status,
8233 cf.reason, cf.serviceClass, cf.toa, (char*)cf.number, cf.timeSeconds);
8237 ss.ssInfo.resize(1);
8238 ss.cfData.resize(0);
8241 ss.ssInfo[0].ssInfo.resize(SS_INFO_MAX);
8242 for (int i = 0; i < SS_INFO_MAX; i++) {
8244 RLOGD("onSupplementaryServiceIndicationInd: Data: %d",
8245 rilSsResponse->ssInfo[i]);
8247 ss.ssInfo[0].ssInfo[i] = rilSsResponse->ssInfo[i];
8252 RLOGD("onSupplementaryServiceIndicationInd");
8254 Return<void> retStatus = radioService[slotId]->mRadioIndication->
8255 onSupplementaryServiceIndication(convertIntToRadioIndicationType(indicationType),
8257 radioService[slotId]->checkReturnStatus(retStatus);
8259 RLOGE("onSupplementaryServiceIndicationInd: "
8260 "radioService[%d]->mRadioIndication == NULL", slotId);
8266 int radio::stkCallControlAlphaNotifyInd(int slotId,
8267 int indicationType, int token, RIL_Errno e, void *response,
8268 size_t responseLen) {
8269 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8270 if (response == NULL || responseLen == 0) {
8271 RLOGE("stkCallControlAlphaNotifyInd: invalid response");
8275 RLOGD("stkCallControlAlphaNotifyInd");
8277 Return<void> retStatus = radioService[slotId]->mRadioIndication->stkCallControlAlphaNotify(
8278 convertIntToRadioIndicationType(indicationType),
8279 convertCharPtrToHidlString((char *) response));
8280 radioService[slotId]->checkReturnStatus(retStatus);
8282 RLOGE("stkCallControlAlphaNotifyInd: radioService[%d]->mRadioIndication == NULL",
8289 void convertRilLceDataInfoToHal(void *response, size_t responseLen, LceDataInfo& lce) {
8290 RIL_LceDataInfo *rilLceDataInfo = (RIL_LceDataInfo *)response;
8291 lce.lastHopCapacityKbps = rilLceDataInfo->last_hop_capacity_kbps;
8292 lce.confidenceLevel = rilLceDataInfo->confidence_level;
8293 lce.lceSuspended = rilLceDataInfo->lce_suspended;
8296 int radio::lceDataInd(int slotId,
8297 int indicationType, int token, RIL_Errno e, void *response,
8298 size_t responseLen) {
8299 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8300 if (response == NULL || responseLen != sizeof(RIL_LceDataInfo)) {
8301 RLOGE("lceDataInd: invalid response");
8305 LceDataInfo lce = {};
8306 convertRilLceDataInfoToHal(response, responseLen, lce);
8308 RLOGD("lceDataInd");
8310 Return<void> retStatus = radioService[slotId]->mRadioIndication->lceData(
8311 convertIntToRadioIndicationType(indicationType), lce);
8312 radioService[slotId]->checkReturnStatus(retStatus);
8314 RLOGE("lceDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8320 int radio::pcoDataInd(int slotId,
8321 int indicationType, int token, RIL_Errno e, void *response,
8322 size_t responseLen) {
8323 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8324 if (response == NULL || responseLen != sizeof(RIL_PCO_Data)) {
8325 RLOGE("pcoDataInd: invalid response");
8329 PcoDataInfo pco = {};
8330 RIL_PCO_Data *rilPcoData = (RIL_PCO_Data *)response;
8331 pco.cid = rilPcoData->cid;
8332 pco.bearerProto = convertCharPtrToHidlString(rilPcoData->bearer_proto);
8333 pco.pcoId = rilPcoData->pco_id;
8334 pco.contents.setToExternal((uint8_t *) rilPcoData->contents, rilPcoData->contents_length);
8337 RLOGD("pcoDataInd");
8339 Return<void> retStatus = radioService[slotId]->mRadioIndication->pcoData(
8340 convertIntToRadioIndicationType(indicationType), pco);
8341 radioService[slotId]->checkReturnStatus(retStatus);
8343 RLOGE("pcoDataInd: radioService[%d]->mRadioIndication == NULL", slotId);
8349 int radio::modemResetInd(int slotId,
8350 int indicationType, int token, RIL_Errno e, void *response,
8351 size_t responseLen) {
8352 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndication != NULL) {
8353 if (response == NULL || responseLen == 0) {
8354 RLOGE("modemResetInd: invalid response");
8358 RLOGD("modemResetInd");
8360 Return<void> retStatus = radioService[slotId]->mRadioIndication->modemReset(
8361 convertIntToRadioIndicationType(indicationType),
8362 convertCharPtrToHidlString((char *) response));
8363 radioService[slotId]->checkReturnStatus(retStatus);
8365 RLOGE("modemResetInd: radioService[%d]->mRadioIndication == NULL", slotId);
8371 int radio::networkScanResultInd(int slotId,
8372 int indicationType, int token, RIL_Errno e, void *response,
8373 size_t responseLen) {
8375 RLOGD("networkScanResultInd");
8377 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8378 if (response == NULL || responseLen == 0) {
8379 RLOGE("networkScanResultInd: invalid response");
8382 RLOGD("networkScanResultInd");
8385 RLOGD("networkScanResultInd");
8388 RIL_NetworkScanResult *networkScanResult = (RIL_NetworkScanResult *) response;
8390 V1_1::NetworkScanResult result;
8391 result.status = (V1_1::ScanStatus) networkScanResult->status;
8392 result.error = (RadioError) networkScanResult->error;
8393 convertRilCellInfoListToHal(
8394 networkScanResult->network_infos,
8395 networkScanResult->network_infos_length * sizeof(RIL_CellInfo_v12),
8396 result.networkInfos);
8398 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->networkScanResult(
8399 convertIntToRadioIndicationType(indicationType), result);
8400 radioService[slotId]->checkReturnStatus(retStatus);
8402 RLOGE("networkScanResultInd: radioService[%d]->mRadioIndicationV1_1 == NULL", slotId);
8407 int radio::carrierInfoForImsiEncryption(int slotId,
8408 int indicationType, int token, RIL_Errno e, void *response,
8409 size_t responseLen) {
8410 if (radioService[slotId] != NULL && radioService[slotId]->mRadioIndicationV1_1 != NULL) {
8411 if (response == NULL || responseLen == 0) {
8412 RLOGE("carrierInfoForImsiEncryption: invalid response");
8415 RLOGD("carrierInfoForImsiEncryption");
8416 Return<void> retStatus = radioService[slotId]->mRadioIndicationV1_1->
8417 carrierInfoForImsiEncryption(convertIntToRadioIndicationType(indicationType));
8418 radioService[slotId]->checkReturnStatus(retStatus);
8420 RLOGE("carrierInfoForImsiEncryption: radioService[%d]->mRadioIndicationV1_1 == NULL",
8427 int radio::keepaliveStatusInd(int slotId,
8428 int indicationType, int token, RIL_Errno e, void *response,
8429 size_t responseLen) {
8431 RLOGD("%s(): token=%d", __FUNCTION__, token);
8433 if (radioService[slotId] == NULL || radioService[slotId]->mRadioIndication == NULL) {
8434 RLOGE("%s: radioService[%d]->mRadioIndication == NULL", __FUNCTION__, slotId);
8438 auto ret = V1_1::IRadioIndication::castFrom(
8439 radioService[slotId]->mRadioIndication);
8441 RLOGE("%s: ret.isOk() == false for radioService[%d]", __FUNCTION__, slotId);
8444 sp<V1_1::IRadioIndication> radioIndicationV1_1 = ret;
8446 if (response == NULL || responseLen != sizeof(V1_1::KeepaliveStatus)) {
8447 RLOGE("%s: invalid response", __FUNCTION__);
8451 V1_1::KeepaliveStatus ks;
8452 convertRilKeepaliveStatusToHal(static_cast<RIL_KeepaliveStatus*>(response), ks);
8454 Return<void> retStatus = radioIndicationV1_1->keepaliveStatus(
8455 convertIntToRadioIndicationType(indicationType), ks);
8456 radioService[slotId]->checkReturnStatus(retStatus);
8460 int radio::oemHookRawInd(int slotId,
8461 int indicationType, int token, RIL_Errno e, void *response,
8462 size_t responseLen) {
8463 if (!kOemHookEnabled) return 0;
8465 if (oemHookService[slotId] != NULL && oemHookService[slotId]->mOemHookIndication != NULL) {
8466 if (response == NULL || responseLen == 0) {
8467 RLOGE("oemHookRawInd: invalid response");
8471 hidl_vec<uint8_t> data;
8472 data.setToExternal((uint8_t *) response, responseLen);
8474 RLOGD("oemHookRawInd");
8476 Return<void> retStatus = oemHookService[slotId]->mOemHookIndication->oemHookRaw(
8477 convertIntToRadioIndicationType(indicationType), data);
8478 checkReturnStatus(slotId, retStatus, false);
8480 RLOGE("oemHookRawInd: oemHookService[%d]->mOemHookIndication == NULL", slotId);
8486 void radio::registerService(RIL_RadioFunctions *callbacks, CommandInfo *commands) {
8487 using namespace android::hardware;
8489 const char *serviceNames[] = {
8490 android::RIL_getServiceName()
8491 #if (SIM_COUNT >= 2)
8493 #if (SIM_COUNT >= 3)
8495 #if (SIM_COUNT >= 4)
8502 #if (SIM_COUNT >= 2)
8503 simCount = SIM_COUNT;
8506 s_vendorFunctions = callbacks;
8507 s_commands = commands;
8509 configureRpcThreadpool(1, true /* callerWillJoin */);
8510 for (int i = 0; i < simCount; i++) {
8511 pthread_rwlock_t *radioServiceRwlockPtr = getRadioServiceRwlock(i);
8512 int ret = pthread_rwlock_wrlock(radioServiceRwlockPtr);
8515 radioService[i] = new RadioImpl;
8516 radioService[i]->mSlotId = i;
8517 RLOGD("registerService: starting android::hardware::radio::V1_1::IRadio %s",
8519 android::status_t status = radioService[i]->registerAsService(serviceNames[i]);
8521 if (kOemHookEnabled) {
8522 oemHookService[i] = new OemHookImpl;
8523 oemHookService[i]->mSlotId = i;
8524 status = oemHookService[i]->registerAsService(serviceNames[i]);
8527 ret = pthread_rwlock_unlock(radioServiceRwlockPtr);
8532 void rilc_thread_pool() {
8533 joinRpcThreadpool();
8536 pthread_rwlock_t * radio::getRadioServiceRwlock(int slotId) {
8537 pthread_rwlock_t *radioServiceRwlockPtr = &radioServiceRwlock;
8539 #if (SIM_COUNT >= 2)
8540 if (slotId == 2) radioServiceRwlockPtr = &radioServiceRwlock2;
8541 #if (SIM_COUNT >= 3)
8542 if (slotId == 3) radioServiceRwlockPtr = &radioServiceRwlock3;
8543 #if (SIM_COUNT >= 4)
8544 if (slotId == 4) radioServiceRwlockPtr = &radioServiceRwlock4;
8549 return radioServiceRwlockPtr;
8552 // should acquire write lock for the corresponding service before calling this
8553 void radio::setNitzTimeReceived(int slotId, long timeReceived) {
8554 nitzTimeReceived[slotId] = timeReceived;